l4-hurd
[Top][All Lists]
Advanced

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

Re: booting l4-Hurd, memory unaligned


From: Jun Inoue
Subject: Re: booting l4-Hurd, memory unaligned
Date: Wed, 20 Apr 2005 03:11:11 -0700

Hi.

Derek, I suspect you forgot the good old friend -1.
In Andreas's Memory Map 10, END is 0xffffffff, and the calculation for
aligned_end rounds it up to 0x100000000 but doesn't subtract 1.
Also, shouldn't we be rounding down rather than up?

Andreas, could you spare some time to try this patch?


Jun

Index: ia32-cmain.c
===================================================================
RCS file: /cvsroot/hurd/hurd-l4/laden/ia32-cmain.c,v
retrieving revision 1.14
diff -u -r1.14 ia32-cmain.c
--- ia32-cmain.c        17 Nov 2004 16:21:39 -0000      1.14
+++ ia32-cmain.c        20 Apr 2005 09:07:42 -0000
@@ -250,10 +250,25 @@
          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);
+         if (mmap->type == 2)
+           {
+             int aligned_base = mmap->base_addr & (~((1 << 10) - 1));
+             /* Round down to multiple of 1 << 10, minus 1. */
+             int aligned_end = ((end + 1) & (~((1 << 10) - 1))) - 1;
+             int aligned_length = (aligned_end - aligned_base) + 1;
+
+             /* Region is too small. */
+             if (aligned_base >= aligned_end)
+               continue;
+             end = aligned_end;
+             mmap->base_addr = aligned_base;
+             mmap->length = aligned_length;
+           }
+         else
+           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




reply via email to

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