commit-hurd
[Top][All Lists]
Advanced

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

hurd-l4 wortel/ChangeLog wortel/loader.c laden/...


From: Marcus Brinkmann
Subject: hurd-l4 wortel/ChangeLog wortel/loader.c laden/...
Date: Sat, 04 Oct 2003 13:42:22 -0400

CVSROOT:        /cvsroot/hurd
Module name:    hurd-l4
Branch:         
Changes by:     Marcus Brinkmann <address@hidden>       03/10/04 13:42:22

Modified files:
        wortel         : ChangeLog loader.c 
        laden          : ChangeLog ia32-cmain.c laden.h loader.c 

Log message:
        laden/
        2003-10-04  Marcus Brinkmann  <address@hidden>
        
        * laden.h (add_memory_map): Don't round END up to 1K.
        * ia32-cmain.c (find_components): Pass the address of the last
        byte as END to add_memory_map.  Don't do bogus alignment check
        without BIOS map.  Add 0xc0000 - 0xf0000 as shared memory.
        Initially, add the whole address space as shared memory to allow
        arbitrary device access.
        * loader.c: Include <l4/kip.h>.
        (mem_check): Change type of address args to l4_word_t.  Use
        l4_memory_desc_low and l4_memory_desc_high to determine range of
        memory descriptor.  The high address is inclusive now, so take
        this into account.  Allow conventional memory descriptors to
        override non-conventional.  Use L4_PRIxWORD.
        
        wortel/
        2003-10-04  Marcus Brinkmann  <address@hidden>
        
        * loader.c: Include <l4/kip.h>.
        (mem_check): Change type of address args to l4_word_t.  Use
        l4_memory_desc_low and l4_memory_desc_high to determine range of
        memory descriptor.  The high address is inclusive now, so take
        this into account.  Allow conventional memory descriptors to
        override non-conventional.  Use L4_PRIxWORD.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd-l4/wortel/ChangeLog.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd-l4/wortel/loader.c.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd-l4/laden/ChangeLog.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd-l4/laden/ia32-cmain.c.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd-l4/laden/laden.h.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd-l4/laden/loader.c.diff?tr1=1.12&tr2=1.13&r1=text&r2=text

Patches:
Index: hurd-l4/laden/ChangeLog
diff -u hurd-l4/laden/ChangeLog:1.9 hurd-l4/laden/ChangeLog:1.10
--- hurd-l4/laden/ChangeLog:1.9 Mon Sep 29 12:03:55 2003
+++ hurd-l4/laden/ChangeLog     Sat Oct  4 13:42:22 2003
@@ -1,3 +1,18 @@
+2003-10-04  Marcus Brinkmann  <address@hidden>
+
+       * laden.h (add_memory_map): Don't round END up to 1K.
+       * ia32-cmain.c (find_components): Pass the address of the last
+       byte as END to add_memory_map.  Don't do bogus alignment check
+       without BIOS map.  Add 0xc0000 - 0xf0000 as shared memory.
+       Initially, add the whole address space as shared memory to allow
+       arbitrary device access.
+       * loader.c: Include <l4/kip.h>.
+       (mem_check): Change type of address args to l4_word_t.  Use
+       l4_memory_desc_low and l4_memory_desc_high to determine range of
+       memory descriptor.  The high address is inclusive now, so take
+       this into account.  Allow conventional memory descriptors to
+       override non-conventional.  Use L4_PRIxWORD.
+
 2003-09-29  Marcus Brinkmann  <address@hidden>
 
        * loader.c (loader_elf_load): Fix wordsize check.  Submitted by
Index: hurd-l4/laden/ia32-cmain.c
diff -u hurd-l4/laden/ia32-cmain.c:1.11 hurd-l4/laden/ia32-cmain.c:1.12
--- hurd-l4/laden/ia32-cmain.c:1.11     Fri Sep 26 09:46:53 2003
+++ hurd-l4/laden/ia32-cmain.c  Sat Oct  4 13:42:22 2003
@@ -36,6 +36,7 @@
     "through to the rootserver\n"
     "and handled by it.\n";
 }
