The birth of a new OS: VOS
Gain of interest
Something that has always fascinated me was the interaction of PC's with hardware. When I was very little, I learned to program in QuickBASIC and had to poke around in memory, use in and out and use interrupts, to control for instance the parallel port.However, in modern operating systems you can't poke around any more. Devices have become significantly more difficult to use, and this meant that this was all way out of my league. Years have passed, and I started becoming more and more familiar with Linux and later FreeBSD. For a job I had a little while ago I was working with a Linux kernel on an ARM chip and found out that I really needed a driver for something that didn't exist. Now, this nostalgia of using interrupts, poking around in memory etcetera has all come back.
Initial design
Then you'll find yourself in the phase where you define what you want. Of course, I could write an UNIX kernel, aim for maximum stability and portability. But that trick has been mastered by Linux / FreeBSD already, so that's nothing new or special. Of course, I'll learn a lot from it, but it won't actually be an improvement on anything. However, what about an OS that does something weird, but useful?One thing lead to another and I ended up making a design for a kernel which could load LLVM binaries. This would make it possible to run the same executable on a lot of platforms. And that's where things started.
VOS - Virtual Operating System
And VOS will strive to have the following features:- Portable LLVM based executables
- Object oriented operating system interface
- Real-time support
- Graphic support
- Networking support
- USB support
- Bluetooth support
- A rudimentary C interface
- A POSIX and pthread implementation
- x86 (though mostly using VirtualBox / QEMU)
- x86_64
- ARM on the Beaglebone Black board
Where to start?
Okay, so you have an idea. However, writing an operating system is inherently more difficult than just writing a program. You'll end up reading a lot of assembly (and of course, writing it). You have to set up weird compilers, assemblers in order to create code for x86 (if you're running x86_64), you need a good testing environment and debuggers, and loads of documentation. Most importantly, you will need to have a tremendous amount of patience.A very good place to start is a website called osdev.org. Another great source of documentation are existing open source operating systems. I can really recommend taking a look at the Linux and FreeBSD kernels for information about devices. While the Intel Architecture doc's are pretty good, I find that they often lack the higher level information. Kernel sources on the other hand often give a great insight in why and how certain pieces of hardware are used. Another good source of help are the IRC channels #programming, #osdev and #oszero on freenode.net.
Tools
As long as you're not running 16-bit code, the best compiler available is - in my opinion - clang. Not only are the error messages way more understandable than for instance GCC, it also means you don't have to go through the delicate process of setting up cross compilers. In my case, this also gives another great advantage: it uses LLVM as back end, which will come in handy later on when I'm actually able to run LLVM binaries. The debugger I'll be using will be good old gdb, and QEMU will be my emulator. Since writing a bootloader is literally no fun, I use GRUB as bootloader.
Writing makefiles to automatically set up your toolchain and building an image will save you a lot of time as well. I'm developing on two machines and performing a simple svn checkout followed by a make is significantly less work than having to spend hours trying to figure out how exactly you have to set up binutils / clang / grub as well.
Further tips
Although it is possible to write a functional operating system on your own, it really pays off to have some friends help out. Make sure you have a working source of caffeine, because you'll need it. Have a nice chair to program from, some nice calm monitors, open a lot of terminals to write your code and your man-cave is complete. Now start writing your own OS.My project is currently located at GitHub! Don't expect anything but stubs and broken features, although I hope this will significantly improve in the future.
Comments
Post a Comment