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 |
| 9 | #include "biosvar.h" // CONFIG_BIOS_TABLE |
| 10 | #include "ioport.h" // inb |
| 11 | #include "cmos.h" // inb_cmos |
| 12 | |
Kevin O'Connor | e2e5f01 | 2008-03-08 10:27:39 -0500 | [diff] [blame] | 13 | #define E820_RAM 1 |
| 14 | #define E820_RESERVED 2 |
| 15 | #define E820_ACPI 3 |
| 16 | #define E820_NVS 4 |
| 17 | #define E820_UNUSABLE 5 |
| 18 | |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 19 | // Use PS2 System Control port A to set A20 enable |
| 20 | static inline u8 |
| 21 | set_a20(u8 cond) |
| 22 | { |
| 23 | // get current setting first |
| 24 | u8 newval, oldval = inb(PORT_A20); |
| 25 | if (cond) |
| 26 | newval = oldval | 0x02; |
| 27 | else |
| 28 | newval = oldval & ~0x02; |
| 29 | outb(newval, PORT_A20); |
| 30 | |
| 31 | return (newval & 0x02) != 0; |
| 32 | } |
| 33 | |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 34 | static void |
| 35 | handle_152400(struct bregs *regs) |
| 36 | { |
| 37 | set_a20(0); |
| 38 | handle_ret(regs, 0); |
| 39 | } |
| 40 | |
| 41 | static void |
| 42 | handle_152401(struct bregs *regs) |
| 43 | { |
| 44 | set_a20(1); |
| 45 | handle_ret(regs, 0); |
| 46 | } |
| 47 | |
| 48 | static void |
| 49 | handle_152402(struct bregs *regs) |
| 50 | { |
| 51 | regs->al = !!(inb(PORT_A20) & 0x20); |
| 52 | handle_ret(regs, 0); |
| 53 | } |
| 54 | |
| 55 | static void |
| 56 | handle_152403(struct bregs *regs) |
| 57 | { |
| 58 | regs->bx = 3; |
| 59 | handle_ret(regs, 0); |
| 60 | } |
| 61 | |
| 62 | static void |
| 63 | handle_1524XX(struct bregs *regs) |
| 64 | { |
| 65 | handle_ret(regs, RET_EUNSUPPORTED); |
| 66 | } |
| 67 | |
Kevin O'Connor | adb6b37 | 2008-03-01 13:38:38 -0500 | [diff] [blame] | 68 | static void |
| 69 | handle_1524(struct bregs *regs) |
| 70 | { |
| 71 | switch (regs->al) { |
| 72 | case 0x00: handle_152400(regs); break; |
| 73 | case 0x01: handle_152401(regs); break; |
| 74 | case 0x02: handle_152402(regs); break; |
| 75 | case 0x03: handle_152403(regs); break; |
| 76 | default: handle_1524XX(regs); break; |
| 77 | } |
| 78 | } |
| 79 | |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 80 | // removable media eject |
| 81 | static void |
| 82 | handle_1552(struct bregs *regs) |
| 83 | { |
| 84 | handle_ret(regs, 0); |
| 85 | } |
| 86 | |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 87 | // Sleep for n microseconds. currently using the |
| 88 | // refresh request port 0x61 bit4, toggling every 15usec |
| 89 | static void |
| 90 | usleep(u32 count) |
| 91 | { |
| 92 | count = count / 15; |
Kevin O'Connor | ee2fd7a | 2008-03-02 08:42:16 -0500 | [diff] [blame] | 93 | u8 kbd = inb(PORT_PS2_CTRLB); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 94 | while (count) |
Kevin O'Connor | ee2fd7a | 2008-03-02 08:42:16 -0500 | [diff] [blame] | 95 | if ((inb(PORT_PS2_CTRLB) ^ kbd) & KBD_REFRESH) |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 96 | count--; |
| 97 | } |
| 98 | |
| 99 | // Wait for CX:DX microseconds. currently using the |
| 100 | // refresh request port 0x61 bit4, toggling every 15usec |
| 101 | static void |
| 102 | handle_1586(struct bregs *regs) |
| 103 | { |
| 104 | irq_enable(); |
| 105 | usleep((regs->cx << 16) | regs->dx); |
| 106 | irq_disable(); |
| 107 | } |
| 108 | |
| 109 | static void |
| 110 | handle_1587(struct bregs *regs) |
| 111 | { |
| 112 | // +++ should probably have descriptor checks |
| 113 | // +++ should have exception handlers |
| 114 | |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 115 | u8 prev_a20_enable = set_a20(1); // enable A20 line |
| 116 | |
| 117 | // 128K max of transfer on 386+ ??? |
| 118 | // source == destination ??? |
| 119 | |
| 120 | // ES:SI points to descriptor table |
| 121 | // offset use initially comments |
| 122 | // ============================================== |
| 123 | // 00..07 Unused zeros Null descriptor |
| 124 | // 08..0f GDT zeros filled in by BIOS |
| 125 | // 10..17 source ssssssss source of data |
| 126 | // 18..1f dest dddddddd destination of data |
| 127 | // 20..27 CS zeros filled in by BIOS |
| 128 | // 28..2f SS zeros filled in by BIOS |
| 129 | |
| 130 | //es:si |
| 131 | //eeee0 |
| 132 | //0ssss |
| 133 | //----- |
| 134 | |
| 135 | // check for access rights of source & dest here |
| 136 | |
| 137 | // Initialize GDT descriptor |
| 138 | u16 si = regs->si; |
| 139 | u16 base15_00 = (regs->es << 4) + si; |
| 140 | u16 base23_16 = regs->es >> 12; |
| 141 | if (base15_00 < (regs->es<<4)) |
| 142 | base23_16++; |
| 143 | SET_VAR(ES, *(u16*)(si+0x08+0), 47); // limit 15:00 = 6 * 8bytes/descriptor |
| 144 | SET_VAR(ES, *(u16*)(si+0x08+2), base15_00);// base 15:00 |
| 145 | SET_VAR(ES, *(u8 *)(si+0x08+4), base23_16);// base 23:16 |
| 146 | SET_VAR(ES, *(u8 *)(si+0x08+5), 0x93); // access |
| 147 | SET_VAR(ES, *(u16*)(si+0x08+6), 0x0000); // base 31:24/reserved/limit 19:16 |
| 148 | |
| 149 | // Initialize CS descriptor |
| 150 | SET_VAR(ES, *(u16*)(si+0x20+0), 0xffff);// limit 15:00 = normal 64K limit |
| 151 | SET_VAR(ES, *(u16*)(si+0x20+2), 0x0000);// base 15:00 |
| 152 | SET_VAR(ES, *(u8 *)(si+0x20+4), 0x000f);// base 23:16 |
| 153 | SET_VAR(ES, *(u8 *)(si+0x20+5), 0x9b); // access |
| 154 | SET_VAR(ES, *(u16*)(si+0x20+6), 0x0000);// base 31:24/reserved/limit 19:16 |
| 155 | |
| 156 | // Initialize SS descriptor |
| 157 | u16 ss = GET_SEG(SS); |
| 158 | base15_00 = ss << 4; |
| 159 | base23_16 = ss >> 12; |
| 160 | SET_VAR(ES, *(u16*)(si+0x28+0), 0xffff); // limit 15:00 = normal 64K limit |
| 161 | SET_VAR(ES, *(u16*)(si+0x28+2), base15_00);// base 15:00 |
| 162 | SET_VAR(ES, *(u8 *)(si+0x28+4), base23_16);// base 23:16 |
| 163 | SET_VAR(ES, *(u8 *)(si+0x28+5), 0x93); // access |
| 164 | SET_VAR(ES, *(u16*)(si+0x28+6), 0x0000); // base 31:24/reserved/limit 19:16 |
| 165 | |
| 166 | asm volatile( |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 167 | // Load new descriptor tables |
| 168 | "lgdt %%es:(%1)\n" |
| 169 | "lidt %%cs:pmode_IDT_info\n" |
| 170 | |
| 171 | // set PE bit in CR0 |
| 172 | "movl %%cr0, %%eax\n" |
| 173 | "orb $0x01, %%al\n" |
| 174 | "movl %%eax, %%cr0\n" |
| 175 | |
| 176 | // far jump to flush CPU queue after transition to protected mode |
Kevin O'Connor | adb6b37 | 2008-03-01 13:38:38 -0500 | [diff] [blame] | 177 | "ljmpw $0x0020, $1f\n" |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 178 | "1:\n" |
| 179 | |
| 180 | // GDT points to valid descriptor table, now load DS, ES |
| 181 | "movw $0x10, %%ax\n" // 010 000 = 2nd descriptor in table, TI=GDT, RPL=00 |
| 182 | "movw %%ax, %%ds\n" |
| 183 | "movw $0x18, %%ax\n" // 011 000 = 3rd descriptor in table, TI=GDT, RPL=00 |
| 184 | "movw %%ax, %%es\n" |
| 185 | |
| 186 | // move CX words from DS:SI to ES:DI |
| 187 | "xorw %%si, %%si\n" |
| 188 | "xorw %%di, %%di\n" |
| 189 | "cld\n" |
| 190 | "rep movsw\n" |
| 191 | |
| 192 | // reset PG bit in CR0 ??? |
| 193 | "movl %%cr0, %%eax\n" |
| 194 | "andb $0xfe, %%al\n" |
| 195 | "movl %%eax, %%cr0\n" |
| 196 | |
| 197 | // far jump to flush CPU queue after transition to real mode |
| 198 | "ljmpw $0xf000, $2f\n" |
| 199 | "2:\n" |
| 200 | |
| 201 | // restore IDT to normal real-mode defaults |
| 202 | "lidt %%cs:rmode_IDT_info\n" |
| 203 | |
Kevin O'Connor | e20ed9f | 2008-03-01 14:25:44 -0500 | [diff] [blame] | 204 | // Restore %ds (from %ss) |
| 205 | "movw %%ss, %%ax\n" |
| 206 | "movw %%ax, %%ds\n" |
| 207 | : : "c" (regs->cx), "r" (si + 8) |
| 208 | : "eax", "di", "si"); // XXX - also clobbers %es |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 209 | |
| 210 | set_a20(prev_a20_enable); |
| 211 | |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 212 | handle_ret(regs, 0); |
| 213 | } |
| 214 | |
| 215 | // Get the amount of extended memory (above 1M) |
| 216 | static void |
| 217 | handle_1588(struct bregs *regs) |
| 218 | { |
Kevin O'Connor | e09b982 | 2008-03-06 19:16:37 -0500 | [diff] [blame] | 219 | regs->al = inb_cmos(CMOS_MEM_EXTMEM_LOW); |
| 220 | regs->ah = inb_cmos(CMOS_MEM_EXTMEM_HIGH); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 221 | // According to Ralf Brown's interrupt the limit should be 15M, |
| 222 | // but real machines mostly return max. 63M. |
| 223 | if (regs->ax > 0xffc0) |
| 224 | regs->ax = 0xffc0; |
| 225 | set_cf(regs, 0); |
| 226 | } |
| 227 | |
| 228 | // Device busy interrupt. Called by Int 16h when no key available |
| 229 | static void |
| 230 | handle_1590(struct bregs *regs) |
| 231 | { |
| 232 | } |
| 233 | |
| 234 | // Interrupt complete. Called by Int 16h when key becomes available |
| 235 | static void |
| 236 | handle_1591(struct bregs *regs) |
| 237 | { |
| 238 | } |
| 239 | |
Kevin O'Connor | 38fcbfe | 2008-02-25 22:30:47 -0500 | [diff] [blame] | 240 | // keyboard intercept |
| 241 | static void |
| 242 | handle_154f(struct bregs *regs) |
| 243 | { |
| 244 | set_cf(regs, 1); |
| 245 | } |
| 246 | |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 247 | static void |
| 248 | handle_15c0(struct bregs *regs) |
| 249 | { |
| 250 | regs->es = SEG_BIOS; |
| 251 | regs->bx = (u16)&BIOS_CONFIG_TABLE; |
Kevin O'Connor | 44c631d | 2008-03-02 11:24:36 -0500 | [diff] [blame] | 252 | handle_ret(regs, 0); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 253 | } |
| 254 | |
| 255 | static void |
| 256 | handle_15c1(struct bregs *regs) |
| 257 | { |
| 258 | regs->es = GET_BDA(ebda_seg); |
| 259 | set_cf(regs, 0); |
| 260 | } |
| 261 | |
| 262 | static void |
| 263 | handle_15e801(struct bregs *regs) |
| 264 | { |
| 265 | // my real system sets ax and bx to 0 |
| 266 | // this is confirmed by Ralph Brown list |
| 267 | // but syslinux v1.48 is known to behave |
| 268 | // strangely if ax is set to 0 |
| 269 | // regs.u.r16.ax = 0; |
| 270 | // regs.u.r16.bx = 0; |
| 271 | |
| 272 | // Get the amount of extended memory (above 1M) |
Kevin O'Connor | e09b982 | 2008-03-06 19:16:37 -0500 | [diff] [blame] | 273 | regs->cl = inb_cmos(CMOS_MEM_EXTMEM_LOW); |
| 274 | regs->ch = inb_cmos(CMOS_MEM_EXTMEM_HIGH); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 275 | |
| 276 | // limit to 15M |
| 277 | if (regs->cx > 0x3c00) |
| 278 | regs->cx = 0x3c00; |
| 279 | |
| 280 | // Get the amount of extended memory above 16M in 64k blocs |
Kevin O'Connor | e09b982 | 2008-03-06 19:16:37 -0500 | [diff] [blame] | 281 | regs->dl = inb_cmos(CMOS_MEM_EXTMEM2_LOW); |
| 282 | regs->dh = inb_cmos(CMOS_MEM_EXTMEM2_HIGH); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 283 | |
| 284 | // Set configured memory equal to extended memory |
| 285 | regs->ax = regs->cx; |
| 286 | regs->bx = regs->dx; |
| 287 | |
| 288 | set_cf(regs, 0); |
| 289 | } |
| 290 | |
Kevin O'Connor | 47baa3c | 2008-03-08 13:17:16 -0500 | [diff] [blame] | 291 | #define ACPI_DATA_SIZE 0x00010000L |
| 292 | |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 293 | static void |
| 294 | set_e820_range(u16 DI, u32 start, u32 end, u16 type) |
| 295 | { |
| 296 | SET_VAR(ES, *(u16*)(DI+0), start); |
| 297 | SET_VAR(ES, *(u16*)(DI+2), start >> 16); |
| 298 | SET_VAR(ES, *(u16*)(DI+4), 0x00); |
| 299 | SET_VAR(ES, *(u16*)(DI+6), 0x00); |
| 300 | |
| 301 | end -= start; |
| 302 | SET_VAR(ES, *(u16*)(DI+8), end); |
| 303 | SET_VAR(ES, *(u16*)(DI+10), end >> 16); |
| 304 | SET_VAR(ES, *(u16*)(DI+12), 0x0000); |
| 305 | SET_VAR(ES, *(u16*)(DI+14), 0x0000); |
| 306 | |
| 307 | SET_VAR(ES, *(u16*)(DI+16), type); |
| 308 | SET_VAR(ES, *(u16*)(DI+18), 0x0); |
| 309 | } |
| 310 | |
| 311 | // XXX - should create e820 memory map in post and just copy it here. |
| 312 | static void |
| 313 | handle_15e820(struct bregs *regs) |
| 314 | { |
| 315 | if (regs->edx != 0x534D4150) { |
| 316 | handle_ret(regs, RET_EUNSUPPORTED); |
| 317 | return; |
| 318 | } |
| 319 | |
Kevin O'Connor | e09b982 | 2008-03-06 19:16:37 -0500 | [diff] [blame] | 320 | u32 extended_memory_size = inb_cmos(CMOS_MEM_EXTMEM2_HIGH); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 321 | extended_memory_size <<= 8; |
Kevin O'Connor | e09b982 | 2008-03-06 19:16:37 -0500 | [diff] [blame] | 322 | extended_memory_size |= inb_cmos(CMOS_MEM_EXTMEM2_LOW); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 323 | extended_memory_size *= 64; |
| 324 | // greater than EFF00000??? |
| 325 | if (extended_memory_size > 0x3bc000) |
| 326 | // everything after this is reserved memory until we get to 0x100000000 |
| 327 | extended_memory_size = 0x3bc000; |
| 328 | extended_memory_size *= 1024; |
| 329 | extended_memory_size += (16L * 1024 * 1024); |
| 330 | |
| 331 | if (extended_memory_size <= (16L * 1024 * 1024)) { |
Kevin O'Connor | e09b982 | 2008-03-06 19:16:37 -0500 | [diff] [blame] | 332 | extended_memory_size = inb_cmos(CMOS_MEM_EXTMEM_HIGH); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 333 | extended_memory_size <<= 8; |
Kevin O'Connor | e09b982 | 2008-03-06 19:16:37 -0500 | [diff] [blame] | 334 | extended_memory_size |= inb_cmos(CMOS_MEM_EXTMEM_LOW); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 335 | extended_memory_size *= 1024; |
| 336 | } |
| 337 | |
| 338 | switch (regs->bx) { |
| 339 | case 0: |
Kevin O'Connor | e2e5f01 | 2008-03-08 10:27:39 -0500 | [diff] [blame] | 340 | set_e820_range(regs->di, 0x0000000L, 0x0009fc00L, E820_RAM); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 341 | regs->ebx = 1; |
| 342 | regs->eax = 0x534D4150; |
| 343 | regs->ecx = 0x14; |
| 344 | set_cf(regs, 0); |
| 345 | break; |
| 346 | case 1: |
Kevin O'Connor | e2e5f01 | 2008-03-08 10:27:39 -0500 | [diff] [blame] | 347 | set_e820_range(regs->di, 0x0009fc00L, 0x000a0000L, E820_RESERVED); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 348 | regs->ebx = 2; |
| 349 | regs->eax = 0x534D4150; |
| 350 | regs->ecx = 0x14; |
| 351 | set_cf(regs, 0); |
| 352 | break; |
| 353 | case 2: |
Kevin O'Connor | e2e5f01 | 2008-03-08 10:27:39 -0500 | [diff] [blame] | 354 | set_e820_range(regs->di, 0x000e8000L, 0x00100000L, E820_RESERVED); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 355 | regs->ebx = 3; |
| 356 | regs->eax = 0x534D4150; |
| 357 | regs->ecx = 0x14; |
| 358 | set_cf(regs, 0); |
| 359 | break; |
| 360 | case 3: |
| 361 | set_e820_range(regs->di, 0x00100000L, |
Kevin O'Connor | e2e5f01 | 2008-03-08 10:27:39 -0500 | [diff] [blame] | 362 | extended_memory_size - ACPI_DATA_SIZE, E820_RAM); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 363 | regs->ebx = 4; |
| 364 | regs->eax = 0x534D4150; |
| 365 | regs->ecx = 0x14; |
| 366 | set_cf(regs, 0); |
| 367 | break; |
| 368 | case 4: |
| 369 | set_e820_range(regs->di, |
| 370 | extended_memory_size - ACPI_DATA_SIZE, |
Kevin O'Connor | e2e5f01 | 2008-03-08 10:27:39 -0500 | [diff] [blame] | 371 | extended_memory_size, E820_ACPI); // ACPI RAM |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 372 | regs->ebx = 5; |
| 373 | regs->eax = 0x534D4150; |
| 374 | regs->ecx = 0x14; |
| 375 | set_cf(regs, 0); |
| 376 | break; |
| 377 | case 5: |
| 378 | /* 256KB BIOS area at the end of 4 GB */ |
Kevin O'Connor | e2e5f01 | 2008-03-08 10:27:39 -0500 | [diff] [blame] | 379 | set_e820_range(regs->di, 0xfffc0000L, 0x00000000L, E820_RESERVED); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 380 | regs->ebx = 0; |
| 381 | regs->eax = 0x534D4150; |
| 382 | regs->ecx = 0x14; |
| 383 | set_cf(regs, 0); |
| 384 | break; |
| 385 | default: /* AX=E820, DX=534D4150, BX unrecognized */ |
| 386 | handle_ret(regs, RET_EUNSUPPORTED); |
| 387 | } |
| 388 | } |
| 389 | |
| 390 | static void |
| 391 | handle_15e8XX(struct bregs *regs) |
| 392 | { |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 393 | handle_ret(regs, RET_EUNSUPPORTED); |
| 394 | } |
| 395 | |
| 396 | static void |
Kevin O'Connor | adb6b37 | 2008-03-01 13:38:38 -0500 | [diff] [blame] | 397 | handle_15e8(struct bregs *regs) |
| 398 | { |
| 399 | switch (regs->al) { |
| 400 | case 0x01: handle_15e801(regs); break; |
| 401 | case 0x20: handle_15e820(regs); break; |
| 402 | default: handle_15e8XX(regs); break; |
| 403 | } |
| 404 | } |
| 405 | |
| 406 | static void |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 407 | handle_15XX(struct bregs *regs) |
| 408 | { |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 409 | handle_ret(regs, RET_EUNSUPPORTED); |
| 410 | } |
| 411 | |
| 412 | // INT 15h System Services Entry Point |
Kevin O'Connor | 1978676 | 2008-03-05 21:09:59 -0500 | [diff] [blame] | 413 | void VISIBLE16 |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 414 | handle_15(struct bregs *regs) |
| 415 | { |
Kevin O'Connor | adb6b37 | 2008-03-01 13:38:38 -0500 | [diff] [blame] | 416 | //debug_enter(regs); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 417 | switch (regs->ah) { |
Kevin O'Connor | adb6b37 | 2008-03-01 13:38:38 -0500 | [diff] [blame] | 418 | case 0x24: handle_1524(regs); break; |
Kevin O'Connor | 38fcbfe | 2008-02-25 22:30:47 -0500 | [diff] [blame] | 419 | case 0x4f: handle_154f(regs); break; |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 420 | case 0x52: handle_1552(regs); break; |
Kevin O'Connor | bdce35f | 2008-02-26 21:33:14 -0500 | [diff] [blame] | 421 | case 0x53: handle_1553(regs); break; |
| 422 | case 0x83: handle_1583(regs); break; |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 423 | case 0x86: handle_1586(regs); break; |
| 424 | case 0x87: handle_1587(regs); break; |
| 425 | case 0x88: handle_1588(regs); break; |
| 426 | case 0x90: handle_1590(regs); break; |
| 427 | case 0x91: handle_1591(regs); break; |
| 428 | case 0xc0: handle_15c0(regs); break; |
| 429 | case 0xc1: handle_15c1(regs); break; |
| 430 | case 0xc2: handle_15c2(regs); break; |
Kevin O'Connor | adb6b37 | 2008-03-01 13:38:38 -0500 | [diff] [blame] | 431 | case 0xe8: handle_15e8(regs); break; |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 432 | default: handle_15XX(regs); break; |
| 433 | } |
| 434 | debug_exit(regs); |
| 435 | } |
| 436 | |
| 437 | // INT 12h Memory Size Service Entry Point |
Kevin O'Connor | 1978676 | 2008-03-05 21:09:59 -0500 | [diff] [blame] | 438 | void VISIBLE16 |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 439 | handle_12(struct bregs *regs) |
| 440 | { |
| 441 | debug_enter(regs); |
| 442 | regs->ax = GET_BDA(mem_size_kb); |
| 443 | debug_exit(regs); |
| 444 | } |
| 445 | |
| 446 | // INT 11h Equipment List Service Entry Point |
Kevin O'Connor | 1978676 | 2008-03-05 21:09:59 -0500 | [diff] [blame] | 447 | void VISIBLE16 |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 448 | handle_11(struct bregs *regs) |
| 449 | { |
| 450 | debug_enter(regs); |
| 451 | regs->ax = GET_BDA(equipment_list_flags); |
| 452 | debug_exit(regs); |
| 453 | } |
| 454 | |
| 455 | // INT 05h Print Screen Service Entry Point |
Kevin O'Connor | 1978676 | 2008-03-05 21:09:59 -0500 | [diff] [blame] | 456 | void VISIBLE16 |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 457 | handle_05(struct bregs *regs) |
| 458 | { |
| 459 | debug_enter(regs); |
| 460 | } |
| 461 | |
| 462 | // INT 10h Video Support Service Entry Point |
Kevin O'Connor | 1978676 | 2008-03-05 21:09:59 -0500 | [diff] [blame] | 463 | void VISIBLE16 |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 464 | handle_10(struct bregs *regs) |
| 465 | { |
| 466 | debug_enter(regs); |
| 467 | // dont do anything, since the VGA BIOS handles int10h requests |
| 468 | } |
| 469 | |
Kevin O'Connor | 1978676 | 2008-03-05 21:09:59 -0500 | [diff] [blame] | 470 | void VISIBLE16 |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 471 | handle_nmi(struct bregs *regs) |
| 472 | { |
Kevin O'Connor | c65a380 | 2008-03-02 13:58:23 -0500 | [diff] [blame] | 473 | debug_isr(regs); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 474 | // XXX |
| 475 | } |
| 476 | |
| 477 | // INT 75 - IRQ13 - MATH COPROCESSOR EXCEPTION |
Kevin O'Connor | 1978676 | 2008-03-05 21:09:59 -0500 | [diff] [blame] | 478 | void VISIBLE16 |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 479 | handle_75(struct bregs *regs) |
| 480 | { |
Kevin O'Connor | c65a380 | 2008-03-02 13:58:23 -0500 | [diff] [blame] | 481 | debug_isr(regs); |
Kevin O'Connor | 38fcbfe | 2008-02-25 22:30:47 -0500 | [diff] [blame] | 482 | |
| 483 | // clear irq13 |
| 484 | outb(0, PORT_MATH_CLEAR); |
| 485 | // clear interrupt |
| 486 | eoi_both_pics(); |
| 487 | // legacy nmi call |
| 488 | struct bregs br; |
| 489 | memset(&br, 0, sizeof(br)); |
| 490 | call16_int(0x02, &br); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 491 | } |