Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 1 | // 16bit system callbacks |
| 2 | // |
| 3 | // Copyright (C) 2008 Kevin O'Connor <kevin@koconnor.net> |
| 4 | // Copyright (C) 2002 MandrakeSoft S.A. |
| 5 | // |
| 6 | // This file may be distributed under the terms of the GNU GPLv3 license. |
| 7 | |
| 8 | #include "util.h" // irq_restore |
Kevin O'Connor | 2ad3744 | 2008-05-06 19:49:01 -0400 | [diff] [blame] | 9 | #include "biosvar.h" // BIOS_CONFIG_TABLE |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 10 | #include "ioport.h" // inb |
Kevin O'Connor | c781293 | 2008-06-08 23:08:12 -0400 | [diff] [blame] | 11 | #include "memmap.h" // E820_RAM |
Kevin O'Connor | f54c150 | 2008-06-14 15:56:16 -0400 | [diff] [blame^] | 12 | #include "pic.h" // eoi_pic2 |
Kevin O'Connor | e2e5f01 | 2008-03-08 10:27:39 -0500 | [diff] [blame] | 13 | |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 14 | // Use PS2 System Control port A to set A20 enable |
| 15 | static inline u8 |
| 16 | set_a20(u8 cond) |
| 17 | { |
| 18 | // get current setting first |
| 19 | u8 newval, oldval = inb(PORT_A20); |
| 20 | if (cond) |
| 21 | newval = oldval | 0x02; |
| 22 | else |
| 23 | newval = oldval & ~0x02; |
| 24 | outb(newval, PORT_A20); |
| 25 | |
| 26 | return (newval & 0x02) != 0; |
| 27 | } |
| 28 | |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 29 | static void |
| 30 | handle_152400(struct bregs *regs) |
| 31 | { |
| 32 | set_a20(0); |
Kevin O'Connor | 6c78122 | 2008-03-09 12:19:23 -0400 | [diff] [blame] | 33 | set_code_success(regs); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | static void |
| 37 | handle_152401(struct bregs *regs) |
| 38 | { |
| 39 | set_a20(1); |
Kevin O'Connor | 6c78122 | 2008-03-09 12:19:23 -0400 | [diff] [blame] | 40 | set_code_success(regs); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | static void |
| 44 | handle_152402(struct bregs *regs) |
| 45 | { |
| 46 | regs->al = !!(inb(PORT_A20) & 0x20); |
Kevin O'Connor | 6c78122 | 2008-03-09 12:19:23 -0400 | [diff] [blame] | 47 | set_code_success(regs); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | static void |
| 51 | handle_152403(struct bregs *regs) |
| 52 | { |
| 53 | regs->bx = 3; |
Kevin O'Connor | 6c78122 | 2008-03-09 12:19:23 -0400 | [diff] [blame] | 54 | set_code_success(regs); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | static void |
| 58 | handle_1524XX(struct bregs *regs) |
| 59 | { |
Kevin O'Connor | 6c78122 | 2008-03-09 12:19:23 -0400 | [diff] [blame] | 60 | set_code_fail(regs, RET_EUNSUPPORTED); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 61 | } |
| 62 | |
Kevin O'Connor | adb6b37 | 2008-03-01 13:38:38 -0500 | [diff] [blame] | 63 | static void |
| 64 | handle_1524(struct bregs *regs) |
| 65 | { |
| 66 | switch (regs->al) { |
| 67 | case 0x00: handle_152400(regs); break; |
| 68 | case 0x01: handle_152401(regs); break; |
| 69 | case 0x02: handle_152402(regs); break; |
| 70 | case 0x03: handle_152403(regs); break; |
| 71 | default: handle_1524XX(regs); break; |
| 72 | } |
| 73 | } |
| 74 | |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 75 | // removable media eject |
| 76 | static void |
| 77 | handle_1552(struct bregs *regs) |
| 78 | { |
Kevin O'Connor | 6c78122 | 2008-03-09 12:19:23 -0400 | [diff] [blame] | 79 | set_code_success(regs); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 80 | } |
| 81 | |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 82 | static void |
| 83 | handle_1587(struct bregs *regs) |
| 84 | { |
| 85 | // +++ should probably have descriptor checks |
| 86 | // +++ should have exception handlers |
| 87 | |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 88 | u8 prev_a20_enable = set_a20(1); // enable A20 line |
| 89 | |
| 90 | // 128K max of transfer on 386+ ??? |
| 91 | // source == destination ??? |
| 92 | |
| 93 | // ES:SI points to descriptor table |
| 94 | // offset use initially comments |
| 95 | // ============================================== |
| 96 | // 00..07 Unused zeros Null descriptor |
| 97 | // 08..0f GDT zeros filled in by BIOS |
| 98 | // 10..17 source ssssssss source of data |
| 99 | // 18..1f dest dddddddd destination of data |
| 100 | // 20..27 CS zeros filled in by BIOS |
| 101 | // 28..2f SS zeros filled in by BIOS |
| 102 | |
| 103 | //es:si |
| 104 | //eeee0 |
| 105 | //0ssss |
| 106 | //----- |
| 107 | |
| 108 | // check for access rights of source & dest here |
| 109 | |
| 110 | // Initialize GDT descriptor |
Kevin O'Connor | 67c00dd | 2008-03-09 16:10:19 -0400 | [diff] [blame] | 111 | SET_SEG(ES, regs->es); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 112 | u16 si = regs->si; |
| 113 | u16 base15_00 = (regs->es << 4) + si; |
| 114 | u16 base23_16 = regs->es >> 12; |
Kevin O'Connor | 67c00dd | 2008-03-09 16:10:19 -0400 | [diff] [blame] | 115 | if (base15_00 < (u16)(regs->es<<4)) |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 116 | base23_16++; |
| 117 | SET_VAR(ES, *(u16*)(si+0x08+0), 47); // limit 15:00 = 6 * 8bytes/descriptor |
| 118 | SET_VAR(ES, *(u16*)(si+0x08+2), base15_00);// base 15:00 |
| 119 | SET_VAR(ES, *(u8 *)(si+0x08+4), base23_16);// base 23:16 |
| 120 | SET_VAR(ES, *(u8 *)(si+0x08+5), 0x93); // access |
| 121 | SET_VAR(ES, *(u16*)(si+0x08+6), 0x0000); // base 31:24/reserved/limit 19:16 |
| 122 | |
| 123 | // Initialize CS descriptor |
| 124 | SET_VAR(ES, *(u16*)(si+0x20+0), 0xffff);// limit 15:00 = normal 64K limit |
| 125 | SET_VAR(ES, *(u16*)(si+0x20+2), 0x0000);// base 15:00 |
| 126 | SET_VAR(ES, *(u8 *)(si+0x20+4), 0x000f);// base 23:16 |
| 127 | SET_VAR(ES, *(u8 *)(si+0x20+5), 0x9b); // access |
| 128 | SET_VAR(ES, *(u16*)(si+0x20+6), 0x0000);// base 31:24/reserved/limit 19:16 |
| 129 | |
| 130 | // Initialize SS descriptor |
| 131 | u16 ss = GET_SEG(SS); |
| 132 | base15_00 = ss << 4; |
| 133 | base23_16 = ss >> 12; |
| 134 | SET_VAR(ES, *(u16*)(si+0x28+0), 0xffff); // limit 15:00 = normal 64K limit |
| 135 | SET_VAR(ES, *(u16*)(si+0x28+2), base15_00);// base 15:00 |
| 136 | SET_VAR(ES, *(u8 *)(si+0x28+4), base23_16);// base 23:16 |
| 137 | SET_VAR(ES, *(u8 *)(si+0x28+5), 0x93); // access |
| 138 | SET_VAR(ES, *(u16*)(si+0x28+6), 0x0000); // base 31:24/reserved/limit 19:16 |
| 139 | |
Kevin O'Connor | 2cdd8b6 | 2008-03-09 23:37:04 -0400 | [diff] [blame] | 140 | u16 count = regs->cx; |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 141 | asm volatile( |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 142 | // Load new descriptor tables |
Kevin O'Connor | 67c00dd | 2008-03-09 16:10:19 -0400 | [diff] [blame] | 143 | "lgdtw %%es:0x8(%%si)\n" |
| 144 | "lidtw %%cs:pmode_IDT_info\n" |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 145 | |
| 146 | // set PE bit in CR0 |
| 147 | "movl %%cr0, %%eax\n" |
| 148 | "orb $0x01, %%al\n" |
| 149 | "movl %%eax, %%cr0\n" |
| 150 | |
| 151 | // far jump to flush CPU queue after transition to protected mode |
Kevin O'Connor | adb6b37 | 2008-03-01 13:38:38 -0500 | [diff] [blame] | 152 | "ljmpw $0x0020, $1f\n" |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 153 | "1:\n" |
| 154 | |
| 155 | // GDT points to valid descriptor table, now load DS, ES |
| 156 | "movw $0x10, %%ax\n" // 010 000 = 2nd descriptor in table, TI=GDT, RPL=00 |
| 157 | "movw %%ax, %%ds\n" |
| 158 | "movw $0x18, %%ax\n" // 011 000 = 3rd descriptor in table, TI=GDT, RPL=00 |
| 159 | "movw %%ax, %%es\n" |
| 160 | |
| 161 | // move CX words from DS:SI to ES:DI |
| 162 | "xorw %%si, %%si\n" |
| 163 | "xorw %%di, %%di\n" |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 164 | "rep movsw\n" |
| 165 | |
| 166 | // reset PG bit in CR0 ??? |
| 167 | "movl %%cr0, %%eax\n" |
| 168 | "andb $0xfe, %%al\n" |
| 169 | "movl %%eax, %%cr0\n" |
| 170 | |
| 171 | // far jump to flush CPU queue after transition to real mode |
| 172 | "ljmpw $0xf000, $2f\n" |
| 173 | "2:\n" |
| 174 | |
| 175 | // restore IDT to normal real-mode defaults |
| 176 | "lidt %%cs:rmode_IDT_info\n" |
| 177 | |
Kevin O'Connor | e20ed9f | 2008-03-01 14:25:44 -0500 | [diff] [blame] | 178 | // Restore %ds (from %ss) |
| 179 | "movw %%ss, %%ax\n" |
| 180 | "movw %%ax, %%ds\n" |
Kevin O'Connor | 2cdd8b6 | 2008-03-09 23:37:04 -0400 | [diff] [blame] | 181 | : "+c"(count), "+S"(si) |
Kevin O'Connor | ed12849 | 2008-03-11 11:14:59 -0400 | [diff] [blame] | 182 | : : "eax", "di", "cc"); // XXX - also clobbers %es |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 183 | |
| 184 | set_a20(prev_a20_enable); |
| 185 | |
Kevin O'Connor | 6c78122 | 2008-03-09 12:19:23 -0400 | [diff] [blame] | 186 | set_code_success(regs); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 187 | } |
| 188 | |
| 189 | // Get the amount of extended memory (above 1M) |
| 190 | static void |
| 191 | handle_1588(struct bregs *regs) |
| 192 | { |
Kevin O'Connor | 9571ac2 | 2008-05-17 22:20:27 -0400 | [diff] [blame] | 193 | u32 rs = GET_EBDA(ram_size); |
| 194 | |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 195 | // According to Ralf Brown's interrupt the limit should be 15M, |
| 196 | // but real machines mostly return max. 63M. |
Kevin O'Connor | 9571ac2 | 2008-05-17 22:20:27 -0400 | [diff] [blame] | 197 | if (rs > 64*1024*1024) |
| 198 | regs->ax = 63 * 1024; |
| 199 | else |
| 200 | regs->ax = (rs - 1*1024*1024) / 1024; |
Kevin O'Connor | 6c78122 | 2008-03-09 12:19:23 -0400 | [diff] [blame] | 201 | set_success(regs); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 202 | } |
| 203 | |
| 204 | // Device busy interrupt. Called by Int 16h when no key available |
| 205 | static void |
| 206 | handle_1590(struct bregs *regs) |
| 207 | { |
| 208 | } |
| 209 | |
| 210 | // Interrupt complete. Called by Int 16h when key becomes available |
| 211 | static void |
| 212 | handle_1591(struct bregs *regs) |
| 213 | { |
| 214 | } |
| 215 | |
Kevin O'Connor | 38fcbfe | 2008-02-25 22:30:47 -0500 | [diff] [blame] | 216 | // keyboard intercept |
| 217 | static void |
| 218 | handle_154f(struct bregs *regs) |
| 219 | { |
Kevin O'Connor | db9e65e | 2008-06-07 14:41:21 -0400 | [diff] [blame] | 220 | set_fail_silent(regs); |
Kevin O'Connor | 38fcbfe | 2008-02-25 22:30:47 -0500 | [diff] [blame] | 221 | } |
| 222 | |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 223 | static void |
| 224 | handle_15c0(struct bregs *regs) |
| 225 | { |
| 226 | regs->es = SEG_BIOS; |
Kevin O'Connor | 117fc21 | 2008-04-13 18:17:02 -0400 | [diff] [blame] | 227 | regs->bx = (u32)&BIOS_CONFIG_TABLE; |
Kevin O'Connor | 6c78122 | 2008-03-09 12:19:23 -0400 | [diff] [blame] | 228 | set_code_success(regs); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 229 | } |
| 230 | |
| 231 | static void |
| 232 | handle_15c1(struct bregs *regs) |
| 233 | { |
| 234 | regs->es = GET_BDA(ebda_seg); |
Kevin O'Connor | 6c78122 | 2008-03-09 12:19:23 -0400 | [diff] [blame] | 235 | set_success(regs); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | static void |
| 239 | handle_15e801(struct bregs *regs) |
| 240 | { |
| 241 | // my real system sets ax and bx to 0 |
| 242 | // this is confirmed by Ralph Brown list |
| 243 | // but syslinux v1.48 is known to behave |
| 244 | // strangely if ax is set to 0 |
| 245 | // regs.u.r16.ax = 0; |
| 246 | // regs.u.r16.bx = 0; |
| 247 | |
Kevin O'Connor | 9571ac2 | 2008-05-17 22:20:27 -0400 | [diff] [blame] | 248 | u32 rs = GET_EBDA(ram_size); |
| 249 | |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 250 | // Get the amount of extended memory (above 1M) |
Kevin O'Connor | 9571ac2 | 2008-05-17 22:20:27 -0400 | [diff] [blame] | 251 | if (rs > 16*1024*1024) { |
| 252 | // limit to 15M |
| 253 | regs->cx = 15*1024; |
| 254 | // Get the amount of extended memory above 16M in 64k blocks |
| 255 | regs->dx = (rs - 16*1024*1024) / (64*1024); |
| 256 | } else { |
| 257 | regs->cx = (rs - 1*1024*1024) / 1024; |
| 258 | regs->dx = 0; |
| 259 | } |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 260 | |
| 261 | // Set configured memory equal to extended memory |
| 262 | regs->ax = regs->cx; |
| 263 | regs->bx = regs->dx; |
| 264 | |
Kevin O'Connor | 6c78122 | 2008-03-09 12:19:23 -0400 | [diff] [blame] | 265 | set_success(regs); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 266 | } |
| 267 | |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 268 | static void |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 269 | handle_15e820(struct bregs *regs) |
| 270 | { |
Kevin O'Connor | c781293 | 2008-06-08 23:08:12 -0400 | [diff] [blame] | 271 | int count = GET_EBDA(e820_count); |
| 272 | if (regs->edx != 0x534D4150 || regs->bx >= count) { |
Kevin O'Connor | 6c78122 | 2008-03-09 12:19:23 -0400 | [diff] [blame] | 273 | set_code_fail(regs, RET_EUNSUPPORTED); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 274 | return; |
| 275 | } |
| 276 | |
Kevin O'Connor | c781293 | 2008-06-08 23:08:12 -0400 | [diff] [blame] | 277 | struct e820entry *e = &((struct e820entry *)GET_EBDA(e820_loc))[regs->bx]; |
| 278 | memcpy(MAKE_FARPTR(regs->es, regs->di), e, sizeof(*e)); |
| 279 | if (regs->bx == count-1) |
| 280 | regs->ebx = 0; |
| 281 | else |
| 282 | regs->ebx++; |
| 283 | regs->eax = 0x534D4150; |
| 284 | regs->ecx = sizeof(*e); |
| 285 | set_success(regs); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | static void |
| 289 | handle_15e8XX(struct bregs *regs) |
| 290 | { |
Kevin O'Connor | 6c78122 | 2008-03-09 12:19:23 -0400 | [diff] [blame] | 291 | set_code_fail(regs, RET_EUNSUPPORTED); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 292 | } |
| 293 | |
| 294 | static void |
Kevin O'Connor | adb6b37 | 2008-03-01 13:38:38 -0500 | [diff] [blame] | 295 | handle_15e8(struct bregs *regs) |
| 296 | { |
| 297 | switch (regs->al) { |
| 298 | case 0x01: handle_15e801(regs); break; |
| 299 | case 0x20: handle_15e820(regs); break; |
| 300 | default: handle_15e8XX(regs); break; |
| 301 | } |
| 302 | } |
| 303 | |
| 304 | static void |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 305 | handle_15XX(struct bregs *regs) |
| 306 | { |
Kevin O'Connor | 6c78122 | 2008-03-09 12:19:23 -0400 | [diff] [blame] | 307 | set_code_fail(regs, RET_EUNSUPPORTED); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 308 | } |
| 309 | |
| 310 | // INT 15h System Services Entry Point |
Kevin O'Connor | 1978676 | 2008-03-05 21:09:59 -0500 | [diff] [blame] | 311 | void VISIBLE16 |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 312 | handle_15(struct bregs *regs) |
| 313 | { |
Kevin O'Connor | 15c1f22 | 2008-06-12 22:59:43 -0400 | [diff] [blame] | 314 | debug_enter(regs, DEBUG_HDL_15); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 315 | switch (regs->ah) { |
Kevin O'Connor | adb6b37 | 2008-03-01 13:38:38 -0500 | [diff] [blame] | 316 | case 0x24: handle_1524(regs); break; |
Kevin O'Connor | 38fcbfe | 2008-02-25 22:30:47 -0500 | [diff] [blame] | 317 | case 0x4f: handle_154f(regs); break; |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 318 | case 0x52: handle_1552(regs); break; |
Kevin O'Connor | bdce35f | 2008-02-26 21:33:14 -0500 | [diff] [blame] | 319 | case 0x53: handle_1553(regs); break; |
| 320 | case 0x83: handle_1583(regs); break; |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 321 | case 0x86: handle_1586(regs); break; |
| 322 | case 0x87: handle_1587(regs); break; |
| 323 | case 0x88: handle_1588(regs); break; |
| 324 | case 0x90: handle_1590(regs); break; |
| 325 | case 0x91: handle_1591(regs); break; |
| 326 | case 0xc0: handle_15c0(regs); break; |
| 327 | case 0xc1: handle_15c1(regs); break; |
| 328 | case 0xc2: handle_15c2(regs); break; |
Kevin O'Connor | adb6b37 | 2008-03-01 13:38:38 -0500 | [diff] [blame] | 329 | case 0xe8: handle_15e8(regs); break; |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 330 | default: handle_15XX(regs); break; |
| 331 | } |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 332 | } |
| 333 | |
| 334 | // INT 12h Memory Size Service Entry Point |
Kevin O'Connor | 1978676 | 2008-03-05 21:09:59 -0500 | [diff] [blame] | 335 | void VISIBLE16 |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 336 | handle_12(struct bregs *regs) |
| 337 | { |
Kevin O'Connor | 15c1f22 | 2008-06-12 22:59:43 -0400 | [diff] [blame] | 338 | debug_enter(regs, DEBUG_HDL_12); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 339 | regs->ax = GET_BDA(mem_size_kb); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 340 | } |
| 341 | |
| 342 | // INT 11h Equipment List Service Entry Point |
Kevin O'Connor | 1978676 | 2008-03-05 21:09:59 -0500 | [diff] [blame] | 343 | void VISIBLE16 |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 344 | handle_11(struct bregs *regs) |
| 345 | { |
Kevin O'Connor | 15c1f22 | 2008-06-12 22:59:43 -0400 | [diff] [blame] | 346 | debug_enter(regs, DEBUG_HDL_11); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 347 | regs->ax = GET_BDA(equipment_list_flags); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 348 | } |
| 349 | |
| 350 | // INT 05h Print Screen Service Entry Point |
Kevin O'Connor | 1978676 | 2008-03-05 21:09:59 -0500 | [diff] [blame] | 351 | void VISIBLE16 |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 352 | handle_05(struct bregs *regs) |
| 353 | { |
Kevin O'Connor | 15c1f22 | 2008-06-12 22:59:43 -0400 | [diff] [blame] | 354 | debug_enter(regs, DEBUG_HDL_05); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 355 | } |
| 356 | |
| 357 | // INT 10h Video Support Service Entry Point |
Kevin O'Connor | 1978676 | 2008-03-05 21:09:59 -0500 | [diff] [blame] | 358 | void VISIBLE16 |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 359 | handle_10(struct bregs *regs) |
| 360 | { |
Kevin O'Connor | 15c1f22 | 2008-06-12 22:59:43 -0400 | [diff] [blame] | 361 | debug_enter(regs, DEBUG_HDL_10); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 362 | // dont do anything, since the VGA BIOS handles int10h requests |
| 363 | } |
| 364 | |
Kevin O'Connor | 1978676 | 2008-03-05 21:09:59 -0500 | [diff] [blame] | 365 | void VISIBLE16 |
Kevin O'Connor | ed12849 | 2008-03-11 11:14:59 -0400 | [diff] [blame] | 366 | handle_nmi() |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 367 | { |
Kevin O'Connor | 15c1f22 | 2008-06-12 22:59:43 -0400 | [diff] [blame] | 368 | debug_isr(DEBUG_ISR_nmi); |
Kevin O'Connor | ed12849 | 2008-03-11 11:14:59 -0400 | [diff] [blame] | 369 | BX_PANIC("NMI Handler called\n"); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 370 | } |
| 371 | |
Kevin O'Connor | f54c150 | 2008-06-14 15:56:16 -0400 | [diff] [blame^] | 372 | void |
| 373 | mathcp_setup() |
| 374 | { |
| 375 | dprintf(3, "math cp init\n"); |
| 376 | // 80x87 coprocessor installed |
| 377 | SETBITS_BDA(equipment_list_flags, 0x02); |
| 378 | // Enable IRQ13 (handle_75) |
| 379 | unmask_pic2(PIC2_IRQ13); |
| 380 | } |
| 381 | |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 382 | // INT 75 - IRQ13 - MATH COPROCESSOR EXCEPTION |
Kevin O'Connor | 1978676 | 2008-03-05 21:09:59 -0500 | [diff] [blame] | 383 | void VISIBLE16 |
Kevin O'Connor | ed12849 | 2008-03-11 11:14:59 -0400 | [diff] [blame] | 384 | handle_75() |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 385 | { |
Kevin O'Connor | 15c1f22 | 2008-06-12 22:59:43 -0400 | [diff] [blame] | 386 | debug_isr(DEBUG_ISR_75); |
Kevin O'Connor | 38fcbfe | 2008-02-25 22:30:47 -0500 | [diff] [blame] | 387 | |
| 388 | // clear irq13 |
| 389 | outb(0, PORT_MATH_CLEAR); |
| 390 | // clear interrupt |
Kevin O'Connor | f54c150 | 2008-06-14 15:56:16 -0400 | [diff] [blame^] | 391 | eoi_pic2(); |
Kevin O'Connor | 38fcbfe | 2008-02-25 22:30:47 -0500 | [diff] [blame] | 392 | // legacy nmi call |
| 393 | struct bregs br; |
| 394 | memset(&br, 0, sizeof(br)); |
| 395 | call16_int(0x02, &br); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 396 | } |