Changeset 59259 in vbox for trunk/src/VBox/ValidationKit
- Timestamp:
- Jan 6, 2016 2:53:27 AM (9 years ago)
- Location:
- trunk/src/VBox/ValidationKit/bootsectors/bs3kit
- Files:
-
- 4 added
- 10 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk
r59258 r59259 523 523 bs3-cmn-Trap32Init.c \ 524 524 bs3-cmn-Trap32SetGate.c \ 525 bs3-cmn-Trap64SetGate.c \ 526 bs3-cmn-TrapSetHandler.c \ 525 527 ../../../Runtime/common/asm/ASMBitFirstClear.asm \ 526 528 ../../../Runtime/common/asm/ASMBitFirstSet.asm \ … … 588 590 bs3-mode-SwitchToPAE32.asm \ 589 591 bs3-mode-SwitchToLM64.asm \ 592 bs3-mode-SwitchToLM32.asm \ 593 bs3-mode-SwitchToLM16.asm \ 590 594 bs3-mode-EnteredMode.asm \ 591 595 bs3-mode-PagingGetRootForPP16.asm \ … … 594 598 bs3-mode-PagingGetRootForPAE32.asm \ 595 599 bs3-mode-PagingGetRootForLM64.asm \ 600 bs3-mode-TrapSystemCallHandler.asm \ 596 601 597 602 # The 16-bit real mode BS3Kit library. -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-c32-Trap32Generic.asm
r59258 r59259 32 32 33 33 BS3_BEGIN_DATA32 34 ;; Easy to access flat address of Bs3 Idt32GenericEntries.35 BS3_GLOBAL_DATA g_Bs3 Idt32GenericEntriesFlatAddr, 436 dd Bs3 Idt32GenericEntries34 ;; Easy to access flat address of Bs3Trap32GenericEntries. 35 BS3_GLOBAL_DATA g_Bs3Trap32GenericEntriesFlatAddr, 4 36 dd Bs3Trap32GenericEntries 37 37 38 38 ;; Pointer C trap handlers. 39 BS3_GLOBAL_DATA g_apfnBs3Trap 32Handlers, 102439 BS3_GLOBAL_DATA g_apfnBs3TrapHandlers_c32, 1024 40 40 resd 256 41 41 … … 49 49 ; Generic entry points for IDT handlers, 8 byte spacing. 50 50 ; 51 BS3_PROC_BEGIN Bs3 Idt32GenericEntries52 %macro Bs3 Idt32GenericEntry 151 BS3_PROC_BEGIN Bs3Trap32GenericEntries 52 %macro Bs3Trap32GenericEntry 1 53 53 db 06ah, i ; push imm8 - note that this is a signextended value. 54 54 jmp %1 … … 58 58 59 59 %assign i 0 ; start counter. 60 Bs3 Idt32GenericEntry bs3Idt32GenericTrapOrInt ; 061 Bs3 Idt32GenericEntry bs3Idt32GenericTrapOrInt ; 162 Bs3 Idt32GenericEntry bs3Idt32GenericTrapOrInt ; 263 Bs3 Idt32GenericEntry bs3Idt32GenericTrapOrInt ; 364 Bs3 Idt32GenericEntry bs3Idt32GenericTrapOrInt ; 465 Bs3 Idt32GenericEntry bs3Idt32GenericTrapOrInt ; 566 Bs3 Idt32GenericEntry bs3Idt32GenericTrapOrInt ; 667 Bs3 Idt32GenericEntry bs3Idt32GenericTrapOrInt ; 768 Bs3 Idt32GenericEntry bs3Idt32GenericTrapErrCode ; 869 Bs3 Idt32GenericEntry bs3Idt32GenericTrapOrInt ; 970 Bs3 Idt32GenericEntry bs3Idt32GenericTrapErrCode ; a71 Bs3 Idt32GenericEntry bs3Idt32GenericTrapErrCode ; b72 Bs3 Idt32GenericEntry bs3Idt32GenericTrapErrCode ; c73 Bs3 Idt32GenericEntry bs3Idt32GenericTrapErrCode ; d74 Bs3 Idt32GenericEntry bs3Idt32GenericTrapErrCode ; e75 Bs3 Idt32GenericEntry bs3Idt32GenericTrapOrInt ; f (reserved)76 Bs3 Idt32GenericEntry bs3Idt32GenericTrapOrInt ; 1077 Bs3 Idt32GenericEntry bs3Idt32GenericTrapErrCode ; 1178 Bs3 Idt32GenericEntry bs3Idt32GenericTrapOrInt ; 1279 Bs3 Idt32GenericEntry bs3Idt32GenericTrapOrInt ; 1380 Bs3 Idt32GenericEntry bs3Idt32GenericTrapOrInt ; 1481 Bs3 Idt32GenericEntry bs3Idt32GenericTrapOrInt ; 15 (reserved)82 Bs3 Idt32GenericEntry bs3Idt32GenericTrapOrInt ; 16 (reserved)83 Bs3 Idt32GenericEntry bs3Idt32GenericTrapOrInt ; 17 (reserved)84 Bs3 Idt32GenericEntry bs3Idt32GenericTrapOrInt ; 18 (reserved)85 Bs3 Idt32GenericEntry bs3Idt32GenericTrapOrInt ; 19 (reserved)86 Bs3 Idt32GenericEntry bs3Idt32GenericTrapOrInt ; 1a (reserved)87 Bs3 Idt32GenericEntry bs3Idt32GenericTrapOrInt ; 1b (reserved)88 Bs3 Idt32GenericEntry bs3Idt32GenericTrapOrInt ; 1c (reserved)89 Bs3 Idt32GenericEntry bs3Idt32GenericTrapOrInt ; 1d (reserved)90 Bs3 Idt32GenericEntry bs3Idt32GenericTrapErrCode ; 1e91 Bs3 Idt32GenericEntry bs3Idt32GenericTrapOrInt ; 1f (reserved)60 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 0 61 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 1 62 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 2 63 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 3 64 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 4 65 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 5 66 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 6 67 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 7 68 Bs3Trap32GenericEntry bs3Trap32GenericTrapErrCode ; 8 69 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 9 70 Bs3Trap32GenericEntry bs3Trap32GenericTrapErrCode ; a 71 Bs3Trap32GenericEntry bs3Trap32GenericTrapErrCode ; b 72 Bs3Trap32GenericEntry bs3Trap32GenericTrapErrCode ; c 73 Bs3Trap32GenericEntry bs3Trap32GenericTrapErrCode ; d 74 Bs3Trap32GenericEntry bs3Trap32GenericTrapErrCode ; e 75 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; f (reserved) 76 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 10 77 Bs3Trap32GenericEntry bs3Trap32GenericTrapErrCode ; 11 78 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 12 79 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 13 80 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 14 81 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 15 (reserved) 82 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 16 (reserved) 83 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 17 (reserved) 84 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 18 (reserved) 85 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 19 (reserved) 86 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 1a (reserved) 87 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 1b (reserved) 88 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 1c (reserved) 89 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 1d (reserved) 90 Bs3Trap32GenericEntry bs3Trap32GenericTrapErrCode ; 1e 91 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 1f (reserved) 92 92 %rep 224 93 Bs3 Idt32GenericEntry bs3Idt32GenericTrapOrInt93 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt 94 94 %endrep 95 BS3_PROC_END Bs3 Idt32GenericEntries95 BS3_PROC_END Bs3Trap32GenericEntries 96 96 97 97 … … 101 101 ; Trap or interrupt (no error code). 102 102 ; 103 BS3_PROC_BEGIN bs3 Idt32GenericTrapOrInt103 BS3_PROC_BEGIN bs3Trap32GenericTrapOrInt 104 104 pushfd 105 105 cli … … 121 121 mov [esp + BS3TRAPFRAME.uErrCd], edx 122 122 mov [esp + BS3TRAPFRAME.uErrCd + 4], edx 123 jmp bs3 Idt32GenericCommon124 BS3_PROC_END bs3 Idt32GenericTrapOrInt123 jmp bs3Trap32GenericCommon 124 BS3_PROC_END bs3Trap32GenericTrapOrInt 125 125 126 126 … … 128 128 ; Trap with error code. 129 129 ; 130 BS3_PROC_BEGIN bs3 Idt32GenericTrapErrCode130 BS3_PROC_BEGIN bs3Trap32GenericTrapErrCode 131 131 pushfd 132 132 cli … … 150 150 xor edx, edx 151 151 mov [esp + BS3TRAPFRAME.uErrCd + 4], edx 152 jmp bs3 Idt32GenericCommon153 BS3_PROC_END bs3 Idt32GenericTrapErrCode152 jmp bs3Trap32GenericCommon 153 BS3_PROC_END bs3Trap32GenericTrapErrCode 154 154 155 155 … … 170 170 ; @param edx Zero (0). 171 171 ; 172 BS3_PROC_BEGIN bs3 Idt32GenericCommon172 BS3_PROC_BEGIN bs3Trap32GenericCommon 173 173 ; 174 174 ; Fake EBP frame. … … 301 301 ; 302 302 movzx ebx, byte [esp + BS3TRAPFRAME.bXcpt] 303 mov eax, [BS3_DATA_NM(g_apfnBs3Trap 32Handlers) + ebx * 4]303 mov eax, [BS3_DATA_NM(g_apfnBs3TrapHandlers_c32) + ebx * 4] 304 304 or eax, eax 305 305 jnz .call_handler … … 320 320 hlt 321 321 jmp .panic 322 BS3_PROC_END bs3 Idt32GenericCommon323 322 BS3_PROC_END bs3Trap32GenericCommon 323 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PrintChr.asm
r58675 r59259 34 34 push xBP 35 35 mov xBP, xSP 36 push sAX37 push sCX36 push xAX 37 push xCX 38 38 push xBX 39 40 ; Load the char.41 movzx eax, byte [xBP + xCB*2]42 39 43 40 %ifdef TMPL_16BIT … … 47 44 jnz .protected_mode 48 45 46 mov al, [xBP + xCB*2] ; Load the char 49 47 mov bx, 0ff00h 50 48 mov ah, 0eh … … 55 53 %endif 56 54 57 mov ecx, eax58 mov eax, BS3_SYSCALL_PRINT_CHR55 mov cl, [xBP + xCB*2] ; Load the char 56 mov ax, BS3_SYSCALL_PRINT_CHR 59 57 int BS3_TRAP_SYSCALL 60 58 61 59 .return: 62 60 pop xBX 63 pop sCX64 pop sAX61 pop xCX 62 pop xAX 65 63 leave 66 64 BS3_CALL_CONV_EPILOG 1 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Trap32Init.c
r59258 r59259 37 37 while (iIdt-- > 0) 38 38 Bs3Trap32SetGate(iIdt, X86_SEL_TYPE_SYS_386_INT_GATE, 0 /*bDpl*/, 39 BS3_SEL_R0_CS32, BS3_DATA_NM(g_Bs3 Idt32GenericEntriesFlatAddr) + iIdt * 8, 0 /*cParams*/);39 BS3_SEL_R0_CS32, BS3_DATA_NM(g_Bs3Trap32GenericEntriesFlatAddr) + iIdt * 8, 0 /*cParams*/); 40 40 /** @todo Init TSS for double faults and stuff. */ 41 41 } -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Trap64SetGate.c
r59258 r59259 1 1 /* $Id$ */ 2 2 /** @file 3 * BS3Kit - Bs3Trap 32SetGate3 * BS3Kit - Bs3Trap64SetGate 4 4 */ 5 5 … … 32 32 33 33 34 BS3_DECL(void) Bs3Trap 32SetGate(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint32_t off, uint8_t cParams)34 BS3_DECL(void) Bs3Trap64SetGate(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint64_t off, uint8_t bIst) 35 35 { 36 X86DESC BS3_FAR *pIdte = &BS3_DATA_NM(Bs3Idt32)[iIdt];36 X86DESC64 BS3_FAR *pIdte = &BS3_DATA_NM(Bs3Idt64)[iIdt]; 37 37 38 38 BS3_ASSERT(bDpl <= 3); 39 39 BS3_ASSERT(bType <= 7); 40 BS3_ASSERT( cParams <= 15);40 BS3_ASSERT(bIst <= 7); 41 41 pIdte->Gate.u16OffsetLow = (uint16_t)off; 42 pIdte->Gate.u16OffsetHigh = (uint16_t)(off >> 16); 42 pIdte->Gate.u16OffsetHigh = (uint16_t)((uint32_t)off >> 16); 43 pIdte->Gate.u32OffsetTop = (uint32_t)(off >> 32); 43 44 pIdte->Gate.u16Sel = uSel; 44 pIdte->Gate.u 4ParmCount = cParams;45 pIdte->Gate.u3IST = bIst; 45 46 pIdte->Gate.u4Type = bType; 46 47 pIdte->Gate.u2Dpl = bDpl; 47 pIdte->Gate.u 4Reserved = 0;48 pIdte->Gate.u5Reserved = 0; 48 49 pIdte->Gate.u1DescType = 0; /* system */ 49 50 pIdte->Gate.u1Present = 1; 51 pIdte->Gate.u32Reserved = 0; 52 50 53 } 51 54 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-EnteredMode.asm
r59242 r59259 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 … … 46 46 BS3_BEGIN_DATA16 47 47 TMPL_BEGIN_TEXT 48 extern TMPL_NM(Bs3TrapSystemCallHandler) 48 49 xor ax, ax 49 50 mov ss, ax … … 52 53 mov es, ax 53 54 55 mov word [ss: BS3_TRAP_SYSCALL*4], TMPL_NM(Bs3TrapSystemCallHandler) wrt BS3TEXT16 56 mov word [ss: BS3_TRAP_SYSCALL*4 + 2], BS3TEXT16 57 54 58 %elif TMPL_BITS == 16 55 59 BS3_EXTERN_SYSTEM16 Bs3Lidt_Idt16 … … 57 61 BS3_EXTERN_SYSTEM16 Bs3Gdte_Tss16DoubleFault 58 62 TMPL_BEGIN_TEXT 63 ;BS3_EXTERN_CMN Bs3Trap32SetGate 64 ;extern TMPL_NM(Bs3TrapSystemCallHandler) 59 65 jmp BS3_SEL_R0_CS16:.reloaded_cs 60 66 .reloaded_cs: … … 80 86 mov es, ax 81 87 88 ; push 0 ; cParams 89 ; push TMPL_NM(Bs3TrapSystemCallHandler) wrt BS3TEXT16 90 ; push BS3_SEL_R0_CS16 91 ; push 3 ; DPL 92 ; push X86_SEL_TYPE_SYS_286_INT_GATE 93 ; push BS3_TRAP_SYSCALL 94 ; call Bs3Trap16SetGate 95 ; add sp, xCB * 6 96 82 97 %elif TMPL_BITS == 32 83 98 BS3_EXTERN_SYSTEM16 Bs3Lidt_Idt32 … … 85 100 BS3_EXTERN_SYSTEM16 Bs3Gdte_Tss32DoubleFault 86 101 TMPL_BEGIN_TEXT 102 %ifndef TMPL_CMN_LM 103 BS3_EXTERN_CMN Bs3Trap32SetGate 104 extern TMPL_NM(Bs3TrapSystemCallHandler) 105 %else 106 BS3_EXTERN_CMN Bs3Trap64SetGate 107 extern Bs3TrapSystemCallHandler_lm64 108 %endif 109 87 110 mov ax, BS3_SEL_R0_SS32 88 111 mov ss, ax … … 105 128 mov es, ax 106 129 130 %ifndef TMPL_CMN_LM 131 push 0 ; cParams 132 push TMPL_NM(Bs3TrapSystemCallHandler) wrt FLAT 133 push BS3_SEL_R0_CS32 134 push 3 ; DPL 135 push X86_SEL_TYPE_SYS_386_INT_GATE 136 push BS3_TRAP_SYSCALL 137 call Bs3Trap32SetGate 138 add esp, xCB * 6 139 %else 140 push 0 ; cParams 141 push 0 ; upper offset 142 push Bs3TrapSystemCallHandler_lm64 wrt FLAT 143 push BS3_SEL_R0_CS64 144 push 3 ; DPL 145 push AMD64_SEL_TYPE_SYS_INT_GATE 146 push BS3_TRAP_SYSCALL 147 call Bs3Trap64SetGate 148 add esp, xCB * 6 149 %endif 107 150 108 151 %elif TMPL_BITS == 64 … … 110 153 BS3_EXTERN_SYSTEM16 Bs3Gdte_Tss64 111 154 TMPL_BEGIN_TEXT 155 ;BS3_EXTERN_CMN Bs3Trap64SetGate 156 ;extern TMPL_NM(Bs3TrapSystemCallHandler) 112 157 mov ax, BS3_SEL_R0_DS64 113 158 mov ss, ax … … 129 174 mov es, ax 130 175 176 ; push 0 ; cParams 177 ; push TMPL_NM(Bs3TrapSystemCallHandler) wrt FLAT 178 ; push BS3_SEL_R0_CS16 179 ; push 3 ; DPL 180 ; push AMD64_SEL_TYPE_SYS_INT_GATE 181 ; push BS3_TRAP_SYSCALL 182 ; call Bs3Trap64SetGate 183 ; add sp, xCB * 6 184 131 185 %else 132 186 %error "TMPL_BITS" -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToLM64.asm
r59245 r59259 29 29 30 30 ;; 31 ; Switch to PAE paged protectedmode from any other mode.31 ; Switch to 64-bit long mode from any other mode. 32 32 ; 33 33 ; @cproto BS3_DECL(void) Bs3SwitchToLM64(void); 34 34 ; 35 ; @uses Nothing (except high 32-bit register parts), upper part of ESP is 36 ; cleared if caller is in 16-bit mode. 35 ; @uses Nothing (except possibly high 32-bit and/or upper 64-bit register parts). 37 36 ; 38 ; @remarks Obviously returns to 32-bit mode, even if the caller was39 ; in 16-bit or 64-bit mode. It doesn't not preserve the callers40 ; ring, butinstead changes to ring-0.37 ; @remarks Obviously returns to 64-bit mode, even if the caller was in 16-bit 38 ; or 32-bit mode. It doesn't not preserve the callers ring, but 39 ; instead changes to ring-0. 41 40 ; 42 41 BS3_PROC_BEGIN_MODE Bs3SwitchToLM64 … … 52 51 53 52 %else 54 %if TMPL_BITS == 16 55 push word 0 ; save space for extending the return value. 56 %endif 53 ; 54 ; Switch to LM32 and then switch to 64-bits (IDT & TSS are the same for 55 ; LM16, LM32 and LM64, unlike the rest). 56 ; 57 ; (The long mode switching code is going via 32-bit protected mode, so 58 ; Bs3SwitchToLM32 contains the actual code for switching to avoid 59 ; unnecessary 32-bit -> 64-bit -> 32-bit trips.) 60 ; 61 extern TMPL_NM(Bs3SwitchToLM32) 62 call TMPL_NM(Bs3SwitchToLM32) 63 BS3_SET_BITS 32 57 64 58 ; 59 ; Switch to 32-bit protected mode (for identify mapped pages). 60 ; 61 extern TMPL_NM(Bs3SwitchToPE32) 62 call TMPL_NM(Bs3SwitchToPE32) 63 BS3_SET_BITS 32 64 %if TMPL_BITS == 16 65 jmp .thirty_two_bit_segment 66 BS3_BEGIN_TEXT32 67 .thirty_two_bit_segment: 68 %endif 69 70 push eax 71 push ecx 72 push edx 73 pushfd 74 75 ; 76 ; Make sure both PAE and PSE are enabled (requires pentium pro). 77 ; 78 mov eax, cr4 79 mov ecx, eax 80 or eax, X86_CR4_PAE | X86_CR4_PSE 81 cmp eax, ecx 82 je .cr4_is_fine 83 mov cr4, eax 84 .cr4_is_fine: 85 86 ; 87 ; Get the page directory (returned in eax). 88 ; Will lazy init page tables. 89 ; 90 extern NAME(Bs3PagingGetRootForLM64_pe32) 91 call NAME(Bs3PagingGetRootForLM64_pe32) 92 93 cli 94 mov cr3, eax 95 96 ; 97 ; Enable long mode in EFER. 98 ; 99 mov ecx, MSR_K6_EFER 100 rdmsr 101 or eax, MSR_K6_EFER_LME 102 wrmsr 103 104 ; 105 ; Enable paging and thereby activating LM64. 106 ; 107 BS3_EXTERN_SYSTEM16 Bs3Lgdt_Gdt 108 BS3_BEGIN_TEXT32 109 mov eax, cr0 110 or eax, X86_CR0_PG 111 mov cr0, eax 112 jmp .in_lm32 113 .in_lm32: 114 115 ; 116 ; Call rountine for doing mode specific setups. 117 ; 118 extern NAME(Bs3EnteredMode_lm32) 119 call NAME(Bs3EnteredMode_lm32) 120 121 ; 122 ; Restore ecx, eax and flags (IF). 123 ; 124 %if TMPL_BITS == 16 125 movzx eax, word [esp + 16 + 2] ; Load return address. 126 add eax, BS3_ADDR_BS3TEXT16 ; Convert it to a flat address. 127 mov [esp + 16], eax ; Store it in the place right for 32-bit returns. 128 %endif 129 popfd 130 pop edx 131 pop ecx 132 pop eax 133 134 ; 135 ; Now go to 32-bit mode. 136 ; 137 extern NAME(Bs3SwitchTo64Bit_c32) 138 jmp NAME(Bs3SwitchTo64Bit_c32) 139 140 %if TMPL_BITS != 32 141 TMPL_BEGIN_TEXT 142 %endif 65 extern _Bs3SwitchTo64Bit_c32 66 jmp _Bs3SwitchTo64Bit_c32 143 67 %endif 144 68 BS3_PROC_END_MODE Bs3SwitchToLM64 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-template-footer.mac
r58628 r59259 67 67 68 68 %undef TMPL_NM 69 %undef TMPL_NM_U 69 70 %undef BS3_CMN_NM 70 %undef TMPL_MODE 71 %undef TMPL_UNDESCORE 72 %undef TMPL_MODE_UNAME 73 %undef TMPL_MODE_LNAME 71 74 %undef TMPL_MODE_STR 72 75 %undef TMPL_16BIT -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-template-header.mac
r59245 r59259 94 94 %define TMPL_NM(Name) _ %+ Name %+ _rm 95 95 %define BS3_CMN_NM(Name) _ %+ Name %+ _c16 96 %define TMPL_UNDERSCORE _ 97 %define TMPL_MODE_LNAME rm 98 %define TMPL_MODE_UNAME RM 96 99 %define TMPL_MODE_STR 'real mode' 97 100 %define TMPL_HAVE_BIOS … … 143 146 %define TMPL_NM(Name) _ %+ Name %+ _pe16 144 147 %define BS3_CMN_NM(Name) _ %+ Name %+ _c16 148 %define TMPL_UNDERSCORE _ 149 %define TMPL_MODE_LNAME pe16 150 %define TMPL_MODE_UNAME PE16 145 151 %define TMPL_MODE_STR '16-bit unpaged protected mode' 146 152 %endif … … 190 196 %define TMPL_NM(Name) _ %+ Name %+ _pe32 191 197 %define BS3_CMN_NM(Name) _ %+ Name %+ _c32 198 %define TMPL_UNDERSCORE _ 199 %define TMPL_MODE_LNAME pe32 200 %define TMPL_MODE_UNAME PE32 192 201 %define TMPL_MODE_STR '32-bit unpaged protected mode' 193 202 %endif … … 238 247 %define TMPL_NM(Name) _ %+ Name %+ _pev86 239 248 %define BS3_CMN_NM(Name) _ %+ Name %+ _c16 249 %define TMPL_UNDERSCORE _ 250 %define TMPL_MODE_LNAME pev86 251 %define TMPL_MODE_UNAME PEV86 240 252 %define TMPL_MODE_STR 'v8086 unpaged protected mode' 241 253 %endif … … 285 297 %define TMPL_NM(Name) _ %+ Name %+ _pp16 286 298 %define BS3_CMN_NM(Name) _ %+ Name %+ _c16 299 %define TMPL_UNDERSCORE _ 300 %define TMPL_MODE_LNAME pp16 301 %define TMPL_MODE_UNAME PP16 287 302 %define TMPL_MODE_STR '16-bit paged protected mode' 288 303 %endif … … 332 347 %define TMPL_NM(Name) _ %+ Name %+ _pp32 333 348 %define BS3_CMN_NM(Name) _ %+ Name %+ _c32 349 %define TMPL_UNDERSCORE _ 350 %define TMPL_MODE_LNAME pp32 351 %define TMPL_MODE_UNAME PP32 334 352 %define TMPL_MODE_STR '32-bit paged protected mode' 335 353 %endif … … 378 396 %define TMPL_BITS 16 379 397 %define TMPL_PTR_DEF dw 380 %define TMPL_NM(Name) Name %+ _ppv86 381 %define BS3_CMN_NM(Name) Name %+ _c86 398 %define TMPL_NM(Name) _ %+ Name %+ _ppv86 399 %define BS3_CMN_NM(Name) _ %+ Name %+ _c86 400 %define TMPL_UNDERSCORE _ 401 %define TMPL_MODE_LNAME ppv86 402 %define TMPL_MODE_UNAME PPV86 382 403 %define TMPL_MODE_STR 'v8086 paged protected mode' 383 404 %endif … … 427 448 %define TMPL_NM(Name) _ %+ Name %+ _pae16 428 449 %define BS3_CMN_NM(Name) _ %+ Name %+ _c16 450 %define TMPL_UNDERSCORE _ 451 %define TMPL_MODE_LNAME pae16 452 %define TMPL_MODE_UNAME PAE16 429 453 %define TMPL_MODE_STR '16-bit pae protected mode' 430 454 %endif … … 474 498 %define TMPL_NM(Name) _ %+ Name %+ _pae32 475 499 %define BS3_CMN_NM(Name) _ %+ Name %+ _c32 500 %define TMPL_UNDERSCORE _ 501 %define TMPL_MODE_LNAME pae32 502 %define TMPL_MODE_UNAME PAE32 476 503 %define TMPL_MODE_STR '32-bit pae protected mode' 477 504 %endif … … 522 549 %define TMPL_NM(Name) _ %+ Name %+ _paev86 523 550 %define BS3_CMN_NM(Name) _ %+ Name %+ _c86 551 %define TMPL_UNDERSCORE _ 552 %define TMPL_MODE_LNAME paev86 553 %define TMPL_MODE_UNAME PAEV86 524 554 %define TMPL_MODE_STR 'v8086 pae protected mode' 525 555 %endif … … 569 599 %define TMPL_NM(Name) _ %+ Name %+ _lm16 570 600 %define BS3_CMN_NM(Name) _ %+ Name %+ _c16 601 %define TMPL_UNDERSCORE _ 602 %define TMPL_MODE_LNAME lm16 603 %define TMPL_MODE_UNAME LM16 571 604 %define TMPL_MODE_STR '16-bit long mode' 572 605 %endif … … 616 649 %define TMPL_NM(Name) _ %+ Name %+ _lm32 617 650 %define BS3_CMN_NM(Name) _ %+ Name %+ _c32 651 %define TMPL_UNDERSCORE _ 652 %define TMPL_MODE_LNAME lm32 653 %define TMPL_MODE_UNAME LM32 618 654 %define TMPL_MODE_STR '32-bit long mode' 619 655 %endif … … 663 699 %define TMPL_NM(Name) Name %+ _lm64 ; No underscore (C/C++ compatibility). 664 700 %define BS3_CMN_NM(Name) Name %+ _c64 ; No underscore (C/C++ compatibility). 701 %define TMPL_UNDERSCORE 702 %define TMPL_MODE_LNAME lm64 703 %define TMPL_MODE_UNAME LM64 665 704 %define TMPL_MODE_STR '64-bit long mode' 666 705 %endif … … 668 707 %ifndef TMPL_MODE_STR 669 708 %error "internal error" 709 %endif 710 711 %ifnidn TMPL_UNDERSCORE,_; RT_CONCAT3 doesn't work with TMPL_UNDERSCORE being empty. duh. 712 %ifidn RT_CONCAT(TestName_,TMPL_MODE_LNAME),TMPL_NM(TestName) 713 %else 714 %error internal error: RT_CONCAT(TestName_,TMPL_MODE_LNAME) vs TMPL_NM(TestName) 715 %endif 716 %else 717 %ifidn RT_CONCAT3(TMPL_UNDERSCORE,TestName_,TMPL_MODE_LNAME),TMPL_NM(TestName) 718 %else 719 %error internal error: RT_CONCAT3(TMPL_UNDERSCORE,TestName_,TMPL_MODE_LNAME) vs TMPL_NM(TestName) 720 %endif 721 %endif 722 723 ; TMPL_NM version with uppercased suffix and no underscore separating them. 724 %ifnidn TMPL_UNDERSCORE,_ 725 %define TMPL_NM_U(Name) Name %+ TMPL_MODE_UNAME 726 %else 727 %define TMPL_NM_U(Name) TMPL_UNDERSCORE %+ Name %+ TMPL_MODE_UNAME 670 728 %endif 671 729 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.h
r59258 r59259 447 447 448 448 449 /** The system call vector. */ 450 #define BS3_TRAP_SYSCALL UINT8_C(0x20) 451 452 /** @name System call numbers (ax). 453 * Paramenters are generally passed in registers specific to each system call. 454 * @{ */ 455 /** Print char (cl). */ 456 #define BS3_SYSCALL_PRINT_CHR UINT16_C(0x0001) 457 /** Print string (pointer in ds:[e]si, length in cx). */ 458 #define BS3_SYSCALL_PRINT_STR UINT16_C(0x0002) 459 /** Switch to ring-0. */ 460 #define BS3_SYSCALL_TO_RING0 UINT16_C(0x0003) 461 /** Switch to ring-1. */ 462 #define BS3_SYSCALL_TO_RING1 UINT16_C(0x0004) 463 /** Switch to ring-2. */ 464 #define BS3_SYSCALL_TO_RING2 UINT16_C(0x0005) 465 /** Switch to ring-3. */ 466 #define BS3_SYSCALL_TO_RING3 UINT16_C(0x0006) 467 /** @} */ 468 469 449 470 450 471 /** @defgroup grp_bs3kit_system System structures … … 1684 1705 * @param cParams The parameter count (for call gates). 1685 1706 */ 1686 BS3_DECL(void) Bs3Trap32SetGate(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint32_t off, uint8_t cParams); 1687 1688 /** The address of Bs3Idt32GenericEntries. 1689 * Bs3Idt32GenericEntries is an array of interrupt/trap/whatever entry 1707 BS3_DECL(void) Bs3Trap32SetGate_c16(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint32_t off, uint8_t cParams); 1708 BS3_DECL(void) Bs3Trap32SetGate_c32(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint32_t off, uint8_t cParams); /**< @copydoc Bs3Trap32SetGate_c16 */ 1709 BS3_DECL(void) Bs3Trap32SetGate_c64(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint32_t off, uint8_t cParams); /**< @copydoc Bs3Trap32SetGate_c16 */ 1710 #define Bs3Trap32SetGate BS3_CMN_NM(Bs3Trap32SetGate) /**< Selects #Bs3Trap32SetGate_c16, #Bs3Trap32SetGate_c32 or #Bs3Trap32SetGate_c64. */ 1711 1712 /** The address of Bs3Trap32GenericEntries. 1713 * Bs3Trap32GenericEntries is an array of interrupt/trap/whatever entry 1690 1714 * points, 8 bytes each, that will create a register frame and call the generic 1691 1715 * C compatible trap handlers. */ 1692 extern uint32_t BS3_DATA_NM(g_Bs3Idt32GenericEntriesFlatAddr); 1716 extern uint32_t BS3_DATA_NM(g_Bs3Trap32GenericEntriesFlatAddr); 1717 1718 /** 1719 * Modifies the 64-bit IDT entry specified by @a iIdt. 1720 * 1721 * @param iIdt The index of the IDT entry to set. 1722 * @param bType The gate type (X86_SEL_TYPE_SYS_XXX). 1723 * @param bDpl The DPL. 1724 * @param uSel The handler selector. 1725 * @param off The handler offset (if applicable). 1726 * @param bIst The interrupt stack to use. 1727 */ 1728 BS3_DECL(void) Bs3Trap64SetGate_c16(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint64_t off, uint8_t bIst); 1729 BS3_DECL(void) Bs3Trap64SetGate_c32(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint64_t off, uint8_t bIst); /**< @copydoc Bs3Trap64SetGate_c16 */ 1730 BS3_DECL(void) Bs3Trap64SetGate_c64(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint64_t off, uint8_t bIst); /**< @copydoc Bs3Trap64SetGate_c16 */ 1731 #define Bs3Trap64SetGate BS3_CMN_NM(Bs3Trap64SetGate) /**< Selects #Bs3Trap64SetGate_c16, #Bs3Trap64SetGate_c32 or #Bs3Trap64SetGate_c64. */ 1732 1733 /** The address of Bs3Trap64GenericEntries. 1734 * Bs3Trap64GenericEntries is an array of interrupt/trap/whatever entry 1735 * points, 8 bytes each, that will create a register frame and call the generic 1736 * C compatible trap handlers. */ 1737 extern uint32_t BS3_DATA_NM(g_Bs3Trap64GenericEntriesFlatAddr); 1738 1739 /** 1740 * C-style trap handler. 1741 * 1742 * Upon return Bs3Trap16ResumeFrame_c16, #Bs3Trap32ResumeFrame_c32, or 1743 * Bs3Trap64ResumeFrame_c64 will be called depending on the current template 1744 * context. 1745 * 1746 * @param pTrapFrame The trap frame. Registers can be modified. 1747 */ 1748 typedef BS3_DECL_CALLBACK(void) FNBS3TRAPHANDLER(PBS3TRAPFRAME pTrapFrame); 1749 /** Pointer to a trap handler (current template context). */ 1750 typedef FNBS3TRAPHANDLER *PFNBS3TRAPHANDLER; 1751 1752 /** 1753 * Sets a trap handler (C/C++/assembly) for the current bitness. 1754 * 1755 * When using a 32-bit IDT, only #Bs3TrapSetHandler_c32 will have any effect. 1756 * Likewise, when using a 16-bit IDT, only Bs3TrapSetHandler_c16 will make any 1757 * difference. Ditto 64-bit. 1758 * 1759 * Rational: It's mainly a C API, can't easily mix function pointers from other 1760 * bit counts in C. Use assembly helpers or something if that is necessary. 1761 * Besides, most of the real trap handling goes thru the default handler with 1762 * help of trap records. 1763 * 1764 * @returns Previous handler. 1765 * @param iIdt The index of the IDT entry to set. 1766 * @param pfnHandler Pointer to the handler. 1767 */ 1768 BS3_DECL(PFNBS3TRAPHANDLER) Bs3TrapSetHandler_c16(uint8_t iIdt, PFNBS3TRAPHANDLER pfnHandler); 1769 BS3_DECL(PFNBS3TRAPHANDLER) Bs3TrapSetHandler_c32(uint8_t iIdt, PFNBS3TRAPHANDLER pfnHandler); /**< @copydoc Bs3Trap32SetHandler_c16 */ 1770 BS3_DECL(PFNBS3TRAPHANDLER) Bs3TrapSetHandler_c64(uint8_t iIdt, PFNBS3TRAPHANDLER pfnHandler); /**< @copydoc Bs3Trap32SetHandler_c16 */ 1771 #define Bs3Trap32SetHandler BS3_CMN_NM(Bs3Trap32SetHandler) /**< Selects #Bs3Trap32SetHandler_c16, #Bs3Trap32SetHandler_c32 or #Bs3Trap32SetHandler_c64. */ 1693 1772 1694 1773 /** @} */ -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.mac
r59258 r59259 637 637 638 638 ;; The system call vector. 639 %define BS3_TRAP_SYSCALL 20h640 641 ;; @name System call numbers 639 %define BS3_TRAP_SYSCALL 20h 640 641 ;; @name System call numbers (ax) 642 642 ;; @{ 643 643 ;; Print char (cl). 644 %define BS3_SYSCALL_PRINT_CHR 0ca110001h 644 %define BS3_SYSCALL_PRINT_CHR 0001h 645 ;; Print string (pointer in ds:[e]si, length in cx). 646 %define BS3_SYSCALL_PRINT_STR 0002h 645 647 ;; Switch to ring-0. 646 %define BS3_SYSCALL_TO_RING0 0ca110002h648 %define BS3_SYSCALL_TO_RING0 0003h 647 649 ;; Switch to ring-1. 648 %define BS3_SYSCALL_TO_RING1 0ca110003h650 %define BS3_SYSCALL_TO_RING1 0004h 649 651 ;; Switch to ring-2. 650 %define BS3_SYSCALL_TO_RING2 0ca110004h652 %define BS3_SYSCALL_TO_RING2 0005h 651 653 ;; Switch to ring-3. 652 %define BS3_SYSCALL_TO_RING3 0ca110005h 654 %define BS3_SYSCALL_TO_RING3 0006h 655 ;; The last system call value. 656 %define BS3_SYSCALL_LAST BS3_SYSCALL_TO_RING3 653 657 ;; @} 654 658
Note:
See TracChangeset
for help on using the changeset viewer.