Monday, December 11, 2006

First syscall working

I got the first sample system call working, and can switch back and forth between user/supervisor spaces. I'm glad that it works; the assembler glue logic was making me worry long time ago, but it's no big deal really. Things that seem hard to achieve get easy to implement when you investigate them for a while. I could even say driving some devices like usb host controllers correctly is harder than getting a processor going. You are writing software after all, and can follow with the debugger.

I slept for half an hour after work, and caught myself snor multiple times. Man, I was in real deep sleep although only for about half an hour. When you wake up its like you are reborn. From today onwards, I also eat lightly. What was that ice-cream, lamb, ice-cream combo, yesterday. Although with one hour inbetween each meal I was gonna get real sick after the half glass of rum in the end!

Saturday, December 09, 2006

Things getting better

Its a cold winter night here in Cambridge. I've been reading through context switching conventions on ARM. It's not too hard once you write some assembler, run it on the debugger and see how it behaves. I got my first inittask (extremely simple branch to itself task!) running by mapping its tables, giving it a pageful of stack and jumping to it. It's not complicated really. I had to write a pgd allocator first, change the page allocator to give back physical pages on request, create a correct ktcb etc. etc. I'm quite happy though that all this has worked in the first run with minor changes after compilation. No hard debugging times as I expected, because getting CPSR/SPSRs, user space permissions, flushing of caches/tlb at the correct place must be all done the right way, which I hadn't tried before. Perhaps nasty bugs will show up tomorrow. But let me commit this first. By the way it seems I should switch to STGIT, its no doubt more useful to manage your patches with git itself.

Friday, December 01, 2006

Loading loading loading..

I've figured out a way to build all images (the microkernel + multiple svc tasks, like inittask, roottask etc.) independently, and yet have the microkernel discover about where the other images are loaded at.

Each image during it's build extracts the final LMA of the previous image to be loaded before it. It's linker script then includes this information from an autogenerated lds file.

Finally after each image is built, a bootdesc structure is loaded at the end of all images. The microkernel discovers its address at run-time, reads it and learns about all other images.

The nice thing about all this is that it does not require any special modification of elf images during build time, or any custom loader. A generic elf loader (like the one I use from original l4 project, which is great) should suffice to load all this.

The actual problem in general is to find the time and energy to continue this work alongside work-related work, which is also very brain consuming. I can find the time on evenings, but sometimes not the energy to think and solve puzzles. But it's still fun to do this. At last I am doing something that I really wanted to do rather than others wanted me to do.

To get dynamic stack and heap allocation, correct page fault handling, linking with the incomplete user C library, making the system calls, conforming to L4 specs in register layout of system calls etc. etc. are all achievable but each will take time to think about before implementation, and debugging etc. Hopefully I will find lots of time during my 2 weeks christmas holiday. I had a 1 week holiday in september and that's how actually I got the memory allocators debugged/tested/finished in reasonable time.