The last few days I have been thinking of different ways we can structure the OS for our series. What I would like to do is provide an easy structure that will allow ease of expandability and modification.
The basic idea is to completely seperate the Kernel from the C++ runtime initialization code, along with the HAL.
Surprisingly, I have not seen many OS projects do this.
My primary purpose is to insure the Kernel does not directly require specific compiler extensions to insure it is easier to port, and to insure there is no hardware dependent code within the kernel.
Also, By building each project - The CRT (C++ Runtime) Library, Kernel Program, and a HAL Program, into libraries, and link the Kernel with these libraries. As these are libraries, they can be designed to support *.dll library linkage as well.
This also allows us to treat the HAL and CRT as dynamic libraries, and easier add support for it later on.
^^This is my plan for the rest of the series. It does make things a little more complex, but more expandable and more easier to modify and upgrade. It will also help maintain portability for the system.
In looking at this setup for my current demo source, it looks very nice, and works well.
This is the current structure:
/Include -- Standard C++ Include directory
/Lib -- Standard C++ Runtime. Primary initialization program. Includes
mainCRTStartup() and standard library routines.
Outputs Krnl32.exe and Crtlib.lib, as it is the main program.
After initializing the basic C++ functionality, executes Kernels
kmain() initialization routine.
/Hal -- Hardware Abstraction Layer. Outputs Hal.lib and/or Hal.dll.
Statically linked with Kernel.lib so the Kernel
can access hardware dependent features.
/Kernel -- Main kernel program. Executed by Crtlib. Kernel program
never returns to any location. Linked with Hal.lib so
the Kernel can access hardware. Linked with Crtlib.lib
for access to C++ standard routines (printf, puts, etc.)
/Init -- Kernel initialization startup code. Executed by Crtlib.h.
Contains kmain(). First Kernel routine. Initializes HAL
through the linkage of the kernel. Initializes all kernel
Because we do not have a video driver of any kind at the moment, we might allow basic video output through the HAL.
At the moment, any output routines will be hard coded. We can provide a way of retrieving video information and basic text output through a basic video interrupt defined within the Kernel. This may be later though, but will remove hardware dependencies from the standard library routines.