Duje Mihanović [Tue, 28 Jun 2022 10:39:28 +0000 (12:39 +0200)]
Complete build system rehaul
Inspired by Linux, the top Makefile is more recursive and practically every
directory has its own sub-Makefile which builds or includes only code inside its
directory. This new system works beautifully with -B and parallel jobs, while
the previous one would in either case build the bootloader multiple times (and,
in the case of parallel jobs, cause weird sporadic build errors).
Duje Mihanović [Fri, 13 May 2022 12:17:31 +0000 (14:17 +0200)]
(VERY BROKEN) Enable paging
This code (somewhat) successfully enables paging and identity maps addresses
0xB8000-0xBFFFF and 0x100000-0x10FFFF. I say somewhat because enabling paging
for some reason completely breaks interrupt and exception handling, making the
CPU triple fault on any keypress or other exception. For that reason, DO NOT USE
THIS.
Duje Mihanović [Sat, 18 Jun 2022 13:38:14 +0000 (15:38 +0200)]
Compile stage3 in ELF format
During linking it gets converted to a good old flat binary. This was done so
that the ELF loading code can be written in C, which will save me plenty of
headaches later.
Also, since with ELF that's possible, stack space for stage3 is now reserved and
set up in a similar (same) fashion to the kernel.
Duje Mihanović [Fri, 13 May 2022 12:17:31 +0000 (14:17 +0200)]
(VERY BROKEN) Enable paging
This code (somewhat) successfully enables paging and identity maps addresses
0xB8000-0xBFFFF and 0x100000-0x10FFFF. I say somewhat because enabling paging
for some reason completely breaks interrupt and exception handling, making the
CPU triple fault on any keypress or other exception. For that reason, DO NOT USE
THIS.
Duje Mihanović [Sun, 8 May 2022 12:47:14 +0000 (14:47 +0200)]
Fix interrupt trap gates
Until now the code would set the most significant bit in the type part
of the IDT descriptor for trap gates as a result of my error, causing a
triple fault when trying to handle a double fault. A less significant, but still
noteworthy change is that the double fault handler has been slightly revamped to
print out :( on a red background and no longer spits out a warning because I
accidentally wrote a string there, not a char.
Duje Mihanović [Sun, 8 May 2022 11:28:47 +0000 (13:28 +0200)]
Delete the old bootloader
The new FAT32 bootloader has reached feature parity with the old bootloader (can
actually load the kernel). The new bootloader also brings some nice improvements
over the old bootloader such as loading the kernel at 1MB (fixing the potential
issue that when the kernel grows large enough it will overwrite the EBDA and
upper RAM before it ever happened) and automatically adapting to the kernel
size, and as such I believe that there is no reason to keep the old bootloader
in the source tree.
Duje Mihanović [Sat, 30 Apr 2022 20:23:40 +0000 (22:23 +0200)]
Separate loading clusters and cluster chains
This will be crucial for stage 3 loading the kernel, because we will need to
relocate each cluster to 0x100000 (or somewhere after that) manually, and we
can't just do that in the driver as it's also used by the VBR which does not run
in unreal mode.
Duje Mihanović [Sat, 30 Apr 2022 14:35:18 +0000 (16:35 +0200)]
Fixes and improvements to FAT32 driver
* Fix issue where multiple clusters would be loaded 0x800 apart rather than
contiguously.
* Get rid of some global variables, saving space.
* si points to the start LBA address rather than the partition table entry,
saving a bit of space as we no longer need to use offsets.
* In read_cluster_chain, drop push/popad as they in fact do not
save the upper 16 bytes of the registers. Instead, just push
and pops the registers that are used.
Duje Mihanović [Wed, 22 Sep 2021 20:15:40 +0000 (22:15 +0200)]
Handle interrupts
Currently handles exception 8 and IRQ 1. EXC8 is double fault, and IRQ1 is
keyboard. EXC8 handler puts out a ':(' on the top left corner of the screen and
halts the machine, while IRQ1 puts out a string on the screen. However, it will
only do so once, and I have yet to figure out why.