(disclaimer: not actually a kernel)
A single-threaded 32-bit kernel-level program for the x86 architecture written in Odin, because why not.
Certainly Odin is better fitted to doing this than C++.
This project is set free under the Unlicense. Do with it as you wish, I only ask as a matter of courtesy (NOT legal requirement) that you credit me as appropriate.
(only instructions for Linux is provided)
NOTE: you have to have cross-compilation binaries for C installed at ~/opt/cross/bin to compile the kernel
Currently the Odin compiler does not by default support a freestanding x86 target. As such you'll have to patch the Odin compiler to get this project working.
See the heading "Patching the Odin compiler", and place your patched odin executable at ../Odin/odin.
You can build the kernel as follows:
$ ./build.shIf you have QEMU installed you can run it as follows:
$ ./build.sh run # build and run
$ qemu-system-x86_64 -kernel myos # run onlyYou can also create a bootable ISO using grub-mkrescue by running the ./make_grub.sh script.
Note that I have already applied these patches myself,
you can also download my fork of Odin and switch to the i386 branch,
but it is pretty much unmaintained so be warned.
(It works on my laptop so I'm happy with it, if you experience issues you're on your own)
- Download the Odin compiler source into the same directory you downloaded this repo
- In
Odin, opensrc/build_settings.cpp, and add the following code:-
Around line 872:
gb_global TargetMetrics target_freestanding_i386 = { TargetOs_freestanding, TargetArch_i386, 4, 4, I386_MAX_ALIGNMENT, 16, str_lit("i386-unknown-elf"), }; -
Around line 940, after the entry for the
freestanding_amd64_mingwtarget:{ str_lit("freestanding_i386"), &target_freestanding_i386 },
-
- Build the compiler with
./build_odin.sh, and Voilà! you can now compile this project.