+++ /dev/null
-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;
-+}
#include <linux/module.h>
#include <linux/init.h>
#include <linux/kernel.h>
-#include <linux/timer.h>
#include <linux/sysctl.h>
#include <asm/io.h>
#include <typedefs.h>
void (*set_dmz)(u8 state);
static unsigned int diag = 0;
-static struct timer_list timer;
static void diag_change()
{
return r;
}
+// - - - - -
+static unsigned char reset_gpio = 0;
+static unsigned char reset_polarity = 0;
+static unsigned int reset = 0;
+
+static int proc_reset(ctl_table *table, int write, struct file *filp,
+ void *buffer, size_t *lenp)
+{
+
+ if (reset_gpio) {
+ sb_gpiocontrol(sbh,reset_gpio,reset_gpio);
+ sb_gpioouten(sbh,reset_gpio,0);
+ reset=!(sb_gpioin(sbh)&reset_gpio);
+
+ if (reset_polarity) reset=!reset;
+ } else {
+ reset=0;
+ }
+
+ return proc_dointvec(table, write, filp, buffer, lenp);
+}
+
// - - - - -
static struct ctl_table_header *diag_sysctl_header;
mode: 0644,
proc_handler: proc_diag
},
+ {
+ ctl_name: 2001,
+ procname: "reset",
+ data: &reset,
+ maxlen: sizeof(reset),
+ mode: 0444,
+ proc_handler: proc_reset
+ },
{ 0 }
};
static int __init diag_init()
{
+ char *buf;
u32 board_type;
sbh = sb_kattach();
sb_gpiosetcore(sbh);
board_type = sb_boardtype(sbh);
- printk(KERN_INFO "diag board_type: %08x\n",board_type);
+ printk(KERN_INFO "diag boardtype: %08x\n",board_type);
+ set_diag=ignore;
+ set_dmz=ignore;
+
if (board_type & 0x400) {
+ board_type=1;
set_diag=v1_set_diag;
set_dmz=v1_set_dmz;
- if (board_type==0x41d) {
- printk(KERN_INFO "buffalo hack.\n");
+
+ buf=nvram_get("boardtype")?:"";
+
+ if (!strcmp(buf,"bcm94710dev")) {
+ buf=nvram_get("boardnum")?:"";
+ if (!strcmp(buf,"42")) {
+ // wrt54g v1.x
+ set_diag=v1_set_diag;
+ set_dmz=v1_set_dmz;
+ reset_gpio=(1<<6);
+ reset_polarity=0;
+ } else (!strcmp(buf,"asusX")) {
+ //asus wl-500g
+ //no leds
+ reset_gpio=(1<<6);
+ reset_polarity=1;
+ }
+ } else if (!strcmp(buf,"bcm94710ap")) {
+ // buffalo
set_diag=ignore;
set_dmz=v2_set_dmz;
+ reset_gpio=(1<<4);
+ reset_polarity=1;
}
- board_type=1;
} else {
board_type=2;
set_diag=v2_set_diag;
set_dmz=v2_set_dmz;
+ reset_gpio=(1<<6);
+ reset_polarity=0;
}
printk(KERN_INFO "using v%d hardware\n",board_type);
static void __exit diag_exit()
{
unregister_sysctl_table(diag_sysctl_header);
- del_timer(&timer);
}
module_init(diag_init);
# NVRAM overrides
-# This file handles the NVRAM quirks of various hardware
-# this is not a replacement for nvram.
+# This file handles the NVRAM quirks of various hardware.
+#
+# THIS FILE IS NOT A REPLACEMENT FOR NVRAM
# linksys bug has lan doing dhcp; force static
lan_proto="static"
-# failsafe if reset is held
-[ "$FAILSAFE" = "true" ] && {
- echo "### FAILSAFE MODE ####"
- lan_ifname="br0"
- lan_ifnames="vlan0 vlan2 eth1 eth2 eth3"
- lan_ipaddr="192.168.1.1"
- lan_netmask="255.255.255.0"
- lan_hwaddr="00:0B:AD:0A:DD:00"
- wan_ifname="none"
- wifi_ifname="none"
-}
-
# hacks for 1.x hardware
[ "$(nvram get boardnum)" = "42" ] && \
[ "$(nvram get boardtype)" = "bcm94710dev" ] && {
wan_ifname="vlan1"
wan_proto="dhcp"
}
+
+# failsafe if reset is held
+[ "$FAILSAFE" = "true" ] && {
+ echo "### FAILSAFE MODE ####"
+ lan_ifname="br0"
+ lan_ifnames="vlan0 vlan2 eth1 eth2 eth3"
+ lan_ipaddr="192.168.1.1"
+ lan_netmask="255.255.255.0"
+ lan_hwaddr="00:0B:AD:0A:DD:00"
+ wan_ifname="none"
+ wifi_ifname="none"
+}
insmod diag
echo 0x01 > /proc/sys/diag
sleep 1
-if /sbin/resetmon ; then
+if [ $(cat /proc/sys/reset) = 1 ] ; then
mtd unlock mtd4
mount -t jffs2 /dev/mtdblock/4 /jffs
pivot_root /jffs /jffs/rom