Hi,

I eventually managed to get the patchs done. There are three of them
for the specific parts : the libl4 one, which is a standalone, the
laden part (replace multiboot_info in KIP->bootinfo by the
corresponding generic_bootinfo) and the wortel one (read
generic_bootinfo instead of multiboot_info). The last two should be
applied together or wortel will crash when trying to read  from the
bad structure (I can make a workaround as the multiboot_info is not
deleted, if needed). The generic_bootinfo is set at the arbitrary
address of 0x30000 (see ia32-btinfo.c) which did seem to work without
problems.

Currently, we only use info about the loaded modules before deleting
the multiboot_info and generic_bootinfo in wortel.

The patches have been tested in qemu and worked right. The Generic
Bootinfo is now available in KDB but not the command lines (I took a
look at it and it seems that it comes from the pistachio code using
the wrong address in KDB for the command lines but I did not
investigate further).

Regards,

Alexandre
diff -ruN ../contrib/ref/hurd-l4/laden/Makefile.am laden/Makefile.am
--- ../contrib/ref/hurd-l4/laden/Makefile.am	2005-02-14 16:32:45.000000000 +0100
+++ laden/Makefile.am	2005-02-17 11:59:00.000000000 +0100
@@ -19,8 +19,9 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
 
 if ARCH_IA32
-  ARCH_SOURCES = multiboot.h ia32-crt0.S ia32-cmain.c \
-    ia32-output.c output-vga.c output-serial.c ia32-shutdown.c
+  ARCH_SOURCES = multiboot.h ia32-crt0.S ia32-btinfo.c ia32-cmain.c \
+  ia32-output.c output-vga.c output-serial.c \
+  ia32-shutdown.c
 endif
 
 bootdir = $(prefix)/boot
