A little thing called OS..
2 months ago, I got an idea that it would be great to learn "How to make an OS" from scratch. So I got to work looking for all the resources that I can find on this topic. Luckily, there are many people who want to make OS ( Gosh, how many linux flavours you can find ), so someone teamed up and created a (not-so) "Little Book About OS".
So, I thought, well I got the book, I got the tools, so let's get cracking. But as always, the universe conspired to not let me do it. First thing, it required Linux as base. So what I thought, I can make it run on windows with some tinkering. Turns out either windows doesn't support this sort of tinkering, or I am a bad tinkerer ( more plausible ).
Ofcourse I couldn't install Linux virtual machine on my already breaking laptop. So I had to wait a whole month before I got hold of my recent laptop, so that I can install linux vm on it. So, now I am beginning to write my OS. Yay! Let's see how it goes.
So, my current progress in OS building is as follows :
- Created a loader assembly code, that has the MAGIC_NUMBER that GRUB requires to validate the loader file as a bootloader, setup a stack ( actual stack pointer ), and a little code that calls an external C function to add numbers and store the result in the EAX register.
- Created a linker script that basically just tells where to enter the loader script, as well as what section the loader contains and how they should be aligned.
- Created a C file with a single function that adds 3 numbers and returns them. This C file should be compiled with a hell lot of flags such as "nostdlib" because, guess what, we don't have anything at all yet, let alone the standard libraries and stuff. So, it should be plain C code compilation.
- We link the loader and this compiled C code into a ".elf" file ( executable and linkable format ), and then create an iso file using "geniso".
After doing these tiresome things came the best part, to host the ISO image. But running this basic OS in a virtual machine seems like an overkill. So instead we use an emulator called "BOSCH". But again, somebody up there didn't want a successful run so easily. So, it prevented BOSCH from using the "sdl" display library. So naturally, I thought this should be a recurring issue, and it should have an answer somewhere.
I was half correct, it was a recurring issue, "But it didn't have an answer". In the end, I found the answer by using sophisticated debugging methods ( read as random trial and error ).
So, finally today, atleast I have a working OS that adds 3 numbers. Yay! Let's hope I can do something a little less worthless tomorrow. :D
:haha
ReplyDeletewow man this is really good, nicely written :)