Last modified 5 years ago Last modified on 02/18/15 06:59:38

PhobOS Root project

PhobOS Root - is object-oriented operating system completely written in C++ (just several files in assembler are used). It is written in purely educational purposes and can be used as a reference by anyone. While having a lot of fun writing this OS the author will use it as a code base in his next PhobOS Atomic project which is completely different animal - absolutely different OS with completely different architecture and purpose. Source code of PhobOS Root can be obtained from svn repository ‚Äč or be browsed here.

PhobOS Root implements many OS fundamental features like:

  • Multiboot loading - can be loaded by any multiboot-complient loader like GRUB.
  • Memory manager with PAE and eXecute Disable support. There are several types of allocators used in the system - original enhanced buddy allocator and slab allocator in the kernel, and scalable slab allocator in the user space. Unlimited amount of physical memory supported with recursive mapping of page tables - it uses BSD approach for pages handling. Objects layered model is implemented. Objects can be backed by file or swap. They can be mapped for shared or private access (with copy-on-write processing in the latest case).
  • SMP awareness - PhobOS Root supports any number of CPUs and has SMP kernel.
  • Interrupts Manager - provides convenient API for registering hardware or software interrupts handlers with required priority.
  • Devices Manager - provides framework which makes adding and using devices simple.
  • Processes Manager - processes and threads scheduling, balancing and contexts switching. Have simple wait-API to make threads waiting for some event. Threads are supported natively by the kernel.
  • Built-in debugger - provides simple shell for examining system state when stopped (e.g. during panic). But main power is remote GDB stub which implements remote GDB protocol via serial port and allows to conveniently debug the OS from your IDE.
  • System calls interface - the most tricky feature of the system. It is completely original idea. Adding new system call in the kernel is as simple as adding new virtual method in class which is derived from special GateObject class. All the rest is done by the framework - virtual method pointer is replaced by the kernel mode entry point where all parameters are validated, CPU switches to kernel mode, stack mapping is verified and kernel switches to user stack allowing to pass any number of arguments in a gate method. So the call is done transparently for both sides - in the kernel you just define new virtual method for a class, in the user space you just call it. All the magic is done behind the scene. No designated numbers for all your calls, no arguments number limitation, no wrappers for each system call in the user space libraries.
  • ELF binaries loading - the kernel is able to start user space process using standard ELF binary. It handles both static and interpreted binaries (which have PT_INTERP entry in their header).
  • Run-time linker - specified as interpreter for dynamic binaries (usual approach on UNIX systems). Resolves all dependencies and load all ELF shared libraries required for the binary. Performs all kinds of relocations. Run-time linker object persists for process life time and its methods can be called in run-time to get any symbol relocated address or dynamical load or unload new library in run-time.
  • Memory filesystem is compiled in the kernel with ext2 filesystem handled by corresponding drivers.
  • and other features which better to see from the code.

Initially the idea was to continue the system development until nice demo with GUI will be ready. Now when the most part of the platform low-level stuff is ready it could take just several steps to reach this target. What is needed is to add framebuffer driver, several libraries in the user space and demo applications. But I had a completely new idea recently - design completely new OS with not only educational purposes. While PhobOS Root has nothing so special - just is written in C++ and has original system calls interface - new OS - PhobOS Atomic - will have completely new architecture with new approaches to OS design. So the further development of PhobOS Root is stopped but some amount of its code will have a new life as code base for the new project.