/[hurd]/hurd-l4/wortel/loader.c
ViewVC logotype

Diff of /hurd-l4/wortel/loader.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by marcus, Mon Sep 29 16:03:55 2003 UTC revision 1.8 by marcus, Sat Oct 4 17:42:22 2003 UTC
# Line 23  Line 23 
23  #endif  #endif
24    
25  #include <string.h>  #include <string.h>
26    #include <l4/kip.h>
27    
28  #include "loader.h"  #include "loader.h"
29  #include "output.h"  #include "output.h"
# Line 34  Line 35 
35    
36  /* Verify that the memory region START to END (exclusive) is valid.  */  /* Verify that the memory region START to END (exclusive) is valid.  */
37  static void  static void
38  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)
39  {  {
40    l4_memory_desc_t memdesc = 0;    l4_memory_desc_t memdesc;
41    int nr;    int nr;
42    int fits = 0;    int fits = 0;
43    int conflicts = 0;    int conflicts = 0;
# Line 44  mem_check (const char *name, unsigned lo Line 45  mem_check (const char *name, unsigned lo
45    if (!loader_get_num_memory_desc ())    if (!loader_get_num_memory_desc ())
46      return;      return;
47    
48      end--;
49    
50    /* FIXME: This implementation does not account for conventional    /* FIXME: This implementation does not account for conventional
51       memory overriding non-conventional memory in the descriptor       memory overriding non-conventional memory in the descriptor
52       list.  */       list.  */
# Line 54  mem_check (const char *name, unsigned lo Line 57  mem_check (const char *name, unsigned lo
57        if (memdesc->type == L4_MEMDESC_CONVENTIONAL)        if (memdesc->type == L4_MEMDESC_CONVENTIONAL)
58          {          {
59            /* Check if the region fits into conventional memory.  */            /* Check if the region fits into conventional memory.  */
60            if (start >= (memdesc->low << 10) && start < (memdesc->high << 10)            if (start >= l4_memory_desc_low (memdesc)
61                && end > (memdesc->low << 10) && end <= (memdesc->high << 10))                && start <= l4_memory_desc_high (memdesc)
62                  && end >= l4_memory_desc_low (memdesc)
63                  && end <= l4_memory_desc_high (memdesc))
64              fits = 1;              fits = 1;
65          }          }
66        else        else
67          {          {
68            /* Check if the region overlaps with non-conventional            /* Check if the region overlaps with non-conventional
69               memory.  */               memory.  */
70            if ((start >= (memdesc->low << 10) && start < (memdesc->high << 10))            if ((start >= l4_memory_desc_low (memdesc)
71                || (end > (memdesc->low << 10) && end <= (memdesc->high << 10))                 && start <= l4_memory_desc_high (memdesc))
72                || (start < (memdesc->low << 10) && end > (memdesc->high << 10)))                || (end >= l4_memory_desc_low (memdesc)
73                      && end <= l4_memory_desc_high (memdesc))
74                  || (start < l4_memory_desc_low (memdesc)
75                      && end > l4_memory_desc_high (memdesc)))
76              {              {
77                conflicts = 1;                fits = 0;
78                break;                conflicts = 1 + nr;
79              }              }
80          }          }
81      }      }
82    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);  
83    if (!fits)    if (!fits)
84      panic ("%s (0x%llx - 0x%llx) does not fit into memory",      {
85             name, start, end);        if (conflicts)
86            {
87              memdesc = loader_get_memory_desc (conflicts - 1);
88              panic ("%s (0x%" L4_PRIxWORD " - 0x%" L4_PRIxWORD ") conflicts "
89                     "with memory of type %i/%i (0x%" L4_PRIxWORD " - 0x%"
90                     L4_PRIxWORD ")", name, start, end + 1,
91                     memdesc->type, memdesc->subtype,
92                     l4_memory_desc_low (memdesc), l4_memory_desc_high (memdesc));
93            }
94          else
95            panic ("%s (0x%" L4_PRIxWORD " - 0x%" L4_PRIxWORD ") does not fit "
96                   "into memory", name, start, end + 1);
97        }
98  }  }
99    
100    
# Line 257  loader_elf_load (const char *name, l4_wo Line 273  loader_elf_load (const char *name, l4_wo
273    if (!elf->e_phoff)    if (!elf->e_phoff)
274      panic ("%s has no valid program header offset", name);      panic ("%s has no valid program header offset", name);
275    
276  #ifdef i386    /* FIXME: Some architectures support both word sizes.  */
277    if (elf->e_ident[EI_CLASS] != ELFCLASS32    if (!((elf->e_ident[EI_CLASS] == ELFCLASS32
278        || elf->e_ident[EI_DATA] != ELFDATA2LSB           && L4_WORDSIZE == L4_WORDSIZE_32)
279        || elf->e_machine != EM_386)          || (elf->e_ident[EI_CLASS] == ELFCLASS64
280      panic ("%s is not for this architecture", name);              && L4_WORDSIZE == L4_WORDSIZE_64)))
281        panic ("%s has invalid word size", name);
282      if (!((elf->e_ident[EI_DATA] == ELFDATA2LSB
283             && L4_BYTE_ORDER == L4_LITTLE_ENDIAN)
284            || (elf->e_ident[EI_DATA] == ELFDATA2MSB
285                && L4_BYTE_ORDER == L4_BIG_ENDIAN)))
286        panic ("%s has invalid byte order", name);
287    
288    #if i386
289    # define elf_machine EM_386
290    #elif PPC
291    # define elf_machine EM_PPC
292  #else  #else
293  #error Not ported to this architecture!  # error Not ported to this architecture!
294  #endif  #endif
295    
296      if (elf->e_machine != elf_machine)
297        panic ("%s is not for this architecture", name);
298    
299    for (i = 0; i < elf->e_phnum; i++)    for (i = 0; i < elf->e_phnum; i++)
300      {      {
301        Elf32_Phdr *ph = (Elf32_Phdr *) (start + elf->e_phoff        Elf32_Phdr *ph = (Elf32_Phdr *) (start + elf->e_phoff

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26