diff options
author | the lemons <citrons@mondecitronne.com> | 2021-04-04 13:45:42 -0500 |
---|---|---|
committer | the lemons <citrons@mondecitronne.com> | 2021-04-04 13:45:42 -0500 |
commit | 6626a1ecee2759d6fb71e72cc95b22bd6af22875 (patch) | |
tree | a9d1e2cd865db0416422f41b560d66fa0eebc06f | |
parent | 88b524543119a18297240a563cb8c08ff440dd53 (diff) |
memory size reporting
-rwxr-xr-x | kernel.bin | bin | 89720 -> 89932 bytes | |||
-rw-r--r-- | os.iso | bin | 19892224 -> 19892224 bytes | |||
-rw-r--r-- | src/main.c | 4 | ||||
-rw-r--r-- | src/memory.c | 5 | ||||
-rw-r--r-- | src/memory.h | 8 |
5 files changed, 13 insertions, 4 deletions
Binary files differBinary files differ @@ -35,7 +35,9 @@ void kernel_main(multiboot_info_t *mb) { interrupt_init(); start_interrupts(); init_memory(mb); - + + printf("%u MB memory available\n", memory_available / 1000000); + vprint(" _ _ \n"); vprint(" ___(_) |_ _ __ ___ _ __ ___ ___ ___ \n"); vprint(" / __| | __| '__/ _ \\| '_ \\/ __| / _ \\/ __|\n"); diff --git a/src/memory.c b/src/memory.c index 970ba29..bc65311 100644 --- a/src/memory.c +++ b/src/memory.c @@ -4,6 +4,7 @@ #include <stddef.h> #include "memory.h" #include "multiboot.h" +#include "printf.h" struct memory_area { uint32_t len; @@ -12,6 +13,8 @@ struct memory_area { struct memory_area *first = NULL; +uint32_t memory_available = 0; + void init_memory(multiboot_info_t *mb) { struct memory_area *prev = NULL; for ( @@ -31,6 +34,8 @@ void init_memory(multiboot_info_t *mb) { length = UINT_MAX - e->addr; else length = e->len; + memory_available += length; + struct memory_area *cur = (struct memory_area *) e->addr; cur->len = length; diff --git a/src/memory.h b/src/memory.h index 3c38af7..c5b6367 100644 --- a/src/memory.h +++ b/src/memory.h @@ -18,18 +18,20 @@ enum cell_type { struct cell { uint8_t type; - union car { + union { struct cell *free; struct cell *cons; - struct {int type : 8; int size : 24;} ARRAY_CELL; + struct {int type : 8; int size : 24;} array_cell; uint32_t int_; uint32_t char_; float float_; REDACTED_t apioform; - }; + } car; struct cell *cdr; }; +uint32_t memory_available; + void init_memory(multiboot_info_t *mb); #endif |