Changeset 58459 in vbox for trunk/src/VBox/Devices/EFI/Firmware/UefiCpuPkg/CpuDxe/Ia32
- Timestamp:
- Oct 28, 2015 8:17:18 PM (9 years ago)
- Location:
- trunk/src/VBox/Devices/EFI/Firmware
- Files:
-
- 2 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/EFI/Firmware
-
Property svn:mergeinfo
set to (toggle deleted branches)
/vendor/edk2/current 103735-103757
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/VBox/Devices/EFI/Firmware/UefiCpuPkg/CpuDxe/Ia32/CpuAsm.S
r48674 r58459 1 1 #------------------------------------------------------------------------------ 2 2 #* 3 #* Copyright (c) 2006 - 201 1, Intel Corporation. All rights reserved.<BR>3 #* Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR> 4 4 #* This program and the accompanying materials 5 5 #* are licensed and made available under the terms and conditions of the BSD License … … 19 19 #.MMX 20 20 #.XMM 21 22 #EXTRN ASM_PFX(mErrorCodeFlag):DWORD # Error code flags for exceptions23 24 25 #26 # point to the external interrupt vector table27 #28 ExternalVectorTablePtr:29 .byte 0, 0, 0, 030 31 ASM_GLOBAL ASM_PFX(InitializeExternalVectorTablePtr)32 ASM_PFX(InitializeExternalVectorTablePtr):33 movl 4(%esp), %eax34 movl %eax, ExternalVectorTablePtr35 ret36 21 37 22 #------------------------------------------------------------------------------ … … 69 54 ret 70 55 71 #---------------------------------------;72 # CommonInterruptEntry ;73 #---------------------------------------;74 # The follow algorithm is used for the common interrupt routine.75 76 ASM_GLOBAL ASM_PFX(CommonInterruptEntry)77 ASM_PFX(CommonInterruptEntry):78 cli79 #80 # All interrupt handlers are invoked through interrupt gates, so81 # IF flag automatically cleared at the entry point82 #83 84 #85 # Calculate vector number86 #87 # Get the return address of call, actually, it is the88 # address of vector number.89 #90 xchgl (%esp), %ecx91 movw (%ecx), %cx92 andl $0x0FFFF, %ecx93 cmpl $32, %ecx # Intel reserved vector for exceptions?94 jae NoErrorCode95 bt %ecx, ASM_PFX(mErrorCodeFlag)96 jc HasErrorCode97 98 NoErrorCode:99 100 #101 # Stack:102 # +---------------------+103 # + EFlags +104 # +---------------------+105 # + CS +106 # +---------------------+107 # + EIP +108 # +---------------------+109 # + ECX +110 # +---------------------+ <-- ESP111 #112 # Registers:113 # ECX - Vector Number114 #115 116 #117 # Put Vector Number on stack118 #119 pushl %ecx120 121 #122 # Put 0 (dummy) error code on stack, and restore ECX123 #124 xorl %ecx, %ecx # ECX = 0125 xchgl 4(%esp), %ecx126 127 jmp ErrorCodeAndVectorOnStack128 129 HasErrorCode:130 131 #132 # Stack:133 # +---------------------+134 # + EFlags +135 # +---------------------+136 # + CS +137 # +---------------------+138 # + EIP +139 # +---------------------+140 # + Error Code +141 # +---------------------+142 # + ECX +143 # +---------------------+ <-- ESP144 #145 # Registers:146 # ECX - Vector Number147 #148 149 #150 # Put Vector Number on stack and restore ECX151 #152 xchgl (%esp), %ecx153 154 #155 # Fall through to join main routine code156 # at ErrorCodeAndVectorOnStack157 #158 CommonInterruptEntry_al_0000:159 jmp CommonInterruptEntry_al_0000160 161 ErrorCodeAndVectorOnStack:162 pushl %ebp163 movl %esp, %ebp164 165 #166 # Stack:167 # +---------------------+168 # + EFlags +169 # +---------------------+170 # + CS +171 # +---------------------+172 # + EIP +173 # +---------------------+174 # + Error Code +175 # +---------------------+176 # + Vector Number +177 # +---------------------+178 # + EBP +179 # +---------------------+ <-- EBP180 #181 182 #183 # Align stack to make sure that EFI_FX_SAVE_STATE_IA32 of EFI_SYSTEM_CONTEXT_IA32184 # is 16-byte aligned185 #186 andl $0x0fffffff0, %esp187 subl $12, %esp188 189 #; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax;190 pushl %eax191 pushl %ecx192 pushl %edx193 pushl %ebx194 leal 24(%ebp), %ecx195 pushl %ecx # ESP196 pushl (%ebp) # EBP197 pushl %esi198 pushl %edi199 200 #; UINT32 Gs, Fs, Es, Ds, Cs, Ss;201 movl %ss, %eax202 pushl %eax203 movzwl 16(%ebp), %eax204 pushl %eax205 movl %ds, %eax206 pushl %eax207 movl %es, %eax208 pushl %eax209 movl %fs, %eax210 pushl %eax211 movl %gs, %eax212 pushl %eax213 214 #; UINT32 Eip;215 movl 12(%ebp), %eax216 pushl %eax217 218 #; UINT32 Gdtr[2], Idtr[2];219 subl $8, %esp220 sidt (%esp)221 movl 2(%esp), %eax222 xchgl (%esp), %eax223 andl $0x0FFFF, %eax224 movl %eax, 4(%esp)225 226 subl $8, %esp227 sgdt (%esp)228 movl 2(%esp), %eax229 xchgl (%esp), %eax230 andl $0x0FFFF, %eax231 movl %eax, 4(%esp)232 233 #; UINT32 Ldtr, Tr;234 xorl %eax, %eax235 str %ax236 pushl %eax237 sldt %ax238 pushl %eax239 240 #; UINT32 EFlags;241 movl 20(%ebp), %eax242 pushl %eax243 244 #; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4;245 movl %cr4, %eax246 orl $0x208, %eax247 movl %eax, %cr4248 pushl %eax249 movl %cr3, %eax250 pushl %eax251 movl %cr2, %eax252 pushl %eax253 xorl %eax, %eax254 pushl %eax255 movl %cr0, %eax256 pushl %eax257 258 #; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7;259 movl %dr7, %eax260 pushl %eax261 movl %dr6, %eax262 pushl %eax263 movl %dr3, %eax264 pushl %eax265 movl %dr2, %eax266 pushl %eax267 movl %dr1, %eax268 pushl %eax269 movl %dr0, %eax270 pushl %eax271 272 #; FX_SAVE_STATE_IA32 FxSaveState;273 subl $512, %esp274 movl %esp, %edi275 .byte 0x0f, 0x0ae, 0x07 #fxsave [edi]276 277 #; UEFI calling convention for IA32 requires that Direction flag in EFLAGs is clear278 cld279 280 #; UINT32 ExceptionData;281 pushl 8(%ebp)282 283 #; call into exception handler284 movl ExternalVectorTablePtr, %eax # get the interrupt vectors base285 orl %eax, %eax # NULL?286 jz nullExternalExceptionHandler287 288 mov 4(%ebp), %ecx289 movl (%eax,%ecx,4), %eax290 orl %eax, %eax # NULL?291 jz nullExternalExceptionHandler292 293 #; Prepare parameter and call294 movl %esp, %edx295 pushl %edx296 movl 4(%ebp), %edx297 pushl %edx298 299 #300 # Call External Exception Handler301 #302 call *%eax303 addl $8, %esp304 305 nullExternalExceptionHandler:306 307 cli308 #; UINT32 ExceptionData;309 addl $4, %esp310 311 #; FX_SAVE_STATE_IA32 FxSaveState;312 movl %esp, %esi313 .byte 0x0f, 0x0ae, 0x0e # fxrstor [esi]314 addl $512, %esp315 316 #; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7;317 #; Skip restoration of DRx registers to support in-circuit emualators318 #; or debuggers set breakpoint in interrupt/exception context319 addl $24, %esp320 321 #; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4;322 popl %eax323 movl %eax, %cr0324 addl $4, %esp # not for Cr1325 popl %eax326 movl %eax, %cr2327 popl %eax328 movl %eax, %cr3329 popl %eax330 movl %eax, %cr4331 332 #; UINT32 EFlags;333 popl 20(%ebp)334 335 #; UINT32 Ldtr, Tr;336 #; UINT32 Gdtr[2], Idtr[2];337 #; Best not let anyone mess with these particular registers...338 addl $24, %esp339 340 #; UINT32 Eip;341 popl 12(%ebp)342 343 #; UINT32 Gs, Fs, Es, Ds, Cs, Ss;344 #; NOTE - modified segment registers could hang the debugger... We345 #; could attempt to insulate ourselves against this possibility,346 #; but that poses risks as well.347 #;348 popl %gs349 popl %fs350 popl %es351 popl %ds352 popl 16(%ebp)353 popl %ss354 355 #; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax;356 popl %edi357 popl %esi358 addl $4, %esp # not for ebp359 addl $4, %esp # not for esp360 popl %ebx361 popl %edx362 popl %ecx363 popl %eax364 365 movl %ebp, %esp366 popl %ebp367 addl $8, %esp368 iretl369 370 371 56 #END 372 57 -
trunk/src/VBox/Devices/EFI/Firmware/UefiCpuPkg/CpuDxe/Ia32/CpuAsm.asm
r48674 r58459 2 2 ;------------------------------------------------------------------------------ 3 3 ;* 4 ;* Copyright (c) 2006 - 201 1, Intel Corporation. All rights reserved.<BR>4 ;* Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR> 5 5 ;* This program and the accompanying materials 6 6 ;* are licensed and made available under the terms and conditions of the BSD License … … 20 20 .model flat,C 21 21 .code 22 23 EXTRN mErrorCodeFlag:DWORD ; Error code flags for exceptions24 25 ;26 ; point to the external interrupt vector table27 ;28 ExternalVectorTablePtr DWORD 029 30 InitializeExternalVectorTablePtr PROC PUBLIC31 mov eax, [esp+4]32 mov ExternalVectorTablePtr, eax33 ret34 InitializeExternalVectorTablePtr ENDP35 22 36 23 ;------------------------------------------------------------------------------ … … 68 55 SetDataSelectors ENDP 69 56 70 ;---------------------------------------;71 ; CommonInterruptEntry ;72 ;---------------------------------------;73 ; The follow algorithm is used for the common interrupt routine.74 75 CommonInterruptEntry PROC PUBLIC76 cli77 ;78 ; All interrupt handlers are invoked through interrupt gates, so79 ; IF flag automatically cleared at the entry point80 ;81 82 ;83 ; Calculate vector number84 ;85 ; Get the return address of call, actually, it is the86 ; address of vector number.87 ;88 xchg ecx, [esp]89 mov cx, [ecx]90 and ecx, 0FFFFh91 cmp ecx, 32 ; Intel reserved vector for exceptions?92 jae NoErrorCode93 bt mErrorCodeFlag, ecx94 jc HasErrorCode95 96 NoErrorCode:97 98 ;99 ; Stack:100 ; +---------------------+101 ; + EFlags +102 ; +---------------------+103 ; + CS +104 ; +---------------------+105 ; + EIP +106 ; +---------------------+107 ; + ECX +108 ; +---------------------+ <-- ESP109 ;110 ; Registers:111 ; ECX - Vector Number112 ;113 114 ;115 ; Put Vector Number on stack116 ;117 push ecx118 119 ;120 ; Put 0 (dummy) error code on stack, and restore ECX121 ;122 xor ecx, ecx ; ECX = 0123 xchg ecx, [esp+4]124 125 jmp ErrorCodeAndVectorOnStack126 127 HasErrorCode:128 129 ;130 ; Stack:131 ; +---------------------+132 ; + EFlags +133 ; +---------------------+134 ; + CS +135 ; +---------------------+136 ; + EIP +137 ; +---------------------+138 ; + Error Code +139 ; +---------------------+140 ; + ECX +141 ; +---------------------+ <-- ESP142 ;143 ; Registers:144 ; ECX - Vector Number145 ;146 147 ;148 ; Put Vector Number on stack and restore ECX149 ;150 xchg ecx, [esp]151 152 ;153 ; Fall through to join main routine code154 ; at ErrorCodeAndVectorOnStack155 ;156 @@:157 jmp @B158 159 ErrorCodeAndVectorOnStack:160 push ebp161 mov ebp, esp162 163 ;164 ; Stack:165 ; +---------------------+166 ; + EFlags +167 ; +---------------------+168 ; + CS +169 ; +---------------------+170 ; + EIP +171 ; +---------------------+172 ; + Error Code +173 ; +---------------------+174 ; + Vector Number +175 ; +---------------------+176 ; + EBP +177 ; +---------------------+ <-- EBP178 ;179 180 ;181 ; Align stack to make sure that EFI_FX_SAVE_STATE_IA32 of EFI_SYSTEM_CONTEXT_IA32182 ; is 16-byte aligned183 ;184 and esp, 0fffffff0h185 sub esp, 12186 187 ;; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax;188 push eax189 push ecx190 push edx191 push ebx192 lea ecx, [ebp + 6 * 4]193 push ecx ; ESP194 push dword ptr [ebp] ; EBP195 push esi196 push edi197 198 ;; UINT32 Gs, Fs, Es, Ds, Cs, Ss;199 mov eax, ss200 push eax201 movzx eax, word ptr [ebp + 4 * 4]202 push eax203 mov eax, ds204 push eax205 mov eax, es206 push eax207 mov eax, fs208 push eax209 mov eax, gs210 push eax211 212 ;; UINT32 Eip;213 mov eax, [ebp + 3 * 4]214 push eax215 216 ;; UINT32 Gdtr[2], Idtr[2];217 sub esp, 8218 sidt [esp]219 mov eax, [esp + 2]220 xchg eax, [esp]221 and eax, 0FFFFh222 mov [esp+4], eax223 224 sub esp, 8225 sgdt [esp]226 mov eax, [esp + 2]227 xchg eax, [esp]228 and eax, 0FFFFh229 mov [esp+4], eax230 231 ;; UINT32 Ldtr, Tr;232 xor eax, eax233 str ax234 push eax235 sldt ax236 push eax237 238 ;; UINT32 EFlags;239 mov eax, [ebp + 5 * 4]240 push eax241 242 ;; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4;243 mov eax, cr4244 or eax, 208h245 mov cr4, eax246 push eax247 mov eax, cr3248 push eax249 mov eax, cr2250 push eax251 xor eax, eax252 push eax253 mov eax, cr0254 push eax255 256 ;; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7;257 mov eax, dr7258 push eax259 mov eax, dr6260 push eax261 mov eax, dr3262 push eax263 mov eax, dr2264 push eax265 mov eax, dr1266 push eax267 mov eax, dr0268 push eax269 270 ;; FX_SAVE_STATE_IA32 FxSaveState;271 sub esp, 512272 mov edi, esp273 db 0fh, 0aeh, 07h ;fxsave [edi]274 275 ;; UEFI calling convention for IA32 requires that Direction flag in EFLAGs is clear276 cld277 278 ;; UINT32 ExceptionData;279 push dword ptr [ebp + 2 * 4]280 281 ;; call into exception handler282 mov eax, ExternalVectorTablePtr ; get the interrupt vectors base283 or eax, eax ; NULL?284 jz nullExternalExceptionHandler285 286 mov ecx, [ebp + 4]287 mov eax, [eax + ecx * 4]288 or eax, eax ; NULL?289 jz nullExternalExceptionHandler290 291 ;; Prepare parameter and call292 mov edx, esp293 push edx294 mov edx, dword ptr [ebp + 1 * 4]295 push edx296 297 ;298 ; Call External Exception Handler299 ;300 call eax301 add esp, 8302 303 nullExternalExceptionHandler:304 305 cli306 ;; UINT32 ExceptionData;307 add esp, 4308 309 ;; FX_SAVE_STATE_IA32 FxSaveState;310 mov esi, esp311 db 0fh, 0aeh, 0eh ; fxrstor [esi]312 add esp, 512313 314 ;; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7;315 ;; Skip restoration of DRx registers to support in-circuit emualators316 ;; or debuggers set breakpoint in interrupt/exception context317 add esp, 4 * 6318 319 ;; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4;320 pop eax321 mov cr0, eax322 add esp, 4 ; not for Cr1323 pop eax324 mov cr2, eax325 pop eax326 mov cr3, eax327 pop eax328 mov cr4, eax329 330 ;; UINT32 EFlags;331 pop dword ptr [ebp + 5 * 4]332 333 ;; UINT32 Ldtr, Tr;334 ;; UINT32 Gdtr[2], Idtr[2];335 ;; Best not let anyone mess with these particular registers...336 add esp, 24337 338 ;; UINT32 Eip;339 pop dword ptr [ebp + 3 * 4]340 341 ;; UINT32 Gs, Fs, Es, Ds, Cs, Ss;342 ;; NOTE - modified segment registers could hang the debugger... We343 ;; could attempt to insulate ourselves against this possibility,344 ;; but that poses risks as well.345 ;;346 pop gs347 pop fs348 pop es349 pop ds350 pop dword ptr [ebp + 4 * 4]351 pop ss352 353 ;; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax;354 pop edi355 pop esi356 add esp, 4 ; not for ebp357 add esp, 4 ; not for esp358 pop ebx359 pop edx360 pop ecx361 pop eax362 363 mov esp, ebp364 pop ebp365 add esp, 8366 iretd367 368 CommonInterruptEntry ENDP369 57 370 58 END
Note:
See TracChangeset
for help on using the changeset viewer.