Commit Graph

44 Commits

Author SHA1 Message Date
Eric-Paul Ickhorn ebb5a4ad92
Fix wrong memory address in driver manager
The  driver manager gave all  of the initialization  functions a wrong
pointer; it wasn't offset to point into the driver memory area. That's
fixed now.
2024-09-02 04:02:04 +02:00
Eric-Paul Ickhorn 40b89c3985
Refactor PCI device enumeration
The PCI driver's function  'pci_check_device_exists'  can now test for
a specific function. There were a few changes connected to that, those
have also been done now.
2024-08-30 20:19:07 +02:00
Eric-Paul Ickhorn 8127c67d30
Fix wrong write destination offset for RAM dump
The memory dump script didn't align the emulated physical memory space
correctly with the dumped memory counterpart. That's fixed now.
2024-08-30 03:50:41 +02:00
Eric-Paul Ickhorn 8703a97059
Dump more memory when using dump.bash
The dump script was limited to  the memory space below 0xa0000 because
the memory-mapped area of the framebuffer started above there,  making
the GNU Debugger refuse to dump that memory. Now, the script has got a
workaround for that.

The memory which is given to the emulated system is also reduced to 64
megabytes with this commit as to not use half a gigabyte of disk space
per memory dump.
2024-08-30 03:00:19 +02:00
Eric-Paul Ickhorn b1c7303b01 Document PCI driver API
The PCI driver API is now documented, the documentation explains which
functions have to exist in a driver for it to be recognized as capable
of being used as default PCI driver.

Some functions, namely those for interacting with a device, are not
documented yet because there is also no code for that yet.

The functions that need to be supported may increase, but a a decrease
is relatively unlikely.
2024-08-23 18:10:32 +02:00
Eric-Paul Ickhorn 21c873a8f5 Add driver slot documentation
Driver slots had a structure before, but now, it's defined how the
layout should be done. The design was also changed significantly, so
the PCI and ACPI drivers have to be changed now.
2024-08-22 15:08:36 +02:00
Eric-Paul Ickhorn 2ad0d26ff4
Add documentation for textlog driver
The textlog driver isn't quite usable yet, but the documentation for
is being added with this commit because the driver will be a little
more complex; requiring planning which is done using the docs.
2024-08-17 23:22:06 +02:00
Eric-Paul Ickhorn f0fcefc5eb
Add folder structure documentation for i386
As the project grows, it's a good idea to have an overview of the
project as a big picture. The newly added file will provide that big
picture for when the project is too big to read through for making a
small change. It contains unimplemented things in the described
folder structure (AHCI) as well as a documentation folder, which also
doesn't exist yet.
2024-08-17 19:04:18 +02:00
Eric-Paul Ickhorn c249510163
Fix bug in PCI driver with not saved registers
In the PCI driver's device enumeration function, there was a mistake
where a register that is being used in that function wasn't preserved
as it should've been. It didn't cause any errors (at least yet), but
it's better to fix such stuff once found.
2024-08-17 18:59:52 +02:00
Eric-Paul Ickhorn 459936de7a
Call driver setup function in protected entry
The driver manager's function for initializing all builtin drivers is
now being called in the 'stage2_protected_entry'-function, a function
that is called once the GDT is set up and calls all other functions
to get the system to boot.
2024-08-17 18:57:49 +02:00
Eric-Paul Ickhorn f73227fe74
Fix two syntax errors in ACPI utilities
The first one was a stray letter 'Z' somewhere in the source.
The second one was an error due to some changes being half-done; an
assembly label that did not yet exist was used.

