commit-hurd
[Top][All Lists]
Advanced

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

hurd-l4/laden ia32-cmain.c kip-fixup.c laden.c ...


From: Marcus Brinkmann
Subject: hurd-l4/laden ia32-cmain.c kip-fixup.c laden.c ...
Date: Wed, 03 Sep 2003 21:29:36 -0400

CVSROOT:        /cvsroot/hurd
Module name:    hurd-l4
Branch:         
Changes by:     Marcus Brinkmann <address@hidden>       03/09/03 21:29:35

Modified files:
        laden          : ia32-cmain.c kip-fixup.c laden.c laden.h 
                         loader.c multiboot.h output-vga.c 

Log message:
        Simplify panic(), make it prefix all panics with "laden: error: ".
        
        Truncate memory descriptors that stretch out until the very last 
possible
        page.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd-l4/laden/ia32-cmain.c.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd-l4/laden/kip-fixup.c.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd-l4/laden/laden.c.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd-l4/laden/laden.h.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd-l4/laden/loader.c.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd-l4/laden/multiboot.h.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd-l4/laden/output-vga.c.diff?tr1=1.1&tr2=1.2&r1=text&r2=text

Patches:
Index: hurd-l4/laden/ia32-cmain.c
diff -u hurd-l4/laden/ia32-cmain.c:1.1 hurd-l4/laden/ia32-cmain.c:1.2
--- hurd-l4/laden/ia32-cmain.c:1.1      Sat Jul 26 13:26:09 2003
+++ hurd-l4/laden/ia32-cmain.c  Wed Sep  3 21:29:35 2003
@@ -19,6 +19,7 @@
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA. */
 
 #include <alloca.h>
+#include <stdint.h>
 
 #include "laden.h"
 
@@ -44,17 +45,17 @@
 /* Setup the argument vector and pass control over to the main
    function.  */
 void
