kalloc and kfree interface and abstraction
[cortex-from-scratch] / sysinfo.c
index e9b2429..85ca01c 100644 (file)
--- a/sysinfo.c
+++ b/sysinfo.c
@@ -1,3 +1,13 @@
+/* (CC-BY-NC-SA) ROBIN KRENS - ROBIN @ ROBINKRENS.NL
+ * 
+ * $LOG$
+ * 2019/7/20 - ROBIN KRENS     
+ * Initial version
+ * Display some system information, calculate
+ * the amount of SRAM available 
+ * 
+ * */
+
 #include <stdbool.h>
 #include <stddef.h>
 #include <stdint.h>
 #include <sys/robsys.h>
 #include <sys/mmap.h>
 
-#include <lib/stdio.h>
+#include <lib/tinyprintf.h>
 #include <lib/regfunc.h>
 
-#define MEM_SIZE       0x00010000 
-#define MEM_OFFSET     0x20000000
 
 uint32_t get_msp(void);
 
 void sysinfo() {
 
        uint32_t tmp = *MCU_ID;
-       cputs("# ROBSYS 0.1 LOADING...\n");
-       cputs("# DEVICE ID: ");
+       printf("SYSTEM LOADING...\n\n");
+       printf("DEV ID: ");
 
        if (tmp & 0x414) 
-               cputs("HIGH DENSITY\n");
+               printf("H. DENSITY\n");
        else {
-               cputs("UNKNOWN\n");
+               printf("UNKNOWN\n");
        }
 
-       tmp = (tmp >> 16);
-       cputs("# REVISION: ");
+       /* tmp = (tmp >> 16);
+       printf("REV: ");
        switch  (tmp) {
                case 0x1000:
-                     cputs("REVISION A\n");
+                     printf("REVISION A\n");
                      break;
                case 0x1001:
-                     cputs("REVISION Z\n");
+                     printf("REVISION Z\n");
                      break;
                case 0x1003:
-                     cputs("REVISION 1/2/3/X/Y\n");
+                     printf("REVISION 1/2/3/X/Y\n");
                      break;
                default:
-                     cputs("UNKNOWN\n");
-       }
+                     printf("UNKNOWN\n");
+       } */
 
        extern char _endofbss;
-       
+
        uint32_t current_stack = get_msp();
-       uint32_t stack_usage = (MEM_OFFSET + MEM_SIZE) - current_stack;
-       uint32_t data_bss = &_endofbss - MEM_OFFSET;
-       uint32_t mem_free = MEM_SIZE - stack_usage - data_bss;
+       uint32_t stack_usage = (SRAM_OFFSET + SRAM_SIZE) - current_stack;
+       uint32_t data_bss = (uint32_t) &_endofbss - SRAM_OFFSET;
+       uint32_t mem_free = SRAM_SIZE - stack_usage - data_bss;
 
-       cputs("# TOTAL MEMORY: ");
-       cputs(regtohex(MEM_SIZE));
-       cputchar('\n');
-       cputs("# FREE MEMORY: ");
-       cputs(regtohex(mem_free));
-       cputchar('\n');
-       cputs("# STACK USAGE: ");
-       cputs(regtohex(stack_usage));
-       cputchar('\n');
+       extern uint32_t KHEAP_SIZE;
+       
+       printf("TOTAL MEM: %#x\n", SRAM_SIZE);
+       printf("FREE MEM: %#x\n", mem_free);
+       printf("STACK USE: %#x\n", stack_usage);
+       printf("HEAP_SIZE: %#x\n\n", &KHEAP_SIZE);
 
 }