Those two errors are fixed now.
2024-08-17 17:06:09 +02:00
Eric-Paul Ickhorn 916d7bd030
Initialize ACPI driver in manager
The previous commit said that this is being done, but it didn't have
the changes in the driver manager. Those are here.
2024-08-17 17:01:20 +02:00
Eric-Paul Ickhorn 2923a300b5
Write some ACPI stubs
The ACPI driver is not required yet, but some stubs have already been
added to the sources; only to test the driver initialization function
of the driver manager.
2024-08-17 16:52:17 +02:00
Eric-Paul Ickhorn 21ba34f526
Fix stack growing direction in GDT being swapped
In the GDT, the direction in which the stack grows in x86 has been
ignored; for reserving space on the stack, the ESP register was added
to and for cleaning up that space, ESP was subtracted from. That is
obviously wrong and is fixed with this commit.
2024-08-17 16:46:23 +02:00
Eric-Paul Ickhorn 95faf0cc5a
Add procedure for searching RSDT Pointer (RSDP)
The newly added function only searchs the "RSD PTR "-signature in the
Main BIOS Area, not in the *Extended* BIOS Area. That should be fixed,
but right now, it's of little relevance.
2024-08-14 10:24:16 +02:00
Eric-Paul Ickhorn 1b7ef62c61
Rename legacy boot code for clarity
As the legacy boot code will be abandoned for the time being, it made
sense to rename the folder to indicate the legacy nature of the code.
2024-08-07 10:28:40 +02:00
Eric-Paul Ickhorn 7abe0539f9
Make finishing touches before UEFI addition
As legacy BIOS isn't as straightforward to develop using a modern
system, modern emulators/VMs and virtual machine firmware, it was
decided to start work on an UEFI version of the Nightloader.

This commit leaves the not-yet boot-capable, but as far as it's
there already assembling and working legacy BIOS code behind for
later work on this edition.
2024-08-07 10:06:18 +02:00
Eric-Paul Ickhorn 65db388f00
Fix A20 by copying others' implementation
The implementation of the A20 wraparound check was off in some way,
which is why the new implementation was copied from osdev.org, just
using minor modifications to the label naming.
2024-08-06 13:25:42 +02:00
Eric-Paul Ickhorn 5ba30e5f8b
Fix GDT length being insufficient
The value of the GDTR register was set to be 8 bytes too small, with
the effect that an accurate emulation software would error out because
of trying to read over the buffer size, as was noticed when using KVM.

This was due to the perception that the 0th index wouldn't be taken
into account; for that reason, the length of the GDTR was one index
short of what it should've been.
2024-08-06 13:20:40 +02:00
Eric-Paul Ickhorn fd8b5bd57e Fix bug in GDT when using KVM acceleration
The bug was due to the DS segment being set to the 0th segment entry,
causing a general protection fault.
2024-07-30 08:52:24 +02:00
Eric-Paul Ickhorn 0d16e3e35a
Make driver initialization easier in manager.asm
With this change, the driver's setup function only has to be added
to the 'driver_init_functions'-array and it will be called once
'setup_drivers' is called.
2024-07-24 00:14:55 +02:00
Eric-Paul Ickhorn 6e8e022937
Make stage 2 entry (after GDT) call driver setup
The driver setup, which in turn calls all the drivers' setup functions
wasn't being called until now. Now, it is included and being called.

The test text which was used to test some display functions in older
revisions is also gone now.
2024-07-23 23:57:58 +02:00
Eric-Paul Ickhorn 94e5e70305
Add driver manager's setup routine
The setup_drivers routine existed locally for some time now, so now
it also exists in the repository. It has gone through two iterations:

