Changeset 58459 in vbox for trunk/src/VBox/Devices/EFI/Firmware/UefiCpuPkg/CpuDxe/Ia32/CpuAsm.S
- Timestamp:
- Oct 28, 2015 8:17:18 PM (9 years ago)
- Location:
- trunk/src/VBox/Devices/EFI/Firmware
- Files:
-
- 2 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
Note:
See TracChangeset
for help on using the changeset viewer.