Hi, This patch fixes all my concerns I raised in the previous e-mail. It applies on top of lucas patch. So if you apply 1/2, I'll do this one on top. If everybody agrees that is...
grts
diff -urN a/Makefile b/Makefile
--- a/Makefile 2007-04-14 22:55:32.000000000 +0200
+++ b/Makefile 2007-04-14 22:52:34.000000000 +0200
@@ -14,7 +14,7 @@
###############################################################
-ARCH:=$(shell uname -m)
+ARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/ppc.*/ppc/)
CC_FLAGS=-I/usr/local/include -DS2RAM $(CFLAGS)
LD_FLAGS=-L/usr/local/lib
@@ -22,11 +22,18 @@
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
SWSUSP_OBJ=vt.o md5.o encrypt.o config.o loglevel.o splash.o bootsplash.o
-S2RAM_LD_FLAGS = $(LD_FLAGS) -lpci -lz -lx86
+S2RAM_LD_FLAGS = $(LD_FLAGS)
SWSUSP_LD_FLAGS = $(LD_FLAGS)
+ARCH=ppc
+ifeq ($(ARCH), x86)
+ S2RAM_OBJ += s2ram-x86.o dmidecode.o radeontool.o vbetool/vbetool.o
+ S2RAM_LD_FLAGS += -lx86 -lpci -lz
+else ifeq ($(ARCH), ppc)
+ S2RAM_OBJ += s2ram-ppc.o
+endif
ifndef CONFIG_RESUME_DYN
STATIC_LD_FLAGS = -static
@@ -81,13 +88,13 @@
$(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 $@
# Simple objects with header
-config.o vt.o bootsplash.o splash.o splashy_funcs.o vbetool/vbetool.o: %.o :
%.c %.h
+config.o vt.o bootsplash.o splash.o splashy_funcs.o vbetool/vbetool.o
s2ram-ppc.o s2ram-x86.o: %.o : %.c %.h
$(CC) $(CC_FLAGS) -c $< -o $@
# Simple object without header
@@ -98,11 +105,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
$(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
+ $(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)
diff -urN a/s2ram.c b/s2ram.c
--- a/s2ram.c 2007-04-14 21:51:22.000000000 +0200
+++ b/s2ram.c 2007-04-14 22:52:34.000000000 +0200
@@ -27,7 +27,16 @@
int s2ram_do(void)
{
int ret = 0;
- FILE *f = fopen("/sys/power/state", "w");
+ FILE *f;
+
+ /* If this works we're done. Else we just continue as if nothing
+ * happened, future kernels will work with /s/p/s. */
+ ret = s2ram_do_pmu();
+ if (!ret)
+ return ret;
+ ret = 0;
+
+ f = fopen("/sys/power/state", "w");
if (!f) {
printf("/sys/power/state does not exist; what kind of ninja
mutant machine is this?\n");
return ENODEV;
diff -urN a/s2ram.h b/s2ram.h
--- a/s2ram.h 2007-04-14 21:51:22.000000000 +0200
+++ b/s2ram.h 2007-04-14 22:52:34.000000000 +0200
@@ -30,5 +30,5 @@
int s2ram_do(void);
void s2ram_resume(void);
void s2ram_add_flag(int opt, const char *arg);
-
+int s2ram_do_pmu(void);
diff -urN a/s2ram-ppc.c b/s2ram-ppc.c
--- a/s2ram-ppc.c 1970-01-01 01:00:00.000000000 +0100
+++ b/s2ram-ppc.c 2007-04-14 22:52:34.000000000 +0200
@@ -0,0 +1,81 @@
+#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_hacks(void) {
+ return 0;
+}
+
+int s2ram_is_supported(void) {
+ int fd, ret = 0;
+ unsigned long arg = 0;
+
+ /* PMU_IOC_CAN_SLEEP is going away, so we only say unsupported
+ * if PMU_IOC_CAN_SLEEP explicitly says we can't */
+ fd = open("/dev/pmu", O_RDWR);
+ if (fd < 0)
+ return 0;
+
+ ret = ioctl(fd, PMU_IOC_CAN_SLEEP, &arg);
+ if (!ret && arg != 1)
+ ret = ENOTSUP;
+
+ close(fd);
+
+ return 0;
+}
+
+int s2ram_do_pmu (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;
+
+ if (!ret)
+ ret = ioctl(fd, PMU_IOC_SLEEP, 0);
+
+ if (ret)
+ ret = errno;
+
+ close(fd);
+
+ return ret;
+}
+
+
diff -urN a/s2ram-ppc.h b/s2ram-ppc.h
--- a/s2ram-ppc.h 1970-01-01 01:00:00.000000000 +0100
+++ b/s2ram-ppc.h 2007-04-14 22:52:34.000000000 +0200
@@ -0,0 +1,2 @@
+/* No additional options for PPC */
+#define S2RAM_PLATFORM_OPTS
diff -urN a/s2ram-x86.c b/s2ram-x86.c
--- a/s2ram-x86.c 2007-04-14 21:51:22.000000000 +0200
+++ b/s2ram-x86.c 2007-04-14 22:52:34.000000000 +0200
@@ -329,3 +329,7 @@
}
}
+int s2ram_do_pmu (void) {
+ return ENODEV;
+}
+
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
