[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[MiNT] XaAES trap sanitizer
Here is a patch for sanitizing the usage of traps in XaAES.
Basically, it assumes that d2/a1/a2 can be modified by any trap.
I don't know if this will improve things, but our recent discussion showed
that these changes were absolutely required.
This patch compiles well.
I have checked the generated assembly code, it looks good.
However, due to a lack of user competence from myself in FreeMiNT and XaAES,
I have not tested the resulting executables. I do believe there is nothing
wrong in these small changes.
Maintainers, please review this patch and commit.
NB: GemLib patch will follow soon.
--
Vincent Rivière
diff -aurN -x CVS freemint.orig/xaaes/src.km/nkcc-gc.s freemint/xaaes/src.km/nkcc-gc.s
--- freemint.orig/xaaes/src.km/nkcc-gc.s 2004-05-28 15:45:27.000000000 +0200
+++ freemint/xaaes/src.km/nkcc-gc.s 2009-12-19 09:31:54.046875000 +0100
@@ -143,6 +143,7 @@
_nkc_init:
|------------- fetch addresses of TOS' key scan code translation tables
+ moveml d2/a2,sp@- | backup registers
moveql #-1,d0 | the function is also used to
movel d0,sp@- | change the addresses| values
movel d0,sp@- | of -1 as new addresses tell
@@ -156,8 +157,8 @@
movel a0@+,pkey_shift | get ^shifted table
movel a0@,pkey_caps | get ^CapsLock table
-exit1:
movew #VERSION,d0 | load version #
+ moveml sp@+,d2/a2 | restore registers
rts | bye
|***************************************************************************
diff -aurN -x CVS freemint.orig/xaaes/src.km/xa_global.c freemint/xaaes/src.km/xa_global.c
--- freemint.orig/xaaes/src.km/xa_global.c 2009-08-13 13:21:59.000000000 +0200
+++ freemint/xaaes/src.km/xa_global.c 2009-12-19 09:37:45.343750000 +0100
@@ -277,38 +277,8 @@
}
return v;
}
-#if 0
-/*
- * callout the VDI
- */
-void
-do_vdi_trap (XVDIPB * vpb)
-{
- __asm__ volatile
- (
- "movea.l %0,a0\n\t" \
- "move.l a0,d1\n\t" \
- "move.w #115,d0\n\t" \
- "trap #2\n\t" \
- :
- : "a"(vpb)
- : "a0", "d0", "d1", "memory"
- );
-}
void
-VDI(XVDIPB *vpb, short c0, short c1, short c3, short c5, short c6)
-{
- vpb->control[V_OPCODE ] = c0;
- vpb->control[V_N_PTSIN ] = c1;
- vpb->control[V_N_INTIN ] = c3;
- vpb->control[V_SUBOPCODE] = c5;
- vpb->control[V_HANDLE ] = c6;
-
- do_vdi_trap(vpb);
-}
-#endif
-void
get_vdistr(char *d, short *s, short len)
{
for (;len >= 0; len--)
diff -aurN -x CVS freemint.orig/xaaes/src.km/xa_global.h freemint/xaaes/src.km/xa_global.h
--- freemint.orig/xaaes/src.km/xa_global.h 2007-07-13 23:32:54.000000000 +0200
+++ freemint/xaaes/src.km/xa_global.h 2009-12-19 09:46:33.531250000 +0100
@@ -473,8 +473,6 @@
/* Global VDI calls */
XVDIPB * create_vdipb(void);
-// void do_vdi_trap (XVDIPB * vpb);
-// void VDI(XVDIPB *vpb, short c0, short c1, short c3, short c5, short c6);
void get_vdistr(char *d, short *s, short len);
void xvst_font(XVDIPB *vpb, short handle, short id);
XFNT_INFO * xvqt_xfntinfo(XVDIPB *vpb, short handle, short flags, short id, short index);
@@ -485,13 +483,12 @@
{
__asm__ volatile
(
- "movea.l %0,a0\n\t" \
- "move.l a0,d1\n\t" \
+ "move.l %0,d1\n\t" \
"move.w #115,d0\n\t" \
"trap #2\n\t" \
:
- : "a"(vpb)
- : "a0", "d0", "d1", "memory"
+ : "g"(vpb)
+ : "a0", "a1", "a2", "d0", "d1", "a2", "memory"
);
}