www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Booting to D.

reply "John Carter" <john.carter taitradio.com> writes:
So this post...

http://blog.theincredibleholk.org/blog/2013/11/18/booting-to-rust/

..is interesting.

Why? Because it tackles one of the core reasons why C is hard to 
dislodge.

Almost every CPU on the planet "Boots to C", perhaps with a very 
thin crust of assembler.

To dislodge C in my domain (embedded systems), this would be a 
very interesting and effective challenge to take on.


What would it take to "Boot to D"?

Or put it another way...

What base infrastructure does a D program rely on that the OS has 
already provided before we hit "main"?

Typically things like stack setup, program load, register 
initialization, zero'ing .bss segments and copying .data segments 
into ram etc. etc.

Sometime mmap or sbrk for heap management.

What else, and where to look?
Nov 19 2013
next sibling parent reply "Adam D. Ruppe" <destructionator gmail.com> writes:
On Tuesday, 19 November 2013 at 22:49:07 UTC, John Carter wrote:
 What would it take to "Boot to D"?
Check this out: http://arsdnet.net/dcode/minimal.zip I stripped out druntime, then put back only enough to get many of the language features working, but all standing alone. The makefile.bare (or whatever i called it) can make an elf image that can be loaded by GRUB onto bare x86 metal and run the little D program. Though...
 Typically things like stack setup, program load, register 
 initialization, zero'ing .bss segments and copying .data 
 segments into ram etc. etc.
this stuff is all done by GRUB, so I cheated a little. It shouldn't be too hard to do in D though, if nothing else, a naked inline asm function at the start location.
 Sometime mmap or sbrk for heap management.
and I didn't do much heap at all, I just dropped stuff in somewhere. But that's because I'm lazy more than because it is hard.
Nov 19 2013
parent "Adam D. Ruppe" <destructionator gmail.com> writes:
On Tuesday, 19 November 2013 at 22:55:30 UTC, Adam D. Ruppe wrote:
 Check this out:
like i said, there i used grub, but the EFI thing looks like it works more or less the same way - doing it with D should be fairly simple, especially with the stripped druntime.
Nov 19 2013
prev sibling next sibling parent "growler" <growlercab gmail.com> writes:
On Tuesday, 19 November 2013 at 22:49:07 UTC, John Carter wrote:
 So this post...

 http://blog.theincredibleholk.org/blog/2013/11/18/booting-to-rust/

 ..is interesting.

 Why? Because it tackles one of the core reasons why C is hard 
 to dislodge.

 Almost every CPU on the planet "Boots to C", perhaps with a 
 very thin crust of assembler.

 To dislodge C in my domain (embedded systems), this would be a 
 very interesting and effective challenge to take on.


 What would it take to "Boot to D"?

 Or put it another way...

 What base infrastructure does a D program rely on that the OS 
 has already provided before we hit "main"?

 Typically things like stack setup, program load, register 
 initialization, zero'ing .bss segments and copying .data 
 segments into ram etc. etc.

 Sometime mmap or sbrk for heap management.

 What else, and where to look?
http://wiki.osdev.org/D_Bare_Bones I suppose one could argue that technically it's booting into C as it still needs C linkage. But the kernel is D and it's compiled with a D compiler, so I'd consider it a D kernel.
Nov 19 2013
prev sibling parent Jacob Carlborg <doob me.com> writes:
On 2013-11-19 23:49, John Carter wrote:
 So this post...

 http://blog.theincredibleholk.org/blog/2013/11/18/booting-to-rust/

 ..is interesting.

 Why? Because it tackles one of the core reasons why C is hard to dislodge.

 Almost every CPU on the planet "Boots to C", perhaps with a very thin
 crust of assembler.

 To dislodge C in my domain (embedded systems), this would be a very
 interesting and effective challenge to take on.


 What would it take to "Boot to D"?

 Or put it another way...

 What base infrastructure does a D program rely on that the OS has
 already provided before we hit "main"?

 Typically things like stack setup, program load, register
 initialization, zero'ing .bss segments and copying .data segments into
 ram etc. etc.

 Sometime mmap or sbrk for heap management.

 What else, and where to look?
You can have a look that this kernel written in D: https://github.com/xomboverlord/xomb -- /Jacob Carlborg
Nov 19 2013