Apply the amit hacks to busybox-1.7.2

The amit company made some modifications to Busybox-1.0-rc2. The purpose of this modifications were:






It seems that the other utilities on the initrd do not depend on CPU-usage feature. Because of that and because it was the biggest part of the patch, this was not included. The other changes, including and a bugfix, which prevents a write to a random memory address, are included in the patch below.

To create a flash-image with Busybox-1.7.2 replace the contents of busybox_src in the MGB100_\GPL folder with the sources of Busybox-1.7.2. After that cd into that directory and apply the patch. Now you have to configure busybox. After that you can build the flash-image from the MGB100_\GPL folder with make linuxall

If you want to test busybox before you flash the new image have a look at Temporary modifications to the initrd

diff -upNr busybox-1.7.2/Makefile.flags busybox-1.7.2-mod/Makefile.flags
--- busybox-1.7.2/Makefile.flags	2007-09-03 13:48:58.000000000 +0200
+++ busybox-1.7.2-mod/Makefile.flags	2007-10-09 16:37:01.000000000 +0200
@@ -47,6 +47,9 @@ CFLAGS += $(call cc-option,-fno-guess-br
 CFLAGS += $(call cc-option,-funsigned-char -static-libgcc,)
 CFLAGS += $(call cc-option,-falign-functions=1 -falign-jumps=1 -falign-labels=1 -falign-loops=1,)
 
+LDFLAGS += -L$(TOPDIR)../usr_src/amit_lib
+LDLIBS += -lamit
+
 # FIXME: These warnings are at least partially to be concerned about and should
 # be fixed..
 #CFLAGS+=$(call cc-option,-Wconversion,)
diff -upNr busybox-1.7.2/coreutils/date.c busybox-1.7.2-mod/coreutils/date.c
--- busybox-1.7.2/coreutils/date.c	2007-09-03 13:48:39.000000000 +0200
+++ busybox-1.7.2-mod/coreutils/date.c	2007-10-09 13:12:12.000000000 +0200
@@ -11,6 +11,9 @@
 */
 
 #include "libbb.h"
+#include <sys/io.h>
+
+extern void write_into_rtc(struct tm *tm_time);
 
 /* This 'date' command supports only 2 time setting formats,
    all the GNU strftime stuff (its in libc, lets use it),
@@ -171,6 +174,10 @@ int date_main(int argc, char **argv)
 			bb_error_msg_and_die(bb_msg_invalid_date, date_str);
 		}
 		maybe_set_utc(opt);
+#ifdef _HAVE_RTC
+		// added by Lily -- 20050520
+		write_into_rtc(&tm_time);
+#endif
 
 		/* if setting time, set it */
 		if ((opt & DATE_OPT_SET) && stime(&tm) < 0) {
diff -upNr busybox-1.7.2/init/init.c busybox-1.7.2-mod/init/init.c
--- busybox-1.7.2/init/init.c	2007-09-03 13:48:54.000000000 +0200
+++ busybox-1.7.2-mod/init/init.c	2007-10-09 15:11:14.000000000 +0200
@@ -15,6 +15,7 @@
 //#include <sys/ioctl.h>
 //#include <sys/wait.h>
 #include <sys/reboot.h>
+#include <sys/io.h>
 
 #if ENABLE_FEATURE_INIT_SYSLOG
 # include <sys/syslog.h>
@@ -570,6 +571,7 @@ static void init_reboot(unsigned long ma
 
 static void shutdown_system(void)
 {
+	unsigned long reg;
 	sigset_t block_signals;
 
 	/* run everything to be run at "shutdown".  This is done _prior_
@@ -602,6 +604,16 @@ static void shutdown_system(void)
 	sync();
 	sleep(1);
 
+	iopl(3);
+	outl(0x80003848, 0xcf8);
+	reg = inl(0xcfc);
+	reg |= 0x3C;
+	outl(reg, 0xcfc);
+	outl(0x8000384C, 0xcf8);
+	reg = inl(0xcfc);
+	reg &= 0xC3;
+	outl(reg, 0xcfc);
+
 	message(L_CONSOLE | L_LOG, "Sending SIG%s to all processes", "KILL");
 	kill(-1, SIGKILL);
 	sync();
@@ -651,9 +663,12 @@ static void shutdown_signal(int sig)
 {
 	const char *m;
 	int rb;
+	unsigned long reg;
 
 	shutdown_system();
-
+	sleep(1);
+	reg |= 0x3C;
+	outl(reg, 0xcfc);
 	m = "halt";
 	rb = RB_HALT_SYSTEM;
 	if (sig == SIGTERM) {