--- ref/hurd-l4/libl4/l4.h 2005-01-22 03:19:59.000000000 +0100 +++ hurd-l4/libl4/l4.h 2005-02-13 19:47:44.000000000 +0100 @@ -31,5 +31,6 @@ #include #include #include +#include #endif /* l4.h */ --- ref/hurd-l4/libl4/l4/bootinfo.h 1970-01-01 01:00:00.000000000 +0100 +++ hurd-l4/libl4/l4/bootinfo.h 2005-02-13 22:37:41.988211024 +0100 @@ -0,0 +1,190 @@ +/* l4/bootinfo.h - Public interface to the L4 bootinfo structures. + Copyright (C) 2005 Free Software Foundation, Inc. + Written by Matthieu Lemerre . + + 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 +#include + +#define _L4_BOOT_INFO_MAGIC 0x14b0021d +#define _L4_BOOT_INFO_VERSION 1 + + +/* + * Implemented types + */ +#define _L4_BOOT_INFO_MULTIBOOT 0x0102 +#define _L4_BOOT_INFO_MODULE 0x0001 + + +/* + * Generic BootInfo structures + */ + +struct _L4_generic_boot_info +{ + _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_boot_info *_L4_generic_boot_info_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_boot_info_valid (_L4_generic_boot_info_t boot_info) +{ + return (boot_info->magic == _L4_BOOT_INFO_MAGIC + && boot_info->version == _L4_BOOT_INFO_VERSION); +} + +static inline _L4_word_t +_L4_attribute_always_inline +_L4_generic_boot_info_size (_L4_generic_boot_info_t boot_info) +{ + return boot_info->size; +} + +static inline _L4_generic_boot_rec_t +_L4_attribute_always_inline +_L4_generic_boot_info_first_entry (_L4_generic_boot_info_t boot_info) +{ + return (_L4_generic_boot_rec_t) (((_L4_word_t) boot_info) + boot_info->first_entry); +} + +static inline _L4_word_t +_L4_attribute_always_inline +_L4_generic_boot_info_entries (_L4_generic_boot_info_t boot_info) +{ + return boot_info->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_boot_info_MBI +{ + _L4_word_t type; + _L4_word_t version; + _L4_word_t offset_next; + _L4_word_t address; +}; + +typedef struct _L4_generic_boot_info_MBI *_L4_generic_boot_info_MBI_t; + +static inline _L4_word_t +_L4_attribute_always_inline +_L4_MBI_address (_L4_generic_boot_info_MBI_t mbi) +{ + return mbi->address; +} + +static inline _L4_word_t +_L4_attribute_always_inline +_L4_MBI_address_from_bootinfo (_L4_generic_boot_info_t boot_info) +{ + _L4_generic_boot_rec_t boot_rec; + for (boot_rec = (_L4_generic_boot_rec_t) boot_info->first_entry; + boot_rec->type != _L4_BOOT_INFO_MULTIBOOT && + (_L4_word_t) boot_rec < ((_L4_word_t)boot_info + boot_info->size); + boot_rec += boot_rec->offset_next); + if ((_L4_word_t) boot_rec >= ((_L4_word_t)boot_info + boot_info->size)) + return 0; + return _L4_MBI_address ((_L4_generic_boot_info_MBI_t) boot_rec); +} + + + +/* + * Module Type (type 0x0001) + * Binary file inserted in the memory by the bootloader + */ + +struct _L4_generic_boot_info_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_boot_info_module *_L4_generic_boot_info_module_t; + +static inline _L4_word_t +_L4_attribute_always_inline +_L4_module_start (_L4_generic_boot_info_module_t mod) +{ + return mod->start; +} + +static inline _L4_word_t +_L4_attribute_always_inline +_L4_module_size (_L4_generic_boot_info_module_t mod) +{ + return mod->size; +} + +static inline _L4_word_t +_L4_attribute_always_inline +_L4_module_cmdline (_L4_generic_boot_info_module_t mod) +{ + return mod->cmdline_offset; +} + + +#ifdef _L4_INTERFACE_GNU +#include +#endif + +#endif /* l4/bootinfo.h */ + --- ref/hurd-l4/libl4/l4/gnu/bootinfo.h 1970-01-01 01:00:00.000000000 +0100 +++ hurd-l4/libl4/l4/gnu/bootinfo.h 2005-02-13 21:56:55.049202296 +0100 @@ -0,0 +1,120 @@ +/* l4/bootinfo.h - Public GNU interface to the L4 bootinfo structures. + Copyright (C) 2005 Free Software Foundation, Inc. + Written by Alexandre Buisse . + + 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 directly; include instead." +#endif + +typedef struct _L4_generic_boot_info l4_generic_boot_info; + +typedef _L4_generic_boot_info_t l4_generic_boot_info_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_boot_info_valid (l4_generic_boot_info_t boot_info) +{ + return _L4_generic_boot_info_valid (boot_info); +} + +static inline l4_word_t +_L4_attribute_always_inline +l4_generic_boot_info_size (l4_generic_boot_info_t boot_info) +{ + return _L4_generic_boot_info_size (boot_info); +} + +static inline l4_generic_boot_rec_t +_L4_attribute_always_inline +l4_generic_boot_info_first_entry (l4_generic_boot_info_t boot_info) +{ + return _L4_generic_boot_info_first_entry (boot_info); +} + +static inline l4_word_t +_L4_attribute_always_inline +l4_generic_boot_info_entries (l4_generic_boot_info_t boot_info) +{ + return _L4_generic_boot_info_entries (boot_info); +} + +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_boot_info_MBI l4_generic_boot_info_MBI; + +typedef _L4_generic_boot_info_MBI_t l4_generic_boot_info_MBI_t; + +static inline l4_word_t +_L4_attribute_always_inline +l4_MBI_address (l4_generic_boot_info_MBI_t mbi) +{ + return _L4_MBI_address (mbi); +} + +static inline l4_word_t +_L4_attribute_always_inline +l4_MBI_address_from_bootinfo (l4_generic_boot_info_t boot_info) +{ + return _L4_MBI_address_from_bootinfo (boot_info); +} + + +typedef struct _L4_generic_boot_info_module l4_generic_boot_info_module; + +typedef _L4_generic_boot_info_module_t l4_generic_boot_info_module_t; + +static inline l4_word_t +_L4_attribute_always_inline +l4_module_start (l4_generic_boot_info_module_t mod) +{ + return _L4_module_start (mod); +} + +static inline l4_word_t +_L4_attribute_always_inline +l4_module_size (l4_generic_boot_info_module_t mod) +{ + return _L4_module_size (mod); +} + +static inline l4_word_t +_L4_attribute_always_inline +l4_module_cmdline (l4_generic_boot_info_module_t mod) +{ + return _L4_module_cmdline (mod); +} + --- ref/hurd-l4/include/l4/gnu/bootinfo.h 1970-01-01 01:00:00.000000000 +0100 +++ hurd-l4/include/l4/gnu/bootinfo.h 2005-02-13 21:56:50.506892832 +0100 @@ -0,0 +1,120 @@ +/* l4/bootinfo.h - Public GNU interface to the L4 bootinfo structures. + Copyright (C) 2005 Free Software Foundation, Inc. + Written by Alexandre Buisse . + + 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 directly; include instead." +#endif + +typedef struct _L4_generic_boot_info l4_generic_boot_info; + +typedef _L4_generic_boot_info_t l4_generic_boot_info_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_boot_info_valid (l4_generic_boot_info_t boot_info) +{ + return _L4_generic_boot_info_valid (boot_info); +} + +static inline l4_word_t +_L4_attribute_always_inline +l4_generic_boot_info_size (l4_generic_boot_info_t boot_info) +{ + return _L4_generic_boot_info_size (boot_info); +} + +static inline l4_generic_boot_rec_t +_L4_attribute_always_inline +l4_generic_boot_info_first_entry (l4_generic_boot_info_t boot_info) +{ + return _L4_generic_boot_info_first_entry (boot_info); +} + +static inline l4_word_t +_L4_attribute_always_inline +l4_generic_boot_info_entries (l4_generic_boot_info_t boot_info) +{ + return _L4_generic_boot_info_entries (boot_info); +} + +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_boot_info_MBI l4_generic_boot_info_MBI; + +typedef _L4_generic_boot_info_MBI_t l4_generic_boot_info_MBI_t; + +static inline l4_word_t +_L4_attribute_always_inline +l4_MBI_address (l4_generic_boot_info_MBI_t mbi) +{ + return _L4_MBI_address (mbi); +} + +static inline l4_word_t +_L4_attribute_always_inline +l4_MBI_address_from_bootinfo (l4_generic_boot_info_t boot_info) +{ + return _L4_MBI_address_from_bootinfo (boot_info); +} + + +typedef struct _L4_generic_boot_info_module l4_generic_boot_info_module; + +typedef _L4_generic_boot_info_module_t l4_generic_boot_info_module_t; + +static inline l4_word_t +_L4_attribute_always_inline +l4_module_start (l4_generic_boot_info_module_t mod) +{ + return _L4_module_start (mod); +} + +static inline l4_word_t +_L4_attribute_always_inline +l4_module_size (l4_generic_boot_info_module_t mod) +{ + return _L4_module_size (mod); +} + +static inline l4_word_t +_L4_attribute_always_inline +l4_module_cmdline (l4_generic_boot_info_module_t mod) +{ + return _L4_module_cmdline (mod); +} + --- ref/hurd-l4/include/l4/bootinfo.h 1970-01-01 01:00:00.000000000 +0100 +++ hurd-l4/include/l4/bootinfo.h 2005-02-13 22:37:36.323072256 +0100 @@ -0,0 +1,190 @@ +/* l4/bootinfo.h - Public interface to the L4 bootinfo structures. + Copyright (C) 2005 Free Software Foundation, Inc. + Written by Matthieu Lemerre . + + 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 +#include + +#define _L4_BOOT_INFO_MAGIC 0x14b0021d +#define _L4_BOOT_INFO_VERSION 1 + + +/* + * Implemented types + */ +#define _L4_BOOT_INFO_MULTIBOOT 0x0102 +#define _L4_BOOT_INFO_MODULE 0x0001 + + +/* + * Generic BootInfo structures + */ + +struct _L4_generic_boot_info +{ + _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_boot_info *_L4_generic_boot_info_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_boot_info_valid (_L4_generic_boot_info_t boot_info) +{ + return (boot_info->magic == _L4_BOOT_INFO_MAGIC + && boot_info->version == _L4_BOOT_INFO_VERSION); +} + +static inline _L4_word_t +_L4_attribute_always_inline +_L4_generic_boot_info_size (_L4_generic_boot_info_t boot_info) +{ + return boot_info->size; +} + +static inline _L4_generic_boot_rec_t +_L4_attribute_always_inline +_L4_generic_boot_info_first_entry (_L4_generic_boot_info_t boot_info) +{ + return (_L4_generic_boot_rec_t) (((_L4_word_t) boot_info) + boot_info->first_entry); +} + +static inline _L4_word_t +_L4_attribute_always_inline +_L4_generic_boot_info_entries (_L4_generic_boot_info_t boot_info) +{ + return boot_info->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_boot_info_MBI +{ + _L4_word_t type; + _L4_word_t version; + _L4_word_t offset_next; + _L4_word_t address; +}; + +typedef struct _L4_generic_boot_info_MBI *_L4_generic_boot_info_MBI_t; + +static inline _L4_word_t +_L4_attribute_always_inline +_L4_MBI_address (_L4_generic_boot_info_MBI_t mbi) +{ + return mbi->address; +} + +static inline _L4_word_t +_L4_attribute_always_inline +_L4_MBI_address_from_bootinfo (_L4_generic_boot_info_t boot_info) +{ + _L4_generic_boot_rec_t boot_rec; + for (boot_rec = (_L4_generic_boot_rec_t) boot_info->first_entry; + boot_rec->type != _L4_BOOT_INFO_MULTIBOOT && + (_L4_word_t) boot_rec < ((_L4_word_t)boot_info + boot_info->size); + boot_rec += boot_rec->offset_next); + if ((_L4_word_t) boot_rec >= ((_L4_word_t)boot_info + boot_info->size)) + return 0; + return _L4_MBI_address ((_L4_generic_boot_info_MBI_t) boot_rec); +} + + + +/* + * Module Type (type 0x0001) + * Binary file inserted in the memory by the bootloader + */ + +struct _L4_generic_boot_info_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_boot_info_module *_L4_generic_boot_info_module_t; + +static inline _L4_word_t +_L4_attribute_always_inline +_L4_module_start (_L4_generic_boot_info_module_t mod) +{ + return mod->start; +} + +static inline _L4_word_t +_L4_attribute_always_inline +_L4_module_size (_L4_generic_boot_info_module_t mod) +{ + return mod->size; +} + +static inline _L4_word_t +_L4_attribute_always_inline +_L4_module_cmdline (_L4_generic_boot_info_module_t mod) +{ + return mod->cmdline_offset; +} + + +#ifdef _L4_INTERFACE_GNU +#include +#endif + +#endif /* l4/bootinfo.h */ + --- ref/hurd-l4/include/l4.h 1970-01-01 01:00:00.000000000 +0100 +++ hurd-l4/include/l4.h 2005-02-13 19:47:44.000000000 +0100 @@ -0,0 +1,36 @@ +/* l4.h - Public interface to L4. + Copyright (C) 2003, 2005 Free Software Foundation, Inc. + Written by Marcus Brinkmann . + + 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_H +#define _L4_H 1 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif /* l4.h */ --- ref/hurd-l4/laden/Makefile.am 2004-11-17 17:31:17.000000000 +0100 +++ hurd-l4/laden/Makefile.am 2005-02-13 19:39:18.000000000 +0100 @@ -19,15 +19,16 @@ # 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 boot_PROGRAMS = laden laden_CPPFLAGS = -I$(srcdir) -I$(top_builddir)/include \ - -I$(top_srcdir)/libc-parts $(AM_CPPFLAGS) + -I$(top_srcdir)/libc-parts $(AM_CPPFLAGS) -I/l4/include laden_SOURCES = $(ARCH_SOURCES) \ output.h output.c output-none.c \ --- ref/hurd-l4/laden/ia32-cmain.c 2004-11-17 17:21:39.000000000 +0100 +++ hurd-l4/laden/ia32-cmain.c 2005-02-13 21:39:44.431879944 +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); - } -} --- ref/hurd-l4/laden/ia32-btinfo.c 1970-01-01 01:00:00.000000000 +0100 +++ hurd-l4/laden/ia32-btinfo.c 2005-02-13 22:50:23.305473208 +0100 @@ -0,0 +1,321 @@ +/* ia32-btinfo.c - Generic bootinfo support. + Copyright (C) 2005 Free Software Foundation, Inc. + Written by Alexandre Buisse . + + 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 + +#include + +#include "multiboot.h" + + +static int num_entries = 1; +static l4_word_t next; +static l4_generic_boot_info_t bootinfo = (l4_generic_boot_info_t) 0x30000; /* FIXME: should we place it here ? */ +static multiboot_info_t *mbi; + + +/* This adds the module info in a new generic bootinfo record */ +static void +add_generic_bootinfo_module (module_t * mod) +{ + l4_generic_boot_info_module_t bootinfo_mod = (l4_generic_boot_info_module_t) next; + + bootinfo_mod->type = _L4_BOOT_INFO_MODULE; + bootinfo_mod->version = _L4_BOOT_INFO_VERSION; + bootinfo_mod->offset_next = sizeof (l4_generic_boot_info_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) mod->string; + 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++; + return; +} + + +/* 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. FIXME: The rootserver might need the + information about the other modules, though. */ + 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 to a generic bootinfo structure */ +l4_word_t +mbi_to_generic_bootinfo (multiboot_info_t *multiboot_info) +{ + mbi = multiboot_info; + /* Initial values */ + bootinfo->magic = _L4_BOOT_INFO_MAGIC; + bootinfo->version = _L4_BOOT_INFO_VERSION; + bootinfo->first_entry = sizeof(l4_generic_boot_info); + next = (l4_word_t) ((l4_word_t) bootinfo + bootinfo->first_entry); + + /* MBI structure */ + l4_generic_boot_info_MBI_t bootinfo_mbi = (l4_generic_boot_info_MBI_t) next; + bootinfo_mbi->type = _L4_BOOT_INFO_MULTIBOOT; + bootinfo_mbi->version = _L4_BOOT_INFO_VERSION; + bootinfo_mbi->offset_next = sizeof(l4_generic_boot_info_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; +} + + --- ref/hurd-l4/laden/laden.h 2004-03-16 04:37:32.000000000 +0100 +++ hurd-l4/laden/laden.h 2005-02-13 21:46:41.309504912 +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; @@ -39,7 +44,7 @@ /* Find the kernel, the initial servers and the other information required for booting. */ -void find_components (void); +/*void find_components (void);*/ /* Start kernel. IP is the entry point. */ void start_kernel (l4_word_t ip); @@ -85,8 +90,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); --- ref/hurd-l4/laden/laden.c 2005-01-07 12:36:38.000000000 +0100 +++ hurd-l4/laden/laden.c 2005-02-13 21:40:28.250218544 +0100 @@ -102,7 +102,7 @@ } -static void +void parse_args (int argc, char *argv[]) { int i = 1; @@ -192,11 +192,11 @@ int main (int argc, char *argv[]) { - parse_args (argc, argv); + /*parse_args (argc, argv);*/ debug ("%s " PACKAGE_VERSION "\n", program_name); - find_components (); + /* find_components (); */ load_components (); --- ref/hurd-l4/wortel/ia32-cmain.c 2004-10-07 18:10:26.000000000 +0200 +++ hurd-l4/wortel/ia32-cmain.c 2005-02-13 23:23:47.631769296 +0100 @@ -29,6 +29,7 @@ #include #include #include +#include #include "wortel-intern.h" #include "multiboot.h" @@ -47,13 +48,16 @@ multiboot_info_t *mbi; int argc = 0; char **argv = 0; + debug ("we're in wortel!\n"); + mbi = (multiboot_info_t *) (l4_MBI_address_from_bootinfo ((l4_generic_boot_info_t) (l4_boot_info()))); + if (!mbi) + panic ("Unable to find MBI again\n"); + debug ("Multiboot Info: %p\n", mbi); + 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) { /* A command line is available. */