+
 
 /* Start kernel by simply jumping to the entry point.  */
 void
@@ -215,6 +216,12 @@
     }
 
   /* 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.  */
@@ -230,26 +237,9 @@
          if (mmap->base_addr >> 32)
            panic ("L4 does not support more than 4 GB on ia32");
 
-         end = mmap->base_addr + mmap->length;
+         end = mmap->base_addr + mmap->length - 1;
 
-         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)
+         if (end >> 32)
            panic ("L4 does not support more than 4 GB on ia32");
 
          if (mmap->base_addr & ((1 << 10) - 1)
@@ -266,20 +256,16 @@
   else if (CHECK_FLAG (mbi->flags, 0))
     {
       /* mem_* are valid.  */
-      if (mbi->mem_lower & 0x2ff)
-       panic ("Lower memory end address 0x%x is unaligned",
-              mbi->mem_lower);
-      if (mbi->mem_upper & 0x2ff)
-       panic ("Upper memory end address 0x%x is unaligned",
-              mbi->mem_upper);
 
-      add_memory_map (0, mbi->mem_lower << 10, L4_MEMDESC_CONVENTIONAL, 0);
-      add_memory_map (0x100000, 0x100000 + (mbi->mem_upper << 10),
+      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 is usually not included in the BIOS map.  */
-  add_memory_map (0xa0000, 0xc0000, L4_MEMDESC_SHARED, 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)
Index: hurd-l4/laden/laden.h
diff -u hurd-l4/laden/laden.h:1.9 hurd-l4/laden/laden.h:1.10
--- hurd-l4/laden/laden.h:1.9   Fri Sep 26 09:46:53 2003
+++ hurd-l4/laden/laden.h       Sat Oct  4 13:42:22 2003
@@ -48,7 +48,7 @@
 
 /* For the rootserver components, find_components() must fill in the
    start and end address of the ELF images in memory.  The end address
-   is one more than the last byte in the image.  */
+   is one more than the address of the last byte in the image.  */
 extern rootserver_t kernel;
 extern rootserver_t sigma0;
 extern rootserver_t sigma1;
@@ -63,12 +63,12 @@
 extern struct l4_memory_desc memory_map[MEMORY_MAP_MAX];
 extern l4_word_t memory_map_size;
 
-#define add_memory_map(start,end,mtype,msubtype)                               
\
+#define add_memory_map(start, end, mtype, msubtype)                    \
   ({                                                                   \
     if (memory_map_size == MEMORY_MAP_MAX)                             \
       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].high = (end) >> 10;                  \
       memory_map[memory_map_size].virtual = 0;                         \
       memory_map[memory_map_size].type = (mtype);                      \
       memory_map[memory_map_size].subtype = (msubtype);                        
\
Index: hurd-l4/laden/loader.c
diff -u hurd-l4/laden/loader.c:1.12 hurd-l4/laden/loader.c:1.13
--- hurd-l4/laden/loader.c:1.12 Mon Sep 29 12:03:55 2003
+++ hurd-l4/laden/loader.c      Sat Oct  4 13:42:22 2003
@@ -23,6 +23,7 @@
 #endif
 
 #include <string.h>
+#include <l4/kip.h>
 
 #include "loader.h"
 #include "output.h"
@@ -34,7 +35,7 @@
 
 /* Verify that the memory region START to END (exclusive) is valid.  */
 static void
-mem_check (const char *name, unsigned long start, unsigned long end)
+mem_check (const char *name, l4_word_t start, l4_word_t end)
 {
   l4_memory_desc_t memdesc;
   int nr;
@@ -44,6 +45,8 @@
   if (!loader_get_num_memory_desc ())
     return;
 
+  end--;
+
   /* FIXME: This implementation does not account for conventional
      memory overriding non-conventional memory in the descriptor
      list.  */
@@ -54,31 +57,44 @@
       if (memdesc->type == L4_MEMDESC_CONVENTIONAL)
        {
          /* Check if the region fits into conventional memory.  */
-         if (start >= (memdesc->low << 10) && start < (memdesc->high << 10)
-             && end > (memdesc->low << 10) && end <= (memdesc->high << 10))
+         if (start >= l4_memory_desc_low (memdesc)
+             && start <= l4_memory_desc_high (memdesc)
+             && end >= l4_memory_desc_low (memdesc)
+             && end <= l4_memory_desc_high (memdesc))
            fits = 1;
        }
       else
        {
          /* Check if the region overlaps with non-conventional
             memory.  */
-         if ((start >= (memdesc->low << 10) && start < (memdesc->high << 10))
-             || (end > (memdesc->low << 10) && end <= (memdesc->high << 10))
-             || (start < (memdesc->low << 10) && end > (memdesc->high << 10)))
+         if ((start >= l4_memory_desc_low (memdesc)
+              && start <= l4_memory_desc_high (memdesc))
+             || (end >= l4_memory_desc_low (memdesc)
+                 && end <= l4_memory_desc_high (memdesc))
+             || (start < l4_memory_desc_low (memdesc)
+                 && end > l4_memory_desc_high (memdesc)))
            {
-             conflicts = 1;
-             break;
+             fits = 0;
+             conflicts = 1 + nr;
            }
        }
     }
-  if (conflicts)
-    panic ("%s (0x%x - 0x%x) conflicts with memory of "
-          "type %i/%i (0x%x - 0x%x)", name, start, end,
-          memdesc->type, memdesc->subtype,
-          memdesc->low << 10, memdesc->high << 10);
+
   if (!fits)
-    panic ("%s (0x%x - 0x%x) does not fit into memory",
-          name, start, end);
+    {
+      if (conflicts)
+       {
+         memdesc = loader_get_memory_desc (conflicts - 1);
+         panic ("%s (0x%" L4_PRIxWORD " - 0x%" L4_PRIxWORD ") conflicts "
+                "with memory of type %i/%i (0x%" L4_PRIxWORD " - 0x%"
+                L4_PRIxWORD ")", name, start, end + 1,
+                memdesc->type, memdesc->subtype,
+                l4_memory_desc_low (memdesc), l4_memory_desc_high (memdesc));
+       }
+      else
+       panic ("%s (0x%" L4_PRIxWORD " - 0x%" L4_PRIxWORD ") does not fit "
+              "into memory", name, start, end + 1);
+    }
 }
 
 
@@ -128,6 +144,9 @@
   if (nr_regions == MAX_REGIONS)
     panic ("Too many memory regions, region %s doesn't fit", name);
 
+  if (start >= end)
+    panic ("Region %s has a start address following the end address", name);
+
   check_region (name, start, end);
 
   used_regions[nr_regions].name = name;
@@ -159,6 +178,73 @@
 }
 
 
+/* Get the memory range to which the ELF image from START to END
+   (exclusive) will be loaded.  NAME is used for panic messages.  */
+void
+loader_elf_dest (const char *name, l4_word_t start, l4_word_t end,
+                l4_word_t *new_start_p, l4_word_t *new_end_p)
+{
+  l4_word_t new_start = -1;
+  l4_word_t new_end = 0;
+  int i;
+
+  Elf32_Ehdr *elf = (Elf32_Ehdr *) start;
+
+  if (elf->e_ident[EI_MAG0] != ELFMAG0
+      || elf->e_ident[EI_MAG1] != ELFMAG1
+      || elf->e_ident[EI_MAG2] != ELFMAG2
+      || elf->e_ident[EI_MAG3] != ELFMAG3)
+    panic ("%s is not an ELF file", name);
+
+  if (elf->e_type != ET_EXEC)
+    panic ("%s is not an executable file", name);
+
+  if (!elf->e_phoff)
+    panic ("%s has no valid program header offset", name);
+
+  /* FIXME: Some architectures support both word sizes.  */
+  if (!((elf->e_ident[EI_CLASS] == ELFCLASS32
+        && L4_WORDSIZE == L4_WORDSIZE_32)
+       || (elf->e_ident[EI_CLASS] == ELFCLASS64
+           && L4_WORDSIZE == L4_WORDSIZE_64)))
+    panic ("%s has invalid word size", name);
+  if (!((elf->e_ident[EI_DATA] == ELFDATA2LSB
+        && L4_BYTE_ORDER == L4_LITTLE_ENDIAN)
+       || (elf->e_ident[EI_DATA] == ELFDATA2MSB
+           && L4_BYTE_ORDER == L4_BIG_ENDIAN)))
+    panic ("%s has invalid byte order", name);
+
+#if i386
+# define elf_machine EM_386
+#elif PPC
+# define elf_machine EM_PPC
+#else
+# error Not ported to this architecture!
+#endif
+
+  if (elf->e_machine != elf_machine)
+    panic ("%s is not for this architecture", name);
+
+  for (i = 0; i < elf->e_phnum; i++)
+    {
+      Elf32_Phdr *ph = (Elf32_Phdr *) (start + elf->e_phoff
+                                      + i * elf->e_phentsize);
+      if (ph->p_type == PT_LOAD)
+       {
+         if (ph->p_paddr < new_start)
+           new_start = ph->p_paddr;
+         if (ph->p_memsz + ph->p_paddr > new_end)
+           new_end = ph->p_memsz + ph->p_paddr;
+       }
+    }
+
+  if (new_start_p)
+    *new_start_p = new_start;
+  if (new_end_p)
+    *new_end_p = new_end;
+}
+
+
 /* Load the ELF image from START to END (exclusive) into memory under
    the name NAME (also used as the name for the region of the
    resulting ELF program).  Return the lowest and highest address used
Index: hurd-l4/wortel/ChangeLog
diff -u hurd-l4/wortel/ChangeLog:1.8 hurd-l4/wortel/ChangeLog:1.9
--- hurd-l4/wortel/ChangeLog:1.8        Thu Oct  2 06:39:36 2003
+++ hurd-l4/wortel/ChangeLog    Sat Oct  4 13:42:21 2003
@@ -1,3 +1,12 @@
+2003-10-04  Marcus Brinkmann  <address@hidden>
+
+       * loader.c: Include <l4/kip.h>.
+       (mem_check): Change type of address args to l4_word_t.  Use
+       l4_memory_desc_low and l4_memory_desc_high to determine range of
+       memory descriptor.  The high address is inclusive now, so take
+       this into account.  Allow conventional memory descriptors to
+       override non-conventional.  Use L4_PRIxWORD.
+
 2003-10-01  Johan Rydberg  <address@hidden>
 
        * wortel.c (serve_bootstrap_requests): Only throw away page zero
Index: hurd-l4/wortel/loader.c
diff -u hurd-l4/wortel/loader.c:1.7 hurd-l4/wortel/loader.c:1.8
--- hurd-l4/wortel/loader.c:1.7 Mon Sep 29 12:03:55 2003
+++ hurd-l4/wortel/loader.c     Sat Oct  4 13:42:22 2003
@@ -23,6 +23,7 @@
 #endif
 
 #include <string.h>
+#include <l4/kip.h>
 
 #include "loader.h"
 #include "output.h"
@@ -34,9 +35,9 @@
 
 /* Verify that the memory region START to END (exclusive) is valid.  */
 static void
-mem_check (const char *name, unsigned long long start, unsigned long long end)
+mem_check (const char *name, l4_word_t start, l4_word_t end)
 {
-  l4_memory_desc_t memdesc = 0;
+  l4_memory_desc_t memdesc;
   int nr;
   int fits = 0;
   int conflicts = 0;
@@ -44,6 +45,8 @@
   if (!loader_get_num_memory_desc ())
     return;
 
+  end--;
+
   /* FIXME: This implementation does not account for conventional
      memory overriding non-conventional memory in the descriptor
      list.  */
@@ -54,31 +57,44 @@
       if (memdesc->type == L4_MEMDESC_CONVENTIONAL)
        {
          /* Check if the region fits into conventional memory.  */
-         if (start >= (memdesc->low << 10) && start < (memdesc->high << 10)
-             && end > (memdesc->low << 10) && end <= (memdesc->high << 10))
+         if (start >= l4_memory_desc_low (memdesc)
+             && start <= l4_memory_desc_high (memdesc)
+             && end >= l4_memory_desc_low (memdesc)
+             && end <= l4_memory_desc_high (memdesc))
            fits = 1;
        }
       else
        {
          /* Check if the region overlaps with non-conventional
             memory.  */
-         if ((start >= (memdesc->low << 10) && start < (memdesc->high << 10))
-             || (end > (memdesc->low << 10) && end <= (memdesc->high << 10))
-             || (start < (memdesc->low << 10) && end > (memdesc->high << 10)))
+         if ((start >= l4_memory_desc_low (memdesc)
+              && start <= l4_memory_desc_high (memdesc))
+             || (end >= l4_memory_desc_low (memdesc)
+                 && end <= l4_memory_desc_high (memdesc))
+             || (start < l4_memory_desc_low (memdesc)
+                 && end > l4_memory_desc_high (memdesc)))
            {
-             conflicts = 1;
-             break;
+             fits = 0;
+             conflicts = 1 + nr;
            }
        }
     }
-  if (conflicts)
-    panic ("%s (0x%llx - 0x%llx) conflicts with memory of "
-          "type %i/%i (0x%x - 0x%x)", name, start, end,
-          memdesc->type, memdesc->subtype,
-          memdesc->low << 10, memdesc->high << 10);
+
   if (!fits)
-    panic ("%s (0x%llx - 0x%llx) does not fit into memory",
-          name, start, end);
+    {
+      if (conflicts)
+       {
+         memdesc = loader_get_memory_desc (conflicts - 1);
+         panic ("%s (0x%" L4_PRIxWORD " - 0x%" L4_PRIxWORD ") conflicts "
+                "with memory of type %i/%i (0x%" L4_PRIxWORD " - 0x%"
+                L4_PRIxWORD ")", name, start, end + 1,
+                memdesc->type, memdesc->subtype,
+                l4_memory_desc_low (memdesc), l4_memory_desc_high (memdesc));
+       }
+      else
+       panic ("%s (0x%" L4_PRIxWORD " - 0x%" L4_PRIxWORD ") does not fit "
+              "into memory", name, start, end + 1);
+    }
 }
 
 
@@ -257,14 +273,28 @@
   if (!elf->e_phoff)
     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 ("%s is not for this architecture", name);
+  /* FIXME: Some architectures support both word sizes.  */
+  if (!((elf->e_ident[EI_CLASS] == ELFCLASS32
+        && L4_WORDSIZE == L4_WORDSIZE_32)
+       || (elf->e_ident[EI_CLASS] == ELFCLASS64
+           && L4_WORDSIZE == L4_WORDSIZE_64)))
+    panic ("%s has invalid word size", name);
+  if (!((elf->e_ident[EI_DATA] == ELFDATA2LSB
+        && L4_BYTE_ORDER == L4_LITTLE_ENDIAN)
+       || (elf->e_ident[EI_DATA] == ELFDATA2MSB
+           && L4_BYTE_ORDER == L4_BIG_ENDIAN)))
+    panic ("%s has invalid byte order", name);
+
+#if i386
+# define elf_machine EM_386
+#elif PPC
+# define elf_machine EM_PPC
 #else
-#error Not ported to this architecture!
+# error Not ported to this architecture!
 #endif
+
+  if (elf->e_machine != elf_machine)
+    panic ("%s is not for this architecture", name);
 
   for (i = 0; i < elf->e_phnum; i++)
     {




reply via email to

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