|
|
1.1 root 1: /*
1.1.1.2 root 2: Hatari - bios.c
3:
1.1.1.13! root 4: This file is distributed under the GNU General Public License, version 2
! 5: or at your option any later version. Read the file gpl.txt for details.
1.1 root 6:
7: Bios Handler (Trap #13)
8:
1.1.1.7 root 9: We intercept some Bios calls for debugging
1.1 root 10: */
1.1.1.8 root 11: const char Bios__fileid[] = "Hatari bios.c : " __DATE__ " " __TIME__;
1.1 root 12:
13: #include "main.h"
1.1.1.2 root 14: #include "configuration.h"
1.1 root 15: #include "floppy.h"
1.1.1.3 root 16: #include "log.h"
1.1 root 17: #include "m68000.h"
18: #include "printer.h"
19: #include "rs232.h"
20: #include "stMemory.h"
1.1.1.2 root 21: #include "bios.h"
1.1 root 22:
23:
24: /*-----------------------------------------------------------------------*/
1.1.1.6 root 25: /**
26: * BIOS Read/Write disk sector
27: * Call 4
28: */
1.1.1.12 root 29: static void Bios_RWabs(Uint32 Params)
1.1 root 30: {
1.1.1.13! root 31: #if ENABLE_TRACING
1.1.1.3 root 32: Uint32 pBuffer;
33: Uint16 RWFlag, Number, RecNo, Dev;
34:
35: /* Read details from stack */
1.1.1.12 root 36: RWFlag = STMemory_ReadWord(Params);
37: pBuffer = STMemory_ReadLong(Params+SIZE_WORD);
38: Number = STMemory_ReadWord(Params+SIZE_WORD+SIZE_LONG);
39: RecNo = STMemory_ReadWord(Params+SIZE_WORD+SIZE_LONG+SIZE_WORD);
40: Dev = STMemory_ReadWord(Params+SIZE_WORD+SIZE_LONG+SIZE_WORD+SIZE_WORD);
1.1 root 41:
1.1.1.12 root 42: LOG_TRACE(TRACE_OS_BIOS, "BIOS 0x04 Rwabs(%d,0x%lX,%d,%d,%i)\n",
43: RWFlag, STRAM_ADDR(pBuffer), Number, RecNo, Dev);
1.1.1.13! root 44: #endif
! 45: }
! 46:
! 47: /*-----------------------------------------------------------------------*/
! 48: /**
! 49: * BIOS Set/query exception vectors
! 50: * Call 5
! 51: */
! 52: static void Bios_Setexe(Uint32 Params)
! 53: {
! 54: #if ENABLE_TRACING
! 55: Uint16 vec = STMemory_ReadWord(Params);
! 56: Uint32 addr = STMemory_ReadLong(Params+SIZE_WORD);
! 57: struct {
! 58: int vec;
! 59: const char *name;
! 60: } *vecname, vecnames[] =
! 61: {
! 62: { 0x002, "BUSERROR" },
! 63: { 0x003, "ADDRESSERROR" },
! 64: { 0x004, "ILLEGALINSTRUCTION" },
! 65: { 0x021, "GEMDOS" },
! 66: { 0x022, "GEM" },
! 67: { 0x02D, "BIOS" },
! 68: { 0x02E, "XBIOS" },
! 69: { 0x100, "TIMER" },
! 70: { 0x101, "CRITICALERROR" },
! 71: { 0x102, "TERMINATE" },
! 72: { 0x000, "???" }
! 73: };
! 74: for (vecname = &(vecnames[0]); vecname->vec && vec != vecname->vec; vecname++)
! 75: ;
! 76: LOG_TRACE(TRACE_OS_BIOS, "BIOS 0x05 Setexc(0x%hX VEC_%s, 0x%X)\n", vec, vecname->name, addr);
! 77: #endif
1.1 root 78: }
79:
1.1.1.2 root 80:
1.1 root 81: /*-----------------------------------------------------------------------*/
1.1.1.2 root 82:
1.1.1.12 root 83: #if ENABLE_TRACING
1.1.1.6 root 84: /**
1.1.1.12 root 85: * Map BIOS call opcode to BIOS function name
1.1.1.10 root 86: */
1.1.1.12 root 87: static const char* Bios_Call2Name(Uint16 opcode)
1.1.1.10 root 88: {
89: /* GCC uses substrings from above trace statements
90: * where they match, so having them again here
91: * wastes only a pointer & simplifies things
92: */
93: static const char* names[] = {
94: "Getmpb", "Bconstat","Bconin", "Bconout",
95: "Rwabs", "Setexc", "Tickcal","Getbpb",
96: "Bcostat","Mediach", "Drvmap", "Kbshift"
97: };
1.1.1.12 root 98: if (opcode < ARRAYSIZE(names) && names[opcode]) {
99: return names[opcode];
1.1.1.10 root 100: }
1.1.1.12 root 101: return "???";
1.1.1.10 root 102: }
103:
1.1.1.12 root 104: void Bios_Info(Uint32 dummy)
105: {
106: Uint16 opcode;
107: for (opcode = 0; opcode <= 0xB; ) {
108: fprintf(stderr, "%02x %-9s", opcode,
109: Bios_Call2Name(opcode));
110: if (++opcode % 6 == 0) {
111: fputs("\n", stderr);
112: }
113: }
114: }
115: #else /* !ENABLE_TRACING */
116: void Bios_Info(Uint32 bShowOpcodes)
117: {
118: fputs("Hatari isn't configured with ENABLE_TRACING\n", stderr);
119: }
120: #endif /* !ENABLE_TRACING */
121:
1.1.1.10 root 122:
123: /*-----------------------------------------------------------------------*/
124: /**
125: * Check Bios call and see if we need to re-direct to our own routines.
126: * Return true if we've handled the exception, else return false to let
127: * TOS attempt it
1.1.1.6 root 128: */
1.1.1.7 root 129: bool Bios(void)
1.1 root 130: {
1.1.1.3 root 131: Uint32 Params;
132: Uint16 BiosCall;
1.1 root 133:
1.1.1.3 root 134: /* Get call */
135: Params = Regs[REG_A7];
136: BiosCall = STMemory_ReadWord(Params);
1.1.1.12 root 137: Params += SIZE_WORD;
1.1.1.3 root 138:
139: /* Intercept? */
140: switch(BiosCall)
141: {
1.1.1.13! root 142: case 0x0:
! 143: LOG_TRACE(TRACE_OS_BIOS, "BIOS 0x00 Getmpb(0x%X)\n",
! 144: STMemory_ReadLong(Params));
! 145: break;
! 146:
1.1.1.12 root 147: case 0x3:
1.1.1.13! root 148: LOG_TRACE(TRACE_OS_BIOS, "BIOS 0x03 Bconout(%i, 0x%02hX)\n",
! 149: STMemory_ReadWord(Params),
! 150: STMemory_ReadWord(Params+SIZE_WORD));
1.1.1.12 root 151: break;
1.1.1.13! root 152:
1.1.1.12 root 153: case 0x4:
154: Bios_RWabs(Params);
155: break;
156:
157: case 0x5:
1.1.1.13! root 158: Bios_Setexe(Params);
1.1.1.12 root 159: break;
160:
161: case 0x1:
162: case 0x2:
163: case 0x7:
164: case 0x8:
165: case 0x9:
166: case 0xB:
167: /* commands taking a single word */
168: LOG_TRACE(TRACE_OS_BIOS, "BIOS 0x%02hX %s(0x%hX)\n",
169: BiosCall, Bios_Call2Name(BiosCall),
170: STMemory_ReadWord(Params));
171: break;
172:
173: case 0x6:
174: case 0xA:
175: /* commands taking no args */
176: LOG_TRACE(TRACE_OS_BIOS, "BIOS 0x%02hX %s()\n",
177: BiosCall, Bios_Call2Name(BiosCall));
178: break;
179:
180: default:
181: Log_Printf(LOG_WARN, "Unknown BIOS call 0x%x!\n", BiosCall);
182: break;
1.1.1.3 root 183: }
1.1.1.12 root 184: return false;
1.1 root 185: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.