* [PATCH] Huge changes in mm.c
@ 2005-07-11 12:21 Vincent Pelletier
2005-07-11 12:56 ` Marco Gerards
` (2 more replies)
0 siblings, 3 replies; 29+ messages in thread
From: Vincent Pelletier @ 2005-07-11 12:21 UTC (permalink / raw)
To: Grub-devel
[-- Attachment #1: Type: text/plain, Size: 3310 bytes --]
-----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 <subdino2004@yahoo.fr>
* 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-----
[-- Attachment #2: mm.c.diff --]
[-- Type: text/plain, Size: 14586 bytes --]
Index: kern/mm.c
===================================================================
RCS file: /cvsroot/grub/grub2/kern/mm.c,v
retrieving revision 1.10
diff -u -p -r1.10 mm.c
--- kern/mm.c 23 Jun 2005 08:12:19 -0000 1.10
+++ kern/mm.c 11 Jul 2005 12:19:12 -0000
@@ -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
\f
+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
diff -u -p -r1.4 mm.h
--- include/grub/mm.h 20 Jan 2005 17:25:39 -0000 1.4
+++ include/grub/mm.h 11 Jul 2005 12:19:12 -0000
@@ -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
^ permalink raw reply [flat|nested] 29+ messages in thread* Re: [PATCH] Huge changes in mm.c 2005-07-11 12:21 [PATCH] Huge changes in mm.c Vincent Pelletier @ 2005-07-11 12:56 ` Marco Gerards 2005-07-11 13:20 ` Vincent Pelletier 2005-07-11 13:09 ` Vincent Guffens 2005-07-12 10:58 ` Yoshinori K. Okuji 2 siblings, 1 reply; 29+ messages in thread From: Marco Gerards @ 2005-07-11 12:56 UTC (permalink / raw) To: The development of GRUB 2 Vincent Pelletier <subdino2004@yahoo.fr> writes: Hi Vincent, > 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 ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] Huge changes in mm.c 2005-07-11 12:56 ` Marco Gerards @ 2005-07-11 13:20 ` Vincent Pelletier 0 siblings, 0 replies; 29+ messages in thread From: Vincent Pelletier @ 2005-07-11 13:20 UTC (permalink / raw) To: The development of GRUB 2 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain; charset=us-ascii, Size: 1066 bytes --] -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Marco Gerards wrote: > 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 ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] Huge changes in mm.c 2005-07-11 12:21 [PATCH] Huge changes in mm.c Vincent Pelletier 2005-07-11 12:56 ` Marco Gerards @ 2005-07-11 13:09 ` Vincent Guffens 2005-07-12 11:14 ` Vincent Pelletier 2005-07-12 10:58 ` Yoshinori K. Okuji 2 siblings, 1 reply; 29+ messages in thread From: Vincent Guffens @ 2005-07-11 13:09 UTC (permalink / raw) To: The development of GRUB 2 Vincent Pelletier wrote: > -----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. 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. > 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. -- 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 ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] Huge changes in mm.c 2005-07-11 13:09 ` Vincent Guffens @ 2005-07-12 11:14 ` Vincent Pelletier 0 siblings, 0 replies; 29+ messages in thread From: Vincent Pelletier @ 2005-07-12 11:14 UTC (permalink / raw) To: The development of GRUB 2 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain; charset=us-ascii, Size: 1396 bytes --] -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Vincent Guffens wrote: > 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... > 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 ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] Huge changes in mm.c 2005-07-11 12:21 [PATCH] Huge changes in mm.c Vincent Pelletier 2005-07-11 12:56 ` Marco Gerards 2005-07-11 13:09 ` Vincent Guffens @ 2005-07-12 10:58 ` Yoshinori K. Okuji 2005-07-12 12:31 ` Vincent Pelletier 2 siblings, 1 reply; 29+ messages in thread From: Yoshinori K. Okuji @ 2005-07-12 10:58 UTC (permalink / raw) To: The development of GRUB 2 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 ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] Huge changes in mm.c 2005-07-12 10:58 ` Yoshinori K. Okuji @ 2005-07-12 12:31 ` Vincent Pelletier 2005-07-12 12:55 ` Marco Gerards 0 siblings, 1 reply; 29+ messages in thread From: Vincent Pelletier @ 2005-07-12 12:31 UTC (permalink / raw) To: The development of GRUB 2 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Yoshinori K. Okuji wrote: > 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 . > 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. > 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 ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] Huge changes in mm.c 2005-07-12 12:31 ` Vincent Pelletier @ 2005-07-12 12:55 ` Marco Gerards 2005-07-12 13:41 ` Vincent Pelletier 0 siblings, 1 reply; 29+ messages in thread From: Marco Gerards @ 2005-07-12 12:55 UTC (permalink / raw) To: The development of GRUB 2 Vincent Pelletier <subdino2004@yahoo.fr> writes: >> 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 ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] Huge changes in mm.c 2005-07-12 12:55 ` Marco Gerards @ 2005-07-12 13:41 ` Vincent Pelletier 2005-07-12 15:12 ` Hollis Blanchard 0 siblings, 1 reply; 29+ messages in thread From: Vincent Pelletier @ 2005-07-12 13:41 UTC (permalink / raw) To: The development of GRUB 2 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain; charset=us-ascii, Size: 787 bytes --] -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Marco Gerards wrote: > 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 ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] Huge changes in mm.c 2005-07-12 13:41 ` Vincent Pelletier @ 2005-07-12 15:12 ` Hollis Blanchard 2005-07-12 15:46 ` Marco Gerards 0 siblings, 1 reply; 29+ messages in thread From: Hollis Blanchard @ 2005-07-12 15:12 UTC (permalink / raw) To: The development of GRUB 2 On Jul 12, 2005, at 8:41 AM, Vincent Pelletier wrote: > > Marco Gerards wrote: >> 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 ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] Huge changes in mm.c 2005-07-12 15:12 ` Hollis Blanchard @ 2005-07-12 15:46 ` Marco Gerards 2005-07-12 18:46 ` sparc64 port : diffs to powerpc branches Vincent Pelletier 0 siblings, 1 reply; 29+ messages in thread From: Marco Gerards @ 2005-07-12 15:46 UTC (permalink / raw) To: The development of GRUB 2 Hollis Blanchard <hollis@penguinppc.org> writes: > On Jul 12, 2005, at 8:41 AM, Vincent Pelletier wrote: >> >> Marco Gerards wrote: >>> 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... Right :) So the next step would be a linux loader and relocation support. -- Marco ^ permalink raw reply [flat|nested] 29+ messages in thread
* sparc64 port : diffs to powerpc branches 2005-07-12 15:46 ` Marco Gerards @ 2005-07-12 18:46 ` Vincent Pelletier 2005-07-12 19:40 ` Marco Gerards ` (2 more replies) 0 siblings, 3 replies; 29+ messages in thread From: Vincent Pelletier @ 2005-07-12 18:46 UTC (permalink / raw) To: The development of GRUB 2 [-- Attachment #1: Type: text/plain, Size: 1697 bytes --] -----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----- [-- Attachment #2: ppc_usp_boot.f.diff --] [-- Type: text/plain, Size: 20312 bytes --] diff -rupN powerpc/ieee1275/cmain.c sparc64/ieee1275/cmain.c --- powerpc/ieee1275/cmain.c 2005-06-21 05:12:15.000000000 +0200 +++ sparc64/ieee1275/cmain.c 2005-07-12 20:06:59.000000000 +0200 @@ -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; - -\f - -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 (); diff -rupN powerpc/ieee1275/crt0.S sparc64/ieee1275/crt0.S --- powerpc/ieee1275/crt0.S 2005-06-21 04:33:51.000000000 +0200 +++ sparc64/ieee1275/crt0.S 1970-01-01 01:00:00.000000000 +0100 @@ -1,43 +0,0 @@ -/* crt0.S - Startup code for the PowerPC. */ -/* - * GRUB -- GRand Unified Bootloader - * Copyright (C) 2003, 2004, 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. - */ - -.extern __bss_start -.extern _end - - .text - .align 2 - .globl _start -_start: - li 2, 0 - li 13, 0 - - /* Stage1 won't zero BSS for us. In other cases, why not do it again? */ - lis 6, (__bss_start - 4)@h - ori 6, 6, (__bss_start - 4)@l - lis 7, (_end - 4)@h - ori 7, 7, (_end - 4)@l - subf 7, 6, 7 - srwi 7, 7, 2 /* We store 4 bytes at a time. */ - mtctr 7 -2: stwu 2, 4(6) /* We know r2 is already 0 from above. */ - bdnz 2b - - bl cmain -1: b 1b diff -rupN powerpc/ieee1275/ieee1275.c sparc64/ieee1275/ieee1275.c --- powerpc/ieee1275/ieee1275.c 2005-06-21 04:33:51.000000000 +0200 +++ sparc64/ieee1275/ieee1275.c 2005-07-12 20:05:49.000000000 +0200 @@ -20,7 +20,6 @@ #include <grub/machine/ieee1275.h> - #define IEEE1275_PHANDLE_ROOT ((grub_ieee1275_phandle_t) 0) #define IEEE1275_PHANDLE_INVALID ((grub_ieee1275_phandle_t) -1) @@ -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; INIT_IEEE1275_COMMON (&args.common, "finddevice", 1, 1); - args.device = name; + args.device = (grub_intn_t) name; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; - *phandlep = args.phandle; + *phandlep = (grub_ieee1275_phandle_t) args.phandle; return 0; } int grub_ieee1275_get_property (grub_ieee1275_phandle_t phandle, const char *property, void *buf, - grub_size_t size, grub_size_t *actual) + grub_size_t size, grub_ssize_t *actual) { struct get_property_args { struct grub_ieee1275_common_hdr common; - grub_ieee1275_phandle_t phandle; - const char *prop; - void *buf; - int buflen; - int size; + grub_intn_t phandle; + grub_intn_t prop; + grub_intn_t buf; + grub_intn_t buflen; + grub_intn_t size; } args; INIT_IEEE1275_COMMON (&args.common, "getprop", 4, 1); - args.phandle = phandle; - args.prop = property; - args.buf = buf; - args.buflen = size; + args.phandle = (grub_intn_t) phandle; + args.prop = (grub_intn_t) property; + args.buf = (grub_intn_t) buf; + args.buflen = (grub_intn_t) size; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; if (actual) - *actual = args.size; + *actual = (grub_ssize_t) args.size; if (args.size == -1) return -1; return 0; @@ -86,48 +85,47 @@ grub_ieee1275_get_property (grub_ieee127 int grub_ieee1275_next_property (grub_ieee1275_phandle_t phandle, char *prev_prop, - char *prop, int *flags) + char *prop, grub_intn_t *flag) { struct get_property_args { struct grub_ieee1275_common_hdr common; - grub_ieee1275_phandle_t phandle; - char *prev_prop; - char *next_prop; - int flags; + grub_intn_t phandle; + grub_intn_t prev_prop; + grub_intn_t next_prop; + grub_intn_t flag; } args; INIT_IEEE1275_COMMON (&args.common, "nextprop", 3, 1); - args.phandle = phandle; - args.prev_prop = prev_prop; - args.next_prop = prop; - args.flags = -1; + args.phandle = (grub_intn_t) phandle; + args.prev_prop = (grub_intn_t) prev_prop; + args.next_prop = (grub_intn_t) prop; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; - if (flags) - *flags = args.flags; + if (flag) + *flag = args.flag; return 0; } int grub_ieee1275_get_property_length (grub_ieee1275_phandle_t phandle, - const char *prop, grub_size_t *length) + const char *prop, grub_ssize_t *length) { struct get_property_args { struct grub_ieee1275_common_hdr common; - grub_ieee1275_phandle_t phandle; - const char *prop; - grub_size_t length; + grub_intn_t phandle; + grub_intn_t prop; + grub_intn_t length; } args; INIT_IEEE1275_COMMON (&args.common, "getproplen", 2, 1); - args.phandle = phandle; - args.prop = prop; - args.length = -1; + args.phandle = (grub_intn_t) phandle; + args.prop = (grub_intn_t) prop; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; - *length = args.length; + if (length) + *length = (grub_ssize_t) args.length; return 0; } @@ -137,40 +135,41 @@ grub_ieee1275_instance_to_package (grub_ { struct instance_to_package_args { struct grub_ieee1275_common_hdr common; - grub_ieee1275_ihandle_t ihandle; - grub_ieee1275_phandle_t phandle; + grub_intn_t ihandle; + grub_intn_t phandle; } args; INIT_IEEE1275_COMMON (&args.common, "instance-to-package", 1, 1); - args.ihandle = ihandle; + args.ihandle = (grub_intn_t) ihandle; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; - *phandlep = args.phandle; + *phandlep = (grub_ieee1275_phandle_t) args.phandle; return 0; } int grub_ieee1275_package_to_path (grub_ieee1275_phandle_t phandle, - char *path, grub_size_t len, grub_size_t *actual) + char *path, grub_size_t len, + grub_ssize_t *actual) { struct instance_to_package_args { struct grub_ieee1275_common_hdr common; - grub_ieee1275_phandle_t phandle; - char *buf; - int buflen; - int actual; + grub_intn_t phandle; + grub_intn_t buf; + grub_intn_t buflen; + grub_intn_t actual; } args; INIT_IEEE1275_COMMON (&args.common, "package-to-path", 3, 1); - args.phandle = phandle; - args.buf = path; - args.buflen = len; + args.phandle = (grub_intn_t) phandle; + args.buf = (grub_intn_t) path; + args.buflen = (grub_intn_t) len; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; if (actual) - *actual = args.actual; + *actual = (grub_ssize_t) args.actual; return 0; } @@ -181,94 +180,94 @@ grub_ieee1275_instance_to_path (grub_iee { struct instance_to_package_args { struct grub_ieee1275_common_hdr common; - grub_ieee1275_ihandle_t ihandle; - char *buf; - int buflen; - int actual; + grub_intn_t ihandle; + grub_intn_t buf; + grub_intn_t buflen; + grub_intn_t actual; } args; INIT_IEEE1275_COMMON (&args.common, "instance-to-path", 3, 1); - args.ihandle = ihandle; - args.buf = path; - args.buflen = len; + args.ihandle = (grub_intn_t) ihandle; + args.buf = (grub_intn_t) path; + args.buflen = (grub_intn_t) len; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; if (actual) - *actual = args.actual; + *actual = (grub_size_t) args.actual; return 0; } int grub_ieee1275_write (grub_ieee1275_ihandle_t ihandle, void *buffer, - grub_size_t len, grub_size_t *actualp) + grub_size_t len, grub_ssize_t *actualp) { struct write_args { struct grub_ieee1275_common_hdr common; - grub_ieee1275_ihandle_t ihandle; - void *buf; - grub_size_t len; - grub_size_t actual; + grub_intn_t ihandle; + grub_intn_t buf; + grub_intn_t len; + grub_intn_t actual; } args; INIT_IEEE1275_COMMON (&args.common, "write", 3, 1); - args.ihandle = ihandle; - args.buf = buffer; - args.len = len; + args.ihandle = (grub_intn_t) ihandle; + args.buf = (grub_intn_t) buffer; + args.len = (grub_intn_t) len; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; if (actualp) - *actualp = args.actual; + *actualp = (grub_size_t) args.actual; return 0; } int grub_ieee1275_read (grub_ieee1275_ihandle_t ihandle, void *buffer, - grub_size_t len, grub_size_t *actualp) + grub_size_t len, grub_ssize_t *actualp) { struct write_args { struct grub_ieee1275_common_hdr common; - grub_ieee1275_ihandle_t ihandle; - void *buf; - grub_size_t len; - grub_size_t actual; + grub_intn_t ihandle; + grub_intn_t buf; + grub_intn_t len; + grub_intn_t actual; } args; INIT_IEEE1275_COMMON (&args.common, "read", 3, 1); - args.ihandle = ihandle; - args.buf = buffer; - args.len = len; + args.ihandle = (grub_intn_t) ihandle; + args.buf = (grub_intn_t) buffer; + args.len = (grub_intn_t) len; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; if (actualp) - *actualp = args.actual; + *actualp = (grub_size_t) args.actual; return 0; } int grub_ieee1275_seek (grub_ieee1275_ihandle_t ihandle, int pos_hi, - int pos_lo, int *result) + int pos_lo, grub_ssize_t *result) { struct write_args { struct grub_ieee1275_common_hdr common; - grub_ieee1275_ihandle_t ihandle; - int pos_hi; - int pos_lo; - int result; + grub_intn_t ihandle; + grub_intn_t pos_hi; + grub_intn_t pos_lo; + grub_intn_t result; } args; INIT_IEEE1275_COMMON (&args.common, "seek", 3, 1); - args.ihandle = ihandle; - args.pos_hi = pos_hi; - args.pos_lo = pos_lo; + args.ihandle = (grub_intn_t) ihandle; + args.pos_hi = (grub_intn_t) pos_hi; + args.pos_lo = (grub_intn_t) pos_lo; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; if (result) - *result = args.result; + *result = (grub_size_t) args.result; return 0; } @@ -278,16 +277,16 @@ grub_ieee1275_peer (grub_ieee1275_phandl { struct peer_args { struct grub_ieee1275_common_hdr common; - grub_ieee1275_phandle_t node; - grub_ieee1275_phandle_t result; + grub_intn_t node; + grub_intn_t result; } args; INIT_IEEE1275_COMMON (&args.common, "peer", 1, 1); - args.node = node; + args.node = (grub_intn_t) node; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; - *result = args.result; + *result = (grub_ieee1275_phandle_t) args.result; return 0; } @@ -297,17 +296,16 @@ grub_ieee1275_child (grub_ieee1275_phand { struct child_args { struct grub_ieee1275_common_hdr common; - grub_ieee1275_phandle_t node; - grub_ieee1275_phandle_t result; + grub_intn_t node; + grub_intn_t result; } args; INIT_IEEE1275_COMMON (&args.common, "child", 1, 1); - args.node = node; - args.result = IEEE1275_PHANDLE_INVALID; + args.node = (grub_intn_t) node; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; - *result = args.result; + *result = (grub_ieee1275_phandle_t) args.result; return 0; } @@ -317,31 +315,31 @@ grub_ieee1275_parent (grub_ieee1275_phan { struct parent_args { struct grub_ieee1275_common_hdr common; - grub_ieee1275_phandle_t node; - grub_ieee1275_phandle_t result; + grub_intn_t node; + grub_intn_t result; } args; INIT_IEEE1275_COMMON (&args.common, "parent", 1, 1); - args.node = node; + args.node = (grub_intn_t) node; args.result = IEEE1275_PHANDLE_INVALID; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; - *result = args.result; + *result = (grub_ieee1275_phandle_t) args.result; return 0; } int -grub_ieee1275_interpret (const char *command, int *catch) +grub_ieee1275_interpret (const char *command, grub_intn_t *catch) { struct enter_args { struct grub_ieee1275_common_hdr common; - const char *command; - int catch; + grub_intn_t command; + grub_intn_t catch; } args; INIT_IEEE1275_COMMON (&args.common, "interpret", 1, 1); - args.command = command; + args.command = (grub_intn_t) command; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; @@ -373,9 +371,8 @@ grub_ieee1275_exit (void) INIT_IEEE1275_COMMON (&args.common, "exit", 0, 0); - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - return 0; + IEEE1275_CALL_ENTRY_FN (&args); + for (;;); } int @@ -383,16 +380,16 @@ grub_ieee1275_open (char *node, grub_iee { struct open_args { struct grub_ieee1275_common_hdr common; - char *cstr; - grub_ieee1275_ihandle_t result; + grub_intn_t cstr; + grub_intn_t result; } args; INIT_IEEE1275_COMMON (&args.common, "open", 1, 1); - args.cstr = node; + args.cstr = (grub_intn_t) node; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; - *result = args.result; + *result = (grub_ieee1275_ihandle_t) args.result; return 0; } @@ -401,15 +398,14 @@ grub_ieee1275_close (grub_ieee1275_ihand { struct close_args { struct grub_ieee1275_common_hdr common; - grub_ieee1275_ihandle_t ihandle; + grub_intn_t ihandle; } args; INIT_IEEE1275_COMMON (&args.common, "close", 1, 0); - args.ihandle = ihandle; + args.ihandle = (grub_intn_t) ihandle; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; - return 0; } @@ -419,26 +415,23 @@ grub_ieee1275_claim (grub_addr_t addr, g { struct claim_args { struct grub_ieee1275_common_hdr common; - grub_addr_t addr; - grub_size_t size; - unsigned int align; - grub_addr_t base; + grub_intn_t addr; + grub_intn_t size; + grub_intn_t align; + grub_intn_t base; } args; INIT_IEEE1275_COMMON (&args.common, "claim", 3, 1); - args.addr = addr; - args.size = size; - args.align = align; + args.addr = (grub_intn_t) addr; + args.size = (grub_intn_t) size; + args.align = (grub_intn_t) align; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; - if (result) - *result = args.base; - - if (args.base == (grub_addr_t)-1) + *result = (grub_addr_t) args.base; + if ((grub_addr_t) args.base == (grub_addr_t) -1) return -1; - return 0; } @@ -447,17 +440,16 @@ grub_ieee1275_release (grub_addr_t addr, { struct release_args { struct grub_ieee1275_common_hdr common; - grub_addr_t addr; - grub_size_t size; + grub_intn_t addr; + grub_intn_t size; } args; INIT_IEEE1275_COMMON (&args.common, "release", 2, 0); - args.addr = addr; - args.size = size; + args.addr = (grub_intn_t) addr; + args.size = (grub_intn_t) size; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; - return 0; } @@ -468,38 +460,43 @@ grub_ieee1275_set_property (grub_ieee127 { struct set_property_args { struct grub_ieee1275_common_hdr common; - grub_ieee1275_phandle_t phandle; - const char *propname; - void *buf; - grub_size_t size; - grub_size_t actual; + grub_intn_t phandle; + grub_intn_t propname; + grub_intn_t buf; + grub_intn_t size; + grub_intn_t actual; } args; INIT_IEEE1275_COMMON (&args.common, "setprop", 4, 1); - args.size = size; - args.buf = buf; - args.propname = propname; - args.phandle = phandle; + args.size = (grub_intn_t) size; + args.buf = (grub_intn_t) buf; + args.propname = (grub_intn_t) propname; + args.phandle = (grub_intn_t) phandle; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; - *actual = args.actual; + if(actual) + *actual = (grub_size_t) args.actual; return 0; } int -grub_ieee1275_set_color (grub_ieee1275_ihandle_t ihandle, - int index, int r, int g, int b) +grub_ieee1275_set_color (grub_ieee1275_ihandle_t ihandle __attribute__((unused)), + int index __attribute__((unused)), + int r __attribute__((unused)), + int g __attribute__((unused)), + int b __attribute__((unused))) { +#if 0 struct set_color_args { struct grub_ieee1275_common_hdr common; - char *method; - grub_ieee1275_ihandle_t ihandle; - int index; - int b; - int g; - int r; - int result; + char *method; //char * + grub_ieee1275_ihandle_t ihandle; // + int index; //int + int b; //int + int g; //int + int r; //int + int result; //int } args; INIT_IEEE1275_COMMON (&args.common, "call-method", 6, 1); @@ -512,22 +509,22 @@ grub_ieee1275_set_color (grub_ieee1275_i if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; - +#endif return 0; } int -grub_ieee1275_milliseconds (grub_uint32_t *msecs) +grub_ieee1275_milliseconds (grub_uintn_t *msecs) { struct milliseconds_args { struct grub_ieee1275_common_hdr common; - grub_uint32_t msecs; + grub_intn_t msecs; } args; INIT_IEEE1275_COMMON (&args.common, "milliseconds", 0, 1); if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; - *msecs = args.msecs; + *msecs = (grub_uintn_t) args.msecs; return 0; } [-- Attachment #3: ppc_usp_disk.f.diff --] [-- Type: text/plain, Size: 1045 bytes --] diff -rupN powerpc/ieee1275/ofdisk.c sparc64/ieee1275/ofdisk.c --- powerpc/ieee1275/ofdisk.c 2005-05-01 05:45:35.000000000 +0200 +++ sparc64/ieee1275/ofdisk.c 2005-07-12 20:11:06.000000000 +0200 @@ -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; [-- Attachment #4: ppc_usp_include.f.diff --] [-- Type: text/plain, Size: 13101 bytes --] diff -rupN powerpc/ieee1275/ieee1275.h sparc64/ieee1275/ieee1275.h --- powerpc/ieee1275/ieee1275.h 2005-07-09 01:52:26.000000000 +0200 +++ sparc64/ieee1275/ieee1275.h 2005-07-12 20:16:23.000000000 +0200 @@ -50,13 +50,15 @@ struct grub_ieee1275_mem_region passed arguments and the expected number of return values, resp. */ struct grub_ieee1275_common_hdr { - char *name; - int nr_ins; - int nr_outs; + grub_intn_t name; + grub_intn_t nr_ins; + grub_intn_t nr_outs; }; #define INIT_IEEE1275_COMMON(p, xname, xins, xouts) \ - (p)->name = xname; (p)->nr_ins = xins; (p)->nr_outs = xouts + (p)->name = (grub_intn_t)xname; \ + (p)->nr_ins = (grub_intn_t)xins; \ + (p)->nr_outs = (grub_intn_t)xouts /* FIXME jrydberg: is this correct cell types? */ typedef intptr_t grub_ieee1275_ihandle_t; @@ -67,24 +69,6 @@ extern grub_ieee1275_phandle_t EXPORT_VA extern intptr_t (*grub_ieee1275_entry_fn) (void *); extern intptr_t (* EXPORT_VAR(grub_ieee1275_entry_fn)) (void *); -enum grub_ieee1275_flag -{ - /* Old World firmware fails seek when "dev:0" is opened. */ - GRUB_IEEE1275_FLAG_NO_PARTITION_0, - - /* Apple firmware runs in translated mode and requires use of the "map" - method. Other firmware runs in untranslated mode and doesn't like "map" - calls. */ - GRUB_IEEE1275_FLAG_REAL_MODE, - - /* CHRP specifies partitions are numbered from 1 (partition 0 refers to the - whole disk). However, CodeGen firmware numbers partitions from 0. */ - GRUB_IEEE1275_FLAG_0_BASED_PARTITIONS, -}; - -extern int EXPORT_FUNC(grub_ieee1275_test_flag) (enum grub_ieee1275_flag flag); -extern void EXPORT_FUNC(grub_ieee1275_set_flag) (enum grub_ieee1275_flag flag); - \f uint32_t EXPORT_FUNC(grub_ieee1275_decode_int_4) (unsigned char *p); @@ -93,36 +77,39 @@ int EXPORT_FUNC(grub_ieee1275_finddevice int EXPORT_FUNC(grub_ieee1275_get_property) (grub_ieee1275_phandle_t handle, const char *property, void *buf, grub_size_t size, - grub_size_t *actual); -int EXPORT_FUNC(grub_ieee1275_next_property) (int handle, char *prev_prop, - char *prop, int *flags); + grub_ssize_t *actual); +int EXPORT_FUNC(grub_ieee1275_next_property) (grub_ieee1275_phandle_t handle, + char *prev_prop, + char *prop, + grub_intn_t *flag); int EXPORT_FUNC(grub_ieee1275_get_property_length) - (grub_ieee1275_phandle_t handle, const char *prop, grub_size_t *length); + (grub_ieee1275_phandle_t handle, const char *prop, grub_ssize_t *length); int EXPORT_FUNC(grub_ieee1275_instance_to_package) (grub_ieee1275_ihandle_t ihandle, grub_ieee1275_phandle_t *phandlep); int EXPORT_FUNC(grub_ieee1275_package_to_path) (grub_ieee1275_phandle_t phandle, char *path, grub_size_t len, - grub_size_t *actual); + grub_ssize_t *actual); int EXPORT_FUNC(grub_ieee1275_instance_to_path) (grub_ieee1275_ihandle_t ihandle, char *path, grub_size_t len, grub_size_t *actual); int EXPORT_FUNC(grub_ieee1275_write) (grub_ieee1275_ihandle_t ihandle, void *buffer, grub_size_t len, - grub_size_t *actualp); + grub_ssize_t *actualp); int EXPORT_FUNC(grub_ieee1275_read) (grub_ieee1275_ihandle_t ihandle, void *buffer, grub_size_t len, - grub_size_t *actualp); + grub_ssize_t *actualp); int EXPORT_FUNC(grub_ieee1275_seek) (grub_ieee1275_ihandle_t ihandle, - int pos_hi, int pos_lo, int *result); + int pos_hi, int pos_lo, + grub_ssize_t *result); int EXPORT_FUNC(grub_ieee1275_peer) (grub_ieee1275_phandle_t node, grub_ieee1275_phandle_t *result); int EXPORT_FUNC(grub_ieee1275_child) (grub_ieee1275_phandle_t node, grub_ieee1275_phandle_t *result); int EXPORT_FUNC(grub_ieee1275_parent) (grub_ieee1275_phandle_t node, grub_ieee1275_phandle_t *result); -int EXPORT_FUNC(grub_ieee1275_interpret) (const char *command, int *catch); +int EXPORT_FUNC(grub_ieee1275_interpret) (const char *command, grub_intn_t *catch); int EXPORT_FUNC(grub_ieee1275_enter) (void); -int EXPORT_FUNC(grub_ieee1275_exit) (void); +int EXPORT_FUNC(grub_ieee1275_exit) (void) __attribute__ ((noreturn)); int EXPORT_FUNC(grub_ieee1275_open) (char *node, grub_ieee1275_ihandle_t *result); int EXPORT_FUNC(grub_ieee1275_close) (grub_ieee1275_ihandle_t ihandle); @@ -135,7 +122,7 @@ int EXPORT_FUNC(grub_ieee1275_set_proper grub_size_t *actual); int EXPORT_FUNC(grub_ieee1275_set_color) (grub_ieee1275_ihandle_t ihandle, int index, int r, int g, int b); -int EXPORT_FUNC(grub_ieee1275_milliseconds) (grub_uint32_t *msecs); +int EXPORT_FUNC(grub_ieee1275_milliseconds) (grub_uintn_t *msecs); grub_err_t EXPORT_FUNC(grub_devalias_iterate) diff -rupN powerpc/ieee1275/multiboot.h sparc64/ieee1275/multiboot.h --- powerpc/ieee1275/multiboot.h 2004-04-04 15:46:01.000000000 +0200 +++ sparc64/ieee1275/multiboot.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,184 +0,0 @@ -/* multiboot.h - multiboot header file. */ -/* - * GRUB -- GRand Unified Bootloader - * Copyright (C) 2003, 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_MULTIBOOT_MACHINE_HEADER -#define GRUB_MULTIBOOT_MACHINE_HEADER 1 - -/* How many bytes from the start of the file we search for the header. */ -#define GRUB_MB_SEARCH 8192 - -/* The magic field should contain this. */ -#define GRUB_MB_MAGIC 0x1BADB002 - -/* This should be in %eax. */ -#define GRUB_MB_MAGIC2 0x2BADB002 - -/* The bits in the required part of flags field we don't support. */ -#define GRUB_MB_UNSUPPORTED 0x0000fffc - -/* Alignment of multiboot modules. */ -#define GRUB_MB_MOD_ALIGN 0x00001000 - -/* - * Flags set in the 'flags' member of the multiboot header. - */ - -/* Align all boot modules on i386 page (4KB) boundaries. */ -#define GRUB_MB_PAGE_ALIGN 0x00000001 - -/* Must pass memory information to OS. */ -#define GRUB_MB_MEMORY_INFO 0x00000002 - -/* Must pass video information to OS. */ -#define GRUB_MB_VIDEO_MODE 0x00000004 - -/* This flag indicates the use of the address fields in the header. */ -#define GRUB_MB_AOUT_KLUDGE 0x00010000 - -/* - * Flags to be set in the 'flags' member of the multiboot info structure. - */ - -/* is there basic lower/upper memory information? */ -#define GRUB_MB_INFO_MEMORY 0x00000001 -/* is there a boot device set? */ -#define GRUB_MB_INFO_BOOTDEV 0x00000002 -/* is the command-line defined? */ -#define GRUB_MB_INFO_CMDLINE 0x00000004 -/* are there modules to do something with? */ -#define GRUB_MB_INFO_MODS 0x00000008 - -/* These next two are mutually exclusive */ - -/* is there a symbol table loaded? */ -#define GRUB_MB_INFO_AOUT_SYMS 0x00000010 -/* is there an ELF section header table? */ -#define GRUB_MB_INFO_ELF_SHDR 0x00000020 - -/* is there a full memory map? */ -#define GRUB_MB_INFO_MEM_MAP 0x00000040 - -/* Is there drive info? */ -#define GRUB_MB_INFO_DRIVE_INFO 0x00000080 - -/* Is there a config table? */ -#define GRUB_MB_INFO_CONFIG_TABLE 0x00000100 - -/* Is there a boot loader name? */ -#define GRUB_MB_INFO_BOOT_LOADER_NAME 0x00000200 - -/* Is there a APM table? */ -#define GRUB_MB_INFO_APM_TABLE 0x00000400 - -/* Is there video information? */ -#define GRUB_MB_INFO_VIDEO_INFO 0x00000800 - -#ifndef ASM_FILE - -#include <grub/types.h> - -struct grub_multiboot_header -{ - /* Must be GRUB_MB_MAGIC - see above. */ - grub_uint32_t magic; - - /* Feature flags. */ - grub_uint32_t flags; - - /* The above fields plus this one must equal 0 mod 2^32. */ - grub_uint32_t checksum; - - /* These are only valid if GRUB_MB_AOUT_KLUDGE is set. */ - grub_uint32_t header_addr; - grub_uint32_t load_addr; - grub_uint32_t load_end_addr; - grub_uint32_t bss_end_addr; - grub_uint32_t entry_addr; - - /* These are only valid if GRUB_MB_VIDEO_MODE is set. */ - grub_uint32_t mode_type; - grub_uint32_t width; - grub_uint32_t height; - grub_uint32_t depth; -}; - -struct grub_multiboot_info -{ - /* MultiBoot info version number */ - grub_uint32_t flags; - - /* Available memory from BIOS */ - grub_uint32_t mem_lower; - grub_uint32_t mem_upper; - - /* "root" partition */ - grub_uint32_t boot_device; - - /* Kernel command line */ - grub_uint32_t cmdline; - - /* Boot-Module list */ - grub_uint32_t mods_count; - grub_uint32_t mods_addr; - - grub_uint32_t syms[4]; - - /* Memory Mapping buffer */ - grub_uint32_t mmap_length; - grub_uint32_t mmap_addr; - - /* Drive Info buffer */ - grub_uint32_t drives_length; - grub_uint32_t drives_addr; - - /* ROM configuration table */ - grub_uint32_t config_table; - - /* Boot Loader Name */ - grub_uint32_t boot_loader_name; - - /* APM table */ - grub_uint32_t apm_table; - - /* Video */ - grub_uint32_t vbe_control_info; - grub_uint32_t vbe_mode_info; - grub_uint16_t vbe_mode; - grub_uint16_t vbe_interface_seg; - grub_uint16_t vbe_interface_off; - grub_uint16_t vbe_interface_len; -}; - -struct grub_mod_list -{ - /* the memory used goes from bytes 'mod_start' to 'mod_end-1' inclusive */ - grub_uint32_t mod_start; - grub_uint32_t mod_end; - - /* Module command line */ - grub_uint32_t cmdline; - - /* padding to take it to 16 bytes (must be zero) */ - grub_uint32_t pad; -}; - -#endif /* ! ASM_FILE */ - -#endif /* ! GRUB_MULTIBOOT_MACHINE_HEADER */ diff -rupN powerpc/ieee1275/time.h sparc64/ieee1275/time.h --- powerpc/ieee1275/time.h 2005-02-27 22:19:05.000000000 +0100 +++ sparc64/ieee1275/time.h 2005-07-12 19:14:58.000000000 +0200 @@ -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 */ diff -rupN powerpc/libgcc.h sparc64/libgcc.h --- powerpc/libgcc.h 2005-02-13 19:54:57.000000000 +0100 +++ sparc64/libgcc.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,43 +0,0 @@ -/* - * GRUB -- GRand Unified Bootloader - * Copyright (C) 2004 Free Software Foundation, Inc. - * - * GRUB 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 GRUB; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -void EXPORT_FUNC (memset) (void); -void EXPORT_FUNC (__adddf3) (void); -void EXPORT_FUNC (__addsf3) (void); -void EXPORT_FUNC (__ashldi3) (void); -void EXPORT_FUNC (__bss_start) (void); -void EXPORT_FUNC (__extendsfdf2) (void); -void EXPORT_FUNC (__fixunsdfsi) (void); -void EXPORT_FUNC (__floatsidf) (void); -void EXPORT_FUNC (__floatsisf) (void); -void EXPORT_FUNC (__lshrdi3) (void); -void EXPORT_FUNC (__make_dp) (void); -void EXPORT_FUNC (__make_fp) (void); -void EXPORT_FUNC (__muldf3) (void); -void EXPORT_FUNC (__mulsf3) (void); -void EXPORT_FUNC (__pack_d) (void); -void EXPORT_FUNC (__pack_f) (void); -void EXPORT_FUNC (__subdf3) (void); -void EXPORT_FUNC (__subsf3) (void); -void EXPORT_FUNC (__thenan_df) (void); -void EXPORT_FUNC (__thenan_sf) (void); -void EXPORT_FUNC (__trampoline_setup) (void); -void EXPORT_FUNC (__truncdfsf2) (void); -void EXPORT_FUNC (__unpack_d) (void); -void EXPORT_FUNC (__unpack_f) (void); diff -rupN powerpc/types.h sparc64/types.h --- powerpc/types.h 2004-12-27 14:46:20.000000000 +0100 +++ sparc64/types.h 2005-07-12 19:14:58.000000000 +0200 @@ -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 [-- Attachment #5: ppc_usp_kern.f.diff --] [-- Type: text/plain, Size: 14300 bytes --] diff -rupN powerpc/cache.c sparc64/cache.c --- powerpc/cache.c 1970-01-01 01:00:00.000000000 +0100 +++ sparc64/cache.c 2005-07-12 19:14:58.000000000 +0200 @@ -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; +} diff -rupN powerpc/cache.S sparc64/cache.S --- powerpc/cache.S 2004-12-27 14:46:20.000000000 +0100 +++ sparc64/cache.S 1970-01-01 01:00:00.000000000 +0100 @@ -1,45 +0,0 @@ -/* cache.S - Flush the processor cache for a specific region. */ -/* - * 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. - */ - -#define CACHE_LINE_BYTES 32 - - .text - - .align 2 - .globl grub_arch_sync_caches -grub_arch_sync_caches: - /* Force the dcache lines to memory. */ - li 5, 0 -1: dcbst 5, 3 - addi 5, 5, CACHE_LINE_BYTES - cmpw 5, 4 - blt 1b - sync /* Force all dcbsts to complete. */ - - /* Invalidate the icache lines. */ - li 5, 0 -1: icbi 5, 3 - addi 5, 5, CACHE_LINE_BYTES - cmpw 5, 4 - blt 1b - sync /* Force all icbis to complete. */ - isync /* Discard partially executed instructions that were - loaded from the invalid icache. */ - blr diff -rupN powerpc/dl.c sparc64/dl.c --- powerpc/dl.c 2005-02-14 19:41:33.000000000 +0100 +++ sparc64/dl.c 2005-07-12 19:14:58.000000000 +0200 @@ -27,7 +27,7 @@ grub_err_t grub_arch_dl_check_header (void *ehdr) { - Elf32_Ehdr *e = ehdr; + Elf64_Ehdr *e = ehdr; /* Check the magic numbers. */ if (e->e_ident[EI_CLASS] != ELFCLASS32 @@ -43,28 +43,28 @@ grub_arch_dl_check_header (void *ehdr) grub_err_t grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr) { - Elf32_Ehdr *e = ehdr; - Elf32_Shdr *s; - Elf32_Sym *symtab; - Elf32_Word entsize; + Elf64_Ehdr *e = ehdr; + Elf64_Shdr *s; + Elf64_Sym *symtab; + Elf64_Word entsize; unsigned i; /* Find a symbol table. */ - for (i = 0, s = (Elf32_Shdr *) ((char *) e + e->e_shoff); + for (i = 0, s = (Elf64_Shdr *) ((char *) e + e->e_shoff); i < e->e_shnum; - i++, s = (Elf32_Shdr *) ((char *) s + e->e_shentsize)) + i++, s = (Elf64_Shdr *) ((char *) s + e->e_shentsize)) if (s->sh_type == SHT_SYMTAB) break; if (i == e->e_shnum) return grub_error (GRUB_ERR_BAD_MODULE, "no symtab found"); - symtab = (Elf32_Sym *) ((char *) e + s->sh_offset); + symtab = (Elf64_Sym *) ((char *) e + s->sh_offset); entsize = s->sh_entsize; - for (i = 0, s = (Elf32_Shdr *) ((char *) e + e->e_shoff); + for (i = 0, s = (Elf64_Shdr *) ((char *) e + e->e_shoff); i < e->e_shnum; - i++, s = (Elf32_Shdr *) ((char *) s + e->e_shentsize)) + i++, s = (Elf64_Shdr *) ((char *) s + e->e_shentsize)) if (s->sh_type == SHT_RELA) { grub_dl_segment_t seg; @@ -76,23 +76,23 @@ grub_arch_dl_relocate_symbols (grub_dl_t if (seg) { - Elf32_Rela *rel, *max; + Elf64_Rela *rel, *max; - for (rel = (Elf32_Rela *) ((char *) e + s->sh_offset), + for (rel = (Elf64_Rela *) ((char *) e + s->sh_offset), max = rel + s->sh_size / s->sh_entsize; rel < max; rel++) { - Elf32_Word *addr; - Elf32_Sym *sym; - grub_uint32_t value; + Elf64_Xword *addr; + Elf64_Sym *sym; + grub_intn_t value; if (seg->size < rel->r_offset) return grub_error (GRUB_ERR_BAD_MODULE, "reloc offset is out of the segment"); - addr = (Elf32_Word *) ((char *) seg->addr + rel->r_offset); - sym = (Elf32_Sym *) ((char *) symtab + addr = (Elf64_Xword *) ((char *) seg->addr + rel->r_offset); + sym = (Elf64_Sym *) ((char *) symtab + entsize * ELF32_R_SYM (rel->r_info)); /* On the PPC the value does not have an explicit @@ -101,12 +101,12 @@ grub_arch_dl_relocate_symbols (grub_dl_t switch (ELF32_R_TYPE (rel->r_info)) { case R_PPC_ADDR16_LO: - *(Elf32_Half *) addr = value; + *(Elf64_Half *) addr = value; break; case R_PPC_REL24: { - Elf32_Sword delta = value - (Elf32_Word) addr; + Elf64_Sxword delta = value - (Elf64_Xword) addr; if (delta << 6 >> 6 != delta) return grub_error (GRUB_ERR_BAD_MODULE, "Relocation overflow"); @@ -115,7 +115,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t } case R_PPC_ADDR16_HA: - *(Elf32_Half *) addr = (value + 0x8000) >> 16; + *(Elf64_Half *) addr = (value + 0x8000) >> 16; break; case R_PPC_ADDR32: @@ -123,7 +123,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t break; case R_PPC_REL32: - *addr = value - (Elf32_Word) addr; + *addr = value - (Elf64_Xword) addr; break; default: diff -rupN powerpc/ieee1275/init.c sparc64/ieee1275/init.c --- powerpc/ieee1275/init.c 2005-06-21 04:33:51.000000000 +0200 +++ sparc64/ieee1275/init.c 2005-07-12 20:27:15.000000000 +0200 @@ -35,16 +35,14 @@ #include <grub/machine/ofdisk.h> /* Apple OF 1.0.5 reserves 0x0 to 0x4000 for the exception handlers. */ -static const grub_addr_t grub_heap_start = 0x4000; +static const grub_addr_t grub_heap_start = 0x40000; static grub_addr_t grub_heap_len; void abort (void) { /* Trap to Open Firmware. */ - asm ("trap"); - - for (;;); + grub_ieee1275_enter (); } /* Translate an OF filesystem path (separated by backslashes), into a GRUB @@ -69,7 +67,7 @@ grub_set_prefix (void) char *filename; char *prefix; - if (grub_ieee1275_get_property (grub_ieee1275_chosen, "bootpath", &bootpath, + if (grub_ieee1275_get_property (grub_ieee1275_chosen, "bootpath", bootpath, sizeof (bootpath), 0)) { /* Should never happen. */ @@ -111,9 +109,8 @@ grub_set_prefix (void) void grub_machine_init (void) { - char args[256]; - grub_ieee1275_phandle_t chosen; - int actual; + char *args; + grub_ssize_t length; extern char _start; grub_console_init (); @@ -123,11 +120,8 @@ grub_machine_init (void) grub_heap_len = (grub_addr_t) &_start - 0x1000 - grub_heap_start; if (grub_ieee1275_claim (grub_heap_start, grub_heap_len, 0, 0)) - { - grub_printf ("Failed to claim heap at 0x%x, len 0x%x\n", grub_heap_start, + grub_fatal ("Failed to claim heap at %p, len 0x%x\n", grub_heap_start, grub_heap_len); - abort (); - } grub_mm_init_region ((void *) grub_heap_start, grub_heap_len); grub_set_prefix (); @@ -135,14 +129,17 @@ grub_machine_init (void) grub_ofdisk_init (); /* Process commandline. */ - grub_ieee1275_finddevice ("/chosen", &chosen); - if (grub_ieee1275_get_property (chosen, "bootargs", &args, - sizeof args, &actual) == 0 - && actual > 1) + if (grub_ieee1275_get_property_length (grub_ieee1275_chosen, "bootargs", + &length) == 0 && + length > 0) { - int i = 0; + grub_ssize_t i = 0; - while (i < actual) + args = grub_malloc (length); + grub_ieee1275_get_property (grub_ieee1275_chosen, "bootargs", args, + length, 0); + + while (i < length) { char *command = &args[i]; char *end; @@ -150,7 +147,7 @@ grub_machine_init (void) end = grub_strchr (command, ';'); if (end == 0) - i = actual; /* No more commands after this one. */ + i = length; /* No more commands after this one. */ else { *end = '\0'; @@ -168,6 +165,7 @@ grub_machine_init (void) } } } + } void @@ -180,13 +178,13 @@ grub_machine_fini (void) void grub_stop (void) { - for (;;); + grub_ieee1275_exit (); } -grub_uint32_t +grub_uintn_t grub_get_rtc (void) { - grub_uint32_t msecs; + grub_intn_t msecs; if (grub_ieee1275_milliseconds (&msecs)) return 0; diff -rupN powerpc/ieee1275/openfw.c sparc64/ieee1275/openfw.c --- powerpc/ieee1275/openfw.c 2005-06-21 04:33:51.000000000 +0200 +++ sparc64/ieee1275/openfw.c 2005-07-12 20:40:04.000000000 +0200 @@ -53,9 +53,9 @@ grub_children_iterate (char *devpath, char childname[64]; char fullname[64]; struct grub_ieee1275_devalias alias; - int actual; + grub_ssize_t actual; - grub_ieee1275_get_property (child, "device_type", &childtype, + grub_ieee1275_get_property (child, "device_type", childtype, sizeof childtype, &actual); if (actual == -1) continue; @@ -65,7 +65,7 @@ grub_children_iterate (char *devpath, if (actual == -1) continue; - grub_ieee1275_get_property (child, "name", &childname, + grub_ieee1275_get_property (child, "name", childname, sizeof childname, &actual); if (actual == -1) continue; @@ -89,31 +89,29 @@ grub_devalias_iterate (int (*hook) (stru { grub_ieee1275_phandle_t devalias; char aliasname[32]; - int actual; + grub_ssize_t actual; + grub_intn_t flag; struct grub_ieee1275_devalias alias; if (grub_ieee1275_finddevice ("/aliases", &devalias)) return -1; - /* XXX: Is this the right way to find the first property? */ aliasname[0] = '\0'; - /* XXX: Are the while conditions correct? */ - while (grub_ieee1275_next_property (devalias, aliasname, aliasname, &actual) - || actual) + while (grub_ieee1275_next_property (devalias, aliasname, aliasname, &flag) != -1 + && flag != -1 ) { grub_ieee1275_phandle_t dev; - grub_size_t pathlen; - char *devpath; - /* XXX: This should be large enough for any possible case. */ - char devtype[64]; - - grub_ieee1275_get_property_length (devalias, aliasname, &pathlen); + grub_ssize_t pathlen, typelen; + char *devpath, *devtype; + grub_dprintf ("devalias", "devalias name = %s\n", aliasname); + /* The property `name' is a special case we should skip. */ if (!grub_strcmp (aliasname, "name")) continue; + grub_ieee1275_get_property_length (devalias, aliasname, &pathlen); devpath = grub_malloc (pathlen); if (! devpath) return grub_errno; @@ -121,19 +119,29 @@ grub_devalias_iterate (int (*hook) (stru if (grub_ieee1275_get_property (devalias, aliasname, devpath, pathlen, &actual)) { + grub_dprintf ("devalias", "get_property (%s) failed\n", aliasname); grub_free (devpath); continue; } if (grub_ieee1275_finddevice (devpath, &dev) || dev == -1) { + grub_dprintf ("devalias", "finddevice (%s) failed\n", devpath); grub_free (devpath); continue; } - if (grub_ieee1275_get_property (dev, "device_type", devtype, sizeof devtype, - &actual)) + grub_ieee1275_get_property_length (dev, "device_type", &typelen); + devtype = grub_malloc (typelen); + if (! devtype) + { + grub_free (devpath); + return grub_errno; + } + if (grub_ieee1275_get_property (dev, "device_type", devtype, typelen, &actual)) { + grub_dprintf ("devalias", "get device type failed\n"); + grub_free (devtype); grub_free (devpath); continue; } @@ -141,14 +149,21 @@ grub_devalias_iterate (int (*hook) (stru alias.name = aliasname; alias.path= devpath; alias.type = devtype; - hook (&alias); - + if((*hook) (&alias)) + { + grub_free (devtype); + grub_free (devpath); + break; + } + + grub_free (devtype); grub_free (devpath); } return 0; } +#if 0 /* Call the "map" method of /chosen/mmu. */ static int grub_map (grub_addr_t phys, grub_addr_t virt, grub_uint32_t size, @@ -165,7 +180,7 @@ grub_map (grub_addr_t phys, grub_addr_t int catch_result; } args; grub_ieee1275_ihandle_t mmu; - int len; + grub_ssize_t len; grub_ieee1275_get_property (grub_ieee1275_chosen, "mmu", &mmu, sizeof mmu, &len); @@ -185,21 +200,13 @@ grub_map (grub_addr_t phys, grub_addr_t return args.catch_result; } +#endif int grub_claimmap (grub_addr_t addr, grub_size_t size) { if (grub_ieee1275_claim (addr, size, 0, 0)) return -1; - - if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_REAL_MODE) - && grub_map (addr, addr, size, 0x00)) - { - grub_printf ("map failed: address 0x%x, size 0x%x\n", addr, size); - grub_ieee1275_release (addr, size); - return -1; - } - return 0; } @@ -268,7 +275,7 @@ grub_ieee1275_parse_args (const char *pa grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Device %s not found\n", device); goto fail; } - if (grub_ieee1275_get_property (dev, "device_type", &type, sizeof type, 0)) + if (grub_ieee1275_get_property (dev, "device_type", type, sizeof type, 0)) { grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Device %s lacks a device_type property\n", device); @@ -336,10 +343,6 @@ grub_ieee1275_encode_devname (const char { unsigned int partno = grub_strtoul (partition, 0, 0); - /* GRUB partition numbering is 0-based. */ - if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_0_BASED_PARTITIONS)) - partno--; - /* Assume partno will require less than five bytes to encode. */ encoding = grub_malloc (grub_strlen (device) + 3 + 5); grub_sprintf (encoding, "(%s,%d)", device, partno); @@ -365,5 +368,5 @@ grub_reboot (void) void grub_halt (void) { - grub_ieee1275_interpret ("shut-down", 0); + grub_ieee1275_interpret ("power-off", 0); } [-- Attachment #6: ppc_usp_normal.f.diff --] [-- Type: text/plain, Size: 3180 bytes --] diff -rupN powerpc/setjmp.c sparc64/setjmp.c --- powerpc/setjmp.c 1970-01-01 01:00:00.000000000 +0100 +++ sparc64/setjmp.c 2005-07-12 19:14:58.000000000 +0200 @@ -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; +} + diff -rupN powerpc/setjmp.S sparc64/setjmp.S --- powerpc/setjmp.S 2004-11-17 00:34:45.000000000 +0100 +++ sparc64/setjmp.S 1970-01-01 01:00:00.000000000 +0100 @@ -1,85 +0,0 @@ -/* - * 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. - */ - -#include <grub/symbol.h> - - .file "setjmp.S" - - .text - -/* - * int grub_setjmp (grub_jmp_buf env) - */ -FUNCTION(grub_setjmp) - stw 1, 0(3) - stw 14, 4(3) - stw 15, 8(3) - stw 16, 12(3) - stw 17, 16(3) - stw 18, 20(3) - stw 19, 24(3) - stw 20, 28(3) - stw 21, 32(3) - stw 22, 36(3) - stw 23, 40(3) - stw 24, 44(3) - stw 25, 48(3) - stw 26, 52(3) - stw 27, 56(3) - stw 28, 60(3) - stw 29, 64(3) - stw 30, 68(3) - mflr 4 - stw 4, 72(3) - mfcr 4 - stw 4, 76(3) - li 3, 0 - blr - -/* - * int grub_longjmp (grub_jmp_buf env, int val) - */ -FUNCTION(grub_longjmp) - lwz 1, 0(3) - lwz 14, 4(3) - lwz 15, 8(3) - lwz 16, 12(3) - lwz 17, 16(3) - lwz 18, 20(3) - lwz 19, 24(3) - lwz 20, 28(3) - lwz 21, 32(3) - lwz 22, 36(3) - lwz 23, 40(3) - lwz 24, 44(3) - lwz 25, 48(3) - lwz 26, 52(3) - lwz 27, 56(3) - lwz 28, 60(3) - lwz 29, 64(3) - lwz 30, 68(3) - lwz 5, 72(3) - mtlr 5 - lwz 5, 76(3) - mtcr 5 - mr. 3, 4 - bne 1f - li 3, 1 -1: blr - [-- Attachment #7: ppc_usp_term.f.diff --] [-- Type: text/plain, Size: 868 bytes --] diff -rupN powerpc/ieee1275/ofconsole.c sparc64/ieee1275/ofconsole.c --- powerpc/ieee1275/ofconsole.c 2005-06-21 04:33:52.000000000 +0200 +++ sparc64/ieee1275/ofconsole.c 2005-07-12 19:14:58.000000000 +0200 @@ -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, [-- Attachment #8: ppc_usp_util.f.diff --] [-- Type: text/plain, Size: 8531 bytes --] diff -rupN powerpc/ieee1275/grub-mkimage.c sparc64/ieee1275/grub-mkimage.c --- powerpc/ieee1275/grub-mkimage.c 2005-07-03 11:34:45.000000000 +0200 +++ sparc64/ieee1275/grub-mkimage.c 2005-07-12 19:14:58.000000000 +0200 @@ -34,7 +34,7 @@ static char *kernel_path = "grubof"; -#define GRUB_IEEE1275_NOTE_NAME "PowerPC" +#define GRUB_IEEE1275_NOTE_NAME "Sparc64" #define GRUB_IEEE1275_NOTE_TYPE 0x1275 /* These structures are defined according to the CHRP binding to IEEE1275, @@ -42,20 +42,20 @@ static char *kernel_path = "grubof"; struct grub_ieee1275_note_hdr { - grub_uint32_t namesz; - grub_uint32_t descsz; - grub_uint32_t type; + grub_uint64_t namesz; + grub_uint64_t descsz; + grub_uint64_t type; char name[sizeof (GRUB_IEEE1275_NOTE_NAME)]; }; struct grub_ieee1275_note_desc { - grub_uint32_t real_mode; - grub_uint32_t real_base; - grub_uint32_t real_size; - grub_uint32_t virt_base; - grub_uint32_t virt_size; - grub_uint32_t load_base; + grub_uint64_t real_mode; + grub_uint64_t real_base; + grub_uint64_t real_size; + grub_uint64_t virt_base; + grub_uint64_t virt_size; + grub_uint64_t load_base; }; struct grub_ieee1275_note @@ -65,40 +65,40 @@ struct grub_ieee1275_note }; void -load_note (Elf32_Phdr *phdr, FILE *out) +load_note (Elf64_Phdr *phdr, FILE *out) { struct grub_ieee1275_note note; int note_size = sizeof (struct grub_ieee1275_note); grub_util_info ("adding CHRP NOTE segment"); - note.header.namesz = grub_cpu_to_be32 (sizeof (GRUB_IEEE1275_NOTE_NAME)); - note.header.descsz = grub_cpu_to_be32 (note_size); - note.header.type = grub_cpu_to_be32 (GRUB_IEEE1275_NOTE_TYPE); + note.header.namesz = grub_cpu_to_be64 (sizeof (GRUB_IEEE1275_NOTE_NAME)); + note.header.descsz = grub_cpu_to_be64 (note_size); + note.header.type = grub_cpu_to_be64 (GRUB_IEEE1275_NOTE_TYPE); strcpy (note.header.name, GRUB_IEEE1275_NOTE_NAME); - note.descriptor.real_mode = grub_cpu_to_be32 (0xffffffff); - note.descriptor.real_base = grub_cpu_to_be32 (0x00c00000); - note.descriptor.real_size = grub_cpu_to_be32 (0xffffffff); - note.descriptor.virt_base = grub_cpu_to_be32 (0xffffffff); - note.descriptor.virt_size = grub_cpu_to_be32 (0xffffffff); - note.descriptor.load_base = grub_cpu_to_be32 (0x00004000); + note.descriptor.real_mode = grub_cpu_to_be64 (0xffffffff); + note.descriptor.real_base = grub_cpu_to_be64 (0x00c00000); + note.descriptor.real_size = grub_cpu_to_be64 (0xffffffff); + note.descriptor.virt_base = grub_cpu_to_be64 (0xffffffff); + note.descriptor.virt_size = grub_cpu_to_be64 (0xffffffff); + note.descriptor.load_base = grub_cpu_to_be64 (0x00004000); /* Write the note data to the new segment. */ grub_util_write_image_at (¬e, note_size, - grub_be_to_cpu32 (phdr->p_offset), out); + grub_be_to_cpu64 (phdr->p_offset), out); /* Fill in the rest of the segment header. */ - phdr->p_type = grub_cpu_to_be32 (PT_NOTE); - phdr->p_flags = grub_cpu_to_be32 (PF_R); - phdr->p_align = grub_cpu_to_be32 (sizeof (long)); + phdr->p_type = grub_cpu_to_be64 (PT_NOTE); + phdr->p_flags = grub_cpu_to_be64 (PF_R); + phdr->p_align = grub_cpu_to_be64 (sizeof (long)); phdr->p_vaddr = 0; phdr->p_paddr = 0; - phdr->p_filesz = grub_cpu_to_be32 (note_size); + phdr->p_filesz = grub_cpu_to_be64 (note_size); phdr->p_memsz = 0; } void -load_modules (Elf32_Phdr *phdr, const char *dir, char *mods[], FILE *out) +load_modules (Elf64_Phdr *phdr, const char *dir, char *mods[], FILE *out) { char *module_img; struct grub_util_path_list *path_list; @@ -121,9 +121,9 @@ load_modules (Elf32_Phdr *phdr, const ch module_img = xmalloc (total_module_size); modinfo = (struct grub_module_info *) module_img; - modinfo->magic = grub_cpu_to_be32 (GRUB_MODULE_MAGIC); - modinfo->offset = grub_cpu_to_be32 (sizeof (struct grub_module_info)); - modinfo->size = grub_cpu_to_be32 (total_module_size); + modinfo->magic = grub_cpu_to_be64 (GRUB_MODULE_MAGIC); + modinfo->offset = grub_cpu_to_be64 (sizeof (struct grub_module_info)); + modinfo->size = grub_cpu_to_be64 (total_module_size); /* Load all the modules, with headers, into module_img. */ for (p = path_list; p; p = p->next) @@ -136,8 +136,8 @@ load_modules (Elf32_Phdr *phdr, const ch mod_size = grub_util_get_image_size (p->name); header = (struct grub_module_header *) (module_img + offset); - header->offset = grub_cpu_to_be32 (sizeof (*header)); - header->size = grub_cpu_to_be32 (mod_size + sizeof (*header)); + header->offset = grub_cpu_to_be64 (sizeof (*header)); + header->size = grub_cpu_to_be64 (mod_size + sizeof (*header)); grub_util_load_image (p->name, module_img + offset + sizeof (*header)); @@ -146,24 +146,24 @@ load_modules (Elf32_Phdr *phdr, const ch /* Write the module data to the new segment. */ grub_util_write_image_at (module_img, total_module_size, - grub_cpu_to_be32 (phdr->p_offset), out); + grub_cpu_to_be64 (phdr->p_offset), out); /* Fill in the rest of the segment header. */ - phdr->p_type = grub_cpu_to_be32 (PT_LOAD); - phdr->p_flags = grub_cpu_to_be32 (PF_R | PF_W | PF_X); - phdr->p_align = grub_cpu_to_be32 (sizeof (long)); - phdr->p_vaddr = grub_cpu_to_be32 (GRUB_IEEE1275_MODULE_BASE); - phdr->p_paddr = grub_cpu_to_be32 (GRUB_IEEE1275_MODULE_BASE); - phdr->p_filesz = grub_cpu_to_be32 (total_module_size); - phdr->p_memsz = grub_cpu_to_be32 (total_module_size); + phdr->p_type = grub_cpu_to_be64 (PT_LOAD); + phdr->p_flags = grub_cpu_to_be64 (PF_R | PF_W | PF_X); + phdr->p_align = grub_cpu_to_be64 (sizeof (long)); + phdr->p_vaddr = grub_cpu_to_be64 (GRUB_IEEE1275_MODULE_BASE); + phdr->p_paddr = grub_cpu_to_be64 (GRUB_IEEE1275_MODULE_BASE); + phdr->p_filesz = grub_cpu_to_be64 (total_module_size); + phdr->p_memsz = grub_cpu_to_be64 (total_module_size); } void add_segments (char *dir, FILE *out, int chrp, char *mods[]) { - Elf32_Ehdr ehdr; - Elf32_Phdr *phdrs = NULL; - Elf32_Phdr *phdr; + Elf64_Ehdr ehdr; + Elf64_Phdr *phdrs = NULL; + Elf64_Phdr *phdr; FILE *in; off_t phdroff; int i; @@ -185,20 +185,20 @@ add_segments (char *dir, FILE *out, int phdr = phdrs + i; /* Read segment header. */ - grub_util_read_at (phdr, sizeof (Elf32_Phdr), - (grub_be_to_cpu32 (ehdr.e_phoff) + grub_util_read_at (phdr, sizeof (Elf64_Phdr), + (grub_be_to_cpu64 (ehdr.e_phoff) + (i * grub_be_to_cpu16 (ehdr.e_phentsize))), in); grub_util_info ("copying segment %d, type %d", i, - grub_be_to_cpu32 (phdr->p_type)); + grub_be_to_cpu64 (phdr->p_type)); /* Read segment data and write it to new file. */ - segment_img = xmalloc (grub_be_to_cpu32 (phdr->p_filesz)); + segment_img = xmalloc (grub_be_to_cpu64 (phdr->p_filesz)); - grub_util_read_at (segment_img, grub_be_to_cpu32 (phdr->p_filesz), - grub_be_to_cpu32 (phdr->p_offset), in); - grub_util_write_image_at (segment_img, grub_be_to_cpu32 (phdr->p_filesz), - grub_be_to_cpu32 (phdr->p_offset), out); + grub_util_read_at (segment_img, grub_be_to_cpu64 (phdr->p_filesz), + grub_be_to_cpu64 (phdr->p_offset), in); + grub_util_write_image_at (segment_img, grub_be_to_cpu64 (phdr->p_filesz), + grub_be_to_cpu64 (phdr->p_offset), out); free (segment_img); } @@ -210,7 +210,7 @@ add_segments (char *dir, FILE *out, int ehdr.e_phnum = grub_cpu_to_be16 (grub_be_to_cpu16 (ehdr.e_phnum) + 1); /* Fill in p_offset so the callees know where to write. */ - phdr->p_offset = grub_cpu_to_be32 (ALIGN_UP (grub_util_get_fp_size (out), + phdr->p_offset = grub_cpu_to_be64 (ALIGN_UP (grub_util_get_fp_size (out), sizeof (long))); load_modules (phdr, dir, mods, out); @@ -223,7 +223,7 @@ add_segments (char *dir, FILE *out, int ehdr.e_phnum = grub_cpu_to_be16 (grub_be_to_cpu16 (ehdr.e_phnum) + 1); /* Fill in p_offset so the callees know where to write. */ - phdr->p_offset = grub_cpu_to_be32 (ALIGN_UP (grub_util_get_fp_size (out), + phdr->p_offset = grub_cpu_to_be64 (ALIGN_UP (grub_util_get_fp_size (out), sizeof (long))); load_note (phdr, out); @@ -241,7 +241,7 @@ add_segments (char *dir, FILE *out, int out); /* Write ELF header. */ - ehdr.e_phoff = grub_cpu_to_be32 (phdroff); + ehdr.e_phoff = grub_cpu_to_be64 (phdroff); grub_util_write_image_at (&ehdr, sizeof (ehdr), 0, out); free (phdrs); ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: sparc64 port : diffs to powerpc branches 2005-07-12 18:46 ` sparc64 port : diffs to powerpc branches Vincent Pelletier @ 2005-07-12 19:40 ` Marco Gerards 2005-07-12 20:49 ` Vincent Pelletier 2005-07-12 22:17 ` Hollis Blanchard 2005-07-13 1:01 ` common ieee1275 code Hollis Blanchard 2 siblings, 1 reply; 29+ messages in thread From: Marco Gerards @ 2005-07-12 19:40 UTC (permalink / raw) To: The development of GRUB 2 Vincent Pelletier <subdino2004@yahoo.fr> writes: Hi Vincent, > Here are the diffs powerpc -> usparc, with some comments below. > To be used to know which files can be made common. Nice! > All the ieee1275 functions use the grub_intn_t type (see includes). So this can be shared. > 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. > 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? > 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. > 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? > Changed some suspicious "&string" to just "string". hm? > Added malloc calls when size can be known. Nice! > Removed "XXX" when documentation answers. Nice! > 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. > Remove ppc specific partition numbering thing. Can you explain this? > normal: > New dummy function (no asm). When you implement this, you can support switching from normal to rescue mode and back properly. > term: > Type changes. > Added an environment variable to disable cls (useful to see early messages). Ok. > 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 ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: sparc64 port : diffs to powerpc branches 2005-07-12 19:40 ` Marco Gerards @ 2005-07-12 20:49 ` Vincent Pelletier 2005-07-13 15:59 ` Marco Gerards 0 siblings, 1 reply; 29+ messages in thread From: Vincent Pelletier @ 2005-07-12 20:49 UTC (permalink / raw) To: The development of GRUB 2 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain; charset=us-ascii, Size: 2472 bytes --] -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Marco Gerards wrote: > 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. > 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.) >>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 :) ). >>Added malloc calls when size can be known. > Nice! More can be done, I haven't done it everywhere. > 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 :) ). >>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). > 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. > grub-mkimage is used to add modules to grubof. So this works, sun partition label & ext2 is read. > 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 ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: sparc64 port : diffs to powerpc branches 2005-07-12 20:49 ` Vincent Pelletier @ 2005-07-13 15:59 ` Marco Gerards 2005-07-13 20:40 ` Vincent Pelletier 0 siblings, 1 reply; 29+ messages in thread From: Marco Gerards @ 2005-07-13 15:59 UTC (permalink / raw) To: The development of GRUB 2 Vincent Pelletier <subdino2004@yahoo.fr> writes: > Marco Gerards wrote: >> 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. >> 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. >>>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. >>>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. >> 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. :) >>>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. >> 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? >> 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... >> 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 ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: sparc64 port : diffs to powerpc branches 2005-07-13 15:59 ` Marco Gerards @ 2005-07-13 20:40 ` Vincent Pelletier 2005-07-13 21:27 ` Marco Gerards 0 siblings, 1 reply; 29+ messages in thread From: Vincent Pelletier @ 2005-07-13 20:40 UTC (permalink / raw) To: The development of GRUB 2 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain; charset=us-ascii, Size: 1566 bytes --] -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Marco Gerards wrote: > 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. > 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... > 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. > 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 ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: sparc64 port : diffs to powerpc branches 2005-07-13 20:40 ` Vincent Pelletier @ 2005-07-13 21:27 ` Marco Gerards 0 siblings, 0 replies; 29+ messages in thread From: Marco Gerards @ 2005-07-13 21:27 UTC (permalink / raw) To: The development of GRUB 2 Vincent Pelletier <subdino2004@yahoo.fr> writes: >> 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. >> 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 ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: sparc64 port : diffs to powerpc branches 2005-07-12 18:46 ` sparc64 port : diffs to powerpc branches Vincent Pelletier 2005-07-12 19:40 ` Marco Gerards @ 2005-07-12 22:17 ` Hollis Blanchard 2005-07-13 1:01 ` common ieee1275 code Hollis Blanchard 2 siblings, 0 replies; 29+ messages in thread From: Hollis Blanchard @ 2005-07-12 22:17 UTC (permalink / raw) To: The development of GRUB 2 On Jul 12, 2005, at 1:46 PM, Vincent Pelletier wrote: > 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. > boot: > cmain renamed in _start (no asm). Sparc will need to provide its own cmain.c and init.c; these files cannot be shared. > Special ppc options removed. > All the ieee1275 functions use the grub_intn_t type (see includes). > Add explicit casts where needed. --- powerpc/ieee1275/ieee1275.c 2005-06-21 04:33:51.000000000 +0200 +++ sparc64/ieee1275/ieee1275.c 2005-07-12 20:05:49.000000000 +0200 @@ -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. > 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). > 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. > 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 ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: common ieee1275 code 2005-07-12 18:46 ` sparc64 port : diffs to powerpc branches Vincent Pelletier 2005-07-12 19:40 ` Marco Gerards 2005-07-12 22:17 ` Hollis Blanchard @ 2005-07-13 1:01 ` Hollis Blanchard 2005-07-13 16:13 ` Marco Gerards 2 siblings, 1 reply; 29+ messages in thread From: Hollis Blanchard @ 2005-07-13 1:01 UTC (permalink / raw) To: The development of GRUB 2 [-- Attachment #1: Type: text/plain, Size: 1188 bytes --] 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 [-- Attachment #2: grub-ieee1275.diff --] [-- Type: application/octet-stream, Size: 97766 bytes --] Index: boot/powerpc/ieee1275/cmain.c =================================================================== RCS file: /cvsroot/grub/grub2/boot/powerpc/ieee1275/cmain.c,v retrieving revision 1.10 diff -u -p -r1.10 cmain.c --- boot/powerpc/ieee1275/cmain.c 21 Jun 2005 03:12:15 -0000 1.10 +++ boot/powerpc/ieee1275/cmain.c 13 Jul 2005 00:45:08 -0000 @@ -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 diff -u -p -r1.12 ieee1275.c --- boot/powerpc/ieee1275/ieee1275.c 21 Jun 2005 02:33:51 -0000 1.12 +++ boot/powerpc/ieee1275/ieee1275.c 13 Jul 2005 00:45:09 -0000 @@ -18,13 +18,12 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <grub/machine/ieee1275.h> - +#include <grub/ieee1275/ieee1275.h> #define IEEE1275_PHANDLE_ROOT ((grub_ieee1275_phandle_t) 0) #define IEEE1275_PHANDLE_INVALID ((grub_ieee1275_phandle_t) -1) -intptr_t (*grub_ieee1275_entry_fn) (void *); +\f /* FIXME is this function needed? */ grub_uint32_t @@ -36,18 +35,17 @@ grub_ieee1275_decode_int_4 (unsigned cha return (val + *p); } -\f int grub_ieee1275_finddevice (char *name, grub_ieee1275_phandle_t *phandlep) { struct find_device_args { struct grub_ieee1275_common_hdr common; - char *device; + grub_ieee1275_cell_t device; grub_ieee1275_phandle_t phandle; } args; INIT_IEEE1275_COMMON (&args.common, "finddevice", 1, 1); - args.device = name; + args.device = (grub_ieee1275_cell_t) name; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; @@ -58,49 +56,49 @@ grub_ieee1275_finddevice (char *name, gr int grub_ieee1275_get_property (grub_ieee1275_phandle_t phandle, const char *property, void *buf, - grub_size_t size, grub_size_t *actual) + grub_size_t size, grub_ssize_t *actual) { struct get_property_args { struct grub_ieee1275_common_hdr common; grub_ieee1275_phandle_t phandle; - const char *prop; - void *buf; - int buflen; - int size; + grub_ieee1275_cell_t prop; + grub_ieee1275_cell_t buf; + grub_ieee1275_cell_t buflen; + grub_ieee1275_cell_t size; } args; INIT_IEEE1275_COMMON (&args.common, "getprop", 4, 1); args.phandle = phandle; - args.prop = property; - args.buf = buf; - args.buflen = size; + args.prop = (grub_ieee1275_cell_t) property; + args.buf = (grub_ieee1275_cell_t) buf; + args.buflen = (grub_ieee1275_cell_t) size; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; if (actual) - *actual = args.size; - if (args.size == -1) + *actual = (grub_ssize_t) args.size; + if (args.size == (grub_ieee1275_cell_t) -1) return -1; return 0; } int grub_ieee1275_next_property (grub_ieee1275_phandle_t phandle, char *prev_prop, - char *prop, int *flags) + char *prop, grub_ieee1275_cell_t *flags) { struct get_property_args { struct grub_ieee1275_common_hdr common; grub_ieee1275_phandle_t phandle; - char *prev_prop; - char *next_prop; - int flags; + grub_ieee1275_cell_t prev_prop; + grub_ieee1275_cell_t next_prop; + grub_ieee1275_cell_t flags; } args; INIT_IEEE1275_COMMON (&args.common, "nextprop", 3, 1); args.phandle = phandle; - args.prev_prop = prev_prop; - args.next_prop = prop; - args.flags = -1; + args.prev_prop = (grub_ieee1275_cell_t) prev_prop; + args.next_prop = (grub_ieee1275_cell_t) prop; + args.flags = (grub_ieee1275_cell_t) -1; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; @@ -111,19 +109,19 @@ grub_ieee1275_next_property (grub_ieee12 int grub_ieee1275_get_property_length (grub_ieee1275_phandle_t phandle, - const char *prop, grub_size_t *length) + const char *prop, grub_ssize_t *length) { struct get_property_args { struct grub_ieee1275_common_hdr common; grub_ieee1275_phandle_t phandle; - const char *prop; - grub_size_t length; + grub_ieee1275_cell_t prop; + grub_ieee1275_cell_t length; } args; INIT_IEEE1275_COMMON (&args.common, "getproplen", 2, 1); args.phandle = phandle; - args.prop = prop; - args.length = -1; + args.prop = (grub_ieee1275_cell_t) prop; + args.length = (grub_ieee1275_cell_t) -1; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; @@ -152,20 +150,20 @@ grub_ieee1275_instance_to_package (grub_ int grub_ieee1275_package_to_path (grub_ieee1275_phandle_t phandle, - char *path, grub_size_t len, grub_size_t *actual) + char *path, grub_size_t len, grub_ssize_t *actual) { struct instance_to_package_args { struct grub_ieee1275_common_hdr common; grub_ieee1275_phandle_t phandle; - char *buf; - int buflen; - int actual; + grub_ieee1275_cell_t buf; + grub_ieee1275_cell_t buflen; + grub_ieee1275_cell_t actual; } args; INIT_IEEE1275_COMMON (&args.common, "package-to-path", 3, 1); args.phandle = phandle; - args.buf = path; - args.buflen = len; + args.buf = (grub_ieee1275_cell_t) path; + args.buflen = (grub_ieee1275_cell_t) len; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; @@ -177,20 +175,20 @@ grub_ieee1275_package_to_path (grub_ieee int grub_ieee1275_instance_to_path (grub_ieee1275_ihandle_t ihandle, char *path, grub_size_t len, - grub_size_t *actual) + grub_ssize_t *actual) { struct instance_to_package_args { struct grub_ieee1275_common_hdr common; grub_ieee1275_ihandle_t ihandle; - char *buf; - int buflen; - int actual; + grub_ieee1275_cell_t buf; + grub_ieee1275_cell_t buflen; + grub_ieee1275_cell_t actual; } args; INIT_IEEE1275_COMMON (&args.common, "instance-to-path", 3, 1); args.ihandle = ihandle; - args.buf = path; - args.buflen = len; + args.buf = (grub_ieee1275_cell_t) path; + args.buflen = (grub_ieee1275_cell_t) len; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; @@ -201,20 +199,20 @@ grub_ieee1275_instance_to_path (grub_iee int grub_ieee1275_write (grub_ieee1275_ihandle_t ihandle, void *buffer, - grub_size_t len, grub_size_t *actualp) + grub_size_t len, grub_ssize_t *actualp) { struct write_args { struct grub_ieee1275_common_hdr common; grub_ieee1275_ihandle_t ihandle; - void *buf; - grub_size_t len; - grub_size_t actual; + grub_ieee1275_cell_t buf; + grub_ieee1275_cell_t len; + grub_ieee1275_cell_t actual; } args; INIT_IEEE1275_COMMON (&args.common, "write", 3, 1); args.ihandle = ihandle; - args.buf = buffer; - args.len = len; + args.buf = (grub_ieee1275_cell_t) buffer; + args.len = (grub_ieee1275_cell_t) len; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; @@ -225,20 +223,20 @@ grub_ieee1275_write (grub_ieee1275_ihand int grub_ieee1275_read (grub_ieee1275_ihandle_t ihandle, void *buffer, - grub_size_t len, grub_size_t *actualp) + grub_size_t len, grub_ssize_t *actualp) { struct write_args { struct grub_ieee1275_common_hdr common; grub_ieee1275_ihandle_t ihandle; - void *buf; - grub_size_t len; - grub_size_t actual; + grub_ieee1275_cell_t buf; + grub_ieee1275_cell_t len; + grub_ieee1275_cell_t actual; } args; INIT_IEEE1275_COMMON (&args.common, "read", 3, 1); args.ihandle = ihandle; - args.buf = buffer; - args.len = len; + args.buf = (grub_ieee1275_cell_t) buffer; + args.len = (grub_ieee1275_cell_t) len; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; @@ -249,20 +247,20 @@ grub_ieee1275_read (grub_ieee1275_ihandl int grub_ieee1275_seek (grub_ieee1275_ihandle_t ihandle, int pos_hi, - int pos_lo, int *result) + int pos_lo, grub_ssize_t *result) { struct write_args { struct grub_ieee1275_common_hdr common; grub_ieee1275_ihandle_t ihandle; - int pos_hi; - int pos_lo; - int result; + grub_ieee1275_cell_t pos_hi; + grub_ieee1275_cell_t pos_lo; + grub_ieee1275_cell_t result; } args; INIT_IEEE1275_COMMON (&args.common, "seek", 3, 1); args.ihandle = ihandle; - args.pos_hi = pos_hi; - args.pos_lo = pos_lo; + args.pos_hi = (grub_ieee1275_cell_t) pos_hi; + args.pos_lo = (grub_ieee1275_cell_t) pos_lo; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; @@ -332,16 +330,16 @@ grub_ieee1275_parent (grub_ieee1275_phan } int -grub_ieee1275_interpret (const char *command, int *catch) +grub_ieee1275_interpret (const char *command, grub_ieee1275_cell_t *catch) { struct enter_args { struct grub_ieee1275_common_hdr common; - const char *command; - int catch; + grub_ieee1275_cell_t command; + grub_ieee1275_cell_t catch; } args; INIT_IEEE1275_COMMON (&args.common, "interpret", 1, 1); - args.command = command; + args.command = (grub_ieee1275_cell_t) command; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; @@ -373,22 +371,21 @@ grub_ieee1275_exit (void) INIT_IEEE1275_COMMON (&args.common, "exit", 0, 0); - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - return 0; + IEEE1275_CALL_ENTRY_FN (&args); + for (;;) ; } int -grub_ieee1275_open (char *node, grub_ieee1275_ihandle_t *result) +grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result) { struct open_args { struct grub_ieee1275_common_hdr common; - char *cstr; + grub_ieee1275_cell_t path; grub_ieee1275_ihandle_t result; } args; INIT_IEEE1275_COMMON (&args.common, "open", 1, 1); - args.cstr = node; + args.path = (grub_ieee1275_cell_t) path; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; @@ -419,16 +416,16 @@ grub_ieee1275_claim (grub_addr_t addr, g { struct claim_args { struct grub_ieee1275_common_hdr common; - grub_addr_t addr; - grub_size_t size; - unsigned int align; - grub_addr_t base; + grub_ieee1275_cell_t addr; + grub_ieee1275_cell_t size; + grub_ieee1275_cell_t align; + grub_ieee1275_cell_t base; } args; INIT_IEEE1275_COMMON (&args.common, "claim", 3, 1); - args.addr = addr; - args.size = size; - args.align = align; + args.addr = (grub_ieee1275_cell_t) addr; + args.size = (grub_ieee1275_cell_t) size; + args.align = (grub_ieee1275_cell_t) align; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; @@ -436,7 +433,7 @@ grub_ieee1275_claim (grub_addr_t addr, g if (result) *result = args.base; - if (args.base == (grub_addr_t)-1) + if (args.base == (grub_ieee1275_cell_t)-1) return -1; return 0; @@ -447,8 +444,8 @@ grub_ieee1275_release (grub_addr_t addr, { struct release_args { struct grub_ieee1275_common_hdr common; - grub_addr_t addr; - grub_size_t size; + grub_ieee1275_cell_t addr; + grub_ieee1275_cell_t size; } args; INIT_IEEE1275_COMMON (&args.common, "release", 2, 0); @@ -464,22 +461,22 @@ grub_ieee1275_release (grub_addr_t addr, int grub_ieee1275_set_property (grub_ieee1275_phandle_t phandle, const char *propname, void *buf, - grub_size_t size, grub_size_t *actual) + grub_size_t size, grub_ssize_t *actual) { struct set_property_args { struct grub_ieee1275_common_hdr common; grub_ieee1275_phandle_t phandle; - const char *propname; - void *buf; - grub_size_t size; - grub_size_t actual; + grub_ieee1275_cell_t propname; + grub_ieee1275_cell_t buf; + grub_ieee1275_cell_t size; + grub_ieee1275_cell_t actual; } args; INIT_IEEE1275_COMMON (&args.common, "setprop", 4, 1); - args.size = size; - args.buf = buf; - args.propname = propname; - args.phandle = phandle; + args.size = (grub_ieee1275_cell_t) size; + args.buf = (grub_ieee1275_cell_t) buf; + args.propname = (grub_ieee1275_cell_t) propname; + args.phandle = (grub_ieee1275_cell_t) phandle; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; @@ -495,11 +492,11 @@ grub_ieee1275_set_color (grub_ieee1275_i struct grub_ieee1275_common_hdr common; char *method; grub_ieee1275_ihandle_t ihandle; - int index; - int b; - int g; - int r; - int result; + grub_ieee1275_cell_t index; + grub_ieee1275_cell_t b; + grub_ieee1275_cell_t g; + grub_ieee1275_cell_t r; + grub_ieee1275_cell_t result; } args; INIT_IEEE1275_COMMON (&args.common, "call-method", 6, 1); @@ -521,7 +518,7 @@ grub_ieee1275_milliseconds (grub_uint32_ { struct milliseconds_args { struct grub_ieee1275_common_hdr common; - grub_uint32_t msecs; + grub_ieee1275_cell_t msecs; } args; INIT_IEEE1275_COMMON (&args.common, "milliseconds", 0, 1); Index: commands/ieee1275/halt.c =================================================================== RCS file: /cvsroot/grub/grub2/commands/ieee1275/halt.c,v retrieving revision 1.2 diff -u -p -r1.2 halt.c --- commands/ieee1275/halt.c 26 Mar 2005 17:34:50 -0000 1.2 +++ commands/ieee1275/halt.c 13 Jul 2005 00:45:09 -0000 @@ -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 diff -u -p -r1.2 reboot.c --- commands/ieee1275/reboot.c 26 Mar 2005 17:34:50 -0000 1.2 +++ commands/ieee1275/reboot.c 13 Jul 2005 00:45:09 -0000 @@ -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 diff -u -p -r1.2 suspend.c --- commands/ieee1275/suspend.c 31 Jan 2005 21:28:34 -0000 1.2 +++ commands/ieee1275/suspend.c 13 Jul 2005 00:45:09 -0000 @@ -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 diff -u -p -r1.30 powerpc-ieee1275.rmk --- conf/powerpc-ieee1275.rmk 1 May 2005 03:45:35 -0000 1.30 +++ conf/powerpc-ieee1275.rmk 13 Jul 2005 00:45:11 -0000 @@ -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 diff -N disk/powerpc/ieee1275/ofdisk.c --- disk/powerpc/ieee1275/ofdisk.c 12 Jul 2005 22:36:43 -0000 1.10 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,182 +0,0 @@ -/* ofdisk.c - Open Firmware disk access. */ -/* - * 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. - */ - -#include <grub/misc.h> -#include <grub/disk.h> -#include <grub/mm.h> -#include <grub/machine/ieee1275.h> -#include <grub/machine/ofdisk.h> - -static int -grub_ofdisk_iterate (int (*hook) (const char *name)) -{ - auto int dev_iterate (struct grub_ieee1275_devalias *alias); - - int dev_iterate (struct grub_ieee1275_devalias *alias) - { - if (! grub_strcmp (alias->type, "block")) - hook (alias->name); - else if ((! grub_strcmp (alias->type, "scsi")) - || (! grub_strcmp (alias->type, "ide")) - || (! grub_strcmp (alias->type, "ata"))) - /* Search for block-type children of these bus controllers. */ - grub_children_iterate (alias->name, dev_iterate); - return 0; - } - - grub_devalias_iterate (dev_iterate); - return 0; -} - -static grub_err_t -grub_ofdisk_open (const char *name, grub_disk_t disk) -{ - grub_ieee1275_phandle_t dev; - grub_ieee1275_ihandle_t dev_ihandle = 0; - char *devpath; - /* XXX: This should be large enough for any possible case. */ - char prop[64]; - int 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_dprintf ("disk", "Opening `%s'.\n", devpath); - - grub_ieee1275_open (devpath, &dev_ihandle); - if (! dev_ihandle) - { - grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Can't open device"); - goto fail; - } - - grub_dprintf ("disk", "Opened `%s' as handle 0x%x.\n", devpath, dev_ihandle); - - if (grub_ieee1275_finddevice (devpath, &dev)) - { - grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Can't read device properties"); - goto fail; - } - - if (grub_ieee1275_get_property (dev, "device_type", prop, sizeof (prop), - &actual)) - { - grub_error (GRUB_ERR_BAD_DEVICE, "Can't read the device type"); - goto fail; - } - - if (grub_strcmp (prop, "block")) - { - grub_error (GRUB_ERR_BAD_DEVICE, "Not a block device"); - goto fail; - } - - /* XXX: There is no property to read the number of blocks. There - should be a property `#blocks', but it is not there. Perhaps it - is possible to use seek for this. */ - disk->total_sectors = 0xFFFFFFFFUL; - - /* XXX: Is it ok to use this? Perhaps it is better to use the path - or some property. */ - disk->id = dev; - - /* XXX: Read this, somehow. */ - disk->has_partitions = 1; - disk->data = (void *) dev_ihandle; - - fail: - if (grub_errno && dev_ihandle) - grub_ieee1275_close (dev_ihandle); - grub_free (devpath); - return grub_errno; -} - -static void -grub_ofdisk_close (grub_disk_t disk) -{ - grub_dprintf ("disk", "Closing handle 0x%x.\n", - (grub_ieee1275_ihandle_t) disk->data); - grub_ieee1275_close ((grub_ieee1275_ihandle_t) disk->data); -} - -static grub_err_t -grub_ofdisk_read (grub_disk_t disk, unsigned long sector, - unsigned long size, char *buf) -{ - int status; - int actual; - unsigned long long pos; - - grub_dprintf ("disk", - "Reading handle 0x%x: sector 0x%lx, size 0x%lx, buf %p.\n", - (grub_ieee1275_ihandle_t) disk->data, sector, size, buf); - - pos = (unsigned long long) sector * 512UL; - - grub_ieee1275_seek ((grub_ieee1275_ihandle_t) disk->data, (int) (pos >> 32), - (int) pos & 0xFFFFFFFFUL, &status); - if (status != 0) - return grub_error (GRUB_ERR_READ_ERROR, - "Seek error, can't seek block %d", sector); - grub_ieee1275_read ((grub_ieee1275_ihandle_t) disk->data, buf, - size * 512UL, &actual); - if (actual != actual) - return grub_error (GRUB_ERR_READ_ERROR, "Read error on block: %d", sector); - - return 0; -} - -static grub_err_t -grub_ofdisk_write (grub_disk_t disk __attribute ((unused)), - unsigned long sector __attribute ((unused)), - unsigned long size __attribute ((unused)), - const char *buf __attribute ((unused))) -{ - return GRUB_ERR_NOT_IMPLEMENTED_YET; -} - -static struct grub_disk_dev grub_ofdisk_dev = - { - .name = "ofdisk", - .id = GRUB_DISK_DEVICE_OFDISK_ID, - .iterate = grub_ofdisk_iterate, - .open = grub_ofdisk_open, - .close = grub_ofdisk_close, - .read = grub_ofdisk_read, - .write = grub_ofdisk_write, - .next = 0 - }; - -void -grub_ofdisk_init (void) -{ - grub_disk_dev_register (&grub_ofdisk_dev); -} - -void -grub_ofdisk_fini (void) -{ - grub_disk_dev_unregister (&grub_ofdisk_dev); -} Index: include/grub/i386/pc/console.h =================================================================== RCS file: include/grub/i386/pc/console.h diff -N include/grub/i386/pc/console.h --- include/grub/i386/pc/console.h 15 Feb 2005 00:07:01 -0000 1.5 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,59 +0,0 @@ -/* - * GRUB -- GRand Unified Bootloader - * Copyright (C) 2002,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_CONSOLE_MACHINE_HEADER -#define GRUB_CONSOLE_MACHINE_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 - -#ifndef ASM_FILE - -#include <grub/types.h> -#include <grub/symbol.h> - -/* These are global to share code between C and asm. */ -extern grub_uint8_t grub_console_cur_color; -void grub_console_real_putchar (int c); -int EXPORT_FUNC(grub_console_checkkey) (void); -int EXPORT_FUNC(grub_console_getkey) (void); -grub_uint16_t grub_console_getxy (void); -void grub_console_gotoxy (grub_uint8_t x, grub_uint8_t y); -void grub_console_cls (void); -void grub_console_setcursor (int on); - -/* Initialize the console system. */ -void grub_console_init (void); - -/* Finish the console system. */ -void grub_console_fini (void); - -#endif - -#endif /* ! GRUB_CONSOLE_MACHINE_HEADER */ Index: include/grub/powerpc/ieee1275/console.h =================================================================== RCS file: include/grub/powerpc/ieee1275/console.h diff -N include/grub/powerpc/ieee1275/console.h --- include/grub/powerpc/ieee1275/console.h 26 Mar 2005 17:34:50 -0000 1.3 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,59 +0,0 @@ -/* - * 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_MACHINE_HEADER -#define GRUB_CONSOLE_MACHINE_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 - -#ifndef ASM_FILE - -#include <grub/types.h> -#include <grub/symbol.h> - -/* These are global to share code between C and asm. */ -extern grub_uint8_t grub_console_cur_color; -void grub_console_real_putchar (int c); -int EXPORT_FUNC(grub_console_checkkey) (void); -int EXPORT_FUNC(grub_console_getkey) (void); -grub_uint16_t grub_console_getxy (void); -void grub_console_gotoxy (grub_uint8_t x, grub_uint8_t y); -void grub_console_cls (void); -void grub_console_setcursor (int on); - -/* Initialize the console system. */ -void grub_console_init (void); - -/* Finish the console system. */ -void grub_console_fini (void); - -#endif - -#endif /* ! GRUB_CONSOLE_MACHINE_HEADER */ Index: include/grub/powerpc/ieee1275/ieee1275.h =================================================================== RCS file: /cvsroot/grub/grub2/include/grub/powerpc/ieee1275/ieee1275.h,v retrieving revision 1.18 diff -u -p -r1.18 ieee1275.h --- include/grub/powerpc/ieee1275/ieee1275.h 21 Jun 2005 02:33:51 -0000 1.18 +++ include/grub/powerpc/ieee1275/ieee1275.h 13 Jul 2005 00:45:11 -0000 @@ -21,134 +21,8 @@ #ifndef GRUB_IEEE1275_MACHINE_HEADER #define GRUB_IEEE1275_MACHINE_HEADER 1 -#include <stdint.h> -#include <grub/err.h> #include <grub/types.h> -/* Maps a device alias to a pathname. */ -struct grub_ieee1275_devalias -{ - char *name; - char *path; - char *type; -}; - -struct grub_ieee1275_mem_region -{ - unsigned int start; - unsigned int size; -}; - -#ifndef IEEE1275_CALL_ENTRY_FN -#define IEEE1275_CALL_ENTRY_FN(args) (*grub_ieee1275_entry_fn) (args) -#endif - -/* All backcalls to the firmware is done by calling an entry function - which was passed to us from the bootloader. When doing the backcall, - a structure is passed which specifies what the firmware should do. - NAME is the requested service. NR_INS and NR_OUTS is the number of - passed arguments and the expected number of return values, resp. */ -struct grub_ieee1275_common_hdr -{ - char *name; - int nr_ins; - int nr_outs; -}; - -#define INIT_IEEE1275_COMMON(p, xname, xins, xouts) \ - (p)->name = xname; (p)->nr_ins = xins; (p)->nr_outs = xouts - -/* FIXME jrydberg: is this correct cell types? */ -typedef intptr_t grub_ieee1275_ihandle_t; -typedef intptr_t grub_ieee1275_phandle_t; - -extern grub_ieee1275_phandle_t grub_ieee1275_chosen; -extern grub_ieee1275_phandle_t EXPORT_VAR(grub_ieee1275_chosen); -extern intptr_t (*grub_ieee1275_entry_fn) (void *); -extern intptr_t (* EXPORT_VAR(grub_ieee1275_entry_fn)) (void *); - -enum grub_ieee1275_flag -{ - /* Old World firmware fails seek when "dev:0" is opened. */ - GRUB_IEEE1275_FLAG_NO_PARTITION_0, - - /* Apple firmware runs in translated mode and requires use of the "map" - method. Other firmware runs in untranslated mode and doesn't like "map" - calls. */ - GRUB_IEEE1275_FLAG_REAL_MODE, - - /* CHRP specifies partitions are numbered from 1 (partition 0 refers to the - whole disk). However, CodeGen firmware numbers partitions from 0. */ - GRUB_IEEE1275_FLAG_0_BASED_PARTITIONS, -}; - -extern int EXPORT_FUNC(grub_ieee1275_test_flag) (enum grub_ieee1275_flag flag); -extern void EXPORT_FUNC(grub_ieee1275_set_flag) (enum grub_ieee1275_flag flag); - -\f - -uint32_t EXPORT_FUNC(grub_ieee1275_decode_int_4) (unsigned char *p); -int EXPORT_FUNC(grub_ieee1275_finddevice) (char *name, - grub_ieee1275_phandle_t *phandlep); -int EXPORT_FUNC(grub_ieee1275_get_property) (grub_ieee1275_phandle_t handle, - const char *property, void *buf, - grub_size_t size, - grub_size_t *actual); -int EXPORT_FUNC(grub_ieee1275_next_property) (int handle, char *prev_prop, - char *prop, int *flags); -int EXPORT_FUNC(grub_ieee1275_get_property_length) - (grub_ieee1275_phandle_t handle, const char *prop, grub_size_t *length); -int EXPORT_FUNC(grub_ieee1275_instance_to_package) - (grub_ieee1275_ihandle_t ihandle, grub_ieee1275_phandle_t *phandlep); -int EXPORT_FUNC(grub_ieee1275_package_to_path) (grub_ieee1275_phandle_t phandle, - char *path, grub_size_t len, - grub_size_t *actual); -int EXPORT_FUNC(grub_ieee1275_instance_to_path) - (grub_ieee1275_ihandle_t ihandle, char *path, grub_size_t len, - grub_size_t *actual); -int EXPORT_FUNC(grub_ieee1275_write) (grub_ieee1275_ihandle_t ihandle, - void *buffer, grub_size_t len, - grub_size_t *actualp); -int EXPORT_FUNC(grub_ieee1275_read) (grub_ieee1275_ihandle_t ihandle, - void *buffer, grub_size_t len, - grub_size_t *actualp); -int EXPORT_FUNC(grub_ieee1275_seek) (grub_ieee1275_ihandle_t ihandle, - int pos_hi, int pos_lo, int *result); -int EXPORT_FUNC(grub_ieee1275_peer) (grub_ieee1275_phandle_t node, - grub_ieee1275_phandle_t *result); -int EXPORT_FUNC(grub_ieee1275_child) (grub_ieee1275_phandle_t node, - grub_ieee1275_phandle_t *result); -int EXPORT_FUNC(grub_ieee1275_parent) (grub_ieee1275_phandle_t node, - grub_ieee1275_phandle_t *result); -int EXPORT_FUNC(grub_ieee1275_interpret) (const char *command, int *catch); -int EXPORT_FUNC(grub_ieee1275_enter) (void); -int EXPORT_FUNC(grub_ieee1275_exit) (void); -int EXPORT_FUNC(grub_ieee1275_open) (char *node, - grub_ieee1275_ihandle_t *result); -int EXPORT_FUNC(grub_ieee1275_close) (grub_ieee1275_ihandle_t ihandle); -int EXPORT_FUNC(grub_ieee1275_claim) (grub_addr_t addr, grub_size_t size, - unsigned int align, grub_addr_t *result); -int EXPORT_FUNC(grub_ieee1275_release) (grub_addr_t addr, grub_size_t size); -int EXPORT_FUNC(grub_ieee1275_set_property) (grub_ieee1275_phandle_t phandle, - const char *propname, void *buf, - grub_size_t size, - grub_size_t *actual); -int EXPORT_FUNC(grub_ieee1275_set_color) (grub_ieee1275_ihandle_t ihandle, - int index, int r, int g, int b); -int EXPORT_FUNC(grub_ieee1275_milliseconds) (grub_uint32_t *msecs); - - -grub_err_t EXPORT_FUNC(grub_devalias_iterate) - (int (*hook) (struct grub_ieee1275_devalias *alias)); -grub_err_t EXPORT_FUNC(grub_children_iterate) (char *devpath, - int (*hook) (struct grub_ieee1275_devalias *alias)); -int EXPORT_FUNC(grub_claimmap) (grub_addr_t addr, grub_size_t size); - -void EXPORT_FUNC(abort) (void); -void EXPORT_FUNC (grub_reboot) (void); -void EXPORT_FUNC (grub_halt) (void); - -char *EXPORT_FUNC(grub_ieee1275_encode_devname) (const char *path); -char *EXPORT_FUNC(grub_ieee1275_get_filename) (const char *path); +typedef grub_uint32_t grub_ieee1275_cell_t; #endif /* ! GRUB_IEEE1275_MACHINE_HEADER */ Index: include/grub/powerpc/ieee1275/kernel.h =================================================================== RCS file: /cvsroot/grub/grub2/include/grub/powerpc/ieee1275/kernel.h,v retrieving revision 1.2 diff -u -p -r1.2 kernel.h --- include/grub/powerpc/ieee1275/kernel.h 21 Jun 2005 02:33:51 -0000 1.2 +++ include/grub/powerpc/ieee1275/kernel.h 13 Jul 2005 00:45:11 -0000 @@ -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 diff -N include/grub/powerpc/ieee1275/ofdisk.h --- include/grub/powerpc/ieee1275/ofdisk.h 1 May 2005 03:45:35 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -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 diff -u -p -r1.19 init.c --- kern/powerpc/ieee1275/init.c 21 Jun 2005 02:33:51 -0000 1.19 +++ kern/powerpc/ieee1275/init.c 13 Jul 2005 00:45:11 -0000 @@ -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 diff -u -p -r1.11 openfw.c --- kern/powerpc/ieee1275/openfw.c 21 Jun 2005 02:33:51 -0000 1.11 +++ kern/powerpc/ieee1275/openfw.c 13 Jul 2005 00:45:12 -0000 @@ -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 diff -N term/powerpc/ieee1275/ofconsole.c --- term/powerpc/ieee1275/ofconsole.c 21 Jun 2005 02:33:52 -0000 1.7 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,311 +0,0 @@ -/* ofconsole.c -- Open Firmware console for GRUB. */ -/* - * GRUB -- GRand Unified Bootloader - * Copyright (C) 2003, 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. - */ - -#include <grub/machine/console.h> -#include <grub/machine/ieee1275.h> -#include <grub/term.h> -#include <grub/types.h> -#include <grub/misc.h> - -static grub_ieee1275_ihandle_t stdout_ihandle; -static grub_ieee1275_ihandle_t stdin_ihandle; - -static int grub_curr_x; -static int grub_curr_y; - -static int grub_keybuf; -static int grub_buflen; - -struct color -{ - int red; - int green; - int blue; -}; - -#define MAX 0xff -static struct color colors[8] = - { - { 0, 0, 0}, - { MAX, 0, 0}, - { 0, MAX, 0}, - { MAX, MAX, 0}, - { 0, 0, MAX}, - { MAX, 0, MAX}, - { 0, MAX, MAX}, - { MAX, MAX, MAX} - }; - -static int fgcolor = 7; -static int bgcolor = 0; - -/* Write control characters to the console. */ -static void -grub_ofconsole_writeesc (const char *str) -{ - while (*str) - { - char chr = *(str++); - grub_ieee1275_write (stdout_ihandle, &chr, 1, 0); - } - -} - -static void -grub_ofconsole_putchar (grub_uint32_t c) -{ - char chr = c; - if (c == '\n') - { - grub_curr_y++; - grub_curr_x = 0; - } - else - grub_curr_x++; - grub_ieee1275_write (stdout_ihandle, &chr, 1, 0); -} - -static void -grub_ofconsole_setcolorstate (grub_term_color_state state) -{ - char setcol[20]; - int fg; - int bg; - - switch (state) - { - case GRUB_TERM_COLOR_STANDARD: - case GRUB_TERM_COLOR_NORMAL: - fg = fgcolor; - bg = bgcolor; - break; - case GRUB_TERM_COLOR_HIGHLIGHT: - fg = bgcolor; - bg = fgcolor; - break; - default: - return; - } - - grub_sprintf (setcol, "\e[3%dm\e[4%dm", fg, bg); - grub_ofconsole_writeesc (setcol); -} - -static void -grub_ofconsole_setcolor (grub_uint8_t normal_color, - grub_uint8_t highlight_color) -{ - fgcolor = normal_color; - bgcolor = highlight_color; -} - -static int -grub_ofconsole_readkey (int *key) -{ - char c; - int actual = 0; - - grub_ieee1275_read (stdin_ihandle, &c, 1, &actual); - - if (actual > 0 && c == '\e') - { - grub_ieee1275_read (stdin_ihandle, &c, 1, &actual); - if (actual <= 0) - { - *key = '\e'; - return 1; - } - - if (c != 91) - return 0; - - grub_ieee1275_read (stdin_ihandle, &c, 1, &actual); - if (actual <= 0) - return 0; - - switch (c) - { - case 65: - /* Up: Ctrl-p. */ - c = 16; - break; - case 66: - /* Down: Ctrl-n. */ - c = 14; - break; - case 67: - /* Right: Ctrl-f. */ - c = 6; - break; - case 68: - /* Left: Ctrl-b. */ - c = 2; - break; - } - } - - *key = c; - return actual > 0; -} - -static int -grub_ofconsole_checkkey (void) -{ - int key; - int read; - - if (grub_buflen) - return 1; - - read = grub_ofconsole_readkey (&key); - if (read) - { - grub_keybuf = key; - grub_buflen = 1; - return 1; - } - - return 0; -} - -static int -grub_ofconsole_getkey (void) -{ - int key; - - if (grub_buflen) - { - grub_buflen =0; - return grub_keybuf; - } - - while (! grub_ofconsole_readkey (&key)); - - return key; -} - -static grub_uint16_t -grub_ofconsole_getxy (void) -{ - return ((grub_curr_x - 1) << 8) | grub_curr_y; -} - -static void -grub_ofconsole_gotoxy (grub_uint8_t x, grub_uint8_t y) -{ - char s[11]; /* 5 + 3 + 3. */ - grub_curr_x = x; - grub_curr_y = y; - - grub_sprintf (s, "\e[%d;%dH", y + 1, x + 1); - grub_ofconsole_writeesc (s); -} - -static void -grub_ofconsole_cls (void) -{ - /* Clear the screen. */ - grub_ofconsole_writeesc ("\e[2J"); - grub_gotoxy (0, 0); -} - -static void -grub_ofconsole_setcursor (int on __attribute ((unused))) -{ - /* XXX: Not supported. */ -} - -static void -grub_ofconsole_refresh (void) -{ - /* Do nothing, the current console state is ok. */ -} - -static grub_err_t -grub_ofconsole_init (void) -{ - char data[4]; - grub_size_t actual; - int col; - - if (grub_ieee1275_get_property (grub_ieee1275_chosen, "stdout", data, - sizeof data, &actual) - || actual != sizeof data) - return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Cannot find stdout"); - - stdout_ihandle = grub_ieee1275_decode_int_4 (data); - - if (grub_ieee1275_get_property (grub_ieee1275_chosen, "stdin", data, - sizeof data, &actual) - || actual != sizeof data) - return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Cannot find stdin"); - - stdin_ihandle = grub_ieee1275_decode_int_4 (data); - - /* Initialize colors. */ - for (col = 0; col < 7; col++) - grub_ieee1275_set_color (stdout_ihandle, col, colors[col].red, - colors[col].green, colors[col].blue); - - /* Set the right fg and bg colors. */ - grub_ofconsole_setcolorstate (GRUB_TERM_COLOR_NORMAL); - - return 0; -} - -static grub_err_t -grub_ofconsole_fini (void) -{ - return 0; -} - - -\f -static struct grub_term grub_ofconsole_term = - { - .name = "ofconsole", - .init = grub_ofconsole_init, - .fini = grub_ofconsole_fini, - .putchar = grub_ofconsole_putchar, - .checkkey = grub_ofconsole_checkkey, - .getkey = grub_ofconsole_getkey, - .getxy = grub_ofconsole_getxy, - .gotoxy = grub_ofconsole_gotoxy, - .cls = grub_ofconsole_cls, - .setcolorstate = grub_ofconsole_setcolorstate, - .setcolor = grub_ofconsole_setcolor, - .setcursor = grub_ofconsole_setcursor, - .refresh = grub_ofconsole_refresh, - .flags = 0, - .next = 0 - }; - -void -grub_console_init (void) -{ - grub_term_register (&grub_ofconsole_term); - grub_term_set_current (&grub_ofconsole_term); -} - -void -grub_console_fini (void) -{ - grub_term_unregister (&grub_ofconsole_term); -} Index: util/console.c =================================================================== RCS file: /cvsroot/grub/grub2/util/console.c,v retrieving revision 1.8 diff -u -p -r1.8 console.c --- util/console.c 27 Feb 2005 21:19:05 -0000 1.8 +++ util/console.c 13 Jul 2005 00:45:12 -0000 @@ -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 diff -u -p -r1.18 grub-emu.c --- util/grub-emu.c 2 Mar 2005 20:12:46 -0000 1.18 +++ util/grub-emu.c 13 Jul 2005 00:45:12 -0000 @@ -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> --- /dev/null 2004-12-18 12:15:49.000000000 -0600 +++ disk/ieee1275/ofdisk.c 2005-07-12 18:42:56.200066304 -0500 @@ -0,0 +1,182 @@ +/* ofdisk.c - Open Firmware disk access. */ +/* + * 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. + */ + +#include <grub/misc.h> +#include <grub/disk.h> +#include <grub/mm.h> +#include <grub/ieee1275/ieee1275.h> +#include <grub/ieee1275/ofdisk.h> + +static int +grub_ofdisk_iterate (int (*hook) (const char *name)) +{ + auto int dev_iterate (struct grub_ieee1275_devalias *alias); + + int dev_iterate (struct grub_ieee1275_devalias *alias) + { + if (! grub_strcmp (alias->type, "block")) + hook (alias->name); + else if ((! grub_strcmp (alias->type, "scsi")) + || (! grub_strcmp (alias->type, "ide")) + || (! grub_strcmp (alias->type, "ata"))) + /* Search for block-type children of these bus controllers. */ + grub_children_iterate (alias->name, dev_iterate); + return 0; + } + + grub_devalias_iterate (dev_iterate); + return 0; +} + +static grub_err_t +grub_ofdisk_open (const char *name, grub_disk_t disk) +{ + grub_ieee1275_phandle_t dev; + grub_ieee1275_ihandle_t dev_ihandle = 0; + char *devpath; + /* XXX: This should be large enough for any possible case. */ + char prop[64]; + int 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_dprintf ("disk", "Opening `%s'.\n", devpath); + + grub_ieee1275_open (devpath, &dev_ihandle); + if (! dev_ihandle) + { + grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Can't open device"); + goto fail; + } + + grub_dprintf ("disk", "Opened `%s' as handle 0x%x.\n", devpath, dev_ihandle); + + if (grub_ieee1275_finddevice (devpath, &dev)) + { + grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Can't read device properties"); + goto fail; + } + + if (grub_ieee1275_get_property (dev, "device_type", prop, sizeof (prop), + &actual)) + { + grub_error (GRUB_ERR_BAD_DEVICE, "Can't read the device type"); + goto fail; + } + + if (grub_strcmp (prop, "block")) + { + grub_error (GRUB_ERR_BAD_DEVICE, "Not a block device"); + goto fail; + } + + /* XXX: There is no property to read the number of blocks. There + should be a property `#blocks', but it is not there. Perhaps it + is possible to use seek for this. */ + disk->total_sectors = 0xFFFFFFFFUL; + + /* XXX: Is it ok to use this? Perhaps it is better to use the path + or some property. */ + disk->id = dev; + + /* XXX: Read this, somehow. */ + disk->has_partitions = 1; + disk->data = (void *) dev_ihandle; + + fail: + if (grub_errno && dev_ihandle) + grub_ieee1275_close (dev_ihandle); + grub_free (devpath); + return grub_errno; +} + +static void +grub_ofdisk_close (grub_disk_t disk) +{ + grub_dprintf ("disk", "Closing handle 0x%x.\n", + (grub_ieee1275_ihandle_t) disk->data); + grub_ieee1275_close ((grub_ieee1275_ihandle_t) disk->data); +} + +static grub_err_t +grub_ofdisk_read (grub_disk_t disk, unsigned long sector, + unsigned long size, char *buf) +{ + int status; + int actual; + unsigned long long pos; + + grub_dprintf ("disk", + "Reading handle 0x%x: sector 0x%lx, size 0x%lx, buf %p.\n", + (grub_ieee1275_ihandle_t) disk->data, sector, size, buf); + + pos = (unsigned long long) sector * 512UL; + + grub_ieee1275_seek ((grub_ieee1275_ihandle_t) disk->data, (int) (pos >> 32), + (int) pos & 0xFFFFFFFFUL, &status); + if (status != 0) + return grub_error (GRUB_ERR_READ_ERROR, + "Seek error, can't seek block %d", sector); + grub_ieee1275_read ((grub_ieee1275_ihandle_t) disk->data, buf, + size * 512UL, &actual); + if (actual != actual) + return grub_error (GRUB_ERR_READ_ERROR, "Read error on block: %d", sector); + + return 0; +} + +static grub_err_t +grub_ofdisk_write (grub_disk_t disk __attribute ((unused)), + unsigned long sector __attribute ((unused)), + unsigned long size __attribute ((unused)), + const char *buf __attribute ((unused))) +{ + return GRUB_ERR_NOT_IMPLEMENTED_YET; +} + +static struct grub_disk_dev grub_ofdisk_dev = + { + .name = "ofdisk", + .id = GRUB_DISK_DEVICE_OFDISK_ID, + .iterate = grub_ofdisk_iterate, + .open = grub_ofdisk_open, + .close = grub_ofdisk_close, + .read = grub_ofdisk_read, + .write = grub_ofdisk_write, + .next = 0 + }; + +void +grub_ofdisk_init (void) +{ + grub_disk_dev_register (&grub_ofdisk_dev); +} + +void +grub_ofdisk_fini (void) +{ + grub_disk_dev_unregister (&grub_ofdisk_dev); +} --- /dev/null 2004-12-18 12:15:49.000000000 -0600 +++ include/grub/console.h 2005-07-12 18:54:44.584375520 -0500 @@ -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 */ --- /dev/null 2004-12-18 12:15:49.000000000 -0600 +++ include/grub/ieee1275/ieee1275.h 2005-07-12 19:23:44.935801888 -0500 @@ -0,0 +1,154 @@ +/* ieee1275.h - Access the Open Firmware client interface. */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2003, 2004, 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_IEEE1275_HEADER +#define GRUB_IEEE1275_HEADER 1 + +#include <stdint.h> +#include <grub/err.h> +#include <grub/types.h> +#include <grub/machine/ieee1275.h> + +/* Maps a device alias to a pathname. */ +struct grub_ieee1275_devalias +{ + char *name; + char *path; + char *type; +}; + +struct grub_ieee1275_mem_region +{ + unsigned int start; + unsigned int size; +}; + +#ifndef IEEE1275_CALL_ENTRY_FN +#define IEEE1275_CALL_ENTRY_FN(args) (*grub_ieee1275_entry_fn) (args) +#endif + +/* All backcalls to the firmware is done by calling an entry function + which was passed to us from the bootloader. When doing the backcall, + a structure is passed which specifies what the firmware should do. + NAME is the requested service. NR_INS and NR_OUTS is the number of + passed arguments and the expected number of return values, resp. */ +struct grub_ieee1275_common_hdr +{ + grub_ieee1275_cell_t name; + grub_ieee1275_cell_t nr_ins; + grub_ieee1275_cell_t nr_outs; +}; + +#define INIT_IEEE1275_COMMON(p, xname, xins, xouts) \ + (p)->name = (grub_ieee1275_cell_t) xname; \ + (p)->nr_ins = (grub_ieee1275_cell_t) xins; \ + (p)->nr_outs = (grub_ieee1275_cell_t) xouts + +typedef grub_ieee1275_cell_t grub_ieee1275_ihandle_t; +typedef grub_ieee1275_cell_t grub_ieee1275_phandle_t; + +extern grub_ieee1275_phandle_t EXPORT_VAR(grub_ieee1275_chosen); +extern int (* EXPORT_VAR(grub_ieee1275_entry_fn)) (void *); + +enum grub_ieee1275_flag +{ + /* Old World Macintosh firmware fails seek when "dev:0" is opened. */ + GRUB_IEEE1275_FLAG_NO_PARTITION_0, + + /* Apple firmware runs in translated mode and requires use of the "map" + method. Other firmware runs in untranslated mode and doesn't like "map" + calls. */ + GRUB_IEEE1275_FLAG_REAL_MODE, + + /* CHRP specifies partitions are numbered from 1 (partition 0 refers to the + whole disk). However, CodeGen firmware numbers partitions from 0. */ + GRUB_IEEE1275_FLAG_0_BASED_PARTITIONS, +}; + +extern int EXPORT_FUNC(grub_ieee1275_test_flag) (enum grub_ieee1275_flag flag); +extern void EXPORT_FUNC(grub_ieee1275_set_flag) (enum grub_ieee1275_flag flag); + +\f + + +grub_uint32_t EXPORT_FUNC(grub_ieee1275_decode_int_4) (unsigned char *p); +int EXPORT_FUNC(grub_ieee1275_finddevice) (char *name, + grub_ieee1275_phandle_t *phandlep); +int EXPORT_FUNC(grub_ieee1275_get_property) (grub_ieee1275_phandle_t phandle, + const char *property, void *buf, + grub_size_t size, + grub_ssize_t *actual); +int EXPORT_FUNC(grub_ieee1275_next_property) (grub_ieee1275_phandle_t phandle, + char *prev_prop, char *prop, + grub_ieee1275_cell_t *flags); +int EXPORT_FUNC(grub_ieee1275_get_property_length) + (grub_ieee1275_phandle_t phandle, const char *prop, grub_ssize_t *length); +int EXPORT_FUNC(grub_ieee1275_instance_to_package) + (grub_ieee1275_ihandle_t ihandle, grub_ieee1275_phandle_t *phandlep); +int EXPORT_FUNC(grub_ieee1275_package_to_path) (grub_ieee1275_phandle_t phandle, + char *path, grub_size_t len, + grub_ssize_t *actual); +int EXPORT_FUNC(grub_ieee1275_instance_to_path) + (grub_ieee1275_ihandle_t ihandle, char *path, grub_size_t len, + grub_ssize_t *actual); +int EXPORT_FUNC(grub_ieee1275_write) (grub_ieee1275_ihandle_t ihandle, + void *buffer, grub_size_t len, + grub_ssize_t *actualp); +int EXPORT_FUNC(grub_ieee1275_read) (grub_ieee1275_ihandle_t ihandle, + void *buffer, grub_size_t len, + grub_ssize_t *actualp); +int EXPORT_FUNC(grub_ieee1275_seek) (grub_ieee1275_ihandle_t ihandle, + int pos_hi, int pos_lo, + grub_ssize_t *result); +int EXPORT_FUNC(grub_ieee1275_peer) (grub_ieee1275_phandle_t node, + grub_ieee1275_phandle_t *result); +int EXPORT_FUNC(grub_ieee1275_child) (grub_ieee1275_phandle_t node, + grub_ieee1275_phandle_t *result); +int EXPORT_FUNC(grub_ieee1275_parent) (grub_ieee1275_phandle_t node, + grub_ieee1275_phandle_t *result); +int EXPORT_FUNC(grub_ieee1275_interpret) (const char *command, + grub_ieee1275_cell_t *catch); +int EXPORT_FUNC(grub_ieee1275_enter) (void); +int EXPORT_FUNC(grub_ieee1275_exit) (void) __attribute__ ((noreturn)); +int EXPORT_FUNC(grub_ieee1275_open) (const char *node, + grub_ieee1275_ihandle_t *result); +int EXPORT_FUNC(grub_ieee1275_close) (grub_ieee1275_ihandle_t ihandle); +int EXPORT_FUNC(grub_ieee1275_claim) (grub_addr_t addr, grub_size_t size, + unsigned int align, grub_addr_t *result); +int EXPORT_FUNC(grub_ieee1275_release) (grub_addr_t addr, grub_size_t size); +int EXPORT_FUNC(grub_ieee1275_set_property) (grub_ieee1275_phandle_t phandle, + const char *propname, void *buf, + grub_size_t size, + grub_ssize_t *actual); +int EXPORT_FUNC(grub_ieee1275_set_color) (grub_ieee1275_ihandle_t ihandle, + int index, int r, int g, int b); +int EXPORT_FUNC(grub_ieee1275_milliseconds) (grub_uint32_t *msecs); + + +grub_err_t EXPORT_FUNC(grub_devalias_iterate) + (int (*hook) (struct grub_ieee1275_devalias *alias)); +grub_err_t EXPORT_FUNC(grub_children_iterate) (char *devpath, + int (*hook) (struct grub_ieee1275_devalias *alias)); +int EXPORT_FUNC(grub_claimmap) (grub_addr_t addr, grub_size_t size); + +char *EXPORT_FUNC(grub_ieee1275_encode_devname) (const char *path); +char *EXPORT_FUNC(grub_ieee1275_get_filename) (const char *path); + +#endif /* ! GRUB_IEEE1275_HEADER */ --- /dev/null 2004-12-18 12:15:49.000000000 -0600 +++ include/grub/ieee1275/ofdisk.h 2005-07-12 18:47:13.392967040 -0500 @@ -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 */ --- /dev/null 2004-12-18 12:15:49.000000000 -0600 +++ term/ieee1275/ofconsole.c 2005-07-12 18:51:15.309190184 -0500 @@ -0,0 +1,311 @@ +/* ofconsole.c -- Open Firmware console for GRUB. */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2003, 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. + */ + +#include <grub/console.h> +#include <grub/term.h> +#include <grub/types.h> +#include <grub/misc.h> +#include <grub/ieee1275/ieee1275.h> + +static grub_ieee1275_ihandle_t stdout_ihandle; +static grub_ieee1275_ihandle_t stdin_ihandle; + +static int grub_curr_x; +static int grub_curr_y; + +static int grub_keybuf; +static int grub_buflen; + +struct color +{ + int red; + int green; + int blue; +}; + +#define MAX 0xff +static struct color colors[8] = + { + { 0, 0, 0}, + { MAX, 0, 0}, + { 0, MAX, 0}, + { MAX, MAX, 0}, + { 0, 0, MAX}, + { MAX, 0, MAX}, + { 0, MAX, MAX}, + { MAX, MAX, MAX} + }; + +static int fgcolor = 7; +static int bgcolor = 0; + +/* Write control characters to the console. */ +static void +grub_ofconsole_writeesc (const char *str) +{ + while (*str) + { + char chr = *(str++); + grub_ieee1275_write (stdout_ihandle, &chr, 1, 0); + } + +} + +static void +grub_ofconsole_putchar (grub_uint32_t c) +{ + char chr = c; + if (c == '\n') + { + grub_curr_y++; + grub_curr_x = 0; + } + else + grub_curr_x++; + grub_ieee1275_write (stdout_ihandle, &chr, 1, 0); +} + +static void +grub_ofconsole_setcolorstate (grub_term_color_state state) +{ + char setcol[20]; + int fg; + int bg; + + switch (state) + { + case GRUB_TERM_COLOR_STANDARD: + case GRUB_TERM_COLOR_NORMAL: + fg = fgcolor; + bg = bgcolor; + break; + case GRUB_TERM_COLOR_HIGHLIGHT: + fg = bgcolor; + bg = fgcolor; + break; + default: + return; + } + + grub_sprintf (setcol, "\e[3%dm\e[4%dm", fg, bg); + grub_ofconsole_writeesc (setcol); +} + +static void +grub_ofconsole_setcolor (grub_uint8_t normal_color, + grub_uint8_t highlight_color) +{ + fgcolor = normal_color; + bgcolor = highlight_color; +} + +static int +grub_ofconsole_readkey (int *key) +{ + char c; + int actual = 0; + + grub_ieee1275_read (stdin_ihandle, &c, 1, &actual); + + if (actual > 0 && c == '\e') + { + grub_ieee1275_read (stdin_ihandle, &c, 1, &actual); + if (actual <= 0) + { + *key = '\e'; + return 1; + } + + if (c != 91) + return 0; + + grub_ieee1275_read (stdin_ihandle, &c, 1, &actual); + if (actual <= 0) + return 0; + + switch (c) + { + case 65: + /* Up: Ctrl-p. */ + c = 16; + break; + case 66: + /* Down: Ctrl-n. */ + c = 14; + break; + case 67: + /* Right: Ctrl-f. */ + c = 6; + break; + case 68: + /* Left: Ctrl-b. */ + c = 2; + break; + } + } + + *key = c; + return actual > 0; +} + +static int +grub_ofconsole_checkkey (void) +{ + int key; + int read; + + if (grub_buflen) + return 1; + + read = grub_ofconsole_readkey (&key); + if (read) + { + grub_keybuf = key; + grub_buflen = 1; + return 1; + } + + return 0; +} + +static int +grub_ofconsole_getkey (void) +{ + int key; + + if (grub_buflen) + { + grub_buflen =0; + return grub_keybuf; + } + + while (! grub_ofconsole_readkey (&key)); + + return key; +} + +static grub_uint16_t +grub_ofconsole_getxy (void) +{ + return ((grub_curr_x - 1) << 8) | grub_curr_y; +} + +static void +grub_ofconsole_gotoxy (grub_uint8_t x, grub_uint8_t y) +{ + char s[11]; /* 5 + 3 + 3. */ + grub_curr_x = x; + grub_curr_y = y; + + grub_sprintf (s, "\e[%d;%dH", y + 1, x + 1); + grub_ofconsole_writeesc (s); +} + +static void +grub_ofconsole_cls (void) +{ + /* Clear the screen. */ + grub_ofconsole_writeesc ("\e[2J"); + grub_gotoxy (0, 0); +} + +static void +grub_ofconsole_setcursor (int on __attribute ((unused))) +{ + /* XXX: Not supported. */ +} + +static void +grub_ofconsole_refresh (void) +{ + /* Do nothing, the current console state is ok. */ +} + +static grub_err_t +grub_ofconsole_init (void) +{ + char data[4]; + grub_size_t actual; + int col; + + if (grub_ieee1275_get_property (grub_ieee1275_chosen, "stdout", data, + sizeof data, &actual) + || actual != sizeof data) + return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Cannot find stdout"); + + stdout_ihandle = grub_ieee1275_decode_int_4 (data); + + if (grub_ieee1275_get_property (grub_ieee1275_chosen, "stdin", data, + sizeof data, &actual) + || actual != sizeof data) + return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Cannot find stdin"); + + stdin_ihandle = grub_ieee1275_decode_int_4 (data); + + /* Initialize colors. */ + for (col = 0; col < 7; col++) + grub_ieee1275_set_color (stdout_ihandle, col, colors[col].red, + colors[col].green, colors[col].blue); + + /* Set the right fg and bg colors. */ + grub_ofconsole_setcolorstate (GRUB_TERM_COLOR_NORMAL); + + return 0; +} + +static grub_err_t +grub_ofconsole_fini (void) +{ + return 0; +} + + +\f +static struct grub_term grub_ofconsole_term = + { + .name = "ofconsole", + .init = grub_ofconsole_init, + .fini = grub_ofconsole_fini, + .putchar = grub_ofconsole_putchar, + .checkkey = grub_ofconsole_checkkey, + .getkey = grub_ofconsole_getkey, + .getxy = grub_ofconsole_getxy, + .gotoxy = grub_ofconsole_gotoxy, + .cls = grub_ofconsole_cls, + .setcolorstate = grub_ofconsole_setcolorstate, + .setcolor = grub_ofconsole_setcolor, + .setcursor = grub_ofconsole_setcursor, + .refresh = grub_ofconsole_refresh, + .flags = 0, + .next = 0 + }; + +void +grub_console_init (void) +{ + grub_term_register (&grub_ofconsole_term); + grub_term_set_current (&grub_ofconsole_term); +} + +void +grub_console_fini (void) +{ + grub_term_unregister (&grub_ofconsole_term); +} Index: boot/powerpc/ieee1275/ieee1275.c =================================================================== RCS file: boot/powerpc/ieee1275/ieee1275.c diff -N boot/powerpc/ieee1275/ieee1275.c --- boot/powerpc/ieee1275/ieee1275.c 21 Jun 2005 02:33:51 -0000 1.12 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,533 +0,0 @@ -/* ieee1275.c - Access the Open Firmware client interface. */ -/* - * GRUB -- GRand Unified Bootloader - * Copyright (C) 2003, 2004, 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. - */ - -#include <grub/machine/ieee1275.h> - - -#define IEEE1275_PHANDLE_ROOT ((grub_ieee1275_phandle_t) 0) -#define IEEE1275_PHANDLE_INVALID ((grub_ieee1275_phandle_t) -1) - -intptr_t (*grub_ieee1275_entry_fn) (void *); - -/* FIXME is this function needed? */ -grub_uint32_t -grub_ieee1275_decode_int_4 (unsigned char *p) -{ - grub_uint32_t val = (*p++ << 8); - val = (val + *p++) << 8; - val = (val + *p++) << 8; - return (val + *p); -} - -\f -int -grub_ieee1275_finddevice (char *name, grub_ieee1275_phandle_t *phandlep) -{ - struct find_device_args { - struct grub_ieee1275_common_hdr common; - char *device; - grub_ieee1275_phandle_t phandle; - } args; - - INIT_IEEE1275_COMMON (&args.common, "finddevice", 1, 1); - args.device = name; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - *phandlep = args.phandle; - return 0; -} - -int -grub_ieee1275_get_property (grub_ieee1275_phandle_t phandle, - const char *property, void *buf, - grub_size_t size, grub_size_t *actual) -{ - struct get_property_args { - struct grub_ieee1275_common_hdr common; - grub_ieee1275_phandle_t phandle; - const char *prop; - void *buf; - int buflen; - int size; - } args; - - INIT_IEEE1275_COMMON (&args.common, "getprop", 4, 1); - args.phandle = phandle; - args.prop = property; - args.buf = buf; - args.buflen = size; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - if (actual) - *actual = args.size; - if (args.size == -1) - return -1; - return 0; -} - -int -grub_ieee1275_next_property (grub_ieee1275_phandle_t phandle, char *prev_prop, - char *prop, int *flags) -{ - struct get_property_args { - struct grub_ieee1275_common_hdr common; - grub_ieee1275_phandle_t phandle; - char *prev_prop; - char *next_prop; - int flags; - } args; - - INIT_IEEE1275_COMMON (&args.common, "nextprop", 3, 1); - args.phandle = phandle; - args.prev_prop = prev_prop; - args.next_prop = prop; - args.flags = -1; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - if (flags) - *flags = args.flags; - return 0; -} - -int -grub_ieee1275_get_property_length (grub_ieee1275_phandle_t phandle, - const char *prop, grub_size_t *length) -{ - struct get_property_args { - struct grub_ieee1275_common_hdr common; - grub_ieee1275_phandle_t phandle; - const char *prop; - grub_size_t length; - } args; - - INIT_IEEE1275_COMMON (&args.common, "getproplen", 2, 1); - args.phandle = phandle; - args.prop = prop; - args.length = -1; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - *length = args.length; - return 0; -} - -int -grub_ieee1275_instance_to_package (grub_ieee1275_ihandle_t ihandle, - grub_ieee1275_phandle_t *phandlep) -{ - struct instance_to_package_args { - struct grub_ieee1275_common_hdr common; - grub_ieee1275_ihandle_t ihandle; - grub_ieee1275_phandle_t phandle; - } args; - - INIT_IEEE1275_COMMON (&args.common, "instance-to-package", 1, 1); - args.ihandle = ihandle; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - *phandlep = args.phandle; - return 0; -} - -int -grub_ieee1275_package_to_path (grub_ieee1275_phandle_t phandle, - char *path, grub_size_t len, grub_size_t *actual) -{ - struct instance_to_package_args { - struct grub_ieee1275_common_hdr common; - grub_ieee1275_phandle_t phandle; - char *buf; - int buflen; - int actual; - } args; - - INIT_IEEE1275_COMMON (&args.common, "package-to-path", 3, 1); - args.phandle = phandle; - args.buf = path; - args.buflen = len; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - if (actual) - *actual = args.actual; - return 0; -} - -int -grub_ieee1275_instance_to_path (grub_ieee1275_ihandle_t ihandle, - char *path, grub_size_t len, - grub_size_t *actual) -{ - struct instance_to_package_args { - struct grub_ieee1275_common_hdr common; - grub_ieee1275_ihandle_t ihandle; - char *buf; - int buflen; - int actual; - } args; - - INIT_IEEE1275_COMMON (&args.common, "instance-to-path", 3, 1); - args.ihandle = ihandle; - args.buf = path; - args.buflen = len; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - if (actual) - *actual = args.actual; - return 0; -} - -int -grub_ieee1275_write (grub_ieee1275_ihandle_t ihandle, void *buffer, - grub_size_t len, grub_size_t *actualp) -{ - struct write_args { - struct grub_ieee1275_common_hdr common; - grub_ieee1275_ihandle_t ihandle; - void *buf; - grub_size_t len; - grub_size_t actual; - } args; - - INIT_IEEE1275_COMMON (&args.common, "write", 3, 1); - args.ihandle = ihandle; - args.buf = buffer; - args.len = len; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - if (actualp) - *actualp = args.actual; - return 0; -} - -int -grub_ieee1275_read (grub_ieee1275_ihandle_t ihandle, void *buffer, - grub_size_t len, grub_size_t *actualp) -{ - struct write_args { - struct grub_ieee1275_common_hdr common; - grub_ieee1275_ihandle_t ihandle; - void *buf; - grub_size_t len; - grub_size_t actual; - } args; - - INIT_IEEE1275_COMMON (&args.common, "read", 3, 1); - args.ihandle = ihandle; - args.buf = buffer; - args.len = len; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - if (actualp) - *actualp = args.actual; - return 0; -} - -int -grub_ieee1275_seek (grub_ieee1275_ihandle_t ihandle, int pos_hi, - int pos_lo, int *result) -{ - struct write_args { - struct grub_ieee1275_common_hdr common; - grub_ieee1275_ihandle_t ihandle; - int pos_hi; - int pos_lo; - int result; - } args; - - INIT_IEEE1275_COMMON (&args.common, "seek", 3, 1); - args.ihandle = ihandle; - args.pos_hi = pos_hi; - args.pos_lo = pos_lo; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - - if (result) - *result = args.result; - return 0; -} - -int -grub_ieee1275_peer (grub_ieee1275_phandle_t node, - grub_ieee1275_phandle_t *result) -{ - struct peer_args { - struct grub_ieee1275_common_hdr common; - grub_ieee1275_phandle_t node; - grub_ieee1275_phandle_t result; - } args; - - INIT_IEEE1275_COMMON (&args.common, "peer", 1, 1); - args.node = node; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - *result = args.result; - return 0; -} - -int -grub_ieee1275_child (grub_ieee1275_phandle_t node, - grub_ieee1275_phandle_t *result) -{ - struct child_args { - struct grub_ieee1275_common_hdr common; - grub_ieee1275_phandle_t node; - grub_ieee1275_phandle_t result; - } args; - - INIT_IEEE1275_COMMON (&args.common, "child", 1, 1); - args.node = node; - args.result = IEEE1275_PHANDLE_INVALID; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - *result = args.result; - return 0; -} - -int -grub_ieee1275_parent (grub_ieee1275_phandle_t node, - grub_ieee1275_phandle_t *result) -{ - struct parent_args { - struct grub_ieee1275_common_hdr common; - grub_ieee1275_phandle_t node; - grub_ieee1275_phandle_t result; - } args; - - INIT_IEEE1275_COMMON (&args.common, "parent", 1, 1); - args.node = node; - args.result = IEEE1275_PHANDLE_INVALID; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - *result = args.result; - return 0; -} - -int -grub_ieee1275_interpret (const char *command, int *catch) -{ - struct enter_args { - struct grub_ieee1275_common_hdr common; - const char *command; - int catch; - } args; - - INIT_IEEE1275_COMMON (&args.common, "interpret", 1, 1); - args.command = command; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - if (catch) - *catch = args.catch; - return 0; -} - -int -grub_ieee1275_enter (void) -{ - struct enter_args { - struct grub_ieee1275_common_hdr common; - } args; - - INIT_IEEE1275_COMMON (&args.common, "enter", 0, 0); - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - return 0; -} - -int -grub_ieee1275_exit (void) -{ - struct exit_args { - struct grub_ieee1275_common_hdr common; - } args; - - INIT_IEEE1275_COMMON (&args.common, "exit", 0, 0); - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - return 0; -} - -int -grub_ieee1275_open (char *node, grub_ieee1275_ihandle_t *result) -{ - struct open_args { - struct grub_ieee1275_common_hdr common; - char *cstr; - grub_ieee1275_ihandle_t result; - } args; - - INIT_IEEE1275_COMMON (&args.common, "open", 1, 1); - args.cstr = node; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - *result = args.result; - return 0; -} - -int -grub_ieee1275_close (grub_ieee1275_ihandle_t ihandle) -{ - struct close_args { - struct grub_ieee1275_common_hdr common; - grub_ieee1275_ihandle_t ihandle; - } args; - - INIT_IEEE1275_COMMON (&args.common, "close", 1, 0); - args.ihandle = ihandle; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - - return 0; -} - -int -grub_ieee1275_claim (grub_addr_t addr, grub_size_t size, unsigned int align, - grub_addr_t *result) -{ - struct claim_args { - struct grub_ieee1275_common_hdr common; - grub_addr_t addr; - grub_size_t size; - unsigned int align; - grub_addr_t base; - } args; - - INIT_IEEE1275_COMMON (&args.common, "claim", 3, 1); - args.addr = addr; - args.size = size; - args.align = align; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - - if (result) - *result = args.base; - - if (args.base == (grub_addr_t)-1) - return -1; - - return 0; -} - -int -grub_ieee1275_release (grub_addr_t addr, grub_size_t size) -{ - struct release_args { - struct grub_ieee1275_common_hdr common; - grub_addr_t addr; - grub_size_t size; - } args; - - INIT_IEEE1275_COMMON (&args.common, "release", 2, 0); - args.addr = addr; - args.size = size; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - - return 0; -} - -int -grub_ieee1275_set_property (grub_ieee1275_phandle_t phandle, - const char *propname, void *buf, - grub_size_t size, grub_size_t *actual) -{ - struct set_property_args { - struct grub_ieee1275_common_hdr common; - grub_ieee1275_phandle_t phandle; - const char *propname; - void *buf; - grub_size_t size; - grub_size_t actual; - } args; - - INIT_IEEE1275_COMMON (&args.common, "setprop", 4, 1); - args.size = size; - args.buf = buf; - args.propname = propname; - args.phandle = phandle; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - *actual = args.actual; - return 0; -} - -int -grub_ieee1275_set_color (grub_ieee1275_ihandle_t ihandle, - int index, int r, int g, int b) -{ - struct set_color_args { - struct grub_ieee1275_common_hdr common; - char *method; - grub_ieee1275_ihandle_t ihandle; - int index; - int b; - int g; - int r; - int result; - } args; - - INIT_IEEE1275_COMMON (&args.common, "call-method", 6, 1); - args.method = "color!"; - args.ihandle = ihandle; - args.index = index; - args.r = r; - args.g = g; - args.b = b; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - - return 0; -} - -int -grub_ieee1275_milliseconds (grub_uint32_t *msecs) -{ - struct milliseconds_args { - struct grub_ieee1275_common_hdr common; - grub_uint32_t msecs; - } args; - - INIT_IEEE1275_COMMON (&args.common, "milliseconds", 0, 1); - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - *msecs = args.msecs; - return 0; -} Index: kern/ieee1275.c =================================================================== RCS file: kern/ieee1275.c diff -N kern/ieee1275.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ kern/ieee1275.c 13 Jul 2005 00:48:15 -0000 @@ -0,0 +1,530 @@ +/* ieee1275.c - Access the Open Firmware client interface. */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2003, 2004, 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. + */ + +#include <grub/ieee1275/ieee1275.h> + +#define IEEE1275_PHANDLE_ROOT ((grub_ieee1275_phandle_t) 0) +#define IEEE1275_PHANDLE_INVALID ((grub_ieee1275_phandle_t) -1) + +\f + +/* FIXME is this function needed? */ +grub_uint32_t +grub_ieee1275_decode_int_4 (unsigned char *p) +{ + grub_uint32_t val = (*p++ << 8); + val = (val + *p++) << 8; + val = (val + *p++) << 8; + return (val + *p); +} + +int +grub_ieee1275_finddevice (char *name, grub_ieee1275_phandle_t *phandlep) +{ + struct find_device_args { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_cell_t device; + grub_ieee1275_phandle_t phandle; + } args; + + INIT_IEEE1275_COMMON (&args.common, "finddevice", 1, 1); + args.device = (grub_ieee1275_cell_t) name; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + *phandlep = args.phandle; + return 0; +} + +int +grub_ieee1275_get_property (grub_ieee1275_phandle_t phandle, + const char *property, void *buf, + grub_size_t size, grub_ssize_t *actual) +{ + struct get_property_args { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_phandle_t phandle; + grub_ieee1275_cell_t prop; + grub_ieee1275_cell_t buf; + grub_ieee1275_cell_t buflen; + grub_ieee1275_cell_t size; + } args; + + INIT_IEEE1275_COMMON (&args.common, "getprop", 4, 1); + args.phandle = phandle; + args.prop = (grub_ieee1275_cell_t) property; + args.buf = (grub_ieee1275_cell_t) buf; + args.buflen = (grub_ieee1275_cell_t) size; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + if (actual) + *actual = (grub_ssize_t) args.size; + if (args.size == (grub_ieee1275_cell_t) -1) + return -1; + return 0; +} + +int +grub_ieee1275_next_property (grub_ieee1275_phandle_t phandle, char *prev_prop, + char *prop, grub_ieee1275_cell_t *flags) +{ + struct get_property_args { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_phandle_t phandle; + grub_ieee1275_cell_t prev_prop; + grub_ieee1275_cell_t next_prop; + grub_ieee1275_cell_t flags; + } args; + + INIT_IEEE1275_COMMON (&args.common, "nextprop", 3, 1); + args.phandle = phandle; + args.prev_prop = (grub_ieee1275_cell_t) prev_prop; + args.next_prop = (grub_ieee1275_cell_t) prop; + args.flags = (grub_ieee1275_cell_t) -1; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + if (flags) + *flags = args.flags; + return 0; +} + +int +grub_ieee1275_get_property_length (grub_ieee1275_phandle_t phandle, + const char *prop, grub_ssize_t *length) +{ + struct get_property_args { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_phandle_t phandle; + grub_ieee1275_cell_t prop; + grub_ieee1275_cell_t length; + } args; + + INIT_IEEE1275_COMMON (&args.common, "getproplen", 2, 1); + args.phandle = phandle; + args.prop = (grub_ieee1275_cell_t) prop; + args.length = (grub_ieee1275_cell_t) -1; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + *length = args.length; + return 0; +} + +int +grub_ieee1275_instance_to_package (grub_ieee1275_ihandle_t ihandle, + grub_ieee1275_phandle_t *phandlep) +{ + struct instance_to_package_args { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_ihandle_t ihandle; + grub_ieee1275_phandle_t phandle; + } args; + + INIT_IEEE1275_COMMON (&args.common, "instance-to-package", 1, 1); + args.ihandle = ihandle; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + *phandlep = args.phandle; + return 0; +} + +int +grub_ieee1275_package_to_path (grub_ieee1275_phandle_t phandle, + char *path, grub_size_t len, grub_ssize_t *actual) +{ + struct instance_to_package_args { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_phandle_t phandle; + grub_ieee1275_cell_t buf; + grub_ieee1275_cell_t buflen; + grub_ieee1275_cell_t actual; + } args; + + INIT_IEEE1275_COMMON (&args.common, "package-to-path", 3, 1); + args.phandle = phandle; + args.buf = (grub_ieee1275_cell_t) path; + args.buflen = (grub_ieee1275_cell_t) len; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + if (actual) + *actual = args.actual; + return 0; +} + +int +grub_ieee1275_instance_to_path (grub_ieee1275_ihandle_t ihandle, + char *path, grub_size_t len, + grub_ssize_t *actual) +{ + struct instance_to_package_args { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_ihandle_t ihandle; + grub_ieee1275_cell_t buf; + grub_ieee1275_cell_t buflen; + grub_ieee1275_cell_t actual; + } args; + + INIT_IEEE1275_COMMON (&args.common, "instance-to-path", 3, 1); + args.ihandle = ihandle; + args.buf = (grub_ieee1275_cell_t) path; + args.buflen = (grub_ieee1275_cell_t) len; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + if (actual) + *actual = args.actual; + return 0; +} + +int +grub_ieee1275_write (grub_ieee1275_ihandle_t ihandle, void *buffer, + grub_size_t len, grub_ssize_t *actualp) +{ + struct write_args { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_ihandle_t ihandle; + grub_ieee1275_cell_t buf; + grub_ieee1275_cell_t len; + grub_ieee1275_cell_t actual; + } args; + + INIT_IEEE1275_COMMON (&args.common, "write", 3, 1); + args.ihandle = ihandle; + args.buf = (grub_ieee1275_cell_t) buffer; + args.len = (grub_ieee1275_cell_t) len; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + if (actualp) + *actualp = args.actual; + return 0; +} + +int +grub_ieee1275_read (grub_ieee1275_ihandle_t ihandle, void *buffer, + grub_size_t len, grub_ssize_t *actualp) +{ + struct write_args { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_ihandle_t ihandle; + grub_ieee1275_cell_t buf; + grub_ieee1275_cell_t len; + grub_ieee1275_cell_t actual; + } args; + + INIT_IEEE1275_COMMON (&args.common, "read", 3, 1); + args.ihandle = ihandle; + args.buf = (grub_ieee1275_cell_t) buffer; + args.len = (grub_ieee1275_cell_t) len; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + if (actualp) + *actualp = args.actual; + return 0; +} + +int +grub_ieee1275_seek (grub_ieee1275_ihandle_t ihandle, int pos_hi, + int pos_lo, grub_ssize_t *result) +{ + struct write_args { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_ihandle_t ihandle; + grub_ieee1275_cell_t pos_hi; + grub_ieee1275_cell_t pos_lo; + grub_ieee1275_cell_t result; + } args; + + INIT_IEEE1275_COMMON (&args.common, "seek", 3, 1); + args.ihandle = ihandle; + args.pos_hi = (grub_ieee1275_cell_t) pos_hi; + args.pos_lo = (grub_ieee1275_cell_t) pos_lo; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + + if (result) + *result = args.result; + return 0; +} + +int +grub_ieee1275_peer (grub_ieee1275_phandle_t node, + grub_ieee1275_phandle_t *result) +{ + struct peer_args { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_phandle_t node; + grub_ieee1275_phandle_t result; + } args; + + INIT_IEEE1275_COMMON (&args.common, "peer", 1, 1); + args.node = node; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + *result = args.result; + return 0; +} + +int +grub_ieee1275_child (grub_ieee1275_phandle_t node, + grub_ieee1275_phandle_t *result) +{ + struct child_args { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_phandle_t node; + grub_ieee1275_phandle_t result; + } args; + + INIT_IEEE1275_COMMON (&args.common, "child", 1, 1); + args.node = node; + args.result = IEEE1275_PHANDLE_INVALID; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + *result = args.result; + return 0; +} + +int +grub_ieee1275_parent (grub_ieee1275_phandle_t node, + grub_ieee1275_phandle_t *result) +{ + struct parent_args { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_phandle_t node; + grub_ieee1275_phandle_t result; + } args; + + INIT_IEEE1275_COMMON (&args.common, "parent", 1, 1); + args.node = node; + args.result = IEEE1275_PHANDLE_INVALID; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + *result = args.result; + return 0; +} + +int +grub_ieee1275_interpret (const char *command, grub_ieee1275_cell_t *catch) +{ + struct enter_args { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_cell_t command; + grub_ieee1275_cell_t catch; + } args; + + INIT_IEEE1275_COMMON (&args.common, "interpret", 1, 1); + args.command = (grub_ieee1275_cell_t) command; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + if (catch) + *catch = args.catch; + return 0; +} + +int +grub_ieee1275_enter (void) +{ + struct enter_args { + struct grub_ieee1275_common_hdr common; + } args; + + INIT_IEEE1275_COMMON (&args.common, "enter", 0, 0); + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + return 0; +} + +int +grub_ieee1275_exit (void) +{ + struct exit_args { + struct grub_ieee1275_common_hdr common; + } args; + + INIT_IEEE1275_COMMON (&args.common, "exit", 0, 0); + + IEEE1275_CALL_ENTRY_FN (&args); + for (;;) ; +} + +int +grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result) +{ + struct open_args { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_cell_t path; + grub_ieee1275_ihandle_t result; + } args; + + INIT_IEEE1275_COMMON (&args.common, "open", 1, 1); + args.path = (grub_ieee1275_cell_t) path; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + *result = args.result; + return 0; +} + +int +grub_ieee1275_close (grub_ieee1275_ihandle_t ihandle) +{ + struct close_args { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_ihandle_t ihandle; + } args; + + INIT_IEEE1275_COMMON (&args.common, "close", 1, 0); + args.ihandle = ihandle; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + + return 0; +} + +int +grub_ieee1275_claim (grub_addr_t addr, grub_size_t size, unsigned int align, + grub_addr_t *result) +{ + struct claim_args { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_cell_t addr; + grub_ieee1275_cell_t size; + grub_ieee1275_cell_t align; + grub_ieee1275_cell_t base; + } args; + + INIT_IEEE1275_COMMON (&args.common, "claim", 3, 1); + args.addr = (grub_ieee1275_cell_t) addr; + args.size = (grub_ieee1275_cell_t) size; + args.align = (grub_ieee1275_cell_t) align; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + + if (result) + *result = args.base; + + if (args.base == (grub_ieee1275_cell_t)-1) + return -1; + + return 0; +} + +int +grub_ieee1275_release (grub_addr_t addr, grub_size_t size) +{ + struct release_args { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_cell_t addr; + grub_ieee1275_cell_t size; + } args; + + INIT_IEEE1275_COMMON (&args.common, "release", 2, 0); + args.addr = addr; + args.size = size; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + + return 0; +} + +int +grub_ieee1275_set_property (grub_ieee1275_phandle_t phandle, + const char *propname, void *buf, + grub_size_t size, grub_ssize_t *actual) +{ + struct set_property_args { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_phandle_t phandle; + grub_ieee1275_cell_t propname; + grub_ieee1275_cell_t buf; + grub_ieee1275_cell_t size; + grub_ieee1275_cell_t actual; + } args; + + INIT_IEEE1275_COMMON (&args.common, "setprop", 4, 1); + args.size = (grub_ieee1275_cell_t) size; + args.buf = (grub_ieee1275_cell_t) buf; + args.propname = (grub_ieee1275_cell_t) propname; + args.phandle = (grub_ieee1275_cell_t) phandle; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + *actual = args.actual; + return 0; +} + +int +grub_ieee1275_set_color (grub_ieee1275_ihandle_t ihandle, + int index, int r, int g, int b) +{ + struct set_color_args { + struct grub_ieee1275_common_hdr common; + char *method; + grub_ieee1275_ihandle_t ihandle; + grub_ieee1275_cell_t index; + grub_ieee1275_cell_t b; + grub_ieee1275_cell_t g; + grub_ieee1275_cell_t r; + grub_ieee1275_cell_t result; + } args; + + INIT_IEEE1275_COMMON (&args.common, "call-method", 6, 1); + args.method = "color!"; + args.ihandle = ihandle; + args.index = index; + args.r = r; + args.g = g; + args.b = b; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + + return 0; +} + +int +grub_ieee1275_milliseconds (grub_uint32_t *msecs) +{ + struct milliseconds_args { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_cell_t msecs; + } args; + + INIT_IEEE1275_COMMON (&args.common, "milliseconds", 0, 1); + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + *msecs = args.msecs; + return 0; +} Index: loader/powerpc/ieee1275/linux.c =================================================================== RCS file: /cvsroot/grub/grub2/loader/powerpc/ieee1275/linux.c,v retrieving revision 1.8 diff -u -p -r1.8 linux.c --- loader/powerpc/ieee1275/linux.c 12 Jul 2005 22:36:43 -0000 1.8 +++ loader/powerpc/ieee1275/linux.c 13 Jul 2005 00:54:34 -0000 @@ -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 ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: common ieee1275 code 2005-07-13 1:01 ` common ieee1275 code Hollis Blanchard @ 2005-07-13 16:13 ` Marco Gerards 2005-07-14 3:38 ` Hollis Blanchard 0 siblings, 1 reply; 29+ messages in thread From: Marco Gerards @ 2005-07-13 16:13 UTC (permalink / raw) To: The development of GRUB 2 Hollis Blanchard <hollis@penguinppc.org> writes: > 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 ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: common ieee1275 code 2005-07-13 16:13 ` Marco Gerards @ 2005-07-14 3:38 ` Hollis Blanchard 2005-07-14 9:55 ` Marco Gerards 2005-07-18 17:19 ` Marco Gerards 0 siblings, 2 replies; 29+ messages in thread From: Hollis Blanchard @ 2005-07-14 3:38 UTC (permalink / raw) To: The development of GRUB 2 [-- Attachment #1: Type: text/plain, Size: 3196 bytes --] On Jul 13, 2005, at 11:13 AM, Marco Gerards wrote: > Hollis Blanchard <hollis@penguinppc.org> writes: > >> 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. 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 <hollis@penguinppc.org> * 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'. [-- Attachment #2: grub-ieee1275.diff --] [-- Type: application/octet-stream, Size: 63116 bytes --] Index: boot/powerpc/ieee1275/cmain.c =================================================================== RCS file: /cvsroot/grub/grub2/boot/powerpc/ieee1275/cmain.c,v retrieving revision 1.10 diff -u -p -r1.10 cmain.c --- boot/powerpc/ieee1275/cmain.c 21 Jun 2005 03:12:15 -0000 1.10 +++ boot/powerpc/ieee1275/cmain.c 14 Jul 2005 03:06:09 -0000 @@ -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 diff -N boot/powerpc/ieee1275/ieee1275.c --- boot/powerpc/ieee1275/ieee1275.c 21 Jun 2005 02:33:51 -0000 1.12 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,533 +0,0 @@ -/* ieee1275.c - Access the Open Firmware client interface. */ -/* - * GRUB -- GRand Unified Bootloader - * Copyright (C) 2003, 2004, 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. - */ - -#include <grub/machine/ieee1275.h> - - -#define IEEE1275_PHANDLE_ROOT ((grub_ieee1275_phandle_t) 0) -#define IEEE1275_PHANDLE_INVALID ((grub_ieee1275_phandle_t) -1) - -intptr_t (*grub_ieee1275_entry_fn) (void *); - -/* FIXME is this function needed? */ -grub_uint32_t -grub_ieee1275_decode_int_4 (unsigned char *p) -{ - grub_uint32_t val = (*p++ << 8); - val = (val + *p++) << 8; - val = (val + *p++) << 8; - return (val + *p); -} - -\f -int -grub_ieee1275_finddevice (char *name, grub_ieee1275_phandle_t *phandlep) -{ - struct find_device_args { - struct grub_ieee1275_common_hdr common; - char *device; - grub_ieee1275_phandle_t phandle; - } args; - - INIT_IEEE1275_COMMON (&args.common, "finddevice", 1, 1); - args.device = name; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - *phandlep = args.phandle; - return 0; -} - -int -grub_ieee1275_get_property (grub_ieee1275_phandle_t phandle, - const char *property, void *buf, - grub_size_t size, grub_size_t *actual) -{ - struct get_property_args { - struct grub_ieee1275_common_hdr common; - grub_ieee1275_phandle_t phandle; - const char *prop; - void *buf; - int buflen; - int size; - } args; - - INIT_IEEE1275_COMMON (&args.common, "getprop", 4, 1); - args.phandle = phandle; - args.prop = property; - args.buf = buf; - args.buflen = size; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - if (actual) - *actual = args.size; - if (args.size == -1) - return -1; - return 0; -} - -int -grub_ieee1275_next_property (grub_ieee1275_phandle_t phandle, char *prev_prop, - char *prop, int *flags) -{ - struct get_property_args { - struct grub_ieee1275_common_hdr common; - grub_ieee1275_phandle_t phandle; - char *prev_prop; - char *next_prop; - int flags; - } args; - - INIT_IEEE1275_COMMON (&args.common, "nextprop", 3, 1); - args.phandle = phandle; - args.prev_prop = prev_prop; - args.next_prop = prop; - args.flags = -1; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - if (flags) - *flags = args.flags; - return 0; -} - -int -grub_ieee1275_get_property_length (grub_ieee1275_phandle_t phandle, - const char *prop, grub_size_t *length) -{ - struct get_property_args { - struct grub_ieee1275_common_hdr common; - grub_ieee1275_phandle_t phandle; - const char *prop; - grub_size_t length; - } args; - - INIT_IEEE1275_COMMON (&args.common, "getproplen", 2, 1); - args.phandle = phandle; - args.prop = prop; - args.length = -1; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - *length = args.length; - return 0; -} - -int -grub_ieee1275_instance_to_package (grub_ieee1275_ihandle_t ihandle, - grub_ieee1275_phandle_t *phandlep) -{ - struct instance_to_package_args { - struct grub_ieee1275_common_hdr common; - grub_ieee1275_ihandle_t ihandle; - grub_ieee1275_phandle_t phandle; - } args; - - INIT_IEEE1275_COMMON (&args.common, "instance-to-package", 1, 1); - args.ihandle = ihandle; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - *phandlep = args.phandle; - return 0; -} - -int -grub_ieee1275_package_to_path (grub_ieee1275_phandle_t phandle, - char *path, grub_size_t len, grub_size_t *actual) -{ - struct instance_to_package_args { - struct grub_ieee1275_common_hdr common; - grub_ieee1275_phandle_t phandle; - char *buf; - int buflen; - int actual; - } args; - - INIT_IEEE1275_COMMON (&args.common, "package-to-path", 3, 1); - args.phandle = phandle; - args.buf = path; - args.buflen = len; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - if (actual) - *actual = args.actual; - return 0; -} - -int -grub_ieee1275_instance_to_path (grub_ieee1275_ihandle_t ihandle, - char *path, grub_size_t len, - grub_size_t *actual) -{ - struct instance_to_package_args { - struct grub_ieee1275_common_hdr common; - grub_ieee1275_ihandle_t ihandle; - char *buf; - int buflen; - int actual; - } args; - - INIT_IEEE1275_COMMON (&args.common, "instance-to-path", 3, 1); - args.ihandle = ihandle; - args.buf = path; - args.buflen = len; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - if (actual) - *actual = args.actual; - return 0; -} - -int -grub_ieee1275_write (grub_ieee1275_ihandle_t ihandle, void *buffer, - grub_size_t len, grub_size_t *actualp) -{ - struct write_args { - struct grub_ieee1275_common_hdr common; - grub_ieee1275_ihandle_t ihandle; - void *buf; - grub_size_t len; - grub_size_t actual; - } args; - - INIT_IEEE1275_COMMON (&args.common, "write", 3, 1); - args.ihandle = ihandle; - args.buf = buffer; - args.len = len; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - if (actualp) - *actualp = args.actual; - return 0; -} - -int -grub_ieee1275_read (grub_ieee1275_ihandle_t ihandle, void *buffer, - grub_size_t len, grub_size_t *actualp) -{ - struct write_args { - struct grub_ieee1275_common_hdr common; - grub_ieee1275_ihandle_t ihandle; - void *buf; - grub_size_t len; - grub_size_t actual; - } args; - - INIT_IEEE1275_COMMON (&args.common, "read", 3, 1); - args.ihandle = ihandle; - args.buf = buffer; - args.len = len; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - if (actualp) - *actualp = args.actual; - return 0; -} - -int -grub_ieee1275_seek (grub_ieee1275_ihandle_t ihandle, int pos_hi, - int pos_lo, int *result) -{ - struct write_args { - struct grub_ieee1275_common_hdr common; - grub_ieee1275_ihandle_t ihandle; - int pos_hi; - int pos_lo; - int result; - } args; - - INIT_IEEE1275_COMMON (&args.common, "seek", 3, 1); - args.ihandle = ihandle; - args.pos_hi = pos_hi; - args.pos_lo = pos_lo; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - - if (result) - *result = args.result; - return 0; -} - -int -grub_ieee1275_peer (grub_ieee1275_phandle_t node, - grub_ieee1275_phandle_t *result) -{ - struct peer_args { - struct grub_ieee1275_common_hdr common; - grub_ieee1275_phandle_t node; - grub_ieee1275_phandle_t result; - } args; - - INIT_IEEE1275_COMMON (&args.common, "peer", 1, 1); - args.node = node; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - *result = args.result; - return 0; -} - -int -grub_ieee1275_child (grub_ieee1275_phandle_t node, - grub_ieee1275_phandle_t *result) -{ - struct child_args { - struct grub_ieee1275_common_hdr common; - grub_ieee1275_phandle_t node; - grub_ieee1275_phandle_t result; - } args; - - INIT_IEEE1275_COMMON (&args.common, "child", 1, 1); - args.node = node; - args.result = IEEE1275_PHANDLE_INVALID; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - *result = args.result; - return 0; -} - -int -grub_ieee1275_parent (grub_ieee1275_phandle_t node, - grub_ieee1275_phandle_t *result) -{ - struct parent_args { - struct grub_ieee1275_common_hdr common; - grub_ieee1275_phandle_t node; - grub_ieee1275_phandle_t result; - } args; - - INIT_IEEE1275_COMMON (&args.common, "parent", 1, 1); - args.node = node; - args.result = IEEE1275_PHANDLE_INVALID; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - *result = args.result; - return 0; -} - -int -grub_ieee1275_interpret (const char *command, int *catch) -{ - struct enter_args { - struct grub_ieee1275_common_hdr common; - const char *command; - int catch; - } args; - - INIT_IEEE1275_COMMON (&args.common, "interpret", 1, 1); - args.command = command; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - if (catch) - *catch = args.catch; - return 0; -} - -int -grub_ieee1275_enter (void) -{ - struct enter_args { - struct grub_ieee1275_common_hdr common; - } args; - - INIT_IEEE1275_COMMON (&args.common, "enter", 0, 0); - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - return 0; -} - -int -grub_ieee1275_exit (void) -{ - struct exit_args { - struct grub_ieee1275_common_hdr common; - } args; - - INIT_IEEE1275_COMMON (&args.common, "exit", 0, 0); - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - return 0; -} - -int -grub_ieee1275_open (char *node, grub_ieee1275_ihandle_t *result) -{ - struct open_args { - struct grub_ieee1275_common_hdr common; - char *cstr; - grub_ieee1275_ihandle_t result; - } args; - - INIT_IEEE1275_COMMON (&args.common, "open", 1, 1); - args.cstr = node; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - *result = args.result; - return 0; -} - -int -grub_ieee1275_close (grub_ieee1275_ihandle_t ihandle) -{ - struct close_args { - struct grub_ieee1275_common_hdr common; - grub_ieee1275_ihandle_t ihandle; - } args; - - INIT_IEEE1275_COMMON (&args.common, "close", 1, 0); - args.ihandle = ihandle; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - - return 0; -} - -int -grub_ieee1275_claim (grub_addr_t addr, grub_size_t size, unsigned int align, - grub_addr_t *result) -{ - struct claim_args { - struct grub_ieee1275_common_hdr common; - grub_addr_t addr; - grub_size_t size; - unsigned int align; - grub_addr_t base; - } args; - - INIT_IEEE1275_COMMON (&args.common, "claim", 3, 1); - args.addr = addr; - args.size = size; - args.align = align; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - - if (result) - *result = args.base; - - if (args.base == (grub_addr_t)-1) - return -1; - - return 0; -} - -int -grub_ieee1275_release (grub_addr_t addr, grub_size_t size) -{ - struct release_args { - struct grub_ieee1275_common_hdr common; - grub_addr_t addr; - grub_size_t size; - } args; - - INIT_IEEE1275_COMMON (&args.common, "release", 2, 0); - args.addr = addr; - args.size = size; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - - return 0; -} - -int -grub_ieee1275_set_property (grub_ieee1275_phandle_t phandle, - const char *propname, void *buf, - grub_size_t size, grub_size_t *actual) -{ - struct set_property_args { - struct grub_ieee1275_common_hdr common; - grub_ieee1275_phandle_t phandle; - const char *propname; - void *buf; - grub_size_t size; - grub_size_t actual; - } args; - - INIT_IEEE1275_COMMON (&args.common, "setprop", 4, 1); - args.size = size; - args.buf = buf; - args.propname = propname; - args.phandle = phandle; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - *actual = args.actual; - return 0; -} - -int -grub_ieee1275_set_color (grub_ieee1275_ihandle_t ihandle, - int index, int r, int g, int b) -{ - struct set_color_args { - struct grub_ieee1275_common_hdr common; - char *method; - grub_ieee1275_ihandle_t ihandle; - int index; - int b; - int g; - int r; - int result; - } args; - - INIT_IEEE1275_COMMON (&args.common, "call-method", 6, 1); - args.method = "color!"; - args.ihandle = ihandle; - args.index = index; - args.r = r; - args.g = g; - args.b = b; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - - return 0; -} - -int -grub_ieee1275_milliseconds (grub_uint32_t *msecs) -{ - struct milliseconds_args { - struct grub_ieee1275_common_hdr common; - grub_uint32_t msecs; - } args; - - INIT_IEEE1275_COMMON (&args.common, "milliseconds", 0, 1); - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - *msecs = args.msecs; - return 0; -} Index: commands/ieee1275/halt.c =================================================================== RCS file: /cvsroot/grub/grub2/commands/ieee1275/halt.c,v retrieving revision 1.2 diff -u -p -r1.2 halt.c --- commands/ieee1275/halt.c 26 Mar 2005 17:34:50 -0000 1.2 +++ commands/ieee1275/halt.c 14 Jul 2005 03:06:09 -0000 @@ -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 diff -u -p -r1.2 reboot.c --- commands/ieee1275/reboot.c 26 Mar 2005 17:34:50 -0000 1.2 +++ commands/ieee1275/reboot.c 14 Jul 2005 03:06:09 -0000 @@ -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 diff -u -p -r1.2 suspend.c --- commands/ieee1275/suspend.c 31 Jan 2005 21:28:34 -0000 1.2 +++ commands/ieee1275/suspend.c 14 Jul 2005 03:06:09 -0000 @@ -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 diff -u -p -r1.30 powerpc-ieee1275.rmk --- conf/powerpc-ieee1275.rmk 1 May 2005 03:45:35 -0000 1.30 +++ conf/powerpc-ieee1275.rmk 14 Jul 2005 03:06:09 -0000 @@ -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 diff -N disk/powerpc/ieee1275/ofdisk.c --- disk/powerpc/ieee1275/ofdisk.c 12 Jul 2005 22:36:43 -0000 1.10 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,182 +0,0 @@ -/* ofdisk.c - Open Firmware disk access. */ -/* - * 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. - */ - -#include <grub/misc.h> -#include <grub/disk.h> -#include <grub/mm.h> -#include <grub/machine/ieee1275.h> -#include <grub/machine/ofdisk.h> - -static int -grub_ofdisk_iterate (int (*hook) (const char *name)) -{ - auto int dev_iterate (struct grub_ieee1275_devalias *alias); - - int dev_iterate (struct grub_ieee1275_devalias *alias) - { - if (! grub_strcmp (alias->type, "block")) - hook (alias->name); - else if ((! grub_strcmp (alias->type, "scsi")) - || (! grub_strcmp (alias->type, "ide")) - || (! grub_strcmp (alias->type, "ata"))) - /* Search for block-type children of these bus controllers. */ - grub_children_iterate (alias->name, dev_iterate); - return 0; - } - - grub_devalias_iterate (dev_iterate); - return 0; -} - -static grub_err_t -grub_ofdisk_open (const char *name, grub_disk_t disk) -{ - grub_ieee1275_phandle_t dev; - grub_ieee1275_ihandle_t dev_ihandle = 0; - char *devpath; - /* XXX: This should be large enough for any possible case. */ - char prop[64]; - int 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_dprintf ("disk", "Opening `%s'.\n", devpath); - - grub_ieee1275_open (devpath, &dev_ihandle); - if (! dev_ihandle) - { - grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Can't open device"); - goto fail; - } - - grub_dprintf ("disk", "Opened `%s' as handle 0x%x.\n", devpath, dev_ihandle); - - if (grub_ieee1275_finddevice (devpath, &dev)) - { - grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Can't read device properties"); - goto fail; - } - - if (grub_ieee1275_get_property (dev, "device_type", prop, sizeof (prop), - &actual)) - { - grub_error (GRUB_ERR_BAD_DEVICE, "Can't read the device type"); - goto fail; - } - - if (grub_strcmp (prop, "block")) - { - grub_error (GRUB_ERR_BAD_DEVICE, "Not a block device"); - goto fail; - } - - /* XXX: There is no property to read the number of blocks. There - should be a property `#blocks', but it is not there. Perhaps it - is possible to use seek for this. */ - disk->total_sectors = 0xFFFFFFFFUL; - - /* XXX: Is it ok to use this? Perhaps it is better to use the path - or some property. */ - disk->id = dev; - - /* XXX: Read this, somehow. */ - disk->has_partitions = 1; - disk->data = (void *) dev_ihandle; - - fail: - if (grub_errno && dev_ihandle) - grub_ieee1275_close (dev_ihandle); - grub_free (devpath); - return grub_errno; -} - -static void -grub_ofdisk_close (grub_disk_t disk) -{ - grub_dprintf ("disk", "Closing handle 0x%x.\n", - (grub_ieee1275_ihandle_t) disk->data); - grub_ieee1275_close ((grub_ieee1275_ihandle_t) disk->data); -} - -static grub_err_t -grub_ofdisk_read (grub_disk_t disk, unsigned long sector, - unsigned long size, char *buf) -{ - int status; - int actual; - unsigned long long pos; - - grub_dprintf ("disk", - "Reading handle 0x%x: sector 0x%lx, size 0x%lx, buf %p.\n", - (grub_ieee1275_ihandle_t) disk->data, sector, size, buf); - - pos = (unsigned long long) sector * 512UL; - - grub_ieee1275_seek ((grub_ieee1275_ihandle_t) disk->data, (int) (pos >> 32), - (int) pos & 0xFFFFFFFFUL, &status); - if (status != 0) - return grub_error (GRUB_ERR_READ_ERROR, - "Seek error, can't seek block %d", sector); - grub_ieee1275_read ((grub_ieee1275_ihandle_t) disk->data, buf, - size * 512UL, &actual); - if (actual != actual) - return grub_error (GRUB_ERR_READ_ERROR, "Read error on block: %d", sector); - - return 0; -} - -static grub_err_t -grub_ofdisk_write (grub_disk_t disk __attribute ((unused)), - unsigned long sector __attribute ((unused)), - unsigned long size __attribute ((unused)), - const char *buf __attribute ((unused))) -{ - return GRUB_ERR_NOT_IMPLEMENTED_YET; -} - -static struct grub_disk_dev grub_ofdisk_dev = - { - .name = "ofdisk", - .id = GRUB_DISK_DEVICE_OFDISK_ID, - .iterate = grub_ofdisk_iterate, - .open = grub_ofdisk_open, - .close = grub_ofdisk_close, - .read = grub_ofdisk_read, - .write = grub_ofdisk_write, - .next = 0 - }; - -void -grub_ofdisk_init (void) -{ - grub_disk_dev_register (&grub_ofdisk_dev); -} - -void -grub_ofdisk_fini (void) -{ - grub_disk_dev_unregister (&grub_ofdisk_dev); -} Index: include/grub/i386/pc/console.h =================================================================== RCS file: include/grub/i386/pc/console.h diff -N include/grub/i386/pc/console.h --- include/grub/i386/pc/console.h 15 Feb 2005 00:07:01 -0000 1.5 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,59 +0,0 @@ -/* - * GRUB -- GRand Unified Bootloader - * Copyright (C) 2002,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_CONSOLE_MACHINE_HEADER -#define GRUB_CONSOLE_MACHINE_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 - -#ifndef ASM_FILE - -#include <grub/types.h> -#include <grub/symbol.h> - -/* These are global to share code between C and asm. */ -extern grub_uint8_t grub_console_cur_color; -void grub_console_real_putchar (int c); -int EXPORT_FUNC(grub_console_checkkey) (void); -int EXPORT_FUNC(grub_console_getkey) (void); -grub_uint16_t grub_console_getxy (void); -void grub_console_gotoxy (grub_uint8_t x, grub_uint8_t y); -void grub_console_cls (void); -void grub_console_setcursor (int on); - -/* Initialize the console system. */ -void grub_console_init (void); - -/* Finish the console system. */ -void grub_console_fini (void); - -#endif - -#endif /* ! GRUB_CONSOLE_MACHINE_HEADER */ Index: include/grub/powerpc/ieee1275/console.h =================================================================== RCS file: include/grub/powerpc/ieee1275/console.h diff -N include/grub/powerpc/ieee1275/console.h --- include/grub/powerpc/ieee1275/console.h 26 Mar 2005 17:34:50 -0000 1.3 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,59 +0,0 @@ -/* - * 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_MACHINE_HEADER -#define GRUB_CONSOLE_MACHINE_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 - -#ifndef ASM_FILE - -#include <grub/types.h> -#include <grub/symbol.h> - -/* These are global to share code between C and asm. */ -extern grub_uint8_t grub_console_cur_color; -void grub_console_real_putchar (int c); -int EXPORT_FUNC(grub_console_checkkey) (void); -int EXPORT_FUNC(grub_console_getkey) (void); -grub_uint16_t grub_console_getxy (void); -void grub_console_gotoxy (grub_uint8_t x, grub_uint8_t y); -void grub_console_cls (void); -void grub_console_setcursor (int on); - -/* Initialize the console system. */ -void grub_console_init (void); - -/* Finish the console system. */ -void grub_console_fini (void); - -#endif - -#endif /* ! GRUB_CONSOLE_MACHINE_HEADER */ Index: include/grub/powerpc/ieee1275/ieee1275.h =================================================================== RCS file: /cvsroot/grub/grub2/include/grub/powerpc/ieee1275/ieee1275.h,v retrieving revision 1.18 diff -u -p -r1.18 ieee1275.h --- include/grub/powerpc/ieee1275/ieee1275.h 21 Jun 2005 02:33:51 -0000 1.18 +++ include/grub/powerpc/ieee1275/ieee1275.h 14 Jul 2005 03:06:09 -0000 @@ -21,134 +21,8 @@ #ifndef GRUB_IEEE1275_MACHINE_HEADER #define GRUB_IEEE1275_MACHINE_HEADER 1 -#include <stdint.h> -#include <grub/err.h> #include <grub/types.h> -/* Maps a device alias to a pathname. */ -struct grub_ieee1275_devalias -{ - char *name; - char *path; - char *type; -}; - -struct grub_ieee1275_mem_region -{ - unsigned int start; - unsigned int size; -}; - -#ifndef IEEE1275_CALL_ENTRY_FN -#define IEEE1275_CALL_ENTRY_FN(args) (*grub_ieee1275_entry_fn) (args) -#endif - -/* All backcalls to the firmware is done by calling an entry function - which was passed to us from the bootloader. When doing the backcall, - a structure is passed which specifies what the firmware should do. - NAME is the requested service. NR_INS and NR_OUTS is the number of - passed arguments and the expected number of return values, resp. */ -struct grub_ieee1275_common_hdr -{ - char *name; - int nr_ins; - int nr_outs; -}; - -#define INIT_IEEE1275_COMMON(p, xname, xins, xouts) \ - (p)->name = xname; (p)->nr_ins = xins; (p)->nr_outs = xouts - -/* FIXME jrydberg: is this correct cell types? */ -typedef intptr_t grub_ieee1275_ihandle_t; -typedef intptr_t grub_ieee1275_phandle_t; - -extern grub_ieee1275_phandle_t grub_ieee1275_chosen; -extern grub_ieee1275_phandle_t EXPORT_VAR(grub_ieee1275_chosen); -extern intptr_t (*grub_ieee1275_entry_fn) (void *); -extern intptr_t (* EXPORT_VAR(grub_ieee1275_entry_fn)) (void *); - -enum grub_ieee1275_flag -{ - /* Old World firmware fails seek when "dev:0" is opened. */ - GRUB_IEEE1275_FLAG_NO_PARTITION_0, - - /* Apple firmware runs in translated mode and requires use of the "map" - method. Other firmware runs in untranslated mode and doesn't like "map" - calls. */ - GRUB_IEEE1275_FLAG_REAL_MODE, - - /* CHRP specifies partitions are numbered from 1 (partition 0 refers to the - whole disk). However, CodeGen firmware numbers partitions from 0. */ - GRUB_IEEE1275_FLAG_0_BASED_PARTITIONS, -}; - -extern int EXPORT_FUNC(grub_ieee1275_test_flag) (enum grub_ieee1275_flag flag); -extern void EXPORT_FUNC(grub_ieee1275_set_flag) (enum grub_ieee1275_flag flag); - -\f - -uint32_t EXPORT_FUNC(grub_ieee1275_decode_int_4) (unsigned char *p); -int EXPORT_FUNC(grub_ieee1275_finddevice) (char *name, - grub_ieee1275_phandle_t *phandlep); -int EXPORT_FUNC(grub_ieee1275_get_property) (grub_ieee1275_phandle_t handle, - const char *property, void *buf, - grub_size_t size, - grub_size_t *actual); -int EXPORT_FUNC(grub_ieee1275_next_property) (int handle, char *prev_prop, - char *prop, int *flags); -int EXPORT_FUNC(grub_ieee1275_get_property_length) - (grub_ieee1275_phandle_t handle, const char *prop, grub_size_t *length); -int EXPORT_FUNC(grub_ieee1275_instance_to_package) - (grub_ieee1275_ihandle_t ihandle, grub_ieee1275_phandle_t *phandlep); -int EXPORT_FUNC(grub_ieee1275_package_to_path) (grub_ieee1275_phandle_t phandle, - char *path, grub_size_t len, - grub_size_t *actual); -int EXPORT_FUNC(grub_ieee1275_instance_to_path) - (grub_ieee1275_ihandle_t ihandle, char *path, grub_size_t len, - grub_size_t *actual); -int EXPORT_FUNC(grub_ieee1275_write) (grub_ieee1275_ihandle_t ihandle, - void *buffer, grub_size_t len, - grub_size_t *actualp); -int EXPORT_FUNC(grub_ieee1275_read) (grub_ieee1275_ihandle_t ihandle, - void *buffer, grub_size_t len, - grub_size_t *actualp); -int EXPORT_FUNC(grub_ieee1275_seek) (grub_ieee1275_ihandle_t ihandle, - int pos_hi, int pos_lo, int *result); -int EXPORT_FUNC(grub_ieee1275_peer) (grub_ieee1275_phandle_t node, - grub_ieee1275_phandle_t *result); -int EXPORT_FUNC(grub_ieee1275_child) (grub_ieee1275_phandle_t node, - grub_ieee1275_phandle_t *result); -int EXPORT_FUNC(grub_ieee1275_parent) (grub_ieee1275_phandle_t node, - grub_ieee1275_phandle_t *result); -int EXPORT_FUNC(grub_ieee1275_interpret) (const char *command, int *catch); -int EXPORT_FUNC(grub_ieee1275_enter) (void); -int EXPORT_FUNC(grub_ieee1275_exit) (void); -int EXPORT_FUNC(grub_ieee1275_open) (char *node, - grub_ieee1275_ihandle_t *result); -int EXPORT_FUNC(grub_ieee1275_close) (grub_ieee1275_ihandle_t ihandle); -int EXPORT_FUNC(grub_ieee1275_claim) (grub_addr_t addr, grub_size_t size, - unsigned int align, grub_addr_t *result); -int EXPORT_FUNC(grub_ieee1275_release) (grub_addr_t addr, grub_size_t size); -int EXPORT_FUNC(grub_ieee1275_set_property) (grub_ieee1275_phandle_t phandle, - const char *propname, void *buf, - grub_size_t size, - grub_size_t *actual); -int EXPORT_FUNC(grub_ieee1275_set_color) (grub_ieee1275_ihandle_t ihandle, - int index, int r, int g, int b); -int EXPORT_FUNC(grub_ieee1275_milliseconds) (grub_uint32_t *msecs); - - -grub_err_t EXPORT_FUNC(grub_devalias_iterate) - (int (*hook) (struct grub_ieee1275_devalias *alias)); -grub_err_t EXPORT_FUNC(grub_children_iterate) (char *devpath, - int (*hook) (struct grub_ieee1275_devalias *alias)); -int EXPORT_FUNC(grub_claimmap) (grub_addr_t addr, grub_size_t size); - -void EXPORT_FUNC(abort) (void); -void EXPORT_FUNC (grub_reboot) (void); -void EXPORT_FUNC (grub_halt) (void); - -char *EXPORT_FUNC(grub_ieee1275_encode_devname) (const char *path); -char *EXPORT_FUNC(grub_ieee1275_get_filename) (const char *path); +typedef grub_uint32_t grub_ieee1275_cell_t; #endif /* ! GRUB_IEEE1275_MACHINE_HEADER */ Index: include/grub/powerpc/ieee1275/kernel.h =================================================================== RCS file: /cvsroot/grub/grub2/include/grub/powerpc/ieee1275/kernel.h,v retrieving revision 1.2 diff -u -p -r1.2 kernel.h --- include/grub/powerpc/ieee1275/kernel.h 21 Jun 2005 02:33:51 -0000 1.2 +++ include/grub/powerpc/ieee1275/kernel.h 14 Jul 2005 03:06:09 -0000 @@ -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 diff -N include/grub/powerpc/ieee1275/ofdisk.h --- include/grub/powerpc/ieee1275/ofdisk.h 1 May 2005 03:45:35 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -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 diff -N kern/ieee1275.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ kern/ieee1275.c 14 Jul 2005 03:06:10 -0000 @@ -0,0 +1,530 @@ +/* ieee1275.c - Access the Open Firmware client interface. */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2003, 2004, 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. + */ + +#include <grub/ieee1275/ieee1275.h> + +#define IEEE1275_PHANDLE_ROOT ((grub_ieee1275_phandle_t) 0) +#define IEEE1275_PHANDLE_INVALID ((grub_ieee1275_phandle_t) -1) + +\f + +/* FIXME is this function needed? */ +grub_uint32_t +grub_ieee1275_decode_int_4 (unsigned char *p) +{ + grub_uint32_t val = (*p++ << 8); + val = (val + *p++) << 8; + val = (val + *p++) << 8; + return (val + *p); +} + +int +grub_ieee1275_finddevice (char *name, grub_ieee1275_phandle_t *phandlep) +{ + struct find_device_args { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_cell_t device; + grub_ieee1275_phandle_t phandle; + } args; + + INIT_IEEE1275_COMMON (&args.common, "finddevice", 1, 1); + args.device = (grub_ieee1275_cell_t) name; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + *phandlep = args.phandle; + return 0; +} + +int +grub_ieee1275_get_property (grub_ieee1275_phandle_t phandle, + const char *property, void *buf, + grub_size_t size, grub_ssize_t *actual) +{ + struct get_property_args { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_phandle_t phandle; + grub_ieee1275_cell_t prop; + grub_ieee1275_cell_t buf; + grub_ieee1275_cell_t buflen; + grub_ieee1275_cell_t size; + } args; + + INIT_IEEE1275_COMMON (&args.common, "getprop", 4, 1); + args.phandle = phandle; + args.prop = (grub_ieee1275_cell_t) property; + args.buf = (grub_ieee1275_cell_t) buf; + args.buflen = (grub_ieee1275_cell_t) size; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + if (actual) + *actual = (grub_ssize_t) args.size; + if (args.size == (grub_ieee1275_cell_t) -1) + return -1; + return 0; +} + +int +grub_ieee1275_next_property (grub_ieee1275_phandle_t phandle, char *prev_prop, + char *prop, grub_ieee1275_cell_t *flags) +{ + struct get_property_args { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_phandle_t phandle; + grub_ieee1275_cell_t prev_prop; + grub_ieee1275_cell_t next_prop; + grub_ieee1275_cell_t flags; + } args; + + INIT_IEEE1275_COMMON (&args.common, "nextprop", 3, 1); + args.phandle = phandle; + args.prev_prop = (grub_ieee1275_cell_t) prev_prop; + args.next_prop = (grub_ieee1275_cell_t) prop; + args.flags = (grub_ieee1275_cell_t) -1; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + if (flags) + *flags = args.flags; + return 0; +} + +int +grub_ieee1275_get_property_length (grub_ieee1275_phandle_t phandle, + const char *prop, grub_ssize_t *length) +{ + struct get_property_args { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_phandle_t phandle; + grub_ieee1275_cell_t prop; + grub_ieee1275_cell_t length; + } args; + + INIT_IEEE1275_COMMON (&args.common, "getproplen", 2, 1); + args.phandle = phandle; + args.prop = (grub_ieee1275_cell_t) prop; + args.length = (grub_ieee1275_cell_t) -1; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + *length = args.length; + return 0; +} + +int +grub_ieee1275_instance_to_package (grub_ieee1275_ihandle_t ihandle, + grub_ieee1275_phandle_t *phandlep) +{ + struct instance_to_package_args { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_ihandle_t ihandle; + grub_ieee1275_phandle_t phandle; + } args; + + INIT_IEEE1275_COMMON (&args.common, "instance-to-package", 1, 1); + args.ihandle = ihandle; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + *phandlep = args.phandle; + return 0; +} + +int +grub_ieee1275_package_to_path (grub_ieee1275_phandle_t phandle, + char *path, grub_size_t len, grub_ssize_t *actual) +{ + struct instance_to_package_args { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_phandle_t phandle; + grub_ieee1275_cell_t buf; + grub_ieee1275_cell_t buflen; + grub_ieee1275_cell_t actual; + } args; + + INIT_IEEE1275_COMMON (&args.common, "package-to-path", 3, 1); + args.phandle = phandle; + args.buf = (grub_ieee1275_cell_t) path; + args.buflen = (grub_ieee1275_cell_t) len; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + if (actual) + *actual = args.actual; + return 0; +} + +int +grub_ieee1275_instance_to_path (grub_ieee1275_ihandle_t ihandle, + char *path, grub_size_t len, + grub_ssize_t *actual) +{ + struct instance_to_package_args { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_ihandle_t ihandle; + grub_ieee1275_cell_t buf; + grub_ieee1275_cell_t buflen; + grub_ieee1275_cell_t actual; + } args; + + INIT_IEEE1275_COMMON (&args.common, "instance-to-path", 3, 1); + args.ihandle = ihandle; + args.buf = (grub_ieee1275_cell_t) path; + args.buflen = (grub_ieee1275_cell_t) len; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + if (actual) + *actual = args.actual; + return 0; +} + +int +grub_ieee1275_write (grub_ieee1275_ihandle_t ihandle, void *buffer, + grub_size_t len, grub_ssize_t *actualp) +{ + struct write_args { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_ihandle_t ihandle; + grub_ieee1275_cell_t buf; + grub_ieee1275_cell_t len; + grub_ieee1275_cell_t actual; + } args; + + INIT_IEEE1275_COMMON (&args.common, "write", 3, 1); + args.ihandle = ihandle; + args.buf = (grub_ieee1275_cell_t) buffer; + args.len = (grub_ieee1275_cell_t) len; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + if (actualp) + *actualp = args.actual; + return 0; +} + +int +grub_ieee1275_read (grub_ieee1275_ihandle_t ihandle, void *buffer, + grub_size_t len, grub_ssize_t *actualp) +{ + struct write_args { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_ihandle_t ihandle; + grub_ieee1275_cell_t buf; + grub_ieee1275_cell_t len; + grub_ieee1275_cell_t actual; + } args; + + INIT_IEEE1275_COMMON (&args.common, "read", 3, 1); + args.ihandle = ihandle; + args.buf = (grub_ieee1275_cell_t) buffer; + args.len = (grub_ieee1275_cell_t) len; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + if (actualp) + *actualp = args.actual; + return 0; +} + +int +grub_ieee1275_seek (grub_ieee1275_ihandle_t ihandle, int pos_hi, + int pos_lo, grub_ssize_t *result) +{ + struct write_args { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_ihandle_t ihandle; + grub_ieee1275_cell_t pos_hi; + grub_ieee1275_cell_t pos_lo; + grub_ieee1275_cell_t result; + } args; + + INIT_IEEE1275_COMMON (&args.common, "seek", 3, 1); + args.ihandle = ihandle; + args.pos_hi = (grub_ieee1275_cell_t) pos_hi; + args.pos_lo = (grub_ieee1275_cell_t) pos_lo; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + + if (result) + *result = args.result; + return 0; +} + +int +grub_ieee1275_peer (grub_ieee1275_phandle_t node, + grub_ieee1275_phandle_t *result) +{ + struct peer_args { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_phandle_t node; + grub_ieee1275_phandle_t result; + } args; + + INIT_IEEE1275_COMMON (&args.common, "peer", 1, 1); + args.node = node; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + *result = args.result; + return 0; +} + +int +grub_ieee1275_child (grub_ieee1275_phandle_t node, + grub_ieee1275_phandle_t *result) +{ + struct child_args { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_phandle_t node; + grub_ieee1275_phandle_t result; + } args; + + INIT_IEEE1275_COMMON (&args.common, "child", 1, 1); + args.node = node; + args.result = IEEE1275_PHANDLE_INVALID; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + *result = args.result; + return 0; +} + +int +grub_ieee1275_parent (grub_ieee1275_phandle_t node, + grub_ieee1275_phandle_t *result) +{ + struct parent_args { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_phandle_t node; + grub_ieee1275_phandle_t result; + } args; + + INIT_IEEE1275_COMMON (&args.common, "parent", 1, 1); + args.node = node; + args.result = IEEE1275_PHANDLE_INVALID; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + *result = args.result; + return 0; +} + +int +grub_ieee1275_interpret (const char *command, grub_ieee1275_cell_t *catch) +{ + struct enter_args { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_cell_t command; + grub_ieee1275_cell_t catch; + } args; + + INIT_IEEE1275_COMMON (&args.common, "interpret", 1, 1); + args.command = (grub_ieee1275_cell_t) command; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + if (catch) + *catch = args.catch; + return 0; +} + +int +grub_ieee1275_enter (void) +{ + struct enter_args { + struct grub_ieee1275_common_hdr common; + } args; + + INIT_IEEE1275_COMMON (&args.common, "enter", 0, 0); + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + return 0; +} + +int +grub_ieee1275_exit (void) +{ + struct exit_args { + struct grub_ieee1275_common_hdr common; + } args; + + INIT_IEEE1275_COMMON (&args.common, "exit", 0, 0); + + IEEE1275_CALL_ENTRY_FN (&args); + for (;;) ; +} + +int +grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result) +{ + struct open_args { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_cell_t path; + grub_ieee1275_ihandle_t result; + } args; + + INIT_IEEE1275_COMMON (&args.common, "open", 1, 1); + args.path = (grub_ieee1275_cell_t) path; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + *result = args.result; + return 0; +} + +int +grub_ieee1275_close (grub_ieee1275_ihandle_t ihandle) +{ + struct close_args { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_ihandle_t ihandle; + } args; + + INIT_IEEE1275_COMMON (&args.common, "close", 1, 0); + args.ihandle = ihandle; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + + return 0; +} + +int +grub_ieee1275_claim (grub_addr_t addr, grub_size_t size, unsigned int align, + grub_addr_t *result) +{ + struct claim_args { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_cell_t addr; + grub_ieee1275_cell_t size; + grub_ieee1275_cell_t align; + grub_ieee1275_cell_t base; + } args; + + INIT_IEEE1275_COMMON (&args.common, "claim", 3, 1); + args.addr = (grub_ieee1275_cell_t) addr; + args.size = (grub_ieee1275_cell_t) size; + args.align = (grub_ieee1275_cell_t) align; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + + if (result) + *result = args.base; + + if (args.base == (grub_ieee1275_cell_t)-1) + return -1; + + return 0; +} + +int +grub_ieee1275_release (grub_addr_t addr, grub_size_t size) +{ + struct release_args { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_cell_t addr; + grub_ieee1275_cell_t size; + } args; + + INIT_IEEE1275_COMMON (&args.common, "release", 2, 0); + args.addr = addr; + args.size = size; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + + return 0; +} + +int +grub_ieee1275_set_property (grub_ieee1275_phandle_t phandle, + const char *propname, void *buf, + grub_size_t size, grub_ssize_t *actual) +{ + struct set_property_args { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_phandle_t phandle; + grub_ieee1275_cell_t propname; + grub_ieee1275_cell_t buf; + grub_ieee1275_cell_t size; + grub_ieee1275_cell_t actual; + } args; + + INIT_IEEE1275_COMMON (&args.common, "setprop", 4, 1); + args.size = (grub_ieee1275_cell_t) size; + args.buf = (grub_ieee1275_cell_t) buf; + args.propname = (grub_ieee1275_cell_t) propname; + args.phandle = (grub_ieee1275_cell_t) phandle; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + *actual = args.actual; + return 0; +} + +int +grub_ieee1275_set_color (grub_ieee1275_ihandle_t ihandle, + int index, int r, int g, int b) +{ + struct set_color_args { + struct grub_ieee1275_common_hdr common; + char *method; + grub_ieee1275_ihandle_t ihandle; + grub_ieee1275_cell_t index; + grub_ieee1275_cell_t b; + grub_ieee1275_cell_t g; + grub_ieee1275_cell_t r; + grub_ieee1275_cell_t result; + } args; + + INIT_IEEE1275_COMMON (&args.common, "call-method", 6, 1); + args.method = "color!"; + args.ihandle = ihandle; + args.index = index; + args.r = r; + args.g = g; + args.b = b; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + + return 0; +} + +int +grub_ieee1275_milliseconds (grub_uint32_t *msecs) +{ + struct milliseconds_args { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_cell_t msecs; + } args; + + INIT_IEEE1275_COMMON (&args.common, "milliseconds", 0, 1); + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + *msecs = args.msecs; + return 0; +} Index: kern/powerpc/ieee1275/init.c =================================================================== RCS file: /cvsroot/grub/grub2/kern/powerpc/ieee1275/init.c,v retrieving revision 1.19 diff -u -p -r1.19 init.c --- kern/powerpc/ieee1275/init.c 21 Jun 2005 02:33:51 -0000 1.19 +++ kern/powerpc/ieee1275/init.c 14 Jul 2005 03:06:10 -0000 @@ -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 diff -u -p -r1.11 openfw.c --- kern/powerpc/ieee1275/openfw.c 21 Jun 2005 02:33:51 -0000 1.11 +++ kern/powerpc/ieee1275/openfw.c 14 Jul 2005 03:06:10 -0000 @@ -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 diff -u -p -r1.8 linux.c --- loader/powerpc/ieee1275/linux.c 12 Jul 2005 22:36:43 -0000 1.8 +++ loader/powerpc/ieee1275/linux.c 14 Jul 2005 03:06:10 -0000 @@ -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 diff -N term/powerpc/ieee1275/ofconsole.c --- term/powerpc/ieee1275/ofconsole.c 21 Jun 2005 02:33:52 -0000 1.7 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,311 +0,0 @@ -/* ofconsole.c -- Open Firmware console for GRUB. */ -/* - * GRUB -- GRand Unified Bootloader - * Copyright (C) 2003, 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. - */ - -#include <grub/machine/console.h> -#include <grub/machine/ieee1275.h> -#include <grub/term.h> -#include <grub/types.h> -#include <grub/misc.h> - -static grub_ieee1275_ihandle_t stdout_ihandle; -static grub_ieee1275_ihandle_t stdin_ihandle; - -static int grub_curr_x; -static int grub_curr_y; - -static int grub_keybuf; -static int grub_buflen; - -struct color -{ - int red; - int green; - int blue; -}; - -#define MAX 0xff -static struct color colors[8] = - { - { 0, 0, 0}, - { MAX, 0, 0}, - { 0, MAX, 0}, - { MAX, MAX, 0}, - { 0, 0, MAX}, - { MAX, 0, MAX}, - { 0, MAX, MAX}, - { MAX, MAX, MAX} - }; - -static int fgcolor = 7; -static int bgcolor = 0; - -/* Write control characters to the console. */ -static void -grub_ofconsole_writeesc (const char *str) -{ - while (*str) - { - char chr = *(str++); - grub_ieee1275_write (stdout_ihandle, &chr, 1, 0); - } - -} - -static void -grub_ofconsole_putchar (grub_uint32_t c) -{ - char chr = c; - if (c == '\n') - { - grub_curr_y++; - grub_curr_x = 0; - } - else - grub_curr_x++; - grub_ieee1275_write (stdout_ihandle, &chr, 1, 0); -} - -static void -grub_ofconsole_setcolorstate (grub_term_color_state state) -{ - char setcol[20]; - int fg; - int bg; - - switch (state) - { - case GRUB_TERM_COLOR_STANDARD: - case GRUB_TERM_COLOR_NORMAL: - fg = fgcolor; - bg = bgcolor; - break; - case GRUB_TERM_COLOR_HIGHLIGHT: - fg = bgcolor; - bg = fgcolor; - break; - default: - return; - } - - grub_sprintf (setcol, "\e[3%dm\e[4%dm", fg, bg); - grub_ofconsole_writeesc (setcol); -} - -static void -grub_ofconsole_setcolor (grub_uint8_t normal_color, - grub_uint8_t highlight_color) -{ - fgcolor = normal_color; - bgcolor = highlight_color; -} - -static int -grub_ofconsole_readkey (int *key) -{ - char c; - int actual = 0; - - grub_ieee1275_read (stdin_ihandle, &c, 1, &actual); - - if (actual > 0 && c == '\e') - { - grub_ieee1275_read (stdin_ihandle, &c, 1, &actual); - if (actual <= 0) - { - *key = '\e'; - return 1; - } - - if (c != 91) - return 0; - - grub_ieee1275_read (stdin_ihandle, &c, 1, &actual); - if (actual <= 0) - return 0; - - switch (c) - { - case 65: - /* Up: Ctrl-p. */ - c = 16; - break; - case 66: - /* Down: Ctrl-n. */ - c = 14; - break; - case 67: - /* Right: Ctrl-f. */ - c = 6; - break; - case 68: - /* Left: Ctrl-b. */ - c = 2; - break; - } - } - - *key = c; - return actual > 0; -} - -static int -grub_ofconsole_checkkey (void) -{ - int key; - int read; - - if (grub_buflen) - return 1; - - read = grub_ofconsole_readkey (&key); - if (read) - { - grub_keybuf = key; - grub_buflen = 1; - return 1; - } - - return 0; -} - -static int -grub_ofconsole_getkey (void) -{ - int key; - - if (grub_buflen) - { - grub_buflen =0; - return grub_keybuf; - } - - while (! grub_ofconsole_readkey (&key)); - - return key; -} - -static grub_uint16_t -grub_ofconsole_getxy (void) -{ - return ((grub_curr_x - 1) << 8) | grub_curr_y; -} - -static void -grub_ofconsole_gotoxy (grub_uint8_t x, grub_uint8_t y) -{ - char s[11]; /* 5 + 3 + 3. */ - grub_curr_x = x; - grub_curr_y = y; - - grub_sprintf (s, "\e[%d;%dH", y + 1, x + 1); - grub_ofconsole_writeesc (s); -} - -static void -grub_ofconsole_cls (void) -{ - /* Clear the screen. */ - grub_ofconsole_writeesc ("\e[2J"); - grub_gotoxy (0, 0); -} - -static void -grub_ofconsole_setcursor (int on __attribute ((unused))) -{ - /* XXX: Not supported. */ -} - -static void -grub_ofconsole_refresh (void) -{ - /* Do nothing, the current console state is ok. */ -} - -static grub_err_t -grub_ofconsole_init (void) -{ - char data[4]; - grub_size_t actual; - int col; - - if (grub_ieee1275_get_property (grub_ieee1275_chosen, "stdout", data, - sizeof data, &actual) - || actual != sizeof data) - return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Cannot find stdout"); - - stdout_ihandle = grub_ieee1275_decode_int_4 (data); - - if (grub_ieee1275_get_property (grub_ieee1275_chosen, "stdin", data, - sizeof data, &actual) - || actual != sizeof data) - return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Cannot find stdin"); - - stdin_ihandle = grub_ieee1275_decode_int_4 (data); - - /* Initialize colors. */ - for (col = 0; col < 7; col++) - grub_ieee1275_set_color (stdout_ihandle, col, colors[col].red, - colors[col].green, colors[col].blue); - - /* Set the right fg and bg colors. */ - grub_ofconsole_setcolorstate (GRUB_TERM_COLOR_NORMAL); - - return 0; -} - -static grub_err_t -grub_ofconsole_fini (void) -{ - return 0; -} - - -\f -static struct grub_term grub_ofconsole_term = - { - .name = "ofconsole", - .init = grub_ofconsole_init, - .fini = grub_ofconsole_fini, - .putchar = grub_ofconsole_putchar, - .checkkey = grub_ofconsole_checkkey, - .getkey = grub_ofconsole_getkey, - .getxy = grub_ofconsole_getxy, - .gotoxy = grub_ofconsole_gotoxy, - .cls = grub_ofconsole_cls, - .setcolorstate = grub_ofconsole_setcolorstate, - .setcolor = grub_ofconsole_setcolor, - .setcursor = grub_ofconsole_setcursor, - .refresh = grub_ofconsole_refresh, - .flags = 0, - .next = 0 - }; - -void -grub_console_init (void) -{ - grub_term_register (&grub_ofconsole_term); - grub_term_set_current (&grub_ofconsole_term); -} - -void -grub_console_fini (void) -{ - grub_term_unregister (&grub_ofconsole_term); -} Index: util/console.c =================================================================== RCS file: /cvsroot/grub/grub2/util/console.c,v retrieving revision 1.8 diff -u -p -r1.8 console.c --- util/console.c 27 Feb 2005 21:19:05 -0000 1.8 +++ util/console.c 14 Jul 2005 03:06:10 -0000 @@ -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 diff -u -p -r1.18 grub-emu.c --- util/grub-emu.c 2 Mar 2005 20:12:46 -0000 1.18 +++ util/grub-emu.c 14 Jul 2005 03:06:10 -0000 @@ -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> ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: common ieee1275 code 2005-07-14 3:38 ` Hollis Blanchard @ 2005-07-14 9:55 ` Marco Gerards 2005-07-14 14:23 ` Hollis Blanchard 2005-07-18 17:19 ` Marco Gerards 1 sibling, 1 reply; 29+ messages in thread From: Marco Gerards @ 2005-07-14 9:55 UTC (permalink / raw) To: The development of GRUB 2 Hollis Blanchard <hollis@penguinppc.org> writes: > 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! > 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 ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: common ieee1275 code 2005-07-14 9:55 ` Marco Gerards @ 2005-07-14 14:23 ` Hollis Blanchard 2005-07-14 22:54 ` Vincent Pelletier 0 siblings, 1 reply; 29+ messages in thread From: Hollis Blanchard @ 2005-07-14 14:23 UTC (permalink / raw) To: The development of GRUB 2 On Jul 14, 2005, at 4:55 AM, Marco Gerards wrote: >> 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 ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: common ieee1275 code 2005-07-14 14:23 ` Hollis Blanchard @ 2005-07-14 22:54 ` Vincent Pelletier 2005-07-16 18:45 ` Marco Gerards 0 siblings, 1 reply; 29+ messages in thread From: Vincent Pelletier @ 2005-07-14 22:54 UTC (permalink / raw) To: The development of GRUB 2 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain; charset=US-ASCII, Size: 1104 bytes --] -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hollis Blanchard wrote: > "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 ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: common ieee1275 code 2005-07-14 22:54 ` Vincent Pelletier @ 2005-07-16 18:45 ` Marco Gerards 2005-07-16 20:10 ` Hollis Blanchard 0 siblings, 1 reply; 29+ messages in thread From: Marco Gerards @ 2005-07-16 18:45 UTC (permalink / raw) To: The development of GRUB 2 Vincent Pelletier <subdino2004@yahoo.fr> writes: > 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 ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: common ieee1275 code 2005-07-16 18:45 ` Marco Gerards @ 2005-07-16 20:10 ` Hollis Blanchard 2005-07-16 22:07 ` Vincent Pelletier 0 siblings, 1 reply; 29+ messages in thread From: Hollis Blanchard @ 2005-07-16 20:10 UTC (permalink / raw) To: The development of GRUB 2 On Jul 16, 2005, at 2:45 PM, Marco Gerards wrote: > Vincent Pelletier <subdino2004@yahoo.fr> writes: > >> 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 ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: common ieee1275 code 2005-07-16 20:10 ` Hollis Blanchard @ 2005-07-16 22:07 ` Vincent Pelletier 0 siblings, 0 replies; 29+ messages in thread From: Vincent Pelletier @ 2005-07-16 22:07 UTC (permalink / raw) To: The development of GRUB 2 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain; charset=US-ASCII, Size: 1081 bytes --] -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hollis Blanchard wrote: > 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 ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: common ieee1275 code 2005-07-14 3:38 ` Hollis Blanchard 2005-07-14 9:55 ` Marco Gerards @ 2005-07-18 17:19 ` Marco Gerards 2005-07-18 18:59 ` Hollis Blanchard 1 sibling, 1 reply; 29+ messages in thread From: Marco Gerards @ 2005-07-18 17:19 UTC (permalink / raw) To: The development of GRUB 2 Hollis Blanchard <hollis@penguinppc.org> writes: > 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. :) ... > 2005-07-13 Hollis Blanchard <hollis@penguinppc.org> > > * 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 ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: common ieee1275 code 2005-07-18 17:19 ` Marco Gerards @ 2005-07-18 18:59 ` Hollis Blanchard 0 siblings, 0 replies; 29+ messages in thread From: Hollis Blanchard @ 2005-07-18 18:59 UTC (permalink / raw) To: The development of GRUB 2 On Jul 18, 2005, at 1:19 PM, Marco Gerards wrote: > Hollis Blanchard <hollis@penguinppc.org> writes: > >> 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. :) > > ... > >> 2005-07-13 Hollis Blanchard <hollis@penguinppc.org> >> >> * 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 ^ permalink raw reply [flat|nested] 29+ messages in thread
end of thread, other threads:[~2005-07-18 19:28 UTC | newest] Thread overview: 29+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2005-07-11 12:21 [PATCH] Huge changes in mm.c Vincent Pelletier 2005-07-11 12:56 ` Marco Gerards 2005-07-11 13:20 ` Vincent Pelletier 2005-07-11 13:09 ` Vincent Guffens 2005-07-12 11:14 ` Vincent Pelletier 2005-07-12 10:58 ` Yoshinori K. Okuji 2005-07-12 12:31 ` Vincent Pelletier 2005-07-12 12:55 ` Marco Gerards 2005-07-12 13:41 ` Vincent Pelletier 2005-07-12 15:12 ` Hollis Blanchard 2005-07-12 15:46 ` Marco Gerards 2005-07-12 18:46 ` sparc64 port : diffs to powerpc branches Vincent Pelletier 2005-07-12 19:40 ` Marco Gerards 2005-07-12 20:49 ` Vincent Pelletier 2005-07-13 15:59 ` Marco Gerards 2005-07-13 20:40 ` Vincent Pelletier 2005-07-13 21:27 ` Marco Gerards 2005-07-12 22:17 ` Hollis Blanchard 2005-07-13 1:01 ` common ieee1275 code Hollis Blanchard 2005-07-13 16:13 ` Marco Gerards 2005-07-14 3:38 ` Hollis Blanchard 2005-07-14 9:55 ` Marco Gerards 2005-07-14 14:23 ` Hollis Blanchard 2005-07-14 22:54 ` Vincent Pelletier 2005-07-16 18:45 ` Marco Gerards 2005-07-16 20:10 ` Hollis Blanchard 2005-07-16 22:07 ` Vincent Pelletier 2005-07-18 17:19 ` Marco Gerards 2005-07-18 18:59 ` Hollis Blanchard
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.