commit-hurd
[Top][All Lists]
Advanced

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

hurd-l4 physmem/Makefile.am physmem/zalloc.c wo...


From: Marcus Brinkmann
Subject: hurd-l4 physmem/Makefile.am physmem/zalloc.c wo...
Date: Wed, 17 Sep 2003 10:23:00 -0400

CVSROOT:        /cvsroot/hurd
Module name:    hurd-l4
Branch:         
Changes by:     Marcus Brinkmann <address@hidden>       03/09/17 10:23:00

Modified files:
        physmem        : Makefile.am zalloc.c 
        wortel         : wortel.c 

Log message:
        Fix zone allocation stuff.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd-l4/physmem/Makefile.am.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd-l4/physmem/zalloc.c.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd-l4/wortel/wortel.c.diff?tr1=1.13&tr2=1.14&r1=text&r2=text

Patches:
Index: hurd-l4/physmem/Makefile.am
diff -u hurd-l4/physmem/Makefile.am:1.3 hurd-l4/physmem/Makefile.am:1.4
--- hurd-l4/physmem/Makefile.am:1.3     Tue Sep 16 21:16:53 2003
+++ hurd-l4/physmem/Makefile.am Wed Sep 17 10:22:59 2003
@@ -33,6 +33,6 @@
        physmem.h physmem.c
 
 /* FIXME: Make linkbase configurable.  */
-physmem_LDFLAGS = -u_start -e_start -N -nostdlib -Ttext=0x350000
+physmem_LDFLAGS = -u_start -e_start -N -nostdlib -Ttext=0x35000
 
 physmem_LDADD = -lgcc
Index: hurd-l4/physmem/zalloc.c
diff -u hurd-l4/physmem/zalloc.c:1.2 hurd-l4/physmem/zalloc.c:1.3
--- hurd-l4/physmem/zalloc.c:1.2        Tue Sep 16 22:50:37 2003
+++ hurd-l4/physmem/zalloc.c    Wed Sep 17 10:22:59 2003
@@ -108,25 +108,6 @@
 static struct block *zone[ZONES] = { 0, };
 
 
-/* Find the first bit set.  The least significant bit is 1.  If no bit
-   is set, return 0.  FIXME: This can be optimized a lot, in an
-   archtecture dependent way.  Add to libl4, like __l4_msb().  */
-static inline unsigned int
-wffs (l4_word_t nr)
-{
-  unsigned int bit = 0;
-
-  while (bit < sizeof (l4_word_t) * 8)
-    {
-      if ((1ULL << bit) & nr)
-       {
-         return bit + 1;
-       }
-      bit++;
-    }
-}
-
-
 /* Add the block BLOCK to the zone ZONE_NR.  The block has the
    right size and alignment.  Buddy up if possible.  */
 static inline
@@ -160,7 +141,7 @@
          block = left;
          zone_nr++;
        }
-      else if (right && ((l4_word_t) right) ^ ((l4_word_t) block)
+      else if (right && (((l4_word_t) right) ^ ((l4_word_t) block))
               == ZONE_SIZE (zone_nr))
        {
          /* Buddy on the right.  */
@@ -218,8 +199,14 @@
   do
     {
       /* All blocks must be stored aligned to their size.  */
-      unsigned int zone_nr = wffs (block | size) - 1 - L4_MIN_PAGE_SHIFT;
+      unsigned int block_align = l4_lsb (block) - 1;
+      unsigned int size_align = l4_msb (size) - 1;
+      unsigned int zone_nr = (block_align < size_align
+                             ? block_align : size_align)
+       - L4_MIN_PAGE_SHIFT;
 
+      printf ("block align: %u  size_align: %u  zone_nr: %u\n",
+             block_align, size_align, zone_nr);
       add_block ((struct block *) block, zone_nr);
 
       block += ZONE_SIZE (zone_nr);
@@ -245,14 +232,14 @@
     panic ("%s: requested size 0x%x is not a multiple of "
           "minimum page size", __func__, size);
 
-  /* Calculate the logarithm to base two of SIZE rounded to the
+  /* Calculate the logarithm to base two of SIZE rounded up to the
      nearest power of two (actually, the MSB function returns one more
      than the logarithm to base two of its argument, rounded down to
      the nearest power of two - this is the same except for the border
      case where only one bit is set.  To adjust for this border case,
      we subtract one from the argument to the MSB function).  Calculate
      the zone number by subtracting page shift.  */
-  zone_nr = __l4_msb (size - 1) - L4_MIN_PAGE_SHIFT;
+  zone_nr = l4_msb (size - 1) - L4_MIN_PAGE_SHIFT;
 
   /* Find the smallest zone which fits the request and has memory
      available.  */
Index: hurd-l4/wortel/wortel.c
diff -u hurd-l4/wortel/wortel.c:1.13 hurd-l4/wortel/wortel.c:1.14
--- hurd-l4/wortel/wortel.c:1.13        Wed Sep 17 03:45:26 2003
+++ hurd-l4/wortel/wortel.c     Wed Sep 17 10:23:00 2003
@@ -121,25 +121,6 @@
 #define MAX_FPAGES (sizeof (l4_word_t) * 8 - 10)
 
 
-/* Find the first bit set.  The least significant bit is 1.  If no bit
-   is set, return 0.  FIXME: This can be optimized a lot, in an
-   archtecture dependent way.  Add to libl4, like __l4_msb().  */
-static inline unsigned int
-wffs (l4_word_t nr)
-{
-  unsigned int bit = 0;
-
-  while (bit < sizeof (l4_word_t) * 8)
-    {
-      if ((1ULL << bit) & nr)
-       {
-         return bit + 1;
-       }
-      bit++;
-    }
-}
-
-
 /* Determine the fpages required to cover the bytes from START to END
    (exclusive).  START must be aligned to the minimal page size
    supported by the system.  Returns the number of fpages required to
@@ -164,11 +145,17 @@
   nr_fpages = 0;
   while (start < end)
     {
+      unsigned int addr_align;
+      unsigned int size_align;
+
       /* Each fpage must be self-aligned.  */
-      unsigned int fpsize_log2 = wffs (start | (end - start)) - 1;
+      addr_align = l4_lsb (start) - 1;
+      size_align = l4_msb (end - start) - 1;
+      if (addr_align < size_align)
+       size_align = addr_align;
 
       fpages[nr_fpages]
-       = l4_fpage_add_rights (l4_fpage_log2 (start, fpsize_log2),
+       = l4_fpage_add_rights (l4_fpage_log2 (start, size_align),
                               l4_fully_accessible);
       start += l4_size (fpages[nr_fpages]);
       nr_fpages++;




reply via email to

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