Skip to contentSkip to conversation

Huge changes in mm.c

PATCH In review Vincent Pelletier 5 participants 29 messages Jul 11, 2005 – Jul 18, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Huge changes in mm.c

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi.

In my attempt to port grub 2 to usparc, I had big problems with all the memory allocation things, so I decided to rewrite the functions after reading them (I wasn't able to understand at all 20% of the code).

Some comments :
It *seems* that before the alloc'ed chunks weren't linked any more with other chunks. Now all the chunks of a region are part of the same ring. Chunks were allocated from the end of the memory to the beginning, I kept this behaviour.
It *seems* that the chunk headers were "forgotten" in the malloc process, which led to my problems on usparc : a chunk was overwriting the header of the previous one. It's now fixed.

A little schema to explain how it works :
First, we have a full free region, with the region header & chunk header:
( free )
[H_CHUNK ] (free, "next" points to self)
[H_REGION] ("head" always points to first chunk header)

We allocate a chunk that fit in the free space :
(alloc'ed)
[H_CHUNK ] (alloc, "next" points to free chunk) ( free )
[H_CHUNK ] (free, "next" points to alloc'ed chunk) [H_REGION] (no change)

And so on.
Each chunk is 32 or 64 bits aligned (depends on arch) and his length is a multiple of this alignment by giving some extra bytes to the alloc'ed chunk if needed (its end is then also aligned, no byte loss).

I've added a defrag function that merges consecutive free chunks. It's pretty fast (O(N), N=number of chunks) but I only call it when needed... Maybe could it be interesting to call it on each grub_free().

I've added lots of dprintf calls triggered by "mm". They slows everything down a lot...

I'm not sure where to put the 3 new prototypes, and I'm not even sure about the name they should have. Please correct if it is wrong.

2005-07-11 Vincent Pelletier <[email protected]>

* kern/mm.c (GRUB_MM_ALIGN): Removed macro. Renamed GRUB_MM_ALIGN_LOG2 into GRUB_MM_ALIGN. (grub_defragment, align_before, align_after): New functions and their prototypes.
(get_header_from_pointer): Check alignment correctly. Add grub_dprintf call. Cast pointers so additions give the correct result.
(grub_mm_init_region): Add dprintf calls. Compute size before testing it. Only keep regions which can contain 1 or more bytes.
(grub_real_malloc): Add grub_dprintf calls. Do some extra sanity checks. Add grub_mm_dump calls. Change "for" loop into "do..while". Don't change *first value. Keep alloc'ed headers in the ring. Align beginning and end of alloc'ed chunks. (grub_memalign): Add grub_dprintf calls. Add grub_mm_dump call. Always align. Give the real wanted size to grub_real_malloc. Use grub_defragment if needed.
(grub_free): Add grub_dprintf calls. Do some extra sanity checks. Handle GRUB_MM_ALLOC_MAGIC in the ring correctly. Call grub_fatal if the chunk to be freed isn't found. (grub_realloc): Remove useless alignment things, since they are handled in grub_real_malloc. Add (disabled) experimental code to call grub_defragment if needed. (grub_mm_dump): Follow the ring to be faster.
* include/grub/mm.h (MM_DEBUG): Changed default value to 0.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFC0mRSFEQoKRQyjtURApn4AJ9qUXY0b7w3pEZq8ctVl3dM3Sr2UgCgj2sj MTPU8nMkchdxhf+fA1JzPVE=
=oPFJ
-----END PGP SIGNATURE-----

Index: kern/mm.c
===================================================================
RCS file: /cvsroot/grub/grub2/kern/mm.c,v
retrieving revision 1.10

mm.c +240 -136
diff -u -p -r1.10 mm.c
@@ -46,13 +46,11 @@ typedef struct grub_mm_header
 *grub_mm_header_t;
 
 #if GRUB_CPU_SIZEOF_VOID_P == 4
-# define GRUB_MM_ALIGN_LOG2	4
+# define GRUB_MM_ALIGN	4
 #elif GRUB_CPU_SIZEOF_VOID_P == 8
-# define GRUB_MM_ALIGN_LOG2	8
+# define GRUB_MM_ALIGN	8
 #endif
 
-#define GRUB_MM_ALIGN	(1 << GRUB_MM_ALIGN_LOG2)
-
 typedef struct grub_mm_region
 {
   struct grub_mm_header *first;
@@ -64,21 +62,45 @@ typedef struct grub_mm_region
 
 
 
+void grub_defragment (grub_mm_region_t r);
+grub_addr_t align_before (grub_addr_t addr, grub_size_t align);
+grub_addr_t align_after (grub_addr_t addr, grub_size_t align);
+
 static grub_mm_region_t base;
 
+/* Align given memory address to the first valid position after addr.
+   If addr is already aligned, don't touch it.   */
+grub_addr_t align_after (grub_addr_t addr, grub_size_t align)
+{
+  if (addr % align)
+    return addr + align - ( addr % align );
+  return addr;
+}
+
+/* Align given memory address to the first valid position before addr.
+ *    If addr is already aligned, don't touch it.   */
+grub_addr_t align_before (grub_addr_t addr, grub_size_t align)
+{
+  return addr - addr % align;
+} 
+
 /* Get a header from the pointer PTR, and set *P and *R to a pointer
    to the header and a pointer to its region, respectively. PTR must
    be allocated.  */
 static void
 get_header_from_pointer (void *ptr, grub_mm_header_t *p, grub_mm_region_t *r)
 {
-  if ((grub_addr_t) ptr & (GRUB_MM_ALIGN - 1))
+  if ((grub_addr_t) ptr % GRUB_MM_ALIGN)
     grub_fatal ("unaligned pointer %p", ptr);
 
   for (*r = base; *r; *r = (*r)->next)
-    if ((grub_addr_t) ptr > (*r)->addr
-	&& (grub_addr_t) ptr <= (*r)->addr + (*r)->size)
-      break;
+    {
+      grub_dprintf ("mm", "[%p..%p]\n", ((*r)->addr),
+                    ((grub_addr_t) (*r)->addr) + (*r)->size);
+      if ((grub_addr_t) ptr >= ((grub_addr_t) (*r)->addr)
+          && (grub_addr_t) ptr <= ((grub_addr_t) (*r)->addr) + (*r)->size)
+        break;
+    }
 
   if (! *r)
     grub_fatal ("out of range pointer %p", ptr);
@@ -96,27 +118,28 @@ grub_mm_init_region (void *addr, grub_si
   grub_mm_header_t h;
   grub_mm_region_t r, *p, q;
 
-#if 0
-  grub_printf ("%s:%d: addr=%p, size=%u\n", __FILE__, __LINE__, addr, size);
-#endif
-  
+  grub_dprintf ("mm", "New region (before) : %p:%x\n", addr, size);
+  r = (grub_mm_region_t) align_after ((grub_addr_t) addr, GRUB_MM_ALIGN);
+
+  size = align_before (size - sizeof (*r) -
+                       ((grub_addr_t) r - (grub_addr_t) addr),
+		      GRUB_MM_ALIGN);
+
   /* If this region is too small, ignore it.  */
-  if (size < GRUB_MM_ALIGN * 2)
+  if (size < sizeof (grub_mm_header_t) + 1)
     return;
 
-  /* Allocate a region from the head.  */
-  r = (grub_mm_region_t) (((grub_addr_t) addr + GRUB_MM_ALIGN - 1)
-			  & (~(GRUB_MM_ALIGN - 1)));
-  size -= (char *) r - (char *) addr + sizeof (*r);
-  
-  h = (grub_mm_header_t) ((char *) r + GRUB_MM_ALIGN);
+  h = (grub_mm_header_t) (r + 1);
   h->next = h;
   h->magic = GRUB_MM_FREE_MAGIC;
-  h->size = (size >> GRUB_MM_ALIGN_LOG2);
+  h->size = size - sizeof (*h);
 
   r->first = h;
   r->addr = (grub_addr_t) h;
-  r->size = (h->size << GRUB_MM_ALIGN_LOG2);
+  r->size = size;
+
+  grub_dprintf ("mm", "First header in new region : h=%p, size=%x\n",
+      h, h->size);
 
   /* Find where to insert this region. Put a smaller one before bigger ones,
      to prevent fragmentations.  */
@@ -126,6 +149,7 @@ grub_mm_init_region (void *addr, grub_si
   
   *p = r;
   r->next = q;
+  grub_dprintf ("mm", "New region (after) : %p:%x:%p\n", r, size, r->next);
 }
 
 /* Allocate the number of units N with the alignment ALIGN from the ring
@@ -134,63 +158,87 @@ grub_mm_init_region (void *addr, grub_si
 static void *
 grub_real_malloc (grub_mm_header_t *first, grub_size_t n, grub_size_t align)
 {
-  grub_mm_header_t p, q;
+  grub_mm_header_t p, q, r;
+  grub_off_t extra = align_after (n, align) - n;
 
-  if ((*first)->magic == GRUB_MM_ALLOC_MAGIC)
-    return 0;
-
-  for (q = *first, p = q->next; ; q = p, p = p->next)
+  if (! first)
+    grub_fatal ("null in the ring (at start)");
+  
+  p = *first;
+  
+  switch (p->magic)
     {
-      grub_off_t extra;
+    case GRUB_MM_ALLOC_MAGIC:
+    case GRUB_MM_FREE_MAGIC:
+      break;
+    default:
+#if MM_DEBUG
+      grub_mm_dump (__LINE__);
+#endif
+      grub_fatal ("magic is broken (at start) %p: 0x%x", p, p->magic);
+    }
 
-      extra = ((grub_addr_t) (p + 1) >> GRUB_MM_ALIGN_LOG2) % align;
-      if (extra)
-	extra = align - extra;
+  do
+    {
+      q = p;
+      p = p->next;
 
       if (! p)
 	grub_fatal ("null in the ring");
 
-      if (p->magic != GRUB_MM_FREE_MAGIC)
-	grub_fatal ("free magic is broken at %p: 0x%x", p, p->magic);
-
-      if (p->size >= n + extra)
-	{
-	  if (extra == 0 && p->size == n)
+      switch (p->magic)
+        {
+        case GRUB_MM_ALLOC_MAGIC:
+          break;
+        case GRUB_MM_FREE_MAGIC:
+          grub_dprintf ("mm", "Before: p %p:%x:%p\n",
+             p, p->size, p->next);
+          grub_dprintf ("mm", "Before: q %p:%x:%p\n",
+              q, q->size, q->next);
+	  grub_dprintf ("mm", "Align = 0x%x Size = 0x%x Extra = 0x%x\n",
+              align, n, extra);
+	  if (p->size == n + extra)
 	    {
-	      q->next = p->next;
 	      p->magic = GRUB_MM_ALLOC_MAGIC;
+              grub_dprintf ("mm", "After : p %p:%x:%p\n",
+                  p, p->size, p->next);
+              grub_dprintf ("mm", "After : q %p:%x:%p\n",
+                  q, q->size, q->next);
+	      return p + 1;
 	    }
-	  else if (extra == 0 || p->size == n + extra)
+	  if (p->size >= n + extra + sizeof (*r))
 	    {
-	      p->size -= n;
-	      p += p->size;
-	      p->size = n;
-	      p->magic = GRUB_MM_ALLOC_MAGIC;
-	    }
-	  else
-	    {
-	      grub_mm_header_t r;
-
-	      r = p + extra + n;
-	      r->magic = GRUB_MM_FREE_MAGIC;
-	      r->size = p->size - extra - n;
-	      r->next = p->next;
-	      
-	      p->size = extra;
-	      p->next = r;
-	      p += extra;
-	      p->size = n;
-	      p->magic = GRUB_MM_ALLOC_MAGIC;
-	    }
+#if 0
+	        r = (grub_mm_header_t) align_before (
+	            ((grub_addr_t) p) + p->size - (extra + n),
+                    align);
+#else
+                /* XXX: Is it safe to assume we are aligned ?  */
+                r = ((grub_addr_t) p) + p->size - (extra + n);
+#endif
+              r->magic = GRUB_MM_ALLOC_MAGIC;
+              r->size = n + extra;
+              r->next = p;
+              p->size = p->size - r->size - sizeof (*r);
+              q->next = r;
+
+              grub_dprintf ("mm", "After : p %p:%x:%p\n",
+                  p, p->size, p->next);
+              grub_dprintf ("mm", "After : q %p:%x:%p\n",
+                  q, q->size, q->next);
+              grub_dprintf ("mm", "After : r %p:%x:%p\n",
+                  r, r->size, r->next);
+              return r + 1;
+            }
+            break;
+        default:
+#if MM_DEBUG
+          grub_mm_dump (__LINE__);
+#endif
+          grub_fatal ("magic is broken at %p: 0x%x", p, p->magic);
+        }
 
-	  *first = q;
-	  
-	  return p + 1;
-	}
-
-      if (p == *first)
-	break;
-    }
+    } while ( p != *first );
 
   return 0;
 }
