diff options
author | Christian Cunningham <cc@localhost> | 2022-01-23 16:23:56 -0700 |
---|---|---|
committer | Christian Cunningham <cc@localhost> | 2022-01-23 16:23:56 -0700 |
commit | 741e7431d013c7fda4a1b8b34bcc2dfa1ecda039 (patch) | |
tree | 0301b7de87c34e13b3028e80fbf34bb93c2d58c6 | |
parent | 1b005b885a713199106587f3e6d8f53f0ecfdfcd (diff) |
Visual view of memory map
-rw-r--r-- | include/lib/mem.h | 1 | ||||
-rw-r--r-- | include/sys/schedule.h | 3 | ||||
-rw-r--r-- | src/cpu/irq.c | 10 | ||||
-rw-r--r-- | src/lib/mem.c | 25 | ||||
-rw-r--r-- | src/sys/schedule.c | 4 | ||||
-rw-r--r-- | src/util/status.c | 2 |
6 files changed, 39 insertions, 6 deletions
diff --git a/include/lib/mem.h b/include/lib/mem.h index ea1be5d..655e648 100644 --- a/include/lib/mem.h +++ b/include/lib/mem.h @@ -41,6 +41,7 @@ void* calloca(unsigned char size, unsigned char amnt); void free(void* memloc); void* heap_base(void); void* heap_top(void); +void vheap_info(void); void heap_info(void); void heap_info_u(void); diff --git a/include/sys/schedule.h b/include/sys/schedule.h index d28ea6d..8a68e05 100644 --- a/include/sys/schedule.h +++ b/include/sys/schedule.h @@ -6,6 +6,9 @@ #define TQUEUE_CNT 5 #define PRIORITIES 6 #define MAX_THREADS TQUEUE_MAX*PRIORITIES*TQUEUE_CNT +#define STACK_DRAW_YOFF 320 +#define STACK_DRAW_WIDTH 32 +#define STACK_DRAW_SIZE 3 enum ThreadStatus { THREAD_READY = 0, diff --git a/src/cpu/irq.c b/src/cpu/irq.c index e195261..7b6ae7e 100644 --- a/src/cpu/irq.c +++ b/src/cpu/irq.c @@ -11,6 +11,7 @@ #include <util/status.h> #include <util/time.h> +void testfxn(void); void handle_data(unsigned char); void c_irq_handler(void) @@ -115,11 +116,10 @@ void handle_data(unsigned char data) cmd[off] = (char) data; off += 1; release_mutex(&exe_cnt_m, SYS_PID); - // heap Info - } else if (data == 0x69) { + } else if (data == 0x61) { cmd[off] = (char) data; off += 1; - add_thread(heap_info, 0, 5); + add_thread(testfxn, 0, 3); // Else output } else { cmd[off] = (char) data; @@ -147,3 +147,7 @@ void handle_data(unsigned char data) write_string(&g_Drawer, "> "); write_string(&g_Drawer, cmd); } + +void testfxn(void) +{ +} diff --git a/src/lib/mem.c b/src/lib/mem.c index 82f7f45..2f50d3d 100644 --- a/src/lib/mem.c +++ b/src/lib/mem.c @@ -1,6 +1,8 @@ #include <drivers/uart.h> #include <globals.h> +#include <graphics/lfb.h> #include <lib/mem.h> +#include <sys/schedule.h> void memcpyrot(unsigned char* src, struct RotBuffer* rb, unsigned int n) { @@ -246,6 +248,28 @@ void* heap_top(void) return rpi_heap_top; } +void vheap_info(void) +{ + unsigned char* base = rpi_heap; + unsigned long ioff = STACK_DRAW_WIDTH*STACK_DRAW_SIZE; + unsigned long yoff = STACK_DRAW_YOFF; + draw_cbox(ioff, yoff, STACK_DRAW_SIZE*STACK_DRAW_WIDTH, STACK_DRAW_SIZE * 8, 0x0); + while ((void*)base < rpi_heap_top) { + unsigned char size = base[MEM_SIZE_OFFSET]; + if(base[MEM_USE_OFFSET] == 0) { + draw_cbox(ioff, yoff, STACK_DRAW_SIZE, STACK_DRAW_SIZE, 0x00FF00); + } else { + draw_cbox(ioff, yoff, STACK_DRAW_SIZE, STACK_DRAW_SIZE, 0xFF0000); + } + ioff += STACK_DRAW_SIZE; + if(ioff % STACK_DRAW_WIDTH == 0) { + yoff += STACK_DRAW_SIZE; + ioff = STACK_DRAW_WIDTH*STACK_DRAW_SIZE; + } + base += size + MEM_META_SIZE; + } +} + void heap_info(void) { unsigned char* base = rpi_heap; @@ -254,6 +278,7 @@ void heap_info(void) if(base[MEM_USE_OFFSET] == 0) { uart_char('F'); uart_char(' '); + } else { } uart_hex((unsigned long)(base + MEM_BASE_SIZE)); uart_string(" Size: "); diff --git a/src/sys/schedule.c b/src/sys/schedule.c index ad7feec..0e9df78 100644 --- a/src/sys/schedule.c +++ b/src/sys/schedule.c @@ -52,9 +52,7 @@ struct RStack get_stack(void) void draw_stacks(void) { unsigned long ioff = 0; - unsigned long yoff = 320; -#define STACK_DRAW_WIDTH 32 -#define STACK_DRAW_SIZE 3 + unsigned long yoff = STACK_DRAW_YOFF; for(int i = 0; i < MAX_THREADS; i++) { if(stacks_table[i]) draw_cbox(ioff, yoff, STACK_DRAW_SIZE, STACK_DRAW_SIZE, 0xFFFFFF); diff --git a/src/util/status.c b/src/util/status.c index bb6dd68..155f016 100644 --- a/src/util/status.c +++ b/src/util/status.c @@ -2,6 +2,7 @@ #include <globals.h> #include <graphics/drawer.h> #include <graphics/lfb.h> +#include <lib/mem.h> #include <symbols.h> #include <sys/core.h> #include <sys/schedule.h> @@ -181,4 +182,5 @@ void status(void) g_Drawer.y = y; draw_stacks(); + vheap_info(); } |