commit-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

hurd-l4/laden ia32-cmain.c laden.c laden.h load...


From: Marcus Brinkmann
Subject: hurd-l4/laden ia32-cmain.c laden.c laden.h load...
Date: Mon, 08 Sep 2003 10:23:18 -0400

CVSROOT:        /cvsroot/hurd
Module name:    hurd-l4
Branch:         
Changes by:     Marcus Brinkmann <address@hidden>       03/09/08 10:23:17

Modified files:
        laden          : ia32-cmain.c laden.c laden.h loader.c output.c 
                         output.h shutdown.h 
Added files:
        laden          : loader.h 

Log message:
        Make loader modular and shuffle things around a bit.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd-l4/laden/loader.h?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd-l4/laden/ia32-cmain.c.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd-l4/laden/laden.c.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd-l4/laden/laden.h.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd-l4/laden/loader.c.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd-l4/laden/output.c.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd-l4/laden/output.h.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd-l4/laden/shutdown.h.diff?tr1=1.2&tr2=1.3&r1=text&r2=text

Patches:
Index: hurd-l4/laden/ia32-cmain.c
diff -u hurd-l4/laden/ia32-cmain.c:1.6 hurd-l4/laden/ia32-cmain.c:1.7
--- hurd-l4/laden/ia32-cmain.c:1.6      Sun Sep  7 21:39:14 2003
+++ hurd-l4/laden/ia32-cmain.c  Mon Sep  8 10:23:17 2003
@@ -109,7 +109,7 @@
       argc = 1;
 
       argv = alloca (sizeof (char *) * 2);
-      argv[0] = PROGRAM_NAME;
+      argv[0] = program_name;
       argv[1] = 0;
     }
 
@@ -323,7 +323,6 @@
          add_memory_map (low, high, L4_MEMDESC_RESERVED, 0);
        }
     }
-
 
   /* Now protect ourselves and the mulitboot info (at least the module
      configuration.  */
Index: hurd-l4/laden/laden.c
diff -u hurd-l4/laden/laden.c:1.5 hurd-l4/laden/laden.c:1.6
--- hurd-l4/laden/laden.c:1.5   Sun Sep  7 21:39:14 2003
+++ hurd-l4/laden/laden.c       Mon Sep  8 10:23:17 2003
@@ -25,6 +25,9 @@
 #include "laden.h"
 
 
+/* The program name.  */
+char *program_name = "laden";
+
 rootserver_t kernel;
 rootserver_t sigma0;
 rootserver_t sigma1;
@@ -33,12 +36,70 @@
 /* The boot info to be inserted into the L4 KIP.  */
 l4_word_t boot_info;
 
+
 struct l4_memory_desc memory_map[MEMORY_MAP_MAX];
-int memory_map_size;
 
-
-/* True if debug mode is enabled.  */
-int debug;
+l4_word_t memory_map_size;
+
+
+/* Return the number of memory descriptors.  */
+l4_word_t
+loader_get_num_memory_desc (void)
+{
+  return memory_map_size;
+}
+
+
+/* Return the NRth memory descriptor.  The first memory descriptor is
+   indexed by 0.  */
+l4_memory_desc_t
+loader_get_memory_desc (l4_word_t nr)
+{
+  return &memory_map[nr];
+}
+
+
+/* Load the ELF images of the kernel and the initial servers into
+   memory, checking for overlaps.  Update the start and end
+   information with the information from the ELF program, and fill in
+   the entry points.  */
+static void
+load_components (void)
+{
+  if (!kernel.low)
+    panic ("No L4 kernel found");
+  loader_add_region ("kernel-mod", kernel.low, kernel.high);
+
+  if (!sigma0.low)
+    panic ("No sigma0 server found");
+  loader_add_region ("sigma0-mod", sigma0.low, sigma0.high);
+
+  if (sigma1.low)
+    loader_add_region ("sigma1-mod", sigma1.low, sigma1.high);
+
+  if (!rootserver.low)
+    panic ("No rootserver server found");
+  loader_add_region ("rootserver-mod", rootserver.low, rootserver.high);
+
+  loader_elf_load ("kernel", kernel.low, kernel.high,
+                  &kernel.low, &kernel.high, &kernel.ip);
+  loader_remove_region ("kernel-mod");
+
+  loader_elf_load ("sigma0", sigma0.low, sigma0.high,
+                  &sigma0.low, &sigma0.high, &sigma0.ip);
+  loader_remove_region ("sigma0-mod");
+
+  if (sigma1.low)
+    {
+      loader_elf_load ("sigma1", sigma1.low, sigma1.high,
+                      &sigma1.low, &sigma1.high, &sigma1.ip);
+      loader_remove_region ("sigma1-mod");
+    }
+
+  loader_elf_load ("rootserver", rootserver.low, rootserver.high,
+                  &rootserver.low, &rootserver.high, &rootserver.ip);
+  loader_remove_region ("rootserver-mod");
+}
 
 
 static void
