mov si, BufferStartLocation\r
mov ebx, [si]\r
\r
- mov si, ModeOffsetLocation\r
- mov eax, [si]\r
- mov si, CodeSegmentLocation\r
- mov edx, [si]\r
- mov di, ax\r
- sub di, 02h\r
- mov [di], dx\r
- sub di, 04h\r
- add eax, ebx\r
- mov [di],eax\r
-\r
mov si, DataSegmentLocation\r
mov edx, [si]\r
\r
+ ;\r
+ ; Get start address of 32-bit code in low memory (<1MB)\r
+ ;\r
+ mov edi, ModeTransitionMemoryLocation\r
+\r
mov si, GdtrLocation\r
o32 lgdt [cs:si]\r
\r
mov si, IdtrLocation\r
o32 lidt [cs:si]\r
\r
- xor ax, ax\r
- mov ds, ax\r
-\r
+ ;\r
+ ; Switch to protected mode\r
+ ;\r
mov eax, cr0 ; Get control register 0\r
or eax, 000000003h ; Set PE bit (bit #0) & MP\r
mov cr0, eax\r
\r
- jmp 0:strict dword 0 ; far jump to protected mode\r
+ ; Switch to 32-bit code in executable memory (>1MB)\r
+o32 jmp far [cs:di]\r
+\r
+;\r
+; Following code may be copied to memory with type of EfiBootServicesCode.\r
+; This is required at DXE phase if NX is enabled for EfiBootServicesCode of\r
+; memory.\r
+;\r
BITS 32\r
Flat32Start: ; protected mode entry point\r
mov ds, dx\r
\r
mov esi, ebx\r
\r
+ ; Increment the number of APs executing here as early as possible\r
+ ; This is decremented in C code when AP is finished executing\r
+ mov edi, esi\r
+ add edi, NumApsExecutingLocation\r
+ lock inc dword [edi]\r
+\r
mov edi, esi\r
add edi, EnableExecuteDisableLocation\r
cmp byte [edi], 0\r
jz TestLock\r
\r
mov ecx, esi\r
- add ecx, NumApsExecutingLocation\r
+ add ecx, ApIndexLocation\r
inc dword [ecx]\r
mov ebx, [ecx]\r
\r
mov eax, ASM_PFX(InitializeFloatingPointUnits)\r
call eax ; Call assembly function to initialize FPU per UEFI spec\r
\r
- push ebx ; Push NumApsExecuting\r
+ push ebx ; Push ApIndex\r
mov eax, esi\r
add eax, LockLocation\r
push eax ; push address of exchange info data buffer\r
mov dword [ebx + 8h], RendezvousFunnelProcEnd - RendezvousFunnelProcStart\r
mov dword [ebx + 0Ch], AsmRelocateApLoopStart\r
mov dword [ebx + 10h], AsmRelocateApLoopEnd - AsmRelocateApLoopStart\r
+ mov dword [ebx + 14h], Flat32Start - RendezvousFunnelProcStart\r
\r
popad\r
ret\r