mirror of
https://git.planet-casio.com/Lephenixnoir/gint.git
synced 2025-01-01 14:33:34 +01:00
exch: add trapa #31 handler
This commit is contained in:
parent
badbd0fd2b
commit
395250b5a9
5 changed files with 52 additions and 7 deletions
|
@ -125,6 +125,7 @@ set(SOURCES
|
||||||
src/kernel/osmenu.c
|
src/kernel/osmenu.c
|
||||||
src/kernel/start.c
|
src/kernel/start.c
|
||||||
src/kernel/start.S
|
src/kernel/start.S
|
||||||
|
src/kernel/syscall.c
|
||||||
src/kernel/syscalls.S
|
src/kernel/syscalls.S
|
||||||
src/kernel/tlbh.S
|
src/kernel/tlbh.S
|
||||||
src/kernel/world.c
|
src/kernel/world.c
|
||||||
|
|
|
@ -132,10 +132,9 @@ void *intc_handler(int event_code, void const *handler, size_t size);
|
||||||
the numerous constraints of intc_handler(), at the cost of always going back
|
the numerous constraints of intc_handler(), at the cost of always going back
|
||||||
to userspace and a small time overhead.
|
to userspace and a small time overhead.
|
||||||
|
|
||||||
Since gint_inth_callback is used to do the heavy lifting of setting up a sane
|
gint_inth_callback does the heavy lifting of setting up a sane context for C
|
||||||
context for C code, the gint_call_t object can be built with GINT_CALL_FLAG
|
code. If the gint_call_t object is built with GINT_CALL_FLAG, the function
|
||||||
if the called function expects a gint_inth_callback_context_t structure as its
|
is called with a gint_inth_callback_context_t * as its first argument.
|
||||||
first argument.
|
|
||||||
|
|
||||||
@event_code Identifier of the interrupt block
|
@event_code Identifier of the interrupt block
|
||||||
@function Function to use as a handler
|
@function Function to use as a handler
|
||||||
|
|
|
@ -16,8 +16,31 @@ _gint_exch:
|
||||||
mov.l @r0, r0
|
mov.l @r0, r0
|
||||||
tst #1, r0
|
tst #1, r0
|
||||||
mov.l .expevt_sh4, r8
|
mov.l .expevt_sh4, r8
|
||||||
bt catch
|
mov.l .tra_sh4, r9
|
||||||
|
bt syscall
|
||||||
mov.l .expevt_sh3, r8
|
mov.l .expevt_sh3, r8
|
||||||
|
mov.l .tra_sh3, r9
|
||||||
|
|
||||||
|
syscall:
|
||||||
|
/* If this is trapa #31, save context and run the syscall interface. */
|
||||||
|
mov.l @r8, r4
|
||||||
|
mov.w .expevt_trapa, r5
|
||||||
|
mov.l @r9, r0
|
||||||
|
cmp/eq r4, r5
|
||||||
|
bf catch
|
||||||
|
cmp/eq #31*4, r0
|
||||||
|
bf catch
|
||||||
|
|
||||||
|
add #-20, r15
|
||||||
|
mov.l .syscall_entry_plus1, r0
|
||||||
|
mov r15, r4
|
||||||
|
mov.l .callback, r1
|
||||||
|
mov.l @r1, r1
|
||||||
|
jsr @r1
|
||||||
|
mov.l r0, @r4
|
||||||
|
|
||||||
|
bra end
|
||||||
|
add #20, r15
|
||||||
|
|
||||||
catch:
|
catch:
|
||||||
/* Panic if the catcher is NULL */
|
/* Panic if the catcher is NULL */
|
||||||
|
@ -89,3 +112,13 @@ end:
|
||||||
.long (0xf << 4)
|
.long (0xf << 4)
|
||||||
.SR_clear_BL:
|
.SR_clear_BL:
|
||||||
.long ~(1 << 28)
|
.long ~(1 << 28)
|
||||||
|
.callback:
|
||||||
|
.long _gint_inth_callback
|
||||||
|
.syscall_entry_plus1:
|
||||||
|
.long _syscall_entry + 1
|
||||||
|
.tra_sh3:
|
||||||
|
.long 0xffffffd0
|
||||||
|
.tra_sh4:
|
||||||
|
.long 0xff000020
|
||||||
|
.expevt_trapa:
|
||||||
|
.word 0x160
|
||||||
|
|
13
src/kernel/syscall.c
Normal file
13
src/kernel/syscall.c
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#include <gint/gint.h>
|
||||||
|
|
||||||
|
int debug_syscall_count = 0;
|
||||||
|
int debug_syscall_lastnr = 0;
|
||||||
|
|
||||||
|
void syscall_entry(gint_inth_callback_context_t *ptr)
|
||||||
|
{
|
||||||
|
/* TODO: Currently, only user's r0...r7, spc, and ssr are saved here */
|
||||||
|
(void)ptr;
|
||||||
|
|
||||||
|
++debug_syscall_count;
|
||||||
|
debug_syscall_lastnr = ptr->r3;
|
||||||
|
}
|
|
@ -32,8 +32,7 @@ _inth_tmu:
|
||||||
sts.l pr, @-r15
|
sts.l pr, @-r15
|
||||||
mov.l r5, @-r15
|
mov.l r5, @-r15
|
||||||
|
|
||||||
/* Clear the interrupt flag. Because r5 contains 0, 1 or 2 the 16 top
|
/* Clear the interrupt flag */
|
||||||
bits are 0 so we can compare without extending */
|
|
||||||
1: mov.w @r1, r5
|
1: mov.w @r1, r5
|
||||||
extu.b r5, r3
|
extu.b r5, r3
|
||||||
cmp/eq r5, r3
|
cmp/eq r5, r3
|
||||||
|
|
Loading…
Reference in a new issue