- 時間撮記:
- 2016-3-11 下午07:12:05 (9 年 以前)
- 位置:
- trunk/src/VBox/ValidationKit/bootsectors/bs3kit
- 檔案:
-
- 新增 1 筆資料
- 修改 18 筆資料
- 複製 1 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk
r59984 r60000 99 99 bs3-cmn-SwitchToRing2.asm \ 100 100 bs3-cmn-SwitchToRing3.asm \ 101 bs3-cmn-SwitchToRingX.asm \ 101 102 bs3-cmn-SwitchTo16Bit.asm \ 102 103 bs3-cmn-SwitchTo16BitV86.asm \ 103 104 bs3-cmn-SwitchTo32Bit.asm \ 104 105 bs3-cmn-SwitchTo64Bit.asm \ 106 bs3-cmn-Syscall.asm \ 105 107 bs3-cmn-TestData.c \ 106 108 bs3-cmn-TestInit.c \ -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-c16-Trap16Generic.asm
r59984 r60000 39 39 ;********************************************************************************************************************************* 40 40 BS3_EXTERN_DATA16 g_bBs3CurrentMode 41 BS3_EXTERN_DATA16 g_uBs3TrapEipHint 41 42 BS3_EXTERN_SYSTEM16 Bs3Gdt 42 43 TMPL_BEGIN_TEXT … … 149 150 150 151 add bp, 4 ; adjust so it points to the word before the iret frame. 152 xor dx, dx 151 153 jmp bs3Trap16GenericCommon 152 154 BS3_PROC_END bs3Trap16GenericTrapOrInt … … 190 192 191 193 add bp, 4 ; adjust so it points to the word before the iret frame. 194 mov dx, 1 192 195 jmp bs3Trap16GenericCommon 193 196 BS3_PROC_END bs3Trap16GenericTrapOrInt80286 … … 237 240 238 241 add bp, 6 ; adjust so it points to the word before the iret frame. 242 xor dx, dx 239 243 jmp bs3Trap16GenericCommon 240 244 BS3_PROC_END bs3Trap16GenericTrapErrCode … … 281 285 282 286 add bp, 4 ; adjust so it points to the word before the iret frame. 287 mov dl, 1 283 288 jmp bs3Trap16GenericCommon 284 289 BS3_PROC_END bs3Trap16GenericTrapErrCode80286 … … 320 325 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rdi], edi 321 326 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rsi], esi 327 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rsp], esp ; high word 322 328 jmp .save_segment_registers 323 329 .save_word_grps: … … 344 350 shl ax, BS3_SEL_RING_SHIFT 345 351 or ax, cx 346 add ax, BS3_SEL_R0_DS 32352 add ax, BS3_SEL_R0_DS16 347 353 mov ds, ax 348 354 mov es, ax … … 391 397 lea eax, [ebp + 12] 392 398 mov [ss:bx + BS3TRAPFRAME.uHandlerRsp], eax 393 jmp .iret_frame_ done399 jmp .iret_frame_seed_high_eip_word 394 400 .ret_frame_different_cpl_286: 395 401 CPU 286 … … 411 417 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rsp], ecx 412 418 mov [ss:bx + BS3TRAPFRAME.uHandlerRsp], ecx 413 jmp .iret_frame_ done419 jmp .iret_frame_seed_high_eip_word 414 420 .iret_frame_same_cpl_286: 415 421 CPU 286 … … 438 444 mov [ss:bx + BS3TRAPFRAME.uHandlerRsp], eax 439 445 jmp .iret_frame_done 446 447 ; 448 ; For 386 we do special tricks to supply the high word of EIP when 449 ; arriving here from 32-bit code. (ESP was seeded earlier.) 450 ; 451 .iret_frame_seed_high_eip_word: 452 lar eax, [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.cs] 453 jnz .iret_frame_done 454 test eax, X86LAR_F_D 455 jz .iret_frame_done 456 mov ax, [g_uBs3TrapEipHint+2] 457 mov [ss:bx + BS3TRAPFRAME.Ctx + BS3REGCTX.rip + 2], ax 440 458 441 459 .iret_frame_done: -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PerCpuData.c
r59938 r60000 41 41 #if ARCH_BITS == 16 42 42 43 uint8_t BS3_DATA_NM(g_bBs3CurrentMode) = BS3_MODE_RM; 43 /** The current CPU mode. */ 44 uint8_t BS3_DATA_NM(g_bBs3CurrentMode) = BS3_MODE_RM; 45 46 /** Hint for 16-bit trap handlers regarding the high word of EIP. */ 47 uint32_t BS3_DATA_NM(g_uBs3TrapEipHint) = 0; 48 44 49 45 50 #endif /* ARCH_BITS == 16 */ -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PrintChr.asm
r59984 r60000 25 25 ; 26 26 27 28 ;********************************************************************************************************************************* 29 ;* Header Files * 30 ;********************************************************************************************************************************* 27 31 %include "bs3kit-template-header.mac" 32 33 34 ;********************************************************************************************************************************* 35 ;* External Symbols * 36 ;********************************************************************************************************************************* 37 %if TMPL_BITS == 16 38 BS3_EXTERN_DATA16 g_bBs3CurrentMode 39 %endif 40 BS3_EXTERN_CMN Bs3Syscall 41 42 43 TMPL_BEGIN_TEXT 28 44 29 45 ;; … … 38 54 push xBX 39 55 40 %ifdef TMPL_16BIT 41 ; If we're not in protected mode, call the VGA BIOS directly. 42 smsw bx 43 test bx, X86_CR0_PE 44 jnz .protected_mode 56 %if TMPL_BITS == 16 57 ; If we're in real mode or v8086 mode, call the VGA BIOS directly. 58 mov bl, [g_bBs3CurrentMode] 59 cmp bl, BS3_MODE_RM 60 je .do_vga_bios_call 61 ;later ; and bl, BS3_MODE_CODE_MASK 62 ;later ; cmp bl, BS3_MODE_CODE_V86 63 jne .do_system_call 45 64 65 .do_vga_bios_call: 46 66 mov al, [xBP + xCB*2] ; Load the char 47 67 mov bx, 0ff00h … … 49 69 int 10h 50 70 jmp .return 51 52 .protected_mode:53 71 %endif 54 72 73 .do_system_call: 55 74 mov cl, [xBP + xCB*2] ; Load the char 56 75 mov ax, BS3_SYSCALL_PRINT_CHR 57 int BS3_TRAP_SYSCALL76 call Bs3Syscall ; (no BS3_CALL!) 58 77 59 78 .return: -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-RegCtxRestore.asm
r59976 r60000 224 224 225 225 ; TR - complicated because we need to clear the busy bit. ASSUMES GDT. 226 BS3_ONLY_64BIT_STMT hlt 226 227 str ax 227 228 cmp ax, [xBX + BS3REGCTX.tr] -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchTo16Bit.asm
r59977 r60000 28 28 29 29 BS3_EXTERN_DATA16 g_bBs3CurrentMode 30 %if TMPL_BITS == 16 31 BS3_EXTERN_CMN Bs3Syscall 32 %endif 30 33 TMPL_BEGIN_TEXT 31 34 … … 41 44 42 45 ; Check g_bBs3CurrentMode whether we're in v8086 mode or not. 43 mov ax, seg g_bBs3CurrentMode44 mov ds, ax45 46 mov al, [BS3_DATA16_WRT(g_bBs3CurrentMode)] 46 47 and al, BS3_MODE_CODE_MASK … … 50 51 ; Switch to ring-0 if v8086 mode. 51 52 mov ax, BS3_SYSCALL_TO_RING0 52 lock int BS3_TRAP_SYSCALL53 call Bs3Syscall 53 54 54 55 .ret_16bit: -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchTo32Bit.asm
r59949 r60000 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 … … 30 30 %if TMPL_BITS == 16 31 31 BS3_EXTERN_CMN Bs3SelProtFar32ToFlat32 32 BS3_EXTERN_CMN Bs3Syscall 32 33 %endif 33 34 %if TMPL_BITS != 32 … … 75 76 ; Switch to 16-bit ring0 and go on to do the far jump to 32-bit code. 76 77 mov ax, BS3_SYSCALL_TO_RING0 77 int BS3_TRAP_SYSCALL78 call Bs3Syscall 78 79 79 80 mov xAX, BS3_SEL_R0_CS32 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchToRing0.asm
r59976 r60000 25 25 ; 26 26 27 ;********************************************************************************************************************************* 28 ;* Header Files * 29 ;********************************************************************************************************************************* 27 30 %include "bs3kit-template-header.mac" 28 31 29 32 30 %if TMPL_BITS == 16 31 BS3_EXTERN_DATA16 g_bBs3CurrentMode 32 %endif 33 ;********************************************************************************************************************************* 34 ;* External Symbols * 35 ;********************************************************************************************************************************* 36 BS3_EXTERN_CMN Bs3SwitchToRingX 33 37 TMPL_BEGIN_TEXT 34 38 … … 40 44 ; 41 45 BS3_PROC_BEGIN_CMN Bs3SwitchToRing0 42 push xAX 43 44 %if TMPL_BITS == 16 45 ; Check the current mode. 46 push ds 47 mov ax, seg g_bBs3CurrentMode 48 mov ds, ax 49 mov al, [BS3_DATA16_WRT(g_bBs3CurrentMode)] 50 pop ds 51 52 ; If real mode: Nothing to do, it's considered ring-0 here. 53 cmp al, BS3_MODE_RM 54 je .return 55 56 ; If V8086 mode: Always do syscall and add a lock prefix to make sure it gets to the VMM. 57 and al, BS3_MODE_CODE_MASK 58 cmp al, BS3_MODE_CODE_V86 59 jne .not_v8086 60 61 mov xAX, BS3_SYSCALL_TO_RING0 62 lock int BS3_TRAP_SYSCALL 63 jmp .return 64 65 .not_v8086: 66 %endif 67 68 ; In protected mode: Check the CPL we're currently at skip syscall if ring-0 already. 69 mov ax, cs 70 test ax, 3 71 jz .return 72 73 mov xAX, BS3_SYSCALL_TO_RING0 74 int BS3_TRAP_SYSCALL 75 76 .return: 77 pop xAX 46 BS3_ONLY_64BIT_STMT sub rsp, 18h 47 push 0 48 BS3_CALL Bs3SwitchToRingX, 1 49 add xSP, xCB BS3_ONLY_64BIT(+ 18h) 78 50 ret 79 51 BS3_PROC_END_CMN Bs3SwitchToRing0 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchToRing1.asm
r59949 r60000 25 25 ; 26 26 27 ;********************************************************************************************************************************* 28 ;* Header Files * 29 ;********************************************************************************************************************************* 27 30 %include "bs3kit-template-header.mac" 28 31 29 32 30 %if TMPL_BITS == 16 31 BS3_EXTERN_DATA16 g_bBs3CurrentMode 32 %endif 33 ;********************************************************************************************************************************* 34 ;* External Symbols * 35 ;********************************************************************************************************************************* 36 BS3_EXTERN_CMN Bs3SwitchToRingX 33 37 TMPL_BEGIN_TEXT 34 38 … … 40 44 ; 41 45 BS3_PROC_BEGIN_CMN Bs3SwitchToRing1 42 push xAX 43 44 %if TMPL_BITS == 16 45 ; Check the current mode. 46 push ds 47 mov ax, seg g_bBs3CurrentMode 48 mov ds, ax 49 mov al, [BS3_DATA16_WRT(g_bBs3CurrentMode)] 50 pop ds 51 52 ; If real mode: assert, shouldn't call this function in real mode! 53 cmp al, BS3_MODE_RM 54 jne .not_real_mode 55 int3 56 jmp .return 57 .not_real_mode: 58 59 ; If V8086 mode: Have to make the system call (v8086 mode is kind of like ring-3). 60 and al, BS3_MODE_CODE_MASK 61 cmp al, BS3_MODE_CODE_V86 62 je .just_do_it 63 %endif 64 65 ; In protected mode: Check the CPL we're currently at skip syscall if ring-1 already. 66 mov ax, cs 67 and ax, 3 68 cmp ax, 1 69 je .return 70 71 .just_do_it: 72 mov xAX, BS3_SYSCALL_TO_RING1 73 int BS3_TRAP_SYSCALL 74 75 .return: 76 pop xAX 46 BS3_ONLY_64BIT_STMT sub rsp, 18h 47 push 1 48 BS3_CALL Bs3SwitchToRingX, 1 49 add xSP, xCB BS3_ONLY_64BIT(+ 18h) 77 50 ret 78 51 BS3_PROC_END_CMN Bs3SwitchToRing1 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchToRing2.asm
r59949 r60000 25 25 ; 26 26 27 ;********************************************************************************************************************************* 28 ;* Header Files * 29 ;********************************************************************************************************************************* 27 30 %include "bs3kit-template-header.mac" 28 31 29 32 30 %if TMPL_BITS == 16 31 BS3_EXTERN_DATA16 g_bBs3CurrentMode 32 %endif 33 ;********************************************************************************************************************************* 34 ;* External Symbols * 35 ;********************************************************************************************************************************* 36 BS3_EXTERN_CMN Bs3SwitchToRingX 33 37 TMPL_BEGIN_TEXT 34 38 … … 40 44 ; 41 45 BS3_PROC_BEGIN_CMN Bs3SwitchToRing2 42 push xAX 43 44 %if TMPL_BITS == 16 45 ; Check the current mode. 46 push ds 47 mov ax, seg g_bBs3CurrentMode 48 mov ds, ax 49 mov al, [BS3_DATA16_WRT(g_bBs3CurrentMode)] 50 pop ds 51 52 ; If real mode: assert, shouldn't call this function in real mode! 53 cmp al, BS3_MODE_RM 54 jne .not_real_mode 55 int3 56 jmp .return 57 .not_real_mode: 58 59 ; If V8086 mode: Have to make the system call (v8086 mode is kind of like ring-3). 60 and al, BS3_MODE_CODE_MASK 61 cmp al, BS3_MODE_CODE_V86 62 je .just_do_it 63 %endif 64 65 ; In protected mode: Check the CPL we're currently at skip syscall if ring-2 already. 66 mov ax, cs 67 and ax, 3 68 cmp ax, 2 69 je .return 70 71 .just_do_it: 72 mov xAX, BS3_SYSCALL_TO_RING2 73 int BS3_TRAP_SYSCALL 74 75 .return: 76 pop xAX 46 BS3_ONLY_64BIT_STMT sub rsp, 18h 47 push 2 48 BS3_CALL Bs3SwitchToRingX, 1 49 add xSP, xCB BS3_ONLY_64BIT(+ 18h) 77 50 ret 78 51 BS3_PROC_END_CMN Bs3SwitchToRing2 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchToRing3.asm
r59949 r60000 25 25 ; 26 26 27 ;********************************************************************************************************************************* 28 ;* Header Files * 29 ;********************************************************************************************************************************* 27 30 %include "bs3kit-template-header.mac" 28 31 29 32 30 %if TMPL_BITS == 16 31 BS3_EXTERN_DATA16 g_bBs3CurrentMode 32 %endif 33 ;********************************************************************************************************************************* 34 ;* External Symbols * 35 ;********************************************************************************************************************************* 36 BS3_EXTERN_CMN Bs3SwitchToRingX 33 37 TMPL_BEGIN_TEXT 34 38 … … 40 44 ; 41 45 BS3_PROC_BEGIN_CMN Bs3SwitchToRing3 42 push xAX 43 44 %if TMPL_BITS == 16 45 ; Check the current mode. 46 push ds 47 mov ax, seg g_bBs3CurrentMode 48 mov ds, ax 49 mov al, [BS3_DATA16_WRT(g_bBs3CurrentMode)] 50 pop ds 51 52 ; If real mode: assert, shouldn't call this function in real mode! 53 cmp al, BS3_MODE_RM 54 jne .not_real_mode 55 int3 56 jmp .return 57 .not_real_mode: 58 59 ; If V8086 mode: Have to make the system call (we don't consider v8086 ring-3 here). 60 and al, BS3_MODE_CODE_MASK 61 cmp al, BS3_MODE_CODE_V86 62 je .just_do_it 63 %endif 64 65 ; In protected mode: Check the CPL we're currently at skip syscall if ring-3 already. 66 mov ax, cs 67 and ax, 3 68 cmp ax, 3 69 je .return 70 71 .just_do_it: 72 mov xAX, BS3_SYSCALL_TO_RING3 73 int BS3_TRAP_SYSCALL 74 75 .return: 76 pop xAX 46 BS3_ONLY_64BIT_STMT sub rsp, 18h 47 push 3 48 BS3_CALL Bs3SwitchToRingX, 1 49 add xSP, xCB BS3_ONLY_64BIT(+ 18h) 77 50 ret 78 51 BS3_PROC_END_CMN Bs3SwitchToRing3 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchToRingX.asm
r59976 r60000 1 1 ; $Id$ 2 2 ;; @file 3 ; BS3Kit - Bs3SwitchToRing 03 ; BS3Kit - Bs3SwitchToRingX 4 4 ; 5 5 … … 28 28 29 29 30 BS3_EXTERN_CMN Bs3Syscall 30 31 %if TMPL_BITS == 16 31 32 BS3_EXTERN_DATA16 g_bBs3CurrentMode … … 35 36 36 37 ;; 37 ; @cproto BS3_DECL(void) Bs3SwitchToRing 0(void);38 ; @cproto BS3_DECL(void) Bs3SwitchToRingX(uint8_t bRing); 38 39 ; 40 ; @param bRing The target ring (0..3). 39 41 ; @remarks Does not require 20h of parameter scratch space in 64-bit mode. 40 42 ; 41 BS3_PROC_BEGIN_CMN Bs3SwitchToRing0 43 BS3_PROC_BEGIN_CMN Bs3SwitchToRingX 44 BS3_CALL_CONV_PROLOG 1 45 push xBP 46 mov xBP, xSP 42 47 push xAX 43 48 44 49 %if TMPL_BITS == 16 45 50 ; Check the current mode. 46 push ds47 mov ax, seg g_bBs3CurrentMode48 mov ds, ax49 51 mov al, [BS3_DATA16_WRT(g_bBs3CurrentMode)] 50 pop ds51 52 52 ; If real mode: Nothing to do, it's considered ring-0 here.53 ; If real mode: Nothing we can do, but we'll bitch if the request isn't for ring-0. 53 54 cmp al, BS3_MODE_RM 54 je .return 55 je .return_real_mode 55 56 56 57 ; If V8086 mode: Always do syscall and add a lock prefix to make sure it gets to the VMM. 57 58 and al, BS3_MODE_CODE_MASK 58 59 cmp al, BS3_MODE_CODE_V86 59 jne .not_v8086 60 61 mov xAX, BS3_SYSCALL_TO_RING0 62 lock int BS3_TRAP_SYSCALL 63 jmp .return 64 65 .not_v8086: 60 je .just_do_it 66 61 %endif 67 62 68 63 ; In protected mode: Check the CPL we're currently at skip syscall if ring-0 already. 69 64 mov ax, cs 70 test ax, 3 71 jz .return 65 and al, 3 66 cmp al, byte [xBP + xCB*2] 67 je .return 72 68 69 .just_do_it: 73 70 mov xAX, BS3_SYSCALL_TO_RING0 74 int BS3_TRAP_SYSCALL 71 add al, [xBP + xCB*2] 72 call Bs3Syscall 75 73 74 %ifndef BS3_STRICT 75 .return_real_mode: 76 %endif 76 77 .return: 77 78 pop xAX 79 pop xBP 80 BS3_CALL_CONV_EPILOG 1 78 81 ret 79 BS3_PROC_END_CMN Bs3SwitchToRing080 82 83 %ifdef BS3_STRICT 84 ; In real mode, only ring-0 makes any sense. 85 .return_real_mode: 86 cmp byte [xBP + xCB*2], 0 87 je .return 88 int3 89 jmp .return 90 %endif 91 BS3_PROC_END_CMN Bs3SwitchToRingX 92 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TrapDefaultHandler.c
r59976 r60000 152 152 { 153 153 pTrapFrame->Ctx.rip.u16 += (uint16_t)(pbCode - pbCodeStart); 154 # if 0 154 155 Bs3Printf("Calling Bs3RegCtxRestore\n"); 155 156 Bs3RegCtxPrint(&pTrapFrame->Ctx); 157 # endif 156 158 Bs3RegCtxRestore(&pTrapFrame->Ctx, 0 /*fFlags*/); /* does not return. */ 157 159 return; -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-EnteredMode.asm
r59975 r60000 27 27 %include "bs3kit-template-header.mac" 28 28 29 %if TMPL_BITS == 16 30 BS3_EXTERN_DATA16 g_uBs3CpuDetected 31 %endif 29 32 BS3_EXTERN_DATA16 g_bBs3CurrentMode 30 33 TMPL_BEGIN_TEXT … … 152 155 153 156 ; 154 ; Load ds and es .155 ; 156 %if def TMPL_CMN_V86157 ; Load ds and es; clear fs and gs. 158 ; 159 %if BS3_MODE_IS_RM_OR_V86(TMPL_MODE) 157 160 mov ax, BS3_SEL_DATA16 158 161 %else … … 166 169 push ax 167 170 push ax 168 %endif 171 172 cmp byte [BS3_DATA16_WRT(g_uBs3CpuDetected)], BS3CPU_80286 173 jbe .skip_fs_gs 174 %endif 175 xor ax, ax 176 mov fs, ax 177 mov gs, ax 178 .skip_fs_gs: 169 179 170 180 ; … … 246 256 %endif 247 257 pop xAX 258 %ifdef BS3_STRICT 259 cmp xBP, xSP 260 je .return_stack_ok 261 int3 262 .return_stack_ok: 263 %endif 248 264 leave 249 265 ret -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToRM.asm
r59977 r60000 40 40 ; @cproto BS3_DECL(void) Bs3SwitchToRM(void); 41 41 ; 42 ; @uses Nothing (except high 32-bit register parts). 42 ; @uses GPRs and EFLAGS are unchanged (except high 32-bit register (AMD64) parts). 43 ; CS is loaded with BS3TEXT16. 44 ; SS:[RE]SP is converted to real mode address. 45 ; DS and ES are loaded with BS3DATA16_GROUP. 46 ; FS and GS are loaded with zero if present. 43 47 ; 44 48 ; @remarks Obviously returns to 16-bit mode, even if the caller was … … 120 124 BS3_SET_BITS 16 121 125 %endif 126 ; 127 ; Before exiting to real mode we must load sensible selectors into the 128 ; segment registers so the hidden parts (which doesn't get reloaded in 129 ; real mode) are real mode compatible. 130 ; 131 .is_386_or_better: 132 ;; @todo Testcase: Experiment leaving weird stuff in the hidden segment registers. 133 mov ax, BS3_SEL_R0_DS16 134 mov ds, ax 135 mov es, ax 136 mov fs, ax 137 mov gs, ax 122 138 123 139 ; 124 140 ; Exit to real mode. 125 141 ; 126 .is_386_or_better:127 142 mov eax, cr0 128 143 and eax, X86_CR0_NO_PE_NO_PG -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-TestDoModes.c
r59984 r60000 192 192 Bs3TestSub(paEntries[i].pszSubTest); 193 193 194 #if 1 194 195 if (paEntries[i].pfnDoRM) 195 196 { … … 205 206 * Unpaged prot mode. 206 207 */ 207 #if 0208 208 if (paEntries[i].pfnDoPE16) 209 209 { 210 Bs3Printf("Calling pfnDoPE16\n");211 210 bErrNo = TMPL_NM(Bs3TestCallDoerInPE16)(CONV_TO_BS3TEXT16(paEntries[i].pfnDoPE16)); 212 Bs3Printf("pfnDoPE16 returns %d\n", bErrNo);213 211 if (bErrNo != 0) 214 212 Bs3TestFailedF("Error #%u (%#x) in %s!\n", bErrNo, bErrNo, BS3_DATA_NM(g_szBs3ModeName_pe16)); … … 219 217 if (paEntries[i].pfnDoPE16_32) 220 218 { 221 Bs3Printf("Calling pfnDoPE16_32\n");222 219 bErrNo = TMPL_NM(Bs3TestCallDoerInPE16_32)(CONV_TO_FLAT(paEntries[i].pfnDoPE16_32)); 223 Bs3Printf("pfnDoPE16_32 returns %d\n", bErrNo);224 220 if (bErrNo != 0) 225 221 Bs3TestFailedF("Error #%u (%#x) in %s!\n", bErrNo, bErrNo, BS3_DATA_NM(g_szBs3ModeName_pe16_32)); … … 227 223 228 224 if (paEntries[i].pfnDoPE16_V86 && fDoWeirdV86Modes) 229 #endif230 225 { 231 226 bErrNo = TMPL_NM(Bs3TestCallDoerInPE16_V86)(CONV_TO_BS3TEXT16(paEntries[i].pfnDoPE16_V86)); … … 367 362 Bs3TestFailedF("Error #%u (%#x) in %s!\n", bErrNo, bErrNo, BS3_DATA_NM(g_szBs3ModeName_lm32)); 368 363 } 369 364 #endif 370 365 if (paEntries[i].pfnDoLM64) 371 366 { … … 375 370 } 376 371 } 372 for (;;) { } 377 373 } 378 374 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-TestDoModesHlp.asm
r59984 r60000 157 157 158 158 159 160 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 161 ;; Real mode 162 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 163 159 164 ;; 160 165 ; @cproto BS3_DECL(uint8_t) Bs3TestCallDoerInRM(uint16_t offBs3Text16); … … 171 176 call TMPL_NM(Bs3SwitchToRM) 172 177 BS3_SET_BITS 16 173 call ax 178 mov cx, BS3_MODE_RM 179 push cx 180 call ax 181 add sp, 2 174 182 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_rm) 175 183 BS3_SET_BITS TMPL_BITS … … 197 205 call TMPL_NM(Bs3SwitchToPE16) 198 206 BS3_SET_BITS 16 207 push BS3_MODE_PE16 199 208 call ax 200 209 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pe16) … … 216 225 call TMPL_NM(Bs3SwitchToPE16_32) 217 226 BS3_SET_BITS 32 227 push BS3_MODE_RM 218 228 call eax 219 229 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pe16_32) … … 229 239 jmp TMPL_NM(bs3TestCallDoerPrologue) 230 240 .doit: 231 mov eax, [xBP + xCB*2]; Load function pointer.241 mov ax, [xBP + xCB*2] ; Load function pointer. 232 242 233 243 ; Mode switch, make the call, switch back. 234 244 call TMPL_NM(Bs3SwitchToPE16_V86) 235 BS3_SET_BITS 32236 call eax237 .repeat: jmp .repeat 245 BS3_SET_BITS 16 246 push BS3_MODE_PE16_V86 247 call ax 238 248 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pe16_v86) 239 249 BS3_SET_BITS TMPL_BITS … … 253 263 call TMPL_NM(Bs3SwitchToPE32) 254 264 BS3_SET_BITS 32 265 push BS3_MODE_PE32 255 266 call eax 256 267 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pe32) … … 273 284 call TMPL_NM(Bs3SwitchToPE32_16) 274 285 BS3_SET_BITS 16 286 push BS3_MODE_PE32_16 275 287 call ax 276 288 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pe32_16) … … 294 306 call TMPL_NM(Bs3SwitchToPEV86) 295 307 BS3_SET_BITS 16 308 push BS3_MODE_PEV86 296 309 call ax 297 310 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pev86) … … 321 334 call TMPL_NM(Bs3SwitchToPP16) 322 335 BS3_SET_BITS 16 336 push BS3_MODE_PP16 323 337 call ax 324 338 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pp16) … … 340 354 call TMPL_NM(Bs3SwitchToPP16_32) 341 355 BS3_SET_BITS 32 356 push BS3_MODE_PP16_32 342 357 call eax 343 358 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pp16_32) … … 353 368 jmp TMPL_NM(bs3TestCallDoerPrologue) 354 369 .doit: 355 mov eax, [xBP + xCB*2]; Load function pointer.370 mov ax, [xBP + xCB*2] ; Load function pointer. 356 371 357 372 ; Mode switch, make the call, switch back. 358 373 call TMPL_NM(Bs3SwitchToPP16_V86) 359 BS3_SET_BITS 32 360 call eax 374 BS3_SET_BITS 16 375 push BS3_MODE_PP16_V86 376 call ax 361 377 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pp16_v86) 362 378 BS3_SET_BITS TMPL_BITS … … 376 392 call TMPL_NM(Bs3SwitchToPP32) 377 393 BS3_SET_BITS 32 394 push BS3_MODE_PP32 378 395 call eax 379 396 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pp32) … … 396 413 call TMPL_NM(Bs3SwitchToPP32_16) 397 414 BS3_SET_BITS 16 415 push BS3_MODE_PP32_16 398 416 call ax 399 417 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pp32_16) … … 417 435 call TMPL_NM(Bs3SwitchToPPV86) 418 436 BS3_SET_BITS 16 437 push BS3_MODE_PPV86 419 438 call ax 420 439 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_ppv86) … … 444 463 call TMPL_NM(Bs3SwitchToPAE16) 445 464 BS3_SET_BITS 16 465 push BS3_MODE_PAE16 446 466 call ax 447 467 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pae16) … … 463 483 call TMPL_NM(Bs3SwitchToPAE16_32) 464 484 BS3_SET_BITS 32 485 push BS3_MODE_PAE16_32 465 486 call eax 466 487 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pae16_32) … … 476 497 jmp TMPL_NM(bs3TestCallDoerPrologue) 477 498 .doit: 478 mov eax, [xBP + xCB*2]; Load function pointer.499 mov ax, [xBP + xCB*2] ; Load function pointer. 479 500 480 501 ; Mode switch, make the call, switch back. 481 502 call TMPL_NM(Bs3SwitchToPAE16_V86) 482 BS3_SET_BITS 32 483 call eax 503 BS3_SET_BITS 16 504 push BS3_MODE_PAE16_V86 505 call ax 484 506 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pae16_v86) 485 507 BS3_SET_BITS TMPL_BITS … … 499 521 call TMPL_NM(Bs3SwitchToPAE32) 500 522 BS3_SET_BITS 32 523 push BS3_MODE_PAE16_32 501 524 call eax 502 525 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pae32) … … 519 542 call TMPL_NM(Bs3SwitchToPAE32_16) 520 543 BS3_SET_BITS 16 544 push BS3_MODE_PAE32_16 521 545 call ax 522 546 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pae32_16) … … 540 564 call TMPL_NM(Bs3SwitchToPAEV86) 541 565 BS3_SET_BITS 16 566 push BS3_MODE_PAEV86 542 567 call ax 543 568 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_paev86) … … 567 592 call TMPL_NM(Bs3SwitchToLM16) 568 593 BS3_SET_BITS 16 594 push BS3_MODE_LM16 569 595 call ax 570 596 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_lm16) … … 586 612 call TMPL_NM(Bs3SwitchToLM32) 587 613 BS3_SET_BITS 32 614 and esp, ~03h 615 push BS3_MODE_LM32 588 616 call eax 589 617 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_lm32) … … 604 632 call TMPL_NM(Bs3SwitchToLM64) 605 633 BS3_SET_BITS 64 606 call rax 634 and rsp, ~0fh 635 sub rsp, 18h 636 push BS3_MODE_LM64 637 BS3_CALL rax, 1 607 638 call RT_CONCAT3(Bs3SwitchTo,TMPL_MODE_UNAME,_lm64) 608 639 BS3_SET_BITS TMPL_BITS -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-TrapSystemCallHandler.asm
r59984 r60000 25 25 ; 26 26 27 ;********************************************************************************************************************************* 28 ;* Header Files * 29 ;********************************************************************************************************************************* 27 30 %include "bs3kit-template-header.mac" 28 31 29 32 33 ;********************************************************************************************************************************* 34 ;* External Symbols * 35 ;********************************************************************************************************************************* 30 36 BS3_EXTERN_DATA16 g_bBs3CurrentMode 31 37 BS3_EXTERN_DATA16 g_uBs3CpuDetected 38 %if TMPL_BITS == 16 39 BS3_EXTERN_DATA16 g_uBs3TrapEipHint 40 %endif 32 41 TMPL_BEGIN_TEXT 33 42 … … 52 61 ; 53 62 ; Note! The 16-bit versions of this code must be careful with using extended 54 ; registers as we wish this code to work on real 8086 CPUs too! 63 ; registers as we wish this code to work on real 80286 (maybe even 8086) 64 ; CPUs too! 55 65 ; 56 66 BS3_PROC_BEGIN_MODE Bs3TrapSystemCallHandler 67 ; 68 ; This prologue is kind of complicated because of 80286 and older CPUs 69 ; as well as different requirements for 64-bit and the other modes. 70 ; 71 %define VAR_CALLER_BP [xBP] 72 %if TMPL_BITS != 64 73 %define VAR_CALLER_DS [xBP - xCB] 74 %endif 75 %define VAR_CALLER_BX [xBP - sCB*1 - xCB] 76 %define VAR_CALLER_AX [xBP - sCB*2 - xCB] 77 %define VAR_CALLER_CX [xBP - sCB*3 - xCB] 78 %define VAR_CALLER_DX [xBP - sCB*4 - xCB] 79 %define VAR_CALLER_SI [xBP - sCB*5 - xCB] 80 %define VAR_CALLER_DI [xBP - sCB*6 - xCB] 81 %if TMPL_BITS == 16 82 %define VAR_CALLER_ESP [xBP - sCB*7 - xCB] 83 %define VAR_CALLER_EBP [xBP - sCB*8 - xCB] 84 %define VAR_CALLER_EFLAGS [xBP - sCB*9 - xCB] 85 %define VAR_CALLER_MODE [xBP - sCB*9 - xCB*2] 86 %else 87 %define VAR_CALLER_MODE [xBP - sCB*6 - xCB*2] 88 %endif 57 89 push xBP 58 90 mov xBP, xSP 59 %ifndef TMPL_64BIT 60 %define VAR_CALLER_DS [xBP - xCB] 91 %if TMPL_BITS == 64 92 push 0 ; dummy DS entry 93 %else 61 94 push ds 62 95 %ifdef TMPL_CMN_R86 … … 65 98 push RT_CONCAT(BS3_SEL_R0_DS,TMPL_BITS) 66 99 %endif 67 pop ds 68 %define VAR_CALLER_BP [xBP] 69 %define VAR_CALLER_DS [xBP - - xCB] 70 %define VAR_CALLER_BX [xBP - xCB*1 - xCB] 71 %define VAR_CALLER_AX [xBP - xCB*2 - xCB] 72 %define VAR_CALLER_CX [xBP - xCB*3 - xCB] 73 %define VAR_CALLER_DX [xBP - xCB*4 - xCB] 74 %define VAR_CALLER_MODE [xBP - xCB*5 - xCB] 75 %else 76 %define VAR_CALLER_BP [xBP] 77 %define VAR_CALLER_BX [xBP - xCB*1] 78 %define VAR_CALLER_AX [xBP - xCB*2] 79 %define VAR_CALLER_CX [xBP - xCB*3] 80 %define VAR_CALLER_DX [xBP - xCB*4] 81 %define VAR_CALLER_MODE [xBP - xCB*5] 82 %endif 83 push xBX 84 push xAX 85 push xCX 86 push xDX 87 100 pop ds ; DS = BS3DATA16_GROUP or FLAT and we can safely access data 101 %if TMPL_BITS == 16 && (TMPL_MODE == BS3_MODE_SYS_RM || TMPL_MODE == BS3_MODE_SYS_PE16) 102 cmp byte [BS3_DATA16_WRT(g_uBs3CpuDetected)], BS3CPU_80286 103 jbe .prologue_pre_80386 104 %endif 105 %endif 106 push sBX 107 push sAX 108 push sCX 109 push sDX 110 push sSI 111 push sDI 112 %if TMPL_BITS == 16 113 push ebp 114 push esp 115 pushfd 116 %if TMPL_MODE == BS3_MODE_SYS_RM || TMPL_MODE == BS3_MODE_SYS_PE16 117 jmp .prologue_end 118 119 .prologue_pre_80386: 120 push bx ; dummy 121 push bx 122 push ax ; dummy 123 push ax 124 push cx ; dummy 125 push cx 126 push dx ; dummy 127 push dx 128 push si ; dummy 129 push si 130 push di ; dummy 131 push di 132 sub sp, 0ch ; dummy 133 %endif 134 %endif 135 .prologue_end: 136 137 ; 88 138 ; VAR_CALLER_MODE: Save the current mode (important for v8086 with 16-bit kernel). 139 ; 89 140 xor xBX, xBX 90 mov bl, [ g_bBs3CurrentMode]141 mov bl, [BS3_DATA16_WRT(g_bBs3CurrentMode)] 91 142 push xBX 92 143 … … 131 182 jmp .return 132 183 133 134 184 ; 135 185 ; Print char in the CL register. … … 139 189 ; requried for the mode switching code. 140 190 ; 141 %ifndef TMPL_16BIT142 191 BS3_BEGIN_TEXT16 143 192 BS3_SET_BITS TMPL_BITS 144 %endif145 193 .print_chr: 146 push xDI 147 push xSI 194 %if TMPL_BITS != 64 195 push es 196 mov di, ss ; Must save and restore SS for supporting 16/32 and 32/16 caller/kernel ring-0 combinations. 197 %endif 148 198 %ifndef TMPL_CMN_R86 149 199 ; Switch to real mode (20h param scratch area not required). … … 152 202 BS3_SET_BITS 16 153 203 %endif 154 push sBX155 push sAX156 push sCX157 push sDX158 push sBP159 204 160 205 ; Print the character. … … 164 209 int 10h 165 210 166 pop sBP167 pop sDX168 pop sCX169 pop sAX170 pop sBX171 211 %ifndef TMPL_CMN_R86 172 212 ; Switch back (20h param scratch area not required). … … 175 215 BS3_SET_BITS TMPL_BITS 176 216 %endif 177 pop xSI 178 pop xDI 217 %if TMPL_BITS != 64 218 mov ss, di 219 pop es 220 %endif 179 221 jmp .return 180 %ifndef TMPL_16BIT181 222 TMPL_BEGIN_TEXT 182 %endif183 223 184 224 … … 192 232 ; 193 233 .print_str: 194 push xSI ; we setup ds:xSI to point to the thing. 195 %if TMPL_BITS != 64 196 mov bl, byte VAR_CALLER_MODE 197 and bl, BS3_MODE_CODE_MASK 198 cmp bl, BS3_MODE_CODE_V86 199 jne .print_str_not_v8086 200 ;; @todo this gets complicated _fast_. Later. 201 .print_str_not_v8086: 202 %endif 234 ;;%if TMPL_BITS != 64 235 ;; mov bl, byte VAR_CALLER_MODE 236 ;; and bl, BS3_MODE_CODE_MASK 237 ;; cmp bl, BS3_MODE_CODE_V86 238 ;; jne .print_str_not_v8086 239 ;; ;; @todo this gets complicated _fast_. Later. 240 ;;.print_str_not_v8086: 241 ;;%endif 203 242 int3 204 243 jmp .return … … 216 255 mov xBX, xSP ; xBP = BS3REGCTX pointer. 217 256 call .save_context 257 218 258 219 259 %if TMPL_BITS == 32 … … 225 265 mov xBX, xAX 226 266 %endif 227 ; Prepare the last call frame. 228 BS3_ONLY_16BIT_STMT push ss 229 push xBX 267 push xBX ; Save pointer for the final restore call. 230 268 231 269 ; Convert the register context from whatever it is to ring-0. 270 BS3_ONLY_64BIT_STMT sub rsp, 10h 232 271 BS3_ONLY_16BIT_STMT push ss 233 272 push xBX … … 236 275 push xAX 237 276 BS3_CALL Bs3RegCtxConvertToRingX, 2 238 add xSP, sCB 277 add xSP, sCB BS3_ONLY_64BIT(+ 10h) 239 278 240 279 ; Restore the register context (does not return). 241 280 pop xBX ; restore saved pointer. 281 BS3_ONLY_64BIT_STMT sub rsp, 18h 242 282 BS3_ONLY_16BIT_STMT push ss 243 283 push xBX … … 251 291 .return: 252 292 pop xBX ; saved mode 293 mov [BS3_DATA16_WRT(g_bBs3CurrentMode)], bl 253 294 %if TMPL_BITS == 16 254 295 and bl, BS3_MODE_CODE_MASK 255 296 cmp bl, BS3_MODE_CODE_V86 256 297 je .return_to_v8086_from_16bit_krnl 257 %endif 258 pop xDX 259 pop xCX 260 pop xAX 261 pop xBX 262 %ifndef TMPL_64BIT 298 cmp bl, BS3_MODE_CODE_32 299 je .return_to_32bit_from_16bit_krnl 300 %if TMPL_MODE == BS3_MODE_SYS_RM || TMPL_MODE == BS3_MODE_SYS_PE16 301 cmp byte [BS3_DATA16_WRT(g_uBs3CpuDetected)], BS3CPU_80286 302 jbe .return_pre_80386 303 %endif 304 305 popfd 306 pop esp 307 pop ebp 308 %endif 309 pop sDI 310 pop sSI 311 pop sDX 312 pop sCX 313 pop sAX 314 pop sBX 315 %if TMPL_BITS != 64 263 316 pop ds 264 %endif265 317 leave 266 %ifdef TMPL_64BIT 318 iret 319 %else 320 leave ; skips fake ds 267 321 iretq 268 %else 322 %endif 323 324 %if TMPL_BITS == 16 325 %if TMPL_MODE == BS3_MODE_SYS_RM || TMPL_MODE == BS3_MODE_SYS_PE16 326 ; Variant of the above for 80286 and older. 327 .return_pre_80386: 328 add sp, 0ch 329 pop di 330 pop di 331 pop si 332 pop si 333 pop dx 334 pop dx 335 pop cx 336 pop cx 337 pop ax 338 pop ax 339 pop bx 340 pop bx 341 pop ds 342 pop bp 269 343 iret 270 %endif 271 272 %if TMPL_BITS == 16 344 %endif 345 273 346 .return_to_v8086_from_16bit_krnl: 274 347 int3 275 348 jmp .return_to_v8086_from_16bit_krnl 276 %endif 277 349 350 ; 351 ; Returning to 32-bit code may require us to expand and seed the eip 352 ; and esp addresses in the iret frame since these are truncated when 353 ; using a 16-bit interrupt handler. 354 ; 355 ; Incoming stack: New stack diff cpl: 356 ; bp + 0ah: [ss] 357 ; bp + 08h: [sp] bx + 38h: [ss] New stack same cpl: 358 ; bp + 06h: flags 359 ; bp + 04h: cs bx + 34h: [esp] bx + 30h: eflags 360 ; bp + 02h: ip 361 ; -------------- bx + 30h: eflags bx + 2ch: cs 362 ; bp + 00h: bp 363 ; bp - 02h: ds bx + 2ch: cs bx + 28h: eip 364 ; ------------- 365 ; bp - 06h: ebx bx + 28h: eip bx + 26h: bp 366 ; -------------- bx + 24h: ds 367 ; bp - 0ah: eax bx + 26h: bp 368 ; bx + 24h: ds bx + 20h: ebx 369 ; bp - 0eh: ecx 370 ; bx + 20h: ebx bx + 1ch: eax 371 ; bp - 12h: edx 372 ; bx + 1ch: eax bx + 18h: ecx 373 ; bp - 16h: esi 374 ; bx + 18h: ecx bx + 14h: edx 375 ; bp - 1ah: edi 376 ; bx + 14h: edx bx + 10h: esi 377 ; bp - 1eh: esp 378 ; bx + 10h: esi bx + 0ch: edi 379 ; bp - 22h: ebp 380 ; bx + 0ch: edi bx + 08h: esp 381 ; bp - 26h: eflags 382 ; bx + 08h: esp bx + 04h: ebp 383 ; 384 ; bx + 04h: ebp bx + 00h: eflags 385 ; 386 ; bx + 00h: eflags 387 ; 388 ; 389 ; If we're returning to the same CPL, we're still using the stack of 390 ; the 32-bit caller. The high ESP word does not need restoring. 391 ; 392 ; If we're returning to a lower CPL, there on a 16-bit ring-0 stack, 393 ; however, the high ESP word is still that of the caller. 394 ; 395 .return_to_32bit_from_16bit_krnl: 396 mov ax, cs 397 and al, 3 398 mov ah, 3 399 and ah, [xBP + xCB*2] 400 ; The iret frame doubles in size, so allocate more stack. 401 cmp al, ah 402 je .return_to_32bit_from_16bit_krnl_same_cpl_sub_sp 403 sub sp, 2*2 404 .return_to_32bit_from_16bit_krnl_same_cpl_sub_sp: 405 sub sp, 3*2 406 mov bx, sp 407 ; Copy the saved registers. 408 xor di, di 409 .return_to_32bit_from_16bit_krnl_copy_loop: 410 mov ecx, [bp + di - 26h] 411 mov [ss:bx + di], ecx 412 add di, 4 413 cmp di, 28h 414 jb .return_to_32bit_from_16bit_krnl_copy_loop 415 ; Convert the 16-bit iret frame to a 32-bit iret frame. 416 mov ecx, [BS3_DATA16_WRT(g_uBs3TrapEipHint)] 417 mov cx, [bp + 02h] ; ip 418 mov [ss:bx + 28h], ecx 419 mov ecx, 0f00d0000h 420 mov cx, [bp + 04h] ; cs 421 mov [ss:bx + 2ch], ecx 422 mov ecx, [ss:bx] ; caller eflags 423 mov cx, [bp + 06h] ; flags 424 mov [ss:bx + 30h], ecx 425 cmp al, ah 426 jz .return_to_32bit_from_16bit_krnl_do_return 427 mov ecx, [ss:bx + 08h] ; caller esp 428 mov cx, [bp + 08h] ; sp 429 mov [ss:bx + 34h], ecx 430 mov ecx, 0f00d0000h 431 mov cx, [bp + 0ah] ; ss 432 mov [ss:bx + 38h], ecx 433 .return_to_32bit_from_16bit_krnl_do_return: 434 popfd 435 pop ecx ; esp - only the high bits! 436 mov cx, sp 437 mov esp, ecx 438 pop ebp 439 lea bp, [bx + 26h] 440 pop edi 441 pop esi 442 pop edx 443 pop ecx 444 pop eax 445 pop ebx 446 pop ds 447 leave 448 iretd 449 450 %endif ; 16-bit 278 451 279 452 … … 284 457 .save_context: 285 458 %if TMPL_BITS == 16 286 cmp byte [ g_uBs3CpuDetected], BS3CPU_80386459 cmp byte [BS3_DATA16_WRT(g_uBs3CpuDetected)], BS3CPU_80386 287 460 jae .save_context_full 288 461 … … 342 515 mov al, VAR_CALLER_MODE 343 516 mov [ss:bx + BS3REGCTX.bMode], al 344 cmp byte [ g_uBs3CpuDetected], BS3CPU_80286517 cmp byte [BS3_DATA16_WRT(g_uBs3CpuDetected)], BS3CPU_80286 345 518 jne .save_context_16_return 346 519 smsw [ss:bx + BS3REGCTX.cr0] … … 371 544 ; Do the 386+ state saving. 372 545 %if TMPL_BITS == 16 ; save the high word of registered pushed on the stack. 373 mov [ss:bx + BS3REGCTX.rax], eax 546 mov ecx, VAR_CALLER_AX 547 mov [ss:bx + BS3REGCTX.rax], ecx 548 mov ecx, VAR_CALLER_CX 374 549 mov [ss:bx + BS3REGCTX.rcx], ecx 375 mov [ss:bx + BS3REGCTX.rdx], edx 376 mov [ss:bx + BS3REGCTX.rbx], ebx 377 mov [ss:bx + BS3REGCTX.rbp], ebp 378 mov [ss:bx + BS3REGCTX.rsp], esp 379 pushfd 380 pop dword [ss:bx + BS3REGCTX.rflags] 550 mov ecx, VAR_CALLER_DX 551 mov [ss:bx + BS3REGCTX.rdx], ecx 552 mov ecx, VAR_CALLER_BX 553 mov [ss:bx + BS3REGCTX.rbx], ecx 554 mov ecx, VAR_CALLER_EBP 555 mov [ss:bx + BS3REGCTX.rbp], ecx 556 mov ecx, VAR_CALLER_ESP 557 mov [ss:bx + BS3REGCTX.rsp], ecx 558 mov ecx, VAR_CALLER_SI 559 mov [ss:bx + BS3REGCTX.rsi], ecx 560 mov ecx, VAR_CALLER_DI 561 mov [ss:bx + BS3REGCTX.rdi], ecx 562 mov ecx, VAR_CALLER_EFLAGS 563 mov [ss:bx + BS3REGCTX.rflags], ecx 564 %if TMPL_BITS == 16 565 ; Seed high EIP word if 32-bit CS. 566 lar ecx, [bp + 4] 567 jnz .save_context_full_done_16bit_high_word 568 test ecx, X86LAR_F_D 569 jz .save_context_full_done_16bit_high_word 570 mov ecx, [BS3_DATA16_WRT(g_uBs3TrapEipHint)] 571 mov [ss:bx + BS3REGCTX.rip], ecx 572 %endif ; 16-bit 573 .save_context_full_done_16bit_high_word: 381 574 %endif 382 575 mov xAX, VAR_CALLER_AX … … 470 663 mov [BS3_NOT_64BIT(ss:) xBX + BS3REGCTX.gs], ax 471 664 mov byte [BS3_NOT_64BIT(ss:) xBX + BS3REGCTX.bCpl], 3 472 %endif 665 jmp .save_context_full_return 666 667 %endif ; !64-bit 668 473 669 .save_context_full_return: 474 670 ret -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.h
r59984 r60000 818 818 819 819 /** The current mode (BS3_MODE_XXX) of CPU \#0. */ 820 extern uint8_t BS3_DATA_NM(g_bBs3CurrentMode); 820 extern uint8_t BS3_DATA_NM(g_bBs3CurrentMode); 821 822 /** Hint for 16-bit trap handlers regarding the high word of EIP. */ 823 extern uint32_t BS3_DATA_NM(g_uBs3TrapEipHint); 821 824 822 825 … … 846 849 # endif 847 850 #endif 851 848 852 849 853
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器