- Timestamp:
- Jan 8, 2016 10:08:40 AM (9 years ago)
- Location:
- trunk/src/VBox/ValidationKit/bootsectors/bs3kit
- Files:
-
- 34 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk
r59286 r59287 530 530 bs3-cmn-TestSendStrCmd.asm \ 531 531 bs3-cmn-TestIsVmmDevTestingPresent.asm \ 532 bs3-cmn-Trap16SetGate.c \ 532 533 bs3-cmn-Trap32Init.c \ 533 534 bs3-cmn-Trap32SetGate.c \ -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-c32-Trap32Generic.asm
r59286 r59287 205 205 shl ax, BS3_SEL_RING_SHIFT 206 206 or ax, cx 207 a nd ax, BS3_SEL_R0_DS32207 add ax, BS3_SEL_R0_DS32 208 208 mov ds, ax 209 209 mov es, ax -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-A20Disable.asm
r59239 r59287 40 40 BS3_PROC_BEGIN_CMN Bs3A20Disable 41 41 ; Must call both because they may be ORed together on real HW. 42 BS3_ONLY_64BIT_STMT sub rsp, 20h 42 43 call BS3_CMN_NM(Bs3A20DisableViaKbd) 43 44 call BS3_CMN_NM(Bs3A20DisableViaPortA) 45 BS3_ONLY_64BIT_STMT add rsp, 20h 44 46 ret 45 47 BS3_PROC_END_CMN Bs3A20Disable … … 78 80 pushf 79 81 cli 82 BS3_ONLY_64BIT_STMT sub rsp, 20h 80 83 81 84 call Bs3KbdWait … … 94 97 call Bs3KbdWait 95 98 99 BS3_ONLY_64BIT_STMT add rsp, 20h 96 100 popf 97 101 pop xAX -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-A20Enable.asm
r59239 r59287 41 41 push xBP 42 42 mov xBP, xSP 43 BS3_ONLY_64BIT_STMT sub rsp, 20h 43 44 44 45 call BS3_CMN_NM(Bs3A20EnableViaPortA) … … 62 63 pushf 63 64 cli 65 BS3_ONLY_64BIT_STMT sub rsp, 20h 64 66 65 67 call Bs3KbdWait … … 78 80 call Bs3KbdWait 79 81 82 BS3_ONLY_64BIT_STMT add rsp, 20h 80 83 popf 81 84 pop xAX -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-KbdWrite.asm
r59239 r59287 49 49 mov xBP, xSP 50 50 push xAX 51 BS3_ONLY_64BIT_STMT sub rsp, 20h 51 52 52 53 mov al, [xBP + xCB*2] … … 58 59 call Bs3KbdWait 59 60 61 BS3_ONLY_64BIT_STMT add rsp, 20h 60 62 pop xAX 61 63 leave -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PrintStrColonSpaces.asm
r58628 r59287 48 48 push xAX 49 49 push xDI 50 sub esp, 20h50 sub xSP, 20h 51 51 52 52 mov sAX, [xBP + xCB*2] … … 68 68 jb .next_space 69 69 70 add xSP, 20h 70 71 pop xDI 71 72 pop xAX -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PrintU32.asm
r58789 r59287 66 66 67 67 ; Print the string. 68 BS3_ONLY_64BIT_STMT add rsp, 18h 68 69 BS3_ONLY_16BIT_STMT push ss 69 70 push xBX 70 call Bs3PrintStr71 BS3_CALL Bs3PrintStr, 1 71 72 72 add xSP, 30h + BS3_ ONLY_16BIT(2 + )xCB73 add xSP, 30h + BS3_IF_16_32_64BIT(2, 0, 18h) + xCB 73 74 BS3_ONLY_16BIT_STMT pop ds 74 75 pop sBX -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PrintX32.asm
r58789 r59287 70 70 71 71 ; Print the string. 72 BS3_ONLY_64BIT_STMT add rsp, 18h 72 73 BS3_ONLY_16BIT_STMT push ss 73 74 push xBX 74 call Bs3PrintStr75 BS3_CALL Bs3PrintStr, 1 75 76 76 add xSP, 30h + BS3_ ONLY_16BIT(2 + )xCB77 add xSP, 30h + BS3_IF_16_32_64BIT(2, 0, 18h) + xCB 77 78 BS3_ONLY_16BIT_STMT pop ds 78 79 pop sBX -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchTo16Bit.asm
r59245 r59287 29 29 ;; 30 30 ; @cproto BS3_DECL(void) Bs3SwitchTo16Bit(void); 31 ; @remarks Does not require 20h of parameter scratch space in 64-bit mode. 31 32 ; 32 33 BS3_PROC_BEGIN_CMN Bs3SwitchTo16Bit -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchTo32Bit.asm
r59215 r59287 29 29 ;; 30 30 ; @cproto BS3_DECL(void) Bs3SwitchTo32Bit(void); 31 ; 32 ; @remarks Does not require 20h of parameter scratch space in 64-bit mode. 31 33 ; 32 34 BS3_PROC_BEGIN_CMN Bs3SwitchTo32Bit -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchTo64Bit.asm
r59245 r59287 31 31 ;; 32 32 ; @cproto BS3_DECL(void) Bs3SwitchTo64Bit(void); 33 ; 34 ; @remarks Does not require 20h of parameter scratch space in 64-bit mode. 33 35 ; 34 36 BS3_PROC_BEGIN_CMN Bs3SwitchTo64Bit -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchToRing0.asm
r58812 r59287 30 30 ; @cproto BS3_DECL(void) Bs3SwitchToRing0(void); 31 31 ; 32 ; @remarks Does not require 20h of parameter scratch space in 64-bit mode. 33 ; 32 34 BS3_PROC_BEGIN_CMN Bs3SwitchToRing0 33 35 push sAX -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchToRing1.asm
r59215 r59287 30 30 ; @cproto BS3_DECL(void) Bs3SwitchToRing1(void); 31 31 ; 32 ; @remarks Does not require 20h of parameter scratch space in 64-bit mode. 33 ; 32 34 BS3_PROC_BEGIN_CMN Bs3SwitchToRing1 33 35 push sAX -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchToRing2.asm
r58812 r59287 30 30 ; @cproto BS3_DECL(void) Bs3SwitchToRing2(void); 31 31 ; 32 ; @remarks Does not require 20h of parameter scratch space in 64-bit mode. 33 ; 32 34 BS3_PROC_BEGIN_CMN Bs3SwitchToRing2 33 35 push sAX -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchToRing3.asm
r58812 r59287 30 30 ; @cproto BS3_DECL(void) Bs3SwitchToRing3(void); 31 31 ; 32 ; @remarks Does not require 20h of parameter scratch space in 64-bit mode. 33 ; 32 34 BS3_PROC_BEGIN_CMN Bs3SwitchToRing3 33 35 push sAX -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Trap16SetGate.c
r59286 r59287 31 31 32 32 33 BS3_DECL(void) Bs3Trap 32SetGate(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint32_t off, uint8_t cParams)33 BS3_DECL(void) Bs3Trap16SetGate(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint16_t off, uint8_t cParams) 34 34 { 35 X86DESC BS3_FAR *pIdte = &BS3_DATA_NM(Bs3Idt 32)[iIdt];35 X86DESC BS3_FAR *pIdte = &BS3_DATA_NM(Bs3Idt16)[iIdt]; 36 36 37 37 BS3_ASSERT(bDpl <= 3); … … 39 39 BS3_ASSERT(cParams <= 15); 40 40 pIdte->Gate.u16OffsetLow = (uint16_t)off; 41 pIdte->Gate.u16OffsetHigh = (uint16_t)(off >> 16);41 pIdte->Gate.u16OffsetHigh = 0; 42 42 pIdte->Gate.u16Sel = uSel; 43 43 pIdte->Gate.u4ParmCount = cParams; -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-first-pe16.asm
r59286 r59287 68 68 BS3_EXTERN_CMN Bs3Trap32Init 69 69 70 extern _Bs3PrintChr_c16 70 71 extern _Bs3PrintChr_c32 71 72 extern Bs3PrintChr_c64 … … 77 78 call NAME(Bs3InitMemory_rm) ; Initialize the memory (must be done from real mode). 78 79 call Bs3Trap32Init 80 sub xSP, 20h ; for 64-bit calls. 79 81 call NAME(Bs3SwitchToPE16_rm) 82 push '1' 83 call NAME(Bs3PrintChr_c16) 80 84 81 85 call NAME(Bs3SwitchTo32Bit_c16) … … 83 87 call NAME(Bs3SwitchTo16Bit_c32) 84 88 BS3_SET_BITS 16 89 push '2' 90 call NAME(Bs3PrintChr_c16) 85 91 86 92 call NAME(Bs3SwitchToRM_pe16) … … 88 94 call NAME(Bs3SwitchToPE32_rm) 89 95 BS3_SET_BITS 32 96 push '3' 97 call NAME(Bs3PrintChr_c32) 90 98 call NAME(Bs3SwitchToRM_pe32) 91 99 BS3_SET_BITS 16 100 push '4' 101 call NAME(Bs3PrintChr_c16) 102 92 103 call NAME(Bs3SwitchToPE16_rm) 104 push '5' 105 call NAME(Bs3PrintChr_c16) 106 93 107 call NAME(Bs3SwitchToRM_pe16) 108 push '6' 109 call NAME(Bs3PrintChr_c16) 94 110 95 111 call NAME(Bs3SwitchToPP16_rm) 112 push '7' 113 call NAME(Bs3PrintChr_c16) 114 96 115 call NAME(Bs3SwitchToRM_pp16) 116 push '8' 117 call NAME(Bs3PrintChr_c16) 97 118 98 119 call NAME(Bs3SwitchToPP32_rm) 99 120 BS3_SET_BITS 32 100 push ' !'121 push '9' 101 122 call NAME(Bs3PrintChr_c32) 123 102 124 call NAME(Bs3SwitchToRM_pp32) 103 125 BS3_SET_BITS 16 126 push 'a' 127 call NAME(Bs3PrintChr_c16) 104 128 105 129 call NAME(Bs3SwitchToPAE32_rm) 106 130 BS3_SET_BITS 32 107 push ' ~'131 push 'b' 108 132 call NAME(Bs3PrintChr_c32) 133 109 134 call NAME(Bs3SwitchToRM_pae32) 110 135 BS3_SET_BITS 16 136 push 'c' 137 call NAME(Bs3PrintChr_c16) 111 138 112 139 call NAME(Bs3SwitchToPAE16_rm) 113 BS3_SET_BITS 32 140 push 'd' 141 call NAME(Bs3PrintChr_c16) 142 114 143 call NAME(Bs3SwitchToRM_pae16) 115 BS3_SET_BITS 16 144 push 'e' 145 call NAME(Bs3PrintChr_c16) 116 146 117 147 call NAME(Bs3SwitchToLM64_rm) 118 148 BS3_SET_BITS 64 119 ;; todo: push '~' 120 ;; todo: call Bs3PrintChr_c64 149 push 'f' 150 BS3_CALL Bs3PrintChr_c64,1 151 121 152 call Bs3SwitchToRM_lm64 122 153 BS3_SET_BITS 16 154 push 'g' 155 call NAME(Bs3PrintChr_c16) 123 156 124 157 ; -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-EnteredMode.asm
r59286 r59287 39 39 mov xBP, xSP 40 40 push xAX 41 42 ; 43 ; Load selectors, IDTs and stuff as appropriate. 41 %if TMPL_BITS == 64 42 push rcx 43 push rdx 44 push r8 45 push r9 46 %endif 47 48 ; 49 ; Load stack selector (not always necessary) and sometimes CS too. 50 ; 51 %ifdef TMPL_RM 52 xor ax, ax 53 %elifdef TMPL_CMN_V86 54 extern v86_versions_of_Bs3EnteredMode_should_not_be_dragged_into_the_link 55 call v86_versions_of_Bs3EnteredMode_should_not_be_dragged_into_the_link 56 %elif TMPL_BITS == 16 57 jmp BS3_SEL_R0_CS16:.reloaded_cs 58 .reloaded_cs: 59 mov ax, BS3_SEL_R0_SS16 60 %elif TMPL_BITS == 32 61 mov ax, BS3_SEL_R0_SS32 62 %elif TMPL_BITS == 64 63 mov ax, BS3_SEL_R0_DS64 64 %else 65 %error "TMPL_BITS" 66 %endif 67 mov ss, ax 68 69 ; 70 ; Load selector appropriate for accessing BS3SYSTEM16 data. 71 ; 72 %if TMPL_BITS == 16 73 mov ax, BS3_SEL_SYSTEM16 74 %else 75 mov ax, RT_CONCAT(BS3_SEL_R0_DS,TMPL_BITS) 76 %endif 77 mov ds, ax 78 79 ; 80 ; Load the appropritate IDT or IVT. 81 ; Always 64-bit in long mode, otherwise according to TMPL_BITS. 44 82 ; 45 83 %ifdef TMPL_CMN_R86 46 BS3_BEGIN_DATA16 47 BS3_EXTERN_SYSTEM16 Bs3Lidt_Ivt 48 TMPL_BEGIN_TEXT 49 extern TMPL_NM(Bs3TrapSystemCallHandler) 50 xor ax, ax 51 mov ss, ax 52 53 mov ax, BS3_SEL_SYSTEM16 54 mov ds, ax 84 BS3_EXTERN_SYSTEM16 Bs3Lidt_Ivt 85 TMPL_BEGIN_TEXT 55 86 lidt [Bs3Lidt_Ivt] 56 57 mov ax, BS3DATA16 87 %elifdef TMPL_CMN_LM 88 BS3_EXTERN_SYSTEM16 Bs3Lidt_Idt64 89 TMPL_BEGIN_TEXT 90 lidt [Bs3Lidt_Idt64 TMPL_WRT_SYSTEM16_OR_FLAT] 91 %else 92 BS3_EXTERN_SYSTEM16 RT_CONCAT(Bs3Lidt_Idt,TMPL_BITS) 93 TMPL_BEGIN_TEXT 94 lidt [RT_CONCAT(Bs3Lidt_Idt,TMPL_BITS) TMPL_WRT_SYSTEM16_OR_FLAT] 95 %endif 96 97 %ifndef TMPL_CMN_R86 98 ; 99 ; Load the appropriate task selector. 100 ; Always 64-bit in long mode, otherwise according to TMPL_BITS. 101 ; 102 mov ax, X86DESCGENERIC_BIT_OFF_TYPE + 1 ; For clearing the busy bit in the TSS descriptor type. 103 %ifdef TMPL_CMN_LM 104 BS3_EXTERN_SYSTEM16 Bs3Gdte_Tss64 105 TMPL_BEGIN_TEXT 106 btr [Bs3Gdte_Tss64 TMPL_WRT_SYSTEM16_OR_FLAT], ax 107 mov ax, BS3_SEL_TSS64 108 109 %elif TMPL_BITS == 16 110 BS3_EXTERN_SYSTEM16 Bs3Gdte_Tss16 111 BS3_EXTERN_SYSTEM16 Bs3Gdte_Tss16DoubleFault 112 TMPL_BEGIN_TEXT 113 btr [Bs3Gdte_Tss16 TMPL_WRT_SYSTEM16_OR_FLAT], ax 114 btr [Bs3Gdte_Tss16DoubleFault TMPL_WRT_SYSTEM16_OR_FLAT], ax 115 mov ax, BS3_SEL_TSS16 116 117 %elif TMPL_BITS == 32 118 BS3_EXTERN_SYSTEM16 Bs3Gdte_Tss32 119 BS3_EXTERN_SYSTEM16 Bs3Gdte_Tss32DoubleFault 120 BS3_EXTERN_SYSTEM16 Bs3Tss32 121 BS3_EXTERN_SYSTEM16 Bs3Tss32DoubleFault 122 TMPL_BEGIN_TEXT 123 btr [Bs3Gdte_Tss32 TMPL_WRT_SYSTEM16_OR_FLAT], ax 124 btr [Bs3Gdte_Tss32DoubleFault TMPL_WRT_SYSTEM16_OR_FLAT], ax 125 mov eax, cr3 126 mov [X86TSS32.cr3 + Bs3Tss32 TMPL_WRT_SYSTEM16_OR_FLAT], eax 127 mov [X86TSS32.cr3 + Bs3Tss32DoubleFault TMPL_WRT_SYSTEM16_OR_FLAT], eax 128 mov ax, BS3_SEL_TSS32 129 %else 130 %error "TMPL_BITS" 131 %endif 132 ltr ax 133 %endif ; !TMPL_CMN_R86 134 135 %ifndef TMPL_CMN_R86 136 ; 137 ; Load the LDT. 138 ; 139 mov ax, BS3_SEL_LDT 140 lldt ax 141 %endif 142 143 ; 144 ; Load ds and es. 145 ; 146 %ifdef TMPL_CMN_V86 147 mov ax, BS3_SEL_DATA16 148 %else 149 mov ax, RT_CONCAT(BS3_SEL_R0_DS,TMPL_BITS) 150 %endif 58 151 mov ds, ax 59 152 mov es, ax 60 153 154 ; 155 ; Install system call handler. 156 ; Always 64-bit in long mode, otherwise according to TMPL_BITS. 157 ; 158 %ifdef TMPL_CMN_RM 61 159 mov word [ss: BS3_TRAP_SYSCALL*4], TMPL_NM(Bs3TrapSystemCallHandler) wrt BS3TEXT16 62 160 mov word [ss: BS3_TRAP_SYSCALL*4 + 2], BS3TEXT16 161 %elifdef TMPL_CMN_LM 162 BS3_EXTERN_CMN Bs3Trap64SetGate 163 extern Bs3TrapSystemCallHandler_lm64 164 TMPL_BEGIN_TEXT 165 push 0 ; bIst 166 %ifdef TMPL_64BIT 167 push Bs3TrapSystemCallHandler_lm64 wrt FLAT 168 %else 169 push dword 0 ; upper offset 170 push dword Bs3TrapSystemCallHandler_lm64 wrt FLAT 171 %endif 172 push BS3_SEL_R0_CS64 173 push 3 ; DPL 174 push AMD64_SEL_TYPE_SYS_INT_GATE 175 push BS3_TRAP_SYSCALL 176 BS3_CALL Bs3Trap64SetGate,6 177 add xSP, xCB * 5 + 8 63 178 64 179 %elif TMPL_BITS == 16 65 BS3_EXTERN_SYSTEM16 Bs3Lidt_Idt16 66 BS3_EXTERN_SYSTEM16 Bs3Gdte_Tss16 67 BS3_EXTERN_SYSTEM16 Bs3Gdte_Tss16DoubleFault 68 TMPL_BEGIN_TEXT 69 jmp BS3_SEL_R0_CS16:.reloaded_cs 70 .reloaded_cs: 71 72 mov ax, BS3_SEL_R0_SS16 73 mov ss, ax 74 75 mov ax, BS3_SEL_SYSTEM16 76 mov ds, ax 77 lidt [Bs3Lidt_Idt16] 78 79 mov ax, X86DESCGENERIC_BIT_OFF_TYPE + 1 80 btr [Bs3Gdte_Tss16DoubleFault], ax ; mark it not busy 81 btr [Bs3Gdte_Tss16], ax ; mark it not busy 82 mov ax, BS3_SEL_TSS16 83 ltr ax 84 85 mov ax, BS3_SEL_LDT 86 lldt ax 87 88 mov ax, BS3_SEL_R0_DS16 89 mov ds, ax 90 mov es, ax 91 92 %ifndef TMPL_CMN_LM 93 ; BS3_EXTERN_CMN Bs3Trap32SetGate 94 ; extern TMPL_NM(Bs3TrapSystemCallHandler) 95 ; push 0 ; cParams 96 ; push TMPL_NM(Bs3TrapSystemCallHandler) wrt BS3TEXT16 97 ; push BS3_SEL_R0_CS16 98 ; push 3 ; DPL 99 ; push X86_SEL_TYPE_SYS_286_INT_GATE 100 ; push BS3_TRAP_SYSCALL 101 ; BS3_CALL Bs3Trap16SetGate,6 102 ; add sp, xCB * 6 103 %endif 180 BS3_EXTERN_CMN Bs3Trap16SetGate 181 extern TMPL_NM(Bs3TrapSystemCallHandler) 182 TMPL_BEGIN_TEXT 183 push 0 ; cParams 184 push TMPL_NM(Bs3TrapSystemCallHandler) wrt BS3TEXT16 185 push BS3_SEL_R0_CS16 186 push 3 ; DPL 187 push X86_SEL_TYPE_SYS_286_INT_GATE 188 push BS3_TRAP_SYSCALL 189 BS3_CALL Bs3Trap16SetGate,6 190 add xSP, xCB * 6 104 191 105 192 %elif TMPL_BITS == 32 106 BS3_EXTERN_SYSTEM16 Bs3Lidt_Idt32107 BS3_EXTERN_SYSTEM16 Bs3Gdte_Tss32108 BS3_EXTERN_SYSTEM16 Bs3Gdte_Tss32DoubleFault109 BS3_EXTERN_SYSTEM16 Bs3Tss32110 BS3_EXTERN_SYSTEM16 Bs3Tss32DoubleFault111 TMPL_BEGIN_TEXT112 mov ax, BS3_SEL_R0_SS32113 mov ss, ax114 115 mov ax, BS3_SEL_SYSTEM16116 mov ds, ax117 lidt [Bs3Lidt_Idt32]118 119 mov ax, X86DESCGENERIC_BIT_OFF_TYPE + 1120 btr [Bs3Gdte_Tss32DoubleFault], ax ; mark it not busy121 btr [Bs3Gdte_Tss32], ax ; mark it not busy122 mov eax, cr3123 mov [Bs3Tss32 + X86TSS32.cr3], eax124 mov [Bs3Tss32DoubleFault + X86TSS32.cr3], eax125 mov ax, BS3_SEL_TSS32126 ltr ax127 128 mov ax, BS3_SEL_LDT129 mov [Bs3Tss32 + X86TSS32.selLdt], ax130 lldt ax131 132 mov ax, BS3_SEL_R0_DS32133 mov ds, ax134 mov es, ax135 136 %ifndef TMPL_CMN_LM137 193 BS3_EXTERN_CMN Bs3Trap32SetGate 138 194 extern TMPL_NM(Bs3TrapSystemCallHandler) 195 TMPL_BEGIN_TEXT 139 196 push 0 ; cParams 140 197 push TMPL_NM(Bs3TrapSystemCallHandler) wrt FLAT … … 144 201 push BS3_TRAP_SYSCALL 145 202 BS3_CALL Bs3Trap32SetGate,6 146 add esp, xCB * 6 147 %endif 148 149 %elif TMPL_BITS == 64 150 BS3_EXTERN_SYSTEM16 Bs3Lidt_Idt64 151 BS3_EXTERN_SYSTEM16 Bs3Gdte_Tss64 152 TMPL_BEGIN_TEXT 153 mov ax, BS3_SEL_R0_DS64 154 mov ss, ax 155 156 mov ax, BS3_SEL_SYSTEM16 157 mov ds, ax 158 lidt [Bs3Lidt_Idt64] 159 160 mov eax, X86DESCGENERIC_BIT_OFF_TYPE + 1 161 btr [Bs3Gdte_Tss64], eax ; mark it not busy 162 mov ax, BS3_SEL_TSS64 163 ltr ax 164 165 mov ax, BS3_SEL_LDT 166 lldt ax 167 168 mov ax, BS3_SEL_R0_DS64 169 mov ds, ax 170 mov es, ax 171 203 add xSP, xCB * 6 172 204 %else 173 205 %error "TMPL_BITS" 174 206 %endif 175 207 176 %ifdef TMPL_CMN_LM 177 ; 178 ; In long mode we always use a 64-bit TSS and a IDT with all 64-bit gates. 179 ; 180 %if TMPL_BITS == 64 181 push rcx 182 push rdx 183 push r8 184 push r9 185 %endif 186 187 BS3_EXTERN_CMN Bs3Trap64SetGate 188 extern Bs3TrapSystemCallHandler_lm64 189 push 0 ; bIst 190 %ifdef TMPL_64BIT 191 push Bs3TrapSystemCallHandler_lm64 wrt FLAT 192 %else 193 push dword 0 ; upper offset 194 push dword Bs3TrapSystemCallHandler_lm64 wrt FLAT 195 %endif 196 push BS3_SEL_R0_CS64 197 push 3 ; DPL 198 push AMD64_SEL_TYPE_SYS_INT_GATE 199 push BS3_TRAP_SYSCALL 200 BS3_CALL Bs3Trap64SetGate,6 201 add xSP, xCB * 5 + 8 202 203 %if TMPL_BITS == 64 208 ; 209 ; Epilogue. 210 ; 211 %if TMPL_BITS == 64 204 212 pop r9 205 213 pop r8 206 214 pop rdx 207 215 pop rcx 208 %endif 209 %endif 210 216 %endif 211 217 pop xAX 212 218 leave -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-PagingGetRootForLM64.asm
r59286 r59287 86 86 ; Not a problematic addressing mode. 87 87 ; 88 call Bs3PagingInitRootForLM 88 BS3_ONLY_64BIT_STMT add rsp, 20h 89 BS3_CALL Bs3PagingInitRootForLM, 0 89 90 %endif 90 91 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-PagingGetRootForPAE32.asm
r59286 r59287 86 86 ; Not a problematic addressing mode. 87 87 ; 88 call Bs3PagingInitRootForPAE 88 BS3_ONLY_64BIT_STMT add rsp, 20h 89 BS3_CALL Bs3PagingInitRootForPAE, 0 89 90 %endif 90 91 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-PagingGetRootForPP32.asm
r59286 r59287 86 86 ; Not a problematic addressing mode. 87 87 ; 88 call Bs3PagingInitRootForPP 88 BS3_ONLY_64BIT_STMT add rsp, 20h 89 BS3_CALL Bs3PagingInitRootForPP, 0 89 90 %endif 90 91 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToLM16.asm
r59259 r59287 39 39 ; instead changes to ring-0. 40 40 ; 41 ; @remarks Does not require 20h of parameter scratch space in 64-bit mode. 42 ; 41 43 BS3_PROC_BEGIN_MODE Bs3SwitchToLM16 42 44 %ifdef TMPL_LM16 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToLM32.asm
r59259 r59287 41 41 ; or 64-bit mode. It doesn't not preserve the callers ring, but 42 42 ; instead changes to ring-0. 43 ; 44 ; @remarks Does not require 20h of parameter scratch space in 64-bit mode. 43 45 ; 44 46 BS3_PROC_BEGIN_MODE Bs3SwitchToLM32 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToLM64.asm
r59286 r59287 39 39 ; instead changes to ring-0. 40 40 ; 41 ; @remarks Does not require 20h of parameter scratch space in 64-bit mode. 42 ; 41 43 BS3_PROC_BEGIN_MODE Bs3SwitchToLM64 42 44 %ifdef TMPL_LM64 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPAE16.asm
r59244 r59287 44 44 ; @remarks Obviously returns to 16-bit mode, even if the caller was 45 45 ; in 32-bit or 64-bit mode. 46 ; 47 ; @remarks Does not require 20h of parameter scratch space in 64-bit mode. 46 48 ; 47 49 BS3_PROC_BEGIN_MODE Bs3SwitchToPAE16 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPAE32.asm
r59244 r59287 39 39 ; in 16-bit or 64-bit mode. It doesn't not preserve the callers 40 40 ; ring, but instead changes to ring-0. 41 ; 42 ; @remarks Does not require 20h of parameter scratch space in 64-bit mode. 41 43 ; 42 44 BS3_PROC_BEGIN_MODE Bs3SwitchToPAE32 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPE16.asm
r59242 r59287 37 37 ; @remarks Obviously returns to 16-bit mode, even if the caller was 38 38 ; in 32-bit or 64-bit mode. 39 ; 40 ; @remarks Does not require 20h of parameter scratch space in 64-bit mode. 39 41 ; 40 42 BS3_PROC_BEGIN_MODE Bs3SwitchToPE16 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPE32.asm
r59242 r59287 38 38 ; @remarks Obviously returns to 32-bit mode, even if the caller was 39 39 ; in 16-bit or 64-bit mode. 40 ; 41 ; @remarks Does not require 20h of parameter scratch space in 64-bit mode. 40 42 ; 41 43 BS3_PROC_BEGIN_MODE Bs3SwitchToPE32 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPP16.asm
r59242 r59287 44 44 ; @remarks Obviously returns to 16-bit mode, even if the caller was 45 45 ; in 32-bit or 64-bit mode. 46 ; 47 ; @remarks Does not require 20h of parameter scratch space in 64-bit mode. 46 48 ; 47 49 BS3_PROC_BEGIN_MODE Bs3SwitchToPP16 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPP32.asm
r59242 r59287 39 39 ; in 16-bit or 64-bit mode. It doesn't not preserve the callers 40 40 ; ring, but instead changes to ring-0. 41 ; 42 ; @remarks Does not require 20h of parameter scratch space in 64-bit mode. 41 43 ; 42 44 BS3_PROC_BEGIN_MODE Bs3SwitchToPP32 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToRM.asm
r59245 r59287 40 40 ; @remarks Obviously returns to 16-bit mode, even if the caller was 41 41 ; in 32-bit or 64-bit mode. 42 ; 43 ; @remarks Does not require 20h of parameter scratch space in 64-bit mode. 42 44 ; 43 45 BS3_PROC_BEGIN_MODE Bs3SwitchToRM … … 115 117 pop eax 116 118 pop eax 117 retn 6118 119 %else 119 120 popfd 120 121 pop ebx 121 122 pop eax 122 retn 2123 123 %endif 124 retn BS3_IF_16_32_64BIT(0, 2, 6) 124 125 125 126 %if TMPL_BITS != 16 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-TrapSystemCallHandler.asm
r59286 r59287 115 115 .print_chr: 116 116 %ifndef TMPL_CMN_R86 117 ; Switch to real mode .117 ; Switch to real mode (20h param scratch area not required). 118 118 extern TMPL_NM(Bs3SwitchToRM) 119 119 call TMPL_NM(Bs3SwitchToRM) … … 128 128 129 129 %ifndef TMPL_CMN_R86 130 ; Switch back .130 ; Switch back (20h param scratch area not required). 131 131 extern RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_rm) 132 132 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_rm) -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-template-header.mac
r59259 r59287 848 848 %endif 849 849 850 ;; @def TMPL_WRT_SYSTEM16_OR_FLAT 851 ; WRT BS3SYSTEM16 in 16-bit mode, WRT FLAT in 32- and 64-bit modes. 852 ; This is important when accessing global variables in the BS3SYSTEM16 segment. 853 %ifdef TMPL_16BIT 854 %define TMPL_WRT_SYSTEM16_OR_FLAT wrt BS3SYSTEM16 855 %else 856 %define TMPL_WRT_SYSTEM16_OR_FLAT wrt FLAT 857 %endif 858 850 859 ; 851 860 ; Default code segment (changes BITS too). -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.h
r59286 r59287 1745 1745 * @param cParams The parameter count (for call gates). 1746 1746 */ 1747 BS3_DECL(void) Bs3Trap16SetGate_c16(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint 32_t off, uint8_t cParams);1748 BS3_DECL(void) Bs3Trap16SetGate_c32(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint 32_t off, uint8_t cParams); /**< @copydoc Bs3Trap16SetGate_c16 */1749 BS3_DECL(void) Bs3Trap16SetGate_c64(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint 32_t off, uint8_t cParams); /**< @copydoc Bs3Trap16SetGate_c16 */1747 BS3_DECL(void) Bs3Trap16SetGate_c16(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint16_t off, uint8_t cParams); 1748 BS3_DECL(void) Bs3Trap16SetGate_c32(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint16_t off, uint8_t cParams); /**< @copydoc Bs3Trap16SetGate_c16 */ 1749 BS3_DECL(void) Bs3Trap16SetGate_c64(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint16_t off, uint8_t cParams); /**< @copydoc Bs3Trap16SetGate_c16 */ 1750 1750 #define Bs3Trap16SetGate BS3_CMN_NM(Bs3Trap16SetGate) /**< Selects #Bs3Trap16SetGate_c16, #Bs3Trap16SetGate_c32 or #Bs3Trap16SetGate_c64. */ 1751 1751 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.mac
r59286 r59287 63 63 %endif 64 64 65 %undef BS3_ONLY_64BIT 66 %if %1 == 64 67 %define BS3_ONLY_64BIT(a_Expr) a_Expr 68 %else 69 %define BS3_ONLY_64BIT(a_Expr) 70 %endif 71 72 %undef BS3_IF_16_32_64BIT 73 %if %1 == 16 74 %define BS3_IF_16_32_64BIT(a_16BitExpr, a_32BitExpr, a_64BitExpr) a_16BitExpr 75 %elif %1 == 32 76 %define BS3_IF_16_32_64BIT(a_16BitExpr, a_32BitExpr, a_64BitExpr) a_32BitExpr 77 %else 78 %define BS3_IF_16_32_64BIT(a_16BitExpr, a_32BitExpr, a_64BitExpr) a_64BitExpr 79 %endif 80 65 81 %undef BS3_WRT_RIP 66 82 %if %1 == 64 … … 68 84 %else 69 85 %define BS3_WRT_RIP 86 %endif 87 88 %undef BS3_IF_16BIT_OTHERWISE 89 %if %1 == 16 90 %define BS3_IF_16BIT_OTHERWISE(a_16BitExpr, a_OtherwiseExpr) a_16BitExpr 91 %else 92 %define BS3_IF_16BIT_OTHERWISE(a_16BitExpr, a_OtherwiseExpr) a_OtherwiseExpr 93 %endif 94 95 %undef BS3_IF_32BIT_OTHERWISE 96 %if %1 == 32 97 %define BS3_IF_32BIT_OTHERWISE(a_32BitExpr, a_OtherwiseExpr) a_32BitExpr 98 %else 99 %define BS3_IF_32BIT_OTHERWISE(a_32BitExpr, a_OtherwiseExpr) a_OtherwiseExpr 100 %endif 101 102 %undef BS3_IF_64BIT_OTHERWISE 103 %if %1 == 32 104 %define BS3_IF_64BIT_OTHERWISE(a_64BitExpr, a_OtherwiseExpr) a_32BitExpr 105 %else 106 %define BS3_IF_64BIT_OTHERWISE(a_64BitExpr, a_OtherwiseExpr) a_OtherwiseExpr 70 107 %endif 71 108 %endmacro … … 97 134 %define BS3_ONLY_16BIT(a_Expr) 98 135 %endif 136 137 ;; For odd 64-bit stuff. Follows BS3_SET_BITS. 138 %if ARCH_BITS == 64 139 %define BS3_ONLY_64BIT(a_Expr) a_Expr 140 %else 141 %define BS3_ONLY_64BIT(a_Expr) 142 %endif 143 144 ;; For stack cleanups and similar where each bit mode is different. Follows BS3_SET_BITS. 145 %if ARCH_BITS == 16 146 %define BS3_IF_16_32_64BIT(a_16BitExpr, a_32BitExpr, a_64BitExpr) a_16BitExpr 147 %elif ARCH_BITS == 32 148 %define BS3_IF_16_32_64BIT(a_16BitExpr, a_32BitExpr, a_64BitExpr) a_32BitExpr 149 %else 150 %define BS3_IF_16_32_64BIT(a_16BitExpr, a_32BitExpr, a_64BitExpr) a_64BitExpr 151 %endif 152 99 153 100 154 ;; … … 506 560 %if __BITS__ == 64 507 561 %if %2 >= 1 508 mov rcx, [rsp + 008h]562 mov rcx, [rsp] 509 563 %ifdef BS3_STRICT 510 and qword [rsp + 008h], 11h564 and qword [rsp], 11h 511 565 %endif 512 566 %endif 513 567 %if %2 >= 2 514 mov rdx, [rsp + 0 10h]568 mov rdx, [rsp + 008h] 515 569 %ifdef BS3_STRICT 516 and qword [rsp + 0 10h], 12h570 and qword [rsp + 008h], 12h 517 571 %endif 518 572 %endif 519 573 %if %2 >= 3 520 mov r8, [rsp + 01 8h]574 mov r8, [rsp + 010h] 521 575 %ifdef BS3_STRICT 522 and qword [rsp + 01 8h], 13h576 and qword [rsp + 010h], 13h 523 577 %endif 524 578 %endif 525 579 %if %2 >= 4 526 mov r9, [rsp + 0 20h]580 mov r9, [rsp + 018h] 527 581 %ifdef BS3_STRICT 528 and qword [rsp + 0 20h], 14h582 and qword [rsp + 018h], 14h 529 583 %endif 530 584 %endif
Note:
See TracChangeset
for help on using the changeset viewer.