@@ -52,7 +113,7 @@
        {
          i++;
          printf ("Usage %s [OPTION...]\n", argv[0]);
-         printf ("Try `" PROGRAM_NAME " --help' for more information\n");
+         printf ("Try `%s --help' for more information\n", program_name);
          shutdown ();    
        }
       else if (!strcmp (argv[i], "--help"))
@@ -95,7 +156,7 @@
       else if (!strcmp (argv[i], "--version"))
        {
          i++;
-         printf (PROGRAM_NAME " " PACKAGE_VERSION "\n");
+         printf ("%s " PACKAGE_VERSION "\n", program_name);
          shutdown ();    
        }
       else if (!strcmp (argv[i], "-o") || !strcmp (argv[i], "--output"))
@@ -118,7 +179,7 @@
       else if (!strcmp (argv[i], "-D") || !strcmp (argv[i], "--debug"))
        {
          i++;
-         debug = 1;
+         output_debug = 1;
        }
       else if (argv[i][0] == '-')
        panic ("Unsupported option %s", argv[i]);
@@ -133,7 +194,7 @@
 {
   parse_args (argc, argv);
 
-  debug (PROGRAM_NAME " " PACKAGE_VERSION "\n");
+  debug ("%s " PACKAGE_VERSION "\n", program_name);
 
   find_components ();
 
Index: hurd-l4/laden/laden.h
diff -u hurd-l4/laden/laden.h:1.6 hurd-l4/laden/laden.h:1.7
--- hurd-l4/laden/laden.h:1.6   Sun Sep  7 21:39:14 2003
+++ hurd-l4/laden/laden.h       Mon Sep  8 10:23:17 2003
@@ -22,9 +22,12 @@
 #include "string.h"
 #include "output.h"
 #include "shutdown.h"
+#include "loader.h"
 
 
-#define PROGRAM_NAME   "laden"
+/* The program name.  */
+extern char *program_name;
+
 #define BUG_ADDRESS    "<address@hidden>"
 
 
@@ -49,7 +52,7 @@
 /* The memory map to be provided to the kernel.  */
 #define MEMORY_MAP_MAX 200
 extern struct l4_memory_desc memory_map[MEMORY_MAP_MAX];
-extern int memory_map_size;
+extern l4_word_t memory_map_size;
 
 #define add_memory_map(start,end,mtype,msubtype)                               
\
   ({                                                                   \
@@ -76,33 +79,6 @@
 
 
 /* The generic code defines these functions.  */
-
-/* Print an error message and fail.  */
-#define panic(...)                             \
-  ({                                           \
-    printf (PROGRAM_NAME ": error: ");         \
-    printf (__VA_ARGS__);                      \
-    putchar ('\n');                            \
-    shutdown ();                               \
-  })
-
-/* True if debug mode is enabled.  */
-extern int debug;
-
-/* Print a debug message.  */
-#define debug(...) do { if (debug) printf (__VA_ARGS__); } while (0)
-
-/* Add the region with the name NAME from START to END to the table of
-   regions to check against.  Before doing that, check for overlaps
-   with existing regions.  */
-void loader_add_region (char *name, l4_word_t start, l4_word_t end);
-
-
-/* Load the ELF images of the kernel and the initial servers into
-   memory, checking for overlaps.  Update the start and end
-   information with the information from the ELF program, and fill in
-   the entry points.  */
-void load_components (void);
 
 void kip_fixup (void);
 
Index: hurd-l4/laden/loader.c
diff -u hurd-l4/laden/loader.c:1.5 hurd-l4/laden/loader.c:1.6
--- hurd-l4/laden/loader.c:1.5  Sun Sep  7 21:39:14 2003
+++ hurd-l4/laden/loader.c      Mon Sep  8 10:23:17 2003
@@ -18,7 +18,9 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA. */
 
-#include "laden.h"
+#include "loader.h"
+#include "output.h"
+#include "shutdown.h"
 
 #include "elf.h"
 
@@ -28,17 +30,20 @@
 static void
 mem_check (const char *name, unsigned long start, unsigned long end)
 {
+  l4_memory_desc_t memdesc;
   int nr;
   int fits = 0;
   int conflicts = 0;
 
+  if (!loader_get_num_memory_desc ())
+    return;
+
   /* FIXME: This implementation does not account for conventional
      memory overriding non-conventional memory in the descriptor
      list.  */
-
-  for (nr = 0; nr < memory_map_size; nr++)
+  for (nr = 0; nr < loader_get_num_memory_desc (); nr++)
     {
-      l4_memory_desc_t memdesc = &memory_map[nr];
+      memdesc = loader_get_memory_desc (nr);
 
       if (memdesc->type == L4_MEMDESC_CONVENTIONAL)
        {
@@ -63,8 +68,8 @@
   if (conflicts)
     panic ("%s (0x%x - 0x%x) conflicts with memory of "
           "type %i/%i (0x%x - 0x%x)", name, start, end,
-          memory_map[nr].type, memory_map[nr].subtype,
-          memory_map[nr].low << 10, memory_map[nr].high << 10);
+          memdesc->type, memdesc->subtype,
+          memdesc->low << 10, memdesc->high << 10);
   if (!fits)
     panic ("%s (0x%x - 0x%x) does not fit into memory",
           name, start, end);
@@ -127,8 +132,8 @@
 
 
 /* Remove the region with the name NAME from the table.  */
-static void
-remove_region (const char *name)
+void
+loader_remove_region (const char *name)
 {
   int i;
 
@@ -153,9 +158,10 @@
    program).  Return the lowest and highest address used by the
    program in NEW_START_P and NEW_END_P, and the entry point in
    ENTRY.  */
-static void
-elf_load (char *name, l4_word_t start, l4_word_t end,
-         l4_word_t *new_start_p, l4_word_t *new_end_p, l4_word_t *entry)
+void
+loader_elf_load (char *name, l4_word_t start, l4_word_t end,
+                l4_word_t *new_start_p, l4_word_t *new_end_p,
+                l4_word_t *entry)
 {
   l4_word_t new_start = -1;
   l4_word_t new_end = 0;
@@ -215,47 +221,4 @@
     *new_end_p = new_end;
   if (entry)
     *entry = elf->e_entry;
-}
-
-
-/* Load the ELF images of the kernel and the initial servers into
-   memory, checking for overlaps.  Update the start and end
-   information with the information from the ELF program, and fill in
-   the entry points.  */
-void
-load_components (void)
-{
-  if (!kernel.low)
-    panic ("No L4 kernel found");
-  loader_add_region ("kernel-mod", kernel.low, kernel.high);
-
-  if (!sigma0.low)
-    panic ("No sigma0 server found");
-  loader_add_region ("sigma0-mod", sigma0.low, sigma0.high);
-
-  if (sigma1.low)
-    loader_add_region ("sigma1-mod", sigma1.low, sigma1.high);
-
-  if (!rootserver.low)
-    panic ("No rootserver server found");
-  loader_add_region ("rootserver-mod", rootserver.low, rootserver.high);
-
-  elf_load ("kernel", kernel.low, kernel.high,
-           &kernel.low, &kernel.high, &kernel.ip);
-  remove_region ("kernel-mod");
-
-  elf_load ("sigma0", sigma0.low, sigma0.high,
-           &sigma0.low, &sigma0.high, &sigma0.ip);
-  remove_region ("sigma0-mod");
-
-  if (sigma1.low)
-    {
-      elf_load ("sigma1", sigma1.low, sigma1.high,
-               &sigma1.low, &sigma1.high, &sigma1.ip);
-      remove_region ("sigma1-mod");
-    }
-
-  elf_load ("rootserver", rootserver.low, rootserver.high,
-           &rootserver.low, &rootserver.high, &rootserver.ip);
-  remove_region ("rootserver-mod");
 }
Index: hurd-l4/laden/output.c
diff -u hurd-l4/laden/output.c:1.3 hurd-l4/laden/output.c:1.4
--- hurd-l4/laden/output.c:1.3  Sun Sep  7 18:13:04 2003
+++ hurd-l4/laden/output.c      Mon Sep  8 10:23:17 2003
@@ -26,6 +26,10 @@
 
 #include "output.h"
 
+
+/* True if debugging is enabled.  */
+int output_debug;
+
 
 /* The active output driver.  */
 static struct output_driver *output;
Index: hurd-l4/laden/output.h
diff -u hurd-l4/laden/output.h:1.2 hurd-l4/laden/output.h:1.3
--- hurd-l4/laden/output.h:1.2  Sun Sep  7 18:13:04 2003
+++ hurd-l4/laden/output.h      Mon Sep  8 10:23:17 2003
@@ -62,4 +62,10 @@
 
 void printf (const char *fmt, ...);
 
+/* True if debug mode is enabled.  */
+extern int output_debug;
+
+/* Print a debug message.  */
+#define debug(...) do { if (output_debug) printf (__VA_ARGS__); } while (0)
+
 #endif /* _OUTPUT_H */
Index: hurd-l4/laden/shutdown.h
diff -u hurd-l4/laden/shutdown.h:1.2 hurd-l4/laden/shutdown.h:1.3
--- hurd-l4/laden/shutdown.h:1.2        Sun Sep  7 18:13:04 2003
+++ hurd-l4/laden/shutdown.h    Mon Sep  8 10:23:17 2003
@@ -42,4 +42,16 @@
    system.  */
 void shutdown (void);
 
+/* The program name.  */
+extern char *program_name;
+
+/* Print an error message and fail.  */
+#define panic(...)                             \
+  ({                                           \
+    printf ("%s: error: ", program_name);      \
+    printf (__VA_ARGS__);                      \
+    putchar ('\n');                            \
+    shutdown ();                               \
+  })
+
 #endif /* _SHUTDOWN_H */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]