Skip to content

Commit 6e96246

Browse files
authored
add info about mem and tlb for qemu monitor (#49)
1 parent ed52bc1 commit 6e96246

2 files changed

Lines changed: 32 additions & 1 deletion

File tree

02_Architecture/01_Overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Architecture and Drivers
1+
# Architecture And Drivers
22

33
Before going beyond a basic "hello world" and implementing the first real parts of our kernel, there are some key concepts about how the CPU operates that we have to understand. What is an interrupt, and how do we handle it? What does it mean to mask them? What is the GDT and what is it's purpose?
44

99_Appendices/E_Debugging.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,37 @@ From here you can send commands directly to the emulator, below a list of useful
204204
* **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
205205
* **xp/cf address** same as above, but for physical memory
206206

207+
#### Info mem & Info tlb
208+
209+
These commands are very useful when we need to debug memory related issues, the first command `info mem` will print the list of active virtual memory mappings, the output format depends on the architecture, for exmple on `x86-64`, it will be similar to the following:
210+
211+
```
212+
info mem
213+
ffff800000000000-ffff800100491000 0000000100491000 -rw
214+
ffff800100491000-ffff800100498000 0000000000007000 -r-
215+
ffff800100498000-ffff80010157a000 00000000010e2000 -rw
216+
ffffffff80000000-ffffffff80057000 0000000000057000 -r-
217+
ffffffff80057000-ffffffff8006b000 0000000000014000 -rw
218+
```
219+
220+
Where every line contain represent a single virtual memory mapping, and contains in order: _base, limit, size and flags_.
221+
222+
the `info tlb` shows the virtual to physical memory mappings. An example output is:
223+
224+
```
225+
info tlb
226+
ffffffff80062000: 000000000994a000 XG------W
227+
ffffffff80063000: 000000000994b000 XG------W
228+
ffffffff80064000: 000000000994c000 XG--A---W
229+
ffffffff80065000: 000000000994d000 XG-DA---W
230+
ffffffff80066000: 000000000994e000 XG-DA---W
231+
ffffffff80067000: 000000000994f000 XG-DA---W
232+
ffffffff80068000: 0000000009950000 XG-DA---W
233+
ffffffff80069000: 0000000009951000 XG-DA---W
234+
ffffffff8006a000: 0000000009952000 XG-DA---W
235+
```
236+
237+
In this case the line contains: _virtualaddress: physicaladdress flags_. The command is not available on all architecture, so if developing on an architecture different from `x86-64` it could not be available.
207238

208239
### Debugcon
209240

0 commit comments

Comments
 (0)