Author

I Pancakes wrote this to help jump start you into developing for the ARM using QEMU or even a real piece of hardware. I have wrote software for both emulators and real hardware, but this has only been tested on QEMU so far. Please make any needed changes if you find problems. Also let me know at kmcg3413@gmail.com if you find this useful, have comments, or suggestions.

Intro

You should be coming from one of the previous pages. I prefer the last one if you have been
following along. Well, the moment has arrived. You are now ready to see a method of attaching
some modules and even a demonstration of loading a ELF32 module into user space.

First we will cover the method to attach files to the end of the kernel image. Then we will look
at loading an ELF32 module into user space.

Attaching A Module

Python Script

This scripts pads the module to a 32-bit boundary so reads will be aligned, and inserts the
special header so it can be located. The header contains a few fields, see C code further down to see a structure defined for the header. The module can present it's own fields in the header through the slots field.

Kernel Code

The first part of the kernel code here assumes you have been following along with the other pages
in this series of pages. So I am not going to go too deep to explain much of it. But, essentially I check that the module is of type KMODTYPE_ELFUSER and if so then I find a free task slot and
hand that to a function that will do the actual loading of the image.

Full Source

Going Further

At this point you have almost a fully functional kernel. Your missing better support for device drivers, services, and such things. Your also at the point where you can build different kernel types depending on your design. Your missing system calls for user space for memory allocation. Also, you need processes and threads instead of the more primitive task like design we have now. Also, you need to handle exceptions for user space correctly such as terminating the offending process or thread. Also, synchronization primitives and common services like timers and sleeping are missing. And, then again maybe you do not need these and you have some really awesome design!? Well, code to your heart's content is my suggestion!

You can continue along with me or branch out in your own direction if you like, but in the next page we are going to create actual processes and threads, improve our exception handling, and add just a few basic services through system calls to threads.