implemented trap #0 handler in assembler
This commit is contained in:
@@ -32,30 +32,6 @@
|
||||
|
||||
static BPB sd_bpb[4]; /* space for four partitions on SD card */
|
||||
|
||||
static xhdi_call_fun old_vector = NULL;
|
||||
extern uint32_t xhdi_vec(uint16_t *stack);
|
||||
|
||||
__attribute__((__interrupt__)) xhdi_call_fun xhdi_sd_install(xhdi_call_fun ov)
|
||||
{
|
||||
old_vector = ov;
|
||||
uint32_t *_drvbits = (uint32_t *) 0x4c2;
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"move.l %[xhdi_call],d1\n\t"
|
||||
"move.l d1,(sp)\n\t" /* FIXME: dirty overwrite of saved register on stack with return value */
|
||||
"move.l d1,8(sp)\n\t"
|
||||
: /* output */
|
||||
: [xhdi_call]"g"(xhdi_vec)
|
||||
: "d1","memory");
|
||||
|
||||
*_drvbits |= (uint32_t) 1 << ('S' - 'A');
|
||||
/*
|
||||
* this is just to make the compiler happy, the return value is overwritten anyway. Therefore we previously overwrite
|
||||
* the saved register value on the stack so everything is as we want it to be
|
||||
*/
|
||||
return (xhdi_call_fun) xhdi_call;
|
||||
}
|
||||
|
||||
uint16_t xhdi_version(void)
|
||||
{
|
||||
xprintf("xhdi_version() called\r\n");
|
||||
|
||||
@@ -3,13 +3,36 @@
|
||||
//
|
||||
.extern _xhdi_call
|
||||
.globl _xhdi_vec
|
||||
.globl _xhdi_sd_install
|
||||
|
||||
//
|
||||
// this is where the XHDI cookie points to:
|
||||
//
|
||||
|
||||
.text
|
||||
_xhdi_vec:
|
||||
lea -12(sp),sp
|
||||
lea -12(sp),sp // save all used registers according to XHDI spec
|
||||
movem.l d1/a0-a1,(sp)
|
||||
pea 16(sp)
|
||||
jsr _xhdi_call
|
||||
addq.l #4,sp
|
||||
movem.l (sp),d1/a0-a1
|
||||
pea 16(sp) // forward address of parameters on stack
|
||||
jsr _xhdi_call // to internal routine
|
||||
addq.l #4,sp // correct stack
|
||||
movem.l (sp),d1/a0-a1 // restore registers
|
||||
lea 12(sp),sp
|
||||
rts
|
||||
|
||||
.equ _drvbits, 0x4c2
|
||||
|
||||
.data
|
||||
_old_vector:
|
||||
.ds.l 1
|
||||
|
||||
.text
|
||||
|
||||
//
|
||||
// trap #0 handler to bring the address of the disk routines into TOS
|
||||
//
|
||||
_xhdi_sd_install:
|
||||
move.l 4(sp),d0 // address of the old XHDI vector
|
||||
move.l d0,_old_vector // save it in case we need it
|
||||
move.l _xhdi_vec,d0 // return our BaS vector to TOS
|
||||
rte
|
||||
|
||||
Reference in New Issue
Block a user