@@ -200,12 +248,16 @@ void *
 grub_memalign (grub_size_t align, grub_size_t size)
 {
   grub_mm_region_t r;
-  grub_size_t n = ((size + GRUB_MM_ALIGN - 1) >> GRUB_MM_ALIGN_LOG2) + 1;
   int count = 0;
   
-  align = (align >> GRUB_MM_ALIGN_LOG2);
+#if 0
+  align = (align >> GRUB_MM_ALIGN);
   if (align == 0)
     align = 1;
+#else
+  /* XXX: Is it right to always align ?  */
+  align = GRUB_MM_ALIGN;
+#endif
 
  again:
   
@@ -213,9 +265,18 @@ grub_memalign (grub_size_t align, grub_s
     {
       void *p;
       
-      p = grub_real_malloc (&(r->first), n, align);
+      p = grub_real_malloc (&(r->first), size, align);
       if (p)
-	return p;
+        {
+	  grub_dprintf("mm","%p=malloc(0x%x)\n",p,size);
+#if MM_DEBUG
+	  grub_size_t a;
+	  for(a = 0; a < size; a++)
+            ((char *) p)[a] = 'X'; /* To test overlapping.  */
+          grub_mm_dump (__LINE__);
+#endif
+	  return p;
+        }
     }
 
   /* If failed, increase free memory somehow.  */
@@ -228,6 +289,13 @@ grub_memalign (grub_size_t align, grub_s
       goto again;
       
     case 1:
+      /* Defragment memory.  */
+      for (r = base; r; r = r->next)
+        grub_defragment (r);
+      count++;
+      goto again;
+      
+    case 2:
       /* Unload unneeded modules.  */
       grub_dl_unload_unneeded ();
       count++;
@@ -248,6 +316,43 @@ grub_malloc (grub_size_t size)
   return grub_memalign (0, size);
 }
 
+/* Aggregates consecutive free segments.  */
+void
+grub_defragment (grub_mm_region_t r)
+{
+  grub_mm_header_t p, first_free = 0;
+
+  grub_dprintf ("mm", "Defrag running...\n");
+  
+  p = r->first;
+
+  do
+    {
+      p = p->next;
+      switch (p->magic)
+        {
+        case GRUB_MM_ALLOC_MAGIC:
+          first_free = 0;
+          break;
+        case GRUB_MM_FREE_MAGIC:
+          if (first_free)
+          {
+            first_free->next = p->next;
+            first_free->size += p->size + sizeof (*p);
+          }
+          else
+            first_free = p;
+          break;
+        default:
+#if MM_DEBUG
+          grub_mm_dump (__LINE__);
+#endif
+          grub_fatal ("magic is broken at %p: 0x%x", p, p->magic);
+        }
+    } while ( p != r->first );
+  grub_dprintf ("mm", "Done.\n");
+}
+
 /* Deallocate the pointer PTR.  */
 void
 grub_free (void *ptr)
@@ -258,60 +363,44 @@ grub_free (void *ptr)
   if (! ptr)
     return;
 
+  grub_dprintf ("mm", "free(%p)\n", ptr);
+  
   get_header_from_pointer (ptr, &p, &r);
 
-  if (r->first->magic == GRUB_MM_ALLOC_MAGIC)
-    {
-      p->magic = GRUB_MM_FREE_MAGIC;
-      r->first = p->next = p;
-    }
-  else
+  p = r->first;
+
+  do
     {
-      grub_mm_header_t q;
+      p = p->next;
 
-#if 0
-      q = r->first;
-      do
-	{
-	  grub_printf ("%s:%d: q=%p, q->size=0x%x, q->magic=0x%x\n",
-		       __FILE__, __LINE__, q, q->size, q->magic);
-	  q = q->next;
-	}
-      while (q != r->first);
+      if (! p)
+	grub_fatal ("null in the ring");
+
+      switch (p->magic)
+        {
+        case GRUB_MM_ALLOC_MAGIC:
+          if (p + 1 != ptr)
+            continue;
+          else
+            {
+              p->magic = GRUB_MM_FREE_MAGIC;
+#if MM_DEBUG
+              grub_mm_dump (__LINE__);
+#endif	    
+              return;
+            }
+        case GRUB_MM_FREE_MAGIC:
+          continue;
+        default:
+#if MM_DEBUG
+          grub_mm_dump (__LINE__);
 #endif
-      
-      for (q = r->first; q >= p || q->next <= p; q = q->next)
-	{
-	  if (q->magic != GRUB_MM_FREE_MAGIC)
-	    grub_fatal ("free magic is broken at %p: 0x%x", q, q->magic);
-	  
-	  if (q >= q->next && (q < p || q->next > p))
-	    break;
-	}
-
-      p->magic = GRUB_MM_FREE_MAGIC;
-      p->next = q->next;
-      q->next = p;
-      
-      if (p + p->size == p->next)
-	{
-	  if (p->next == q)
-	    q = p;
+          grub_fatal ("magic is broken at %p: 0x%x", p, p->magic);
+        }
+    } while ( p != r->first );
 
-	  p->next->magic = 0;
-	  p->size += p->next->size;
-	  p->next = p->next->next;
-	}
-      
-      if (q + q->size == p)
-	{
-	  p->magic = 0;
-	  q->size += p->size;
-	  q->next = p->next;
-	}
+  grub_fatal ("alloc'ed chunk not found");
 
-      r->first = q;
-    }
 }
 
 /* Reallocate SIZE bytes and return the pointer. The contents will be
@@ -322,7 +411,6 @@ grub_realloc (void *ptr, grub_size_t siz
   grub_mm_header_t p;
   grub_mm_region_t r;
   void *q;
-  grub_size_t n;
   
   if (! ptr)
     return grub_malloc (size);
@@ -334,18 +422,33 @@ grub_realloc (void *ptr, grub_size_t siz
     }
 
   /* FIXME: Not optimal.  */
-  n = ((size + GRUB_MM_ALIGN - 1) >> GRUB_MM_ALIGN_LOG2) + 1;
   get_header_from_pointer (ptr, &p, &r);
   
-  if (p->size >= n)
+  if (p->size >= size)
     return ptr;
+
+#if 0 /* XXX: Experimental.  */
+  if(p->next->magic == GRUB_MM_FREE_MAGIC)
+    {
+      if (p->size + p->next->size < size)
+        grub_defragment (r); /* Try to increase the free space.  */
+      
+      if (p->size + p->next->size >= size)
+        {
+          grub_size_t delta = size - p->size;
+          p->next->size -= delta;
+          p->size += delta;
+          grub_memcpy (p->next, p->next + delta, sizeof(*p));
+        }
+    }
+#endif
   
   q = grub_malloc (size);
-  if (! q)
-    return q;
-  
-  grub_memcpy (q, ptr, size);
-  grub_free (ptr);
+  if (q)
+    {
+      grub_memcpy (q, ptr, size);
+      grub_free (ptr);
+    }
   return q;
 }
 
@@ -354,28 +457,29 @@ void
 grub_mm_dump (unsigned lineno)
 {
   grub_mm_region_t r;
+  grub_mm_header_t p;
 
-  grub_printf ("called at line %u\n", lineno);
+  grub_printf ("Dump called at line %u\n", lineno);
   for (r = base; r; r = r->next)
     {
-      grub_mm_header_t p;
-      
-      for (p = (grub_mm_header_t) ((r->addr + GRUB_MM_ALIGN - 1)
-				   & (~(GRUB_MM_ALIGN - 1)));
-	   (grub_addr_t) p < r->addr + r->size;
-	   p++)
+      p = r->first;
+      do
 	{
 	  switch (p->magic)
 	    {
 	    case GRUB_MM_FREE_MAGIC:
-	      grub_printf ("F:%p:%u:%p\n",
-			   p, p->size << GRUB_MM_ALIGN_LOG2, p->next);
+	      grub_printf ("F:%p:%x:%p\n",
+			   p, (grub_uintn_t) p->size, p->next);
 	      break;
 	    case GRUB_MM_ALLOC_MAGIC:
-	      grub_printf ("A:%p:%u\n", p, p->size << GRUB_MM_ALIGN_LOG2);
+	      grub_printf ("A:%p:%x:%p\n", p, (grub_uintn_t) p->size, p->next);
 	      break;
+            default:
+              grub_printf ("magic broken at %p\n", p);
+              return; /* XXX: A little rough.  */
 	    }
-	}
+          p = p->next;
+	} while (p != r->first);
     }
 
   grub_printf ("\n");

Index: include/grub/mm.h
===================================================================
RCS file: /cvsroot/grub/grub2/include/grub/mm.h,v
retrieving revision 1.4

grub/mm.h +1 -1
diff -u -p -r1.4 mm.h
@@ -31,7 +31,7 @@ void *EXPORT_FUNC(grub_realloc) (void *p
 void *EXPORT_FUNC(grub_memalign) (grub_size_t align, grub_size_t size);
 
 /* For debugging.  */
-#define MM_DEBUG	1
+#define MM_DEBUG	0
 #if MM_DEBUG
 void grub_mm_dump (unsigned lineno);
 #endif
#1 lore raw

Vincent Pelletier <[email protected]> writes:

Hi Vincent,

Quoted 3 lines

I've added a defrag function that merges consecutive free chunks. It's pretty fast (O(N), N=number of chunks) but I only call it when needed... Maybe could it be interesting to call it on each grub_free().

What do you mean with defragmenting? I think you mean joining freed regions, which should be done at the time it is freed. I always thought that was the case already.

For the other changes I will wait for the comments of Okuji, he wrote the old code. But it always works on the PPC and x86, it sounds like a 64 bits problem to me...

--
Marco

#2 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 3 lines · Marco Gerards

What do you mean with defragmenting? I think you mean joining freed regions, which should be done at the time it is freed. I always thought that was the case already.

I'll add the line, and I might change the defrag function a bit to be more efficient when we know which is the freed region, maybe merging it with grub_free.
I'll also wait for okuji's comments to send a changed patch (there are always changes ;) ).
But that code works pretty well both on x86 and on usparc (well tested, with debug messages checked...) so I hope there won't be too many.

Vincent Pelletier
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFC0nIjFEQoKRQyjtURAvRKAJ4zYQB7+g7+JevDS29AWEPfz7ojhwCffqn4 V6U6qA2duxJ1c+YOajHmj1s=
=qq9V
-----END PGP SIGNATURE-----

