You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Minor fixes in the appendices section
* minor syntax fix to acpi chapter
* clarify length field in acpisdt header
* Fix file name (issue #86)
* minor changes to memory management section
* Minor changes to heap chapter
* Requested changes
Copy file name to clipboardExpand all lines: 01_Build_Process/03_Gnu_Makefiles.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ There's a million and one excellent resources on makefiles out there, so this ch
6
6
7
7
There's multiple different make-like programs out there, a lot of them share a common base, usually the one specified in posix. GNU make also has a bunch of custom extensions it adds, which can be quite useful. These will render our Makefiles only usable for gnu make, which is the most common version. So this is fine, but if we care about being fully portable between make versions, we'll have to avoid these.
8
8
9
-
If we want to use gnu make extensions, we now have a makefile that wont run under every version of make. Fortunately the folks at gnu allow us to name our makefile `GNUMakefile` instead, and this will run as normal. However other versions of make won't see this file, meaning they wont try to run it.
9
+
If we want to use gnu make extensions, we now have a makefile that wont run under every version of make. Fortunately the folks at gnu allow us to name our makefile `GNUmakefile` instead, and this will run as normal. However other versions of make won't see this file, meaning they wont try to run it.
Copy file name to clipboardExpand all lines: 02_Architecture/06_ACPITables.md
+6-4Lines changed: 6 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,8 +20,8 @@ The newer version is backward compatible with the older.
20
20
21
21
Accessing the RSDP register depends on the boot system used, if we are using grub, we get a copy of the RSDT/XSDT in one of the multiboot2 header tags. The specs contains two possible tags for the RSDP value, which one is used depend on the version:
22
22
23
-
* For the version 1 the MULTIBOOT_TAG_TYPE_ACPI_OLD is used (type 14)
24
-
* For the version 2 the MULTIBOOT_TAG_TYPE_ACPI_NEW is used (type 15)
23
+
* For the version 1 the `MULTIBOOT_TAG_TYPE_ACPI_OLD` is used (type 14)
24
+
* For the version 2 the `MULTIBOOT_TAG_TYPE_ACPI_NEW` is used (type 15)
25
25
26
26
Both headers are identical, with the only difference being in the type value, they are composed of just two fields:
27
27
@@ -113,6 +113,8 @@ struct ACPISDTHeader {
113
113
```
114
114
* The second part is the table itself, every SDT has its own table
115
115
116
+
It's important to note that hte `Length` field contains the size of the table, header included.
117
+
116
118
#### RSDT vs XSDT
117
119
118
120
These 2 tables have the same purpose and are mutually exclusive. If the latter exists, the former is to be ignored, otherwise use the former.
* Be aware that the Signaturein the RSD* structure is not nullterminated. This means that if we try to print it, you will most likely end up in printing garbage in the best case scenario.
146
-
* The RSDT Data is an array of uint32_t addresses while the XSDT data is an array of uint64_t addresses. The number of items in the RSDT and XSDT can be computed in the following way:
147
+
* Be aware that the `Signature` the signature in any of the ACPI tables are not null-terminated. This means that if we try to print it, you will most likely end up in printing garbage in the best case scenario.
148
+
* The RSDT Data is an array of `uint32_t` addresses while the XSDT data is an array of `uint64_t` addresses. The number of items in the RSDT and XSDT can be computed in the following way:
Copy file name to clipboardExpand all lines: 04_Memory_Management/01_Overview.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,7 @@ Each of the layers has a dedicated chapter, however we'll start with a high leve
28
28
29
29
## A Word of Wisdom
30
30
31
-
As said at the beginning of this chapter Memory management is one of the most important parts of a kernel, as every other part of the kernel will interact with it in some way. It's worth taking the extra time to consider what features we want our PMM and VMM to have, and the ramifications. A little planning now can save us a lot of heacaches and rewriting code later!
31
+
As said at the beginning of this chapter Memory management is one of the most important parts of a kernel, as every other part of the kernel will interact with it in some way. It's worth taking the extra time to consider what features we want our PMM and VMM to have, and the ramifications. A little planning now can save us a lot of headaches and rewriting code later!
Copy file name to clipboardExpand all lines: 04_Memory_Management/05_Heap_Allocation.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -55,7 +55,7 @@ Well the answer is, as we already know: it allocates memory, specifically in byt
55
55
56
56
If we are writing an OS, we already know that RAM can be viewed as a very long array, where the index into this array is the memory address. The allocator is returning these indices. So we can already see the first detail we'll need to keep track of: next available address.
57
57
58
-
Let's start with a simple example, assume that we have an address space of 100 bytes, nothing has allocated yet, and the program makes the following consecutive `alloc()` calls:
58
+
Let's start with a simple example, assume that we have an address space of 100 bytes, nothing has been allocated yet, and the program makes the following consecutive `alloc()` calls:
59
59
60
60
```c
61
61
alloc(10);
@@ -94,7 +94,7 @@ uint8_t *cur_heap_position = 0; //Just an example, in the real world you would u
94
94
//a virtual address allocated from the VMM.
95
95
void *first_alloc(size_t size) {
96
96
uint8_t *addr_to_return = cur_heap_position;
97
-
cur_heap_position= cur_heap_position + size;
97
+
cur_heap_position= cur_heap_position + size;
98
98
return (void*) addr_to_return;
99
99
}
100
100
```
@@ -111,7 +111,7 @@ void first_free(void *ptr) {
111
111
112
112
Yeah... that's right, it's not an error. A bump allocator does not have `free()`.
113
113
114
-
Why? Because we are not keeping track of the allocated memory, so we can't just update the `cur_heap_position` variable with the address of ptr, because we don't know who is using the memory after ptr. So we are forced just to do nothing.
114
+
Why? Because we are not keeping track of the allocated memory, so we can't just update the `cur_heap_position` variable with the address of ptr, since we don't know who is using the memory after ptr. So we are forced just to do nothing.
115
115
116
116
Even if probably useless let's see what are the pros and cons of this approach:
117
117
@@ -128,9 +128,9 @@ Of course the cons are probably pretty clear and make this algorithm pretty usel
128
128
* There is no way to traverse the heap, because we don't keep track of the allocations.
129
129
* We will eventually run out of memory (OOM - out of memory).
130
130
131
-
### Part 2: Adding Free()
131
+
### Part 2: Adding free()
132
132
133
-
The main problem with this algorithm is that we don't keep track of what we have allocated in the past, so we are not able to free that memory in the future, when it's no longer used.
133
+
The main problem with the algorithm outlined above is that we don't keep track of what we have allocated in the past, so we are not able to free that memory in the future, when it's no longer used.
134
134
135
135
Now we're going to build a new allocator based on the one we just implemented. The first thing to do is try to figure out what are the information we need to keep track of from the previous allocations:
* Show register content: *info register reg* where reg is the register we need
28
-
* Set breakpoint to specific address: *break 0xaddress*
29
-
* Show memory address content: *x/nfu addr* wher: n is the number of iterations f the format (x = hex) and the addr we want to show
30
-
* We can show also the content of pointer stored into a register: *x/h ($rax)* shows the content of memory address pointed by rax
27
+
* Show register content: `info register reg` where reg is the register we need
28
+
* Set breakpoint to specific address: `break 0xaddress`
29
+
* Show memory address content: `x/nfu addr` where: *n* is the number of iterations *f* the format (*x* = hex) and the *addr* we want to show
30
+
* We can show also the content of pointer stored into a register: `x/h ($rax)` shows the content of memory address pointed by rax
31
31
32
32
### Navigation
33
33
@@ -223,10 +223,10 @@ QEMU 6.1.0 monitor - type 'help' for more information
223
223
224
224
From here is possible to send commands directly to the emulator, below a list of useful commands:
225
225
226
-
***help** Well this is the first command to get some help on how to use the monitor.
227
-
***info xxxx** It will print several information, depending on xxxx for example: *info lapic* will show the current status of the local apic, *info mem* will print current virtual memory mappings, *info registers* will print the registers content.
228
-
***x/cf address** where c is the number of items we want to display in decimal, f is the format (`x` for hex, `c` for char, etc) display the content of c virtual memory locations starting from address.
229
-
***xp/cf address** same as above, but for physical memory.
226
+
*`help` Well this is the first command to get some help on how to use the monitor.
227
+
*`info xxxx` It will print several information, depending on xxxx for example: `info lapic` will show the current status of the local apic, `info mem` will print current virtual memory mappings, `info registers` will print the registers content.
228
+
*`x /cf address` where c is the number of items we want to display in decimal, f is the format (`x` for hex, `c` for char, etc) display the content of c virtual memory locations starting from address.
229
+
*`xp /cf address` same as above, but for physical memory.
0 commit comments