2013-06-18

2013-06-18 - Hello World ELF

As well as pulling in sections of code from previous iterations of the OS, I've been thinking more and more about the library, driver, and executable system.  Between the system calls from Linux, the POSIX specification and the functions required by NewLib, I've been able to whittle down a short list of system calls which I need to develop, and a rough order in which to do them.

My plan is to create a Hello World! program, but this program will not have a crt0.o, and will not include a LibC.  Instead it will use the OS method of getting a handle on the kernel.library (which will provide methods for opening libraries and finding symbol locations), from there it will find the "write" symbol, and call it to write the string (for the moment, it can assume that the stdout is at a specific file number).

Once this program is ready, I'll need to finish all the kernel code to underpin this.  For the moment, the following simplifications will be made:

  1. The program binary will be loaded into memory by Grub (to save the filesystem code yet)
  2. The program will be linked to start at 4Mb, and will be loaded into the kernel memory space at this address.
  3. The process model will not create a separate process for the program.


The workflow needed in order to achieve this, including required components is:

  • Create enough of the process table to store the open file list.
  • Create the Open File list (including file operations).
  • Create a basic console as previous versions, except using the stdin and stdout streams via read and write.  The read() call will spinlock inside the process subsystem until keys are pressed.
  • Get the kernel process to call into the console.
  • Configure an exit command from the console to return to the kernel.
  • Define the method of finding the kernel library and then finding other symbols.
  • Reimplement the 
  • Pull in the ELF loader


Distracted again, but Bochs has implemented a basic beep capability, and I've put the start of a "music" player based loosely on the the ZX Spectrum +2 PLAY command in so that I can program Greensleeves ...

No comments:

Post a Comment