Changeset 59984 in vbox
- Timestamp:
- Mar 11, 2016 12:56:10 AM (9 years ago)
- Location:
- trunk/src/VBox/ValidationKit/bootsectors
- Files:
-
- 14 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/bootsectors/Config.kmk
r59940 r59984 314 314 # -wx Maxium warning level. 315 315 # -zl Don't emit default library information. 316 # -zdp DS pegged to BS3DATA16_GROUP. 316 317 # -zu Assume SS != DS. 317 318 # -mc Compact memory model, far data, small code. … … 342 343 TEMPLATE_VBoxBS3KitImg_CXXTOOL = Bs3Ow16 343 344 TEMPLATE_VBoxBS3KitImg_CFLAGS = \ 344 -nt=BS3TEXT16 -nd=BS3DATA16 -nc=BS3CODE16 -ecw -q -0 -wx -zl -z u -mc $(BS3_OW_DBG_OPT) -d1 -s -oa -ob -of -oi -ol -or -os345 -nt=BS3TEXT16 -nd=BS3DATA16 -nc=BS3CODE16 -ecw -q -0 -wx -zl -zdp -zu -mc $(BS3_OW_DBG_OPT) -d1 -s -oa -ob -of -oi -ol -or -os 345 346 TEMPLATE_VBoxBS3KitImg_CXXFLAGS = \ 346 -nt=BS3TEXT16 -nd=BS3DATA16 -nc=BS3CODE16 -ecw -q -0 -wx -zl -z u -mc $(BS3_OW_DBG_OPT) -d1 -s -oa -ob -of -oi -ol -or -os347 -nt=BS3TEXT16 -nd=BS3DATA16 -nc=BS3CODE16 -ecw -q -0 -wx -zl -zdp -zu -mc $(BS3_OW_DBG_OPT) -d1 -s -oa -ob -of -oi -ol -or -os 347 348 TEMPLATE_VBoxBS3KitImg_INCS = $(VBOX_PATH_BS3KIT_SRC) . 348 349 TEMPLATE_VBoxBS3KitImg_LDTOOL = OPENWATCOM-WL -
trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-basic-2-template.mac
r59941 r59984 9 9 %include "bs3kit-template-header.mac" ; setup environment 10 10 11 12 11 %undef Bs3PrintStr 12 BS3_EXTERN_CMN Bs3PrintStr 13 13 14 14 BS3_PROC_BEGIN_CMN bs3CpuBasic2_iret 15 ;hlt 15 16 %if TMPL_BITS == 16 17 push cs 18 push .szMsg 19 call Bs3PrintStr 20 add sp, 4 21 %else 22 push .szMsg wrt FLAT 23 BS3_CALL Bs3PrintStr, 1 24 add xSP, xCB 25 %endif 26 27 ; Return 16 28 xor al, al 17 29 mov al, TMPL_MODE 18 30 ret 31 .szMsg: db 'hello world ', TMPL_MODE_STR, '!', 13, 10, 0 32 19 33 BS3_PROC_END_CMN bs3CpuBasic2_iret 20 34 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk
r59976 r59984 114 114 bs3-cmn-TestSendCmdWithU32.asm \ 115 115 bs3-cmn-TestIsVmmDevTestingPresent.asm \ 116 bs3-cmn-Trap16Init.c \ 116 117 bs3-cmn-Trap16SetGate.c \ 117 118 bs3-cmn-Trap32Init.c \ … … 159 160 bs3-wc16-U4D.asm \ 160 161 bs3-wc16-I4D.asm \ 162 bs3-c16-Trap16Generic.asm 161 163 162 164 # The 32-bit BS3Kit library. -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-c16-Trap16Generic.asm
r59976 r59984 1 1 ; $Id$ 2 2 ;; @file 3 ; BS3Kit - Trap, 32-bit assembly handlers.3 ; BS3Kit - Trap, 16-bit assembly handlers. 4 4 ; 5 5 … … 30 30 %include "bs3kit-template-header.mac" 31 31 32 %ifndef TMPL_ 32BIT33 %error " 32-bit only template"32 %ifndef TMPL_16BIT 33 %error "16-bit only template" 34 34 %endif 35 35 … … 39 39 ;********************************************************************************************************************************* 40 40 BS3_EXTERN_DATA16 g_bBs3CurrentMode 41 BS3_EXTERN_SYSTEM16 Bs3Gdt 41 42 TMPL_BEGIN_TEXT 42 43 BS3_EXTERN_CMN Bs3TrapDefaultHandler … … 49 50 ;********************************************************************************************************************************* 50 51 BS3_BEGIN_DATA16 51 ;; Easy to access flat address of Bs3Trap32GenericEntries. 52 BS3_GLOBAL_DATA g_Bs3Trap32GenericEntriesFlatAddr, 4 53 dd Bs3Trap32GenericEntries wrt FLAT 54 ;; Easy to access flat address of Bs3Trap32DoubleFaultHandler. 55 BS3_GLOBAL_DATA g_Bs3Trap32DoubleFaultHandlerFlatAddr, 4 56 dd Bs3Trap32DoubleFaultHandler wrt FLAT 57 58 BS3_BEGIN_DATA32 59 ;; Pointer C trap handlers. 60 BS3_GLOBAL_DATA g_apfnBs3TrapHandlers_c32, 1024 61 resd 256 52 ;; Pointer C trap handlers (BS3TEXT16). 53 BS3_GLOBAL_DATA g_apfnBs3TrapHandlers_c16, 512 54 resw 256 62 55 63 56 … … 66 59 ; Generic entry points for IDT handlers, 8 byte spacing. 67 60 ; 68 BS3_PROC_BEGIN Bs3Trap32GenericEntries 69 %macro Bs3Trap32GenericEntry 1 61 BS3_PROC_BEGIN _Bs3Trap16GenericEntries 62 BS3_PROC_BEGIN Bs3Trap16GenericEntries 63 %macro Bs3Trap16GenericEntry 1 70 64 db 06ah, i ; push imm8 - note that this is a signextended value. 65 hlt 71 66 jmp %1 72 67 ALIGNCODE(8) … … 75 70 76 71 %assign i 0 ; start counter. 77 Bs3Trap 32GenericEntry bs3Trap32GenericTrapOrInt ; 078 Bs3Trap 32GenericEntry bs3Trap32GenericTrapOrInt ; 179 Bs3Trap 32GenericEntry bs3Trap32GenericTrapOrInt ; 280 Bs3Trap 32GenericEntry bs3Trap32GenericTrapOrInt ; 381 Bs3Trap 32GenericEntry bs3Trap32GenericTrapOrInt ; 482 Bs3Trap 32GenericEntry bs3Trap32GenericTrapOrInt ; 583 Bs3Trap 32GenericEntry bs3Trap32GenericTrapOrInt ; 684 Bs3Trap 32GenericEntry bs3Trap32GenericTrapOrInt ; 785 Bs3Trap 32GenericEntry bs3Trap32GenericTrapErrCode ; 886 Bs3Trap 32GenericEntry bs3Trap32GenericTrapOrInt ; 987 Bs3Trap 32GenericEntry bs3Trap32GenericTrapErrCode ; a88 Bs3Trap 32GenericEntry bs3Trap32GenericTrapErrCode ; b89 Bs3Trap 32GenericEntry bs3Trap32GenericTrapErrCode ; c90 Bs3Trap 32GenericEntry bs3Trap32GenericTrapErrCode ; d91 Bs3Trap 32GenericEntry bs3Trap32GenericTrapErrCode ; e92 Bs3Trap 32GenericEntry bs3Trap32GenericTrapOrInt ; f (reserved)93 Bs3Trap 32GenericEntry bs3Trap32GenericTrapOrInt ; 1094 Bs3Trap 32GenericEntry bs3Trap32GenericTrapErrCode ; 1195 Bs3Trap 32GenericEntry bs3Trap32GenericTrapOrInt ; 1296 Bs3Trap 32GenericEntry bs3Trap32GenericTrapOrInt ; 1397 Bs3Trap 32GenericEntry bs3Trap32GenericTrapOrInt ; 1498 Bs3Trap 32GenericEntry bs3Trap32GenericTrapOrInt ; 15 (reserved)99 Bs3Trap 32GenericEntry bs3Trap32GenericTrapOrInt ; 16 (reserved)100 Bs3Trap 32GenericEntry bs3Trap32GenericTrapOrInt ; 17 (reserved)101 Bs3Trap 32GenericEntry bs3Trap32GenericTrapOrInt ; 18 (reserved)102 Bs3Trap 32GenericEntry bs3Trap32GenericTrapOrInt ; 19 (reserved)103 Bs3Trap 32GenericEntry bs3Trap32GenericTrapOrInt ; 1a (reserved)104 Bs3Trap 32GenericEntry bs3Trap32GenericTrapOrInt ; 1b (reserved)105 Bs3Trap 32GenericEntry bs3Trap32GenericTrapOrInt ; 1c (reserved)106 Bs3Trap 32GenericEntry bs3Trap32GenericTrapOrInt ; 1d (reserved)107 Bs3Trap 32GenericEntry bs3Trap32GenericTrapErrCode ; 1e108 Bs3Trap 32GenericEntry bs3Trap32GenericTrapOrInt ; 1f (reserved)72 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 0 73 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 1 74 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 2 75 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 3 76 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 4 77 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 5 78 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 6 79 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 7 80 Bs3Trap16GenericEntry bs3Trap16GenericTrapErrCode ; 8 81 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 9 82 Bs3Trap16GenericEntry bs3Trap16GenericTrapErrCode ; a 83 Bs3Trap16GenericEntry bs3Trap16GenericTrapErrCode ; b 84 Bs3Trap16GenericEntry bs3Trap16GenericTrapErrCode ; c 85 Bs3Trap16GenericEntry bs3Trap16GenericTrapErrCode ; d 86 Bs3Trap16GenericEntry bs3Trap16GenericTrapErrCode ; e 87 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; f (reserved) 88 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 10 89 Bs3Trap16GenericEntry bs3Trap16GenericTrapErrCode ; 11 90 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 12 91 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 13 92 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 14 93 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 15 (reserved) 94 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 16 (reserved) 95 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 17 (reserved) 96 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 18 (reserved) 97 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 19 (reserved) 98 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 1a (reserved) 99 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 1b (reserved) 100 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 1c (reserved) 101 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 1d (reserved) 102 Bs3Trap16GenericEntry bs3Trap16GenericTrapErrCode ; 1e 103 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 1f (reserved) 109 104 %rep 224 110 Bs3Trap 32GenericEntry bs3Trap32GenericTrapOrInt105 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt 111 106 %endrep 112 BS3_PROC_END Bs3Trap32GenericEntries 113 114 115 116 117 ;; 118 ; Trap or interrupt (no error code). 119 ; 120 BS3_PROC_BEGIN bs3Trap32GenericTrapOrInt 107 BS3_PROC_END Bs3Trap16GenericEntries 108 109 110 111 112 ;; 113 ; 80386+: Trap or interrupt (no error code). 114 ; 115 BS3_PROC_BEGIN _bs3Trap16GenericTrapOrInt 116 BS3_PROC_BEGIN bs3Trap16GenericTrapOrInt 117 CPU 386 118 jmp near bs3Trap16GenericTrapOrInt80286 ; Bs3Trap16Init adjusts this on 80386+ 119 push ebp 120 mov bp, sp 121 push ebx 121 122 pushfd 122 123 cli 123 124 cld 124 125 125 sub esp, BS3TRAPFRAME_size 126 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rax], eax 127 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rbp], ebp 128 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rdx], edx 129 lea ebp, [esp + BS3TRAPFRAME_size + 4] ; iret - 4 (i.e. ebp frame chain location) 130 131 mov edx, [esp + BS3TRAPFRAME_size] 132 mov [esp + BS3TRAPFRAME.fHandlerRfl], edx 133 134 movzx edx, byte [esp + BS3TRAPFRAME_size + 4] 135 mov [esp + BS3TRAPFRAME.bXcpt], edx 136 137 xor edx, edx 138 mov [esp + BS3TRAPFRAME.uErrCd], edx 139 mov [esp + BS3TRAPFRAME.uErrCd + 4], edx 140 jmp bs3Trap32GenericCommon 141 BS3_PROC_END bs3Trap32GenericTrapOrInt 126 ; Reserve space for the the register and trap frame. 127 mov bx, (BS3TRAPFRAME_size + 7) / 8 128 .more_zeroed_space: 129 push 0 130 push 0 131 push 0 132 push 0 133 dec bx 134 jz .more_zeroed_space 135 movzx ebx, sp 136 137 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rax], eax 138 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rdx], edx 139 mov edx, [bp] 140 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rbp], edx 141 mov edx, [bp - 4] 142 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rbx], edx 143 144 mov edx, [bp - 8] 145 mov [ss:bx + BS3TRAPFRAME.fHandlerRfl], edx 146 147 mov dl, [bp + 4] 148 mov [ss:bx + BS3TRAPFRAME.bXcpt], dl 149 150 add bp, 4 ; adjust so it points to the word before the iret frame. 151 jmp bs3Trap16GenericCommon 152 BS3_PROC_END bs3Trap16GenericTrapOrInt 153 154 155 ;; 156 ; 80286: Trap or interrupt (no error code) 157 ; 158 BS3_PROC_BEGIN bs3Trap16GenericTrapOrInt80286 159 CPU 286 160 push bp 161 mov bp, sp 162 push bx 163 pushf 164 cli 165 cld 166 167 ; Reserve space for the the register and trap frame. 168 mov bx, (BS3TRAPFRAME_size + 7) / 8 169 .more_zeroed_space: 170 push 0 171 push 0 172 push 0 173 push 0 174 dec bx 175 jz .more_zeroed_space 176 mov bx, sp 177 178 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rax], ax 179 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rdx], dx 180 mov dx, [bp] 181 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rbp], dx 182 mov dx, [bp - 2] 183 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rbx], dx 184 185 mov dl, [bp - 4] 186 mov [ss:bx + BS3TRAPFRAME.fHandlerRfl], dl 187 188 mov al, byte [bp + 4] 189 mov [ss:bx + BS3TRAPFRAME.bXcpt], al 190 191 add bp, 4 ; adjust so it points to the word before the iret frame. 192 jmp bs3Trap16GenericCommon 193 BS3_PROC_END bs3Trap16GenericTrapOrInt80286 142 194 143 195 … … 145 197 ; Trap with error code. 146 198 ; 147 BS3_PROC_BEGIN bs3Trap32GenericTrapErrCode 199 BS3_PROC_BEGIN _bs3Trap16GenericTrapErrCode 200 BS3_PROC_BEGIN bs3Trap16GenericTrapErrCode 201 CPU 386 202 jmp near bs3Trap16GenericTrapOrInt80286 ; Bs3Trap16Init adjusts this on 80386+ 203 push ebp 204 mov bp, sp 205 push ebx 148 206 pushfd 149 207 cli 150 208 cld 151 209 152 sub esp, BS3TRAPFRAME_size 153 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rax], eax 154 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rbp], ebp 155 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rdx], edx 156 lea ebp, [esp + BS3TRAPFRAME_size + 8] ; iret - 4 (i.e. ebp frame chain location) 157 158 mov edx, [esp + BS3TRAPFRAME_size] 159 mov [esp + BS3TRAPFRAME.fHandlerRfl], edx 160 161 movzx edx, byte [esp + BS3TRAPFRAME_size + 4] 162 mov [esp + BS3TRAPFRAME.bXcpt], edx 163 164 mov edx, [esp + BS3TRAPFRAME_size + 8] 210 ; Reserve space for the the register and trap frame. 211 mov bx, (BS3TRAPFRAME_size + 7) / 8 212 .more_zeroed_space: 213 push 0 214 push 0 215 push 0 216 push 0 217 dec bx 218 jz .more_zeroed_space 219 movzx ebx, sp 220 221 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rax], eax 222 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rdx], edx 223 mov edx, [bp] 224 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rbp], edx 225 mov edx, [bp - 4] 226 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rbx], ebx 227 228 mov edx, [bp - 8] 229 mov [ss:bx + BS3TRAPFRAME.fHandlerRfl], edx 230 231 mov dl, [bp + 4] 232 mov [ss:bx + BS3TRAPFRAME.bXcpt], dl 233 234 mov dx, [bp + 6] 165 235 ;; @todo Do voodoo checks for 'int xx' or misguided hardware interrupts. 166 mov [esp + BS3TRAPFRAME.uErrCd], edx 167 xor edx, edx 168 mov [esp + BS3TRAPFRAME.uErrCd + 4], edx 169 jmp bs3Trap32GenericCommon 170 BS3_PROC_END bs3Trap32GenericTrapErrCode 236 mov [ss:bx + BS3TRAPFRAME.uErrCd], dx 237 238 add bp, 6 ; adjust so it points to the word before the iret frame. 239 jmp bs3Trap16GenericCommon 240 BS3_PROC_END bs3Trap16GenericTrapErrCode 241 242 ;; 243 ; Trap with error code - 80286 code variant. 244 ; 245 BS3_PROC_BEGIN bs3Trap16GenericTrapErrCode80286 246 CPU 286 247 push bp 248 mov bp, sp 249 push bx 250 pushf 251 cli 252 cld 253 254 ; Reserve space for the the register and trap frame. 255 mov bx, (BS3TRAPFRAME_size + 7) / 8 256 .more_zeroed_space: 257 push 0 258 push 0 259 push 0 260 push 0 261 dec bx 262 jz .more_zeroed_space 263 mov bx, sp 264 265 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rax], ax 266 mov [bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rdx], dx 267 mov dx, [bp] 268 mov [bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rbp], dx 269 mov dx, [bp - 2] 270 mov [bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rbx], bx 271 272 mov dx, [bp - 4] 273 mov [bx + BS3TRAPFRAME.fHandlerRfl], dx 274 275 mov dl, [bp + 2] 276 mov [bx + BS3TRAPFRAME.bXcpt], dl 277 278 mov dx, [bp + 4] 279 ;; @todo Do voodoo checks for 'int xx' or misguided hardware interrupts. 280 mov [ss:bx + BS3TRAPFRAME.uErrCd], dx 281 282 add bp, 4 ; adjust so it points to the word before the iret frame. 283 jmp bs3Trap16GenericCommon 284 BS3_PROC_END bs3Trap16GenericTrapErrCode80286 171 285 172 286 … … 174 288 ; Common context saving code and dispatching. 175 289 ; 176 ; @param espPointer to the trap frame. The following members have been290 ; @param bx Pointer to the trap frame. The following members have been 177 291 ; filled in by the previous code: 178 292 ; - bXcpt 179 293 ; - uErrCd 180 294 ; - fHandlerRFL 181 ; - Ctx.eax (except upper dword) 182 ; - Ctx.edx (except upper dword) 183 ; - Ctx.ebp (except upper dword) 184 ; 185 ; @param ebp Pointer to the dword before the iret frame, i.e. where ebp 186 ; would be saved if this was a normal call. 187 ; @param edx Zero (0). 188 ; 189 BS3_PROC_BEGIN bs3Trap32GenericCommon 295 ; - Ctx.eax (except upper stuff) 296 ; - Ctx.edx (except upper stuff) 297 ; - Ctx.ebx (except upper stuff) 298 ; - Ctx.ebp (except upper stuff) 299 ; - All other bytes are zeroed. 300 ; 301 ; @param bp Pointer to the word before the iret frame, i.e. where bp 302 ; would be saved if this was a normal near call. 303 ; @param dx zero (0) if 286, set (1) if 386 304 ; 305 BS3_PROC_BEGIN bs3Trap16GenericCommon 306 CPU 286 190 307 ; 191 308 ; Fake EBP frame. 192 309 ; 193 mov eax, [esp+ BS3TRAPFRAME.Ctx + BS3REGCTX.rbp]194 mov [ ebp], eax310 mov ax, [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rbp] 311 mov [bp], ax 195 312 196 313 ; 197 314 ; Save the remaining GPRs and segment registers. 198 315 ; 199 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rcx], ecx 200 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rbx], ebx 201 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rdi], edi 202 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rsi], esi 203 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.ds], ds 204 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.es], es 205 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.fs], fs 206 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.gs], gs 207 208 ; 209 ; Load 32-bit data selector for the DPL we're executing at into DS and ES. 316 test dx, dx 317 jz .save_word_grps 318 CPU 386 319 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rcx], ecx 320 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rdi], edi 321 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rsi], esi 322 jmp .save_segment_registers 323 .save_word_grps: 324 CPU 286 325 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rcx], cx 326 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rdi], di 327 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rsi], si 328 .save_segment_registers: 329 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.ds], ds 330 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.es], es 331 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.fs], fs 332 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.gs], gs 333 334 ; 335 ; Load 16-bit data selector for the DPL we're executing at into DS and ES. 210 336 ; Save the handler SS and CS values first. 211 337 ; 212 338 mov ax, cs 213 mov [ esp+ BS3TRAPFRAME.uHandlerCs], ax339 mov [ss:bx + BS3TRAPFRAME.uHandlerCs], ax 214 340 mov ax, ss 215 mov [ esp+ BS3TRAPFRAME.uHandlerSs], ax341 mov [ss:bx + BS3TRAPFRAME.uHandlerSs], ax 216 342 and ax, 3 217 343 mov cx, ax … … 226 352 ; 227 353 mov al, [BS3_DATA16_WRT(g_bBs3CurrentMode)] 228 mov [ esp+ BS3TRAPFRAME.Ctx + BS3REGCTX.bMode], al354 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.bMode], al 229 355 and al, ~BS3_MODE_CODE_MASK 230 356 or al, BS3_MODE_CODE_32 … … 234 360 ; Copy iret info. 235 361 ; 236 mov ecx, [ebp + 4] 237 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rip], ecx 238 mov ecx, [ebp + 12] 239 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rflags], ecx 240 mov cx, [ebp + 8] 241 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.cs], cx 242 test dword [ebp + 12], X86_EFL_VM 243 jnz .iret_frame_v8086 362 mov cx, [bp + 2] 363 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rip], cx 364 mov cx, [bp + 6] 365 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rflags], cx 366 mov cx, [bp + 4] 367 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.cs], cx 368 369 mov al, [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.bMode] 370 and al, BS3_MODE_CODE_MASK 371 cmp al, BS3_MODE_CODE_V86 372 je .iret_frame_v8086 373 244 374 mov ax, ss 245 375 and al, 3 246 376 and cl, 3 247 mov [ esp+ BS3TRAPFRAME.Ctx + BS3REGCTX.bCpl], cl377 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.bCpl], cl 248 378 cmp cl, al 249 379 je .iret_frame_same_cpl 250 380 251 mov ecx, [ebp + 16] 252 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rsp], ecx 381 .ret_frame_different_cpl: 382 mov cx, [bp + 10] 383 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.ss], cx 384 test dx, dx 385 jz .ret_frame_different_cpl_286 386 .ret_frame_different_cpl_386: 387 CPU 386 388 mov ecx, esp 389 mov cx, [bp + 8] 390 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rsp], ecx 391 lea eax, [ebp + 12] 392 mov [ss:bx + BS3TRAPFRAME.uHandlerRsp], eax 393 jmp .iret_frame_done 394 .ret_frame_different_cpl_286: 395 CPU 286 396 mov cx, [bp + 8] 397 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rsp], cx 398 lea ax, [bp + 12] 399 mov [ss:bx + BS3TRAPFRAME.uHandlerRsp], ax 400 jmp .iret_frame_done 401 402 .iret_frame_same_cpl: 403 mov cx, ss 404 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.ss], cx 405 test dx, dx 406 jz .iret_frame_same_cpl_286 407 .iret_frame_same_cpl_386: 408 CPU 386 409 mov ecx, esp 410 lea cx, [bp + 8] 411 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rsp], ecx 412 mov [ss:bx + BS3TRAPFRAME.uHandlerRsp], ecx 413 jmp .iret_frame_done 414 .iret_frame_same_cpl_286: 415 CPU 286 416 lea cx, [bp + 8] 417 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rsp], cx 418 mov [ss:bx + BS3TRAPFRAME.uHandlerRsp], cx 419 jmp .iret_frame_done 420 421 .iret_frame_v8086: 422 CPU 386 423 mov byte [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.bCpl], 3 424 or byte [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.bMode], BS3_MODE_CODE_V86 ; paranoia ^ 2 425 movzx ecx, word [ebp + 16] 426 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rsp], ecx 253 427 mov cx, [ebp + 20] 254 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.ss], cx 255 lea eax, [ebp + 24] 256 mov [esp + BS3TRAPFRAME.uHandlerRsp], eax 428 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.ss], cx 429 mov cx, [ebp + 24] 430 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.es], cx 431 mov cx, [ebp + 28] 432 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.ds], cx 433 mov cx, [ebp + 32] 434 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.fs], cx 435 mov cx, [ebp + 36] 436 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.gs], cx 437 lea eax, [ebp + 40] 438 mov [ss:bx + BS3TRAPFRAME.uHandlerRsp], eax 257 439 jmp .iret_frame_done 258 440 259 .iret_frame_same_cpl:260 lea ecx, [ebp + 12]261 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rsp], ecx262 mov cx, ss263 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.ss], cx264 lea eax, [ebp + 16]265 mov [esp + BS3TRAPFRAME.uHandlerRsp], eax266 jmp .iret_frame_done267 268 .iret_frame_v8086:269 mov byte [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.bCpl], 3270 or byte [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.bMode], BS3_MODE_CODE_V86 ; paranoia ^ 2271 movzx ecx, word [ebp + 16]272 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rsp], ecx273 mov cx, [ebp + 20]274 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.ss], cx275 mov cx, [ebp + 24]276 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.es], cx277 mov cx, [ebp + 28]278 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.ds], cx279 mov cx, [ebp + 32]280 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.fs], cx281 mov cx, [ebp + 36]282 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.gs], cx283 lea eax, [ebp + 40]284 mov [esp + BS3TRAPFRAME.uHandlerRsp], eax285 jmp .iret_frame_done286 287 441 .iret_frame_done: 288 442 ; 289 443 ; Control registers. 290 444 ; 445 str [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.tr] 446 sldt [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.ldtr] 447 test dx, dx 448 jz .save_286_control_registers 449 .save_386_control_registers: 450 CPU 386 291 451 mov eax, cr0 292 mov [ esp+ BS3TRAPFRAME.Ctx + BS3REGCTX.cr0], eax452 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.cr0], eax 293 453 mov eax, cr2 294 mov [ esp+ BS3TRAPFRAME.Ctx + BS3REGCTX.cr2], eax454 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.cr2], eax 295 455 mov eax, cr3 296 mov [ esp+ BS3TRAPFRAME.Ctx + BS3REGCTX.cr3], eax456 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.cr3], eax 297 457 mov eax, cr4 298 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.cr4], eax 299 str ax 300 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.tr], ax 301 sldt ax 302 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.ldtr], ax 303 304 ; 305 ; Set context bit width and clear all upper dwords and unused register members. 306 ; 307 .clear_and_dispatch_to_handler: ; The double fault code joins us here. 308 xor edx, edx 309 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.abPadding], dx 310 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.abPadding + 2], edx 311 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rax + 4], edx 312 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rcx + 4], edx 313 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rdx + 4], edx 314 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rbx + 4], edx 315 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rsp + 4], edx 316 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rbp + 4], edx 317 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rsi + 4], edx 318 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rdi + 4], edx 319 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.r8 + 4], edx 320 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.r9 + 4], edx 321 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.r10 + 4], edx 322 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.r11 + 4], edx 323 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.r12 + 4], edx 324 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.r13 + 4], edx 325 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.r14 + 4], edx 326 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.r15 + 4], edx 327 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rflags + 4], edx 328 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rip + 4], edx 329 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.cr0 + 4], edx 330 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.cr2 + 4], edx 331 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.cr3 + 4], edx 332 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.cr4 + 4], edx 458 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.cr4], eax 459 jmp .dispatch_to_handler 460 CPU 286 461 .save_286_control_registers: 462 smsw [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.cr0] 333 463 334 464 ; 335 465 ; Dispatch it to C code. 336 466 ; 337 movzx ebx, byte [esp + BS3TRAPFRAME.bXcpt] 338 mov eax, [ebx * 4 + BS3_DATA16_WRT(_g_apfnBs3TrapHandlers_c32)] 339 or eax, eax 467 .dispatch_to_handler: ; The double fault code joins us here. 468 mov di, bx 469 mov bl, byte [ss:bx + BS3TRAPFRAME.bXcpt] 470 mov bh, 0 471 shl bx, 1 472 mov bx, [bx + BS3_DATA16_WRT(_g_apfnBs3TrapHandlers_c16)] 473 or bx, bx 340 474 jnz .call_handler 341 mov eax, Bs3TrapDefaultHandler475 mov bx, Bs3TrapDefaultHandler 342 476 .call_handler: 343 mov edi, esp344 push edi345 call eax477 push ss 478 push di 479 call bx 346 480 347 481 ; … … 349 483 ; 350 484 push 0 351 add edi, BS3TRAPFRAME.Ctx 352 push edi 485 push ss 486 add di, BS3TRAPFRAME.Ctx 487 push di 353 488 call Bs3RegCtxRestore 354 489 .panic: 355 490 hlt 356 491 jmp .panic 357 BS3_PROC_END bs3Trap 32GenericCommon492 BS3_PROC_END bs3Trap16GenericCommon 358 493 359 494 … … 361 496 ; Helper. 362 497 ; 363 ; @retruns Flat address in e ax.364 ; @param ax498 ; @retruns Flat address in es:di. 499 ; @param di 365 500 ; @uses eax 366 501 ; 367 bs3Trap32TssInAxToFlatInEax: 368 ; Get the GDT base address and find the descriptor address (EAX) 369 sub esp, 16h 370 sgdt [esp + 2] ; +2 for correct alignment. 371 and eax, 0fff8h 372 add eax, [esp + 4] ; GDT base address. 373 add esp, 16h 374 375 ; Get the flat TSS address from the descriptor. 376 push ecx 377 mov ecx, [eax + 4] 378 and eax, 0ffff0000h 379 movzx eax, word [eax] 380 or eax, ecx 381 pop ecx 382 502 bs3Trap16TssInDiToFar1616InEsDi: 503 CPU 286 504 push ax 505 506 ; ASSUME Bs3Gdt is being used. 507 push BS3_SEL_SYSTEM16 508 pop es 509 and di, 0fff8h 510 add di, Bs3Gdt wrt BS3SYSTEM16 511 512 ; Load the TSS base into ax:di (di is low, ax high) 513 mov al, [es:di + (X86DESCGENERIC_BIT_OFF_BASE_HIGH1 / 8)] 514 mov ah, [es:di + (X86DESCGENERIC_BIT_OFF_BASE_HIGH2 / 8)] 515 mov di, [es:di + (X86DESCGENERIC_BIT_OFF_BASE_LOW / 8)] 516 517 ; Convert ax to tiled selector, if not within the tiling area we read 518 ; random BS3SYSTEM16 bits as that's preferable to #GP'ing. 519 shl ax, X86_SEL_SHIFT 520 cmp ax, BS3_SEL_TILED_LAST - BS3_SEL_TILED 521 %ifdef BS3_STRICT 522 jbe .tiled 523 int3 524 %endif 525 ja .return ; don't crash again. 526 .tiled: 527 add ax, BS3_SEL_TILED 528 mov es, ax 529 .return: 530 pop ax 383 531 ret 532 384 533 385 534 ;; … … 389 538 ; TSS specified sane values which got loaded during the task switch. 390 539 ; 391 BS3_PROC_BEGIN Bs3Trap32DoubleFaultHandler 540 ; @param dx Zero (1) (for 386+). 541 ; 542 BS3_PROC_BEGIN _Bs3Trap16DoubleFaultHandler80386 543 BS3_PROC_BEGIN Bs3Trap16DoubleFaultHandler80386 544 CPU 386 392 545 push 0 ; We'll copy the rip from the other TSS here later to create a more sensible call chain. 393 546 push ebp 394 mov ebp, esp 547 mov bp, sp 548 pushfd ; Handler flags. 549 550 ; Reserve space for the the register and trap frame. 551 mov bx, (BS3TRAPFRAME_size + 15) / 16 552 .more_zeroed_space: 553 push dword 0 554 push dword 0 555 push dword 0 556 push dword 0 557 dec bx 558 jz .more_zeroed_space 559 mov bx, sp 560 561 ; 562 ; Fill in the high GRP register words before we mess them up. 563 ; 564 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rax], eax 565 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rbx], ebx 566 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rcx], ecx 567 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rdx], edx 568 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rsi], esi 569 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rdi], edi 570 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rbp], ebp 571 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rsp], esp 572 573 ; 574 ; FS and GS are not part of the 16-bit TSS because they are 386+ specfic. 575 ; 576 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.fs], fs 577 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.gs], gs 395 578 396 579 ; 397 580 ; Fill in the non-context trap frame bits. 398 581 ; 399 pushfd ; Get handler flags. 400 pop ecx 401 xor edx, edx ; NULL register. 402 403 sub esp, BS3TRAPFRAME_size ; Allocate trap frame. 404 mov [esp + BS3TRAPFRAME.fHandlerRfl], ecx 405 mov word [esp + BS3TRAPFRAME.bXcpt], X86_XCPT_DF 406 mov [esp + BS3TRAPFRAME.uHandlerCs], cs 407 mov [esp + BS3TRAPFRAME.uHandlerSs], ss 408 lea ecx, [ebp + 12] 409 mov [esp + BS3TRAPFRAME.uHandlerRsp], ecx 410 mov [esp + BS3TRAPFRAME.uHandlerRsp + 4], edx 411 mov ecx, [ebp + 8] 412 mov [esp + BS3TRAPFRAME.uErrCd], ecx 413 mov [esp + BS3TRAPFRAME.uErrCd + 4], edx 582 mov ecx, [bp - 4] 583 mov [ss:bx + BS3TRAPFRAME.fHandlerRfl], ecx 584 mov byte [ss:bx + BS3TRAPFRAME.bXcpt], X86_XCPT_DF 585 mov [ss:bx + BS3TRAPFRAME.uHandlerCs], cs 586 mov [ss:bx + BS3TRAPFRAME.uHandlerSs], ss 587 mov ecx, esp 588 lea cx, [bp + 8] 589 mov [ss:bx + BS3TRAPFRAME.uHandlerRsp], ecx 590 mov cx, [bp + 6] 591 mov [ss:bx + BS3TRAPFRAME.uErrCd], cx 592 593 ; 594 ; Copy 80386+ control registers. 595 ; 596 mov ecx, cr0 597 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.cr0], ecx 598 mov ecx, cr2 599 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.cr2], ecx 600 mov ecx, cr3 601 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.cr3], ecx 602 mov ecx, cr4 603 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.cr4], ecx 414 604 415 605 ; 416 606 ; Copy the register state from the previous task segment. 417 ; 418 607 ; The 80286 code with join us here. 608 ; 609 .common: 610 CPU 286 419 611 ; Find our TSS. 420 str ax421 call bs3Trap 32TssInAxToFlatInEax612 str di 613 call bs3Trap16TssInDiToFar1616InEsDi 422 614 423 615 ; Find the previous TSS. 424 mov ax, [eax+ X86TSS32.selPrev]425 mov [ esp+ BS3TRAPFRAME.Ctx + BS3REGCTX.tr], ax426 call bs3Trap 32TssInAxToFlatInEax616 mov di, [es:di + X86TSS32.selPrev] 617 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.tr], ax 618 call bs3Trap16TssInDiToFar1616InEsDi 427 619 428 620 ; Do the copying. 429 mov ecx, [eax + X86TSS32.eax] 430 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rax], ecx 431 mov ecx, [eax + X86TSS32.ecx] 432 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rcx], ecx 433 mov ecx, [eax + X86TSS32.edx] 434 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rdx], ecx 435 mov ecx, [eax + X86TSS32.ebx] 436 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rbx], ecx 437 mov ecx, [eax + X86TSS32.esp] 438 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rsp], ecx 439 mov ecx, [eax + X86TSS32.ebp] 440 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rbp], ecx 441 mov [ebp], ecx ; For better call stacks. 442 mov ecx, [eax + X86TSS32.esi] 443 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rsi], ecx 444 mov ecx, [eax + X86TSS32.edi] 445 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rdi], ecx 446 mov ecx, [eax + X86TSS32.esi] 447 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rsi], ecx 448 mov ecx, [eax + X86TSS32.eflags] 449 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rflags], ecx 450 mov ecx, [eax + X86TSS32.eip] 451 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rip], ecx 452 mov [ebp + 4], ecx ; For better call stacks. 453 mov cx, [eax + X86TSS32.cs] 454 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.cs], cx 455 mov cx, [eax + X86TSS32.ds] 456 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.ds], cx 457 mov cx, [eax + X86TSS32.es] 458 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.es], cx 459 mov cx, [eax + X86TSS32.fs] 460 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.fs], cx 461 mov cx, [eax + X86TSS32.gs] 462 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.gs], cx 463 mov cx, [eax + X86TSS32.ss] 464 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.ss], cx 465 mov cx, [eax + X86TSS32.selLdt] ; Note! This isn't necessarily the ldtr at the time of the fault. 466 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.ldtr], cx 467 mov cx, [eax + X86TSS32.cr3] ; Note! This isn't necessarily the cr3 at the time of the fault. 468 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.cr3], ecx 621 mov cx, [es:di + X86TSS16.ax] 622 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rax], cx 623 mov cx, [es:di + X86TSS16.cx] 624 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rcx], cx 625 mov cx, [es:di + X86TSS16.dx] 626 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rdx], cx 627 mov cx, [es:di + X86TSS16.bx] 628 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rbx], cx 629 mov cx, [es:di + X86TSS16.sp] 630 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rsp], cx 631 mov cx, [es:di + X86TSS16.bp] 632 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rbp], cx 633 mov [bp], cx ; For better call stacks. 634 mov cx, [es:di + X86TSS16.si] 635 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rsi], cx 636 mov cx, [es:di + X86TSS16.di] 637 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rdi], cx 638 mov cx, [es:di + X86TSS16.si] 639 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rsi], cx 640 mov cx, [es:di + X86TSS16.flags] 641 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rflags], cx 642 mov cx, [es:di + X86TSS16.ip] 643 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rip], cx 644 mov [ebp + 2], cx ; For better call stacks. 645 mov cx, [eax + X86TSS16.cs] 646 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.cs], cx 647 mov cx, [eax + X86TSS16.ds] 648 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.ds], cx 649 mov cx, [eax + X86TSS16.es] 650 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.es], cx 651 mov cx, [eax + X86TSS16.ss] 652 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.ss], cx 653 mov cx, [eax + X86TSS16.selLdt] ; Note! This isn't necessarily the ldtr at the time of the fault. 654 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.ldtr], cx 469 655 470 656 ; 471 657 ; Set CPL; copy and update mode. 472 658 ; 473 mov cl, [ esp+ BS3TRAPFRAME.Ctx + BS3REGCTX.ss]659 mov cl, [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.ss] 474 660 and cl, 3 475 mov [ esp+ BS3TRAPFRAME.Ctx + BS3REGCTX.bCpl], cl661 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.bCpl], cl 476 662 477 663 mov cl, [BS3_DATA16_WRT(g_bBs3CurrentMode)] 478 mov [ esp+ BS3TRAPFRAME.Ctx + BS3REGCTX.bMode], cl664 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.bMode], cl 479 665 and cl, ~BS3_MODE_CODE_MASK 480 666 or cl, BS3_MODE_CODE_32 … … 482 668 483 669 ; 484 ; Control registers.485 ;486 mov ecx, cr0487 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.cr0], ecx488 mov ecx, cr2489 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.cr2], ecx490 mov ecx, cr4491 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.cr4], ecx492 493 ;494 670 ; Join code paths with the generic handler code. 495 671 ; 496 jmp bs3Trap32GenericCommon.clear_and_dispatch_to_handler 497 BS3_PROC_END Bs3Trap32DoubleFaultHandler 498 672 jmp bs3Trap16GenericCommon.dispatch_to_handler 673 BS3_PROC_END Bs3Trap16DoubleFaultHandler 674 675 676 ;; 677 ; Double fault handler. 678 ; 679 ; We don't have to load any selectors or clear anything in EFLAGS because the 680 ; TSS specified sane values which got loaded during the task switch. 681 ; 682 ; @param dx Zero (0) (for 286). 683 ; 684 BS3_PROC_BEGIN _Bs3Trap16DoubleFaultHandler80286 685 BS3_PROC_BEGIN Bs3Trap16DoubleFaultHandler80286 686 CPU 286 687 push 0 ; We'll copy the rip from the other TSS here later to create a more sensible call chain. 688 push bp 689 mov bp, sp 690 pushf ; Handler flags. 691 692 ; Reserve space for the the register and trap frame. 693 mov bx, (BS3TRAPFRAME_size + 7) / 8 694 .more_zeroed_space: 695 push 0 696 push 0 697 push 0 698 push 0 699 dec bx 700 jz .more_zeroed_space 701 mov bx, sp 702 703 ; 704 ; Fill in the non-context trap frame bits. 705 ; 706 mov cx, [bp - 2] 707 mov [ss:bx + BS3TRAPFRAME.fHandlerRfl], cx 708 mov byte [ss:bx + BS3TRAPFRAME.bXcpt], X86_XCPT_DF 709 mov [ss:bx + BS3TRAPFRAME.uHandlerCs], cs 710 mov [ss:bx + BS3TRAPFRAME.uHandlerSs], ss 711 lea cx, [bp + 8] 712 mov [ss:bx + BS3TRAPFRAME.uHandlerRsp], cx 713 mov cx, [bp + 6] 714 mov [ss:bx + BS3TRAPFRAME.uErrCd], cx 715 716 ; 717 ; Copy 80286 specific control register. 718 ; 719 smsw [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.cr0] 720 721 jmp Bs3Trap16DoubleFaultHandler80386.common 722 BS3_PROC_END Bs3Trap16DoubleFaultHandler80286 723 724 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-c32-Trap32Generic.asm
r59976 r59984 249 249 je .iret_frame_same_cpl 250 250 251 .iret_frame_different_cpl: 251 252 mov ecx, [ebp + 16] 252 253 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rsp], ecx … … 260 261 lea ecx, [ebp + 12] 261 262 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rsp], ecx 263 mov [esp + BS3TRAPFRAME.uHandlerRsp], ecx 262 264 mov cx, ss 263 265 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.ss], cx 264 lea eax, [ebp + 16]265 mov [esp + BS3TRAPFRAME.uHandlerRsp], eax266 266 jmp .iret_frame_done 267 267 … … 367 367 bs3Trap32TssInAxToFlatInEax: 368 368 ; Get the GDT base address and find the descriptor address (EAX) 369 sub esp, 16h370 sgdt [esp + 2] ; +2 for correct alignment.369 sub esp, 8+2 370 sgdt [esp] 371 371 and eax, 0fff8h 372 add eax, [esp + 4] ; GDT base address.373 add esp, 16h372 add eax, [esp + 2] ; GDT base address. 373 add esp, 8+2 374 374 375 375 ; Get the flat TSS address from the descriptor. 376 push ecx 377 mov ecx, [eax + 4] 378 and eax, 0ffff0000h 379 movzx eax, word [eax] 380 or eax, ecx 381 pop ecx 382 376 mov al, [eax + (X86DESCGENERIC_BIT_OFF_BASE_HIGH1 / 8)] 377 mov ah, [eax + (X86DESCGENERIC_BIT_OFF_BASE_HIGH2 / 8)] 378 shl eax, 16 379 mov ax, [eax + (X86DESCGENERIC_BIT_OFF_BASE_LOW / 8)] 383 380 ret 384 381 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PrintChr.asm
r59259 r59984 5 5 6 6 ; 7 ; Copyright (C) 2007-201 5Oracle Corporation7 ; Copyright (C) 2007-2016 Oracle Corporation 8 8 ; 9 9 ; This file is part of VirtualBox Open Source Edition (OSE), as -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchTo16BitV86.asm
r59949 r59984 53 53 push dword BS3_SEL_TEXT16 ; +0x04 54 54 push word 0 55 %if TMPL_BITS == 16 56 push word [esp + 2 + 8 * 4 + 2] ; +0x00 57 %else 58 push word [esp + 2 + 8 * 4] ; +0x00 59 %endif 55 push word [esp + 24h - 2] ; +0x00 60 56 ; Save registers and stuff. 61 57 push eax … … 79 75 pop edx 80 76 pop eax 81 add xSP, (9-1)*477 add xSP, 0x24 82 78 ret 83 79 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Trap16Init.c
r59955 r59984 1 1 /* $Id$ */ 2 2 /** @file 3 * BS3Kit - Bs3Trap 32Init3 * BS3Kit - Bs3Trap16Init 4 4 */ 5 5 … … 34 34 * Global Variables * 35 35 *********************************************************************************************************************************/ 36 extern uint32_t BS3_DATA_NM(g_Bs3Trap32DoubleFaultHandlerFlatAddr); 36 /* We ASSUME that BS3CODE16 is 64KB aligned, so the low 16-bit of the 37 flat address matches. Also, these symbols are defined both with 38 and without underscore prefixes. */ 39 extern BS3_DECL(void) BS3_FAR_CODE Bs3Trap16DoubleFaultHandler80386(void); 40 extern BS3_DECL(void) BS3_FAR_CODE Bs3Trap16DoubleFaultHandler80286(void); 41 extern BS3_DECL(void) BS3_FAR_CODE Bs3Trap16GenericEntries(void); 42 43 /* These two are ugly. Need data access for patching purposes. */ 44 extern uint8_t BS3_FAR_DATA bs3Trap16GenericTrapOrInt[]; 45 extern uint8_t BS3_FAR_DATA bs3Trap16GenericTrapErrCode[]; 37 46 38 47 39 BS3_DECL(void) Bs3Trap 32Init(void)48 BS3_DECL(void) Bs3Trap16Init(bool f386Plus) 40 49 { 41 X86TSS32 BS3_FAR *pTss; 42 unsigned iIdt; 50 X86TSS16 BS3_FAR *pTss; 51 unsigned iIdt; 52 53 /* 54 * If 386 or later, patch the trap handler code to not jump to the 80286 55 * code but continue with the next instruction (the 386+ code). 56 */ 57 if (f386Plus) 58 { 59 bs3Trap16GenericTrapErrCode[1] = 0; 60 bs3Trap16GenericTrapErrCode[2] = 0; 61 bs3Trap16GenericTrapOrInt[1] = 0; 62 bs3Trap16GenericTrapOrInt[2] = 0; 63 } 43 64 44 65 /* … … 46 67 */ 47 68 for (iIdt = 0; iIdt < BS3_TRAP_SYSCALL; iIdt++) 48 Bs3Trap 32SetGate(iIdt, X86_SEL_TYPE_SYS_386_INT_GATE, 0 /*bDpl*/,49 BS3_SEL_R0_CS 32, BS3_DATA_NM(g_Bs3Trap32GenericEntriesFlatAddr)+ iIdt * 8, 0 /*cParams*/);69 Bs3Trap16SetGate(iIdt, X86_SEL_TYPE_SYS_286_INT_GATE, 0 /*bDpl*/, 70 BS3_SEL_R0_CS16, (uint16_t)(uintptr_t)Bs3Trap16GenericEntries + iIdt * 8, 0 /*cParams*/); 50 71 for (iIdt = BS3_TRAP_SYSCALL + 1; iIdt < 256; iIdt++) 51 Bs3Trap 32SetGate(iIdt, X86_SEL_TYPE_SYS_386_INT_GATE, 0 /*bDpl*/,52 BS3_SEL_R0_CS 32, BS3_DATA_NM(g_Bs3Trap32GenericEntriesFlatAddr)+ iIdt * 8, 0 /*cParams*/);72 Bs3Trap16SetGate(iIdt, X86_SEL_TYPE_SYS_286_INT_GATE, 0 /*bDpl*/, 73 BS3_SEL_R0_CS16, (uint16_t)(uintptr_t)Bs3Trap16GenericEntries + iIdt * 8, 0 /*cParams*/); 53 74 54 75 /* 55 76 * Initialize the normal TSS so we can do ring transitions via the IDT. 56 77 */ 57 //pTss = &BS3_DATA_NM(Bs3Tss32);58 Bs3MemZero( &BS3_DATA_NM(Bs3Tss32), sizeof(*pTss));59 BS3_DATA_NM(Bs3Tss32).esp0= BS3_ADDR_STACK_R0;60 BS3_DATA_NM(Bs3Tss32).ss0 = BS3_SEL_R0_SS32;61 BS3_DATA_NM(Bs3Tss32).esp1= BS3_ADDR_STACK_R1;62 BS3_DATA_NM(Bs3Tss32).ss1 = BS3_SEL_R1_SS32;63 BS3_DATA_NM(Bs3Tss32).esp2= BS3_ADDR_STACK_R2;64 BS3_DATA_NM(Bs3Tss32).ss2 = BS3_SEL_R2_SS32;78 pTss = &BS3_DATA_NM(Bs3Tss16); 79 Bs3MemZero(pTss, sizeof(*pTss)); 80 pTss->sp0 = BS3_ADDR_STACK_R0; 81 pTss->ss0 = BS3_SEL_R0_SS16; 82 pTss->sp1 = BS3_ADDR_STACK_R1; 83 pTss->ss1 = BS3_SEL_R1_SS16 | 1; 84 pTss->sp2 = BS3_ADDR_STACK_R2; 85 pTss->ss2 = BS3_SEL_R2_SS16 | 2; 65 86 66 87 /* … … 68 89 * cr3 is filled in by switcher code, when needed. 69 90 */ 70 pTss = &BS3_DATA_NM(Bs3Tss 32DoubleFault);91 pTss = &BS3_DATA_NM(Bs3Tss16DoubleFault); 71 92 Bs3MemZero(pTss, sizeof(*pTss)); 72 pTss->esp0 = BS3_ADDR_STACK_R0; 73 pTss->ss0 = BS3_SEL_R0_SS32; 74 pTss->esp1 = BS3_ADDR_STACK_R1; 75 pTss->ss1 = BS3_SEL_R1_SS32; 76 pTss->esp2 = BS3_ADDR_STACK_R2; 77 pTss->ss2 = BS3_SEL_R2_SS32; 78 pTss->eip = BS3_DATA_NM(g_Bs3Trap32DoubleFaultHandlerFlatAddr); 79 pTss->eflags = X86_EFL_1; 80 pTss->esp = BS3_ADDR_STACK_R0_IST1; 81 pTss->es = BS3_SEL_R0_DS32; 82 pTss->ds = BS3_SEL_R0_DS32; 83 pTss->cs = BS3_SEL_R0_CS32; 84 pTss->ss = BS3_SEL_R0_SS32; 93 pTss->sp0 = BS3_ADDR_STACK_R0; 94 pTss->ss0 = BS3_SEL_R0_SS16; 95 pTss->sp1 = BS3_ADDR_STACK_R1; 96 pTss->ss1 = BS3_SEL_R1_SS16 | 1; 97 pTss->sp2 = BS3_ADDR_STACK_R2; 98 pTss->ss2 = BS3_SEL_R2_SS16 | 2; 99 pTss->ip = (uint16_t)(uintptr_t)(f386Plus ? &Bs3Trap16DoubleFaultHandler80386 : &Bs3Trap16DoubleFaultHandler80286); 100 pTss->flags = X86_EFL_1; 101 pTss->sp = BS3_ADDR_STACK_R0_IST1; 102 pTss->es = BS3_SEL_R0_DS16; 103 pTss->ds = BS3_SEL_R0_DS16; 104 pTss->cs = BS3_SEL_R0_CS16; 105 pTss->ss = BS3_SEL_R0_SS16; 106 pTss->dx = f386Plus; 85 107 86 Bs3Trap 32SetGate(X86_XCPT_DF, X86_SEL_TYPE_SYS_TASK_GATE, 0 /*bDpl*/, BS3_SEL_TSS32_DF, 0, 0 /*cParams*/);108 Bs3Trap16SetGate(X86_XCPT_DF, X86_SEL_TYPE_SYS_TASK_GATE, 0 /*bDpl*/, BS3_SEL_TSS16_DF, 0, 0 /*cParams*/); 87 109 } 88 110 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Trap32Init.c
r59286 r59984 55 55 * Initialize the normal TSS so we can do ring transitions via the IDT. 56 56 */ 57 //pTss = &BS3_DATA_NM(Bs3Tss32);58 Bs3MemZero( &BS3_DATA_NM(Bs3Tss32), sizeof(*pTss));59 BS3_DATA_NM(Bs3Tss32).esp0 = BS3_ADDR_STACK_R0;60 BS3_DATA_NM(Bs3Tss32).ss0 = BS3_SEL_R0_SS32;61 BS3_DATA_NM(Bs3Tss32).esp1 = BS3_ADDR_STACK_R1;62 BS3_DATA_NM(Bs3Tss32).ss1 = BS3_SEL_R1_SS32;63 BS3_DATA_NM(Bs3Tss32).esp2 = BS3_ADDR_STACK_R2;64 BS3_DATA_NM(Bs3Tss32).ss2 = BS3_SEL_R2_SS32;57 pTss = &BS3_DATA_NM(Bs3Tss32); 58 Bs3MemZero(pTss, sizeof(*pTss)); 59 pTss->esp0 = BS3_ADDR_STACK_R0; 60 pTss->ss0 = BS3_SEL_R0_SS32; 61 pTss->esp1 = BS3_ADDR_STACK_R1; 62 pTss->ss1 = BS3_SEL_R1_SS32 | 1; 63 pTss->esp2 = BS3_ADDR_STACK_R2; 64 pTss->ss2 = BS3_SEL_R2_SS32 | 2; 65 65 66 66 /* … … 73 73 pTss->ss0 = BS3_SEL_R0_SS32; 74 74 pTss->esp1 = BS3_ADDR_STACK_R1; 75 pTss->ss1 = BS3_SEL_R1_SS32 ;75 pTss->ss1 = BS3_SEL_R1_SS32 | 1; 76 76 pTss->esp2 = BS3_ADDR_STACK_R2; 77 pTss->ss2 = BS3_SEL_R2_SS32 ;77 pTss->ss2 = BS3_SEL_R2_SS32 | 2; 78 78 pTss->eip = BS3_DATA_NM(g_Bs3Trap32DoubleFaultHandlerFlatAddr); 79 79 pTss->eflags = X86_EFL_1; -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPE16_V86.asm
r59938 r59984 67 67 ; Switch to v8086 mode (return address is already 16-bit). 68 68 ; 69 hlt 69 70 extern _Bs3SwitchTo16BitV86_c16 70 71 jmp _Bs3SwitchTo16BitV86_c16 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-TestDoModes.c
r59976 r59984 205 205 * Unpaged prot mode. 206 206 */ 207 #if 0 207 208 if (paEntries[i].pfnDoPE16) 208 209 { 210 Bs3Printf("Calling pfnDoPE16\n"); 209 211 bErrNo = TMPL_NM(Bs3TestCallDoerInPE16)(CONV_TO_BS3TEXT16(paEntries[i].pfnDoPE16)); 212 Bs3Printf("pfnDoPE16 returns %d\n", bErrNo); 210 213 if (bErrNo != 0) 211 214 Bs3TestFailedF("Error #%u (%#x) in %s!\n", bErrNo, bErrNo, BS3_DATA_NM(g_szBs3ModeName_pe16)); 212 215 } 213 214 216 if (bCpuType < BS3CPU_80386) 215 217 continue; … … 217 219 if (paEntries[i].pfnDoPE16_32) 218 220 { 221 Bs3Printf("Calling pfnDoPE16_32\n"); 219 222 bErrNo = TMPL_NM(Bs3TestCallDoerInPE16_32)(CONV_TO_FLAT(paEntries[i].pfnDoPE16_32)); 223 Bs3Printf("pfnDoPE16_32 returns %d\n", bErrNo); 220 224 if (bErrNo != 0) 221 225 Bs3TestFailedF("Error #%u (%#x) in %s!\n", bErrNo, bErrNo, BS3_DATA_NM(g_szBs3ModeName_pe16_32)); … … 223 227 224 228 if (paEntries[i].pfnDoPE16_V86 && fDoWeirdV86Modes) 229 #endif 225 230 { 226 231 bErrNo = TMPL_NM(Bs3TestCallDoerInPE16_V86)(CONV_TO_BS3TEXT16(paEntries[i].pfnDoPE16_V86)); -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-TestDoModesHlp.asm
r59946 r59984 235 235 BS3_SET_BITS 32 236 236 call eax 237 .repeat: jmp .repeat 237 238 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pe16_v86) 238 239 BS3_SET_BITS TMPL_BITS -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-TrapSystemCallHandler.asm
r59975 r59984 152 152 BS3_SET_BITS 16 153 153 %endif 154 push sBX 155 push sAX 156 push sCX 157 push sDX 158 push sBP 154 159 155 160 ; Print the character. … … 159 164 int 10h 160 165 166 pop sBP 167 pop sDX 168 pop sCX 169 pop sAX 170 pop sBX 161 171 %ifndef TMPL_CMN_R86 162 172 ; Switch back (20h param scratch area not required). -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-rm-InitAll.c
r59789 r59984 41 41 if ((BS3_DATA_NM(g_uBs3CpuDetected) & BS3CPU_TYPE_MASK) >= BS3CPU_80386) 42 42 Bs3Trap32Init(); 43 //if ((BS3_DATA_NM(g_uBs3CpuDetected) & BS3CPU_TYPE_MASK) >= BS3CPU_80286)44 // Bs3Trap16Init();43 if ((BS3_DATA_NM(g_uBs3CpuDetected) & BS3CPU_TYPE_MASK) >= BS3CPU_80286) 44 Bs3Trap16Init((BS3_DATA_NM(g_uBs3CpuDetected) & BS3CPU_TYPE_MASK) >= BS3CPU_80386); 45 45 } 46 46 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-docs.c
r58679 r59984 5 5 6 6 /* 7 * Copyright (C) 2007-201 5Oracle Corporation7 * Copyright (C) 2007-2016 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 78 78 * | RFLAGS.DF | =0 | =0 | =0 | =0 | 79 79 * | CS | preserved | preserved | preserved | preserved | 80 * | DS | volatile?| preserved? | preserved | both |80 * | DS | preserved! | preserved? | preserved | both | 81 81 * | ES | volatile | volatile | preserved | volatile | 82 82 * | FS | preserved | preserved | preserved | preserved | … … 103 103 * significant bits. 104 104 * 105 * The DS segment register is pegged to BS3DATA16_GROUP in 16-bit code so that 106 * we don't need to reload it all the time. This allows us to modify it in 107 * ring-0 and mode switching code without ending up in any serious RPL or DPL 108 * trouble. In 32-bit and 64-bit mode the DS register is a flat, unlimited, 109 * writable selector. 110 * 111 * In 16-bit and 32-bit code we do not assume anything about ES, FS, and GS. 112 * 113 * 105 114 * For an in depth coverage of x86 and AMD64 calling convensions, see 106 115 * http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/function-calling-conventions.html 107 116 * 108 117 * 118 * 119 * @section sec_modes Execution Modes 120 * 121 * BS3Kit defines a number of execution modes in order to be able to test the 122 * full CPU capabilities (that VirtualBox care about anyways). It currently 123 * omits system management mode, hardware virtualization modes, and security 124 * modes as those aren't supported by VirtualBox or are difficult to handle. 125 * 126 * The modes are categorized into normal and weird ones. 127 * 128 * The normal ones are: 129 * + RM - Real mode. 130 * + PE16 - Protected mode running 16-bit code, 16-bit TSS and 16-bit handlers. 131 * + PE32 - Protected mode running 32-bit code, 32-bit TSS and 32-bit handlers. 132 * + PEV86 - Protected mode running v8086 code, 32-bit TSS and 32-bit handlers. 133 * + PP16 - 386 paged mode running 16-bit code, 16-bit TSS and 16-bit handlers. 134 * + PP32 - 386 paged mode running 32-bit code, 32-bit TSS and 32-bit handlers. 135 * + PPV86 - 386 paged mode running v8086 code, 32-bit TSS and 32-bit handlers. 136 * + PAE16 - PAE paged mode running 16-bit code, 16-bit TSS and 16-bit handlers. 137 * + PAE32 - PAE paged mode running 32-bit code, 32-bit TSS and 32-bit handlers. 138 * + PAEV86 - PAE paged mode running v8086 code, 32-bit TSS and 32-bit handlers. 139 * + LM16 - AMD64 long mode running 16-bit code, 64-bit TSS and 64-bit handlers. 140 * + LM32 - AMD64 long mode running 32-bit code, 64-bit TSS and 64-bit handlers. 141 * + LM64 - AMD64 long mode running 64-bit code, 64-bit TSS and 64-bit handlers. 142 * 143 * The weird ones: 144 * + PE16_32 - Protected mode running 16-bit code, 16-bit TSS and 16-bit handlers. 145 * + PE16_V86 - Protected mode running 16-bit code, 16-bit TSS and 16-bit handlers. 146 * + PE32_16 - Protected mode running 32-bit code, 32-bit TSS and 32-bit handlers. 147 * + PP16_32 - 386 paged mode running 16-bit code, 16-bit TSS and 16-bit handlers. 148 * + PP16_V86 - 386 paged mode running 16-bit code, 16-bit TSS and 16-bit handlers. 149 * + PP32_16 - 386 paged mode running 32-bit code, 32-bit TSS and 32-bit handlers. 150 * + PAE16_32 - PAE paged mode running 16-bit code, 16-bit TSS and 16-bit handlers. 151 * + PAE16_V86 - PAE paged mode running 16-bit code, 16-bit TSS and 16-bit handlers. 152 * + PAE32_16 - PAE paged mode running 32-bit code, 32-bit TSS and 32-bit handlers. 153 * 154 * Actually, the PE32_16, PP32_16 and PAE32_16 modes aren't all that weird and fits in 155 * right next to LM16 and LM32, but this is the way it ended up. :-) 156 * 109 157 */ 110 158 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.h
r59976 r59984 2075 2075 * Initializes 16-bit (protected mode) trap handling. 2076 2076 * 2077 * @param f386Plus Set if the CPU is 80386 or later and 2078 * extended registers should be saved. Once initialized 2079 * with this parameter set to @a true, the effect cannot be 2080 * reversed. 2081 * 2077 2082 * @remarks Does not install 16-bit trap handling, just initializes the 2078 2083 * structures. 2079 2084 */ 2080 BS3_DECL(void) Bs3Trap16Init_c16( void);2081 BS3_DECL(void) Bs3Trap16Init_c32( void); /**< @copydoc Bs3Trap16Init_c16 */2082 BS3_DECL(void) Bs3Trap16Init_c64( void); /**< @copydoc Bs3Trap16Init_c16 */2085 BS3_DECL(void) Bs3Trap16Init_c16(bool f386Plus); 2086 BS3_DECL(void) Bs3Trap16Init_c32(bool f386Plus); /**< @copydoc Bs3Trap16Init_c16 */ 2087 BS3_DECL(void) Bs3Trap16Init_c64(bool f386Plus); /**< @copydoc Bs3Trap16Init_c16 */ 2083 2088 #define Bs3Trap16Init BS3_CMN_NM(Bs3Trap16Init) /**< Selects #Bs3Trap16Init_c16, #Bs3Trap16Init_c32 or #Bs3Trap16Init_c64. */ 2084 2089
Note:
See TracChangeset
for help on using the changeset viewer.