- Timestamp:
- Mar 26, 2016 11:45:22 PM (9 years ago)
- Location:
- trunk/src/VBox/ValidationKit/bootsectors
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-basic-2-template.c
r60199 r60202 32 32 *********************************************************************************************************************************/ 33 33 #include <iprt/asm.h> 34 #include <iprt/asm-amd64-x86.h> 34 35 35 36 … … 92 93 { 93 94 Bs3TrapPrintFrame(pTrapCtx); 94 #if 0 95 # ifdef __WATCOMC__ 96 __asm hlt; 97 # else 98 __halt(); 99 # endif 100 #endif 95 ASMHalt(); 101 96 } 102 97 } … … 117 112 { 118 113 Bs3TrapPrintFrame(pTrapCtx); 119 #if 0 120 # ifdef __WATCOMC__ 121 __asm hlt; 122 # else 123 __halt(); 124 # endif 125 #endif 114 ASMHalt(); 126 115 } 127 116 } … … 397 386 * Modify the gate CS value and run the handler at a different CPL. 398 387 */ 399 # if BS3_MODE_IS_ 16BIT_SYS(TMPL_MODE)388 # if BS3_MODE_IS_32BIT_SYS(TMPL_MODE) || BS3_MODE_IS_16BIT_SYS(TMPL_MODE) 400 389 for (i = 0; i <= 3; i++) 401 390 { … … 426 415 } 427 416 } 428 //__asm hlt;429 //__asm nop;430 417 #else 431 418 i = 0; NOREF(i); -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-c16-Trap16Generic.asm
r60199 r60202 63 63 BS3_PROC_BEGIN _Bs3Trap16GenericEntries 64 64 BS3_PROC_BEGIN Bs3Trap16GenericEntries 65 %macro Bs3Trap16GenericEntry 1 66 db 06ah, i ; push imm8 - note that this is a signextended value. 67 jmp %1 65 %macro Bs3Trap16GenericEntryNoErr 1 66 push byte 0 ; 2 byte: fake error code 67 db 06ah, i ; 2 byte: push imm8 - note that this is a signextended value. 68 jmp %1 ; 3 byte 68 69 ALIGNCODE(8) 69 70 %assign i i+1 70 71 %endmacro 71 72 73 %macro Bs3Trap16GenericEntryErrCd 1 74 db 06ah, i ; 2 byte: push imm8 - note that this is a signextended value. 75 jmp %1 ; 3 byte 76 ALIGNCODE(8) 77 %assign i i+1 78 %endmacro 79 72 80 %assign i 0 ; start counter. 73 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 074 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 175 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 276 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 377 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 478 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 579 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 680 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 781 Bs3Trap16GenericEntry bs3Trap16GenericTrapErrCode; 882 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 983 Bs3Trap16GenericEntry bs3Trap16GenericTrapErrCode; a84 Bs3Trap16GenericEntry bs3Trap16GenericTrapErrCode; b85 Bs3Trap16GenericEntry bs3Trap16GenericTrapErrCode; c86 Bs3Trap16GenericEntry bs3Trap16GenericTrapErrCode; d87 Bs3Trap16GenericEntry bs3Trap16GenericTrapErrCode; e88 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; f (reserved)89 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 1090 Bs3Trap16GenericEntry bs3Trap16GenericTrapErrCode; 1191 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 1292 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 1393 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 1494 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 15 (reserved)95 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 16 (reserved)96 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 17 (reserved)97 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 18 (reserved)98 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 19 (reserved)99 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 1a (reserved)100 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 1b (reserved)101 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 1c (reserved)102 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 1d (reserved)103 Bs3Trap16GenericEntry bs3Trap16GenericTrapErrCode; 1e104 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt ; 1f (reserved)81 Bs3Trap16GenericEntryNoErr bs3Trap16GenericTrapOrInt ; 0 82 Bs3Trap16GenericEntryNoErr bs3Trap16GenericTrapOrInt ; 1 83 Bs3Trap16GenericEntryNoErr bs3Trap16GenericTrapOrInt ; 2 84 Bs3Trap16GenericEntryNoErr bs3Trap16GenericTrapOrInt ; 3 85 Bs3Trap16GenericEntryNoErr bs3Trap16GenericTrapOrInt ; 4 86 Bs3Trap16GenericEntryNoErr bs3Trap16GenericTrapOrInt ; 5 87 Bs3Trap16GenericEntryNoErr bs3Trap16GenericTrapOrInt ; 6 88 Bs3Trap16GenericEntryNoErr bs3Trap16GenericTrapOrInt ; 7 89 Bs3Trap16GenericEntryErrCd bs3Trap16GenericTrapOrInt ; 8 90 Bs3Trap16GenericEntryNoErr bs3Trap16GenericTrapOrInt ; 9 91 Bs3Trap16GenericEntryErrCd bs3Trap16GenericTrapOrInt ; a 92 Bs3Trap16GenericEntryErrCd bs3Trap16GenericTrapOrInt ; b 93 Bs3Trap16GenericEntryErrCd bs3Trap16GenericTrapOrInt ; c 94 Bs3Trap16GenericEntryErrCd bs3Trap16GenericTrapOrInt ; d 95 Bs3Trap16GenericEntryErrCd bs3Trap16GenericTrapOrInt ; e 96 Bs3Trap16GenericEntryNoErr bs3Trap16GenericTrapOrInt ; f (reserved) 97 Bs3Trap16GenericEntryNoErr bs3Trap16GenericTrapOrInt ; 10 98 Bs3Trap16GenericEntryErrCd bs3Trap16GenericTrapOrInt ; 11 99 Bs3Trap16GenericEntryNoErr bs3Trap16GenericTrapOrInt ; 12 100 Bs3Trap16GenericEntryNoErr bs3Trap16GenericTrapOrInt ; 13 101 Bs3Trap16GenericEntryNoErr bs3Trap16GenericTrapOrInt ; 14 102 Bs3Trap16GenericEntryNoErr bs3Trap16GenericTrapOrInt ; 15 (reserved) 103 Bs3Trap16GenericEntryNoErr bs3Trap16GenericTrapOrInt ; 16 (reserved) 104 Bs3Trap16GenericEntryNoErr bs3Trap16GenericTrapOrInt ; 17 (reserved) 105 Bs3Trap16GenericEntryNoErr bs3Trap16GenericTrapOrInt ; 18 (reserved) 106 Bs3Trap16GenericEntryNoErr bs3Trap16GenericTrapOrInt ; 19 (reserved) 107 Bs3Trap16GenericEntryNoErr bs3Trap16GenericTrapOrInt ; 1a (reserved) 108 Bs3Trap16GenericEntryNoErr bs3Trap16GenericTrapOrInt ; 1b (reserved) 109 Bs3Trap16GenericEntryNoErr bs3Trap16GenericTrapOrInt ; 1c (reserved) 110 Bs3Trap16GenericEntryNoErr bs3Trap16GenericTrapOrInt ; 1d (reserved) 111 Bs3Trap16GenericEntryErrCd bs3Trap16GenericTrapOrInt ; 1e 112 Bs3Trap16GenericEntryNoErr bs3Trap16GenericTrapOrInt ; 1f (reserved) 105 113 %rep 224 106 Bs3Trap16GenericEntry bs3Trap16GenericTrapOrInt114 Bs3Trap16GenericEntryNoErr bs3Trap16GenericTrapOrInt 107 115 %endrep 108 116 BS3_PROC_END Bs3Trap16GenericEntries 109 110 117 AssertCompile(Bs3Trap16GenericEntries_EndProc - Bs3Trap16GenericEntries == 8*256) 111 118 112 119 113 120 ;; 114 ; 80386+: Trap or interrupt (no error code). 121 ; Trap or interrupt with error code, faked if necessary. 122 ; 123 ; Note! This code is going to "misbehave" if the high word of ESP is not cleared. 115 124 ; 116 125 BS3_PROC_BEGIN _bs3Trap16GenericTrapOrInt 117 126 BS3_PROC_BEGIN bs3Trap16GenericTrapOrInt 118 127 CPU 386 119 jmp near bs3Trap16GenericTrapOrInt80286 ; Bs3Trap16Init adjusts this on 80386+ 120 push ebp 121 movzx ebp, sp 122 push ebx ; BP - 04h 123 pushfd ; BP - 08h 124 cld 125 push edx ; BP - 0ch 126 push ss ; BP - 0eh 127 push esp ; BP - 12h 128 129 ; 130 ; We may be comming from 32-bit code where SS is flat and ESP has a non- 131 ; zero high word. We need to thunk it for C code to work correctly with 132 ; [BP+xx] and [SS:BX+xx] style addressing that leaves out the high word. 133 ; 134 ; Note! Require ring-0 handler for non-standard stacks (SS.DPL must equal CPL). 135 ; 136 mov bx, ss 137 lar ebx, bx 138 test ebx, X86LAR_F_D 139 jz .stack_fine 140 test esp, 0ffff0000h 141 jnz .stack_thunk 142 .stack_load_r0_ss16: 143 mov bx, ss 144 and bl, 3 145 AssertCompile(BS3_SEL_RING_SHIFT == 8) 146 mov bh, bl 147 add bx, BS3_SEL_R0_SS16 148 jmp .stack_load_bx_into_ss 149 .stack_thunk: 150 mov ebx, esp 151 shr ebx, 16 152 shl ebx, X86_SEL_SHIFT 153 add ebx, BS3_SEL_TILED_R0 154 cmp ebx, BS3_SEL_TILED_R0_LAST 155 ja .stack_esp_out_of_bounds 156 .stack_load_bx_into_ss: 157 mov ss, bx 158 .stack_fine: 159 movzx esp, sp 160 161 ; Reserve space for the the register and trap frame. 162 mov bx, (BS3TRAPFRAME_size + 7) / 8 163 .more_zeroed_space: 164 push 0 165 push 0 166 push 0 167 push 0 168 dec bx 169 jnz .more_zeroed_space 170 movzx ebx, sp 171 172 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rax], eax 173 mov edx, [bp - 12h] 174 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rsp], edx 175 mov [ss:bx + BS3TRAPFRAME.uHandlerRsp], edx 176 mov dx, [bp - 0eh] 177 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.ss], dx 178 mov [ss:bx + BS3TRAPFRAME.uHandlerSs], dx 179 mov edx, [bp - 0ch] 180 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rdx], edx 181 mov edx, [bp - 8] 182 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rflags], edx ; high bits 183 mov [ss:bx + BS3TRAPFRAME.fHandlerRfl], edx 184 mov edx, [bp - 4] 185 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rbx], edx 186 mov edx, [bp] 187 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rbp], edx 188 189 mov dl, [bp + 4] 190 mov [ss:bx + BS3TRAPFRAME.bXcpt], dl 191 192 add bp, 4 ; adjust so it points to the word before the iret frame. 193 xor dx, dx 194 jmp bs3Trap16GenericCommon 195 196 .stack_esp_out_of_bounds: 197 %ifdef BS3_STRICT 198 int3 199 %endif 200 jmp .stack_load_bx_into_ss 201 BS3_PROC_END bs3Trap16GenericTrapOrInt 202 203 204 ;; 205 ; 80286: Trap or interrupt (no error code) 206 ; 207 BS3_PROC_BEGIN bs3Trap16GenericTrapOrInt80286 208 CPU 286 209 push bp 210 mov bp, sp 211 push bx 212 pushf 213 cld 214 215 ; Reserve space for the the register and trap frame. 216 mov bx, (BS3TRAPFRAME_size + 7) / 8 217 .more_zeroed_space: 218 push 0 219 push 0 220 push 0 221 push 0 222 dec bx 223 jnz .more_zeroed_space 224 mov bx, sp 225 226 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rax], ax 227 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.ss], ss 228 mov [ss:bx + BS3TRAPFRAME.uHandlerSs], ss 229 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rdx], dx 230 mov dx, [bp - 4] 231 mov [ss:bx + BS3TRAPFRAME.fHandlerRfl], dx 232 mov dx, [bp - 2] 233 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rbx], dx 234 mov dx, [bp] 235 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rbp], dx 236 237 mov dl, [bp + 4] 238 mov [ss:bx + BS3TRAPFRAME.bXcpt], dl 239 240 add bp, 4 ; adjust so it points to the word before the iret frame. 241 mov dx, 1 242 jmp bs3Trap16GenericCommon 243 BS3_PROC_END bs3Trap16GenericTrapOrInt80286 244 245 246 ;; 247 ; Trap with error code. 248 ; 249 ; Note! This code is going to "misbehave" if the high word of ESP is not cleared. 250 ; 251 BS3_PROC_BEGIN _bs3Trap16GenericTrapErrCode 252 BS3_PROC_BEGIN bs3Trap16GenericTrapErrCode 253 CPU 386 254 jmp near bs3Trap16GenericTrapOrInt80286 ; Bs3Trap16Init adjusts this on 80386+ 128 jmp near bs3Trap16GenericTrapErrCode80286 ; Bs3Trap16Init adjusts this on 80386+ 255 129 push ebp 256 130 movzx ebp, sp -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-c32-Trap32Generic.asm
r60184 r60202 68 68 ; 69 69 BS3_PROC_BEGIN Bs3Trap32GenericEntries 70 %macro Bs3Trap32GenericEntry 1 71 db 06ah, i ; push imm8 - note that this is a signextended value. 72 jmp %1 73 ALIGNCODE(8) 70 %macro Bs3Trap32GenericEntryNoErr 1 71 push byte 0 ; 2 byte: fake error code. 72 db 06ah, i ; 2 byte: push imm8 - note that this is a signextended value. 73 jmp near %1 ; 5 byte 74 ALIGNCODE(2) 74 75 %assign i i+1 75 76 %endmacro 76 77 78 %macro Bs3Trap32GenericEntryErrCd 1 79 db 06ah, i ; 2 byte: push imm8 - note that this is a signextended value. 80 jmp near %1 ; 5 byte 81 db 0cch, 0cch ; 2 byte: padding. 82 ALIGNCODE(2) 83 %assign i i+1 84 %endmacro 85 77 86 %assign i 0 ; start counter. 78 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 079 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 180 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 281 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 382 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 483 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 584 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 685 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 786 Bs3Trap32GenericEntry bs3Trap32GenericTrapErrCode; 887 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 988 Bs3Trap32GenericEntry bs3Trap32GenericTrapErrCode; a89 Bs3Trap32GenericEntry bs3Trap32GenericTrapErrCode; b90 Bs3Trap32GenericEntry bs3Trap32GenericTrapErrCode; c91 Bs3Trap32GenericEntry bs3Trap32GenericTrapErrCode; d92 Bs3Trap32GenericEntry bs3Trap32GenericTrapErrCode; e93 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; f (reserved)94 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 1095 Bs3Trap32GenericEntry bs3Trap32GenericTrapErrCode; 1196 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 1297 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 1398 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 1499 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 15 (reserved)100 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 16 (reserved)101 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 17 (reserved)102 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 18 (reserved)103 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 19 (reserved)104 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 1a (reserved)105 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 1b (reserved)106 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 1c (reserved)107 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 1d (reserved)108 Bs3Trap32GenericEntry bs3Trap32GenericTrapErrCode; 1e109 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 1f (reserved)87 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 0 88 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 1 89 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 2 90 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 3 91 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 4 92 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 5 93 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 6 94 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 7 95 Bs3Trap32GenericEntryErrCd bs3Trap32GenericTrapOrInt ; 8 96 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 9 97 Bs3Trap32GenericEntryErrCd bs3Trap32GenericTrapOrInt ; a 98 Bs3Trap32GenericEntryErrCd bs3Trap32GenericTrapOrInt ; b 99 Bs3Trap32GenericEntryErrCd bs3Trap32GenericTrapOrInt ; c 100 Bs3Trap32GenericEntryErrCd bs3Trap32GenericTrapOrInt ; d 101 Bs3Trap32GenericEntryErrCd bs3Trap32GenericTrapOrInt ; e 102 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; f (reserved) 103 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 10 104 Bs3Trap32GenericEntryErrCd bs3Trap32GenericTrapOrInt ; 11 105 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 12 106 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 13 107 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 14 108 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 15 (reserved) 109 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 16 (reserved) 110 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 17 (reserved) 111 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 18 (reserved) 112 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 19 (reserved) 113 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 1a (reserved) 114 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 1b (reserved) 115 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 1c (reserved) 116 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 1d (reserved) 117 Bs3Trap32GenericEntryErrCd bs3Trap32GenericTrapOrInt ; 1e 118 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 1f (reserved) 110 119 %rep 224 111 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt120 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt 112 121 %endrep 113 122 BS3_PROC_END Bs3Trap32GenericEntries 114 115 123 AssertCompile(Bs3Trap32GenericEntries_EndProc - Bs3Trap32GenericEntries == 10*256) 116 124 117 125 118 126 ;; 119 ; Trap or interrupt (no error code).127 ; Trap or interrupt with error code, faked if necessary. 120 128 ; 121 129 BS3_PROC_BEGIN bs3Trap32GenericTrapOrInt … … 123 131 mov ebp, esp 124 132 pushfd ; -04h 125 cli126 133 cld 127 134 push eax ; -08h 128 135 push edi ; -0ch 129 lea eax, [esp + (4 + 1)*4] ; 4 pushes above, 1 exception number push.136 lea eax, [esp + (4+1+1)*4] ; 4 pushes above, 1 exception number push, 1 error code. 130 137 push eax ; -10h = handler ESP 131 138 add eax, 3*4 ; 3 dword iret frame … … 135 142 136 143 ; Make sure we've got a flat DS (ASSUMES ring-0). It makes everything so much simpler. 137 mov ax, BS3_SEL_R0_DS32 144 mov ax, ss 145 and al, 3 146 AssertCompile(BS3_SEL_RING_SHIFT == 8) 147 mov ah, al 148 add ax, BS3_SEL_R0_DS32 138 149 mov ds, ax 139 150 … … 147 158 test eax, X86LAR_F_D 148 159 jz .stack_thunk 149 mov ax, BS3_SEL_R0_SS32 160 mov ax, ss 161 and al, 3 162 AssertCompile(BS3_SEL_RING_SHIFT == 8) 163 mov ah, al 164 add ax, BS3_SEL_R0_SS32 150 165 mov ss, ax 151 166 jmp .stack_flat … … 160 175 add ebp, eax 161 176 movzx edi, sp ; SS:SP -> flat ESP in EAX. 162 add eax, edi 163 mov di, BS3_SEL_R0_SS32 164 mov ss, di 165 mov esp, eax 177 add edi, eax 178 mov ax, ss 179 and al, 3 180 AssertCompile(BS3_SEL_RING_SHIFT == 8) 181 mov ah, al 182 add ax, BS3_SEL_R0_SS32 183 mov ss, ax 184 mov esp, edi 166 185 sub dword [ebp - 10h], (4+1)*4 ; Recalc handler ESP in case of wraparound. 167 186 add word [ebp - 10h], (4+1)*4 168 187 sub dword [ebp - 10h], (4+1+3)*4 ; Recalc caller ESP in case of wraparound. 169 188 add word [ebp - 10h], (4+1+3)*4 170 .stack_flat:171 172 ; Reserve space for the the register and trap frame.173 mov eax, (BS3TRAPFRAME_size + 7) / 8174 AssertCompileSizeAlignment(BS3TRAPFRAME, 8)175 .more_zeroed_space:176 push dword 0177 push dword 0178 dec eax179 jnz .more_zeroed_space180 mov edi, esp ; edi points to trapframe structure.181 182 ; Copy stuff from the stack over.183 mov al, [ebp + 4]184 mov [edi + BS3TRAPFRAME.bXcpt], al185 mov eax, [ebp]186 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rbp], eax187 mov eax, [ebp - 04h]188 mov [edi + BS3TRAPFRAME.fHandlerRfl], eax189 mov eax, [ebp - 08h]190 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rax], eax191 mov eax, [ebp - 0ch]192 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rdi], eax193 mov eax, [ebp - 10h]194 mov [edi + BS3TRAPFRAME.uHandlerRsp], eax195 mov eax, [ebp - 14h]196 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rsp], eax197 mov ax, [ebp - 18h]198 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.ss], ax199 mov [edi + BS3TRAPFRAME.uHandlerSs], ax200 mov ax, [ebp - 1ch]201 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.ds], ax202 203 lea ebp, [ebp + 4] ; iret - 4 (i.e. ebp frame chain location)204 jmp bs3Trap32GenericCommon205 BS3_PROC_END bs3Trap32GenericTrapOrInt206 207 208 ;;209 ; Trap with error code.210 ;211 BS3_PROC_BEGIN bs3Trap32GenericTrapErrCode212 push ebp ; 0213 mov ebp, esp214 pushfd ; -04h215 cli216 cld217 push eax ; -08h218 push edi ; -0ch219 lea eax, [esp + (4+1+1)*4] ; 4 pushes above, 1 exception number push, 1 error code.220 push eax ; -10h = handler ESP221 add eax, 3*4 ; 3 dword iret frame222 push eax ; -14h = caller ESP if same CPL223 push ss ; -18h224 push ds ; -1ch225 226 ; Make sure we've got a flat DS (ASSUMES ring-0). It makes everything so much simpler.227 mov ax, BS3_SEL_R0_DS32228 mov ds, ax229 230 ;231 ; We may be comming from 16-bit code with a 16-bit SS. Thunk it as232 ; the C code may assume flat SS and we'll mess up by using EBP/ESP/EDI233 ; instead of BP/SP/SS:DI. ASSUMES standard GDT selector.234 ;235 mov ax, ss236 lar eax, ax237 test eax, X86LAR_F_D238 jz .stack_thunk239 mov ax, BS3_SEL_R0_SS32240 mov ss, ax241 jmp .stack_flat242 .stack_thunk:243 mov di, ss244 and edi, X86_SEL_MASK_OFF_RPL245 mov al, [X86DESCGENERIC_BIT_OFF_BASE_HIGH1 / 8 + edi + Bs3Gdt wrt FLAT]246 mov ah, [X86DESCGENERIC_BIT_OFF_BASE_HIGH2 / 8 + edi + Bs3Gdt wrt FLAT]247 shl eax, 16248 mov ax, [X86DESCGENERIC_BIT_OFF_BASE_LOW / 8 + edi + Bs3Gdt wrt FLAT] ; eax = SS.base249 movzx ebp, bp ; SS:BP -> flat EBP.250 add ebp, eax251 movzx edi, sp ; SS:SP -> flat ESP in EAX.252 add eax, edi253 mov di, BS3_SEL_R0_SS32254 mov ss, di255 mov esp, eax256 sub dword [ebp - 10h], (4+1+1)*4 ; Recalc handler ESP in case of wraparound.257 add word [ebp - 10h], (4+1+1)*4258 sub dword [ebp - 14h], (4+1+1+3)*4 ; Recalc caller ESP in case of wraparound.259 add word [ebp - 14h], (4+1+1+3)*4260 189 .stack_flat: 261 190 … … 319 248 ; would be saved if this was a normal call. 320 249 ; 250 ; @remarks This is a separate function for hysterical raisins. 251 ; 321 252 BS3_PROC_BEGIN bs3Trap32GenericCommon 322 253 ; … … 343 274 mov ax, cs 344 275 mov [edi + BS3TRAPFRAME.uHandlerCs], ax 345 and ax, 3 346 mov cx, ax 347 shl ax, BS3_SEL_RING_SHIFT 348 or ax, cx 276 and al, 3 277 AssertCompile(BS3_SEL_RING_SHIFT == 8) 278 mov ah, al 349 279 add ax, BS3_SEL_R0_DS32 350 280 mov ds, ax … … 411 341 ; Control registers. 412 342 ; 343 str ax 344 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.tr], ax 345 sldt ax 346 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.ldtr], ax 347 348 mov ax, ss 349 test al, 3 350 jnz .skip_crX_because_cpl_not_0 351 413 352 mov eax, cr0 414 353 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.cr0], eax … … 419 358 mov eax, cr4 420 359 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.cr4], eax 421 str ax 422 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.tr], ax 423 sldt ax 424 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.ldtr], ax 360 jmp .dispatch_to_handler 361 .skip_crX_because_cpl_not_0: 362 or byte [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.fbFlags], BS3REG_CTX_F_NO_CR 425 363 426 364 ; -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Trap16Init.c
r60088 r60202 43 43 /* These two are ugly. Need data access for patching purposes. */ 44 44 extern uint8_t BS3_FAR_DATA bs3Trap16GenericTrapOrInt[]; 45 extern uint8_t BS3_FAR_DATA bs3Trap16GenericTrapErrCode[];46 45 47 46 … … 57 56 if (f386Plus) 58 57 { 59 uint8_t BS3_FAR_DATA *pbFunction = &bs3Trap16GenericTrapErrCode[0]; 60 #if ARCH_BITS == 16 61 if (g_bBs3CurrentMode != BS3_MODE_RM) 62 pbFunction = (uint8_t BS3_FAR_DATA *)BS3_FP_MAKE(BS3_SEL_TILED + 1, BS3_FP_OFF(pbFunction)); 63 #endif 64 pbFunction[1] = 0; 65 pbFunction[2] = 0; 66 67 pbFunction = &bs3Trap16GenericTrapOrInt[0]; 58 uint8_t BS3_FAR_DATA *pbFunction = &bs3Trap16GenericTrapOrInt[0]; 68 59 #if ARCH_BITS == 16 69 60 if (g_bBs3CurrentMode != BS3_MODE_RM) -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Trap32Init.c
r59984 r60202 47 47 for (iIdt = 0; iIdt < BS3_TRAP_SYSCALL; iIdt++) 48 48 Bs3Trap32SetGate(iIdt, X86_SEL_TYPE_SYS_386_INT_GATE, 0 /*bDpl*/, 49 BS3_SEL_R0_CS32, BS3_DATA_NM(g_Bs3Trap32GenericEntriesFlatAddr) + iIdt * 8, 0 /*cParams*/);49 BS3_SEL_R0_CS32, BS3_DATA_NM(g_Bs3Trap32GenericEntriesFlatAddr) + iIdt * 10, 0 /*cParams*/); 50 50 for (iIdt = BS3_TRAP_SYSCALL + 1; iIdt < 256; iIdt++) 51 51 Bs3Trap32SetGate(iIdt, X86_SEL_TYPE_SYS_386_INT_GATE, 0 /*bDpl*/, 52 BS3_SEL_R0_CS32, BS3_DATA_NM(g_Bs3Trap32GenericEntriesFlatAddr) + iIdt * 8, 0 /*cParams*/);52 BS3_SEL_R0_CS32, BS3_DATA_NM(g_Bs3Trap32GenericEntriesFlatAddr) + iIdt * 10, 0 /*cParams*/); 53 53 54 54 /* -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-TrapSystemCallHandler.asm
r60199 r60202 544 544 .save_context_full: 545 545 546 ; Clear the state area first unless 64-bit mode. 547 %if TMPL_BITS != 64 546 ; Clear the state area. 548 547 push xDI 549 548 xor xDI, xDI 550 .save_context_32_clear_loop: 549 AssertCompileSizeAlignment(BS3REGCTX, 16) 550 .save_context_full_clear_loop: 551 %if TMPL_BITS != 64 551 552 mov dword [ss:xBX + xDI], 0 552 553 mov dword [ss:xBX + xDI + 4], 0 553 554 add xDI, 8 555 %else 556 mov qword [xBX + xDI], 0 557 mov qword [xBX + xDI + 8], 0 558 add xDI, 10h 559 %endif 554 560 cmp xDI, BS3REGCTX_size 555 jb .save_context_ 32_clear_loop561 jb .save_context_full_clear_loop 556 562 pop xDI 557 %endif558 563 559 564 ; Do the 386+ state saving. -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.h
r60199 r60202 1832 1832 BS3REG cr3; /**< 0xb8 */ 1833 1833 BS3REG cr4; /**< 0xc0 */ 1834 uint64_t uUnused; /**< 0xc8 */ 1834 1835 } BS3REGCTX; 1836 AssertCompileSize(BS3REGCTX, 0xd0); 1835 1837 /** Pointer to a register context. */ 1836 1838 typedef BS3REGCTX BS3_FAR *PBS3REGCTX; … … 2016 2018 /** The address of Bs3Trap32GenericEntries. 2017 2019 * Bs3Trap32GenericEntries is an array of interrupt/trap/whatever entry 2018 * points, 8bytes each, that will create a register frame and call the generic2020 * points, 10 bytes each, that will create a register frame and call the generic 2019 2021 * C compatible trap handlers. */ 2020 2022 extern uint32_t BS3_DATA_NM(g_Bs3Trap32GenericEntriesFlatAddr); -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.mac
r60199 r60202 1163 1163 .cr3 resq 1 ; BS3REG cr3; /**< 0xb8 */ 1164 1164 .cr4 resq 1 ; BS3REG cr4; /**< 0xc0 */ 1165 .uUnused resq 1 ; BS3REG uUnused; /**< 0xc8 */ 1165 1166 endstruc 1166 1167
Note:
See TracChangeset
for help on using the changeset viewer.