-cmain (unsigned long magic, multiboot_info_t *mbi)
+cmain (uint32_t magic, multiboot_info_t *mbi)
 {
   int argc = 0;
   char **argv = 0;
 
   /* Verify that we are booted by a Multiboot-compliant boot loader.  */
   if (magic != MULTIBOOT_BOOTLOADER_MAGIC)
-    panic ("Error: Invalid magic number: 0x%x", magic);
+    panic ("Invalid magic number: 0x%x", magic);
 
   if (!CHECK_FLAG (mbi->flags, 0) && !CHECK_FLAG (mbi->flags, 6))
-    panic ("Error: Bootloader did not provide a memory map");
+    panic ("Bootloader did not provide a memory map");
 
   if (CHECK_FLAG (mbi->flags, 2))
     {
@@ -111,7 +112,7 @@
   /* 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 = (unsigned long) mbi;
+  boot_info = (uint32_t) mbi;
 
   /* Now invoke the main function.  */
   main (argc, argv);
@@ -148,12 +149,13 @@
       int nr = 1;
 
       for (mmap = (memory_map_t *) mbi->mmap_addr;
-          (unsigned long) mmap < mbi->mmap_addr + mbi->mmap_length;
-          mmap = (memory_map_t *) ((unsigned long) mmap
+          (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%x%x, Length 0x%x%x\n",
-              nr++, mmap->type, mmap->base_addr_high, mmap->base_addr_low,
-              mmap->length_high, mmap->length_low);
+              nr++, mmap->type, mmap->base_addr >> 32,
+              mmap->base_addr & ((1ULL << 32) - 1),
+              mmap->length >> 32, mmap->length & ((1ULL << 32) - 1));
     }
 }
 
@@ -196,31 +198,43 @@
       memory_map_t *mmap;
 
       for (mmap = (memory_map_t *) mbi->mmap_addr;
-          (unsigned long) mmap < mbi->mmap_addr + mbi->mmap_length;
-          mmap = (memory_map_t *) ((unsigned long) mmap
+          (uint32_t) mmap < mbi->mmap_addr + mbi->mmap_length;
+          mmap = (memory_map_t *) ((uint32_t) mmap
                                    + mmap->size + sizeof (mmap->size)))
        {
-         unsigned long long end;
+         uint64_t end;
 
-         if (mmap->base_addr_high)
-           panic ("Error: L4 does not support more than 4 GB on ia32");
+         if (mmap->base_addr >> 32)
+           panic ("L4 does not support more than 4 GB on ia32");
 
-         end = (((unsigned long long) mmap->base_addr_high) << 32)
-           | mmap->base_addr_low;
-         end += (((unsigned long long) mmap->length_high) << 32)
-           | mmap->length_low;
+         end = mmap->base_addr + mmap->length;
 
-         if (end >> 32)
-           panic ("Error: L4 does not support more than 4 GB on ia32");
-
-         if ((end + (1 << 10) - 1) >> 32)
-           panic ("Error: L4 does not support exactly 4 GB on ia32");
+         if (end == (1ULL << 32))
+           {
+#if 0
+           panic ("L4 does not support exactly 4 GB on ia32");
+#elif 1
+             /* The L4 specification does not seem to allow this
+                configuration.  Truncate the region by dropping the
+                last page.  FIXME: kickstart overflows and sets the
+                high address to 0.  This is unambiguous, but needs to
+                be supported by sigma0 and the operating system.
+                Clarification of the specification is required.  */
+             end = (1ULL << 32) - (1 << 10);
+#else
+             /* This is effectively what kickstart does.  */
+             end = 0;
+#endif
+           }
+         else if (end >> 32)
+           panic ("L4 does not support more than 4 GB on ia32");
 
-         if (mmap->base_addr_low & 0x2ff || mmap->length_low & 0x2ff)
-           panic ("Error: Memory region (0x%x - 0x%x) is unaligned",
-                  mmap->base_addr_low, (unsigned long) end);
+         if (mmap->base_addr & ((1 << 10) - 1)
+             || mmap->length & ((1 << 10) - 1))
+           panic ("Memory region (0x%x - 0x%x) is unaligned",
+                  (uint32_t) mmap->base_addr, (uint32_t) end);
 
-         add_memory_map (mmap->base_addr_low, (unsigned long) 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);
@@ -230,10 +244,10 @@
     {
       /* mem_* are valid.  */
       if (mbi->mem_lower & 0x2ff)
-       panic ("Error: Lower memory end address 0x%x is unaligned",
+       panic ("Lower memory end address 0x%x is unaligned",
               mbi->mem_lower);
       if (mbi->mem_upper & 0x2ff)
-       panic ("Error: Upper memory end address 0x%x is unaligned",
+       panic ("Upper memory end address 0x%x is unaligned",
               mbi->mem_upper);
 
       add_memory_map (0, mbi->mem_lower << 10, L4_MEMDESC_CONVENTIONAL, 0);
@@ -255,18 +269,19 @@
       memory_map_t *mmap;
 
       for (mmap = (memory_map_t *) mbi->mmap_addr;
-          (unsigned long) mmap < mbi->mmap_addr + mbi->mmap_length;
-          mmap = (memory_map_t *) ((unsigned long) mmap
+          (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 (mmap->length_low >= KMEM_SIZE
-             && mmap->base_addr_low <= KMEM_MAX - KMEM_SIZE)
+         if (((uint32_t) mmap->length) >= KMEM_SIZE
+             && ((uint32_t) mmap->base_addr) <= KMEM_MAX - KMEM_SIZE)
            {
-             unsigned long high = mmap->base_addr_low + mmap->length_low;
-             unsigned long low;
+             uint32_t high = ((uint32_t) mmap->base_addr)
+                              + ((uint32_t) mmap->length);
+             uint32_t low;
 
              if (high > KMEM_MAX)
                high = KMEM_MAX;
@@ -282,8 +297,8 @@
     {
       if ((mbi->mem_upper << 10) >= KMEM_SIZE)
        {
-         unsigned long high = (mbi->mem_upper << 10) + 0x100000;
-         unsigned long low;
+         uint32_t high = (mbi->mem_upper << 10) + 0x100000;
+         uint32_t low;
 
          if (high > KMEM_MAX)
            high = KMEM_MAX;
Index: hurd-l4/laden/kip-fixup.c
diff -u hurd-l4/laden/kip-fixup.c:1.1 hurd-l4/laden/kip-fixup.c:1.2
--- hurd-l4/laden/kip-fixup.c:1.1       Sat Jul 26 13:26:09 2003
+++ hurd-l4/laden/kip-fixup.c   Wed Sep  3 21:29:35 2003
@@ -34,7 +34,7 @@
     kip = (l4_kip_t) (((l4_word_t) kip) + 0x1000);
 
   if ((l4_word_t) kip >= kernel.high)
-    panic ("Error: No KIP found in the kernel.\n");
+    panic ("No KIP found in the kernel.\n");
   debug ("KIP found at address 0x%x.\n", kip);
 
   kip2 = kip + 0x1000;
@@ -44,12 +44,14 @@
     kip2 = (l4_kip_t) (((l4_word_t) kip2) + 0x1000);
 
   if ((l4_word_t) kip2 < kernel.high)
-    panic ("Error: More than one KIP found in kernel.\n");
+    panic ("More than one KIP found in kernel.\n");
 
   /* Load the rootservers into the KIP.  */
   kip->sigma0 = sigma0;
   kip->sigma1 = sigma1;
   kip->rootserver = rootserver;
+  /* FIXME: We should be able to specify the UTCB area for the
+     rootserver here, but L4 lacks this feature.  */
 
   debug ("Sigma0: Low 0x%x, High 0x%x, IP 0x%x, SP 0x%x\n",
         sigma0.low, sigma0.high, sigma0.ip, sigma0.sp);
@@ -61,7 +63,7 @@
 
   /* Load the memory map into the KIP.  */
   if (memory_map_size > kip->memory_info.nr)
-    panic ("Error: Memory map table in KIP is too small.");
+    panic ("Memory map table in KIP is too small.");
 
   memcpy ((char *) (((l4_word_t) kip) + kip->memory_info.mem_desc_ptr),
          (char *) memory_map,
Index: hurd-l4/laden/laden.c
diff -u hurd-l4/laden/laden.c:1.1 hurd-l4/laden/laden.c:1.2
--- hurd-l4/laden/laden.c:1.1   Sat Jul 26 13:26:09 2003
+++ hurd-l4/laden/laden.c       Wed Sep  3 21:29:35 2003
@@ -59,11 +59,11 @@
   /* Never reached.  */
   if (shutdown_reset)
     {
-      printf ("Error: Unable to reset this machine.\n");
+      printf ("Unable to reset this machine.\n");
       halt ();
     }
 
-  printf ("Error: Unable to halt this machine.\n");
+  printf ("Unable to halt this machine.\n");
   while (1)
     ;
 }
@@ -145,9 +145,9 @@
          debug = 1;
        }
       else if (argv[i][0] == '-')
-       panic ("Error: Unsupported option %s", argv[i]);
+       panic ("Unsupported option %s", argv[i]);
       else
-       panic ("Error: Invalid non-option argument %s", argv[i]);
+       panic ("Invalid non-option argument %s", argv[i]);
     }
 }
 
Index: hurd-l4/laden/laden.h
diff -u hurd-l4/laden/laden.h:1.1 hurd-l4/laden/laden.h:1.2
--- hurd-l4/laden/laden.h:1.1   Sat Jul 26 13:26:09 2003
+++ hurd-l4/laden/laden.h       Wed Sep  3 21:29:35 2003
@@ -51,7 +51,7 @@
 #define add_memory_map(start,end,mtype,msubtype)                               
\
   ({                                                                   \
     if (memory_map_size == MEMORY_MAP_MAX)                             \
-      panic ("Error: No more memory descriptor slots available.\n");   \
+      panic ("No more memory descriptor slots available.\n");          \
       memory_map[memory_map_size].low = (start) >> 10;                 \
       memory_map[memory_map_size].high = ((end) + (1 << 10) - 1) >> 10;        
\
       memory_map[memory_map_size].virtual = 0;                         \
@@ -135,7 +135,13 @@
 void printf (const char *fmt, ...);
 
 /* Print an error message and fail.  */
-#define panic(...) ({ printf (__VA_ARGS__); putchar ('\n'); shutdown (); })
+#define panic(...)                             \
+  ({                                           \
+    printf ("laden: error: ");                 \
+    printf (__VA_ARGS__);                      \
+    putchar ('\n');                            \
+    shutdown ();                               \
+  })
 
 /* True if debug mode is enabled.  */
 extern int debug;
Index: hurd-l4/laden/loader.c
diff -u hurd-l4/laden/loader.c:1.1 hurd-l4/laden/loader.c:1.2
--- hurd-l4/laden/loader.c:1.1  Sat Jul 26 13:26:09 2003
+++ hurd-l4/laden/loader.c      Wed Sep  3 21:29:35 2003
@@ -61,12 +61,12 @@
        }
     }
   if (conflicts)
-    panic ("Error: %s (0x%x - 0x%x) conflicts with memory of "
+    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);
   if (!fits)
-    panic ("Error: %s (0x%x - 0x%x) does not fit into memory",
+    panic ("%s (0x%x - 0x%x) does not fit into memory",
           name, start, end);
 }
 
@@ -98,7 +98,7 @@
     {
       if ((start >= used_regions[i].start && start < used_regions[i].end)
          || (end >= used_regions[i].start && end < used_regions[i].end))
-       panic ("Error: %s (0x%x - 0x%x) conflicts with %s (0x%x - 0x%x)",
+       panic ("%s (0x%x - 0x%x) conflicts with %s (0x%x - 0x%x)",
               name, start, end, used_regions[i].name, used_regions[i].start,
               used_regions[i].end);
     }
@@ -112,7 +112,7 @@
 add_region (char *name, l4_word_t start, l4_word_t end)
 {
   if (nr_regions == MAX_REGIONS)
-    panic ("Error: Too many memory regions, region %s doesn't fit", name);
+    panic ("Too many memory regions, region %s doesn't fit", name);
 
   check_region (name, start, end);
 
@@ -164,19 +164,19 @@
       || elf->e_ident[EI_MAG1] != ELFMAG1
       || elf->e_ident[EI_MAG2] != ELFMAG2
       || elf->e_ident[EI_MAG3] != ELFMAG3)
-    panic ("Error: %s is not an ELF file", name);
+    panic ("%s is not an ELF file", name);
 
   if (elf->e_type != ET_EXEC)
-    panic ("Error: %s is not an executable file", name);
+    panic ("%s is not an executable file", name);
 
   if (!elf->e_phoff)
-    panic ("Error: %s has no valid program header offset", name);
+    panic ("%s has no valid program header offset", name);
 
 #ifdef i386
   if (elf->e_ident[EI_CLASS] != ELFCLASS32
       || elf->e_ident[EI_DATA] != ELFDATA2LSB
       || elf->e_machine != EM_386)
-    panic ("Error: %s is not for this architecture", name);
+    panic ("%s is not for this architecture", name);
 #else
 #error Not ported to this architecture!
 #endif
@@ -223,18 +223,18 @@
 load_components (void)
 {
   if (!kernel.low)
-    panic ("Error: No L4 kernel found");
+    panic ("No L4 kernel found");
   add_region ("kernel-mod", kernel.low, kernel.high);
 
   if (!sigma0.low)
-    panic ("Error: No sigma0 server found");
+    panic ("No sigma0 server found");
   add_region ("sigma0-mod", sigma0.low, sigma0.high);
 
   if (sigma1.low)
     add_region ("sigma1-mod", sigma1.low, sigma1.high);
 
   if (!rootserver.low)
-    panic ("Error: No rootserver server found");
+    panic ("No rootserver server found");
   add_region ("rootserver-mod", rootserver.low, rootserver.high);
 
   elf_load ("kernel", kernel.low, kernel.high,
Index: hurd-l4/laden/multiboot.h
diff -u hurd-l4/laden/multiboot.h:1.1 hurd-l4/laden/multiboot.h:1.2
--- hurd-l4/laden/multiboot.h:1.1       Sat Jul 26 13:26:09 2003
+++ hurd-l4/laden/multiboot.h   Wed Sep  3 21:29:35 2003
@@ -15,6 +15,7 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
+
 /* Macros.  */
 
 /* The magic number for the Multiboot header.  */
@@ -35,86 +36,86 @@
 
 /* Types.  */
 
+#include <sys/types.h>
+
 /* The Multiboot header.  */
 typedef struct multiboot_header
 {
-  unsigned long magic;
-  unsigned long flags;
-  unsigned long checksum;
-  unsigned long header_addr;
-  unsigned long load_addr;
-  unsigned long load_end_addr;
-  unsigned long bss_end_addr;
-  unsigned long entry_addr;
+  uint32_t magic;
+  uint32_t flags;
+  uint32_t checksum;
+  uint32_t header_addr;
+  uint32_t load_addr;
+  uint32_t load_end_addr;
+  uint32_t bss_end_addr;
+  uint32_t entry_addr;
 } multiboot_header_t;
 
 /* The symbol table for a.out.  */
 typedef struct aout_symbol_table
 {
-  unsigned long tabsize;
-  unsigned long strsize;
-  unsigned long addr;
-  unsigned long reserved;
+  uint32_t tabsize;
+  uint32_t strsize;
+  uint32_t addr;
+  uint32_t reserved;
 } aout_symbol_table_t;
 
 /* The section header table for ELF.  */
 typedef struct elf_section_header_table
 {
-  unsigned long num;
-  unsigned long size;
-  unsigned long addr;
-  unsigned long shndx;
+  uint32_t num;
+  uint32_t size;
+  uint32_t addr;
+  uint32_t shndx;
 } elf_section_header_table_t;
 
 /* The Multiboot information.  */
 typedef struct multiboot_info
 {
-  unsigned long flags;
-  unsigned long mem_lower;
-  unsigned long mem_upper;
-  unsigned long boot_device;
-  unsigned long cmdline;
-  unsigned long mods_count;
-  unsigned long mods_addr;
+  uint32_t flags;
+  uint32_t mem_lower;
+  uint32_t mem_upper;
+  uint32_t boot_device;
+  uint32_t cmdline;
+  uint32_t mods_count;
+  uint32_t mods_addr;
   union
   {
     aout_symbol_table_t aout_sym;
     elf_section_header_table_t elf_sec;
   } u;
-  unsigned long mmap_length;
-  unsigned long mmap_addr;
-  unsigned long drives_length;
-  unsigned long drives_addr;
-  unsigned long config_table;
-  unsigned long boot_loader_name;
-  unsigned long apm_table;
-  unsigned long vbe_control_info;
-  unsigned long vbe_mode_info;
-  unsigned long vbe_mode;
-  unsigned long vbe_interface_seg;
-  unsigned long vbe_interface_off;
-  unsigned long vbe_interface_len;
+  uint32_t mmap_length;
+  uint32_t mmap_addr;
+  uint32_t drives_length;
+  uint32_t drives_addr;
+  uint32_t config_table;
+  uint32_t boot_loader_name;
+  uint32_t apm_table;
+  uint32_t vbe_control_info;
+  uint32_t vbe_mode_info;
+  uint32_t vbe_mode;
+  uint32_t vbe_interface_seg;
+  uint32_t vbe_interface_off;
+  uint32_t vbe_interface_len;
 } multiboot_info_t;
 
 /* The module structure.  */
 typedef struct module
 {
-  unsigned long mod_start;
-  unsigned long mod_end;
-  unsigned long string;
-  unsigned long reserved;
+  uint32_t mod_start;
+  uint32_t mod_end;
+  uint32_t string;
+  uint32_t reserved;
 } module_t;
 
-/* The memory map. Be careful that the offset 0 is base_addr_low
-   but no size.  */
+/* The memory map.  SIZE is the size of the structure except for the
+   SIZE field itself.  */
 typedef struct memory_map
 {
-  unsigned long size;
-  unsigned long base_addr_low;
-  unsigned long base_addr_high;
-  unsigned long length_low;
-  unsigned long length_high;
-  unsigned long type;
+  uint32_t size;
+  uint64_t base_addr;
+  uint64_t length;
+  uint32_t type;
 } memory_map_t;
 
 #endif /* ! ASM */
Index: hurd-l4/laden/output-vga.c
diff -u hurd-l4/laden/output-vga.c:1.1 hurd-l4/laden/output-vga.c:1.2
--- hurd-l4/laden/output-vga.c:1.1      Sat Jul 26 13:26:09 2003
+++ hurd-l4/laden/output-vga.c  Wed Sep  3 21:29:35 2003
@@ -53,7 +53,7 @@
 }
 
 
-/* Set the cursor position to POS, which is (x_pos + y_pos * width).  */
+/* Get the cursor position, which is (x_pos + y_pos * width).  */
 static unsigned int
 vga_get_cursor_pos (void)
 {




reply via email to

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