refactor: one more step towards arch-agnostic design
[lunaix-os.git] / lunaix-os / kernel / debug / trace.c
1 #include <lunaix/mm/mmio.h>
2 #include <lunaix/mm/page.h>
3 #include <lunaix/spike.h>
4 #include <lunaix/trace.h>
5
6 #include <klibc/string.h>
7
8 static struct trace_context trace_ctx;
9
10 void
11 trace_modksyms_init(struct boot_handoff* bhctx)
12 {
13     struct boot_modent* modents = bhctx->mods.entries;
14     for (size_t i = 0; i < bhctx->mods.mods_num; i++) {
15         struct boot_modent* mod = &bhctx->mods.entries[i];
16         if (streq(mod->str, "modksyms")) {
17             // In case boot loader does not place our ksyms on page boundary
18             ptr_t start = PG_ALIGN(mod->start);
19             ptr_t end = ROUNDUP(mod->end, PG_SIZE);
20             ptr_t ksym_va = (ptr_t)ioremap(start, (end - start));
21
22             trace_ctx.ksym_table =
23               (struct ksyms*)(ksym_va + (mod->start - start));
24         }
25     }
26 }
27
28 struct ksym_entry*
29 trace_sym_lookup(ptr_t pc)
30 {
31     return NULL;
32 }
33
34 void
35 trace_walkback(ptr_t fp)
36 {
37 }