Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 1 | /* |
| 2 | * DOS interrupt 34->3e handlers. All FPU interrupt code should be |
| 3 | * moved into this file. |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 4 | * |
| 5 | * Copyright 2002 Robert 'Admiral' Coeyman |
| 6 | * |
| 7 | * This library is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU Lesser General Public |
| 9 | * License as published by the Free Software Foundation; either |
| 10 | * version 2.1 of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * This library is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * Lesser General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU Lesser General Public |
| 18 | * License along with this library; if not, write to the Free Software |
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 20 | */ |
| 21 | |
| 22 | #include <stdlib.h> |
Alexandre Julliard | e983652 | 2003-11-15 00:13:20 +0000 | [diff] [blame] | 23 | #include "dosexe.h" |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 24 | #include "wine/debug.h" |
| 25 | |
| 26 | WINE_DEFAULT_DEBUG_CHANNEL(int); |
| 27 | |
| 28 | /* |
| 29 | * The actual work is done by a single routine. |
| 30 | */ |
| 31 | |
| 32 | static void FPU_ModifyCode(CONTEXT86 *context, BYTE Opcode); |
| 33 | |
| 34 | |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 35 | /********************************************************************** |
Jukka Heinonen | 416c2ae | 2002-11-12 23:29:48 +0000 | [diff] [blame] | 36 | * DOSVM_Int34Handler (WINEDOS16.152) |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 37 | * |
| 38 | * Handler for int 34 (FLOATING POINT EMULATION - Opcode 0xd8). |
| 39 | * |
| 40 | * The interrupt list isn't specific about what this interrupt |
| 41 | * actually does. [ interrup.m ] |
| 42 | */ |
Jukka Heinonen | 416c2ae | 2002-11-12 23:29:48 +0000 | [diff] [blame] | 43 | void WINAPI DOSVM_Int34Handler(CONTEXT86 *context) |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 44 | { |
Alexandre Julliard | ef94e40 | 2003-08-18 20:04:27 +0000 | [diff] [blame] | 45 | TRACE("Int 0x34 called-- FP opcode 0xd8\n"); |
Jukka Heinonen | 416c2ae | 2002-11-12 23:29:48 +0000 | [diff] [blame] | 46 | FPU_ModifyCode(context, 0xd8); |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 47 | } |
| 48 | |
Jukka Heinonen | 416c2ae | 2002-11-12 23:29:48 +0000 | [diff] [blame] | 49 | |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 50 | /********************************************************************** |
Jukka Heinonen | 416c2ae | 2002-11-12 23:29:48 +0000 | [diff] [blame] | 51 | * DOSVM_Int35Handler (WINEDOS16.153) |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 52 | * |
| 53 | * Handler for int 35 (FLOATING POINT EMULATION - Opcode 0xd9). |
| 54 | * |
| 55 | * The interrupt list isn't specific about what this interrupt |
| 56 | * actually does. [ interrup.m ] |
| 57 | */ |
Jukka Heinonen | 416c2ae | 2002-11-12 23:29:48 +0000 | [diff] [blame] | 58 | void WINAPI DOSVM_Int35Handler(CONTEXT86 *context) |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 59 | { |
Alexandre Julliard | ef94e40 | 2003-08-18 20:04:27 +0000 | [diff] [blame] | 60 | TRACE("Int 0x35 called-- FP opcode 0xd9\n"); |
Jukka Heinonen | 416c2ae | 2002-11-12 23:29:48 +0000 | [diff] [blame] | 61 | FPU_ModifyCode(context, 0xd9); |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | |
| 65 | /********************************************************************** |
Jukka Heinonen | 416c2ae | 2002-11-12 23:29:48 +0000 | [diff] [blame] | 66 | * DOSVM_Int36Handler (WINEDOS16.154) |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 67 | * |
| 68 | * Handler for int 36 (FLOATING POINT EMULATION - Opcode 0xda). |
| 69 | * |
| 70 | * The interrupt list isn't specific about what this interrupt |
| 71 | * actually does. [ interrup.m ] |
| 72 | */ |
Jukka Heinonen | 416c2ae | 2002-11-12 23:29:48 +0000 | [diff] [blame] | 73 | void WINAPI DOSVM_Int36Handler(CONTEXT86 *context) |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 74 | { |
Alexandre Julliard | ef94e40 | 2003-08-18 20:04:27 +0000 | [diff] [blame] | 75 | TRACE("Int 0x36 called-- FP opcode 0xda\n"); |
Jukka Heinonen | 416c2ae | 2002-11-12 23:29:48 +0000 | [diff] [blame] | 76 | FPU_ModifyCode(context, 0xda); |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 77 | } |
| 78 | |
Jukka Heinonen | 416c2ae | 2002-11-12 23:29:48 +0000 | [diff] [blame] | 79 | |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 80 | /********************************************************************** |
Jukka Heinonen | 416c2ae | 2002-11-12 23:29:48 +0000 | [diff] [blame] | 81 | * DOSVM_Int37Handler (WINEDOS16.155) |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 82 | * |
| 83 | * Handler for int 37 (FLOATING POINT EMULATION - Opcode 0xdb). |
| 84 | * |
| 85 | * The interrupt list isn't specific about what this interrupt |
| 86 | * actually does. [ interrup.m ] |
| 87 | */ |
Jukka Heinonen | 416c2ae | 2002-11-12 23:29:48 +0000 | [diff] [blame] | 88 | void WINAPI DOSVM_Int37Handler(CONTEXT86 *context) |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 89 | { |
Alexandre Julliard | ef94e40 | 2003-08-18 20:04:27 +0000 | [diff] [blame] | 90 | TRACE("Int 0x37 called-- FP opcode 0xdb\n"); |
Jukka Heinonen | 416c2ae | 2002-11-12 23:29:48 +0000 | [diff] [blame] | 91 | FPU_ModifyCode(context, 0xdb); |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 92 | } |
| 93 | |
Jukka Heinonen | 416c2ae | 2002-11-12 23:29:48 +0000 | [diff] [blame] | 94 | |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 95 | /********************************************************************** |
Jukka Heinonen | 416c2ae | 2002-11-12 23:29:48 +0000 | [diff] [blame] | 96 | * DOSVM_Int38Handler (WINEDOS16.156) |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 97 | * |
| 98 | * Handler for int 38 (FLOATING POINT EMULATION - Opcode 0xdc). |
| 99 | * |
| 100 | * Between versions 3.0 and 5.01, the original PC-MOS API call that |
| 101 | * was here was moved to int 0xd4. |
| 102 | * |
| 103 | * The interrupt list isn't specific about what this interrupt |
| 104 | * actually does. [ interrup.m ] |
| 105 | */ |
Jukka Heinonen | 416c2ae | 2002-11-12 23:29:48 +0000 | [diff] [blame] | 106 | void WINAPI DOSVM_Int38Handler(CONTEXT86 *context) |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 107 | { |
Alexandre Julliard | ef94e40 | 2003-08-18 20:04:27 +0000 | [diff] [blame] | 108 | TRACE("Int 0x38 called-- FP opcode 0xdc\n"); |
Jukka Heinonen | 416c2ae | 2002-11-12 23:29:48 +0000 | [diff] [blame] | 109 | FPU_ModifyCode(context, 0xdc); |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 110 | } |
| 111 | |
Jukka Heinonen | 416c2ae | 2002-11-12 23:29:48 +0000 | [diff] [blame] | 112 | |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 113 | /********************************************************************** |
Jukka Heinonen | 416c2ae | 2002-11-12 23:29:48 +0000 | [diff] [blame] | 114 | * DOSVM_Int39Handler (WINEDOS16.157) |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 115 | * |
| 116 | * Handler for int 39 (FLOATING POINT EMULATION - Opcode 0xdd). |
| 117 | * |
| 118 | * The interrupt list isn't specific about what this interrupt |
| 119 | * actually does. [ interrup.m ] |
| 120 | */ |
Jukka Heinonen | 416c2ae | 2002-11-12 23:29:48 +0000 | [diff] [blame] | 121 | void WINAPI DOSVM_Int39Handler(CONTEXT86 *context) |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 122 | { |
Alexandre Julliard | ef94e40 | 2003-08-18 20:04:27 +0000 | [diff] [blame] | 123 | TRACE("Int 0x39 called-- FP opcode 0xdd\n"); |
Jukka Heinonen | 416c2ae | 2002-11-12 23:29:48 +0000 | [diff] [blame] | 124 | FPU_ModifyCode(context, 0xdd); |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 125 | } |
| 126 | |
Jukka Heinonen | 416c2ae | 2002-11-12 23:29:48 +0000 | [diff] [blame] | 127 | |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 128 | /********************************************************************** |
Jukka Heinonen | 416c2ae | 2002-11-12 23:29:48 +0000 | [diff] [blame] | 129 | * DOSVM_Int3aHandler (WINEDOS16.158) |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 130 | * |
| 131 | * Handler for int 3a (FLOATING POINT EMULATION - Opcode 0xde). |
| 132 | * |
| 133 | * The interrupt list isn't specific about what this interrupt |
| 134 | * actually does. [ interrup.m ] |
| 135 | */ |
Jukka Heinonen | 416c2ae | 2002-11-12 23:29:48 +0000 | [diff] [blame] | 136 | void WINAPI DOSVM_Int3aHandler(CONTEXT86 *context) |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 137 | { |
Alexandre Julliard | ef94e40 | 2003-08-18 20:04:27 +0000 | [diff] [blame] | 138 | TRACE("Int 0x3a called-- FP opcode 0xde\n"); |
Jukka Heinonen | 416c2ae | 2002-11-12 23:29:48 +0000 | [diff] [blame] | 139 | FPU_ModifyCode(context, 0xde); |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 140 | } |
| 141 | |
Jukka Heinonen | 416c2ae | 2002-11-12 23:29:48 +0000 | [diff] [blame] | 142 | |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 143 | /********************************************************************** |
Jukka Heinonen | 416c2ae | 2002-11-12 23:29:48 +0000 | [diff] [blame] | 144 | * DOSVM_Int3bHandler (WINEDOS16.159) |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 145 | * |
| 146 | * Handler for int 3B (FLOATING POINT EMULATION - Opcode 0xdf). |
| 147 | * |
| 148 | * The interrupt list isn't specific about what this interrupt |
| 149 | * actually does. [ interrup.m ] |
| 150 | */ |
Jukka Heinonen | 416c2ae | 2002-11-12 23:29:48 +0000 | [diff] [blame] | 151 | void WINAPI DOSVM_Int3bHandler(CONTEXT86 *context) |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 152 | { |
Alexandre Julliard | ef94e40 | 2003-08-18 20:04:27 +0000 | [diff] [blame] | 153 | TRACE("Int 0x3b called-- FP opcode 0xdf\n"); |
Jukka Heinonen | 416c2ae | 2002-11-12 23:29:48 +0000 | [diff] [blame] | 154 | FPU_ModifyCode(context, 0xdf); |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 155 | } |
| 156 | |
| 157 | |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 158 | /********************************************************************** |
Jukka Heinonen | 416c2ae | 2002-11-12 23:29:48 +0000 | [diff] [blame] | 159 | * DOSVM_Int3cHandler (WINEDOS16.160) |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 160 | * |
| 161 | * Handler for int 3C (FLOATING POINT EMULATION - INSTRUCTIONS WITH SEGMENT OVERRIDE). |
| 162 | * |
| 163 | * Generated code is CD 3C xy mm ... (CD = int | 3C = this interrupt) |
| 164 | * xy is a modified ESC code and mm is the modR/M byte. |
| 165 | * xy byte seems to be encoded as ss011xxx or ss000xxx |
| 166 | * ss= segment override. |
Jukka Heinonen | 416c2ae | 2002-11-12 23:29:48 +0000 | [diff] [blame] | 167 | * 00 -> DS |
| 168 | * 01 -> SS |
| 169 | * 10 -> CS |
| 170 | * 11 -> ES |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 171 | * |
| 172 | * 11011xxx should be the opcode instruction. |
| 173 | */ |
Jukka Heinonen | 416c2ae | 2002-11-12 23:29:48 +0000 | [diff] [blame] | 174 | void WINAPI DOSVM_Int3cHandler(CONTEXT86 *context) |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 175 | { |
Alexandre Julliard | ef94e40 | 2003-08-18 20:04:27 +0000 | [diff] [blame] | 176 | FIXME("Int 3C NOT Implemented\n"); |
Jukka Heinonen | 416c2ae | 2002-11-12 23:29:48 +0000 | [diff] [blame] | 177 | INT_BARF(context, 0x3c); |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 178 | } |
| 179 | |
Jukka Heinonen | 416c2ae | 2002-11-12 23:29:48 +0000 | [diff] [blame] | 180 | |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 181 | /********************************************************************** |
Jukka Heinonen | 416c2ae | 2002-11-12 23:29:48 +0000 | [diff] [blame] | 182 | * DOSVM_Int3dHandler (WINEDOS16.161) |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 183 | * |
| 184 | * Handler for int 3D (FLOATING POINT EMULATION - Standalone FWAIT). |
| 185 | * |
| 186 | * Opcode 0x90 is a NOP. It just fills space where the 3D was. |
| 187 | */ |
Jukka Heinonen | 416c2ae | 2002-11-12 23:29:48 +0000 | [diff] [blame] | 188 | void WINAPI DOSVM_Int3dHandler(CONTEXT86 *context) |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 189 | { |
Alexandre Julliard | ef94e40 | 2003-08-18 20:04:27 +0000 | [diff] [blame] | 190 | TRACE("Int 0x3d called-- Standalone FWAIT\n"); |
Jukka Heinonen | 416c2ae | 2002-11-12 23:29:48 +0000 | [diff] [blame] | 191 | FPU_ModifyCode(context, 0x90); |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 192 | } |
| 193 | |
| 194 | |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 195 | /********************************************************************** |
Jukka Heinonen | 416c2ae | 2002-11-12 23:29:48 +0000 | [diff] [blame] | 196 | * DOSVM_Int3eHandler (WINEDOS16.162) |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 197 | * |
| 198 | * FLOATING POINT EMULATION -- Borland "Shortcut" call. |
| 199 | * The two bytes following the int 3E instruction are |
| 200 | * the subcode and a NOP ( 0x90 ), except for subcodes DC and DE |
| 201 | * where the second byte is the register count. |
| 202 | * |
| 203 | * Direct access 4.0 modifies and does not restore this vector. |
| 204 | * |
| 205 | */ |
Jukka Heinonen | 416c2ae | 2002-11-12 23:29:48 +0000 | [diff] [blame] | 206 | void WINAPI DOSVM_Int3eHandler(CONTEXT86 *context) |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 207 | { |
Alexandre Julliard | ef94e40 | 2003-08-18 20:04:27 +0000 | [diff] [blame] | 208 | FIXME("Int 3E NOT Implemented\n"); |
Jukka Heinonen | 416c2ae | 2002-11-12 23:29:48 +0000 | [diff] [blame] | 209 | INT_BARF(context, 0x3e); |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 210 | } |
| 211 | |
Jukka Heinonen | 416c2ae | 2002-11-12 23:29:48 +0000 | [diff] [blame] | 212 | |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 213 | /********************************************************************** |
| 214 | * FPU_ModifyCode |
| 215 | * |
| 216 | * This is the function that inserts the 0x9b fwait instruction |
| 217 | * and the actual FPU opcode into the program. |
| 218 | * -A.C. |
| 219 | * |
| 220 | * Code thanks to Ove Kaaven |
| 221 | */ |
| 222 | static void FPU_ModifyCode(CONTEXT86 *context, BYTE Opcode) |
| 223 | { |
Jukka Heinonen | fbbe6a4 | 2003-08-20 18:17:39 +0000 | [diff] [blame] | 224 | BYTE *code = CTX_SEG_OFF_TO_LIN(context, context->SegCs, context->Eip); |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 225 | |
Jukka Heinonen | 416c2ae | 2002-11-12 23:29:48 +0000 | [diff] [blame] | 226 | /* |
| 227 | * All *NIX systems should have a real or kernel emulated FPU. |
| 228 | */ |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 229 | |
Jukka Heinonen | 416c2ae | 2002-11-12 23:29:48 +0000 | [diff] [blame] | 230 | code[-2] = 0x9b; /* The fwait instruction */ |
| 231 | code[-1] = Opcode; /* Insert the opcode */ |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 232 | |
Jukka Heinonen | fbbe6a4 | 2003-08-20 18:17:39 +0000 | [diff] [blame] | 233 | if ( ISV86(context) && LOWORD(context->Eip) < 2 ) |
| 234 | FIXME("Backed up over a real mode segment boundary in FPU code.\n"); |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 235 | |
Jukka Heinonen | fbbe6a4 | 2003-08-20 18:17:39 +0000 | [diff] [blame] | 236 | context->Eip -= 2; /* back up the return address 2 bytes */ |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 237 | |
Alexandre Julliard | ef94e40 | 2003-08-18 20:04:27 +0000 | [diff] [blame] | 238 | TRACE("Modified code in FPU int call to 0x9b 0x%x\n",Opcode); |
Admiral Coeyman | 9cb2b21 | 2002-07-10 23:22:29 +0000 | [diff] [blame] | 239 | } |