GdtrProfile equ LockLocation + 10h\r
IdtrProfile equ LockLocation + 16h\r
BufferStart equ LockLocation + 1Ch\r
-\r
+ProcessorNumber equ LockLocation + 20h\r
;-------------------------------------------------------------------------------\r
#define GdtrProfile RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x10\r
#define IdtrProfile RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x16\r
#define BufferStart RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x1C\r
+#define ProcessorNumber, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x20\r
\r
#-------------------------------------------------------------------------------------\r
#RendezvousFunnelProc procedure follows. All APs execute their procedure. This\r
.byte 0x66\r
movw %ax,%ss # Flat mode setup.\r
\r
-\r
+ #\r
+ # ProgramStack\r
+ #\r
+ movl $0x1b, %ecx\r
+ rdmsr\r
+ andl $0xfffff000, %eax\r
+ addl $0x20, %eax\r
+ movl (%eax), %ebx\r
+ shrl $24, %ebx\r
+ \r
+ xorl %ecx, %ecx\r
movl %esi,%edi\r
- addl $LockLocation, %edi\r
- movb $NotVacantFlag, %al\r
-TestLock:\r
- xchgb (%edi), %al\r
- cmpb $NotVacantFlag, %al\r
- jz TestLock\r
-\r
-ProgramStack:\r
+ addl $ProcessorNumber, %edi\r
+ movl (%edi, %ebx, 4), %ecx\r
+\r
movl %esi,%edi\r
addl $StackSize, %edi\r
movl (%edi), %eax\r
+ incl %ecx\r
+ mull %ecx\r
+\r
movl %esi,%edi\r
addl $StackStart, %edi\r
- addl (%edi), %eax\r
- movl %eax,%esp\r
- movl %eax, (%edi)\r
+ movl (%edi), %ebx\r
+ addl %ebx, %eax\r
\r
-Releaselock:\r
- movb $VacantFlag, %al\r
- movl %esi,%edi\r
- addl $LockLocation, %edi\r
- xchgb (%edi), %al\r
+ movl %eax, %esp\r
\r
#\r
# Call C Function\r
mov gs, ax\r
mov ss, ax ; Flat mode setup.\r
\r
-\r
+ ;\r
+ ; ProgramStack\r
+ ;\r
+ mov ecx, 1bh ; Read IA32_APIC_BASE MSR\r
+ rdmsr\r
+ and eax, 0fffff000h\r
+ add eax, 20h\r
+ mov ebx, dword ptr [eax]\r
+ shr ebx, 24\r
+ \r
+ xor ecx, ecx\r
mov edi, esi\r
- add edi, LockLocation\r
- mov al, NotVacantFlag\r
-TestLock::\r
- xchg byte ptr [edi], al\r
- cmp al, NotVacantFlag\r
- jz TestLock\r
-\r
-ProgramStack::\r
+ add edi, ProcessorNumber\r
+ mov ecx, dword ptr [edi + 4 * ebx] ; ECX = CpuNumber\r
\r
mov edi, esi\r
add edi, StackSize\r
mov eax, dword ptr [edi]\r
+ inc ecx\r
+ mul ecx ; EAX = StackSize * (CpuNumber + 1)\r
+\r
mov edi, esi\r
add edi, StackStart\r
- add eax, dword ptr [edi]\r
- mov esp, eax\r
- mov dword ptr [edi], eax\r
+ mov ebx, dword ptr [edi]\r
+ add eax, ebx ; EAX = StackStart + StackSize * (CpuNumber + 1)\r
\r
-Releaselock::\r
- mov al, VacantFlag\r
- mov edi, esi\r
- add edi, LockLocation\r
- xchg byte ptr [edi], al\r
+ mov esp, eax\r
\r
;\r
; Call C Function\r
MP_SYSTEM_DATA mMPSystemData;\r
EFI_PHYSICAL_ADDRESS mStartupVector;\r
MP_CPU_EXCHANGE_INFO *mExchangeInfo;\r
-VOID *mStackStartAddress;\r
BOOLEAN mStopCheckAPsStatus = FALSE;\r
UINTN mNumberOfProcessors;\r
EFI_GENERIC_MEMORY_TEST_PROTOCOL *mGenMemoryTest;\r
\r
This function sends INIT-SIPI-SIPI to AP, and assign procedure specified by ApFunction.\r
\r
- @param Broadcast If TRUE, broadcase IPI to all APs; otherwise, send to specified AP.\r
- @param ApicID The Local APIC ID of the specified AP. If Broadcast is TRUE, it is ignored.\r
- @param ApFunction The procedure for AP to work on.\r
+ @param ProcessorNumber The processor number of the specified AP.\r
+ @param ApicID The Local APIC ID of the specified AP.\r
+ @param ApFunction The procedure for AP to work on.\r
\r
**/\r
VOID\r
SendInitSipiSipi (\r
- IN BOOLEAN Broadcast,\r
+ IN UINTN ProcessorNumber,\r
IN UINT32 ApicID,\r
IN VOID *ApFunction\r
)\r
UINT32 DeliveryMode;\r
\r
mExchangeInfo->ApFunction = ApFunction;\r
- mExchangeInfo->StackStart = mStackStartAddress;\r
+ mExchangeInfo->ProcessorNumber[ApicID] = (UINT32) ProcessorNumber;\r
\r
- if (Broadcast) {\r
- ICRHigh = 0;\r
- ICRLow = BROADCAST_MODE_ALL_EXCLUDING_SELF_BIT | TRIGGER_MODE_LEVEL_BIT | ASSERT_BIT;\r
- } else {\r
- ICRHigh = ApicID << 24;\r
- ICRLow = SPECIFY_CPU_MODE_BIT | TRIGGER_MODE_LEVEL_BIT | ASSERT_BIT;\r
- }\r
+ ICRHigh = ApicID << 24;\r
+ ICRLow = SPECIFY_CPU_MODE_BIT | TRIGGER_MODE_LEVEL_BIT | ASSERT_BIT;\r
\r
VectorNumber = 0;\r
DeliveryMode = DELIVERY_MODE_INIT;\r
\r
VectorNumber = (UINT32) RShiftU64 (mStartupVector, 12);\r
DeliveryMode = DELIVERY_MODE_SIPI;\r
- if (Broadcast) {\r
- ICRLow = BROADCAST_MODE_ALL_EXCLUDING_SELF_BIT | TRIGGER_MODE_LEVEL_BIT | ASSERT_BIT;\r
- } else {\r
- ICRLow = SPECIFY_CPU_MODE_BIT | TRIGGER_MODE_LEVEL_BIT | ASSERT_BIT;\r
- }\r
+ ICRLow = SPECIFY_CPU_MODE_BIT | TRIGGER_MODE_LEVEL_BIT | ASSERT_BIT;\r
\r
ICRLow |= VectorNumber | (DeliveryMode << 8);\r
\r
ASSERT_EFI_ERROR (Status);\r
\r
SendInitSipiSipi (\r
- FALSE,\r
+ ProcessorNumber,\r
(UINT32) ProcessorInfoBuffer.ProcessorId,\r
(VOID *) (UINTN) ApProcWrapper\r
);\r
ASSERT_EFI_ERROR (Status);\r
\r
SendInitSipiSipi (\r
- FALSE,\r
+ ProcessorNumber,\r
(UINT32) ProcessorInfoBuffer.ProcessorId,\r
NULL\r
);\r
\r
ZeroMem ((VOID *) mExchangeInfo, sizeof (MP_CPU_EXCHANGE_INFO));\r
\r
- mStackStartAddress = AllocatePages (EFI_SIZE_TO_PAGES (MAX_CPU_NUMBER * AP_STACK_SIZE));\r
+ mExchangeInfo->StackStart = AllocatePages (EFI_SIZE_TO_PAGES (mNumberOfProcessors * AP_STACK_SIZE));\r
mExchangeInfo->StackSize = AP_STACK_SIZE;\r
\r
AsmReadGdtr (&GdtrForBSP);\r
{\r
EFI_STATUS Status;\r
\r
- PrepareMemoryForConfiguration ();\r
-\r
//\r
// Locates Framework version MP Services Protocol\r
//\r
ASSERT_EFI_ERROR (Status);\r
ASSERT (mNumberOfProcessors < MAX_CPU_NUMBER);\r
\r
+ PrepareMemoryForConfiguration ();\r
+\r
//\r
// Create timer event to check AP state for non-blocking execution.\r
//\r
IA32_DESCRIPTOR IdtrProfile;\r
UINT32 BufferStart;\r
UINT32 Cr3;\r
+ UINT32 ProcessorNumber[MAX_CPU_NUMBER];\r
} MP_CPU_EXCHANGE_INFO;\r
\r
typedef struct {\r
IdtrLocation equ LockLocation + 2Ah\r
BufferStartLocation equ LockLocation + 34h\r
Cr3OffsetLocation equ LockLocation + 38h\r
+ProcessorNumberLocation equ LockLocation + 3Ch\r
\r
;-------------------------------------------------------------------------------\r
.equ IdtrLocation, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x2A\r
.equ BufferStartLocation, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x34\r
.equ Cr3OffsetLocation, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x38\r
+.equ ProcessorNumberLocation, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x38\r
\r
#-------------------------------------------------------------------------------------\r
\r
.byte 0x66\r
movw %ax,%ss\r
\r
- movl %esi, %edi\r
- addl $LockLocation, %edi\r
- movb $NotVacantFlag, %al\r
-TestLock:\r
- xchgb (%edi), %al\r
- cmpb $NotVacantFlag, %al\r
- jz TestLock\r
-\r
-ProgramStack:\r
+ #\r
+ # ProgramStack\r
+ #\r
+ movl $0x1b, %ecx\r
+ rdmsr\r
+ andl $0xfffff000, %eax\r
+ addl $0x20, %eax\r
+ movl (%eax), %ebx\r
+ shrl $24, %ebx\r
+ \r
+ xorq %rcx, %rcx\r
+ movl %esi,%edi\r
+ addl $ProcessorNumberLocation, %edi\r
+ movl (%edi, %ebx, 4), %ecx\r
\r
- movl %esi, %edi\r
- addl $StackSizeLocation, %edi \r
+ movl %esi,%edi\r
+ addl $StackSizeLocation, %edi\r
movq (%edi), %rax\r
- movl %esi, %edi\r
- addl $StackStartAddressLocation, %edi\r
- addq (%edi), %rax\r
- movq %rax, %rsp\r
- movq %rax, (%edi) \r
+ incq %rcx\r
+ mulq %rcx\r
\r
-Releaselock:\r
+ movl %esi,%edi\r
+ addl $StackStartAddressLocation, %edi\r
+ movq (%edi), %rbx\r
+ addq %rbx, %rax\r
\r
- movb $VacantFlag, %al\r
- movl %esi, %edi\r
- addl $LockLocation, %edi\r
- xchgb (%edi), %al\r
+ movq %rax, %rsp\r
\r
#\r
# Call C Function\r
mov es, ax\r
mov ss, ax\r
\r
+ ;\r
+ ; ProgramStack\r
+ ;\r
+ mov ecx, 1bh ; Read IA32_APIC_BASE MSR\r
+ rdmsr\r
+ and eax, 0fffff000h\r
+ add eax, 20h\r
+ mov ebx, dword ptr [eax]\r
+ shr ebx, 24\r
+ \r
+ xor rcx, rcx\r
mov edi, esi\r
- add edi, LockLocation\r
- mov al, NotVacantFlag\r
-TestLock::\r
- xchg byte ptr [edi], al\r
- cmp al, NotVacantFlag\r
- jz TestLock\r
-\r
-ProgramStack::\r
+ add edi, ProcessorNumberLocation\r
+ mov ecx, dword ptr [edi + 4 * ebx] ; RCX = CpuNumber\r
\r
mov edi, esi\r
add edi, StackSizeLocation\r
mov rax, qword ptr [edi]\r
+ inc rcx\r
+ mul rcx ; RAX = StackSize * (CpuNumber + 1)\r
+\r
mov edi, esi\r
add edi, StackStartAddressLocation\r
- add rax, qword ptr [edi]\r
- mov rsp, rax\r
- mov qword ptr [edi], rax\r
-\r
-Releaselock::\r
+ mov rbx, qword ptr [edi]\r
+ add rax, rbx ; RAX = StackStart + StackSize * (CpuNumber + 1)\r
\r
- mov al, VacantFlag\r
- mov edi, esi\r
- add edi, LockLocation\r
- xchg byte ptr [edi], al\r
+ mov rsp, rax\r
\r
;\r
; Call C Function\r