Simple BIOS Call Working
Simple test of a bconout BIOS call is working under Easy68K emulator.
This commit is contained in:
parent
7e494acd60
commit
642e17b084
12
src/Makefile
12
src/Makefile
|
@ -1,18 +1,18 @@
|
|||
AS=vasmm68k_mot
|
||||
CC=vc
|
||||
CFLAGS=+../vbcc/config/m68k-foenix -I. -Iinclude
|
||||
CFLAGS=+../vbcc/config/m68k-foenix -I. -Iinclude -k
|
||||
DEPS=syscalls_m68k.h
|
||||
|
||||
foenixmcp.s68: foenixmcp.o bios_m68k.o syscalls_m68k.o startup_m68k.o
|
||||
$(CC) $(CFLAGS) -o foenixmcp.s68 foenixmcp.o bios_m68k.o syscalls_m68k.o
|
||||
|
||||
startup_m68k.o: startup_m68k.s
|
||||
$(AS) -Fvobj -o $@ $<
|
||||
|
||||
%.o: %.c $(DEPS)
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
foenixmcp: foenixmcp.o bios_m68k.o syscalls_m68k.o startup_m68k.o
|
||||
$(CC) $(CFLAGS) -o foenixmcp foenixmcp.o bios_m68k.o syscalls_m68k.o
|
||||
$(CC) -S -c -o $@ $< $(CFLAGS)
|
||||
|
||||
PHONEY: clean
|
||||
|
||||
clean:
|
||||
rm *.o
|
||||
del *.o
|
||||
|
|
48
src/bios_m68k.asm
Normal file
48
src/bios_m68k.asm
Normal file
|
@ -0,0 +1,48 @@
|
|||
idnt "bios_m68k.c"
|
||||
opt o+,ol+,op+,oc+,ot+,oj+,ob+,om+
|
||||
section "CODE",code
|
||||
public _impl_bconout
|
||||
cnop 0,4
|
||||
_impl_bconout
|
||||
movem.l l3,-(a7)
|
||||
move.b (7+l5,a7),d1
|
||||
move.l _text_cursor_0,d0
|
||||
addq.l #1,_text_cursor_0
|
||||
move.l #16384,a0
|
||||
move.b d1,(0,a0,d0.l)
|
||||
moveq #0,d0
|
||||
l1
|
||||
l3 reg
|
||||
l5 equ 0
|
||||
rts
|
||||
; stacksize=0
|
||||
opt o+,ol+,op+,oc+,ot+,oj+,ob+,om+
|
||||
public _bios_dispatch
|
||||
cnop 0,4
|
||||
_bios_dispatch
|
||||
movem.l l11,-(a7)
|
||||
move.l (8+l13,a7),d3
|
||||
move.l (4+l13,a7),d2
|
||||
move.l d2,d0
|
||||
subq.l #1,d0
|
||||
beq l9
|
||||
bra l10
|
||||
l9
|
||||
move.l d3,-(a7)
|
||||
jsr _impl_bconout
|
||||
addq.w #4,a7
|
||||
bra l6
|
||||
l10
|
||||
moveq #-1,d0
|
||||
l8
|
||||
l6
|
||||
l11 reg d2/d3
|
||||
movem.l (a7)+,d2/d3
|
||||
l13 equ 8
|
||||
rts
|
||||
; stacksize=16
|
||||
public _text_cursor_0
|
||||
section "DATA",data
|
||||
cnop 0,4
|
||||
_text_cursor_0
|
||||
dc.l 0
|
|
@ -4,39 +4,52 @@
|
|||
* NOTE: these routines are not called directly but are instead called through TRAP#13
|
||||
*/
|
||||
|
||||
#define TEXT_MATRIX_0 ((volatile char *)0x00AFA000)
|
||||
#define TEXT_MATRIX_0 ((volatile char *)0x00004000)
|
||||
|
||||
typedef void (* interrupt_handler)();
|
||||
|
||||
static int text_cursor_0 = 0;
|
||||
int text_cursor_0 = 0;
|
||||
|
||||
int impl_bconout(long context, char c) {
|
||||
int impl_bconout(char c) {
|
||||
TEXT_MATRIX_0[text_cursor_0++] = c;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set an exception handler
|
||||
*
|
||||
* If handler is the nil pointer, just return the current value.
|
||||
*
|
||||
* Inputs:
|
||||
* number = the number of the 68000 exception vector (2 - 255)
|
||||
* handler = pointer to the handler (must be coded as an interrupt handler)
|
||||
*
|
||||
* Return:
|
||||
* the previous value
|
||||
*/
|
||||
long impl_setexc(long context, unsigned short number, void (* handler)()) {
|
||||
interrupt_handler * address = 0;
|
||||
long result = 0;
|
||||
if ((number > 1) && (number < 256)) {
|
||||
address = (interrupt_handler *)(number * 2);
|
||||
result = (long)(*address);
|
||||
if (handler != 0) {
|
||||
*address = handler;
|
||||
}
|
||||
}
|
||||
// /*
|
||||
// * Set an exception handler
|
||||
// *
|
||||
// * If handler is the nil pointer, just return the current value.
|
||||
// *
|
||||
// * Inputs:
|
||||
// * number = the number of the 68000 exception vector (2 - 255)
|
||||
// * handler = pointer to the handler (must be coded as an interrupt handler)
|
||||
// *
|
||||
// * Return:
|
||||
// * the previous value
|
||||
// */
|
||||
// long impl_setexc(unsigned short number, void (* handler)()) {
|
||||
// interrupt_handler * address = 0;
|
||||
// long result = 0;
|
||||
// if ((number > 1) && (number < 256)) {
|
||||
// address = (interrupt_handler *)(number * 2);
|
||||
// result = (long)(*address);
|
||||
// if (handler != 0) {
|
||||
// *address = handler;
|
||||
// }
|
||||
// }
|
||||
|
||||
return result;
|
||||
// return result;
|
||||
// }
|
||||
|
||||
/*
|
||||
* Determine the correct BIOS function implementation to call and call it.
|
||||
*/
|
||||
int bios_dispatch(int function, int param0, int param1, int param2, int param3, int param4, int param5) {
|
||||
switch (function) {
|
||||
case 1:
|
||||
return impl_bconout(param0);
|
||||
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
|
@ -1,22 +1,22 @@
|
|||
:020000040001F9
|
||||
:200000004FF90011000041F900010224203C0000000467104298598066FA41FA001A327C39
|
||||
:2000200000B422884EB90001010060FE4E7370004E754E4D4E7548A73F3E3C4F4E6F3F0EA8
|
||||
:20004000302F00040C4000066C08E5484EBB00146004700144803C5F4E673E4E4C9F7CFC55
|
||||
:200060004E730001002E000101740001002E0001002E0001002E00010194000048E7203078
|
||||
:2000800047F90001020A203C0001020A672674014AAB0004670C52822002E5884AB30800D4
|
||||
:2000A00066F45382670E2002E588247308004E92538266F22F2F00104EB90001002A584F1A
|
||||
:2000C0004CDF0C044E754E7148E700304AB90001021C6626267900010224700123C000013B
|
||||
:2000E000021C200B670C246B00044E922653200B66F42F2F000C6184584F4CDF0C004E75E3
|
||||
:2001000048E7003047F900010216203C00010212670C4A936708245B4E924A9366F82F2FFF
|
||||
:2001200000102F2F00104EB90001013C2F0061984FEF000C4CDF0C004E75000048E7003031
|
||||
:2001400047FA0026244B60121012488048C02F004EB9000101EC584F528A200A66EA60FEE6
|
||||
:2001600070004CDF0C004E75466F656E69782F4D43500000122F000B20390001022052B9CA
|
||||
:2001800000010220207C00AFA0001181080070004E754E712F02322F000E226F001091C82B
|
||||
:2001A0007400B27C00016316B27C0100641070003001D0802040241020096702208920029E
|
||||
:2001C000241F4E7548E72020342F000E246F00102F0A700030022F00487800054EB90001BF
|
||||
:2001E00000324FEF000C4CDF04044E752F02142F000B1002488048C02F00487800014EB935
|
||||
:0A02000000010032504F241F4E751C
|
||||
:08020A000000000000000000EC
|
||||
:080212000000000000000000E4
|
||||
:08021C000000000000000000DA
|
||||
:00000001FF
|
||||
S00C0000666F656E69786D63702A
|
||||
S2240100004FF90002000041F900010224203C0000000467104298598066FA41FA001A327C42
|
||||
S22401002000B422884EB90001010060FE4E7370004E754E4D4E7548A73F3E3C4F4E6F3F0EA2
|
||||
S224010040302F00040C4000066C08E5484EBB00146004700144803C5F4E673E4E4C9F7CFC4F
|
||||
S2240100604E730001002E000101740001002E0001002E0001002E00010194000048E7203072
|
||||
S22401008047F90001020A203C0001020A672674014AAB0004670C52822002E5884AB30800CE
|
||||
S2240100A066F45382670E2002E588247308004E92538266F22F2F00104EB90001002A584F14
|
||||
S2240100C04CDF0C044E754E7148E700304AB90001021C6626267900010224700123C0000135
|
||||
S2240100E0021C200B670C246B00044E922653200B66F42F2F000C6184584F4CDF0C004E75DD
|
||||
S22401010048E7003047F900010216203C00010212670C4A936708245B4E924A9366F82F2FF9
|
||||
S22401012000102F2F00104EB90001013C2F0061984FEF000C4CDF0C004E75000048E700302B
|
||||
S22401014047FA0026244B60121012488048C02F004EB9000101EC584F528A200A66EA60FEE0
|
||||
S22401016070004CDF0C004E75466F656E69782F4D43500000122F000B20390001022052B9C4
|
||||
S22401018000010220207C00AFA0001181080070004E754E712F02322F000E226F001091C825
|
||||
S2240101A07400B27C00016316B27C0100641070003001D08020402410200967022089200298
|
||||
S2240101C0241F4E7548E72020342F000E246F00102F0A700030022F00487800054EB90001B9
|
||||
S2240101E000324FEF000C4CDF04044E752F02142F000B1002488048C02F00487800014EB92F
|
||||
S20E01020000010032504F241F4E7516
|
||||
S20C01020A0000000000000000E6
|
||||
S20C0102120000000000000000DE
|
||||
S20C01021C0000000000000000D4
|
||||
S804010000FA
|
||||
|
|
|
@ -5,6 +5,13 @@
|
|||
cnop 0,4
|
||||
_main
|
||||
movem.l l6,-(a7)
|
||||
move.l #65,-(a7)
|
||||
jsr _bconout
|
||||
move.l #66,-(a7)
|
||||
jsr _bconout
|
||||
move.l #67,-(a7)
|
||||
jsr _bconout
|
||||
add.w #12,a7
|
||||
l3
|
||||
bra l3
|
||||
l5
|
||||
|
@ -13,4 +20,4 @@ l1
|
|||
l6 reg
|
||||
l8 equ 0
|
||||
rts
|
||||
; stacksize=0
|
||||
public _bconout
|
||||
|
|
|
@ -5,12 +5,9 @@
|
|||
#include "syscalls_m68k.h"
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
|
||||
char * greet = "Foenix/MCP";
|
||||
|
||||
for (char * c = greet; c != 0; c++) {
|
||||
bconout(*c);
|
||||
}
|
||||
bconout('A');
|
||||
bconout('B');
|
||||
bconout('C');
|
||||
|
||||
/* Infinite loop... */
|
||||
while (1) {};
|
||||
|
|
19
src/foenixmcp.s68
Normal file
19
src/foenixmcp.s68
Normal file
|
@ -0,0 +1,19 @@
|
|||
S0100000666F656E69786D63702E73363817
|
||||
S2240100004FF90002000041F9000101C4203C0000000467104298598066FA41FA0038327C85
|
||||
S22401002000B422884EB9000100E860FE48E77F002E2F00122C2F00162A2F001A282F001E98
|
||||
S224010040262F002C242F0030222F002A4E4D4CDF00FE4E752F022F014EB900010168508FE3
|
||||
S2240100604E73000048E7203047F9000101AA203C000101AA672674014AAB0004670C528204
|
||||
S2240100802002E5884AB3080066F45382670E2002E588247308004E92538266F22F2F001079
|
||||
S2240100A04EB90001002A584F4CDF0C044E754E7148E700304AB9000101BC66262679000158
|
||||
S2240100C001C4700123C0000101BC200B670C246B00044E922653200B66F42F2F000C6184E5
|
||||
S2240100E0584F4CDF0C004E7548E7003047F9000101B6203C000101B2670C4A936708245BB4
|
||||
S2240101004E924A9366F82F2F00102F2F00104EB9000101242F0061984FEF000C4CDF0C000C
|
||||
S2240101204E750000487800414EB90001018C487800424EB90001018C487800434EB90001BE
|
||||
S224010140018C4FEF000C60FE70004E75122F00072039000101C052B9000101C0307C400015
|
||||
S2240101601181080070004E7548E73000262F0010242F000C20025380670260082F0361CC64
|
||||
S224010180584F600270FF4CDF000C4E752F02142F000B1002488048C02F00487800014EB98F
|
||||
S20E0101A00001002C504F241F4E757D
|
||||
S20C0101AA000000000000000047
|
||||
S20C0101B200000000000000003F
|
||||
S20C0101BC000000000000000035
|
||||
S804010000FA
|
149
src/mapfile
149
src/mapfile
|
@ -1,120 +1,103 @@
|
|||
../vbcc/targets/m68k-foenix/lib/libvc.a (_main.o) needed due to ___main
|
||||
..\vbcc\targets\m68k-foenix\lib\libvc.a (_main.o) needed due to ___main
|
||||
|
||||
Files:
|
||||
startup_m68k.o: CODE 10000(7a) hex
|
||||
../vbcc/targets/m68k-foenix/lib/libvc.a (_main.o): CODE 1007c(be), DATA 1021c(4), BSS 10224(4) hex
|
||||
foenixmcp.o: CODE 1013c(37) hex
|
||||
bios_m68k.o: CODE 10174(50), DATA 10220(4) hex
|
||||
syscalls_m68k.o: CODE 101c4(46) hex
|
||||
INITEXIT: .dtors 1020a(8), .ctors 10212(8) hex
|
||||
startup_m68k.o: CODE 10000(62) hex
|
||||
..\vbcc\targets\m68k-foenix\lib\libvc.a (_main.o): CODE 10064(be), DATA 101bc(4), BSS 101c4(4) hex
|
||||
foenixmcp.o: CODE 10124(28) hex
|
||||
bios_m68k.o: CODE 1014c(40), DATA 101c0(4) hex
|
||||
syscalls_m68k.o: CODE 1018c(1e) hex
|
||||
INITEXIT: .dtors 101aa(8), .ctors 101b2(8) hex
|
||||
|
||||
|
||||
Section mapping (numbers in hex):
|
||||
------------------------------
|
||||
00010000 text (size 20a)
|
||||
00010000 - 0001007a startup_m68k.o(CODE)
|
||||
0001007c - 0001013a _main.o(CODE)
|
||||
0001013c - 00010173 foenixmcp.o(CODE)
|
||||
00010174 - 000101c4 bios_m68k.o(CODE)
|
||||
000101c4 - 0001020a syscalls_m68k.o(CODE)
|
||||
00010000 text (size 1aa)
|
||||
00010000 - 00010062 startup_m68k.o(CODE)
|
||||
00010064 - 00010122 _main.o(CODE)
|
||||
00010124 - 0001014c foenixmcp.o(CODE)
|
||||
0001014c - 0001018c bios_m68k.o(CODE)
|
||||
0001018c - 000101aa syscalls_m68k.o(CODE)
|
||||
------------------------------
|
||||
0001020a .dtors (size 8, allocated 0)
|
||||
0001020a - 00010212 INITEXIT(.dtors)
|
||||
000101aa .dtors (size 8, allocated 0)
|
||||
000101aa - 000101b2 INITEXIT(.dtors)
|
||||
------------------------------
|
||||
00010212 .ctors (size 8, allocated 0)
|
||||
00010212 - 0001021a INITEXIT(.ctors)
|
||||
000101b2 .ctors (size 8, allocated 0)
|
||||
000101b2 - 000101ba INITEXIT(.ctors)
|
||||
------------------------------
|
||||
0001021c data (size 8, allocated 4)
|
||||
0001021c - 00010220 _main.o(DATA)
|
||||
00010220 - 00010224 bios_m68k.o(DATA)
|
||||
000101bc data (size 8, allocated 4)
|
||||
000101bc - 000101c0 _main.o(DATA)
|
||||
000101c0 - 000101c4 bios_m68k.o(DATA)
|
||||
------------------------------
|
||||
00010224 bss (size 4, allocated 0)
|
||||
00010224 - 00010228 _main.o(BSS)
|
||||
000101c4 bss (size 4, allocated 0)
|
||||
000101c4 - 000101c8 _main.o(BSS)
|
||||
|
||||
|
||||
Symbols of text:
|
||||
0x00000000 l4: local abs, size 0
|
||||
0x00000000 l8: local abs, size 0
|
||||
0x00000000 l5: local abs, size 0
|
||||
0x00000000 l3: local abs, size 0
|
||||
0x00000000 l6: local abs, size 0
|
||||
0x00000004 l14: local abs, size 0
|
||||
0x00000004 l16: local abs, size 0
|
||||
0x00000004 l10: local abs, size 0
|
||||
0x00000004 l8: local abs, size 0
|
||||
0x00000006 BIOS_FUNCS: local abs, size 0
|
||||
0x00000008 l31: local abs, size 0
|
||||
0x00000004 l5: local abs, size 0
|
||||
0x00000004 l3: local abs, size 0
|
||||
0x00000008 l43: local abs, size 0
|
||||
0x00000008 l13: local abs, size 0
|
||||
0x00000008 l5: local abs, size 0
|
||||
0x00000008 l31: local abs, size 0
|
||||
0x0000000c l11: local abs, size 0
|
||||
0x0000000c l18: local abs, size 0
|
||||
0x00000404 l3: local abs, size 0
|
||||
0x00000c00 l41: local abs, size 0
|
||||
0x00000c00 l29: local abs, size 0
|
||||
0x00000c00 l11: local abs, size 0
|
||||
0x00000c04 l16: local abs, size 0
|
||||
0x00010000 coldboot: local reloc, size 0
|
||||
0x00010014 clrloop: local reloc, size 0
|
||||
0x00010024 callmain: local reloc, size 0
|
||||
0x0001002a ___exit: global reloc, size 0
|
||||
0x0001002c no_handler: local reloc, size 0
|
||||
0x0001002e no_proc: local reloc, size 0
|
||||
0x00010032 _bios: global reloc, size 0
|
||||
0x00010036 h_trap_13: local reloc, size 0
|
||||
0x00010052 bad_func: local reloc, size 0
|
||||
0x00010056 htrap_done: local reloc, size 0
|
||||
0x00010062 bios_jump: local reloc, size 0
|
||||
0x0001007c __Exit: global reloc, size 0
|
||||
0x00010096 l12: local reloc, size 0
|
||||
0x000100a2 l14: local reloc, size 0
|
||||
0x000100a6 l13: local reloc, size 0
|
||||
0x000100b4 l15: local reloc, size 0
|
||||
0x000100c8 _exit: global reloc, size 0
|
||||
0x000100e6 l27: local reloc, size 0
|
||||
0x000100f2 l28: local reloc, size 0
|
||||
0x000100fa l23: local reloc, size 0
|
||||
0x00010100 ___main: global reloc, size 0
|
||||
0x00010116 l39: local reloc, size 0
|
||||
0x0001011e l40: local reloc, size 0
|
||||
0x0001013c _main: global reloc, size 0
|
||||
0x00010148 l4: local reloc, size 0
|
||||
0x00010158 l7: local reloc, size 0
|
||||
0x0001015a l5: local reloc, size 0
|
||||
0x0001015e l6: local reloc, size 0
|
||||
0x0001015e l8: local reloc, size 0
|
||||
0x00010160 l10: local reloc, size 0
|
||||
0x00010162 l1: local reloc, size 0
|
||||
0x00010168 l3: local reloc, size 0
|
||||
0x00010174 _impl_bconout: global reloc, size 0
|
||||
0x00010190 l2: local reloc, size 0
|
||||
0x00010194 _impl_setexc: global reloc, size 0
|
||||
0x000101a8 l11: local reloc, size 0
|
||||
0x000101ae l9: local reloc, size 0
|
||||
0x000101bc l12: local reloc, size 0
|
||||
0x000101be l10: local reloc, size 0
|
||||
0x000101be l13: local reloc, size 0
|
||||
0x000101c0 l7: local reloc, size 0
|
||||
0x000101c4 _setexc: global reloc, size 0
|
||||
0x000101e6 l1: local reloc, size 0
|
||||
0x000101ec _bconout: global reloc, size 0
|
||||
0x00010206 l6: local reloc, size 0
|
||||
0x0001002c _bios: global reloc, size 0
|
||||
0x00010054 h_trap_13: local reloc, size 0
|
||||
0x00010064 __Exit: global reloc, size 0
|
||||
0x0001007e l12: local reloc, size 0
|
||||
0x0001008a l14: local reloc, size 0
|
||||
0x0001008e l13: local reloc, size 0
|
||||
0x0001009c l15: local reloc, size 0
|
||||
0x000100b0 _exit: global reloc, size 0
|
||||
0x000100ce l27: local reloc, size 0
|
||||
0x000100da l28: local reloc, size 0
|
||||
0x000100e2 l23: local reloc, size 0
|
||||
0x000100e8 ___main: global reloc, size 0
|
||||
0x000100fe l39: local reloc, size 0
|
||||
0x00010106 l40: local reloc, size 0
|
||||
0x00010124 _main: global reloc, size 0
|
||||
0x00010146 l3: local reloc, size 0
|
||||
0x00010148 l5: local reloc, size 0
|
||||
0x0001014a l1: local reloc, size 0
|
||||
0x0001014c _impl_bconout: global reloc, size 0
|
||||
0x00010166 l1: local reloc, size 0
|
||||
0x00010168 _bios_dispatch: global reloc, size 0
|
||||
0x0001017c l9: local reloc, size 0
|
||||
0x00010184 l10: local reloc, size 0
|
||||
0x00010186 l6: local reloc, size 0
|
||||
0x00010186 l8: local reloc, size 0
|
||||
0x0001018c _bconout: global reloc, size 0
|
||||
0x000101a6 l1: local reloc, size 0
|
||||
|
||||
Symbols of .dtors:
|
||||
0x0001020a ___DTOR_LIST__: global reloc object, size 8
|
||||
0x000101aa ___DTOR_LIST__: global reloc object, size 8
|
||||
|
||||
Symbols of .ctors:
|
||||
0x00010212 ___CTOR_LIST__: global reloc object, size 8
|
||||
0x000101b2 ___CTOR_LIST__: global reloc object, size 8
|
||||
|
||||
Symbols of data:
|
||||
0x0001021c l21: local reloc, size 0
|
||||
0x00010220 l1: local reloc, size 0
|
||||
0x000101bc l21: local reloc, size 0
|
||||
0x000101c0 _text_cursor_0: global reloc, size 0
|
||||
|
||||
Symbols of bss:
|
||||
0x00010224 ___firstexit: global reloc, size 0
|
||||
0x000101c4 ___firstexit: global reloc, size 0
|
||||
|
||||
Linker symbols:
|
||||
0x00010000 RAMSTART: global abs, size 0
|
||||
0x00100000 RAMSIZE: global abs, size 0
|
||||
0x00010000 RAMSIZE: global abs, size 0
|
||||
0x00000400 STACKLEN: global abs, size 0
|
||||
0x00010228 ___heap: global abs, size 0
|
||||
0x0010fc00 ___heapend: global abs, size 0
|
||||
0x00010224 ___BSSSTART: global abs, size 0
|
||||
0x000101c8 ___heap: global abs, size 0
|
||||
0x0001fc00 ___heapend: global abs, size 0
|
||||
0x000101c4 ___BSSSTART: global abs, size 0
|
||||
0x00000004 ___BSSSIZE: global abs, size 0
|
||||
0x00110000 ___STACK: global abs, size 0
|
||||
0x00020000 ___STACK: global abs, size 0
|
||||
|
|
|
@ -23,70 +23,36 @@ callmain: jsr ___main ; call __main to transfer to the C code
|
|||
___exit:
|
||||
bra ___exit
|
||||
|
||||
;
|
||||
; Dummy interrupt handler for when we have no vector installed
|
||||
;
|
||||
no_handler: rte
|
||||
|
||||
;
|
||||
; Dummy routine for when we have no function defined
|
||||
;
|
||||
no_proc: moveq.l #0,d0 ; Return 0
|
||||
rts
|
||||
|
||||
;
|
||||
; Function to make a BIOS system call based on the number of the BIOS function:
|
||||
; int bios(int number, ...)
|
||||
; int bios(int number, int p0, int p1, int p2, int p3, int p4, int p5)
|
||||
;
|
||||
_bios:: trap #13
|
||||
_bios:: movem.l d1-d7,-(sp)
|
||||
|
||||
move.l (18,sp),d7 ; Parameter 5 to D7
|
||||
move.l (22,sp),d6 ; Parameter 4 to D6
|
||||
move.l (26,sp),d5 ; Parameter 3 to D5
|
||||
move.l (30,sp),d4 ; Parameter 2 to D4
|
||||
move.l (44,sp),d3 ; Parameter 1 to D3
|
||||
move.l (48,sp),d2 ; Parameter 0 to D2
|
||||
move.l (42,sp),d1 ; Function number to D1
|
||||
|
||||
trap #13
|
||||
|
||||
movem.l (sp)+,d1-d7
|
||||
rts
|
||||
|
||||
;
|
||||
; TRAP#13 handler... play stack games and transfer control to the C dispatcher
|
||||
; TRAP#13 handler... transfer control to the C dispatcher
|
||||
;
|
||||
; Calling conventions:
|
||||
; Programs will call the kernel using TRAP, first pushing arguments to the user stack
|
||||
; the only mandatory argument is the function number, which will be the last argument
|
||||
; pushed to the stack.
|
||||
;
|
||||
; Values returned will be in d0
|
||||
;
|
||||
; The C routine to process a TRAP will have an additional context variable which
|
||||
; will be unused by the kernel except by the assembly routine as a means of restoring
|
||||
; the caller's stack context:
|
||||
;
|
||||
; uint32_t handle_TRAP_13(uint32_t context, uint16_t function, ...)
|
||||
;
|
||||
h_trap_13: movem d2-d7/a2-a6,-(sp) ; Save the caller's registers to the system stack
|
||||
movea sp,a6 ; Hold onto the SSP
|
||||
move usp,a7 ; Get back the usp
|
||||
move a6,-(sp) ; Push the SSP as the context argument
|
||||
h_trap_13:
|
||||
move.l d2,-(sp)
|
||||
move.l d1,-(sp)
|
||||
|
||||
move.w (4,sp),d0 ; Get the function #
|
||||
cmpi #BIOS_FUNCS,d0 ; Is it within range?
|
||||
bge bad_func ; No: return an error number
|
||||
jsr _bios_dispatch ; Call the C routine to do the dispatch
|
||||
; Note: the C routine depends upon the register push order
|
||||
|
||||
lsl.w #2,d0 ; offset := number * 4
|
||||
jsr (bios_jump,pc,d0) ; Call the function
|
||||
bra htrap_done ; And return results
|
||||
addq.l #8,a7
|
||||
|
||||
bad_func: moveq.l #1,d0 ; Return -1 for an error
|
||||
neg.l d0
|
||||
|
||||
htrap_done: move (sp)+,a6 ; Get the SSP off the user stack
|
||||
move a7,usp ; Put the USP back
|
||||
movea a6,a7 ; Restore the SSP
|
||||
movem (sp)+,d2-d7/a2-a6 ; Restore the caller's registers from the system stack
|
||||
rte ; Return to the caller
|
||||
|
||||
BIOS_FUNCS=6 ; The number of BIOS functions that are defined
|
||||
|
||||
;
|
||||
; Jump table for the BIOS dispatch
|
||||
;
|
||||
bios_jump: dc.l no_proc ; Function #0 = NULL
|
||||
dc.l _impl_bconout ; Function #1 = bconout
|
||||
dc.l no_proc ; Function #2 = NULL
|
||||
dc.l no_proc ; Function #3 = NULL
|
||||
dc.l no_proc ; Function #4 = NULL
|
||||
dc.l _impl_setexc ; Function #5 = SETEXCW
|
||||
|
|
|
@ -1,28 +1,21 @@
|
|||
idnt "syscalls_m68k.c"
|
||||
opt o+,ol+,op+,oc+,ot+,oj+,ob+,om+
|
||||
section "CODE",code
|
||||
public _setexc
|
||||
public _bconout
|
||||
cnop 0,4
|
||||
_setexc
|
||||
_bconout
|
||||
movem.l l3,-(a7)
|
||||
move.w (6+l5,a7),d2
|
||||
move.l (8+l5,a7),a2
|
||||
move.l a2,-(a7)
|
||||
moveq #0,d0
|
||||
move.w d2,d0
|
||||
move.l d0,-(a7)
|
||||
moveq #0,d0
|
||||
move.w _BIOS_SETEXC,d0
|
||||
move.b (7+l5,a7),d2
|
||||
move.b d2,d0
|
||||
ext.w d0
|
||||
ext.l d0
|
||||
move.l d0,-(a7)
|
||||
move.l #1,-(a7)
|
||||
jsr _bios
|
||||
add.w #12,a7
|
||||
addq.w #8,a7
|
||||
l1
|
||||
l3 reg a2/d2
|
||||
movem.l (a7)+,a2/d2
|
||||
l5 equ 8
|
||||
l3 reg d2
|
||||
movem.l (a7)+,d2
|
||||
l5 equ 4
|
||||
rts
|
||||
public _BIOS_SETEXC
|
||||
cnop 0,4
|
||||
_BIOS_SETEXC
|
||||
dc.w 5
|
||||
public _bios
|
||||
|
|
|
@ -7,23 +7,23 @@
|
|||
/*
|
||||
* Call into the BIOS by issuing a TRAP #13
|
||||
*/
|
||||
extern int bios(unsigned short function, ...);
|
||||
extern int bios(int function, ...);
|
||||
|
||||
/*
|
||||
* Set an exception handler
|
||||
*
|
||||
* If handler is the nil pointer, just return the current value.
|
||||
*
|
||||
* Inputs:
|
||||
* number = the number of the 68000 exception vector (2 - 255)
|
||||
* handler = pointer to the handler (must be coded as an interrupt handler)
|
||||
*
|
||||
* Return:
|
||||
* the previous value
|
||||
*/
|
||||
long setexc(unsigned short number, void (* handler)()) {
|
||||
return (long)bios(5, number, handler);
|
||||
}
|
||||
// /*
|
||||
// * Set an exception handler
|
||||
// *
|
||||
// * If handler is the nil pointer, just return the current value.
|
||||
// *
|
||||
// * Inputs:
|
||||
// * number = the number of the 68000 exception vector (2 - 255)
|
||||
// * handler = pointer to the handler (must be coded as an interrupt handler)
|
||||
// *
|
||||
// * Return:
|
||||
// * the previous value
|
||||
// */
|
||||
// int setexc(unsigned short number, void (* handler)()) {
|
||||
// return bios(5, number, (int)handler);
|
||||
// }
|
||||
|
||||
/*
|
||||
* Print a character to the text screen
|
||||
|
@ -32,5 +32,5 @@ long setexc(unsigned short number, void (* handler)()) {
|
|||
* c = character to print
|
||||
*/
|
||||
int bconout(char c) {
|
||||
return (int)bios(1, c);
|
||||
return bios(1, c);
|
||||
}
|
|
@ -10,14 +10,14 @@
|
|||
#ifndef __SYSCALLS_M68K_H
|
||||
#define __SYSCALLS_M68K_H
|
||||
|
||||
/*
|
||||
* Set an exception handler
|
||||
*
|
||||
* Inputs:
|
||||
* number = the number of the 68000 exception vector
|
||||
* handler = pointer to the handler (must be coded as an interrupt handler)
|
||||
*/
|
||||
extern long setexc(unsigned short number, void (* handler)());
|
||||
// /*
|
||||
// * Set an exception handler
|
||||
// *
|
||||
// * Inputs:
|
||||
// * number = the number of the 68000 exception vector
|
||||
// * handler = pointer to the handler (must be coded as an interrupt handler)
|
||||
// */
|
||||
// extern int setexc(unsigned short number, void (* handler)());
|
||||
|
||||
/*
|
||||
* Print a character to the text screen
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
-cc=vbccm68k -quiet %s -o= %s %s -O=%ld -Ivbcc/targets/m68k-foenix/include
|
||||
-ccv=vbccm68k %s -o= %s %s -O=%ld -Ivbcc/targets/m68k-foenix/include
|
||||
-cc=vbccm68k -quiet %s -o= %s %s -O=%ld -Ivbcc\targets\m68k-foenix\include
|
||||
-ccv=vbccm68k %s -o= %s %s -O=%ld -Ivbcc\targets\m68k-foenix\include
|
||||
-as=vasmm68k_mot -quiet -Fvobj -nowarn=62 %s -o %s
|
||||
-asv=vasmm68k_mot -Fvobj -nowarn=62 %s -o %s
|
||||
-rm=rm -f %s
|
||||
-rmv=rm %s
|
||||
-ld=vlink -bihex -x -Cvbcc startup_m68k.o %s %s -L../vbcc/targets/m68k-foenix/lib -T../vbcc/targets/m68k-foenix/vlink.cmd -lvc -o %s -Mmapfile
|
||||
-l2=vlink -bihex -x -Cvbcc %s %s -L../vbcc/targets/m68k-foenix/lib -T../vbcc/targets/m68k-foenix/vlink.cmd -o %s -Mmapfile
|
||||
-ldv=vlink -bihex -t -x -Cvbcc src/m68k/startup.o %s %s -L../vbcc/targets/m68k-foenix/lib -T../vbcc/targets/m68k-foenix/vlink.cmd -lvc -o %s -Mmapfile
|
||||
-l2v=vlink -bihex -t -x -Cvbcc %s %s -L../vbcc/targets/m68k-foenix/lib -T../vbcc/targets/m68k-foenix/vlink.cmd -o %s -Mmapfile
|
||||
-rm=del %s
|
||||
-rmv=del %s
|
||||
-ld=vlink -bsrec28 -x -Cvbcc startup_m68k.o %s %s -L..\vbcc\targets\m68k-foenix\lib -T..\vbcc\targets\m68k-foenix\vlink.cmd -lvc -o %s -Mmapfile
|
||||
-l2=vlink -bsrec28 -x -Cvbcc %s %s -L..\vbcc\targets\m68k-foenix\lib -T..\vbcc\targets\m68k-foenix\vlink.cmd -o %s -Mmapfile
|
||||
-ldv=vlink -bsrec28 -t -x -Cvbcc src\m68k\startup.o %s %s -L..\vbcc\targets\m68k-foenix\lib -T..\vbcc\targets\m68k-foenix\vlink.cmd -lvc -o %s -Mmapfile
|
||||
-l2v=vlink -bsrec28 -t -x -Cvbcc %s %s -L..\vbcc\targets\m68k-foenix\lib -T..\vbcc\targets\m68k-foenix\vlink.cmd -o %s -Mmapfile
|
||||
-ul=-l%s
|
||||
-cf=-F%s
|
||||
-ml=1000
|
||||
|
|
Loading…
Reference in a new issue