Several people have tried writing an Operating System kernel with D.
Titan is an exokernel project using 100% D and ASM. Developed in 2006 by Trevor Parscal, Daniel Kreig, and Kyle Furlong the project is now at a stand-still. At this point, no further development is specifically planned.
Another D project has leveraged the code and research of DsourceProject:titan to get started - and others are welcome to do the same.
I've started work on creating an OS using the D programming language. As the foundation I chose the OKL4 microkernel, but I am left with one big problem now, and that is the IPC code generation. Any software in C written to run on top of OKL4 would use code generated from IDL, but it seems to me that such is not the way to go with D. So I'd like to be able to use just a D interface, and then have it somehow be exposed via IPC. Ideally the way D interfaces are called would be compatible to IDL interfaces, but that is not a strict requirement (i.e. if such comes with a couple of disadvantages, we probably shouldn't do it, otherwise it's probably the way to go). ( source)
- kernel totally in D with necessary parts in assembly
- source: NG:digitalmars.D.announce/6562
I don't know what "simple kernel" you found - there are several out there. The one I've played around was Mike Wynn's. It compiles, runs and supports classes.
Be warned that it is quite rudemental and certanly contains bugs.
http://dkernel.kuehne.cn/dkernel-current.zip (an updated dkernel version)
It basically has just 4 parts that are finished/working:
- An interface to be loaded by a multiboot compatible boot loader
- A text driver
- A memory manager which uses paging and can keep track of 4GB of memory. (simple reservation system, kmalloc, etc.)
- A tool for automatically creating a bochs hard drive image after each compile, which allows for very fast testing.
I don't claim to be a great programmer, and this was my first operating system. Nonetheless, I feel it may be helpful to someone.
P.S. The last compiler I used for this was either DMD 0.92 or 0.93 - perhaps you might get some new compiler errors/warning due to deprecated features. Also, the Makefiles are all set up for Linux. It would be a lot of work to get this to compile on Windows.
I found a simple kernel written in D. But it should be compiled with a really old dmd release...
Is there anyone who know to make a simple operating system in D made up of a boot loader and a kernel?
Hi, I have spent some time to get a basic "kernel" (I wouldn't call it a kernel yet) to boot. It's possible to do screen output but no input yet. That would be next. But getting input already requires a lot of pre-work with interrupt controlers etc.
I'm trying to make it but it's hard to link D object files with libraries.
Hard? Hmm... The thing is, you can't use any libraries because those functions are using operating-system functions. And those are not available for your own kernel. So you first have to implement all functions that the library uses before you can use this library to futher compiler programs.
It works fine by compiling the kernel without using any library, but i can't use classes and other D stuff without them!
Not true. You can use classes but you can't use the posted code here. Try to get phobos to work, than you can compile most of the avaiable (non-gui) code.
I need to specificy -Ttext 0x10000 (to set the text section entry point) but i can't if i link libraries...
I don't what you try to do with libraries. Just forget them when doing a kernel. You need to be able to create a special executable and boot this one. I just used "grub" for this and an ELF exectuable.
How do I compile the kernel in binary format (not PE/ELF/etc.)?
- Using the MultiBoot standard (see http://www.gnu.org/software/grub/manual/multiboot/multiboot.html), you won't need a kernel image in a pure binary image, you can use non-relocatable ELF/PE/etc...
- GRUB ( http://www.gnu.org/software/grub/) is a MultiBoot compliant boot loader.
- To reduce the start-up time, you can use also OSLib ( http://oslib.sourceforge.net/overview.html), a library to ease the development of operating systems.
- Freedos32 ( http://freedos-32.sourceforge.net/) is an example of a MultiBoot compliant OS that uses OSLib.
I did search the D news groups and found no previous reference to SANOS.
How about translating this in D ?
Sanos is a minimalistic 32-bit x86 OS kernel, written 98% C and 2%assembler, running on standard PC hardware. This enables you to run java server applications without the need to install a traditional host operating system like Windows or Linux.
The kernel was developed as part of an experiment on investigating the feasibility of running java server applications without a traditional operating system only using a simple kernel.
The kernel implements basic operating system services like booting, memory management, thread scheduling, local and remote file systems, TCP/IP networking and DLL loading and linking. A win32 layer allows the Windows version of the standard HotSpot? JVM to run under sanos, essentially providing a JavaOS? platform for server applications. This enables you to run java based server applications, like tomcat and jboss, under sanos.
Alternatively, you can use sanos as a small kernel for embedded server applications written in C. Sanos has a fairly standard POSIX based API and an ANSI Standard C library. In this case you don't need the JVM and the win32 wrappers.
Sanos is open source under a BSD style license. Please see the COPYING file for details.
- 2003-12-09: OS development with D
- 2004-01-26: OS development in D starter kit
- 2004-02-19: Dernel the D Kernel
- 2004-02-24: Dernel: _moduleCtor not working correct?
- 2004-02-19: Dernel: dynamic arrays
- 2004-02-20: Dernel: how does exception handling work?
- 2004-02-24: Dernel: Inline Assembler question
- 2004-02-24: Dernel: Using D's GC as kernel memory manager?
- 2004-03-02: Dernel: pointer arithmetic question
- 2004-03-03: Dernel: Protected mode far pointers in D?
- 2004-03-04: Dernel: D & interrupt handling
- 2004-04-20: D Newbies
- 2004-09-25: OS - Kernel link problem
- 2007-01-02: Experimental OS development using D (microkernel similar to L4)
- 2007-04-19: Writting SO kernel in D
- 2007-04-19: Writting SO kernel in D