On Wed, 11 Apr 2007 00:19:35 +0200
Luca Tettamanti <[EMAIL PROTECTED]> wrote:

> 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.
> 
> 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/ )
> +

This seems a bit overkill, I don't think we'll ever support s390 or parisc.
And if we do we can add them then. x86 and ppc seems enough for me. According

> +is_arch = $(shell test $(ARCH) == $(1) && echo 1)
> +
> +ifeq ($(call is_arch, "x86"), 1)
> +     s2ram_extra = dmidecode.o radeontool.o vbetool/vbetool.o
> +endif

Why can't we do ifeq ($(ARCH), x86) ?

>  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

-lx86 -lpcu -lz are only necessary for s2ram-x86.o

> @@ -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)

We can add s2ram-$(ARCH) to $(S2RAM_OBJ)

>  resume:      resume.c $(SWSUSP_OBJ)
>       $(CC) $(CC_FLAGS) $(STATIC_CC_FLAGS) $^ -o $@ $(STATIC_LD_FLAGS) 
> $(SWSUSP_LD_FLAGS)

There is not rule for s2ram-ppc.o nor s2ram-x86.o

> --- a/s2ram-ppc.c     1970-01-01 01:00:00.000000000 +0100
> +++ b/s2ram-ppc.c     2007-04-10 23:28:09.000000000 +0200
> +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;
> +}

This doesn't take into account the usage in s2both. There s2ram_hacks
is called early on. The actual trigger to suspend is done by doing
ioctl(/dev/snaphost,SUSPEND_TO_RAM) (or something like that). Not by
calling s2ram_do(). It will do roughly the same thing
as /sys/power/state, without the freezing, that was done by calling
freeze()

The whole PMU thing will be deprecated in the next kernel release, I
only added it to s2ram to be nice to people running older kernels. s2both
won't work for them, but that would be impossible to support anyway.


> --- 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

Attachment: signature.asc
Description: PGP signature

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Suspend-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/suspend-devel

Reply via email to