fixed driver_vec retrieval. Sholdn't crash anymore on FireTOS.

This commit is contained in:
Markus Fröschle
2014-09-29 22:26:25 +00:00
parent 76d2a1c9b7
commit 465cb67109
5 changed files with 56 additions and 11 deletions

View File

@@ -1,11 +1,11 @@
.PHONY: tos
.PHONY: jtagwait
.PHONY: mcdcook
tos: jtagwait mcdcook
.PHONY: bascook
tos: jtagwait bascook
jtagwait:
(cd $@; make)
bascook:
(cd $@; make)

View File

@@ -10,8 +10,10 @@ struct driver_table *get_bas_drivers(void)
struct driver_table *ret = NULL;
__asm__ __volatile__(
" trap #0\n\t"
" move.l d0,%[ret]\n\t"
" bra.s do_trap \n\t"
" .dc.l 0x5f424153 \n\t" // '_BAS'
"do_trap: trap #0 \n\t"
" move.l d0,%[ret] \n\t"
: [ret] "=m" (ret) /* output */
: /* no inputs */
: /* clobbered */
@@ -20,6 +22,22 @@ struct driver_table *get_bas_drivers(void)
return ret;
}
/*
* temporarily replace the trap 0 handler with this so we can avoid
* getting caught by BaS versions that don't understand the driver interface
* exposure call.
* If we get here, we have a BaS version that doesn't support the trap 0 interface
*/
static void __attribute__((interrupt)) my_own_trap0_handler(void)
{
__asm__ __volatile__(
" clr.l d0 \n\t" // return 0 to indicate not supported
:
:
:
);
}
static uint32_t cookieptr(void)
{
return * (uint32_t *) 0x5a0L;
@@ -86,11 +104,16 @@ int main(int argc, char *argv[])
{
struct driver_table *dt;
void *ssp;
void *old_vector;
(void) Cconws("retrieve BaS driver interface\r\n");
ssp = (void *) Super(0L);
dt = get_bas_drivers();
old_vector = Setexc(0x20, my_own_trap0_handler); /* set our own temporarily */
dt = get_bas_drivers(); /* trap #1 */
(void) Setexc(0x20, old_vector); /* restore original vector */
if (dt)
{
struct generic_interface *ifc = &dt->interfaces[0];