Commit 94cd0495 authored by Paul Mundt's avatar Paul Mundt

sh: sh_bios detection.

This adds some VBR sanity checks in the sh_bios code to ensure that the
BIOS VBR is in range before blindly trapping in to it. This permits
boards with varying boot loader configurations to always leave support
for sh-bios enabled and it will just be disabled at run-time if not
found.
Signed-off-by: default avatarPaul Mundt <lethal@linux-sh.org>
parent a99eae54
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
#define BIOS_CALL_SHUTDOWN 11 #define BIOS_CALL_SHUTDOWN 11
#define BIOS_CALL_GDB_DETACH 0xff #define BIOS_CALL_GDB_DETACH 0xff
void *gdb_vbr_vector = NULL;
static inline long sh_bios_call(long func, long arg0, long arg1, long arg2, static inline long sh_bios_call(long func, long arg0, long arg1, long arg2,
long arg3) long arg3)
{ {
...@@ -32,6 +34,9 @@ static inline long sh_bios_call(long func, long arg0, long arg1, long arg2, ...@@ -32,6 +34,9 @@ static inline long sh_bios_call(long func, long arg0, long arg1, long arg2,
register long r6 __asm__("r6") = arg2; register long r6 __asm__("r6") = arg2;
register long r7 __asm__("r7") = arg3; register long r7 __asm__("r7") = arg3;
if (!gdb_vbr_vector)
return -ENOSYS;
__asm__ __volatile__("trapa #0x3f":"=z"(r0) __asm__ __volatile__("trapa #0x3f":"=z"(r0)
:"0"(r0), "r"(r4), "r"(r5), "r"(r6), "r"(r7) :"0"(r0), "r"(r4), "r"(r5), "r"(r6), "r"(r7)
:"memory"); :"memory");
...@@ -60,8 +65,6 @@ void sh_bios_shutdown(unsigned int how) ...@@ -60,8 +65,6 @@ void sh_bios_shutdown(unsigned int how)
sh_bios_call(BIOS_CALL_SHUTDOWN, how, 0, 0, 0); sh_bios_call(BIOS_CALL_SHUTDOWN, how, 0, 0, 0);
} }
void *gdb_vbr_vector = NULL;
/* /*
* Read the old value of the VBR register to initialise the vector * Read the old value of the VBR register to initialise the vector
* through which debug and BIOS traps are delegated by the Linux trap * through which debug and BIOS traps are delegated by the Linux trap
...@@ -76,8 +79,12 @@ void sh_bios_vbr_init(void) ...@@ -76,8 +79,12 @@ void sh_bios_vbr_init(void)
__asm__ __volatile__ ("stc vbr, %0" : "=r" (vbr)); __asm__ __volatile__ ("stc vbr, %0" : "=r" (vbr));
if (vbr) {
gdb_vbr_vector = (void *)(vbr + 0x100); gdb_vbr_vector = (void *)(vbr + 0x100);
printk(KERN_NOTICE "Setting GDB trap vector to %p\n", gdb_vbr_vector); printk(KERN_NOTICE "Setting GDB trap vector to %p\n",
gdb_vbr_vector);
} else
printk(KERN_NOTICE "SH-BIOS not detected\n");
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment