[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: help with powerpc asm (moving grub_ieee1275_entry_fn initialization
Re: help with powerpc asm (moving grub_ieee1275_entry_fn initialization to crt0.S)
Thu, 17 Jan 2008 20:11:56 +0100
On Thu, Jan 17, 2008 at 12:30:19PM -0500, Pavel Roskin wrote:
> Oh, I didn't realize that kern/powerpc/ieee1275/cmain.c is actually used
> by the i386-ieee1275 build. That's misleading! Perhaps it should be
> moved to kern/ieee1275/
Yes. I had this in mind, but I think it's better to wait untill the i386
port is complete before we start moving files.
> Anyway, Sparc code doesn't use cmain() in any way. It starts
> immediately with the function _start() written in C. So you shouldn't
> worry about breaking Sparc.
Ah, I see. I didn't expect this.
> Please feel free to integrate the PowerPC part of my patch into your
> patch, as it indeed needs to be committed at once.
Ok. I'm attaching the complete patch.
> > Another option would be to have just one param. This would be the cleanest
> > on i386, since the call from OFW already uses -mregparm=1 for the callback
> > address, but I don't know about powerpc.
> I would prefer that we don't choose global CFLAGS to adjust one
> function. There is a "regparm" attribute that can be used on cmain() on
> i386 architecture.
The CFLAGS for i386-ieee1275 are already set to regparm. This makes it easier
to interact with OFW in both ways, since call backs also use %eax as first
(and only) parameter.
In fact, our current code seems to assume that grub_ieee1275_entry_fn() always
has the same calling conventions than GRUB. Because of this, I thought it'd
be consistent to assume the same for our _start routine.
However, powerpc and sparc64 seem to disagree with i386 on which is the
parameter that ought to be used to initialize grub_ieee1275_entry_fn. I
suppose it's better to move this out of cmain, then..
> But if you want to keep cmain() shared between architectures, then the
> cleanest approach would be to take care of grub_ieee1275_entry_fn before
> cmain() is called. It doesn't have to be in assembly. Sparc can still
> use its _start function to set grub_ieee1275_entry_fn and then call
Ok. That sounds good.
> Arguments are transmitted in registers r3, r4 and r5. Nothing is passed
> on the stack. r5 has the data we want to be in grub_ieee1275_entry_fn.
> The first instruction takes the high 16 bits of the
> grub_ieee1275_entry_fn address and put is to register 9. Register 9 is
> the favorite choice for memory operations, as it has no special purpose
> and doesn't need to be preserved.
> The second instruction places the contents of register 5 into an address
> pointed to by the register 9 plus the lower 16 bits of the
> grub_ieee1275_entry_fn address.
> A 32-bit constant cannot be loaded in one operation, since all PowerPC
> commands are 32-bit, and it simply won't fit one command.
<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)
Description: Text Data