diff -ruN ../contrib/ref/hurd-l4/laden/ia32-btinfo.c laden/ia32-btinfo.c
--- ../contrib/ref/hurd-l4/laden/ia32-btinfo.c	1970-01-01 01:00:00.000000000 +0100
+++ laden/ia32-btinfo.c	2005-02-19 22:14:14.000000000 +0100
@@ -0,0 +1,325 @@
+/* ia32-btinfo.c - Generic bootinfo support.
+   Copyright (C) 2005 Free Software Foundation, Inc.
+   Written by Alexandre Buisse <[EMAIL PROTECTED]>.
+
+   This file is part of the GNU Hurd.
+
+   The GNU Hurd 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, or (at
+   your option) any later version.
+
+   The GNU Hurd 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, USA. */
+
+#include "laden.h"
+#include <stdint.h>
+
+#include <l4/bootinfo.h>
+
+#include "multiboot.h"
+
+#define GENERIC_BTINFO_ADDR 0x30000 /* FIXME: should we place it here ? */
+
+
+static int num_entries = 1;
+static l4_word_t next;
+static l4_generic_bootinfo_t bootinfo = 
+       (l4_generic_bootinfo_t) GENERIC_BTINFO_ADDR; 
+static multiboot_info_t *mbi;
+
+
+/* This adds the module info in a new generic bootinfo record. 
+   We choose to keep it simple and not add free space between two records.
+   Thus offset_next has the exact size of the record. */
+static void
+add_generic_bootinfo_module (module_t *mod)
+{
+  l4_generic_bootinfo_module_t bootinfo_mod = 
+             (l4_generic_bootinfo_module_t) next;
+  
+  bootinfo_mod->type           = _L4_BOOTINFO_MODULE;
+  bootinfo_mod->version        = _L4_BOOTINFO_VERSION;
+  bootinfo_mod->offset_next    = sizeof (l4_generic_bootinfo_module);
+  bootinfo_mod->start          = (l4_word_t) mod->mod_start;
+  bootinfo_mod->size           = (l4_word_t) (mod->mod_end - mod->mod_start);
+  bootinfo_mod->cmdline_offset = (l4_word_t) ((l4_word_t) mod->string - (l4_word_t) bootinfo_mod);
+  debug ("Module at %x inserted at %x, with size %x, cmdline_offset %x and offset_next %x\n",
+	    bootinfo_mod->start, (l4_word_t) bootinfo_mod, bootinfo_mod->size, 
+	    bootinfo_mod->cmdline_offset, bootinfo_mod->offset_next);
+  next += bootinfo_mod->offset_next;
+  num_entries++;
+}
+
+/* Dump of multiboot info we retrieved from grub. */
+static void
+debug_dump (void)
+{
+  if (CHECK_FLAG (mbi->flags, 9))
+    debug ("Booted by %s\n", (char *) mbi->boot_loader_name);
+
+  if (CHECK_FLAG (mbi->flags, 0))
+    debug ("Memory: Lower %u KB, Upper %u KB\n",
+	   mbi->mem_lower, mbi->mem_upper);
+
+  if (CHECK_FLAG (mbi->flags, 3))
+    {
+      module_t *mod = (module_t *) mbi->mods_addr;
+      int nr;
+
+      for (nr = 0; nr < mbi->mods_count; nr++)
+	debug ("Module %i: Start 0x%x, End 0x%x, Cmd %s\n",
+	       nr + 1, mod[nr].mod_start, mod[nr].mod_end,
+	       (char *) mod[nr].string);
+    }
+
+  if (CHECK_FLAG (mbi->flags, 6))
+    {
+      memory_map_t *mmap;
+      int nr = 1;
+
+      for (mmap = (memory_map_t *) mbi->mmap_addr;
+	   (uint32_t) mmap < mbi->mmap_addr + mbi->mmap_length;
+	   mmap = (memory_map_t *) ((uint32_t) mmap
+				    + mmap->size + sizeof (mmap->size)))
+	debug ("Memory Map %i: Type %i, Base 0x%llx, Length 0x%llx\n",
+	       nr++, mmap->type, mmap->base_addr, mmap->length);
+    }
+}
+
+
+/* The following must be defined and are used to calculate the extents
+   of the laden binary itself.  */
+extern char _start;
+extern char _end;
+
+
+/* Find the kernel, the initial servers and the other information
+   required for booting.  */
+void
+find_components (multiboot_info_t* mbi)
+{
+  l4_word_t start;
+  l4_word_t end;
+
+  debug_dump ();
+
+  /* Load the module information.  */
+  if (CHECK_FLAG (mbi->flags, 3))
+    {
+      module_t *mod = (module_t *) mbi->mods_addr;
+
+      if (mbi->mods_count > 0)
+	{
+	  add_generic_bootinfo_module (mod);
+	  kernel.low = mod->mod_start;
+	  kernel.high = mod->mod_end;
+	  mod++;
+	  mbi->mods_count--;
+	}
+      if (mbi->mods_count > 0)
+	{
+	  add_generic_bootinfo_module (mod);
+	  sigma0.low = mod->mod_start;
+	  sigma0.high = mod->mod_end;
+	  mod++;
+	  mbi->mods_count--;
+	}
+      /* Swallow the modules we used so far.  This makes the
+	 rootserver the first module in the list, regardless if
+	 sigma1 is used or not. */
+      mbi->mods_addr = (l4_word_t) mod;
+      if (mbi->mods_count > 0)
+	{
+	  add_generic_bootinfo_module (mod);
+	  rootserver.low = mod->mod_start;
+	  rootserver.high = mod->mod_end;
+	}
+
+      /* finish adding the modules in the generic bootinfo structure */
+      int nr;
+      for (nr = 1, mod++; nr < mbi->mods_count; nr++, mod++)
+	  add_generic_bootinfo_module (mod);
+      bootinfo->size = (l4_word_t) ((l4_word_t) next - (l4_word_t) bootinfo);
+      bootinfo->num_entries = (l4_word_t) num_entries;
+    }
+
+  /* Now create the memory map.  */
+
+  /* First, add the whole address space as shared memory by default to
+     allow arbitrary device access.  */
+  add_memory_map (0, -1, L4_MEMDESC_SHARED, 0);
+
+  /* Now add what GRUB tells us.  */
+  if (CHECK_FLAG (mbi->flags, 6))
+    {
+      /* mmap_* are valid.  */
+      memory_map_t *mmap;
+
+      for (mmap = (memory_map_t *) mbi->mmap_addr;
+	   (uint32_t) mmap < mbi->mmap_addr + mbi->mmap_length;
+	   mmap = (memory_map_t *) ((uint32_t) mmap
+				    + mmap->size + sizeof (mmap->size)))
+	{
+	  uint64_t end;
+
+	  if (mmap->base_addr >> 32)
+	    panic ("L4 does not support more than 4 GB on ia32");
+
+	  end = mmap->base_addr + mmap->length - 1;
+
+	  if (end >> 32)
+	    panic ("L4 does not support more than 4 GB on ia32");
+
+	  if (mmap->base_addr & ((1 << 10) - 1)
+	      || mmap->length & ((1 << 10) - 1))
+	    panic ("Memory region (0x%llx - 0x%llx) is unaligned",
+		   mmap->base_addr, end);
+
+	  add_memory_map ((uint32_t) mmap->base_addr, (uint32_t) end,
+			  mmap->type == 1
+			  ? L4_MEMDESC_CONVENTIONAL : L4_MEMDESC_ARCH,
+			  mmap->type == 1 ? 0 : mmap->type);
+	}
+    }
+  else if (CHECK_FLAG (mbi->flags, 0))
+    {
+      /* mem_* are valid.  */
+
+      add_memory_map (0, (mbi->mem_lower << 10) - 1,
+		      L4_MEMDESC_CONVENTIONAL, 0);
+      add_memory_map (0x100000, (0x100000 + (mbi->mem_upper << 10)) - 1,
+		      L4_MEMDESC_CONVENTIONAL, 0);
+    }
+
+  /* The VGA memory, and ROM extension, is usually not included in the
+     BIOS map.  We add it here.  */
+  add_memory_map (0xa0000, 0xf0000 - 1, L4_MEMDESC_SHARED, 0);
+
+  /* The amount of conventional memory to be reserved for the kernel.  */
+#define KMEM_SIZE	(16 * 0x100000)
+
+  /* The upper limit for the end of the kernel memory.  */
+#define KMEM_MAX	(240 * 0x100000)
+
+  if (CHECK_FLAG (mbi->flags, 6))
+    {
+      memory_map_t *mmap;
+
+      for (mmap = (memory_map_t *) mbi->mmap_addr;
+	   (uint32_t) mmap < mbi->mmap_addr + mbi->mmap_length;
+	   mmap = (memory_map_t *) ((uint32_t) mmap
+				    + mmap->size + sizeof (mmap->size)))
+	{
+	  if (mmap->type != 1)
+	    continue;
+
+	  if (((uint32_t) mmap->length) >= KMEM_SIZE
+	      && ((uint32_t) mmap->base_addr) <= KMEM_MAX - KMEM_SIZE)
+	    {
+	      uint32_t high = ((uint32_t) mmap->base_addr)
+			       + ((uint32_t) mmap->length);
+	      uint32_t low;
+
+	      if (high > KMEM_MAX)
+		high = KMEM_MAX;
+	      low = high - KMEM_SIZE;
+	      /* Round up to the next super page (4 MB).  */
+	      low = (low + 0x3fffff) & ~0x3fffff;
+
+	      add_memory_map (low, high, L4_MEMDESC_RESERVED, 0);
+	    }
+	}
+    }
+  else if (CHECK_FLAG (mbi->flags, 0))
+    {
+      if ((mbi->mem_upper << 10) >= KMEM_SIZE)
+	{
+	  uint32_t high = (mbi->mem_upper << 10) + 0x100000;
+	  uint32_t low;
+
+	  if (high > KMEM_MAX)
+	    high = KMEM_MAX;
+
+	  low = high - KMEM_SIZE;
+	  /* Round up to the next super page (4 MB).  */
+	  low = (low + 0x3fffff) & ~0x3fffff;
+
+	  add_memory_map (low, high, L4_MEMDESC_RESERVED, 0);
+	}
+    }
+
+  /* Now protect ourselves, the multiboot info and the generic multiboot 
+     info (at least the module configuration).  */
+  loader_add_region (program_name, (l4_word_t) &_start, (l4_word_t) &_end);
+  loader_add_region ("generic-btinfo", (l4_word_t) bootinfo, 
+                                (l4_word_t) (bootinfo + bootinfo->size));
+
+  start = (l4_word_t) mbi;
+  end = start + sizeof (*mbi);
+  loader_add_region ("grub-mbi", start, end);
+  
+  if (CHECK_FLAG (mbi->flags, 3) && mbi->mods_count)
+    {
+      module_t *mod = (module_t *) mbi->mods_addr;
+      int nr;
+
+      start = (l4_word_t) mod;
+      end = ((l4_word_t) mod) + mbi->mods_count * sizeof (*mod);
+      loader_add_region ("grub-mods", start, end);
+
+      start = (l4_word_t) mod[0].string;
+      end = start + 1;
+      for (nr = 0; nr < mbi->mods_count; nr++)
+	{
+	  char *str = (char *) mod[nr].string;
+
+	  if (str)
+	    {
+	      if (((l4_word_t) str) < start)
+		start = (l4_word_t) str;
+	      while (*str)
+		str++;
+	      if (((l4_word_t) str) + 1 > end)
+		end = (l4_word_t) str + 1;
+	    }
+	}
+      loader_add_region ("grub-mods-cmdlines", start, end);
+    }
+}
+
+
+
+
+/* Convert a multiboot info in a generic bootinfo structure */
+l4_word_t 
+mbi_to_generic_bootinfo (multiboot_info_t *multiboot_info)
+{
+  mbi = multiboot_info;
+  /* Initial values */
+  bootinfo->magic = _L4_BOOTINFO_MAGIC;
+  bootinfo->version = _L4_BOOTINFO_VERSION;
+  bootinfo->first_entry = sizeof(l4_generic_bootinfo);
+  next = (l4_word_t) ((l4_word_t) bootinfo + bootinfo->first_entry);
+
+  /* MBI structure */
+  l4_generic_bootinfo_MBI_t bootinfo_mbi = (l4_generic_bootinfo_MBI_t) next;
+  bootinfo_mbi->type         = _L4_BOOTINFO_MULTIBOOT;
+  bootinfo_mbi->version      = _L4_BOOTINFO_VERSION;
+  bootinfo_mbi->offset_next  = sizeof(l4_generic_bootinfo_MBI);
+  bootinfo_mbi->address      = (l4_word_t) mbi;
+  debug ("mbi: %x, bootinfo_mbi: %x\n", (l4_word_t) mbi, (l4_word_t) bootinfo_mbi);
+  next += bootinfo_mbi->offset_next;
+  
+  find_components(mbi);
+
+  return (l4_word_t) bootinfo;
+}
+
+
diff -ruN ../contrib/ref/hurd-l4/laden/ia32-cmain.c laden/ia32-cmain.c
--- ../contrib/ref/hurd-l4/laden/ia32-cmain.c	2005-02-14 16:32:45.000000000 +0100
+++ laden/ia32-cmain.c	2005-02-17 11:59:00.000000000 +0100
@@ -25,6 +25,8 @@
 
 #include "multiboot.h"
 