___________________________________________________________________________
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger Téléchargez cette version sur http://fr.messenger.yahoo.com

#3 lore raw
In reply to Vincent Pelletier
Quoted 9 lines · Vincent Pelletier

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi.

In my attempt to port grub 2 to usparc, I had big problems with all the memory allocation things, so I decided to rewrite the functions after reading them (I wasn't able to understand at all 20% of the code).

Quoted 5 lines

Some comments :
It *seems* that before the alloc'ed chunks weren't linked any more with other chunks. Now all the chunks of a region are part of the same ring. Chunks were allocated from the end of the memory to the beginning, I kept this behaviour.

From what I understood by reading the sources, the allocated chunks were not linked to other free chunks as you can easily recover the header of such an allocated memory chunk by using the pointer returned by the malloc function. This is simply p-1. It is not possible to free an allocated region without that pointer anyway as it is not possible to know if someone is still using that memory region. It must be released by the one who called the malloc.

Quoted 3 lines

It *seems* that the chunk headers were "forgotten" in the malloc process, which led to my problems on usparc : a chunk was overwriting the header of the previous one. It's now fixed.

Maybe it is specific of that architecture. The function grub_malloc calls grub_memalign (0, size). Then the size is converted in blocks with

grub_size_t n = ((size + GRUB_MM_ALIGN - 1) >> GRUB_MM_ALIGN_LOG2) + 1;

which adds the extra block for the header. Which headers were overwritten exactly, I spent quite some time on that code and I couldn't see any problem except for the "grub free magic is broken" problem but off course it was not with that architecture in mind.

Signature · 6 lines
				Vincent Guffens
				PhD Student UCL/CESAME
				tel:   +32 10 47 80 30
Value your freedom, or you will lose it, teaches history.
"Don't bother us with politics," respond those who don't want to learn.
	      	-- Richard M. Stallman
#5 lore raw
In reply to Vincent Pelletier

Since I have no time at the moment, I will write a short comment.

Basically, I do not want huge changes, unless you have a good reason to do it. The current implementation has been tested intensively, is very stable, and I see no missing functionality in it. Please do not reinvent a wheel only because you do not understand it.

At a quick glance, one trivial bug is that GRUB_MM_ALIGN_LOG2 is set to 8 on 64-bit systems. This must be 5.

Okuji

#4 lore raw
In reply to Vincent Guffens

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 2 lines · Vincent Guffens

Vincent Pelletier wrote:
It must be released by the one who called the malloc.

I don't see any good reason to forget - on kernel side - this chunk, as we still keep the struct member in memory.
Anyway, I've done some other major changes to this patch, now the chunks are a simple chained list. That prevents bugs like thinking the first chunk is right after the last one in memory.
The new code is also much lighter on dprintf. I'll send a patch when I'll have solved what I think is the last bug which only triggers on
x86: malloc returns sometime out of region pointers...

Quoted 2 lines

grub_size_t n = ((size + GRUB_MM_ALIGN - 1) >> GRUB_MM_ALIGN_LOG2) + 1; which adds the extra block for the header.

I prefer relying on sizeof when it comes to allocating space instead of such formula. If we ever change the struct size, it would break in a strange way - like all memory allocation problems.

Vincent Pelletier
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFC06YxFEQoKRQyjtURArzOAKCfGiIOe2uRirlH5UxRum2YzKwXXQCfdxua ra/FrNuwvA+rG3GpWt7mtZw=
=UP6z
-----END PGP SIGNATURE-----

___________________________________________________________________________
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger Téléchargez cette version sur http://fr.messenger.yahoo.com

#6 lore raw
In reply to Yoshinori K. Okuji

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 1 line · Yoshinori K. Okuji

Basically, I do not want huge changes, unless you have a good reason to do it.

One of the reasons that made me study mm.c it that I get an unaligned pointer when I type "rescue".
Built from current cvs & tested with :

cvsco && ./configure && make && ./grub-mkimage -v -d . -o core.img *.mod && dd if=core.img of=/dev/fd0 bs=512 seek=1 && qemu -fda /dev/fd0

Tested with debian's gcc 4 and 3.4 .

Quoted 1 line

Please do not reinvent a wheel only because you do not understand it.

I thought it wasn't reliable because of the error mentioned higher. The problem is that for now my implementation gets more errors... :'( I found it really difficult to understand (mainly the alignment things) I thought that on a maintainer point of view it could be good to rewrite it with separate alignment functions.
I also thought it would be fun to code, but in the end it was more of a challenge "I can't believe I can't do that myself !" when it was crashing again and again.

Quoted 2 lines

At a quick glance, one trivial bug is that GRUB_MM_ALIGN_LOG2 is set to 8 on 64-bit systems. This must be 5.

Works 8|...

Vincent Pelletier
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFC07gnFEQoKRQyjtURAq1VAJ9EgPXFR7Hl3FKGNnszLtY+VjpXmgCfWByJ DiZHotfnwNIRDW7FSgsqK5s=
=tZKb
-----END PGP SIGNATURE-----

___________________________________________________________________________
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger T�l�chargez cette version sur http://fr.messenger.yahoo.com

#7 lore raw
Quoted 4 lines · Vincent Pelletier
Quoted 2 lines

At a quick glance, one trivial bug is that GRUB_MM_ALIGN_LOG2 is set to 8 on 64-bit systems. This must be 5.

Works 8|...

So with this change all problems are fixed? In that case this patch needs to be committed.

--
Marco

#8 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 2 lines · Marco Gerards

So with this change all problems are fixed? In that case this patch needs to be committed.

No I can read files from an ext2 partition on sparc64. What's the next step ? :) Loading modules ? I don't know exactly how to make a disk bootable, but I think I'll keep net boot for now.

Vincent Pelletier
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFC08h3FEQoKRQyjtURAk/nAJ9zuuGSoXlhimNQ7X9o9CZYX766BACdEaga ZTBLcL9L4XWm24t6gbldSII=
=QCgU
-----END PGP SIGNATURE-----

___________________________________________________________________________
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger Téléchargez cette version sur http://fr.messenger.yahoo.com

#9 lore raw
Quoted 8 lines · Vincent Pelletier
Quoted 2 lines · Marco Gerards

So with this change all problems are fixed? In that case this patch needs to be committed.

No I can read files from an ext2 partition on sparc64. What's the next step ? :) Loading modules ? I don't know exactly how to make a disk bootable, but I think I'll keep net boot for now.

In that case I would post the full patch for review now.

The PowerPC port lived for a long time without module support (although this was extremely awkward), so once your patch is fixed up it can be committed...

-Hollis

#10 lore raw
Quoted 10 lines · Hollis Blanchard
Quoted 8 lines · Vincent Pelletier
Quoted 2 lines · Marco Gerards

So with this change all problems are fixed? In that case this patch needs to be committed.

No I can read files from an ext2 partition on sparc64. What's the next step ? :) Loading modules ? I don't know exactly how to make a disk bootable, but I think I'll keep net boot for now.

Quoted 5 lines

In that case I would post the full patch for review now.

The PowerPC port lived for a long time without module support (although this was extremely awkward), so once your patch is fixed up it can be committed...

Right :)

So the next step would be a linux loader and relocation support.

--
Marco

#11 lore raw

sparc64 port : diffs to powerpc branches

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi.
Here are the diffs powerpc -> usparc, with some comments below. To be used to know which files can be made common.

boot:
cmain renamed in _start (no asm).
Special ppc options removed.
All the ieee1275 functions use the grub_intn_t type (see includes). Add explicit casts where needed.
Make "exit" call a "no return".

disk:
Special ppc test removed.
Types changed.

include:
ieee1275 functions prototypes updated.
Add explicit casts where needed.
Special ppc structs removed.
multiboot.h, libgcc removed (weren't modified).
Types length modified.

kern:
New dummy function (no asm).
dl updated to 64 bits ELF, but I'm not sure where it is used... grub_heap_start at 0x40000 to start after the ELF image in memory (when net loaded)
Changed "abort" to use "enter" OF standard function : now it *does* return when the user types "go" at the OF prompt.
Changed "stop" to use "exit" OF standard function : doesn't return, but fall back to OF prompt.
Changed some suspicious "&string" to just "string".
Added malloc calls when size can be known.
Removed "XXX" when documentation answers.
Added dprintf calls.
Disabled (#if 0) unused function.
Remove ppc specific partition numbering thing.
Use OB command to shut-down.

loader:
(nothing)

normal:
New dummy function (no asm).

term:
Type changes.
Added an environment variable to disable cls (useful to see early messages).

util:
Brute changes... Like dl, I don't know when it is used, so...

Vincent Pelletier
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFC1BATFEQoKRQyjtURAgZeAJ9yjTdxcQ20gTAJ7w1QGwXc+mM3ZQCgqD1w qYxuopRVuv+dKC5CKql/lQw=
=09bV
-----END PGP SIGNATURE-----

ieee1275/cmain.c +15 -65
diff -rupN powerpc/ieee1275/cmain.c sparc64/ieee1275/cmain.c
@@ -1,4 +1,4 @@
-/* cmain.c - Startup code for the PowerPC.  */
+/* cmain.c - Startup code for the UltraSparc.  */
 /*
  *  GRUB  --  GRand Unified Bootloader
  *  Copyright (C) 2003, 2004, 2005  Free Software Foundation, Inc.
@@ -24,80 +24,30 @@
 #include <grub/machine/ieee1275.h>
 #include <grub/kernel.h>
 
-/* OpenFirmware entry point passed to us from the real bootloader.  */
+/* OpenBoot entry point.  */
 intptr_t (*grub_ieee1275_entry_fn) (void *);
 
 grub_ieee1275_phandle_t grub_ieee1275_chosen;
 
-static grub_uint32_t grub_ieee1275_flags;
-
-
-
-int
-grub_ieee1275_test_flag (enum grub_ieee1275_flag flag)
-{
-  return (grub_ieee1275_flags & (1 << flag));
-}
-
 void
-grub_ieee1275_set_flag (enum grub_ieee1275_flag flag)
-{
-  grub_ieee1275_flags |= (1 << flag);
-}
-
-static void
-grub_ieee1275_find_options (void)
-{
-  grub_ieee1275_phandle_t options;
-  grub_ieee1275_phandle_t openprom;
-  int realmode;
-  int smartfw;
-
-  grub_ieee1275_finddevice ("/options", &options);
-  grub_ieee1275_get_property (options, "real-mode?", &realmode,
-			      sizeof (realmode), 0);
-  if (realmode)
-    grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_REAL_MODE);
-
-  grub_ieee1275_finddevice ("/openprom", &openprom);
-  smartfw = grub_ieee1275_get_property (openprom, "SmartFirmware-version",
-					0, 0, 0);
-  if (smartfw != -1)
-    grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_0_BASED_PARTITIONS);
-}
-
-void cmain (uint32_t r3, uint32_t r4, uint32_t r5);
+_start (uint64_t r0 __attribute__((unused)),
+        uint64_t r1 __attribute__((unused)),
+        uint64_t r2 __attribute__((unused)),
+        uint64_t r3 __attribute__((unused)),
+        uint64_t r4,
+        uint64_t r5 __attribute__((unused)));
 void
-cmain (uint32_t r3, uint32_t r4 __attribute__((unused)), uint32_t r5)
+_start (uint64_t r0 __attribute__((unused)),
+        uint64_t r1 __attribute__((unused)),
+        uint64_t r2 __attribute__((unused)),
+        uint64_t r3 __attribute__((unused)),
+        uint64_t r4,
+        uint64_t r5 __attribute__((unused)))
 {
-  if (r5 == 0xdeadbeef)
-    {
-      /* Entered from Old World stage1.  */
-      extern char _start;
-      extern char _end;
-
-      grub_ieee1275_entry_fn = (intptr_t (*)(void *)) r3;
-
-      grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NO_PARTITION_0);
-
-      /* Old World Open Firmware may use 4M-5M without claiming it.  */
-      grub_ieee1275_claim (0x00400000, 0x00100000, 0, 0);
-
-      /* Need to claim ourselves so we don't cannibalize our memory later.  */
-      if (grub_ieee1275_claim ((grub_addr_t) &_start, (grub_addr_t) &_end
-          - (grub_addr_t) &_start, 0, 0))
-	abort();
-    }
-  else
-    {
-      /* Assume we were entered from Open Firmware.  */
-      grub_ieee1275_entry_fn = (intptr_t (*)(void *)) r5;
-    }
+  grub_ieee1275_entry_fn = (intptr_t (*)(void *)) r4;
 
   grub_ieee1275_finddevice ("/chosen", &grub_ieee1275_chosen);
 
-  grub_ieee1275_find_options ();
-
   /* Now invoke the main function.  */
   grub_main ();
 
ieee1275/crt0.S +0 -43

43 lines not on this page · raw message

ieee1275/ieee1275.c +147 -150

586 lines not on this page · raw message

ieee1275/ofdisk.c +4 -5
diff -rupN powerpc/ieee1275/ofdisk.c sparc64/ieee1275/ofdisk.c
@@ -53,15 +53,14 @@ grub_ofdisk_open (const char *name, grub
   char *devpath;
   /* XXX: This should be large enough for any possible case.  */
   char prop[64];
-  int actual;
+  grub_ssize_t actual;
 
   devpath = grub_strndup (name, grub_strlen (name) + 2);
   if (! devpath)
     return grub_errno;
 
   /* To access the complete disk add `:0'.  */
-  if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_PARTITION_0))
-    grub_strcat (devpath, ":0");
+  grub_strcat (devpath, ":0");
 
   grub_ieee1275_open (devpath, &dev_ihandle);
   if (! dev_ihandle)
