Luca Tettamanti schreef:
> Add s2ram support for PPC architecture. s2ram.{c,h} contain the
> implementation of the required functions, used by the main file. The
> Makefile selects the correct platform files using $(ARCH) variable
> (autodetected by default, can be overridden).
>
> PPC code is based on original patch from Tim Dijkstra.

I haven't looked to closely at it, I can't access my machine right now.
But this patch doesn't seem correct. IIRC, s2ram_hacks is called before we
really suspend the system, but the ppc version would. I'll take a closer
look tomorrow night.

> Signed-Off-By: Luca Tettamanti <[EMAIL PROTECTED]>
>
> ---
>  Makefile    |   22 +++++++++++-----
>  s2ram-ppc.c |   75
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  s2ram-ppc.h |    2 +
>  3 files changed, 93 insertions(+), 6 deletions(-)
> --- a/Makefile        2007-04-10 23:46:38.000000000 +0200
> +++ b/Makefile        2007-04-10 23:47:11.000000000 +0200
> @@ -14,7 +14,17 @@
>
>  ###############################################################
>
> -ARCH:=$(shell uname -m)
> +ARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/sun4u/sparc64/ \
> +                             -e s/arm.*/arm/ -e s/sa110/arm/ \
> +                             -e s/s390x/s390/ -e s/parisc64/parisc/ \
> +                             -e s/ppc.*/ppc/ -e s/mips.*/mips/ )
> +
> +
> +is_arch = $(shell test $(ARCH) == $(1) && echo 1)
> +
> +ifeq ($(call is_arch, "x86"), 1)
> +     s2ram_extra = dmidecode.o radeontool.o vbetool/vbetool.o
> +endif
>
>  CC_FLAGS=-I/usr/local/include -DS2RAM $(CFLAGS)
>  LD_FLAGS=-L/usr/local/lib
> @@ -22,7 +32,7 @@
>  BINARIES=s2disk s2both s2ram swap-offset resume
>  BINARIES_MIN=s2disk swap-offset
>
> -S2RAM_OBJ=vt.o vbetool/vbetool.o radeontool.o dmidecode.o
> +S2RAM_OBJ=vt.o $(s2ram_extra)
>  SWSUSP_OBJ=vt.o md5.o encrypt.o config.o loglevel.o splash.o bootsplash.o
>
>  S2RAM_LD_FLAGS = $(LD_FLAGS) -lpci -lz -lx86
> @@ -81,7 +91,7 @@
>       $(CC) $(CC_FLAGS) -DCONFIG_BOTH -c $< -o $@
>
>  s2ram.o: s2ram.c s2ram.h whitelist.c
> -     $(CC) $(CC_FLAGS) -include s2ram-x86.h -c $< -o $@
> +     $(CC) $(CC_FLAGS) -include s2ram-$(ARCH).h -c $< -o $@
>
>  md5.o encrypt.o: %.o : %.c %.h md5.h
>       $(CC) $(CC_FLAGS) -DHAVE_INTTYPES_H -DHAVE_STDINT_H -c $< -o $@
> @@ -98,11 +108,11 @@
>  s2disk:      $(SWSUSP_OBJ) suspend.c
>       $(CC) -g $(CC_FLAGS)  $^ -o $@ $(SWSUSP_LD_FLAGS)
>
> -s2ram:       $(S2RAM_OBJ) s2ram.o s2ram-x86.o
> +s2ram:       $(S2RAM_OBJ) s2ram.o s2ram-$(ARCH).o
>       $(CC) -g $(CC_FLAGS)  $^ -o $@ $(S2RAM_LD_FLAGS)
>
> -s2both:      $(SWSUSP_OBJ) $(S2RAM_OBJ) s2ram-both.o suspend.c s2ram-x86.o
> -     $(CC) -g $(CC_FLAGS) -DCONFIG_BOTH -include s2ram-x86.h $^ -o $@
> $(SWSUSP_LD_FLAGS) $(S2RAM_LD_FLAGS)
> +s2both:      $(SWSUSP_OBJ) $(S2RAM_OBJ) s2ram-both.o suspend.c 
> s2ram-$(ARCH).o
> +     $(CC) -g $(CC_FLAGS) -DCONFIG_BOTH -include s2ram-$(ARCH).h  $^ -o $@
> $(SWSUSP_LD_FLAGS) $(S2RAM_LD_FLAGS)
>
>  resume:      resume.c $(SWSUSP_OBJ)
>       $(CC) $(CC_FLAGS) $(STATIC_CC_FLAGS) $^ -o $@ $(STATIC_LD_FLAGS)
> $(SWSUSP_LD_FLAGS)
> --- a/s2ram-ppc.c     1970-01-01 01:00:00.000000000 +0100
> +++ b/s2ram-ppc.c     2007-04-10 23:28:09.000000000 +0200
> @@ -0,0 +1,75 @@
> +#include <errno.h>
> +#include <fcntl.h>
> +#include <unistd.h>
> +
> +#include <sys/ioctl.h>
> +#include <sys/types.h>
> +#include <sys/stat.h>
> +
> +#include <linux/pmu.h>
> +
> +#include "s2ram.h"
> +
> +void s2ram_usage_platform(void) {
> +     /* No additional options for PPC */
> +}
> +
> +void s2ram_add_flag(int opt, const char *arg) {
> +}
> +
> +int s2ram_prepare(void)
> +{
> +     return 0;
> +}
> +
> +void s2ram_resume(void)
> +{
> +     /* nop */
> +}
> +
> +void identify_machine(void) {
> +     /* TODO */
> +}
> +
> +int s2ram_is_supported(void) {
> +     int fd;
> +     int ret = 0;
> +     unsigned long arg = 0;
> +
> +     fd = open("/dev/pmu", O_RDWR);
> +     if (fd < 0)
> +             return errno;
> +
> +     ret = ioctl(fd, PMU_IOC_CAN_SLEEP, &arg);
> +     if (!ret && arg != 1)
> +             ret = ENOTSUP;
> +
> +     close(fd);
> +
> +     return ret;
> +}
> +
> +int s2ram_hacks(void) {
> +     int fd;
> +     int ret;
> +     unsigned long args;
> +
> +     fd = open("/dev/pmu", O_RDWR);
> +     if (fd < 0)
> +             return errno;
> +
> +     ret = ioctl(fd, PMU_IOC_SLEEP, 0);
> +     if (ret)
> +             ret = errno;
> +
> +     close(fd);
> +
> +     /* Fake return value: if PMU_IOC_SLEEP failed we return success so that
> +      * s2ram tries with "echo mem > /sys/power/state". On success we
> +      * return EINPROGRESS to make s2ram exit.
> +      */
> +     if (!ret)
> +             return EINPROGRESS;
> +     else
> +             return 0;
> +}
> --- a/s2ram-ppc.h     1970-01-01 01:00:00.000000000 +0100
> +++ b/s2ram-ppc.h     2007-04-10 22:07:20.000000000 +0200
> @@ -0,0 +1,2 @@
> +/* No additional options for PPC */
> +#define S2RAM_PLATFORM_OPTS
>
>
> Luca
> --
> Inquietudine sintetica
> Solo, davanti all'ignoto
> Tienimi stretto a te
>



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Suspend-devel mailing list
Suspend-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/suspend-devel

Reply via email to