+extern l4_word_t mbi_to_generic_bootinfo (multiboot_info_t*);
+
 
 /* Return a help text for this architecture.  */
 const char *
@@ -54,10 +56,6 @@
 }
 
 
-/* Check if the bit BIT in FLAGS is set.  */
-#define CHECK_FLAG(flags,bit)	((flags) & (1 << (bit)))
-
-
 /* Setup the argument vector and pass control over to the main
    function.  */
 void
@@ -125,10 +123,13 @@
       argv[1] = 0;
     }
 
+  parse_args (argc, argv);
+
   /* The boot info is set to the multiboot info on ia32.  We use this
      also to get at the multiboot info from other functions called at
      a later time.  */
-  boot_info = (uint32_t) mbi;
+  boot_info = (uint32_t) mbi_to_generic_bootinfo (mbi);
+  
 
   /* Now invoke the main function.  */
   main (argc, argv);
@@ -136,231 +137,3 @@
   /* Never reached.  */
 }    
 
-
-static void
-debug_dump (void)
-{
-  multiboot_info_t *mbi = (multiboot_info_t *) boot_info;
-
-  if (CHECK_FLAG (mbi->flags, 9))
-    debug ("Booted by %s\n", (char *) mbi->boot_loader_name);
-
-  if (CHECK_FLAG (mbi->flags, 0))
-    debug ("Memory: Lower %u KB, Upper %u KB\n",
-	   mbi->mem_lower, mbi->mem_upper);
-
-  if (CHECK_FLAG (mbi->flags, 3))
-    {
-      module_t *mod = (module_t *) mbi->mods_addr;
-      int nr;
-
-      for (nr = 0; nr < mbi->mods_count; nr++)
-	debug ("Module %i: Start 0x%x, End 0x%x, Cmd %s\n",
-	       nr + 1, mod[nr].mod_start, mod[nr].mod_end,
-	       (char *) mod[nr].string);
-    }
-
-  if (CHECK_FLAG (mbi->flags, 6))
-    {
-      memory_map_t *mmap;
-      int nr = 1;
-
-      for (mmap = (memory_map_t *) mbi->mmap_addr;
-	   (uint32_t) mmap < mbi->mmap_addr + mbi->mmap_length;
-	   mmap = (memory_map_t *) ((uint32_t) mmap
-				    + mmap->size + sizeof (mmap->size)))
-	debug ("Memory Map %i: Type %i, Base 0x%llx, Length 0x%llx\n",
-	       nr++, mmap->type, mmap->base_addr, mmap->length);
-    }
-}
-
-
-/* The following must be defined and are used to calculate the extents
-   of the laden binary itself.  */
-extern char _start;
-extern char _end;
-
-
-/* Find the kernel, the initial servers and the other information
-   required for booting.  */
-void
-find_components (void)
-{
-  multiboot_info_t *mbi = (multiboot_info_t *) boot_info;
-  l4_word_t start;
-  l4_word_t end;
-
-  debug_dump ();
-
-  /* Load the module information.  */
-  if (CHECK_FLAG (mbi->flags, 3))
-    {
-      module_t *mod = (module_t *) mbi->mods_addr;
-
-      if (mbi->mods_count > 0)
-	{
-	  kernel.low = mod->mod_start;
-	  kernel.high = mod->mod_end;
-	  mod++;
-	  mbi->mods_count--;
-	}
-      if (mbi->mods_count > 0)
-	{
-	  sigma0.low = mod->mod_start;
-	  sigma0.high = mod->mod_end;
-	  mod++;
-	  mbi->mods_count--;
-	}
-      /* Swallow the modules we used so far.  This makes the
-	 rootserver the first module in the list, regardless if
-	 sigma1 is used or not.  FIXME: The rootserver might need the
-	 information about the other modules, though.  */
-      mbi->mods_addr = (l4_word_t) mod;
-      if (mbi->mods_count > 0)
-	{
-	  rootserver.low = mod->mod_start;
-	  rootserver.high = mod->mod_end;
-	}
-    }
-
-  /* Now create the memory map.  */
-
-  /* First, add the whole address space as shared memory by default to
-     allow arbitrary device access.  */
-  add_memory_map (0, -1, L4_MEMDESC_SHARED, 0);
-
-  /* Now add what GRUB tells us.  */
-  if (CHECK_FLAG (mbi->flags, 6))
-    {
-      /* mmap_* are valid.  */
-      memory_map_t *mmap;
-
-      for (mmap = (memory_map_t *) mbi->mmap_addr;
-	   (uint32_t) mmap < mbi->mmap_addr + mbi->mmap_length;
-	   mmap = (memory_map_t *) ((uint32_t) mmap
-				    + mmap->size + sizeof (mmap->size)))
-	{
-	  uint64_t end;
-
-	  if (mmap->base_addr >> 32)
-	    panic ("L4 does not support more than 4 GB on ia32");
-
-	  end = mmap->base_addr + mmap->length - 1;
-
-	  if (end >> 32)
-	    panic ("L4 does not support more than 4 GB on ia32");
-
-	  if (mmap->base_addr & ((1 << 10) - 1)
-	      || mmap->length & ((1 << 10) - 1))
-	    panic ("Memory region (0x%llx - 0x%llx) is unaligned",
-		   mmap->base_addr, end);
-
-	  add_memory_map ((uint32_t) mmap->base_addr, (uint32_t) end,
-			  mmap->type == 1
-			  ? L4_MEMDESC_CONVENTIONAL : L4_MEMDESC_ARCH,
-			  mmap->type == 1 ? 0 : mmap->type);
-	}
-    }
-  else if (CHECK_FLAG (mbi->flags, 0))
-    {
-      /* mem_* are valid.  */
-
-      add_memory_map (0, (mbi->mem_lower << 10) - 1,
-		      L4_MEMDESC_CONVENTIONAL, 0);
-      add_memory_map (0x100000, (0x100000 + (mbi->mem_upper << 10)) - 1,
-		      L4_MEMDESC_CONVENTIONAL, 0);
-    }
-
-  /* The VGA memory, and ROM extension, is usually not included in the
-     BIOS map.  We add it here.  */
-  add_memory_map (0xa0000, 0xf0000 - 1, L4_MEMDESC_SHARED, 0);
-
-  /* The amount of conventional memory to be reserved for the kernel.  */
-#define KMEM_SIZE	(16 * 0x100000)
-
-  /* The upper limit for the end of the kernel memory.  */
-#define KMEM_MAX	(240 * 0x100000)
-
-  if (CHECK_FLAG (mbi->flags, 6))
-    {
-      memory_map_t *mmap;
-
-      for (mmap = (memory_map_t *) mbi->mmap_addr;
-	   (uint32_t) mmap < mbi->mmap_addr + mbi->mmap_length;
-	   mmap = (memory_map_t *) ((uint32_t) mmap
-				    + mmap->size + sizeof (mmap->size)))
-	{
-	  if (mmap->type != 1)
-	    continue;
-
-	  if (((uint32_t) mmap->length) >= KMEM_SIZE
-	      && ((uint32_t) mmap->base_addr) <= KMEM_MAX - KMEM_SIZE)
-	    {
-	      uint32_t high = ((uint32_t) mmap->base_addr)
-			       + ((uint32_t) mmap->length);
-	      uint32_t low;
-
-	      if (high > KMEM_MAX)
-		high = KMEM_MAX;
-	      low = high - KMEM_SIZE;
-	      /* Round up to the next super page (4 MB).  */
-	      low = (low + 0x3fffff) & ~0x3fffff;
-
-	      add_memory_map (low, high, L4_MEMDESC_RESERVED, 0);
-	    }
-	}
-    }
-  else if (CHECK_FLAG (mbi->flags, 0))
-    {
-      if ((mbi->mem_upper << 10) >= KMEM_SIZE)
-	{
-	  uint32_t high = (mbi->mem_upper << 10) + 0x100000;
-	  uint32_t low;
-
-	  if (high > KMEM_MAX)
-	    high = KMEM_MAX;
-
-	  low = high - KMEM_SIZE;
-	  /* Round up to the next super page (4 MB).  */
-	  low = (low + 0x3fffff) & ~0x3fffff;
-
-	  add_memory_map (low, high, L4_MEMDESC_RESERVED, 0);
-	}
-    }
-
-  /* Now protect ourselves and the mulitboot info (at least the module
-     configuration.  */
-  loader_add_region (program_name, (l4_word_t) &_start, (l4_word_t) &_end);
-
-  start = (l4_word_t) mbi;
-  end = start + sizeof (*mbi);
-  loader_add_region ("grub-mbi", start, end);
-  
-  if (CHECK_FLAG (mbi->flags, 3) && mbi->mods_count)
-    {
-      module_t *mod = (module_t *) mbi->mods_addr;
-      int nr;
-
-      start = (l4_word_t) mod;
-      end = ((l4_word_t) mod) + mbi->mods_count * sizeof (*mod);
-      loader_add_region ("grub-mods", start, end);
-
-      start = (l4_word_t) mod[0].string;
-      end = start + 1;
-      for (nr = 0; nr < mbi->mods_count; nr++)
-	{
-	  char *str = (char *) mod[nr].string;
-
-	  if (str)
-	    {
-	      if (((l4_word_t) str) < start)
-		start = (l4_word_t) str;
-	      while (*str)
-		str++;
-	      if (((l4_word_t) str) + 1 > end)
-		end = (l4_word_t) str + 1;
-	    }
-	}
-      loader_add_region ("grub-mods-cmdlines", start, end);
-    }
-}
diff -ruN ../contrib/ref/hurd-l4/laden/laden.c laden/laden.c
--- ../contrib/ref/hurd-l4/laden/laden.c	2005-02-14 16:32:45.000000000 +0100
+++ laden/laden.c	2005-02-21 15:43:19.000000000 +0100
@@ -102,7 +102,7 @@
 }
 
 