@@ -119,8 +118,8 @@ static grub_err_t
 grub_ofdisk_read (grub_disk_t disk, unsigned long sector,
 		  unsigned long size, char *buf)
 {
-  int status;
-  int actual;
+  grub_ssize_t status;
+  grub_ssize_t actual;
   unsigned long long pos;
 
   pos = (unsigned long long) sector * 512UL;
ieee1275/ieee1275.h +20 -33

100 lines not on this page · raw message

ieee1275/multiboot.h +0 -184

184 lines not on this page · raw message

ieee1275/time.h +1 -1
diff -rupN powerpc/ieee1275/time.h sparc64/ieee1275/time.h
@@ -25,6 +25,6 @@
 #define GRUB_TICKS_PER_SECOND	1000
 
 /* Return the real time in ticks.  */
-grub_uint32_t EXPORT_FUNC (grub_get_rtc) (void);
+grub_uintn_t EXPORT_FUNC (grub_get_rtc) (void);
 
 #endif /* ! KERNEL_TIME_HEADER */
libgcc.h +0 -43

43 lines not on this page · raw message

types.h +3 -3
diff -rupN powerpc/types.h sparc64/types.h
@@ -21,12 +21,12 @@
 #define GRUB_TYPES_CPU_HEADER	1
 
 /* The size of void *.  */
-#define GRUB_HOST_SIZEOF_VOID_P	4
+#define GRUB_HOST_SIZEOF_VOID_P	8
 
 /* The size of long.  */
-#define GRUB_HOST_SIZEOF_LONG	4
+#define GRUB_HOST_SIZEOF_LONG	8
 
-/* powerpc is big-endian.  */
+/* sparc64 is big-endian.  */
 #define GRUB_HOST_WORDS_BIGENDIAN	1
 
 
cache.c +9 -0
diff -rupN powerpc/cache.c sparc64/cache.c
@@ -0,0 +1,9 @@
+#include <grub/types.h>
+
+void grub_arch_sync_caches(void *address __attribute__((unused)),
+                           grub_size_t len __attribute__((unused)));
+void grub_arch_sync_caches(void *address __attribute__((unused)),
+                           grub_size_t len __attribute__((unused)))
+{
+  return;
+}
cache.S +0 -45

45 lines not on this page · raw message

dl.c +21 -21

105 lines not on this page · raw message

ieee1275/init.c +20 -22

103 lines not on this page · raw message

ieee1275/openfw.c +37 -34

167 lines not on this page · raw message

setjmp.c +35 -0
diff -rupN powerpc/setjmp.c sparc64/setjmp.c
@@ -0,0 +1,35 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2004  Free Software Foundation, Inc.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+/*
+ * int grub_setjmp (grub_jmp_buf env)
+ */
+int grub_setjmp (grub_jmp_buf env)
+{
+  return 0;
+}
+
+/*
+ * int grub_longjmp (grub_jmp_buf env, int val)
+ */
+int grub_longjmp (grub_jmp_buf env, int val)
+{
+  return 0;
+}
+
setjmp.S +0 -85

85 lines not on this page · raw message

ieee1275/ofconsole.c +5 -3
diff -rupN powerpc/ieee1275/ofconsole.c sparc64/ieee1275/ofconsole.c
@@ -120,7 +120,7 @@ static int
 grub_ofconsole_readkey (int *key)
 {
   char c;
-  int actual = 0;
+  grub_ssize_t actual = 0;
 
   grub_ieee1275_read (stdin_ihandle, &c, 1, &actual);
 
@@ -222,6 +222,8 @@ static void
 grub_ofconsole_cls (void)
 {
   /* Clear the screen.  */
+  if (grub_env_get ("nocls"))
+    return;
   grub_ofconsole_writeesc ("\e[2J");
   grub_gotoxy (0, 0);
 }
@@ -241,8 +243,8 @@ grub_ofconsole_refresh (void)
 static grub_err_t
 grub_ofconsole_init (void)
 {
-  char data[4];
-  grub_size_t actual;
+  unsigned char data[4];
+  grub_ssize_t actual;
   int col;
 
   if (grub_ieee1275_get_property (grub_ieee1275_chosen, "stdout", data,
ieee1275/grub-mkimage.c +53 -53

202 lines not on this page · raw message

#12 lore raw

Re: sparc64 port : diffs to powerpc branches

Vincent Pelletier <[email protected]> writes:

Hi Vincent,

Quoted 2 lines

Here are the diffs powerpc -> usparc, with some comments below. To be used to know which files can be made common.

Nice!

Quoted 1 line

All the ieee1275 functions use the grub_intn_t type (see includes).

So this can be shared.

Quoted 4 lines

Add explicit casts where needed.

disk:
Special ppc test removed.

This is an important test. Please do not remove it so this code can be shared. Just make sure GRUB_IEEE1275_FLAG_NO_PARTITION_0 is set or not set, depending on how OB works.

Quoted 8 lines

Types changed.

include:
ieee1275 functions prototypes updated.
Add explicit casts where needed.
Special ppc structs removed.
multiboot.h, libgcc removed (weren't modified).
Types length modified.

Can this be done in a way that we can share most (all?) headers related to ieee 1275?

Quoted 3 lines

kern:
New dummy function (no asm).
dl updated to 64 bits ELF, but I'm not sure where it is used...

You have to write the relocator first. It is used for module loading.

Quoted 2 lines

Changed "abort" to use "enter" OF standard function : now it *does* return when the user types "go" at the OF prompt.

Perhaps we can do this on the PPC port as well?

Quoted 1 line

Changed some suspicious "&string" to just "string".

hm?

Quoted 1 line

Added malloc calls when size can be known.

Nice!

Quoted 1 line

Removed "XXX" when documentation answers.

Nice!

Quoted 1 line

Disabled (#if 0) unused function.

Can you write the code so it works on both the PPC and sparc so this code can be shared? Some code you disabled like this has a function on the PPC, IIRC.

Quoted 1 line

Remove ppc specific partition numbering thing.

Can you explain this?

Quoted 2 lines

normal:
New dummy function (no asm).

When you implement this, you can support switching from normal to rescue mode and back properly.

Quoted 3 lines

term:
Type changes.
Added an environment variable to disable cls (useful to see early messages).

Ok.

Quoted 2 lines

util:
Brute changes... Like dl, I don't know when it is used, so...

grub-mkimage is used to add modules to grubof.

Do you want me to fully review the complete patch or was it just a reference for your description?

Thanks,
Marco

#13 lore raw

Re: sparc64 port : diffs to powerpc branches

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 3 lines · Marco Gerards

This is an important test. Please do not remove it so this code can be shared. Just make sure GRUB_IEEE1275_FLAG_NO_PARTITION_0 is set or not set, depending on how OB works.

No problem, I removed it to show that it isn't needed for usparc.

Quoted 2 lines

Can this be done in a way that we can share most (all?) headers related to ieee 1275?

I think so, except for some special function, like the term colour one (I don't think usparc can change colour... Or at least not the same way ppc does.)

Quoted 1 line
Quoted 1 line

Changed some suspicious "&string" to just "string".

Some function with void * arguments were actualy receiving char *[]. There was no warning about it, but I think there was a leak. I changed them to char * (dynamically allocated, see next remark :) ).

Quoted 2 lines
Quoted 1 line

Added malloc calls when size can be known.

Nice!

More can be done, I haven't done it everywhere.

Quoted 3 lines

Can you write the code so it works on both the PPC and sparc so this code can be shared? Some code you disabled like this has a function on the PPC, IIRC.

I think that function works on usparc (not sure though) but as it is not used at all, I commented it (to get some remarks about it so I can guess what it's used for :) ).

Quoted 2 lines
Quoted 1 line

Remove ppc specific partition numbering thing.

Can you explain this?

It seems that ppc numbers his partitions a special way (ruled by a flag, so we can make it common to both if the flag is correctly set).

Quoted 2 lines

When you implement this, you can support switching from normal to rescue mode and back properly.

There should be a bug in the x86 implementation, that would explain the unaligned pointer I get when switching to rescue mode from normal mode.

Quoted 1 line

grub-mkimage is used to add modules to grubof.

So this works, sun partition label & ext2 is read.

Quoted 2 lines

Do you want me to fully review the complete patch or was it just a reference for your description?

I think you shouldn't. Once the common parts will have been extracted a real patch with changelog will be edited.

Vincent Pelletier
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFC1CzBFEQoKRQyjtURAicmAJ9ElgCCIk8uxl5K3CVzxejvt/Tz7QCfTyXC qfT6xq2HLEtGILe/ved1JYA=
=fWNO
-----END PGP SIGNATURE-----

___________________________________________________________________________
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger Téléchargez cette version sur http://fr.messenger.yahoo.com

#17 lore raw

Re: sparc64 port : diffs to powerpc branches

In reply to Vincent Pelletier
Quoted 3 lines · Vincent Pelletier

Hi.
Here are the diffs powerpc -> usparc, with some comments below. To be used to know which files can be made common.

I will see about moving the easily shared files.

Quoted 2 lines

boot:
cmain renamed in _start (no asm).

Sparc will need to provide its own cmain.c and init.c; these files cannot be shared.

Quoted 3 lines

Special ppc options removed.
All the ieee1275 functions use the grub_intn_t type (see includes). Add explicit casts where needed.

ieee1275/ieee1275.c 2005-07-12 20:05:49.000000000 +0200 renamed from ieee1275/ieee1275.c 2005-06-21 04:33:51.000000000 +0200 +2 -2
@@ -42,43 +41,43 @@ grub_ieee1275_finddevice (char *name, gr
  {
    struct find_device_args {
      struct grub_ieee1275_common_hdr common;
-    char *device;
-    grub_ieee1275_phandle_t phandle;
+    grub_intn_t device;
+    grub_intn_t phandle;
    } args;
 

As we discussed on IRC, "grub_intn_t" should instead be called "grub_ieee1275_cell_t", defined as 32 bits on PPC and 64 bits on Sparc.

Quoted 5 lines

Make "exit" call a "no return".

disk:
Special ppc test removed.
Types changed.

Sparc should provide its own grub_ieee1275_test_flag(), as this is a good and trivially portable abstraction. We will then need a consolidated list of flags (common to all IEEE1275 architectures).

Quoted 3 lines

term:
Type changes.
Added an environment variable to disable cls (useful to see early messages).

This is useful, but I believe we should use the already-defined "debug" environment variable for this. After all, if we have set "debug," we probably would like to see the output without the screen being cleared.

Quoted 2 lines

util:
Brute changes... Like dl, I don't know when it is used, so...

You may very well need a grub-mkimage.c, but you do not need to hack up PowerPC's. :)

I will look into these applying some of these changes now...

-Hollis

#18 lore raw

Re: common ieee1275 code

In reply to Vincent Pelletier

This patch is loosely based on Vincent's Sparc patches. It changes the IEEE1275 code to use a new type, grub_ieee1275_cell_t. This is necessary because OpenBoot on Sparc requires the cell size to be 64 bits, while Open Firmware on PowerPC requires it to be 32 bits.

It's rather large because it moves a few files around that Vincent indicated can be directly shared between Sparc and PowerPC:
- disk/powerpc/ieee1275/ofdisk.c -> disk/ieee1275/ofdisk.c
- include/grub/powerpc/ieee1275/ieee1275.h -> include/grub/ieee1275/ieee1275.h
- include/grub/powerpc/ieee1275/ofdisk.h -> include/grub/ieee1275/ofdisk.h
- term/powerpc/ieee1275/ofconsole.c -> term/ieee1275/ofconsole.c
- boot/powerpc/ieee1275/ieee1275.c -> kern/ieee1275.c

As long as I was moving things around, I noticed that <grub/machine/console.h> was no longer useful, so consolidated both i386 and powerpc's into include/grub/console.h.

I have tested this on PowerPC, and once all the compile annoyances were fixed it booted perfectly.

Vincent, this is not exactly what you had in some places, but I think this diff will help you a lot.

If there are no complaints, I will send a real changelog entry soon.

-Hollis

Index: boot/powerpc/ieee1275/cmain.c
===================================================================
RCS file: /cvsroot/grub/grub2/boot/powerpc/ieee1275/cmain.c,v retrieving revision 1.10

powerpc/ieee1275/cmain.c +5 -5
diff -u -p -r1.10 cmain.c
@@ -20,12 +20,12 @@
 
 #include <alloca.h>
 #include <stdint.h>
-
-#include <grub/machine/ieee1275.h>
 #include <grub/kernel.h>
+#include <grub/machine/kernel.h>
+#include <grub/ieee1275/ieee1275.h>
 
 /* OpenFirmware entry point passed to us from the real bootloader.  */
-intptr_t (*grub_ieee1275_entry_fn) (void *);
+int (*grub_ieee1275_entry_fn) (void *);
 
 grub_ieee1275_phandle_t grub_ieee1275_chosen;
 
@@ -76,7 +76,7 @@ cmain (uint32_t r3, uint32_t r4 __attrib
       extern char _start;
       extern char _end;
 
-      grub_ieee1275_entry_fn = (intptr_t (*)(void *)) r3;
+      grub_ieee1275_entry_fn = (int (*)(void *)) r3;
 
       grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NO_PARTITION_0);
 
@@ -91,7 +91,7 @@ cmain (uint32_t r3, uint32_t r4 __attrib
   else
     {
       /* Assume we were entered from Open Firmware.  */
-      grub_ieee1275_entry_fn = (intptr_t (*)(void *)) r5;
+      grub_ieee1275_entry_fn = (int (*)(void *)) r5;
     }
 
   grub_ieee1275_finddevice ("/chosen", &grub_ieee1275_chosen);

Index: boot/powerpc/ieee1275/ieee1275.c
===================================================================
RCS file: /cvsroot/grub/grub2/boot/powerpc/ieee1275/ieee1275.c,v retrieving revision 1.12

powerpc/ieee1275/ieee1275.c +90 -93

398 lines not on this page · raw message

Index: commands/ieee1275/halt.c
===================================================================
RCS file: /cvsroot/grub/grub2/commands/ieee1275/halt.c,v retrieving revision 1.2

ieee1275/halt.c +1 -1
diff -u -p -r1.2 halt.c
@@ -21,7 +21,7 @@
 #include <grub/normal.h>
 #include <grub/dl.h>
 #include <grub/misc.h>
-#include <grub/machine/ieee1275.h>
+#include <grub/machine/kernel.h>
 
 static grub_err_t
 grub_cmd_halt (struct grub_arg_list *state __attribute__ ((unused)),

Index: commands/ieee1275/reboot.c
===================================================================
RCS file: /cvsroot/grub/grub2/commands/ieee1275/reboot.c,v retrieving revision 1.2

ieee1275/reboot.c +1 -1
diff -u -p -r1.2 reboot.c
@@ -21,7 +21,7 @@
 #include <grub/normal.h>
 #include <grub/dl.h>
 #include <grub/misc.h>
-#include <grub/machine/ieee1275.h>
+#include <grub/machine/kernel.h>
 
 static grub_err_t
 grub_cmd_reboot (struct grub_arg_list *state __attribute__ ((unused)),

Index: commands/ieee1275/suspend.c
===================================================================
RCS file: /cvsroot/grub/grub2/commands/ieee1275/suspend.c,v retrieving revision 1.2

ieee1275/suspend.c +1 -1
diff -u -p -r1.2 suspend.c
@@ -21,7 +21,7 @@
 #include <grub/normal.h>
 #include <grub/dl.h>
 #include <grub/misc.h>
-#include <grub/machine/ieee1275.h>
+#include <grub/machine/kernel.h>
 
 static grub_err_t
 grub_cmd_suspend (struct grub_arg_list *state  __attribute__ ((unused)),

Index: conf/powerpc-ieee1275.rmk
===================================================================
RCS file: /cvsroot/grub/grub2/conf/powerpc-ieee1275.rmk,v retrieving revision 1.30

powerpc-ieee1275.rmk +4 -3
diff -u -p -r1.30 powerpc-ieee1275.rmk
@@ -12,7 +12,8 @@ DEFSYMFILES += kernel_syms.lst
 grubof_HEADERS = arg.h boot.h device.h disk.h dl.h elf.h env.h err.h \
 	file.h fs.h kernel.h misc.h mm.h net.h rescue.h symbol.h \
 	term.h types.h powerpc/libgcc.h loader.h \
-	partition.h pc_partition.h machine/time.h machine/ieee1275.h
+	partition.h pc_partition.h ieee1275/ieee1275.h machine/time.h \
+	machine/kernel.h
 
 grubof_symlist.c: $(addprefix include/grub/,$(grubof_HEADERS)) gensymlist.sh
 	sh $(srcdir)/gensymlist.sh $(filter %.h,$^) > $@
@@ -55,8 +56,8 @@ grubof_SOURCES = boot/powerpc/ieee1275/c
 	boot/powerpc/ieee1275/ieee1275.c kern/main.c kern/device.c \
 	kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
 	kern/misc.c kern/mm.c kern/loader.c kern/rescue.c kern/term.c \
-	kern/powerpc/ieee1275/init.c term/powerpc/ieee1275/ofconsole.c \
-	kern/powerpc/ieee1275/openfw.c disk/powerpc/ieee1275/ofdisk.c \
+	kern/powerpc/ieee1275/init.c term/ieee1275/ofconsole.c \
+	kern/powerpc/ieee1275/openfw.c disk/ieee1275/ofdisk.c \
 	kern/partition.c kern/env.c kern/powerpc/dl.c grubof_symlist.c \
 	kern/powerpc/cache.S
 grubof_HEADERS = grub/powerpc/ieee1275/ieee1275.h

Index: disk/powerpc/ieee1275/ofdisk.c
===================================================================
RCS file: disk/powerpc/ieee1275/ofdisk.c

powerpc/ieee1275/ofdisk.c deleted +0 -182

182 lines not on this page · raw message

Index: include/grub/i386/pc/console.h
===================================================================
RCS file: include/grub/i386/pc/console.h

grub/i386/pc/console.h deleted +0 -59

59 lines not on this page · raw message

Index: include/grub/powerpc/ieee1275/console.h
===================================================================
RCS file: include/grub/powerpc/ieee1275/console.h

grub/powerpc/ieee1275/console.h deleted +0 -59

59 lines not on this page · raw message

Index: include/grub/powerpc/ieee1275/ieee1275.h
===================================================================
RCS file: /cvsroot/grub/grub2/include/grub/powerpc/ieee1275/ieee1275.h,v retrieving revision 1.18

grub/powerpc/ieee1275/ieee1275.h +1 -127

135 lines not on this page · raw message

Index: include/grub/powerpc/ieee1275/kernel.h
===================================================================
RCS file: /cvsroot/grub/grub2/include/grub/powerpc/ieee1275/kernel.h,v retrieving revision 1.2

grub/powerpc/ieee1275/kernel.h +6 -0
diff -u -p -r1.2 kernel.h
@@ -20,6 +20,12 @@
 #ifndef GRUB_KERNEL_MACHINE_HEADER
 #define GRUB_KERNEL_MACHINE_HEADER	1
 
+#include <grub/symbol.h>
+
+void EXPORT_FUNC (abort) (void);
+void EXPORT_FUNC (grub_reboot) (void);
+void EXPORT_FUNC (grub_halt) (void);
+
 /* Where grub-mkimage places the core modules in memory.  */
 #define GRUB_IEEE1275_MODULE_BASE 0x00300000
 

Index: include/grub/powerpc/ieee1275/ofdisk.h
===================================================================
RCS file: include/grub/powerpc/ieee1275/ofdisk.h

grub/powerpc/ieee1275/ofdisk.h deleted +0 -26
diff -N include/grub/powerpc/ieee1275/ofdisk.h
@@ -1,26 +0,0 @@
-/*
- *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2005  Free Software Foundation, Inc.
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#ifndef GRUB_OFDISK_MACHINE_HEADER
-#define GRUB_OFDISK_MACHINE_HEADER	1
-
-extern void grub_ofdisk_init (void);
-extern void grub_ofdisk_fini (void);
-
-#endif /* ! GRUB_INIT_MACHINE_HEADER */

Index: kern/powerpc/ieee1275/init.c
===================================================================
RCS file: /cvsroot/grub/grub2/kern/powerpc/ieee1275/init.c,v retrieving revision 1.19

powerpc/ieee1275/init.c +3 -3
diff -u -p -r1.19 init.c
@@ -23,16 +23,16 @@
 #include <grub/disk.h>
 #include <grub/mm.h>
 #include <grub/partition.h>
-#include <grub/machine/ieee1275.h>
 #include <grub/normal.h>
 #include <grub/fs.h>
 #include <grub/setjmp.h>
 #include <grub/env.h>
 #include <grub/misc.h>
+#include <grub/console.h>
 #include <grub/machine/time.h>
 #include <grub/machine/kernel.h>
-#include <grub/machine/console.h>
-#include <grub/machine/ofdisk.h>
+#include <grub/ieee1275/ofdisk.h>
+#include <grub/ieee1275/ieee1275.h>
 
 /* Apple OF 1.0.5 reserves 0x0 to 0x4000 for the exception handlers.  */
 static const grub_addr_t grub_heap_start = 0x4000;

Index: kern/powerpc/ieee1275/openfw.c
===================================================================
RCS file: /cvsroot/grub/grub2/kern/powerpc/ieee1275/openfw.c,v retrieving revision 1.11

powerpc/ieee1275/openfw.c +6 -4
diff -u -p -r1.11 openfw.c
@@ -21,7 +21,8 @@
 #include <grub/err.h>
 #include <grub/misc.h>
 #include <grub/mm.h>
-#include <grub/machine/ieee1275.h>
+#include <grub/machine/kernel.h>
+#include <grub/ieee1275/ieee1275.h>
 
 enum grub_ieee1275_parse_type
 {
@@ -38,11 +39,11 @@ grub_children_iterate (char *devpath,
   grub_ieee1275_phandle_t child;
 
   grub_ieee1275_finddevice (devpath, &dev);
-  if (dev == -1)
+  if (dev == (grub_ieee1275_phandle_t) -1)
     return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Unknown device");
 
   grub_ieee1275_child (dev, &child);
-  if (child == -1)
+  if (child == (grub_ieee1275_phandle_t) -1)
     return grub_error (GRUB_ERR_BAD_DEVICE, "Device has no children");
 
   do
@@ -125,7 +126,8 @@ grub_devalias_iterate (int (*hook) (stru
 	  continue;
 	}
       
-      if (grub_ieee1275_finddevice (devpath, &dev) || dev == -1)
+      if (grub_ieee1275_finddevice (devpath, &dev)
+	  || dev == (grub_ieee1275_phandle_t) -1)
 	{
 	  grub_free (devpath);
 	  continue;

Index: term/powerpc/ieee1275/ofconsole.c
===================================================================
RCS file: term/powerpc/ieee1275/ofconsole.c

powerpc/ieee1275/ofconsole.c deleted +0 -311

311 lines not on this page · raw message

Index: util/console.c
===================================================================
RCS file: /cvsroot/grub/grub2/util/console.c,v
retrieving revision 1.8

console.c +1 -1
diff -u -p -r1.8 console.c
@@ -19,7 +19,7 @@
  */
 
 #include <curses.h>
-#include <grub/machine/console.h>
+#include <grub/console.h>
 #include <grub/term.h>
 #include <grub/types.h>
 

Index: util/grub-emu.c
===================================================================
RCS file: /cvsroot/grub/grub2/util/grub-emu.c,v
retrieving revision 1.18

grub-emu.c +1 -1
diff -u -p -r1.18 grub-emu.c
@@ -29,7 +29,7 @@
 #include <grub/fs.h>
 #include <grub/i386/pc/util/biosdisk.h>
 #include <grub/dl.h>
-#include <grub/machine/console.h>
+#include <grub/console.h>
 #include <grub/util/misc.h>
 #include <grub/kernel.h>
 #include <grub/normal.h>
ieee1275/ofdisk.c new file +182 -0

182 lines not on this page · raw message

grub/console.h new file +39 -0
@@ -0,0 +1,39 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2002, 2004  Free Software Foundation, Inc.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef GRUB_CONSOLE_HEADER
+#define GRUB_CONSOLE_HEADER	1
+
+/* Define scan codes.  */
+#define GRUB_CONSOLE_KEY_LEFT		0x4B00
+#define GRUB_CONSOLE_KEY_RIGHT		0x4D00
+#define GRUB_CONSOLE_KEY_UP		0x4800
+#define GRUB_CONSOLE_KEY_DOWN		0x5000
+#define GRUB_CONSOLE_KEY_IC		0x5200
+#define GRUB_CONSOLE_KEY_DC		0x5300
+#define GRUB_CONSOLE_KEY_BACKSPACE	0x0008
+#define GRUB_CONSOLE_KEY_HOME		0x4700
+#define GRUB_CONSOLE_KEY_END		0x4F00
+#define GRUB_CONSOLE_KEY_NPAGE		0x4900
+#define GRUB_CONSOLE_KEY_PPAGE		0x5100
+
+void grub_console_init (void);
+void grub_console_fini (void);
+
+#endif /* ! GRUB_CONSOLE_HEADER */
grub/ieee1275/ieee1275.h new file +154 -0

154 lines not on this page · raw message

grub/ieee1275/ofdisk.h new file +26 -0
@@ -0,0 +1,26 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2005  Free Software Foundation, Inc.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef GRUB_OFDISK_HEADER
+#define GRUB_OFDISK_HEADER	1
+
+extern void grub_ofdisk_init (void);
+extern void grub_ofdisk_fini (void);
+
+#endif /* ! GRUB_INIT_HEADER */
ieee1275/ofconsole.c new file +311 -0

311 lines not on this page · raw message

Index: boot/powerpc/ieee1275/ieee1275.c
===================================================================
RCS file: boot/powerpc/ieee1275/ieee1275.c

powerpc/ieee1275/ieee1275.c deleted +0 -533

533 lines not on this page · raw message

Index: kern/ieee1275.c
===================================================================
RCS file: kern/ieee1275.c

ieee1275.c new file +530 -0

433 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Index: loader/powerpc/ieee1275/linux.c
===================================================================
RCS file: /cvsroot/grub/grub2/loader/powerpc/ieee1275/linux.c,v retrieving revision 1.8

powerpc/ieee1275/linux.c +3 -3
diff -u -p -r1.8 linux.c

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Part of the diff is not shown here. View the raw message.

#14 lore raw

Re: sparc64 port : diffs to powerpc branches

In reply to Vincent Pelletier
Quoted 6 lines · Vincent Pelletier
Quoted 3 lines · Marco Gerards

This is an important test. Please do not remove it so this code can be shared. Just make sure GRUB_IEEE1275_FLAG_NO_PARTITION_0 is set or not set, depending on how OB works.

No problem, I removed it to show that it isn't needed for usparc.

Ok, but it should be restored for the final patch.

Quoted 6 lines
Quoted 2 lines

Can this be done in a way that we can share most (all?) headers related to ieee 1275?

I think so, except for some special function, like the term colour one (I don't think usparc can change colour... Or at least not the same way ppc does.)

In that case the usparc port needs a GRUB_IEEE1275_FLAG_... to indicate it is not possible to change colors or that it works differently.

Quoted 5 lines
Quoted 1 line
Quoted 1 line

Changed some suspicious "&string" to just "string".

Some function with void * arguments were actualy receiving char *[]. There was no warning about it, but I think there was a leak. I changed them to char * (dynamically allocated, see next remark :) ).

It sounds ok to me.

Quoted 4 lines
Quoted 2 lines
Quoted 1 line

Added malloc calls when size can be known.

Nice!

More can be done, I haven't done it everywhere.

They should all be changed, but it is not that important for this port. It is something that should be done in general.

Quoted 7 lines
Quoted 3 lines

Can you write the code so it works on both the PPC and sparc so this code can be shared? Some code you disabled like this has a function on the PPC, IIRC.

I think that function works on usparc (not sure though) but as it is not used at all, I commented it (to get some remarks about it so I can guess what it's used for :) ).

Ehm, ok, please ask specific questions if you have them. :)

Quoted 5 lines
Quoted 2 lines
Quoted 1 line

Remove ppc specific partition numbering thing.

Can you explain this?

It seems that ppc numbers his partitions a special way (ruled by a flag, so we can make it common to both if the flag is correctly set).

Right.

Quoted 5 lines
Quoted 2 lines

When you implement this, you can support switching from normal to rescue mode and back properly.

There should be a bug in the x86 implementation, that would explain the unaligned pointer I get when switching to rescue mode from normal mode.

Perhaps... Can you put the bug report on the wiki so we will not forget about it?

Quoted 3 lines
Quoted 1 line

grub-mkimage is used to add modules to grubof.

So this works, sun partition label & ext2 is read.

You did not load ext2 as a module, but linked it into the binary. I assume you did not use grub-mkimage yet...

Quoted 5 lines
Quoted 2 lines

Do you want me to fully review the complete patch or was it just a reference for your description?

I think you shouldn't. Once the common parts will have been extracted a real patch with changelog will be edited.

Ok, cool. I am looking forwards to that patch.

Thanks,
Marco

#19 lore raw

Re: common ieee1275 code

In reply to Hollis Blanchard
Quoted 4 lines · Hollis Blanchard

This patch is loosely based on Vincent's Sparc patches. It changes the IEEE1275 code to use a new type, grub_ieee1275_cell_t. This is necessary because OpenBoot on Sparc requires the cell size to be 64 bits, while Open Firmware on PowerPC requires it to be 32 bits.

Thanks for your patch, it should make things easier for Vincent because he has no PPC. I don't have any problems with this patch. Sometimes you include <grub/machine/kernel.h> while it was not included before. Sometimes you add and sometimes you remove <grub/ieee1275/ieee1275.h>, I do not understand it.

Please write a changelog so we can apply this ASAP. I assume there were no additional warnings because of this patch.

Thanks,
Marco

#15 lore raw

Re: sparc64 port : diffs to powerpc branches

In reply to Marco Gerards

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 3 lines · Marco Gerards

In that case the usparc port needs a GRUB_IEEE1275_FLAG_... to indicate it is not possible to change colors or that it works differently.

Good idea.

Quoted 2 lines

Perhaps... Can you put the bug report on the wiki so we will not forget about it?

Done. Btw, I hope my wiki clean up (pages full of links) is ok. I wondered if it was worth the noise it made in the change log...

Quoted 2 lines

You did not load ext2 as a module, but linked it into the binary. I assume you did not use grub-mkimage yet...

Oh, I thought you meant it was used to add them statically in grubof.

Quoted 1 line

Ok, cool. I am looking forwards to that patch.

I think patches should be applied in this order :
- - Apply file moving patch for ieee1275 common files.
- - Apply the general patchs I sent (so we have a clean status to add the sparc64 port, like grub_get_rtc prototype change, the already-applied mm.c patch to correct behaviour on 64 bits archs, ...)
- - Finally apply the sparc64 specific adds (should be only file additions at this step, excepts for changes in configure[.ac] and ChangeLog :) ).

Vincent Pelletier
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFC1XxRFEQoKRQyjtURAgciAKCYAeqt7PGpx85WOj0iciC4P49FLwCffFMe wwtEclilaG6A8+SUUO4KIGQ=
=NR2U
-----END PGP SIGNATURE-----

___________________________________________________________________________
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger Téléchargez cette version sur http://fr.messenger.yahoo.com

#16 lore raw

Re: sparc64 port : diffs to powerpc branches

Quoted 4 lines · Vincent Pelletier
Quoted 2 lines

You did not load ext2 as a module, but linked it into the binary. I assume you did not use grub-mkimage yet...

Oh, I thought you meant it was used to add them statically in grubof.

No, this is how things work:

At the moment you have grubof with ext2 compiled in.

In the future we should have a very small grubof (with a better name ;)). It can load modules at run time. It is possible to add modules to grubof using grub-mkimage. In that case a new grubof binary is made. That new binary is the same as the old one, with the modules embedded. When it is loaded the modules (still ELF files) are loaded to a known location.

The first thing GRUB does is checking that known location to see if there are modules loaded there. It parses and loads the modules (using the ELF loader+relocator). So it works the same as loading a module from disk, now it is just loaded from memory. I hope this makes things a bit more clear, otherwise just ask me on IRC or so.

Quoted 9 lines
Quoted 1 line

Ok, cool. I am looking forwards to that patch.

I think patches should be applied in this order :
- Apply file moving patch for ieee1275 common files.
- Apply the general patchs I sent (so we have a clean status to add the sparc64 port, like grub_get_rtc prototype change, the already-applied mm.c patch to correct behaviour on 64 bits archs, ...)
- Finally apply the sparc64 specific adds (should be only file additions at this step, excepts for changes in configure[.ac] and ChangeLog :) ).

Right, although I still do not agree on the grub_get_rtc prototype. :)

Thanks,
Marco

#20 lore raw

Re: common ieee1275 code

In reply to Marco Gerards
Quoted 7 lines · Marco Gerards
Quoted 4 lines · Hollis Blanchard

This patch is loosely based on Vincent's Sparc patches. It changes the IEEE1275 code to use a new type, grub_ieee1275_cell_t. This is necessary because OpenBoot on Sparc requires the cell size to be 64 bits, while Open Firmware on PowerPC requires it to be 32 bits.

Quoted 8 lines

Thanks for your patch, it should make things easier for Vincent because he has no PPC. I don't have any problems with this patch. Sometimes you include <grub/machine/kernel.h> while it was not included before. Sometimes you add and sometimes you remove <grub/ieee1275/ieee1275.h>, I do not understand it.

Please write a changelog so we can apply this ASAP. I assume there were no additional warnings because of this patch.

Oops, fixed. Now the ufs.c warnings are the only warnings present. ;) Our build is very verbose; "make 1> /dev/null" is quite useful for this.

I did update the patch slightly (attached). If this is acceptable, please check in the patch for me, as I will be travelling for a couple weeks and it will be difficult to work on GRUB during this time. If it is not acceptable, please fix it for me. :)

I will note that one related file is still left: kern/powerpc/ieee1275/openfw.c. That file contains some PowerPC-specific code, such as grub_map, grub_reboot, and grub_halt. However, it also contains code that I think will be generally useful, such as device tree path parsing and grub_devalias_iterate. I will leave it to others to determine how to split that up.

-Hollis

2005-07-13 Hollis Blanchard <[email protected]>

* include/grub/powerpc/ieee1275/ieee1275.h: Move ...
* include/grub/ieee1275/ieee1275.h: ... to here. All users
updated.
Move abort', grub_reboot', and `grub_halt' prototypes ...
* include/grub/powerpc/ieee1275/kernel.h: ... to here.
* commands/ieee1275/halt.c: Include <grub/machine/kernel.h>
instead
of <grub/machine/ieee1275.h>.
* commands/ieee1275/reboot.c: Likewise.
* boot/powerpc/ieee1275/ieee1275.c: Move ...
* kern/ieee1275.c: ... to here. All users updated. Change all parameter structs to use new type `grub_ieee1275_cell_t'.
* term/powerpc/ieee1275/ofconsole.c: Move ...
* term/ieee1275/ofconsole.c: ... to here. All users updated.
* disk/powerpc/ieee1275/ofdisk.c: Move ...
* disk/ieee1275/ofdisk.c: ... to here. All users updated.
* boot/powerpc/ieee1275/cmain.c: Change
`grub_ieee1275_entry_fn' type
to return int.
* include/grub/i386/pc/console.h: Move to
include/grub/console.h.
Remove unused prototypes. All users updated.
* include/grub/powerpc/ieee1275/console.h: Removed.
* include/grub/powerpc/ieee1275/ieee1275.h: Define `grub_ieee1275_cell_t'.
* kern/powerpc/ieee1275/openfw.c: Include
<grub/machine/kernel.h>.
Cast comparisons with -1 to the correct type.
* loader/powerpc/ieee1275/linux.c (kernel_entry_t): Change
parameter

        type to match `grub_ieee1275_entry_fn'.

Index: boot/powerpc/ieee1275/cmain.c
===================================================================
RCS file: /cvsroot/grub/grub2/boot/powerpc/ieee1275/cmain.c,v retrieving revision 1.10

powerpc/ieee1275/cmain.c +5 -5
diff -u -p -r1.10 cmain.c
@@ -20,12 +20,12 @@
 
 #include <alloca.h>
 #include <stdint.h>
-
-#include <grub/machine/ieee1275.h>
 #include <grub/kernel.h>
+#include <grub/machine/kernel.h>
+#include <grub/ieee1275/ieee1275.h>
 
 /* OpenFirmware entry point passed to us from the real bootloader.  */
-intptr_t (*grub_ieee1275_entry_fn) (void *);
+int (*grub_ieee1275_entry_fn) (void *);
 
 grub_ieee1275_phandle_t grub_ieee1275_chosen;
 
@@ -76,7 +75,7 @@ cmain (uint32_t r3, uint32_t r4 __attrib
       extern char _start;
       extern char _end;
 
-      grub_ieee1275_entry_fn = (intptr_t (*)(void *)) r3;
+      grub_ieee1275_entry_fn = (int (*)(void *)) r3;
 
       grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NO_PARTITION_0);
 
@@ -91,7 +90,7 @@ cmain (uint32_t r3, uint32_t r4 __attrib
   else
     {
       /* Assume we were entered from Open Firmware.  */
-      grub_ieee1275_entry_fn = (intptr_t (*)(void *)) r5;
+      grub_ieee1275_entry_fn = (int (*)(void *)) r5;
     }
 
   grub_ieee1275_finddevice ("/chosen", &grub_ieee1275_chosen);

Index: boot/powerpc/ieee1275/ieee1275.c
===================================================================
RCS file: boot/powerpc/ieee1275/ieee1275.c

powerpc/ieee1275/ieee1275.c deleted +0 -533

533 lines not on this page · raw message

Index: commands/ieee1275/halt.c
===================================================================
RCS file: /cvsroot/grub/grub2/commands/ieee1275/halt.c,v retrieving revision 1.2

ieee1275/halt.c +1 -1
diff -u -p -r1.2 halt.c
@@ -21,7 +21,7 @@
 #include <grub/normal.h>
 #include <grub/dl.h>
 #include <grub/misc.h>
-#include <grub/machine/ieee1275.h>
+#include <grub/machine/kernel.h>
 
 static grub_err_t
 grub_cmd_halt (struct grub_arg_list *state __attribute__ ((unused)),

Index: commands/ieee1275/reboot.c
===================================================================
RCS file: /cvsroot/grub/grub2/commands/ieee1275/reboot.c,v retrieving revision 1.2

ieee1275/reboot.c +1 -1
diff -u -p -r1.2 reboot.c
@@ -21,7 +21,7 @@
 #include <grub/normal.h>
 #include <grub/dl.h>
 #include <grub/misc.h>
-#include <grub/machine/ieee1275.h>
+#include <grub/machine/kernel.h>
 
 static grub_err_t
 grub_cmd_reboot (struct grub_arg_list *state __attribute__ ((unused)),

Index: commands/ieee1275/suspend.c
===================================================================
RCS file: /cvsroot/grub/grub2/commands/ieee1275/suspend.c,v retrieving revision 1.2

ieee1275/suspend.c +1 -1
diff -u -p -r1.2 suspend.c
@@ -21,7 +21,7 @@
 #include <grub/normal.h>
 #include <grub/dl.h>
 #include <grub/misc.h>
-#include <grub/machine/ieee1275.h>
+#include <grub/ieee1275/ieee1275.h>
 
 static grub_err_t
 grub_cmd_suspend (struct grub_arg_list *state  __attribute__ ((unused)),

Index: conf/powerpc-ieee1275.rmk
===================================================================
RCS file: /cvsroot/grub/grub2/conf/powerpc-ieee1275.rmk,v retrieving revision 1.30

powerpc-ieee1275.rmk +5 -4
diff -u -p -r1.30 powerpc-ieee1275.rmk
@@ -12,7 +12,8 @@ DEFSYMFILES += kernel_syms.lst
 grubof_HEADERS = arg.h boot.h device.h disk.h dl.h elf.h env.h err.h \
 	file.h fs.h kernel.h misc.h mm.h net.h rescue.h symbol.h \
 	term.h types.h powerpc/libgcc.h loader.h \
-	partition.h pc_partition.h machine/time.h machine/ieee1275.h
+	partition.h pc_partition.h ieee1275/ieee1275.h machine/time.h \
+	machine/kernel.h
 
 grubof_symlist.c: $(addprefix include/grub/,$(grubof_HEADERS)) gensymlist.sh
 	sh $(srcdir)/gensymlist.sh $(filter %.h,$^) > $@
@@ -52,11 +53,11 @@ grub_emu_SOURCES = commands/boot.c comma
 grub_emu_LDFLAGS = -lncurses
 
 grubof_SOURCES = boot/powerpc/ieee1275/crt0.S boot/powerpc/ieee1275/cmain.c \
-	boot/powerpc/ieee1275/ieee1275.c kern/main.c kern/device.c \
+	kern/ieee1275.c kern/main.c kern/device.c \
 	kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
 	kern/misc.c kern/mm.c kern/loader.c kern/rescue.c kern/term.c \
-	kern/powerpc/ieee1275/init.c term/powerpc/ieee1275/ofconsole.c \
-	kern/powerpc/ieee1275/openfw.c disk/powerpc/ieee1275/ofdisk.c \
+	kern/powerpc/ieee1275/init.c term/ieee1275/ofconsole.c \
+	kern/powerpc/ieee1275/openfw.c disk/ieee1275/ofdisk.c \
 	kern/partition.c kern/env.c kern/powerpc/dl.c grubof_symlist.c \
 	kern/powerpc/cache.S
 grubof_HEADERS = grub/powerpc/ieee1275/ieee1275.h

Index: disk/powerpc/ieee1275/ofdisk.c
===================================================================
RCS file: disk/powerpc/ieee1275/ofdisk.c

powerpc/ieee1275/ofdisk.c deleted +0 -182

182 lines not on this page · raw message

Index: include/grub/i386/pc/console.h
===================================================================
RCS file: include/grub/i386/pc/console.h

grub/i386/pc/console.h deleted +0 -59

59 lines not on this page · raw message

Index: include/grub/powerpc/ieee1275/console.h
===================================================================
RCS file: include/grub/powerpc/ieee1275/console.h

grub/powerpc/ieee1275/console.h deleted +0 -59

59 lines not on this page · raw message

Index: include/grub/powerpc/ieee1275/ieee1275.h
===================================================================
RCS file: /cvsroot/grub/grub2/include/grub/powerpc/ieee1275/ieee1275.h,v retrieving revision 1.18

grub/powerpc/ieee1275/ieee1275.h +1 -127

135 lines not on this page · raw message

Index: include/grub/powerpc/ieee1275/kernel.h
===================================================================
RCS file: /cvsroot/grub/grub2/include/grub/powerpc/ieee1275/kernel.h,v retrieving revision 1.2

grub/powerpc/ieee1275/kernel.h +6 -0
diff -u -p -r1.2 kernel.h
@@ -20,6 +20,12 @@
 #ifndef GRUB_KERNEL_MACHINE_HEADER
 #define GRUB_KERNEL_MACHINE_HEADER	1
 
+#include <grub/symbol.h>
+
+void EXPORT_FUNC (abort) (void);
+void EXPORT_FUNC (grub_reboot) (void);
+void EXPORT_FUNC (grub_halt) (void);
+
 /* Where grub-mkimage places the core modules in memory.  */
 #define GRUB_IEEE1275_MODULE_BASE 0x00300000
 

Index: include/grub/powerpc/ieee1275/ofdisk.h
===================================================================
RCS file: include/grub/powerpc/ieee1275/ofdisk.h

grub/powerpc/ieee1275/ofdisk.h deleted +0 -26
diff -N include/grub/powerpc/ieee1275/ofdisk.h
@@ -1,26 +0,0 @@
-/*
- *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2005  Free Software Foundation, Inc.
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#ifndef GRUB_OFDISK_MACHINE_HEADER
-#define GRUB_OFDISK_MACHINE_HEADER	1
-
-extern void grub_ofdisk_init (void);
-extern void grub_ofdisk_fini (void);
-
-#endif /* ! GRUB_INIT_MACHINE_HEADER */

Index: kern/ieee1275.c
===================================================================
RCS file: kern/ieee1275.c

ieee1275.c new file +530 -0

530 lines not on this page · raw message

Index: kern/powerpc/ieee1275/init.c
===================================================================
RCS file: /cvsroot/grub/grub2/kern/powerpc/ieee1275/init.c,v retrieving revision 1.19

powerpc/ieee1275/init.c +3 -3
diff -u -p -r1.19 init.c
@@ -23,16 +23,16 @@
 #include <grub/disk.h>
 #include <grub/mm.h>
 #include <grub/partition.h>
-#include <grub/machine/ieee1275.h>
 #include <grub/normal.h>
 #include <grub/fs.h>
 #include <grub/setjmp.h>
 #include <grub/env.h>
 #include <grub/misc.h>
+#include <grub/console.h>
 #include <grub/machine/time.h>
 #include <grub/machine/kernel.h>
-#include <grub/machine/console.h>
-#include <grub/machine/ofdisk.h>
+#include <grub/ieee1275/ofdisk.h>
+#include <grub/ieee1275/ieee1275.h>
 
 /* Apple OF 1.0.5 reserves 0x0 to 0x4000 for the exception handlers.  */
 static const grub_addr_t grub_heap_start = 0x4000;

Index: kern/powerpc/ieee1275/openfw.c
===================================================================
RCS file: /cvsroot/grub/grub2/kern/powerpc/ieee1275/openfw.c,v retrieving revision 1.11

powerpc/ieee1275/openfw.c +6 -4
diff -u -p -r1.11 openfw.c
@@ -21,7 +21,8 @@
 #include <grub/err.h>
 #include <grub/misc.h>
 #include <grub/mm.h>
-#include <grub/machine/ieee1275.h>
+#include <grub/machine/kernel.h>
+#include <grub/ieee1275/ieee1275.h>
 
 enum grub_ieee1275_parse_type
 {
@@ -38,11 +39,11 @@ grub_children_iterate (char *devpath,
   grub_ieee1275_phandle_t child;
 
   grub_ieee1275_finddevice (devpath, &dev);
-  if (dev == -1)
+  if (dev == (grub_ieee1275_phandle_t) -1)
     return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Unknown device");
 
   grub_ieee1275_child (dev, &child);
-  if (child == -1)
+  if (child == (grub_ieee1275_phandle_t) -1)
     return grub_error (GRUB_ERR_BAD_DEVICE, "Device has no children");
 
   do
@@ -125,7 +126,8 @@ grub_devalias_iterate (int (*hook) (stru
 	  continue;
 	}
       
-      if (grub_ieee1275_finddevice (devpath, &dev) || dev == -1)
+      if (grub_ieee1275_finddevice (devpath, &dev)
+	  || dev == (grub_ieee1275_phandle_t) -1)
 	{
 	  grub_free (devpath);
 	  continue;

Index: loader/powerpc/ieee1275/linux.c
===================================================================
RCS file: /cvsroot/grub/grub2/loader/powerpc/ieee1275/linux.c,v retrieving revision 1.8

powerpc/ieee1275/linux.c +3 -3
diff -u -p -r1.8 linux.c
@@ -18,14 +18,14 @@
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#include <grub/machine/loader.h>
-#include <grub/machine/ieee1275.h>
 #include <grub/elf.h>
 #include <grub/loader.h>
 #include <grub/dl.h>
 #include <grub/mm.h>
 #include <grub/rescue.h>
 #include <grub/misc.h>
+#include <grub/ieee1275/ieee1275.h>
+#include <grub/machine/loader.h>
 
 static grub_dl_t my_mod;
 
@@ -40,7 +40,7 @@ static grub_size_t linux_size;
 
 static char *linux_args;
 
-typedef void (*kernel_entry_t) (void *, unsigned long, intptr_t (void *),
+typedef void (*kernel_entry_t) (void *, unsigned long, int (void *),
 				unsigned long, unsigned long);
 
 static grub_err_t

Index: term/powerpc/ieee1275/ofconsole.c
===================================================================
RCS file: term/powerpc/ieee1275/ofconsole.c

powerpc/ieee1275/ofconsole.c deleted +0 -311

311 lines not on this page · raw message

Index: util/console.c
===================================================================
RCS file: /cvsroot/grub/grub2/util/console.c,v
retrieving revision 1.8

console.c +1 -1
diff -u -p -r1.8 console.c
@@ -19,7 +19,7 @@
  */
 
 #include <curses.h>
-#include <grub/machine/console.h>
+#include <grub/console.h>
 #include <grub/term.h>
 #include <grub/types.h>
 

Index: util/grub-emu.c
===================================================================
RCS file: /cvsroot/grub/grub2/util/grub-emu.c,v
retrieving revision 1.18

grub-emu.c +1 -1
diff -u -p -r1.18 grub-emu.c
@@ -29,7 +29,7 @@
 #include <grub/fs.h>
 #include <grub/i386/pc/util/biosdisk.h>
 #include <grub/dl.h>
-#include <grub/machine/console.h>
+#include <grub/console.h>
 #include <grub/util/misc.h>
 #include <grub/kernel.h>
 #include <grub/normal.h>
#21 lore raw

Re: common ieee1275 code

Quoted 4 lines · Hollis Blanchard

I did update the patch slightly (attached). If this is acceptable, please check in the patch for me, as I will be travelling for a couple weeks and it will be difficult to work on GRUB during this time. If it is not acceptable, please fix it for me. :)

Sure! Have fun next weeks!

Quoted 7 lines

I will note that one related file is still left:
kern/powerpc/ieee1275/openfw.c. That file contains some PowerPC-specific code, such as grub_map, grub_reboot, and grub_halt. However, it also contains code that I think will be generally useful, such as device tree path parsing and grub_devalias_iterate. I will leave it to others to determine how to split that up.

Why won't those functions work on the usparc? I hope Vincent can test those commands.

Thanks,
Marco

#22 lore raw

Re: common ieee1275 code

Quoted 10 lines · Marco Gerards
Quoted 7 lines

I will note that one related file is still left:
kern/powerpc/ieee1275/openfw.c. That file contains some PowerPC-specific code, such as grub_map, grub_reboot, and grub_halt. However, it also contains code that I think will be generally useful, such as device tree path parsing and grub_devalias_iterate. I will leave it to others to determine how to split that up.

Why won't those functions work on the usparc? I hope Vincent can test those commands.

grub_map is necessarily processor-specific; it includes MMU permission bits. I also don't know if it's a method of the cpu node found via /chosen/mmu.

"reboot" and "halt" commands are not specified by IEEE1275, so vary by implementation. For example, although "reset-all" works on both Mac and pSeries, "shut-down" doesn't work on pSeries. The odds of OpenBoot diverging here are pretty good.

-Hollis

#23 lore raw

Re: common ieee1275 code

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 4 lines · Hollis Blanchard

"reboot" and "halt" commands are not specified by IEEE1275, so vary by implementation. For example, although "reset-all" works on both Mac and pSeries, "shut-down" doesn't work on pSeries. The odds of OpenBoot diverging here are pretty good.

Reboot is "reset-all" too, and shutdown is "power-off" (from OB v3 documentation). Tested on U1, U10, Sun blade 150.
Maybe could these be set with #define.

Something like :

kern/ieee1275/openfw.c :
[...]
#include <grub/machine/ieee1275.h>
[...]

include/grub/machine/ieee1275.h :
#define REBOOT "reset-all"
#define HALT "power-off"
[maybe others]

Vincent Pelletier
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFC1u0lFEQoKRQyjtURArpfAKCIcw8pc+2ZYfI3pEjv5HkGQTMLigCcDy/Y nU7GfthXExumgxVGoErbCe4=
=NOTX
-----END PGP SIGNATURE-----

___________________________________________________________________________
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger Téléchargez cette version sur http://fr.messenger.yahoo.com

#24 lore raw

Re: common ieee1275 code

Quoted 3 lines · Vincent Pelletier

Reboot is "reset-all" too, and shutdown is "power-off" (from OB v3 documentation). Tested on U1, U10, Sun blade 150.
Maybe could these be set with #define.

It should be detected run-time, I think. For example there are multiple Open Firmware implementations for the PPC. One binary should be usable on multiple implementations. So a flag or so would be better.

Thanks,
Marco

#25 lore raw

Re: common ieee1275 code

Quoted 10 lines · Marco Gerards
Quoted 3 lines · Vincent Pelletier

Reboot is "reset-all" too, and shutdown is "power-off" (from OB v3 documentation). Tested on U1, U10, Sun blade 150.
Maybe could these be set with #define.

It should be detected run-time, I think. For example there are multiple Open Firmware implementations for the PPC. One binary should be usable on multiple implementations. So a flag or so would be better.

We do not need runtime selection between PPC and Sparc commands. There is no problem with each architecture defining its own grub_reboot() and grub_halt(), in fact you would expect this! Right now each function is a one-liner even...

AFAIK all PPC implementations use "reset-all" to reboot, so until we know of another command used by some other PPC firmware, no flag is needed.

-Hollis

#26 lore raw

Re: common ieee1275 code

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 2 lines · Hollis Blanchard

AFAIK all PPC implementations use "reset-all" to reboot, so until we know of another command used by some other PPC firmware, no flag is needed.

We could even (dirty inside !) call sequeltnailly al the methods. As they are used to perform something that definitelly interrupts program execution, it shouldn't hurt.

Something like :

ieee1275exec("power-off");
ieee1275exec("shutdown");
for(;;);

So each one is a fallback for the previous one. We would have to make sure C doesn't skip the lines following the first, so the function have not to be tagged "never return".

Vincent Pelletier
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFC2YUnFEQoKRQyjtURAvpsAJ0XTOU28i4kfWPVciCeWQeg+x/luQCZARbq IU3/eozctoQJjMa8pC/VXXg=
=KGa0
-----END PGP SIGNATURE-----

___________________________________________________________________________
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger Téléchargez cette version sur http://fr.messenger.yahoo.com

#27 lore raw

Re: common ieee1275 code

In reply to Hollis Blanchard
Quoted 4 lines · Hollis Blanchard

I did update the patch slightly (attached). If this is acceptable, please check in the patch for me, as I will be travelling for a couple weeks and it will be difficult to work on GRUB during this time. If it is not acceptable, please fix it for me. :)

...

Quoted 5 lines

2005-07-13 Hollis Blanchard <[email protected]>

* include/grub/powerpc/ieee1275/ieee1275.h: Move ...
* include/grub/ieee1275/ieee1275.h: ... to here. All users
updated.

This new file does not exist in your patch. Can you please send it to me or tell me how to reproduce it?

Thanks,
Marco

#28 lore raw

Re: common ieee1275 code

Quoted 9 lines · Marco Gerards
Quoted 4 lines · Hollis Blanchard

I did update the patch slightly (attached). If this is acceptable, please check in the patch for me, as I will be travelling for a couple weeks and it will be difficult to work on GRUB during this time. If it is not acceptable, please fix it for me. :)

...

Quoted 8 lines
Quoted 5 lines

2005-07-13 Hollis Blanchard <[email protected]>

* include/grub/powerpc/ieee1275/ieee1275.h: Move ...
* include/grub/ieee1275/ieee1275.h: ... to here. All users
updated.

This new file does not exist in your patch. Can you please send it to me or tell me how to reproduce it?

Unfortunately I can't get at it right now. :/

It was mostly a straight move, but some of the prototypes needed updating... I don't remember, there may have been a few other small changes.

-Hollis