From 6355c3e08c9f4d3db122252abce5837c364d5b81 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Wed, 7 Jul 2021 14:14:37 +0200 Subject: ELF execution of mb1 implementation --- src/loader/sel.c | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'src/loader/sel.c') diff --git a/src/loader/sel.c b/src/loader/sel.c index c4303a4..acdc783 100644 --- a/src/loader/sel.c +++ b/src/loader/sel.c @@ -4,17 +4,47 @@ #include #include #include +#include #include -static u8 sel_entry(struct cfg_entry *entry) +struct { + struct cfg_entry *cfg; +} sel_entries[16] = { 0 }; + +static u8 sel_entry_add(struct cfg_entry *entry) { - vga_log("> '%s' (%s)\n", entry->name, entry->path); + static u8 index = 0; + assert(index + 1 < (u8)sizeof(sel_entries)); + + sel_entries[index].cfg = entry; + + index++; return 0; } +// TODO: Keyboard listener +static void sel_entry_select(u8 entry) +{ + cfg_exec(sel_entries[entry].cfg); +} + +static void sel_entries_draw(void) +{ + for (u8 i = 0; i < COUNT(sel_entries); i++) { + if (!sel_entries[i].cfg) + break; + + vga_log("> '%s' (%s)\n", sel_entries[i].cfg->name, sel_entries[i].cfg->path); + } +} + void sel_draw(void) { vga_clear(); - cfg_foreach(&sel_entry); + cfg_foreach(&sel_entry_add); + sel_entries_draw(); + + // Just for testing + sel_entry_select(0); } -- cgit v1.2.3