-static void
+void
 parse_args (int argc, char *argv[])
 {
   int i = 1;
@@ -192,12 +192,8 @@
 int
 main (int argc, char *argv[])
 {
-  parse_args (argc, argv);
-
   debug ("%s " PACKAGE_VERSION "\n", program_name);
 
-  find_components ();
-
   load_components ();
 
   kip_fixup ();
diff -ruN ../contrib/ref/hurd-l4/laden/laden.h laden/laden.h
--- ../contrib/ref/hurd-l4/laden/laden.h	2005-02-14 16:32:45.000000000 +0100
+++ laden/laden.h	2005-02-21 15:43:51.000000000 +0100
@@ -30,6 +30,11 @@
 #include "shutdown.h"
 #include "loader.h"
 
+
+/* Check if the bit BIT in FLAGS is set.  */
+#define CHECK_FLAG(flags,bit)	((flags) & (1 << (bit)))
+
+
 
 /* The program name.  */
 extern char *program_name;
@@ -37,10 +42,6 @@
 #define BUG_ADDRESS	"<[email protected]>"
 
 
-/* Find the kernel, the initial servers and the other information
-   required for booting.  */
-void find_components (void);
-
 /* Start kernel.  IP is the entry point.  */
 void start_kernel (l4_word_t ip);
 
@@ -85,8 +86,7 @@
    descriptors to be loaded.  */
 int load_mem_info (l4_memory_desc_t memdesc, int nr);
 
-
-/* The generic code defines these functions.  */
+void parse_args (int, char**);
 
 void kip_fixup (void);
 
diff -ruN ../contrib/ref/hurd-l4/libl4/l4/bootinfo.h libl4/l4/bootinfo.h
--- ../contrib/ref/hurd-l4/libl4/l4/bootinfo.h	1970-01-01 01:00:00.000000000 +0100
+++ libl4/l4/bootinfo.h	2005-02-17 12:03:01.000000000 +0100
@@ -0,0 +1,199 @@
+/* l4/bootinfo.h - Public interface to the L4 bootinfo structures.
+   Copyright (C) 2005 Free Software Foundation, Inc.
+   Written by Matthieu Lemerre <[EMAIL PROTECTED]>.
+
+   This file is part of the GNU L4 library.
+ 
+   The GNU L4 library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public License
+   as published by the Free Software Foundation; either version 2.1 of
+   the License, or (at your option) any later version.
+ 
+   The GNU L4 library 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 Lesser General Public License for more details.
+ 
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU L4 library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+   02111-1307, USA.  */
+
+#ifndef _L4_BOOTINFO_H
+#define _L4_BOOTINFO_H  1
+
+#include <l4/features.h>
+#include <l4/types.h>
+
+#define _L4_BOOTINFO_MAGIC  0x14b0021d
+#define _L4_BOOTINFO_VERSION  1
+
+
+/* 
+ * Implemented types 
+ */
+#define _L4_BOOTINFO_MULTIBOOT	  0x0102
+#define _L4_BOOTINFO_MODULE	  0x0001
+
+
+/*
+ * Generic BootInfo structures
+ */
+
+struct _L4_generic_bootinfo
+{
+  _L4_word_t magic;
+  _L4_word_t version;
+  _L4_word_t size;
+  _L4_word_t first_entry;
+  _L4_word_t num_entries;
+  _L4_word_t padded[3];
+};
+
+typedef struct _L4_generic_bootinfo *_L4_generic_bootinfo_t;
+
+struct _L4_generic_boot_rec
+{
+  _L4_word_t type;
+  _L4_word_t version;
+  _L4_word_t offset_next;
+};
+
+typedef struct _L4_generic_boot_rec *_L4_generic_boot_rec_t;
+
+static inline _L4_word_t
+_L4_attribute_always_inline
+_L4_generic_bootinfo_valid (_L4_generic_bootinfo_t bootinfo)
+{
+  return (bootinfo->magic == _L4_BOOTINFO_MAGIC
+	  && bootinfo->version == _L4_BOOTINFO_VERSION);
+}
+
+static inline _L4_word_t
+_L4_attribute_always_inline
+_L4_generic_bootinfo_size (_L4_generic_bootinfo_t bootinfo)
+{
+  return bootinfo->size;
+}
+
+static inline _L4_generic_boot_rec_t
+_L4_attribute_always_inline
+_L4_generic_bootinfo_first_entry (_L4_generic_bootinfo_t bootinfo)
+{
+  return (_L4_generic_boot_rec_t) (((_L4_word_t) bootinfo) + bootinfo->first_entry);
+}
+
+static inline _L4_word_t
+_L4_attribute_always_inline
+_L4_generic_bootinfo_entries (_L4_generic_bootinfo_t bootinfo)
+{
+  return bootinfo->num_entries;
+}
+
+static inline _L4_word_t
+_L4_attribute_always_inline
+_L4_generic_boot_rec_type (_L4_generic_boot_rec_t boot_rec)
+{
+  return boot_rec->type;
+}
+
+static inline _L4_generic_boot_rec_t
+_L4_attribute_always_inline
+_L4_generic_boot_rec_next (_L4_generic_boot_rec_t boot_rec)
+{
+  return (_L4_generic_boot_rec_t) (((_L4_word_t) boot_rec) + boot_rec->offset_next);
+}
+
+
+/* 
+ * Bootinfo type: Multiboot info (type 0x0102)
+ * Delivers location of the first byte of the mutiboot structure
+ */
+
+struct _L4_generic_bootinfo_MBI
+{
+  _L4_word_t type;
+  _L4_word_t version;
+  _L4_word_t offset_next;
+  _L4_word_t address;
+};
+
+typedef struct _L4_generic_bootinfo_MBI *_L4_generic_bootinfo_MBI_t;
+
+static inline _L4_word_t
+_L4_attribute_always_inline
+_L4_MBI_address (_L4_generic_bootinfo_MBI_t mbi)
+{
+  return mbi->address;
+}
+
+static inline _L4_word_t
+_L4_attribute_always_inline
+_L4_MBI_address_from_bootinfo (_L4_generic_bootinfo_t bi)
+{
+  _L4_generic_boot_rec_t boot_rec;
+  int num_entries = (int) bi->num_entries;
+  for (boot_rec = (_L4_generic_boot_rec_t) _L4_generic_bootinfo_first_entry (bi); 
+       boot_rec->type != _L4_BOOTINFO_MULTIBOOT && num_entries-- > 0;			      
+       boot_rec += boot_rec->offset_next);
+  if (!num_entries)
+    return 0;
+  return _L4_MBI_address ((_L4_generic_bootinfo_MBI_t) boot_rec);
+}
+  
+
+
+/*
+ * Module Type (type 0x0001)
+ * Binary file inserted in the memory by the bootloader
+ */
+
+struct _L4_generic_bootinfo_module
+{
+  _L4_word_t type;
+  _L4_word_t version;
+  _L4_word_t offset_next;
+  _L4_word_t start;
+  _L4_word_t size;
+  _L4_word_t cmdline_offset;
+};
+
+typedef struct _L4_generic_bootinfo_module *_L4_generic_bootinfo_module_t;
+
+static inline _L4_word_t
+_L4_attribute_always_inline
+_L4_module_start (_L4_generic_bootinfo_module_t mod)
+{
+  return mod->start;
+}
+
+static inline _L4_word_t
+_L4_attribute_always_inline
+_L4_module_size (_L4_generic_bootinfo_module_t mod)
+{
+  return mod->size;
+}
+
+static inline _L4_word_t
+_L4_attribute_always_inline
+_L4_module_cmdline_offset (_L4_generic_bootinfo_module_t mod)
+{
+  return mod->cmdline_offset;
+}
+
+
+static inline _L4_word_t
+_L4_attribute_always_inline
+_L4_module_cmdline (_L4_generic_bootinfo_module_t mod)
+{
+  return ((l4_word_t) mod + mod->cmdline_offset);
+}
+
+
+
+#ifdef _L4_INTERFACE_GNU
+#include <l4/gnu/bootinfo.h>
+#endif 
+
+#endif /* l4/bootinfo.h */
+
diff -ruN ../contrib/ref/hurd-l4/libl4/l4/gnu/bootinfo.h libl4/l4/gnu/bootinfo.h
--- ../contrib/ref/hurd-l4/libl4/l4/gnu/bootinfo.h	1970-01-01 01:00:00.000000000 +0100
+++ libl4/l4/gnu/bootinfo.h	2005-02-17 12:03:09.000000000 +0100
@@ -0,0 +1,126 @@
+/* l4/bootinfo.h - Public GNU interface to the L4 bootinfo structures.
+   Copyright (C) 2005 Free Software Foundation, Inc.
+   Written by Alexandre Buisse <[EMAIL PROTECTED]>.
+
+   This file is part of the GNU L4 library.
+ 
+   The GNU L4 library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public License
+   as published by the Free Software Foundation; either version 2.1 of
+   the License, or (at your option) any later version.
+ 
+   The GNU L4 library 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 Lesser General Public License for more details.
+ 
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU L4 library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+   02111-1307, USA.  */
+
+
+#ifndef _L4_BOOTINFO_H
+# error "Never use <l4/gnu/bootinfo.h> directly; include <l4/bootinfo.h> instead."
+#endif
+
+typedef struct _L4_generic_bootinfo l4_generic_bootinfo;
+
+typedef _L4_generic_bootinfo_t l4_generic_bootinfo_t;
+
+typedef struct _L4_generic_boot_rec l4_generic_boot_rec;
+
+typedef _L4_generic_boot_rec_t l4_generic_boot_rec_t;
+
+static inline l4_word_t
+_L4_attribute_always_inline
+l4_generic_bootinfo_valid (l4_generic_bootinfo_t bootinfo)
+{
+  return _L4_generic_bootinfo_valid (bootinfo);
+}
+
+static inline l4_word_t
+_L4_attribute_always_inline
+l4_generic_bootinfo_size (l4_generic_bootinfo_t bootinfo)
+{
+  return _L4_generic_bootinfo_size (bootinfo);
+}
+
+static inline l4_generic_boot_rec_t
+_L4_attribute_always_inline
+l4_generic_bootinfo_first_entry (l4_generic_bootinfo_t bootinfo)
+{
+  return _L4_generic_bootinfo_first_entry (bootinfo);
+}
+
+static inline l4_word_t
+_L4_attribute_always_inline
+l4_generic_bootinfo_entries (l4_generic_bootinfo_t bootinfo)
+{
+  return _L4_generic_bootinfo_entries (bootinfo);
+}
+
+static inline l4_word_t
+_L4_attribute_always_inline
+l4_generic_boot_rec_type (l4_generic_boot_rec_t boot_rec)
+{
+  return _L4_generic_boot_rec_type (boot_rec);
+}
+
+static inline l4_generic_boot_rec_t
+_L4_attribute_always_inline
+l4_generic_boot_rec_next (l4_generic_boot_rec_t boot_rec)
+{
+  return _L4_generic_boot_rec_next (boot_rec);
+}
+
+typedef struct _L4_generic_bootinfo_MBI l4_generic_bootinfo_MBI;
+
+typedef _L4_generic_bootinfo_MBI_t l4_generic_bootinfo_MBI_t;
+
+static inline l4_word_t
+_L4_attribute_always_inline
+l4_MBI_address (l4_generic_bootinfo_MBI_t mbi)
+{
+  return _L4_MBI_address (mbi);
+}
+
+static inline l4_word_t
+_L4_attribute_always_inline
+l4_MBI_address_from_bootinfo (l4_generic_bootinfo_t bootinfo)
+{
+  return _L4_MBI_address_from_bootinfo (bootinfo);
+}
+
+
+typedef struct _L4_generic_bootinfo_module l4_generic_bootinfo_module;
+
+typedef _L4_generic_bootinfo_module_t l4_generic_bootinfo_module_t;
+
+static inline l4_word_t
+_L4_attribute_always_inline
+l4_module_start (l4_generic_bootinfo_module_t mod)
+{
+  return _L4_module_start (mod);
+}
+
+static inline l4_word_t
+_L4_attribute_always_inline
+l4_module_size (l4_generic_bootinfo_module_t mod)
+{
+  return _L4_module_size (mod);
+}
+
+static inline l4_word_t
+_L4_attribute_always_inline
+l4_module_cmdline_offset (l4_generic_bootinfo_module_t mod)
+{
+  return _L4_module_cmdline_offset (mod);
+}
+
+static inline l4_word_t
+_L4_attribute_always_inline
+l4_module_cmdline(l4_generic_bootinfo_module_t mod)
+{
+  return _L4_module_cmdline (mod);
+}
diff -ruN ../contrib/ref/hurd-l4/libl4/l4.h libl4/l4.h
--- ../contrib/ref/hurd-l4/libl4/l4.h	2005-02-14 16:32:34.000000000 +0100
+++ libl4/l4.h	2005-02-17 11:59:00.000000000 +0100
@@ -31,5 +31,6 @@
 #include <l4/ipc.h>
 #include <l4/misc.h>
 #include <l4/arch.h>
+#include <l4/bootinfo.h>
 
 #endif	/* l4.h */
diff -ruN ../contrib/ref/hurd-l4/wortel/ia32-cmain.c wortel/ia32-cmain.c
--- ../contrib/ref/hurd-l4/wortel/ia32-cmain.c	2005-02-14 16:32:45.000000000 +0100
+++ wortel/ia32-cmain.c	2005-02-18 14:07:24.000000000 +0100
@@ -24,11 +24,13 @@
 
 #include <alloca.h>
 #include <stdint.h>
+#include <string.h>
 
 #include <l4/globals.h>
 #include <l4/init.h>
 #include <l4/stubs.h>
 #include <l4/stubs-init.h>
+#include <l4/bootinfo.h>
 
 #include "wortel-intern.h"
 #include "multiboot.h"
@@ -44,22 +46,33 @@
 void
 cmain (void)
 {
-  multiboot_info_t *mbi;
+  l4_generic_bootinfo_t bi;
   int argc = 0;
   char **argv = 0;
 
   l4_init ();
   l4_init_stubs ();
-
-  mbi = (multiboot_info_t *) l4_boot_info ();
-  debug ("Multiboot Info: %p\n", mbi);
-
-  if (CHECK_FLAG (mbi->flags, 3) && mbi->mods_count > 0)
-    {
+  
+  bi = (l4_generic_bootinfo_t) (l4_boot_info());
+  
+  /* We are only interested in wortel cmdline */
+  int nr;
+  l4_word_t br = (l4_word_t) l4_generic_bootinfo_first_entry (bi);
+  for (nr = (int) l4_generic_bootinfo_entries (bi);
+       nr > 0;
+       nr--, br += (l4_word_t) ((l4_generic_boot_rec_t) br)->offset_next)
+  {
+    if (((l4_generic_boot_rec_t) br)->type == _L4_BOOTINFO_MODULE
+	  && strstr (((char*) l4_module_cmdline ((l4_generic_bootinfo_module_t) br)), "wortel"))
+      break;
+  }
+  
+  
+  if (nr) 
+  {
       /* A command line is available.  */
-      module_t *mod = (module_t *) mbi->mods_addr;
-      char *str = (char *) mod[0].string;
-      int nr = 0;
+      char *str = (char *) l4_module_cmdline ((l4_generic_bootinfo_module_t) br);
+      nr = 0;
 
       /* First time around we count the number of arguments.  */
       argc = 1;
@@ -77,7 +90,7 @@
       argv = alloca (sizeof (char *) * (argc + 1));
 
       /* Second time around we fill in the argv.  */
-      str = (char *) mod[0].string;
+      str = (char *) l4_module_cmdline ((l4_generic_bootinfo_module_t) br);
 
       while (*str && *str == ' ')
 	str++;
@@ -165,60 +178,91 @@
 void
 find_components (void)
 {
-  multiboot_info_t *mbi = (multiboot_info_t *) l4_boot_info ();
-
-  /* Load the module information.  */
-  if (CHECK_FLAG (mbi->flags, 3))
+  l4_generic_bootinfo_t bi = (l4_generic_bootinfo_t) l4_boot_info();
+  l4_generic_bootinfo_module_t mod;
+  multiboot_info_t *mbi = (multiboot_info_t*) (l4_MBI_address_from_bootinfo (bi));
+  int nr, mod_count;
+  char* str;
+  l4_word_t br = (l4_word_t) l4_generic_bootinfo_first_entry (bi);
+
+  /* Find all the modules after wortel (they should have been added with
+   * respect for their order). */
+  for (nr = (int) l4_generic_bootinfo_entries (bi), mod_count = 0;
+       nr > 0; 
+       nr--, br += (l4_word_t) ((l4_generic_boot_rec_t) br)->offset_next) 
+  {
+    /* Do nothing for laden and sigma0. */
+    if (((l4_generic_boot_rec_t) br)->type == _L4_BOOTINFO_MODULE 
+	  && (++mod_count > 2))
     {
-      module_t *mod = (module_t *) mbi->mods_addr;
-      unsigned int i;
+      mod = (l4_generic_bootinfo_module_t) br;
+      str = (char*) l4_module_cmdline (mod);
+      
+      /* Wortel should be the third on the list. */
+      if (mod_count == 3) 
+      {
+	/* Add its command line args to the list of unused pages. */
+	add_unused_area ((l4_word_t) str, strlen (str) + 1);
+	continue;
+      }
+
+      unsigned int old_mods_args_len;
+
+      /* Fill the mods structure with the relevant info */
+      mods[mod_count-4].name  = mod_names[mod_count-4];
+      mods[mod_count-4].start = l4_module_start (mod);
+      mods[mod_count-4].end   = l4_module_start (mod) + l4_module_size (mod);
+
+      /* We copy over the argument lines, so that we don't depend
+	 on the multiboot info structure anymore, and can reuse
+	 that memory.  */
+      mods[mod_count-4].args = &mods_args[mods_args_len];
+      old_mods_args_len = mods_args_len;
+      while (*str && mods_args_len < sizeof (mods_args))
+	mods_args[mods_args_len++] = *(str++);
+      if (mods_args_len == sizeof (mods_args))
+	panic ("No space to store the argument lines");
+      mods_args[mods_args_len++] = '\0';
+
+
+      /* Now we have to add the source string's area to the list
+	 of unused pages, as we touched that memory. */
+      add_unused_area ((l4_word_t) str,
+	                mods_args_len - old_mods_args_len);
+    }
 
-      /* Add the argument string of the first module to the list of
-	 unused pages.  */
-      add_unused_area ((l4_word_t) mod[0].string,
-		       strlen ((char *) mod[0].string) + 1);
-
-      mods_count = mbi->mods_count - 1;
-      if (mods_count > MOD_NUMBER)
-	mods_count = MOD_NUMBER;
+    /* Also add the generic bootinfo record to the list of unused pages.
+       FIXME: couldn't it be useful later ? */
+    switch (l4_generic_boot_rec_type ((l4_generic_boot_rec_t) br))
+    {
+      case _L4_BOOTINFO_MULTIBOOT:
+	add_unused_area ((l4_word_t) br,
+			  sizeof (l4_generic_bootinfo_MBI));
+	break;
+      case _L4_BOOTINFO_MODULE:
+	add_unused_area ((l4_word_t) br,
+			  sizeof (l4_generic_bootinfo_module));
+	break;
+      default:
+	panic ("Invalid generic bootinfo record type: 0x%x\n",
+	       l4_generic_boot_rec_type ((l4_generic_boot_rec_t) br));
+    }
+  }
 
-      /* Skip the entry for the rootserver.  */
-      mod++;
+  /* Add the MBI module info itself to the list of unused pages. */
+  add_unused_area ((l4_word_t) mbi->mods_addr,
+	            mbi->mods_count * sizeof (module_t));
 
-      for (i = 0; i < mods_count; i++)
-	{
-	  char *args;
-	  unsigned int old_mods_args_len;
+  /* Add the multiboot info to the list of unused pages.  */
+  add_unused_area ((l4_word_t) mbi, sizeof (*mbi));
 
-	  mods[i].name = mod_names[i];
-	  mods[i].start = mod[i].mod_start;
-	  mods[i].end = mod[i].mod_end;
-
-	  /* We copy over the argument lines, so that we don't depend
-	     on the multiboot info structure anymore, and can reuse
-	     that memory.  */
-	  mods[i].args = &mods_args[mods_args_len];
-	  args = (char *) mod[i].string;
-	  old_mods_args_len = mods_args_len;
-	  while (*args && mods_args_len < sizeof (mods_args))
-	    mods_args[mods_args_len++] = *(args++);
-	  if (mods_args_len == sizeof (mods_args))
-	    panic ("No space to store the argument lines");
-	  mods_args[mods_args_len++] = '\0';
-
-	  /* Now we have to add the source string's area to the list
-	     of unused pages, as we touched that memory.  */
-	  add_unused_area ((l4_word_t) mod[i].string,
-			   mods_args_len - old_mods_args_len);
-	}
+  /* Add the generic bootinfo to the list of unused pages. */
+  add_unused_area ((l4_word_t) bi, sizeof (l4_generic_bootinfo));
 
-      /* Add the module info itself to the list of unused pages.  */
-      add_unused_area ((l4_word_t) mbi->mods_addr,
-		       mbi->mods_count * sizeof (module_t));
-    }
+  if (mod_count != MOD_NUMBER + 3)
+    panic ("Bad number of modules: %d instead of required %d\n", mod_count, MOD_NUMBER + 3);
+  mods_count = MOD_NUMBER;
 
-  /* Add the multiboot info to the list of unused pages.  */
-  add_unused_area ((l4_word_t) mbi, sizeof (*mbi));
 
   /* Finally initialize the wortel area variables.  */
   wortel_start = (l4_word_t) &_start;
_______________________________________________
L4-hurd mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/l4-hurd

Reply via email to