OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 5:16 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Compiling a C# kernel to bare metal and booting in QEMU
PostPosted: Fri Jan 05, 2024 10:20 am 
Offline

Joined: Fri Jan 05, 2024 10:10 am
Posts: 4
Hello,

Just to say that I’ve managed to compile a very basic C# kernel to x86 machine code, and then successfully boot it in QEMU.

I've used the .Net AOT compiler that ships with .Net 7 / 8, as I found the C Sharp Bare Bones tutorial on OSDev Wiki quite out of date.

The repo for my kernel is here: PatienceOS (nb. ignore the 'OS' moniker, high ambitions I guess) and an accompanying blog post with more details here: Compiling a C# kernel to bare metal and booting in QEMU.

Posting this here, in case anyone else is interested in compiling a bare bones, bare metal, C# .Net kernel using contemporary versions of .Net.

Frank


Top
 Profile  
 
 Post subject: Re: Compiling a C# kernel to bare metal and booting in QEMU
PostPosted: Tue Feb 27, 2024 4:46 am 
Offline

Joined: Fri Jan 05, 2024 10:10 am
Posts: 4
Update - I've introduced XUnit and written some initial unit tests for several of the kernel classes. Interestingly, it involves building and linking the kernel against the standard .Net BCL, rather than zerosharp ie. being able to multi-target which BCL to use.

I took the idea from Building a self-contained game in C# under 8 kilobytes, namely:

Quote:
For example, parts of the game could be included from an xUnit project to get unit test coverage.

One VS solution builds and links the PatienceOS kernel against the custom .Net BCL (zerosharp based), handy for when you are coding within Visual Studio and want to quickly check building against the custom runtime types.

The other VS solution builds and links the PatienceOS kernel against the standard .Net 8.0 runtime, allowing you to develop and run unit tests within the built-in Visual Studio Test Explorer, as per any other .Net unit test project.

See instructions here: Developing PatienceOS

Regards,
Frank


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 27 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group