1. The drivers are all listed in a null-terminated array of function
   pointers to initialization functions (this didn't work and the time
   for debugging just wasn't there).

2. All drivers (currently, only the PCI driver, because that's the
   only one that exists) are initialized after each other; their
   initialization functions are called manually.

It might be possible that the bug from the first iteration was due to
the memory space being offset by 128 or 256 bytes; it might be useful
to use that concept again because then, it will be easier to add new
drivers. That's not of high importance now, though.
2024-07-23 01:04:35 +02:00
Eric-Paul Ickhorn 18e5b049a4
Add PCI register read utility
The newly added utility routine reads the content of a known PCI
device's register given the index assigned to the device during
enumeration and the index of the register (and the PCI driver area,
but that is implied).
2024-07-23 01:01:20 +02:00
Eric-Paul Ickhorn 1285994cbf
Improve coding style of PCI device enumerator
The arguments of all of the statements are now indented and one or two
comments have been rewritten partially, improving readability.
2024-07-23 00:51:04 +02:00
Eric-Paul Ickhorn 4d9b1e390d
Make PCI enumeration write more information
The PCI enumeration did, until now, only write a PCI device's address
into the device area. Now, it also writes the class and subclass.
2024-07-21 10:26:32 +02:00
Eric-Paul Ickhorn 6ce831bbeb
Fix text display for rows other than the first
Because the calculation of the byte offset within the framebuffer was
wrong, the framebuffer could only be written to on the first line.
That is now fixed.
2024-07-21 06:01:41 +02:00
Eric-Paul Ickhorn 4acf6f3a44
Add hexadecimal dump function
The function which is added with this commit writes a caller-supplied
hexadecimal string of a caller-supplied length to the display, nibble
by nibble, leaving the background black and making the text white.
2024-07-21 02:54:48 +02:00
Eric-Paul Ickhorn 6342b433b4
Add main PCI driver file and device enumeration
In this commit, the PCI driver can finally enumerate the devices in
the system. Some other things are still not pushed.
2024-07-20 18:54:10 +02:00
Eric-Paul Ickhorn 3a778fee44
Add scripts for running bootloader and memdumping
This commit adds two scripts: One for running the bootloader using
Qemu, and one for dumping the memory used by the bootloader for
debugging purposes.
2024-07-19 01:51:28 +02:00
Eric-Paul Ickhorn f573f49874
Fix GDT error offsetting memory by some bytes
The error in the GDT caused the whole memory space to be offset by
128B or 256B (It's not entirely sure which one of those). This was
only made visible by later changes, but now it's fixed.
2024-07-19 00:12:52 +02:00
Eric-Paul Ickhorn a72a41c3ac
Change final bootsector jump to be a near jump
This commit changes the final jump from the bootsector to the second
stage (the partition which gets loaded completely) to be a near jump.
That's important to keep consistency with protected mode.
2024-07-07 13:43:07 +02:00
Eric-Paul Ickhorn 44ca45e8f1
Finish up GDT, get linear address space working
The GDT is now finally set and produces a linear address space.
Execution continues at 'stage2_true_entry'.
2024-07-06 00:12:07 +02:00
Eric-Paul Ickhorn 0d49245a60
Delete GDT-related files
This commit deletes the gdt.asm for the i386 architecture as it was
quite buggy in that state. In a short while, the real GDT code which
works is going to be committed.
2024-07-06 00:12:06 +02:00
Eric-Paul Ickhorn 993864e364
Save progess, then delete GDT for rewrite
This commit saves the progress made on the GDT; the files are deleted
quickly thereafter as the code was quite buggy.
2024-07-06 00:12:06 +02:00
Eric-Paul Ickhorn 83eb29d55c
Try to fix GDT; unsuccessful
This commit just existed because of a misunderstanding leading to the
belief that the GDT was finally working; it wasn't though.
2024-07-06 00:12:06 +02:00
Eric-Paul Ickhorn 776da2f85a
Add README.md for loader on i386
This commit adds a README.md file for the loader partition in the i386
architecture version. The README contains basic information about what
the loader partition has to do and to some degree on how it should be
accomplishing those tasks.

It is just general information which can be useful to have for looking
information up after some time.
2024-07-06 00:12:06 +02:00
Eric-Paul Ickhorn 3a2518ca8f
Add build script
This commit adds a build script for the loader partition. Currently,
it is very simplistic, but it works for assembling the entry.asm,
which in turn includes all other files.
2024-07-06 00:11:14 +02:00
Eric-Paul Ickhorn 5180348c39
Add stage 2 loader entry point
This commit adds the entry point for the second stage of the loader.
It currently doesn't contain a lot of code, but it will have to expand
in the next bit of time.
2024-07-06 00:08:57 +02:00
Eric-Paul Ickhorn d773a8f9e2
Add memory utilities and math utils
This commit adds the well known primitive memory functions:

- Copy Memory
- Compare Memory for being equal
- Set Memory to a value

It also adds a math utility file at the according location.
2024-07-06 00:07:08 +02:00
Eric-Paul Ickhorn c3f2c7fbfc
Intermediate commit to add GDT
In this commit, it was tried to set a linear GDT. It didn't work; but
in the future, it will.
2024-07-06 00:05:17 +02:00
Eric-Paul Ickhorn 94a228b278
Add A20 line check
This commit adds a check for whether the A20 line is usable; checking
whether more than one megabyte of RAM can be used. If it isn't usable,
it currently isn't activated, but rather, the boot process is stopped.
2024-07-06 00:03:48 +02:00
Eric-Paul Ickhorn aa09696218
Add .gitignore with binary executable files
This commit adds a basic .gitignore which only contains machine code
file endings; files which shouldn't be committed as they're better to
be distributed in other ways.
2024-07-06 00:02:38 +02:00
Eric-Paul Ickhorn 757457d456
addition(bootsector) 2024-06-14 13:26:54 +02:00