From 4159b2c7a73a93969d2819a1e15e9fcde039a6ba Mon Sep 17 00:00:00 2001 From: Knud <113939798+KnudAndersen@users.noreply.github.com> Date: Tue, 22 Jul 2025 16:04:37 -0500 Subject: [PATCH 1/6] Page Fault Vector Typo --- 04_Memory_Management/03_Paging.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/04_Memory_Management/03_Paging.md b/04_Memory_Management/03_Paging.md index 5a95bf8..bf6f73b 100644 --- a/04_Memory_Management/03_Paging.md +++ b/04_Memory_Management/03_Paging.md @@ -85,7 +85,7 @@ There are 3 possible scenarios: * 2Mib Pages: in this case we only need 3 page levels. * 1Gib Pages: Only 2 levels are needed. -To implement paging, is strongly recommended to have already implemented interrupts too, specifically handling #PF (vector 0xd). +To implement paging, is strongly recommended to have already implemented interrupts too, specifically handling #PF (vector 0xE). The 4 levels of page directories/tables are: From daf5c48451ccadbec4542264e8b440d5a345cd64 Mon Sep 17 00:00:00 2001 From: Knud <113939798+KnudAndersen@users.noreply.github.com> Date: Tue, 22 Jul 2025 16:19:58 -0500 Subject: [PATCH 2/6] Femtoseconds conversion --- 02_Architecture/08_Timers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/02_Architecture/08_Timers.md b/02_Architecture/08_Timers.md index 5fc6fbe..32c5027 100644 --- a/02_Architecture/08_Timers.md +++ b/02_Architecture/08_Timers.md @@ -143,7 +143,7 @@ Each register is accessed by adding an offset to the base address we obtained be - General configuration: offset `0x10`. - Main counter value: `0xF0`. -We can read the main counter at any time, which is measured in timer ticks. We can convert these ticks into realtime by multiplying them with the timer period in the general capabilities register. Bits 63:32 of the general capabilities register contain the number of femtoseconds for each tick. A nanosecond is 1000 femtoseconds, and 1 second is 1'000'000'000 femtoseconds. +We can read the main counter at any time, which is measured in timer ticks. We can convert these ticks into realtime by multiplying them with the timer period in the general capabilities register. Bits 63:32 of the general capabilities register contain the number of femtoseconds for each tick. A nanosecond is 1'000'000 femtoseconds, and 1 second is 1015 femtoseconds. We can also write to the main counter, usually we would write a 0 here when initializing the HPET in order to be able to determine uptime, but this is not really necessary. From b0bc4e21a5d9a085e141519ece45192fefb4dbcc Mon Sep 17 00:00:00 2001 From: Knud <113939798+KnudAndersen@users.noreply.github.com> Date: Tue, 22 Jul 2025 16:22:56 -0500 Subject: [PATCH 3/6] RSDP Typo The signature for the RSDP is "RSD PTR ", and it is not an SDT. https://uefi.org/specs/ACPI/6.5/05_ACPI_Software_Programming_Model.html?highlight=rsdt#root-system-description-table-rsdt --- 02_Architecture/06_ACPITables.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/02_Architecture/06_ACPITables.md b/02_Architecture/06_ACPITables.md index c903acc..be948b2 100644 --- a/02_Architecture/06_ACPITables.md +++ b/02_Architecture/06_ACPITables.md @@ -124,8 +124,8 @@ The RSDT is an SDT header followed by an array of `uint32_t`s, representing the The XSDT is the same, except the array is of `uint64_t`s. ```c -struct RSDP { - ACPISDTHeader sdtHeader; //signature "RSDP" +struct RSDT { + ACPISDTHeader sdtHeader; //signature "RSDT" uint32_t sdtAddresses[]; }; From b8f30303f6e7197f121b63b16062d40709c7d42c Mon Sep 17 00:00:00 2001 From: Knud <113939798+KnudAndersen@users.noreply.github.com> Date: Tue, 22 Jul 2025 16:43:48 -0500 Subject: [PATCH 4/6] APIC Address Incorrect Fixed the description of the APIC address (the physaddr is not shifted, but the lower bits are masked), and fixed a typo with the location. On my ``qemu-system-x86_64``, the LAPIC base is 0xFEE00000 in physical memory. --- 02_Architecture/07_APIC.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/02_Architecture/07_APIC.md b/02_Architecture/07_APIC.md index be816af..9380c22 100644 --- a/02_Architecture/07_APIC.md +++ b/02_Architecture/07_APIC.md @@ -63,10 +63,10 @@ This register contains the following information: * Bit 8: if set, it means that the processor is the Bootstrap Processor (BSP). * Bits 9:10: reserved. * Bit 11: APIC global enable. This bit can be cleared to disable the local APIC for this processor. Realistically there is no reason to do this on modern processors. -* Bits 12:31: Contains the base address of the local APIC for this processor core. +* Bits 12:31: Contains the base address of the local APIC for this processor core. NOTE: The value read from these bits should not be shifted, e.g. if you read ``0xFEE00``, then the address is ``0xFEE00000``, just with bits 0:11 zeroed out. * Bits 32:63: reserved. -Note that the registers are given as a *physical address*, so to access these we will need to map them somewhere in the virtual address space. This is true for the addresses of any I/O APICs we obtain as well. When the system boots, the base address is usually `0xFEE0000` and often this is the value we read from `rdmsr`. For correct operation the local APIC registers should be mapped as 'strong uncachable'. +Note that the registers are given as a *physical address*, so to access these we will need to map them somewhere in the virtual address space. This is true for the addresses of any I/O APICs we obtain as well. When the system boots, the base address is usually `0xFEE00000` and often this is the value we read from `rdmsr`. For correct operation the local APIC registers should be mapped as 'strong uncachable'. A complete list of local APIC registers is available in the Intel/AMD software development manuals, but the important ones for now are: From 638518c72ce4bfa08d53beda8200c71aea716406 Mon Sep 17 00:00:00 2001 From: Knud <113939798+KnudAndersen@users.noreply.github.com> Date: Wed, 23 Jul 2025 09:44:40 -0500 Subject: [PATCH 5/6] Latex-style exponent --- 02_Architecture/08_Timers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/02_Architecture/08_Timers.md b/02_Architecture/08_Timers.md index 32c5027..77278c9 100644 --- a/02_Architecture/08_Timers.md +++ b/02_Architecture/08_Timers.md @@ -143,7 +143,7 @@ Each register is accessed by adding an offset to the base address we obtained be - General configuration: offset `0x10`. - Main counter value: `0xF0`. -We can read the main counter at any time, which is measured in timer ticks. We can convert these ticks into realtime by multiplying them with the timer period in the general capabilities register. Bits 63:32 of the general capabilities register contain the number of femtoseconds for each tick. A nanosecond is 1'000'000 femtoseconds, and 1 second is 1015 femtoseconds. +We can read the main counter at any time, which is measured in timer ticks. We can convert these ticks into realtime by multiplying them with the timer period in the general capabilities register. Bits 63:32 of the general capabilities register contain the number of femtoseconds for each tick. A nanosecond is 1'000'000 femtoseconds, and 1 second is $10^{15}$ femtoseconds. We can also write to the main counter, usually we would write a 0 here when initializing the HPET in order to be able to determine uptime, but this is not really necessary. From bc02bf1c594cc4348f3fc8f1079f93ac7b1d5eef Mon Sep 17 00:00:00 2001 From: Knud <113939798+KnudAndersen@users.noreply.github.com> Date: Wed, 23 Jul 2025 10:56:12 -0500 Subject: [PATCH 6/6] C struct syntax error You need to create a entry in the symbol table to reference a C-object itself, e.g. for self-referencing in a struct --- 04_Memory_Management/04_Virtual_Memory_Manager.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/04_Memory_Management/04_Virtual_Memory_Manager.md b/04_Memory_Management/04_Virtual_Memory_Manager.md index 17f932b..860a033 100644 --- a/04_Memory_Management/04_Virtual_Memory_Manager.md +++ b/04_Memory_Management/04_Virtual_Memory_Manager.md @@ -38,11 +38,11 @@ In addition, we might want to store some flags in the *vm object*, they are like Here's what our example virtual memory object looks like: ```c -typedef struct { +typedef struct vm_object { uintptr_t base; size_t length; size_t flags; - vm_object* next; + struct vm_object* next; } vm_object; #define VM_FLAG_NONE 0