How is this boot and loading process?
Posted: Sat Aug 24, 2019 1:26 am
Hi! I have been doing a little bit of designing here and there. I have not had much time to do anything osdev related because I have a job now, but I got a little bit done, and I am looking for your opinions. Thanks!
So the load process is as follows:
On the System-Disk (floppy, there is currently no concept of installing to any non-removable storage device), the system's kernel (doskrnl.exe) and the kernel loader (dosldr.exe); of which, only doskrnl.exe is partially loaded, because of the fact that this 'executable file' contains 16 and 32 bit code; the loader is completely 16 bit, and the boot-sector does this work.
dosldr.exe then does nothing but detect hardware, load drivers, and enable the a20-gate. Once this is done, it moves doskrnl.exe past one megabyte, loads the rest of doskrnl.exe (everything 32 bit), and transfers execitution to it's 16 bit segment.
The 16 bit portion of doskrnl.exe sets up the descriptor tables, enables protected mode (The protected-mode part being everything that is not basic setup code, and everything which is functional), and then starts the actual kernel.
There is no concept of an 'init task' or an 'init process' like others talk about. The entire setup happens within the 16 bit segment of doskrnl.exe, and a very small portion of the non 16-bit code. (Should there be an init process? What would the pros and cons be?)
Really, the only 'setup' code that happens in protected-mode would be stuff like loading libraries, starting system services and kernel-drivers, and stuff like that. If it turns out that an actual process would be better than just wielding this into the kernel, I guess this could be put into a process, but I am trying to keep the concept of a 'process' as exclusive to user-mode as possible, and (POSSIBLY) only make exceptions for (certain) kernel-mode drivers.
Anyway, I think that it's a pretty solid setup routine. But I really would like some opinions and critiques. I feel like I'm taking a lot of inspiration from ntoskrnl.exe, but I don't completely know how it works, anyway, so meh. Hahahahaha
So the load process is as follows:
On the System-Disk (floppy, there is currently no concept of installing to any non-removable storage device), the system's kernel (doskrnl.exe) and the kernel loader (dosldr.exe); of which, only doskrnl.exe is partially loaded, because of the fact that this 'executable file' contains 16 and 32 bit code; the loader is completely 16 bit, and the boot-sector does this work.
dosldr.exe then does nothing but detect hardware, load drivers, and enable the a20-gate. Once this is done, it moves doskrnl.exe past one megabyte, loads the rest of doskrnl.exe (everything 32 bit), and transfers execitution to it's 16 bit segment.
The 16 bit portion of doskrnl.exe sets up the descriptor tables, enables protected mode (The protected-mode part being everything that is not basic setup code, and everything which is functional), and then starts the actual kernel.
There is no concept of an 'init task' or an 'init process' like others talk about. The entire setup happens within the 16 bit segment of doskrnl.exe, and a very small portion of the non 16-bit code. (Should there be an init process? What would the pros and cons be?)
Really, the only 'setup' code that happens in protected-mode would be stuff like loading libraries, starting system services and kernel-drivers, and stuff like that. If it turns out that an actual process would be better than just wielding this into the kernel, I guess this could be put into a process, but I am trying to keep the concept of a 'process' as exclusive to user-mode as possible, and (POSSIBLY) only make exceptions for (certain) kernel-mode drivers.
Anyway, I think that it's a pretty solid setup routine. But I really would like some opinions and critiques. I feel like I'm taking a lot of inspiration from ntoskrnl.exe, but I don't completely know how it works, anyway, so meh. Hahahahaha