diff --git a/lagarto-ox.nix b/lagarto-ox.nix index fabab92..13a0155 100644 --- a/lagarto-ox.nix +++ b/lagarto-ox.nix @@ -219,7 +219,7 @@ patches = [ #./u-boot-debug.patch ./uboot-debug-ext-interrupts.patch - ./uboot-sregs.patch + ./uboot-exception-extras.patch ]; # # CONFIG_SERIAL_PRESENT=n diff --git a/uboot-sregs.patch b/uboot-exception-extras.patch similarity index 52% rename from uboot-sregs.patch rename to uboot-exception-extras.patch index ad707e1..b2511ba 100644 --- a/uboot-sregs.patch +++ b/uboot-exception-extras.patch @@ -1,24 +1,41 @@ diff --git a/cmd/riscv/exception.c b/cmd/riscv/exception.c -index f38f454a0b..87877ab235 100644 +index f38f454a0b..9de4effe47 100644 --- a/cmd/riscv/exception.c +++ b/cmd/riscv/exception.c -@@ -56,6 +56,23 @@ static int do_undefined(struct cmd_tbl *cmdtp, int flag, int argc, +@@ -56,6 +56,40 @@ static int do_undefined(struct cmd_tbl *cmdtp, int flag, int argc, return CMD_RET_FAILURE; } +static int do_sregs(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ -+ ulong stvec, sie, sstatus; ++ ulong stvec, sie, sip, sstatus; + + asm volatile ("fence"); + asm volatile ("csrr %0, stvec" : "=r"(stvec) : ); + asm volatile ("csrr %0, sie" : "=r"(sie) : ); ++ asm volatile ("csrr %0, sip" : "=r"(sip) : ); + asm volatile ("csrr %0, sstatus" : "=r"(sstatus) : ); + -+ printf("stvec : 0x%08lx\n", stvec); -+ printf("sie : 0x%08lx\n", sie); -+ printf("sstatus : 0x%08lx\n", sstatus); ++ printf("stvec : 0x%016lx\n", stvec); ++ printf("sie : 0x%016lx\n", sie); ++ printf("sip : 0x%016lx\n", sip); ++ printf("sstatus : 0x%016lx\n", sstatus); ++ ++ return CMD_RET_SUCCESS; ++} ++ ++static int do_enable(struct cmd_tbl *cmdtp, int flag, int argc, ++ char *const argv[]) ++{ ++ ulong which = SIE_SSIE | SIE_SEIE | SIE_STIE; ++ ++ asm volatile ( ++ "csrsi sstatus, 2\n" /* Enable SIE */ ++ "csrs sie, %0\n" /* Enable selected interrupts */ ++ : /* no output */ ++ : "r" (which) ++ ); + + return CMD_RET_SUCCESS; +} @@ -26,20 +43,23 @@ index f38f454a0b..87877ab235 100644 static struct cmd_tbl cmd_sub[] = { U_BOOT_CMD_MKENT(compressed, CONFIG_SYS_MAXARGS, 1, do_compressed, "", ""), -@@ -67,6 +84,8 @@ static struct cmd_tbl cmd_sub[] = { +@@ -67,6 +101,10 @@ static struct cmd_tbl cmd_sub[] = { "", ""), U_BOOT_CMD_MKENT(undefined, CONFIG_SYS_MAXARGS, 1, do_undefined, "", ""), + U_BOOT_CMD_MKENT(sregs, CONFIG_SYS_MAXARGS, 1, do_sregs, ++ "", ""), ++ U_BOOT_CMD_MKENT(enable, CONFIG_SYS_MAXARGS, 1, do_enable, + "", ""), }; static char exception_help_text[] = -@@ -77,6 +96,7 @@ static char exception_help_text[] = +@@ -77,6 +115,8 @@ static char exception_help_text[] = " ialign16 - 16 bit aligned instruction\n" " undefined - illegal instruction\n" " unaligned - load address misaligned\n" + " sregs - print supervisor registers\n" ++ " enable - enable supervisor interrupts\n" ; #include