Kernel in D

Adam D. Ruppe via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat May 31 05:22:25 PDT 2014


On Saturday, 31 May 2014 at 07:28:32 UTC, Mineko wrote:
> Any ideas? :P

Buy my book, chapter 11 talks about it a little to get you 
started :P

http://www.packtpub.com/discover-advantages-of-programming-in-d-cookbook/book


The summary of my approach there is:

1) Use a regular linux compiler and a custom linker script to 
make an ELF executable, I wouldn't worry about making a cross 
compiler or anything fancy like that.

2) Use GRUB or qemu -kernel to boot that executable. No need to 
write your own bootloader.

3) Compile without the runtime, instead using a minimal object.d, 
here's a fairly simple one for example: 
http://arsdnet.net/dcode/bare/object.d or a more complete one can 
be found in here: http://arsdnet.net/dcode/minimal.zip

4) Add back features from teh real druntime as needed, but I say 
avoid those that are too hard to do memory management manually 
(so like just leave array concatenation unimplemented, instead 
write a regular struct that owns its own memory and has append 
methods and use it)

5) Love inline asm and naked functions for interrupt handlers

6) Pay attention to struct alignment (also see chapter 7 of my 
book if you decide to go that route) when defining hardware 
layouts!

7) Don't try to use TLS variables, always use __gshared on module 
level or static variables cuz tls won't actually work.



That should get you started to play around!


More information about the Digitalmars-d-learn mailing list