Update of /cvsroot/blob/blob/src
In directory usw-pr-cvs1:/tmp/cvs-serv3560/src
Modified Files:
init.c Makefile.am rest-ld-script
Log Message:
The init and exit lists code.
Index: init.c
===================================================================
RCS file: /cvsroot/blob/blob/src/init.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- init.c 2001/10/02 21:31:17 1.1
+++ init.c 2001/10/02 21:39:54 1.2
@@ -0,0 +1,84 @@
+/*
+ * init.c: Support for init and exit lists
+ *
+ * Copyright (C) 2001 Erik Mouw (J.A...@it...)
+ *
+ * $Id$
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ident "$Id$"
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include "init.h"
+#include "serial.h"
+
+
+/* int and exit list start and end. filled in by the linker */
+extern u32 __initlist_start;
+extern u32 __initlist_end;
+extern u32 __exitlist_start;
+extern u32 __exitlist_end;
+
+
+static void call_funcs(initlist_t *start, initlist_t *end,
+ u32 magic, int level)
+{
+ initlist_t *item;
+
+ for(item = start; item != end; item++) {
+ if(item->magic != magic) {
+ SerialOutputString("*** Init magic failed for 0x");
+ SerialOutputHex((u32)item);
+ SerialOutputString("!\n");
+
+ return;
+ }
+
+ if(item->level == level) {
+ /* call function */
+ item->callback();
+ }
+ }
+}
+
+
+void init_subsystems(void)
+{
+ int i;
+
+ /* call all subsystem init functions */
+ for(i = INIT_LEVEL_MIN; i <= INIT_LEVEL_MAX; i++)
+ call_funcs((initlist_t *)&__initlist_start,
+ (initlist_t *)&__initlist_end,
+ INIT_MAGIC, i);
+}
+
+
+void exit_subsystems(void)
+{
+ int i;
+
+ /* call all subsystem exit functions */
+ for(i = INIT_LEVEL_MAX; i >= INIT_LEVEL_MIN; i--)
+ call_funcs((initlist_t *)&__exitlist_start,
+ (initlist_t *)&__exitlist_end,
+ EXIT_MAGIC, i);
+}
Index: Makefile.am
===================================================================
RCS file: /cvsroot/blob/blob/src/Makefile.am,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Makefile.am 2001/09/27 21:36:37 1.6
+++ Makefile.am 2001/10/02 21:39:54 1.7
@@ -60,6 +60,7 @@
testmem2.S \
command.c \
flash.c \
+ init.c \
led.c \
linux.c \
main.c \
Index: rest-ld-script
===================================================================
RCS file: /cvsroot/blob/blob/src/rest-ld-script,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- rest-ld-script 2001/09/15 20:14:23 1.4
+++ rest-ld-script 2001/10/02 21:39:54 1.5
@@ -37,6 +37,20 @@
}
. = ALIGN(4);
+ .initlist : {
+ __initlist_start = .;
+ *(.initlist)
+ __initlist_end = .;
+ }
+
+ . = ALIGN(4);
+ .exitlist : {
+ __exitlist_start = .;
+ *(.exitlist)
+ __exitlist_end = .;
+ }
+
+ . = ALIGN(4);
.ptaglist : {
__ptagtable_begin = .;
*(.ptaglist)
|