OS programming ... boot

maccatalan

Registered
Hi.

I found a lot of things talking about the OpenFirmware (Apple TechnicalNotes, OpenFirware Working Group web site, articles ...) but nothing concrete.

By "nothing concrete" I mean I found nothing telling me what to compile and how (and also how to configure) in order to be able to display something at the startup, something booting instead of the Mac OS X (or any other OS) at the startup of my PowerMacintosh (QuickSilver).

I am really interested in OS programming, I tried to find (mostly with Google) things about that ... but nothing "concrete". I just know the basis of gcc in order to compile my C++ projects. I don't even know how to compile a library ... :S !

If anybody can help me, telling me what to read (tutorial or book) provided it is really well-explained, or juste guide me and teach me ... then thank you very much for replying.

Have a nice day,
Pierre. ;)
 
I already saw the first two links (and the linked pages) but not the third. It is interesting ... but it does not tells me how and what to compile in order to get it work.

Your first link is about the boot sequence, but the boot sequence of Mac OS X. Of course, to display a message this is enought. But this is not my goal. I would like to create a (very basic) operating system ... at least something bootable. :D

Thank you for you note but the question remains open ;)
Pierre.

PS: I tried to read and understand the yaboot sources but I have no idea of how to compile it (once modified) in order to get some bootable code file. :S

Thx
 
Ehh...OpenFirmware uses Forth for it's programming language, IIRC. Though the actual booting isn't done in OF, you just select a file that has booting instructions from there.

Yaboot is a pretty good example. Probably doesn't compile for you since it was made to boot the Linux kernel, though.

Why would you want to make your own OS? It's not an easy prospect. You'll have to make device drivers for the video, keyboard, and mouse at the very least to be able to actually use it. And those would most likely need to be done in assembly. Then you'd need to make some kind of higher level API for any applications on your OS to be able to communicate with them. Even a basic OS isn't very basic to create. :p
 
he he :)

I know. But I am really curious to get something booting. Having just text display and keyboard interaction would be enought and far much than what I expect to do (for the while just writting a sentence ... a black screen with maybe something like ... hmmm ... let's say 'Hello World' ;) ).

I don't want to create drivers, or anything. For the while, it's just a study case.

I know (for reading) that OF is a Forth interpreter and that it includes a Telnet daemon, File abstraction and the device tree it creates made me really amazed at the understanding of how complex it is ... well ... far much complex than a PC BIOS :D It is really good. But as you say it is from the OF that we type the boot instruction.
We tell him to boot a file on a device ( for example : ' boot hd:,ofwboot bsd.rd ' for the HD OpenBSD install).

I also tried to get xnu (Mac OS X 's kernel kernel ... is to say Darwin kernel) and to modify it since Apple says how to compile it so clearly. But ... no way! too much complex for me. I don't event find which is the file that contains any kind of begining file (I mean a kind of 'main' function).

In fact my question is :

my program would be something like (in the result) to:

Code:
#include <iostream>

int main()
{
   std::cout << "Hey you!\n";
   return 0;
}

How to modify it and compile it in order to get it bootable (since I think by modifying the OpenBSD HD Install I can indicate what file to use to OF) ?

of course I understand that the program won't work if compiled like that. We will need (I suppose) to acceed directly to VRAM to write in memory what should be displayed ... a bit like what yaboot does I think ... but how to do that, please ? ... or then : how to compile yaboot in a way it will work (I will then modify the int yaboot_main(void); funtion) ? Because I suppose we need some special arguments to pass to gcc , don't we ?

Thank you very much for your answers
Pierre.
 
You seem to forget that even writing a sentence to the screen requires a display driver. Analogously, obtaining keyboard input requires a keyboard driver. As far as I know there is nothing built into a Mac comparable to PC BIOS functions to read from keyboard or display a character on the screen. Doing std::cout &lt;&lt; "whatever" is very very high level compared to what you would have to implement. If you really want to go this way the first thing you would have to do is study the Macintosh hardware specs (btw. they differ from model to model!) since you will have to directly talk to the various controllers in a low-level, hardware-centristic fashion. Normally, this is done in assembly language, not in C++. Good luck mate ;)
 
I know that. And what you're saying is what I mean when writting :

of course I understand that the program won't work if compiled like that. We will need (I suppose) to acceed directly to VRAM to write in memory what should be displayed ...

Of course that idea of VRAM is stupid (it comes from something I saw in a PC tutorial to do exactly what I am trying to do) but the idea is the one of the display driver with horrors like hexadecimal code or assembly code.

I'm not crazy enought to hope to compile C++ and get it "as it". ;)
And in fact my problem remains there ... :'(
HOW TO ???! :'(

I am just hoping that a guru , a very strong man from Apple or elsewhere with enought knowledge to enlight us will come and give here an example, a quick tutorial.
Of course, this represents some work ... but please, if do have the knowledge, let's share it.

NB: something I think I will do is to buy a book about MINIX and learn what I mean to with this book and VirtualPC ... however it will never be like a simple promp at the startup of my mac ... (and not thanks a script in the Mac OS X start up but as a bootable system).

Thank you.
 
Back
Top