Start detect memory

This commit is contained in:
Ciro Santilli
2015-10-20 21:00:24 +02:00
parent eb9b5a4893
commit 3e01929b63
4 changed files with 43 additions and 2 deletions

View File

@@ -25,6 +25,7 @@ Minimal operating systems to learn low level programming.
1. [keyboard loop](bios_keyboard_loop.S)
1. [disk load](bios_disk_load.S)
1. [disk load 2](bios_disk_load2.S)
1. [detect memory](bios_detect_memory.S)
1. [Initial state](initial_state.S)
1. [reboot](reboot.S)
1. [Not testable in userland](not-testable-in-userland.md)

29
bios_detect_memory.S Normal file
View File

@@ -0,0 +1,29 @@
/*
# Detecte memory
# int 15
http://wiki.osdev.org/Detecting_Memory_%28x86%29
Determine how much memory you've got, and how much of it is low memory.
This is important in particular so that you can start your stack there
when you enter protected mode, since the stack grows down.
In 16-bit mode, it does not matter much,
since most modern machines have all addressable memory there.
`int 15` returns a list:
each time you call it a new memory region is returned.
## Low memory
TODO what is it?
*/
#include "common.h"
BEGIN
mov $0xE820, %eax
int $0x15
hlt

View File

@@ -285,7 +285,18 @@ end:
pop %eax
.endm
/* Print a 32-bit register in hex. */
/*
Print a 32-bit register in hex.
Sample usage:
mov $12345678, %eax
VGA_PRINT_REG <%eax>
Expected output on screen:
12345678
*/
.macro VGA_PRINT_REG reg=<%eax>
LOCAL loop
push %eax

View File

@@ -20,7 +20,7 @@ Rationale of the registers:
TODO: this does seem to have special properties as used by string instructions.
- used by the `int 13h` BIOS disk read service
- BIOS calls: `int 13h` disk read, `int 15` memory detection
## FS