summaryrefslogtreecommitdiffstats
path: root/obsolete-buildroot/sources/openwrt/busybox/patches/130-resetmon.patch
blob: b41315e1f7d75b46e41b2c6f3cabd2b25ac08b76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
diff -urN busybox-dist/include/applets.h busybox/include/applets.h
--- busybox-dist/include/applets.h	2004-03-16 09:56:27.000000000 -0600
+++ busybox/include/applets.h	2004-03-16 10:00:14.000000000 -0600
@@ -484,6 +484,9 @@
 #ifdef CONFIG_RESET
 	APPLET(reset, reset_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER)
 #endif
+#ifdef CONFIG_RESETMON
+	APPLET(resetmon, resetmon_main, _BB_DIR_SBIN, _BB_SUID_NEVER)
+#endif
 #ifdef CONFIG_RM
 	APPLET(rm, rm_main, _BB_DIR_BIN, _BB_SUID_NEVER)
 #endif
diff -urN busybox-dist/include/usage.h busybox/include/usage.h
--- busybox-dist/include/usage.h	2004-03-16 09:56:27.000000000 -0600
+++ busybox/include/usage.h	2004-03-16 10:00:14.000000000 -0600
@@ -2024,6 +2024,11 @@
 #define reset_full_usage \
 	"Resets the screen."
 
+#define resetmon_trivial_usage \
+	""
+#define resetmon_full_usage \
+	"Return an exit code of TRUE (0) if reset is NOT pressed."
+
 #define rm_trivial_usage \
 	"[OPTION]... FILE..."
 #define rm_full_usage \
diff -urN busybox-dist/miscutils/Config.in busybox/miscutils/Config.in
--- busybox-dist/miscutils/Config.in	2004-03-15 02:28:46.000000000 -0600
+++ busybox/miscutils/Config.in	2004-03-16 10:00:14.000000000 -0600
@@ -156,6 +156,12 @@
 	  to advance or rewind a tape past a specified number of archive
 	  files on the tape.
 
+config CONFIG_RESETMON
+        bool "resetmon"
+	default y
+	help
+ 	  Linksys wrt54g reset button monitor.  Returns TRUE if NOT pressed.
+
 config CONFIG_RX
         bool "rx"
 	default n
diff -urN busybox-dist/miscutils/Makefile.in busybox/miscutils/Makefile.in
--- busybox-dist/miscutils/Makefile.in	2004-03-15 02:28:46.000000000 -0600
+++ busybox/miscutils/Makefile.in	2004-03-16 10:00:14.000000000 -0600
@@ -33,6 +33,7 @@
 MISCUTILS-$(CONFIG_LAST)		+= last.o
 MISCUTILS-$(CONFIG_MAKEDEVS)		+= makedevs.o
 MISCUTILS-$(CONFIG_MT)			+= mt.o
+MISCUTILS-$(CONFIG_RESETMON)		+= resetmon.o
 MISCUTILS-$(CONFIG_RX)			+= rx.o
 MISCUTILS-$(CONFIG_STRINGS)		+= strings.o
 MISCUTILS-$(CONFIG_TIME)		+= time.o
diff -urN busybox-dist/miscutils/resetmon.c busybox/miscutils/resetmon.c
--- busybox-dist/miscutils/resetmon.c	1969-12-31 18:00:00.000000000 -0600
+++ busybox/miscutils/resetmon.c	2004-03-16 10:00:14.000000000 -0600
@@ -0,0 +1,30 @@
+#include <unistd.h>
+#include <fcntl.h>
+#include "busybox.h"
+
+#define RESET (1<<6) 
+
+int resetmon_main(int argc, char **argv) {
+	int fd = -1;
+	unsigned int val=0;
+
+#if 0
+	if ((fd = open("/dev/gpio/control",O_RDWR))<0) goto error;
+	read(fd,&val,4);
+	val|=RESET;
+	write(fd,&val,4);
+
+	if ((fd = open("/dev/gpio/outen",O_RDWR))<0) goto error;
+	read(fd,&val,4);
+	val&=~RESET;
+	write(fd,&val,4);
+#endif
+
+	if ((fd = open("/dev/gpio/in",O_RDONLY))<0) goto error;
+	read(fd,&val,4);
+	
+	return !(val&RESET);
+
+error:
+	return 1;
+}