* [ppc patch] Old World Mac booting
@ 2004-10-03 18:59 Hollis Blanchard
2004-10-06 18:27 ` Marco Gerards
0 siblings, 1 reply; 5+ messages in thread
From: Hollis Blanchard @ 2004-10-03 18:59 UTC (permalink / raw)
To: grub-devel
This patch allows us to enter GRUB from a stage1 on Old World Macintosh.
Unfortunately that is needed, because Old World firmware cannot read a
filesystem on a disk partition. It can, however, blindy load and run a
contiguous range of sectors (identified in the Apple partition map).
The quik bootloader uses 1KB of data at the very front of a partition,
since filesystems leave that space alone. This is our stage1. There are
still various firmware quirks we need to work around in GRUB, though, such
as claiming firmware's memory for it.
This patch allows GRUB to boot via quik's stage1. Marco doesn't believe we
should depend on quik for a stage1 long-term, but for now it's working
great.
There are still other patches needed to GRUB functional on Old World,
notably claiming memory for memory management, and using grub_of_flags in
ofdisk.c (after the SCSI patch is committed). But this gets us closer.
Please apply.
-Hollis
Index: boot/powerpc/ieee1275/cmain.c
===================================================================
RCS file: /cvsroot/grub/grub2/boot/powerpc/ieee1275/cmain.c,v
retrieving revision 1.2
diff -u -r1.2 cmain.c
--- boot/powerpc/ieee1275/cmain.c 4 Apr 2004 13:45:59 -0000 1.2
+++ boot/powerpc/ieee1275/cmain.c 3 Oct 2004 18:43:39 -0000
@@ -35,6 +35,8 @@
/* OpenFirmware entry point passed to us from the real bootloader. */
intptr_t (*grub_ieee1275_entry_fn) (void *);
+grub_uint32_t grub_of_flags;
+
\f
/* Return a help text for this architecture. */
const char *
@@ -48,14 +50,36 @@
/* Setup the argument vector and pass control over to the main
function. */
void
-cmain (uint32_t firmware_entry)
+cmain (uint32_t r3, uint32_t r4 __attribute__((unused)), uint32_t r5)
{
char **argv, args[256];
grub_ieee1275_phandle_t chosen;
int argc = 0, actual;
long batl, batu;
- grub_ieee1275_entry_fn = (intptr_t (*)(void *)) firmware_entry;
+ if (r5 == 0xdeadbeef)
+ {
+ /* Entered from Old World stage1. */
+ extern char _start;
+ extern char _end;
+
+ grub_ieee1275_entry_fn = (intptr_t (*)(void *)) r3;
+
+ grub_of_flags = GRUB_IEEE1275_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_claim ((grub_addr_t) &_start, (grub_addr_t) &_end
+ - (grub_addr_t) &_start))
+ abort();
+ }
+ else
+ {
+ /* Assume we were entered from Open Firmware. */
+ grub_ieee1275_entry_fn = (intptr_t (*)(void *)) r5;
+ }
/* Initialize BAT registers to unmapped to not generate overlapping
mappings below. */
Index: boot/powerpc/ieee1275/crt0.S
===================================================================
RCS file: /cvsroot/grub/grub2/boot/powerpc/ieee1275/crt0.S,v
retrieving revision 1.2
diff -u -r1.2 crt0.S
--- boot/powerpc/ieee1275/crt0.S 4 Apr 2004 13:45:59 -0000 1.2
+++ boot/powerpc/ieee1275/crt0.S 3 Oct 2004 18:43:39 -0000
@@ -32,7 +32,10 @@
.long 0xffffffff /* virt-base */
.long 0xffffffff /* virt-size */
.long 0x00030000 /* load-base */
-
+
+.extern __bss_start
+.extern _end
+
.text
.align 2
.globl _start
@@ -43,9 +46,17 @@
li 2, 0
li 13, 0
-
- mr 3, 5
+ /* If we came from stage1, we *must* zero BSS. Otherwise, why not? */
+ lis 6, __bss_start@h
+ ori 6, 6, __bss_start@l - 4
+ lis 7, _end@h
+ ori 7, 7, _end@l
+ subf 7, 6, 7
+ mtctr 7
+2: stwu 2, 4(6) /* we know r2 is already 0 from above */
+ bdnz 2b
+
bl cmain
1: b 1b
Index: include/grub/powerpc/ieee1275/ieee1275.h
===================================================================
RCS file: /cvsroot/grub/grub2/include/grub/powerpc/ieee1275/ieee1275.h,v
retrieving revision 1.5
diff -u -r1.5 ieee1275.h
--- include/grub/powerpc/ieee1275/ieee1275.h 3 Oct 2004 09:19:10 -0000 1.5
+++ include/grub/powerpc/ieee1275/ieee1275.h 3 Oct 2004 18:43:40 -0000
@@ -44,6 +44,11 @@
typedef intptr_t grub_ieee1275_phandle_t;
extern intptr_t (*grub_ieee1275_entry_fn) (void *);
+extern grub_uint32_t grub_of_flags;
+
+/* Old World firmware fails seek when "dev:0" is opened. */
+#define GRUB_IEEE1275_NO_PARTITION_0 0x1
+
\f
uint32_t EXPORT_FUNC(grub_ieee1275_decode_int_4) (unsigned char *p);
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [ppc patch] Old World Mac booting
2004-10-06 18:27 ` Marco Gerards
@ 2004-10-06 13:58 ` Hollis Blanchard
2004-10-06 21:03 ` Marco Gerards
2004-10-07 9:26 ` Yoshinori K. Okuji
0 siblings, 2 replies; 5+ messages in thread
From: Hollis Blanchard @ 2004-10-06 13:58 UTC (permalink / raw)
To: The development of GRUB 2
On Wednesday 06 October 2004 18:27, Marco Gerards wrote:
> Hollis Blanchard <hollis@penguinppc.org> writes:
> > This patch allows GRUB to boot via quik's stage1. Marco doesn't believe
> > we should depend on quik for a stage1 long-term, but for now it's working
> > great.
>
> Right. A stage1 would be something for the todo list. Do you want to
> work on that?
Yes, I will do that if nobody else gets to it, but it's a bit lower on my list
than some other things (like adding a proper modularized "suspend" command
and removing the use of BAT mappings).
I can't look right now, but does x86 GRUB need to use a block list for an
early stage? If so, could someone point me to the structures used? I'd like
to use that as my model...
> Ok. I will apply this patch ASAP. Can you send us a changelog entry?
Oops, sorry. Will do.
-Hollis
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [ppc patch] Old World Mac booting
2004-10-03 18:59 [ppc patch] Old World Mac booting Hollis Blanchard
@ 2004-10-06 18:27 ` Marco Gerards
2004-10-06 13:58 ` Hollis Blanchard
0 siblings, 1 reply; 5+ messages in thread
From: Marco Gerards @ 2004-10-06 18:27 UTC (permalink / raw)
To: The development of GRUB 2
Hollis Blanchard <hollis@penguinppc.org> writes:
> This patch allows GRUB to boot via quik's stage1. Marco doesn't believe we
> should depend on quik for a stage1 long-term, but for now it's working
> great.
Right. A stage1 would be something for the todo list. Do you want to
work on that?
> There are still other patches needed to GRUB functional on Old World,
> notably claiming memory for memory management, and using grub_of_flags in
> ofdisk.c (after the SCSI patch is committed). But this gets us closer.
> Please apply.
Ok. I will apply this patch ASAP. Can you send us a changelog entry?
> Index: include/grub/powerpc/ieee1275/ieee1275.h
> ===================================================================
> RCS file: /cvsroot/grub/grub2/include/grub/powerpc/ieee1275/ieee1275.h,v
> retrieving revision 1.5
> diff -u -r1.5 ieee1275.h
> --- include/grub/powerpc/ieee1275/ieee1275.h 3 Oct 2004 09:19:10 -0000 1.5
> +++ include/grub/powerpc/ieee1275/ieee1275.h 3 Oct 2004 18:43:40 -0000
> @@ -44,6 +44,11 @@
> typedef intptr_t grub_ieee1275_phandle_t;
>
> extern intptr_t (*grub_ieee1275_entry_fn) (void *);
> +extern grub_uint32_t grub_of_flags;
I would prefer the prefix "grub_ieee1275_", so better use
"grub_ieee1275_flags" or so.
Thanks,
Marco
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [ppc patch] Old World Mac booting
2004-10-06 13:58 ` Hollis Blanchard
@ 2004-10-06 21:03 ` Marco Gerards
2004-10-07 9:26 ` Yoshinori K. Okuji
1 sibling, 0 replies; 5+ messages in thread
From: Marco Gerards @ 2004-10-06 21:03 UTC (permalink / raw)
To: The development of GRUB 2
Hollis Blanchard <hollis@penguinppc.org> writes:
> On Wednesday 06 October 2004 18:27, Marco Gerards wrote:
>> Hollis Blanchard <hollis@penguinppc.org> writes:
>> > This patch allows GRUB to boot via quik's stage1. Marco doesn't believe
>> > we should depend on quik for a stage1 long-term, but for now it's working
>> > great.
>>
>> Right. A stage1 would be something for the todo list. Do you want to
>> work on that?
>
> Yes, I will do that if nobody else gets to it, but it's a bit lower on my list
> than some other things (like adding a proper modularized "suspend" command
> and removing the use of BAT mappings).
Ok.
> I can't look right now, but does x86 GRUB need to use a block list for an
> early stage? If so, could someone point me to the structures used? I'd like
> to use that as my model...
On the PC there is a block of 32KB (IIRC) that can be used for the
core module. Can't this be done on the old world as well? IIRC there
is a 32KB block on the HFS filesystem.
Thanks,
Marco
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [ppc patch] Old World Mac booting
2004-10-06 13:58 ` Hollis Blanchard
2004-10-06 21:03 ` Marco Gerards
@ 2004-10-07 9:26 ` Yoshinori K. Okuji
1 sibling, 0 replies; 5+ messages in thread
From: Yoshinori K. Okuji @ 2004-10-07 9:26 UTC (permalink / raw)
To: The development of GRUB 2
On Wednesday 06 October 2004 15:58, Hollis Blanchard wrote:
> I can't look right now, but does x86 GRUB need to use a block list
> for an early stage? If so, could someone point me to the structures
> used? I'd like to use that as my model...
You can see the details from the comments at the bottom of
boot/i386/pc/diskboot.S. It is the almost same as the so-called
"blocklist" format. It specifies a list of blocks, and each block
consists of a start sector and the number of contiguous sectors. One
sector is 512-byte.
Okuji
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2004-10-07 9:33 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-03 18:59 [ppc patch] Old World Mac booting Hollis Blanchard
2004-10-06 18:27 ` Marco Gerards
2004-10-06 13:58 ` Hollis Blanchard
2004-10-06 21:03 ` Marco Gerards
2004-10-07 9:26 ` Yoshinori K. Okuji
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.