User:Tudoros1/OSes/Auckland
This page is dedicated to Auckland, my OS. Here are the main components
Kernel mode components
This area contains the kernel mode components in Auckland. Overall, in the OS proper, two kernel files, auckland.dll and KDKHal.dll, are all you need.
Auckland.dll
This is the kernel. It's name is a bit confusing. A .dll extension is used for plugin module like things. But the kernel isn't a plugin, it is an application in that it is able to be started. Then again, Windows 1.0 names its important parts kernel.exe, user.exe and gdi.exe despite the fact they are dlls.
Micro kernel
This part is what makes it a hybrid kernel is that the design is like a micro kernel in concept, but some servers are in kernel mode. It is a hybrid kernel because there are components that can go in user space. But some may call it a monolithic kernel because nothing in a fresh install is a user component.
It contains:
Time services
This is the area that contains the time related functions. It only contains 9 exported functions:
EXPORT int AklGetTime(POINTER time);
EXPORT int AklSetTime(POINTER &time);
EXPORT int AklGetDifference(POINTER diff);
EXPORT int AklSetDifference(POINTER &diff);
EXPORT int AklGetInterval(POINTER interval);
EXPORT int AklAddTimeIntervalCallback(POINTER callback, PDWORD id);
EXPORT int AklGetTimeIntervalCallback(POINTER &callback, PDWORD id);
EXPORT int AklRemoveTimeIntervalCallback(PDWORD id);
Scheduler
This is the area that is responsible for managing thread scheduling. It uses a AKL_SCHDL_X86_THREAD structure along with 2 variables. It has no exports:
typedef struct _AKL_SCHDL_X86_THREAD
{
NWORD greg[AKL_REGNUM];
X87_REG freg[8];
OCTUPLE_DWORD yreg[AKL_REGNUM];
NWORD dreg[AKL_REGNUM];
NWORD flags;
NWORD eip;
WORD sreg[6];
NWORD cr3;
NWORD filedisc;
NWORD exattr;
PAKL_SCHDL_X86_THREAD next;
PAKL_SCHDL_X86_THREAD prev;
} AKL_SCHDL_X86_THREAD, *PAKL_SCHDL_X86_THREAD;
LINKER(0) PAKL_SCHDL_X86_THREAD data;
LINKER(0) AKL_MK_MUTEX smutex
Memory manager
This part handles memory management. It has allocation functions, reservation functions, state get functions and state change functions. It also has a mutex and special finding functions.
The Common namespace
This is the most important part of the OS. I can't stress it's importance. It contains all files, registry entries, pipes, windows, shell objects, you name it. Like a UNIX file system, but more complete. Note: This could be part of the micro kernel, because the page fault handler is implemented here.
Types
Every object has a type, and every type has an object. The types are:
- Standard Object
- IO Object
- File
- Device
- Driver
- Pipe
- Section
- Directory
- Type
- IO Object
The Function Layer
This area takes up most of the kernel proper
Process and thread manager
While the Micro kernel is responsible for actual scheduling, this part is for high level stuff like sleeping, terminating, creating and starting. Loading an Executable is always a big struggle in Auckland. First you call AklNewProcess to create a process, AklNewThread to create a thread, AklLoadModule to load the executable and AklStartThread to start it. The function AklTerminateProcess is just a series of AklTerminateThread calls, an AklFlagThreadForTermination call, an AklFlagProcessForTermination call and a HLT instruction
IPC
The IPC mechanisms are layered for code reuse.
In shared memory, Auckland changes the Paging tables of 1 or both processes to point to the same area. Like this:
Thread1->CR3->PDE->PTE-> Memory <-PTE<-PDE<-CR3<-Thread2(Note, it's thread because one thread structure in a process describes the CR3 as well.
It can also make that area Read-only in 1 or both processes
Shared-Copied Memory is implemented on top of Shared Memory, but the areas are also marked Read-Only and when a page fault occurs at that address, it is copied and marked Writable
Pipes
Pipes are implemented on top of Shared-Copied Memory. In addition, it will free data already read, so if the sender had caused a copy and the receiver has read it, it gets freed.
Messages
Messages are packets passed through a pipe associated with the message queue. These messages are used to implement Asynchronous IO. Win32 window messages might be implemented using message queues.
Module Loader
This part of the kernel loads executable files into memory to save you the trouble. It supports MZ, NE, LE, PE, PE+, ELF, NOP and TCATEXE natively while other formats can be supported by adding System Components. Inherently, These components must be in one of the native formats. Using it, different formats can mix.
System Components
System Components are the heart and soul of extensibility in Auckland. So far these are the components that exist:
- AklComSS.exe (Auckland Common Subsystem) Contains the common DOS devices and CON, a symbolic link to the programs console
- AklAOA64.exe (Auckland Auckland On Auckland 64bit compatibility file) Handles 32bit syscalls and 32bit System Component compatibility.
- Drivers
- Executable format loaders (For the module loader).
IO Manager
Self descriptive name, it contains the file management functions, functions for common IO devices and PNP support and drivers.
The compiled drivers are:
- The PCI driver
- The UCHI driver
- The OCHI driver
- The ECHI driver
- The USB driver
- The PC Card driver
Session Manager
Ok now this is one important thing. A session is essentially a virtual Common Namespace. It contains Special ISC(Inter-Session Communication) functions for when you need to touch another session. Two sessions are made during start up:
- The special Component Session. Regular Auckland processes can't touch them easily.
- The regular Session. This is where the first user programs get loaded to.
More than one session can exist and be pre-emptive with all processes. Its just a virtual Common Namespace and a boundary. There is a kernel mode session space for session space programs.
RT (Runtime)
This is the CRT library. Not much to see here.
Syscall interface
This is the hole from User Mode to Kernel Mode. The Syscall interface is an int 2Ch instruction. The ax register contains the service requested. On entry it does a cli instruction, pushes the edx register, sets edx to the user stack, subtracts 16 from edx, copies 16 bytes from esp+4(not the return address) to edx and does a sti instruction.
The Sysenter instruction might be used instead. The ax register contains the service, the edx register the user stack, cx is our cs value (important in distinguishing between 32 bit and 64 bit in 64 bit) and bx is the ss. The flags are still in the flags register.
In either case, for future compatibly, the high word of eax is 0.
At its heart it dispatches calls by the bits 12-15 of the ax register. The current values are:
- 0 = Main services.
The main services dispatches calls even further than that, using bits 4-11. They are:
- Time and memory services (The micro kernel)
- File IO (The IO manager)
- Power (AklComSS.exe)
- Security (Syscall interface)
- IPC (IPC)
- Registry (IO manager)
- Module Loader (Module loader)
- Process (Process and thread manager)
- Threads (Process and thread manager)
In addition, the main services will perform security restrictions. While the main security check is in the function itself, this part prevents the call itself.
KDKHal.dll
The KDKHal.dll file is the OSes Hardware abstraction layer. There are 6 varieties in 32 bit mode:
- ACPI varieties
- KDKHala.dll for ACPI PIC
- KDKHalam.dll for ACPI APIC
- Legacy varieties
- KDKHal.dll for Legacy PIC
- KDKHalm.dll for Legacy APIC
It contains 4 services:
- Interrupt Controlling services.
- Time services.
- IO services.
- Basic File services (enough to get you booted, but not for Auckland)
Interrupts
The Hal contains lots of services, from setting up an IDT entry, to calling another processor.
Time services
This area helps the micro kernel time services work. It really a few calls for getting the interval and setting up your handler.
IO services
This contains C versions of out dx, eax and in eax, dx. This is very helpful for implementing your services.
Basic File services
Like read file and write file calls. Nothing more nothing less.
AklComSS.exe
This is the subsystem of Auckland. Anything the kernel realize on that can change, like the console drawing area, is in here. There are 3 parts:
- Console services (exposed by the CON filename)
- DOS names (like COM1, COM2, LPT1, LPT2, etc)
- Power services (Defers to Power.dll)
Note the extension .exe is used for programs. Another naming disaster.
User Mode
This part is User mode. This is where programs, User components and the API lives. There are no built in User Components but the API is. The API is the CRT library so any C program that uses the CRT can work on Auckland.
User Components
This is the System Components of User mode. There currently are no User Components, but they will come.
Programs
There are 2 programs that exists, aklinit.exe and aklshell.exe for startup. Another shell program, skytower.exe, and an archive program, museum.exe exist for use. Other programs are:
- shutdown.exe to shutdown (Not to be confused with shutdown.exe on Windows.
- write.exe for editing
- meow.exe for 100 meows to be printed
API
The API is in two pieces:
- AklCRT.dll, the CRT
- Akldll.dll, contains basic stubs and User Component interaction techniques
Other things
Here are things that I can't bother categorising
Help on the NTFS file system thats so woefully undocumented