add lunaix dynamic linker as submodule
[lunaix-os.git] / lunaix-os / kernel / debug / trace.c
index a3553f104925466ff5ffb0b25034696a63a65d0e..ae183d4f03afecf15a7497d03f0a5d7253aaf65c 100644 (file)
@@ -1,5 +1,5 @@
-#include <lunaix/mm/mmio.h>
 #include <lunaix/mm/page.h>
 #include <lunaix/mm/page.h>
+#include <lunaix/mm/vmm.h>
 #include <lunaix/process.h>
 #include <lunaix/spike.h>
 #include <lunaix/syslog.h>
 #include <lunaix/process.h>
 #include <lunaix/spike.h>
 #include <lunaix/syslog.h>
@@ -23,13 +23,14 @@ trace_modksyms_init(struct boot_handoff* bhctx)
     for (size_t i = 0; i < bhctx->mods.mods_num; i++) {
         struct boot_modent* mod = &bhctx->mods.entries[i];
         if (streq(mod->str, "modksyms")) {
     for (size_t i = 0; i < bhctx->mods.mods_num; i++) {
         struct boot_modent* mod = &bhctx->mods.entries[i];
         if (streq(mod->str, "modksyms")) {
-            // In case boot loader does not place our ksyms on page boundary
-            ptr_t start = PG_ALIGN(mod->start);
+            assert(PG_ALIGNED(mod->start));
+
             ptr_t end = ROUNDUP(mod->end, PG_SIZE);
             ptr_t end = ROUNDUP(mod->end, PG_SIZE);
-            ptr_t ksym_va = (ptr_t)ioremap(start, (end - start));
+            ptr_t ksym_va =
+              (ptr_t)vmm_vmap(mod->start, (end - mod->start), PG_PREM_R);
 
 
-            trace_ctx.ksym_table =
-              (struct ksyms*)(ksym_va + (mod->start - start));
+            assert(ksym_va);
+            trace_ctx.ksym_table = (struct ksyms*)ksym_va;
         }
     }
 }
         }
     }
 }
@@ -126,14 +127,16 @@ trace_printstack()
     trace_printstack_of(cpu_get_fp());
 }
 
     trace_printstack_of(cpu_get_fp());
 }
 
-void
+static void
 trace_printswctx(const isr_param* p, char* direction)
 {
 
     struct ksym_entry* sym = trace_sym_lookup(p->execp->eip);
 
 trace_printswctx(const isr_param* p, char* direction)
 {
 
     struct ksym_entry* sym = trace_sym_lookup(p->execp->eip);
 
-    kprintf(
-      KDEBUG ">> (sw:%s) iv:%d, errno:%p <<\n", direction, p->execp->vector);
+    kprintf(KDEBUG ">> (sw:%s) iv:%d, errno:%p <<\n",
+            direction,
+            p->execp->vector,
+            p->execp->err_code);
     kprintf(KDEBUG "%p:%s\n", p->execp->eip, ksym_getstr(sym));
 }
 
     kprintf(KDEBUG "%p:%s\n", p->execp->eip, ksym_getstr(sym));
 }