Skip to contentSkip to conversation

Booting homebrew ELF kernel on NewWorld OpenFirmware 3.0?

DISCUSSION Andrei Warkentin 3 participants 6 messages Oct 10, 2005 – Oct 16, 2005

lore
Share & tools
lore
#0 lore raw

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

Hello,

I trying to cobble together a simple Hello World ``kernel'' on the mac, and have a question concerning the booting specifics. I understand that OF 3.0 groks ELF, but the ELF file should contain some special information in the note section (and have the PT_NOTE thing). This special information entails the values for load-base and real-base (among other things) that are to be used. Here is where I become confused.

There are plenty of warnings on the web (*BSD sites, usually) to not mess with load-base and real-base in OF 3.0, since doing so can inadvertently result in overwriting OF in flash, thus bricking the computer. I don't want to do that to my new iBook :-). Yet, looking at BSD's ofwboot, yaboot, and NewWorld booting code in Linux, I see that all of these mess with the load-base in the note descriptor - setting it to 0x4000 (which, interestingly enough is the default load-base in OF 1.0.5, and not a good one for linux at that) or 0x3000. Is there a reason for not leaving this at 0xffffffff thus using whatever the default OF 3.0 one is? (The BSD bootloader sites assure me it's a good one).

I'm sorry if this a tad OT, but I realized this is probably the best place to ask this question (to which I can't find an answer anywhere) since you guys probably eat this stuff for lunch :-).

Thank you very much and have a good day.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Darwin)

iD8DBQFDSdHZY/rXIPQviuERAoqSAJ9CBBGasgGbTP1daGKIhAOjwJoGTQCgmUKt hx7Pp0UFf8LtOnx/V9XWNRA=
=Dlgh
-----END PGP SIGNATURE-----

#1 lore raw
Quoted 7 lines · Andrei Warkentin

I trying to cobble together a simple Hello World ``kernel'' on the mac, and have a question concerning the booting specifics. I understand that OF 3.0 groks ELF, but the ELF file should contain some special information in the note section (and have the PT_NOTE thing). This special information entails the values for load-base and real-base (among other things) that are to be used. Here is where I become confused.

Noone except IBM CHRP cares about the PT_NOTE.
Proof: yaboot doesnt have one, and yaboot works fine for everyone.

Signature · 2 lines
short story of a lazy sysadmin:
 alias appserv=wotan
#2 lore raw

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

Hello,

Thank you for your reply. Thus, all I need for OF 3.0 to load my ``kernel'' is just a statically-linked ELF file, with proper endianness, and a _start symbol? Does anyone know how well OF 3.0 deals with different endianness if at all?

Thanks again for the information and have a great day.

Quoted 12 lines · Olaf Hering
Quoted 8 lines · Andrei Warkentin

I trying to cobble together a simple Hello World ``kernel'' on the mac, and have a question concerning the booting specifics. I understand that OF 3.0 groks ELF, but the ELF file should contain some special information in the note section (and have the PT_NOTE thing). This special information entails the values for load-base and real-base (among other things) that are to be used. Here is where I become confused.

Quoted 13 lines

Noone except IBM CHRP cares about the PT_NOTE.
Proof: yaboot doesnt have one, and yaboot works fine for everyone.

Signature · 8 lines
short story of a lazy sysadmin:
 alias appserv=wotan


_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Darwin)

iD8DBQFDSoLCY/rXIPQviuERAk9GAJ4tv/4HABaAjQ76tFp+RbyJ95BmtwCaA78t rkdVPC189DlMz1b2qjQkB9I=
=lqdQ
-----END PGP SIGNATURE-----

#3 lore raw
Quoted 9 lines · Andrei Warkentin

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

Hello,

Thank you for your reply. Thus, all I need for OF 3.0 to load my ``kernel'' is just a statically-linked ELF file, with proper endianness, and a _start symbol? Does anyone know how well OF 3.0 deals with different endianness if at all?

_start is the ELF entry point, it can be anywhere in the file. I dont know how OF deals with endianess.

Signature · 2 lines
short story of a lazy sysadmin:
 alias appserv=wotan
#4 lore raw
In reply to Olaf Hering

Thanks for your help. Right now I've gotten to the point where I can print ``hello world'' and exit back to OpenFirmware.
It is interesting though that I cannot ``boot'' it again (or for that matter launch BootX and procede back into OS X) until I reboot the machine.
When I boot my own kernel again I get a CLAIM Failed. When I boot BootX I get ``illegal instruction executed``. As far as I understand, it is because OF CLAIMed the memory area where it was loading my image, and after my kernel quit, that area was still CLAIMed by OF, so it couldn't CLAIM it again. Is there some way of convincing OF to free up the memory it just gobbled up, after my kernel had exited?

Thanks again.

Quoted 25 lines · Olaf Hering
Quoted 8 lines · Andrei Warkentin

I trying to cobble together a simple Hello World ``kernel'' on the mac, and have a question concerning the booting specifics. I understand that OF 3.0 groks ELF, but the ELF file should contain some special information in the note section (and have the PT_NOTE thing). This special information entails the values for load-base and real-base (among other things) that are to be used. Here is where I become confused.

Noone except IBM CHRP cares about the PT_NOTE.
Proof: yaboot doesnt have one, and yaboot works fine for everyone.

Signature · 8 lines
short story of a lazy sysadmin:
 alias appserv=wotan


_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel
#5 lore raw
Quoted 3 lines · Andrei Warkentin

Thanks for your help. Right now I've gotten to the point where I can print ``hello world'' and exit back to OpenFirmware.
It is interesting though that I cannot ``boot'' it again (or for that matter launch BootX and procede back into OS X) until I reboot the machine.
When I boot my own kernel again I get a CLAIM Failed. When I boot BootX I get ``illegal instruction executed``. As far as I understand, it is because OF CLAIMed the memory area where it was loading my image, and after my kernel quit, that area was still CLAIMed by OF, so it couldn't CLAIM it again. Is there some way of convincing OF to free up the memory it just gobbled up, after my kernel had exited?

The real problem is that many firmwares are not well-tested for unusual cases like this.

It's probably possible to fix this up with a Forth script, but reset-all isn't too inconvenient...

-Hollis