mirror of https://github.com/acidanthera/audk.git
Check in thunk driver to produce PI MP Services Protocol based on Framework MP Services Protocol.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9563 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
c0b89afd91
commit
768e2a903b
|
@ -0,0 +1,25 @@
|
|||
;------------------------------------------------------------------------------
|
||||
; Include file for IA32 MpFuncs.asm
|
||||
;
|
||||
; Copyright (c) 2009, Intel Corporation
|
||||
; All rights reserved. This program and the accompanying materials
|
||||
; are licensed and made available under the terms and conditions of the BSD License
|
||||
; which accompanies this distribution. The full text of the license may be found at
|
||||
; http://opensource.org/licenses/bsd-license.php
|
||||
;
|
||||
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
VacantFlag Equ 00h
|
||||
NotVacantFlag Equ 0ffh
|
||||
|
||||
LockLocation equ RendezvousFunnelProcEnd - RendezvousFunnelProcStart
|
||||
StackStart equ LockLocation + 4h
|
||||
StackSize equ LockLocation + 8h
|
||||
RendezvousProc equ LockLocation + 0Ch
|
||||
GdtrProfile equ LockLocation + 10h
|
||||
BufferStart equ LockLocation + 18h
|
||||
|
||||
;-------------------------------------------------------------------------------
|
|
@ -0,0 +1,154 @@
|
|||
#------------------------------------------------------------------------------
|
||||
# IA32 assembly file for AP startup vector.
|
||||
#
|
||||
# Copyright (c) 2009, Intel Corporation
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are licensed and made available under the terms and conditions of the BSD License
|
||||
# which accompanies this distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
.equ VacantFlag, 0x0
|
||||
.equ NotVacantFlag, 0xff
|
||||
|
||||
.equ LockLocation, RendezvousFunnelProcEnd - RendezvousFunnelProcStart
|
||||
.equ StackStart, LockLocation + 0x04
|
||||
.equ StackSize, LockLocation + 0x08
|
||||
.equ RendezvousProc, LockLocation + 0x0C
|
||||
.equ GdtrProfile, LockLocation + 0x10
|
||||
.equ BufferStart, LockLocation + 0x18
|
||||
|
||||
#-------------------------------------------------------------------------------------
|
||||
#RendezvousFunnelProc procedure follows. All APs execute their procedure. This
|
||||
#procedure serializes all the AP processors through an Init sequence. It must be
|
||||
#noted that APs arrive here very raw...ie: real mode, no stack.
|
||||
#ALSO THIS PROCEDURE IS EXECUTED BY APs ONLY ON 16 BIT MODE. HENCE THIS PROC
|
||||
#IS IN MACHINE CODE.
|
||||
#-------------------------------------------------------------------------------------
|
||||
#RendezvousFunnelProc (&WakeUpBuffer,MemAddress);
|
||||
|
||||
ASM_GLOBAL ASM_PFX(RendezvousFunnelProc)
|
||||
ASM_PFX(RendezvousFunnelProc):
|
||||
RendezvousFunnelProcStart:
|
||||
|
||||
|
||||
# At this point CS = 0x(vv00) and ip= 0x0.
|
||||
|
||||
.byte 0x8c,0xc8 # mov ax, cs
|
||||
.byte 0x8e,0xd8 # mov ds, ax
|
||||
.byte 0x8e,0xc0 # mov es, ax
|
||||
.byte 0x8e,0xd0 # mov ss, ax
|
||||
.byte 0x33,0xc0 # xor ax, ax
|
||||
.byte 0x8e,0xe0 # mov fs, ax
|
||||
.byte 0x8e,0xe8 # mov gs, ax
|
||||
|
||||
# Switch to flat mode.
|
||||
|
||||
.byte 0xBE
|
||||
.word BufferStart
|
||||
.byte 0x66,0x8B,0xC # mov ecx,dword ptr [si] ; ECX is keeping the start address of wakeup buffer
|
||||
|
||||
.byte 0xFA # cli
|
||||
.byte 0xBE
|
||||
.word GdtrProfile
|
||||
.byte 0x66 # db 66h
|
||||
.byte 0x2E,0xF,0x1,0x14 # lgdt fword ptr cs:[si]
|
||||
|
||||
.byte 0x33,0xC0 # xor ax, ax
|
||||
.byte 0x8E,0xD8 # mov ds, ax
|
||||
.byte 0xF,0x20,0xC0 # mov eax, cr0 ; Get control register 0
|
||||
.byte 0x66,0x83,0xC8,0x1 # or eax, 000000001h ; Set PE bit (bit #0)
|
||||
.byte 0xF,0x22,0xC0 # mov cr0, eax
|
||||
|
||||
|
||||
#step-4:
|
||||
|
||||
FLAT32_JUMP:
|
||||
.byte 0x66
|
||||
.byte 0x67
|
||||
.byte 0xEA # far jump
|
||||
.long 0x0
|
||||
.word 0x10
|
||||
|
||||
ProtectedModeStart: # protected mode entry point
|
||||
|
||||
movw $0x8,%ax
|
||||
.byte 0x66
|
||||
movw %ax,%ds
|
||||
.byte 0x66
|
||||
movw %ax,%es
|
||||
.byte 0x66
|
||||
movw %ax,%fs
|
||||
.byte 0x66
|
||||
movw %ax,%gs
|
||||
.byte 0x66
|
||||
movw %ax,%ss # Flat mode setup.
|
||||
|
||||
|
||||
movl %esi,%edi
|
||||
addl $LockLocation, %edi
|
||||
movb $NotVacantFlag, %al
|
||||
TestLock:
|
||||
xchgb (%edi), %al
|
||||
cmpb $NotVacantFlag, %al
|
||||
jz TestLock
|
||||
|
||||
ProgramStack:
|
||||
movl %esi,%edi
|
||||
addl $StackSize, %edi
|
||||
movl (%edi), %eax
|
||||
movl %esi,%edi
|
||||
addl $StackStart, %edi
|
||||
addl (%edi), %eax
|
||||
movl %eax,%esp
|
||||
movl %eax, (%edi)
|
||||
|
||||
Releaselock:
|
||||
movb $VacantFlag, %al
|
||||
movl %esi,%edi
|
||||
addl $LockLocation, %edi
|
||||
xchgb (%edi), %al
|
||||
|
||||
#
|
||||
# Call C Function
|
||||
#
|
||||
movl %esi,%edi
|
||||
addl $RendezvousProc, %edi
|
||||
movl (%edi), %ebx
|
||||
|
||||
testl %ebx,%ebx
|
||||
jz GoToSleep
|
||||
call *%ebx # Call C function
|
||||
|
||||
#Step-6: Sleep
|
||||
|
||||
GoToSleep:
|
||||
|
||||
cli
|
||||
hlt
|
||||
jmp GoToSleep
|
||||
|
||||
RendezvousFunnelProcEnd:
|
||||
#-------------------------------------------------------------------------------------
|
||||
# AsmGetAddressMap (&AddressMap);
|
||||
#-------------------------------------------------------------------------------------
|
||||
ASM_GLOBAL ASM_PFX(AsmGetAddressMap)
|
||||
ASM_PFX(AsmGetAddressMap):
|
||||
|
||||
pushal
|
||||
movl %esp,%ebp
|
||||
|
||||
movl 0x24(%ebp), %ebx
|
||||
movl $RendezvousFunnelProcStart, (%ebx)
|
||||
movl $(ProtectedModeStart - RendezvousFunnelProcStart), 0x4(%ebx)
|
||||
movl $(FLAT32_JUMP - RendezvousFunnelProcStart), 0x8(%ebx)
|
||||
movl $0, 0x0c(%ebx)
|
||||
movl $0, 0x10(%ebx)
|
||||
movl $(RendezvousFunnelProcEnd - RendezvousFunnelProcStart), 0x14(%ebx)
|
||||
|
||||
popal
|
||||
ret
|
|
@ -0,0 +1,148 @@
|
|||
;------------------------------------------------------------------------------
|
||||
; IA32 assembly file for AP startup vector.
|
||||
;
|
||||
; Copyright (c) 2009, Intel Corporation
|
||||
; All rights reserved. This program and the accompanying materials
|
||||
; are licensed and made available under the terms and conditions of the BSD License
|
||||
; which accompanies this distribution. The full text of the license may be found at
|
||||
; http://opensource.org/licenses/bsd-license.php
|
||||
;
|
||||
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
.686p
|
||||
.model flat
|
||||
.code
|
||||
|
||||
include AsmInclude.inc
|
||||
;-------------------------------------------------------------------------------------
|
||||
FJMP32 MACRO Selector, Offset
|
||||
DB 066h
|
||||
DB 067h
|
||||
DB 0EAh ; far jump
|
||||
DD Offset ; 32-bit offset
|
||||
DW Selector ; 16-bit selector
|
||||
ENDM
|
||||
|
||||
;-------------------------------------------------------------------------------------
|
||||
;RendezvousFunnelProc procedure follows. All APs execute their procedure. This
|
||||
;procedure serializes all the AP processors through an Init sequence. It must be
|
||||
;noted that APs arrive here very raw...ie: real mode, no stack.
|
||||
;ALSO THIS PROCEDURE IS EXECUTED BY APs ONLY ON 16 BIT MODE. HENCE THIS PROC
|
||||
;IS IN MACHINE CODE.
|
||||
;-------------------------------------------------------------------------------------
|
||||
;RendezvousFunnelProc (&WakeUpBuffer,MemAddress);
|
||||
|
||||
RendezvousFunnelProc PROC near C PUBLIC
|
||||
RendezvousFunnelProcStart::
|
||||
|
||||
|
||||
; At this point CS = 0x(vv00) and ip= 0x0.
|
||||
|
||||
db 8ch, 0c8h ; mov ax, cs
|
||||
db 8eh, 0d8h ; mov ds, ax
|
||||
db 8eh, 0c0h ; mov es, ax
|
||||
db 8eh, 0d0h ; mov ss, ax
|
||||
db 33h, 0c0h ; xor ax, ax
|
||||
db 8eh, 0e0h ; mov fs, ax
|
||||
db 8eh, 0e8h ; mov gs, ax
|
||||
|
||||
; Switch to flat mode.
|
||||
|
||||
db 0BEh
|
||||
dw BufferStart ; mov si, BufferStart
|
||||
db 66h, 8Bh, 0Ch ; mov ecx,dword ptr [si] ; ECX is keeping the start address of wakeup buffer
|
||||
|
||||
db 0FAh ; cli
|
||||
db 0BEh
|
||||
dw GdtrProfile ; mov si, GdtrProfile
|
||||
db 66h ; db 66h
|
||||
db 2Eh,0Fh, 01h, 14h ; lgdt fword ptr cs:[si]
|
||||
|
||||
db 33h, 0C0h ; xor ax, ax
|
||||
db 8Eh, 0D8h ; mov ds, ax
|
||||
db 0Fh, 20h, 0C0h ; mov eax, cr0 ; Get control register 0
|
||||
db 66h, 83h, 0C8h, 01h ; or eax, 000000001h ; Set PE bit (bit #0)
|
||||
db 0Fh, 22h, 0C0h ; mov cr0, eax
|
||||
|
||||
|
||||
FLAT32_JUMP::
|
||||
FJMP32 010h,0h ; Far jmp using code segment descriptor
|
||||
|
||||
ProtectedModeStart:: ; protected mode entry point
|
||||
|
||||
mov ax, 8h
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
mov fs, ax
|
||||
mov gs, ax
|
||||
mov ss, ax ; Flat mode setup.
|
||||
|
||||
|
||||
mov edi, esi
|
||||
add edi, LockLocation
|
||||
mov al, NotVacantFlag
|
||||
TestLock::
|
||||
xchg byte ptr [edi], al
|
||||
cmp al, NotVacantFlag
|
||||
jz TestLock
|
||||
|
||||
ProgramStack::
|
||||
|
||||
mov edi, esi
|
||||
add edi, StackSize
|
||||
mov eax, dword ptr [edi]
|
||||
mov edi, esi
|
||||
add edi, StackStart
|
||||
add eax, dword ptr [edi]
|
||||
mov esp, eax
|
||||
mov dword ptr [edi], eax
|
||||
|
||||
Releaselock::
|
||||
mov al, VacantFlag
|
||||
mov edi, esi
|
||||
add edi, LockLocation
|
||||
xchg byte ptr [edi], al
|
||||
|
||||
;
|
||||
; Call C Function
|
||||
;
|
||||
mov edi, esi
|
||||
add edi, RendezvousProc
|
||||
mov ebx, dword ptr [edi]
|
||||
|
||||
test ebx, ebx
|
||||
jz GoToSleep
|
||||
call ebx ; Call C function
|
||||
|
||||
GoToSleep::
|
||||
|
||||
cli
|
||||
hlt
|
||||
jmp $-2
|
||||
|
||||
RendezvousFunnelProc ENDP
|
||||
RendezvousFunnelProcEnd::
|
||||
;-------------------------------------------------------------------------------------
|
||||
; AsmGetAddressMap (&AddressMap);
|
||||
;-------------------------------------------------------------------------------------
|
||||
AsmGetAddressMap PROC near C PUBLIC
|
||||
|
||||
pushad
|
||||
mov ebp,esp
|
||||
|
||||
mov ebx, dword ptr [ebp+24h]
|
||||
mov dword ptr [ebx], RendezvousFunnelProcStart
|
||||
mov dword ptr [ebx+4h], ProtectedModeStart - RendezvousFunnelProcStart
|
||||
mov dword ptr [ebx+8h], FLAT32_JUMP - RendezvousFunnelProcStart
|
||||
mov dword ptr [ebx+0ch], 0
|
||||
mov dword ptr [ebx+10h], 0
|
||||
mov dword ptr [ebx+14h], RendezvousFunnelProcEnd - RendezvousFunnelProcStart
|
||||
|
||||
popad
|
||||
ret
|
||||
AsmGetAddressMap ENDP
|
||||
|
||||
END
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,516 @@
|
|||
/** @file
|
||||
Include file for PI MP Services Protocol Thunk.
|
||||
|
||||
Copyright (c) 2009 Intel Corporation. <BR>
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
Module Name:
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _MP_SERVICES_ON_FRAMEWORK_MP_SERVICES_THUNK_
|
||||
#define _MP_SERVICES_ON_FRAMEWORK_MP_SERVICES_THUNK_
|
||||
|
||||
#include <Protocol/MpService.h>
|
||||
#include <Protocol/FrameworkMpService.h>
|
||||
#include <Protocol/GenericMemoryTest.h>
|
||||
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/SynchronizationLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/UefiDriverEntryPoint.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/DxeServicesTableLib.h>
|
||||
#include <Library/IoLib.h>
|
||||
#include <Library/TimerLib.h>
|
||||
|
||||
#define AP_STACK_SIZE 0x8000
|
||||
#define MAX_CPU_NUMBER 256
|
||||
|
||||
//
|
||||
// Bit definition for IPI
|
||||
//
|
||||
#define BROADCAST_MODE_ALL_EXCLUDING_SELF_BIT 0xC0000
|
||||
#define SPECIFY_CPU_MODE_BIT 0x00000
|
||||
#define TRIGGER_MODE_LEVEL_BIT 0x08000
|
||||
#define ASSERT_BIT 0x04000
|
||||
|
||||
//
|
||||
// Local APIC register definition for IPI.
|
||||
//
|
||||
#define APIC_REGISTER_ICR_LOW_OFFSET 0x300
|
||||
#define APIC_REGISTER_ICR_HIGH_OFFSET 0x310
|
||||
|
||||
typedef struct {
|
||||
UINTN Lock;
|
||||
VOID *StackStart;
|
||||
UINTN StackSize;
|
||||
VOID *ApFunction;
|
||||
IA32_DESCRIPTOR GdtrProfile;
|
||||
UINT32 BufferStart;
|
||||
UINT32 Cr3;
|
||||
} MP_CPU_EXCHANGE_INFO;
|
||||
|
||||
typedef struct {
|
||||
UINT8 *RendezvousFunnelAddress;
|
||||
UINTN PModeEntryOffset;
|
||||
UINTN FlatJumpOffset;
|
||||
UINTN LModeEntryOffset;
|
||||
UINTN LongJumpOffset;
|
||||
UINTN Size;
|
||||
} MP_ASSEMBLY_ADDRESS_MAP;
|
||||
|
||||
typedef enum {
|
||||
CpuStateIdle,
|
||||
CpuStateReady,
|
||||
CpuStateBusy,
|
||||
CpuStateFinished,
|
||||
CpuStateDisabled
|
||||
} CPU_STATE;
|
||||
|
||||
//
|
||||
// Define Individual Processor Data block.
|
||||
//
|
||||
typedef struct {
|
||||
EFI_AP_PROCEDURE volatile Procedure;
|
||||
VOID* volatile Parameter;
|
||||
|
||||
EFI_EVENT WaitEvent;
|
||||
BOOLEAN *Finished;
|
||||
UINT64 ExpectedTime;
|
||||
UINT64 CurrentTime;
|
||||
UINT64 TotalTime;
|
||||
|
||||
SPIN_LOCK CpuDataLock;
|
||||
CPU_STATE volatile State;
|
||||
|
||||
} CPU_DATA_BLOCK;
|
||||
|
||||
//
|
||||
// Define MP data block which consumes individual processor block.
|
||||
//
|
||||
typedef struct {
|
||||
SPIN_LOCK APSerializeLock;
|
||||
|
||||
EFI_EVENT CheckAPsEvent;
|
||||
|
||||
UINTN FinishCount;
|
||||
UINTN StartCount;
|
||||
|
||||
BOOLEAN CpuList[MAX_CPU_NUMBER];
|
||||
|
||||
EFI_AP_PROCEDURE Procedure;
|
||||
VOID *ProcArguments;
|
||||
BOOLEAN SingleThread;
|
||||
EFI_EVENT WaitEvent;
|
||||
UINTN **FailedCpuList;
|
||||
UINT64 ExpectedTime;
|
||||
UINT64 CurrentTime;
|
||||
UINT64 TotalTime;
|
||||
|
||||
CPU_DATA_BLOCK CpuData[MAX_CPU_NUMBER];
|
||||
} MP_SYSTEM_DATA;
|
||||
|
||||
/**
|
||||
Implementation of GetNumberOfProcessors() service of MP Services Protocol.
|
||||
|
||||
This service retrieves the number of logical processor in the platform
|
||||
and the number of those logical processors that are enabled on this boot.
|
||||
This service may only be called from the BSP.
|
||||
|
||||
@param This A pointer to the EFI_MP_SERVICES_PROTOCOL instance.
|
||||
@param NumberOfProcessors Pointer to the total number of logical processors in the system,
|
||||
including the BSP and disabled APs.
|
||||
@param NumberOfEnabledProcessors Pointer to the number of enabled logical processors that exist
|
||||
in system, including the BSP.
|
||||
|
||||
@retval EFI_SUCCESS Number of logical processors and enabled logical processors retrieved..
|
||||
@retval EFI_DEVICE_ERROR Caller processor is AP.
|
||||
@retval EFI_INVALID_PARAMETER NumberOfProcessors is NULL
|
||||
@retval EFI_INVALID_PARAMETER NumberOfEnabledProcessors is NULL
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
GetNumberOfProcessors (
|
||||
IN EFI_MP_SERVICES_PROTOCOL *This,
|
||||
OUT UINTN *NumberOfProcessors,
|
||||
OUT UINTN *NumberOfEnabledProcessors
|
||||
);
|
||||
|
||||
/**
|
||||
Implementation of GetNumberOfProcessors() service of MP Services Protocol.
|
||||
|
||||
Gets detailed MP-related information on the requested processor at the
|
||||
instant this call is made. This service may only be called from the BSP.
|
||||
|
||||
@param This A pointer to the EFI_MP_SERVICES_PROTOCOL instance.
|
||||
@param ProcessorNumber The handle number of processor.
|
||||
@param ProcessorInfoBuffer A pointer to the buffer where information for the requested processor is deposited.
|
||||
|
||||
@retval EFI_SUCCESS Processor information successfully returned.
|
||||
@retval EFI_DEVICE_ERROR Caller processor is AP.
|
||||
@retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL
|
||||
@retval EFI_NOT_FOUND Processor with the handle specified by ProcessorNumber does not exist.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
GetProcessorInfo (
|
||||
IN EFI_MP_SERVICES_PROTOCOL *This,
|
||||
IN UINTN ProcessorNumber,
|
||||
OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer
|
||||
);
|
||||
|
||||
/**
|
||||
Implementation of StartupAllAPs() service of MP Services Protocol.
|
||||
|
||||
This service lets the caller get all enabled APs to execute a caller-provided function.
|
||||
This service may only be called from the BSP.
|
||||
|
||||
@param This A pointer to the EFI_MP_SERVICES_PROTOCOL instance.
|
||||
@param Procedure A pointer to the function to be run on enabled APs of the system.
|
||||
@param SingleThread Indicates whether to execute the function simultaneously or one by one..
|
||||
@param WaitEvent The event created by the caller.
|
||||
If it is NULL, then execute in blocking mode.
|
||||
If it is not NULL, then execute in non-blocking mode.
|
||||
@param TimeoutInMicroSeconds The time limit in microseconds for this AP to finish the function.
|
||||
Zero means infinity.
|
||||
@param ProcedureArgument Pointer to the optional parameter of the assigned function.
|
||||
@param FailedCpuList The list of processor numbers that fail to finish the function before
|
||||
TimeoutInMicrosecsond expires.
|
||||
|
||||
@retval EFI_SUCCESS In blocking mode, all APs have finished before the timeout expired.
|
||||
@retval EFI_SUCCESS In non-blocking mode, function has been dispatched to all enabled APs.
|
||||
@retval EFI_DEVICE_ERROR Caller processor is AP.
|
||||
@retval EFI_NOT_STARTED No enabled AP exists in the system.
|
||||
@retval EFI_NOT_READY Any enabled AP is busy.
|
||||
@retval EFI_TIMEOUT In blocking mode, The timeout expired before all enabled APs have finished.
|
||||
@retval EFI_INVALID_PARAMETER Procedure is NULL.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
StartupAllAPs (
|
||||
IN EFI_MP_SERVICES_PROTOCOL *This,
|
||||
IN EFI_AP_PROCEDURE Procedure,
|
||||
IN BOOLEAN SingleThread,
|
||||
IN EFI_EVENT WaitEvent OPTIONAL,
|
||||
IN UINTN TimeoutInMicroSeconds,
|
||||
IN VOID *ProcedureArgument OPTIONAL,
|
||||
OUT UINTN **FailedCpuList OPTIONAL
|
||||
);
|
||||
|
||||
/**
|
||||
Implementation of StartupThisAP() service of MP Services Protocol.
|
||||
|
||||
This service lets the caller get one enabled AP to execute a caller-provided function.
|
||||
This service may only be called from the BSP.
|
||||
|
||||
@param This A pointer to the EFI_MP_SERVICES_PROTOCOL instance.
|
||||
@param Procedure A pointer to the function to be run on the designated AP.
|
||||
@param ProcessorNumber The handle number of AP..
|
||||
@param WaitEvent The event created by the caller.
|
||||
If it is NULL, then execute in blocking mode.
|
||||
If it is not NULL, then execute in non-blocking mode.
|
||||
@param TimeoutInMicroseconds The time limit in microseconds for this AP to finish the function.
|
||||
Zero means infinity.
|
||||
@param ProcedureArgument Pointer to the optional parameter of the assigned function.
|
||||
@param Finished Indicates whether AP has finished assigned function.
|
||||
In blocking mode, it is ignored.
|
||||
|
||||
@retval EFI_SUCCESS In blocking mode, specified AP has finished before the timeout expires.
|
||||
@retval EFI_SUCCESS In non-blocking mode, function has been dispatched to specified AP.
|
||||
@retval EFI_DEVICE_ERROR Caller processor is AP.
|
||||
@retval EFI_TIMEOUT In blocking mode, the timeout expires before specified AP has finished.
|
||||
@retval EFI_NOT_READY Specified AP is busy.
|
||||
@retval EFI_NOT_FOUND Processor with the handle specified by ProcessorNumber does not exist.
|
||||
@retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP or disabled AP.
|
||||
@retval EFI_INVALID_PARAMETER Procedure is NULL.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
StartupThisAP (
|
||||
IN EFI_MP_SERVICES_PROTOCOL *This,
|
||||
IN EFI_AP_PROCEDURE Procedure,
|
||||
IN UINTN ProcessorNumber,
|
||||
IN EFI_EVENT WaitEvent OPTIONAL,
|
||||
IN UINTN TimeoutInMicroseconds,
|
||||
IN VOID *ProcedureArgument OPTIONAL,
|
||||
OUT BOOLEAN *Finished OPTIONAL
|
||||
);
|
||||
|
||||
/**
|
||||
Implementation of SwitchBSP() service of MP Services Protocol.
|
||||
|
||||
This service switches the requested AP to be the BSP from that point onward.
|
||||
This service may only be called from the current BSP.
|
||||
|
||||
@param This A pointer to the EFI_MP_SERVICES_PROTOCOL instance.
|
||||
@param ProcessorNumber The handle number of processor.
|
||||
@param EnableOldBSP Whether to enable or disable the original BSP.
|
||||
|
||||
@retval EFI_SUCCESS BSP successfully switched.
|
||||
@retval EFI_DEVICE_ERROR Caller processor is AP.
|
||||
@retval EFI_NOT_FOUND Processor with the handle specified by ProcessorNumber does not exist.
|
||||
@retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP or disabled AP.
|
||||
@retval EFI_NOT_READY Specified AP is busy.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SwitchBSP (
|
||||
IN EFI_MP_SERVICES_PROTOCOL *This,
|
||||
IN UINTN ProcessorNumber,
|
||||
IN BOOLEAN EnableOldBSP
|
||||
);
|
||||
|
||||
/**
|
||||
Implementation of EnableDisableAP() service of MP Services Protocol.
|
||||
|
||||
This service lets the caller enable or disable an AP.
|
||||
This service may only be called from the BSP.
|
||||
|
||||
@param This A pointer to the EFI_MP_SERVICES_PROTOCOL instance.
|
||||
@param ProcessorNumber The handle number of processor.
|
||||
@param EnableAP Indicates whether the newstate of the AP is enabled or disabled.
|
||||
@param HealthFlag Indicates new health state of the AP..
|
||||
|
||||
@retval EFI_SUCCESS AP successfully enabled or disabled.
|
||||
@retval EFI_DEVICE_ERROR Caller processor is AP.
|
||||
@retval EFI_NOT_FOUND Processor with the handle specified by ProcessorNumber does not exist.
|
||||
@retval EFI_INVALID_PARAMETERS ProcessorNumber specifies the BSP.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EnableDisableAP (
|
||||
IN EFI_MP_SERVICES_PROTOCOL *This,
|
||||
IN UINTN ProcessorNumber,
|
||||
IN BOOLEAN EnableAP,
|
||||
IN UINT32 *HealthFlag OPTIONAL
|
||||
);
|
||||
|
||||
/**
|
||||
Implementation of WhoAmI() service of MP Services Protocol.
|
||||
|
||||
This service lets the caller processor get its handle number.
|
||||
This service may be called from the BSP and APs.
|
||||
|
||||
@param This A pointer to the EFI_MP_SERVICES_PROTOCOL instance.
|
||||
@param ProcessorNumber Pointer to the handle number of AP.
|
||||
|
||||
@retval EFI_SUCCESS Processor number successfully returned.
|
||||
@retval EFI_INVALID_PARAMETER ProcessorNumber is NULL
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
WhoAmI (
|
||||
IN EFI_MP_SERVICES_PROTOCOL *This,
|
||||
OUT UINTN *ProcessorNumber
|
||||
);
|
||||
|
||||
/**
|
||||
Checks APs' status periodically.
|
||||
|
||||
This function is triggerred by timer perodically to check the
|
||||
state of APs for StartupAllAPs() and StartupThisAP() executed
|
||||
in non-blocking mode.
|
||||
|
||||
@param Event Event triggered.
|
||||
@param Context Parameter passed with the event.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
CheckAPsStatus (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
/**
|
||||
Checks status of all APs.
|
||||
|
||||
This function checks whether all APs have finished task assigned by StartupAllAPs(),
|
||||
and whether timeout expires.
|
||||
|
||||
@retval EFI_SUCCESS All APs have finished task assigned by StartupAllAPs().
|
||||
@retval EFI_TIMEOUT The timeout expires.
|
||||
@retval EFI_NOT_READY APs have not finished task and timeout has not expired.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
CheckAllAPs (
|
||||
VOID
|
||||
);
|
||||
|
||||
/**
|
||||
Checks status of specified AP.
|
||||
|
||||
This function checks whether specified AP has finished task assigned by StartupThisAP(),
|
||||
and whether timeout expires.
|
||||
|
||||
@param ProcessorNumber The handle number of processor.
|
||||
|
||||
@retval EFI_SUCCESS Specified AP has finished task assigned by StartupThisAPs().
|
||||
@retval EFI_TIMEOUT The timeout expires.
|
||||
@retval EFI_NOT_READY Specified AP has not finished task and timeout has not expired.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
CheckThisAP (
|
||||
UINTN ProcessorNumber
|
||||
);
|
||||
|
||||
/**
|
||||
Calculate timeout value and return the current performance counter value.
|
||||
|
||||
Calculate the number of performance counter ticks required for a timeout.
|
||||
If TimeoutInMicroseconds is 0, return value is also 0, which is recognized
|
||||
as infinity.
|
||||
|
||||
@param TimeoutInMicroseconds Timeout value in microseconds.
|
||||
@param CurrentTime Returns the current value of the performance counter.
|
||||
|
||||
@return Expected timestamp counter for timeout.
|
||||
If TimeoutInMicroseconds is 0, return value is also 0, which is recognized
|
||||
as infinity.
|
||||
|
||||
**/
|
||||
UINT64
|
||||
CalculateTimeout (
|
||||
IN UINTN TimeoutInMicroseconds,
|
||||
OUT UINT64 *CurrentTime
|
||||
);
|
||||
|
||||
/**
|
||||
Checks whether timeout expires.
|
||||
|
||||
Check whether the number of ellapsed performance counter ticks required for a timeout condition
|
||||
has been reached. If Timeout is zero, which means infinity, return value is always FALSE.
|
||||
|
||||
@param PreviousTime On input, the value of the performance counter when it was last read.
|
||||
On output, the current value of the performance counter
|
||||
@param TotalTime The total amount of ellapsed time in performance counter ticks.
|
||||
@param Timeout The number of performance counter ticks required to reach a timeout condition.
|
||||
|
||||
@retval TRUE A timeout condition has been reached.
|
||||
@retval FALSE A timeout condition has not been reached.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
CheckTimeout (
|
||||
IN OUT UINT64 *PreviousTime,
|
||||
IN UINT64 *TotalTime,
|
||||
IN UINT64 Timeout
|
||||
);
|
||||
|
||||
/**
|
||||
Searches for the next waiting AP.
|
||||
|
||||
Search for the next AP that is put in waiting state by single-threaded StartupAllAPs().
|
||||
|
||||
@param NextProcessorNumber Pointer to the processor number of the next waiting AP.
|
||||
|
||||
@retval EFI_SUCCESS The next waiting AP has been found.
|
||||
@retval EFI_NOT_FOUND No waiting AP exists.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
GetNextWaitingProcessorNumber (
|
||||
OUT UINTN *NextProcessorNumber
|
||||
);
|
||||
|
||||
/**
|
||||
Wrapper function for all procedures assigned to AP.
|
||||
|
||||
Wrapper function for all procedures assigned to AP via MP service protocol.
|
||||
It controls states of AP and invokes assigned precedure.
|
||||
|
||||
**/
|
||||
VOID
|
||||
ApProcWrapper (
|
||||
VOID
|
||||
);
|
||||
|
||||
/**
|
||||
Function to wake up a specified AP and assign procedure to it.
|
||||
|
||||
@param ProcessorNumber Handle number of the specified processor.
|
||||
@param Procedure Procedure to assign.
|
||||
@param ProcArguments Argument for Procedure.
|
||||
|
||||
**/
|
||||
VOID
|
||||
WakeUpAp (
|
||||
IN UINTN ProcessorNumber,
|
||||
IN EFI_AP_PROCEDURE Procedure,
|
||||
IN VOID *ProcArguments
|
||||
);
|
||||
|
||||
/**
|
||||
Terminate AP's task and set it to idle state.
|
||||
|
||||
This function terminates AP's task due to timeout by sending INIT-SIPI,
|
||||
and sends it to idle state.
|
||||
|
||||
@param ProcessorNumber Handle number of the specified processor.
|
||||
|
||||
**/
|
||||
VOID
|
||||
ResetProcessorToIdleState (
|
||||
UINTN ProcessorNumber
|
||||
);
|
||||
|
||||
/**
|
||||
Worker function of EnableDisableAP ()
|
||||
|
||||
Worker function of EnableDisableAP (). Changes state of specified processor.
|
||||
|
||||
@param ProcessorNumber Processor number of specified AP.
|
||||
@param NewState Desired state of the specified AP.
|
||||
|
||||
@retval EFI_SUCCESS AP's state successfully changed.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
ChangeCpuState (
|
||||
IN UINTN ProcessorNumber,
|
||||
IN BOOLEAN NewState
|
||||
);
|
||||
|
||||
/**
|
||||
Gets the processor number of BSP.
|
||||
|
||||
@return The processor number of BSP.
|
||||
|
||||
**/
|
||||
UINTN
|
||||
GetBspNumber (
|
||||
VOID
|
||||
);
|
||||
|
||||
/**
|
||||
Get address map of RendezvousFunnelProc.
|
||||
|
||||
This function gets address map of RendezvousFunnelProc.
|
||||
|
||||
@param AddressMap Output buffer for address map information
|
||||
|
||||
**/
|
||||
VOID
|
||||
AsmGetAddressMap (
|
||||
OUT MP_ASSEMBLY_ADDRESS_MAP *AddressMap
|
||||
);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,68 @@
|
|||
#/** @file
|
||||
# Produces PI MP Services Protocol on top of Framework MP Services Protocol.
|
||||
#
|
||||
# Intel's Framework MP Services Protocol is replaced by EFI_MP_SERVICES_PROTOCOL in PI 1.1.
|
||||
# This module produces PI MP Services Protocol on top of Framework MP Services Protocol.
|
||||
#
|
||||
# Copyright (c) 2009, Intel Corporation
|
||||
#
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are licensed and made available under the terms and conditions of the BSD License
|
||||
# which accompanies this distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
#
|
||||
#**/
|
||||
|
||||
[Defines]
|
||||
INF_VERSION = 0x00010005
|
||||
BASE_NAME = MpServicesOnFrameworkMpServicesThunk
|
||||
FILE_GUID = 51739E2A-A022-4D73-ADB9-91F0C9BC7142
|
||||
MODULE_TYPE = DXE_DRIVER
|
||||
ENTRY_POINT = InitializeMpServicesProtocol
|
||||
|
||||
#
|
||||
# The following information is for reference only and not required by the build tools.
|
||||
#
|
||||
# VALID_ARCHITECTURES = IA32 X64
|
||||
#
|
||||
|
||||
[Sources.common]
|
||||
MpServicesOnFrameworkMpServicesThunk.c
|
||||
MpServicesOnFrameworkMpServicesThunk.h
|
||||
|
||||
[Sources.X64]
|
||||
X64/MpFuncs.asm
|
||||
X64/MpFuncs.S
|
||||
|
||||
[Sources.IA32]
|
||||
IA32/MpFuncs.asm
|
||||
IA32/MpFuncs.S
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
MdeModulePkg/MdeModulePkg.dec
|
||||
IntelFrameworkPkg/IntelFrameworkPkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
TimerLib
|
||||
IoLib
|
||||
UefiBootServicesTableLib
|
||||
DxeServicesTableLib
|
||||
MemoryAllocationLib
|
||||
UefiDriverEntryPoint
|
||||
BaseMemoryLib
|
||||
UefiLib
|
||||
DebugLib
|
||||
BaseLib
|
||||
SynchronizationLib
|
||||
|
||||
[Protocols]
|
||||
gEfiMpServiceProtocolGuid ## PRODUCES
|
||||
gFrameworkEfiMpServiceProtocolGuid ## CONSUMES
|
||||
gEfiGenericMemTestProtocolGuid ## SOMETIMES_CONSUMES
|
||||
|
||||
[Depex]
|
||||
gFrameworkEfiMpServiceProtocolGuid
|
|
@ -0,0 +1,26 @@
|
|||
;------------------------------------------------------------------------------
|
||||
; Include file for X64 MpFuncs.asm
|
||||
;
|
||||
; Copyright (c) 2009, Intel Corporation
|
||||
; All rights reserved. This program and the accompanying materials
|
||||
; are licensed and made available under the terms and conditions of the BSD License
|
||||
; which accompanies this distribution. The full text of the license may be found at
|
||||
; http://opensource.org/licenses/bsd-license.php
|
||||
;
|
||||
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
VacantFlag Equ 00h
|
||||
NotVacantFlag Equ 0ffh
|
||||
|
||||
LockLocation equ RendezvousFunnelProcEnd - RendezvousFunnelProcStart
|
||||
StackStartAddressLocation equ LockLocation + 08h
|
||||
StackSizeLocation equ LockLocation + 10h
|
||||
CProcedureLocation equ LockLocation + 18h
|
||||
GdtrLocation equ LockLocation + 20h
|
||||
BufferStartLocation equ LockLocation + 2Ch
|
||||
Cr3OffsetLocation equ LockLocation + 30h
|
||||
|
||||
;-------------------------------------------------------------------------------
|
|
@ -0,0 +1,189 @@
|
|||
#------------------------------------------------------------------------------
|
||||
# X64 assembly file for AP startup vector.
|
||||
#
|
||||
# Copyright (c) 2009, Intel Corporation
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are licensed and made available under the terms and conditions of the BSD License
|
||||
# which accompanies this distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
|
||||
.equ VacantFlag, 0x0
|
||||
.equ NotVacantFlag, 0xff
|
||||
|
||||
.equ LockLocation, RendezvousFunnelProcEnd - RendezvousFunnelProcStart
|
||||
.equ StackStartAddressLocation, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x08
|
||||
.equ StackSizeLocation, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x10
|
||||
.equ CProcedureLocation, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x18
|
||||
.equ GdtrLocation, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x20
|
||||
.equ BufferStartLocation, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x2C
|
||||
.equ Cr3OffsetLocation, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x30
|
||||
|
||||
#-------------------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------------------
|
||||
#RendezvousFunnelProc procedure follows. All APs execute their procedure. This
|
||||
#procedure serializes all the AP processors through an Init sequence. It must be
|
||||
#noted that APs arrive here very raw...ie: real mode, no stack.
|
||||
#ALSO THIS PROCEDURE IS EXECUTED BY APs ONLY ON 16 BIT MODE. HENCE THIS PROC
|
||||
#IS IN MACHINE CODE.
|
||||
#-------------------------------------------------------------------------------------
|
||||
#RendezvousFunnelProc (&WakeUpBuffer,MemAddress);
|
||||
|
||||
.text
|
||||
|
||||
ASM_GLOBAL ASM_PFX(RendezvousFunnelProc)
|
||||
ASM_PFX(RendezvousFunnelProc):
|
||||
RendezvousFunnelProcStart:
|
||||
|
||||
# At this point CS = 0x(vv00) and ip= 0x0.
|
||||
|
||||
.byte 0x8c,0xc8 # mov ax, cs
|
||||
.byte 0x8e,0xd8 # mov ds, ax
|
||||
.byte 0x8e,0xc0 # mov es, ax
|
||||
.byte 0x8e,0xd0 # mov ss, ax
|
||||
.byte 0x33,0xc0 # xor ax, ax
|
||||
.byte 0x8e,0xe0 # mov fs, ax
|
||||
.byte 0x8e,0xe8 # mov gs, ax
|
||||
|
||||
# Switch to flat mode.
|
||||
|
||||
.byte 0xBE
|
||||
.word BufferStartLocation
|
||||
.byte 0x66,0x8B,0x14 # mov edx,dword ptr [si] ; EDX is keeping the start address of wakeup buffer
|
||||
|
||||
.byte 0xBE
|
||||
.word Cr3OffsetLocation
|
||||
.byte 0x66,0x8B,0xC # mov ecx,dword ptr [si] ; ECX is keeping the value of CR3
|
||||
|
||||
.byte 0xBE
|
||||
.word GdtrLocation
|
||||
.byte 0x66 # db 66h
|
||||
.byte 0x2E,0xF,0x1,0x14 # lgdt fword ptr cs:[si]
|
||||
|
||||
.byte 0x33,0xC0 # xor ax, ax
|
||||
.byte 0x8E,0xD8 # mov ds, ax
|
||||
|
||||
.byte 0xF,0x20,0xC0 # mov eax, cr0 ; Get control register 0
|
||||
.byte 0x66,0x83,0xC8,0x1 # or eax, 000000001h ; Set PE bit (bit #0)
|
||||
.byte 0xF,0x22,0xC0 # mov cr0, eax
|
||||
|
||||
FLAT32_JUMP:
|
||||
|
||||
.byte 0x66,0x67,0xEA # far jump
|
||||
.long 0x0 # 32-bit offset
|
||||
.word 0x20 # 16-bit selector
|
||||
|
||||
ProtectedModeStart:
|
||||
|
||||
.byte 0x66,0xB8,0x18,0x0 # mov ax, 18h
|
||||
.byte 0x66,0x8E,0xD8 # mov ds, ax
|
||||
.byte 0x66,0x8E,0xC0 # mov es, ax
|
||||
.byte 0x66,0x8E,0xE0 # mov fs, ax
|
||||
.byte 0x66,0x8E,0xE8 # mov gs, ax
|
||||
.byte 0x66,0x8E,0xD0 # mov ss, ax ; Flat mode setup.
|
||||
|
||||
.byte 0xF,0x20,0xE0 # mov eax, cr4
|
||||
.byte 0xF,0xBA,0xE8,0x5 # bts eax, 5
|
||||
.byte 0xF,0x22,0xE0 # mov cr4, eax
|
||||
|
||||
.byte 0xF,0x22,0xD9 # mov cr3, ecx
|
||||
|
||||
.byte 0x8B,0xF2 # mov esi, edx ; Save wakeup buffer address
|
||||
|
||||
.byte 0xB9
|
||||
.long 0xC0000080 # mov ecx, 0c0000080h ; EFER MSR number.
|
||||
.byte 0xF,0x32 # rdmsr ; Read EFER.
|
||||
.byte 0xF,0xBA,0xE8,0x8 # bts eax, 8 ; Set LME=1.
|
||||
.byte 0xF,0x30 # wrmsr ; Write EFER.
|
||||
|
||||
.byte 0xF,0x20,0xC0 # mov eax, cr0 ; Read CR0.
|
||||
.byte 0xF,0xBA,0xE8,0x1F # bts eax, 31 ; Set PG=1.
|
||||
.byte 0xF,0x22,0xC0 # mov cr0, eax ; Write CR0.
|
||||
|
||||
LONG_JUMP:
|
||||
|
||||
.byte 0x67,0xEA # far jump
|
||||
.long 0x0 # 32-bit offset
|
||||
.word 0x38 # 16-bit selector
|
||||
|
||||
LongModeStart:
|
||||
|
||||
movw $0x30,%ax
|
||||
.byte 0x66
|
||||
movw %ax,%ds
|
||||
.byte 0x66
|
||||
movw %ax,%es
|
||||
.byte 0x66
|
||||
movw %ax,%ss
|
||||
|
||||
movl %esi, %edi
|
||||
addl $LockLocation, %edi
|
||||
movb $NotVacantFlag, %al
|
||||
TestLock:
|
||||
xchgb (%edi), %al
|
||||
cmpb $NotVacantFlag, %al
|
||||
jz TestLock
|
||||
|
||||
ProgramStack:
|
||||
|
||||
movl %esi, %edi
|
||||
addl $StackSizeLocation, %edi
|
||||
movq (%edi), %rax
|
||||
movl %esi, %edi
|
||||
addl $StackStartAddressLocation, %edi
|
||||
addq (%edi), %rax
|
||||
movq %rax, %rsp
|
||||
movq %rax, (%edi)
|
||||
|
||||
Releaselock:
|
||||
|
||||
movb $VacantFlag, %al
|
||||
movl %esi, %edi
|
||||
addl $LockLocation, %edi
|
||||
xchgb (%edi), %al
|
||||
|
||||
#
|
||||
# Call C Function
|
||||
#
|
||||
movl %esi,%edi
|
||||
addl $CProcedureLocation, %edi
|
||||
movq (%edi), %rax
|
||||
|
||||
testq %rax, %rax
|
||||
jz GoToSleep
|
||||
|
||||
subq $0x20, %rsp
|
||||
call *%rax
|
||||
addq $0x20, %rsp
|
||||
|
||||
GoToSleep:
|
||||
|
||||
cli
|
||||
hlt
|
||||
jmp .-2
|
||||
|
||||
RendezvousFunnelProcEnd:
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------------
|
||||
# AsmGetAddressMap (&AddressMap);
|
||||
#-------------------------------------------------------------------------------------
|
||||
# comments here for definition of address map
|
||||
ASM_GLOBAL ASM_PFX(AsmGetAddressMap)
|
||||
ASM_PFX(AsmGetAddressMap):
|
||||
|
||||
movq $RendezvousFunnelProcStart, %rax
|
||||
movq %rax, (%rcx)
|
||||
movq $(ProtectedModeStart - RendezvousFunnelProcStart), 0x08(%rcx)
|
||||
movq $(FLAT32_JUMP - RendezvousFunnelProcStart), 0x10(%rcx)
|
||||
movq $(LongModeStart - RendezvousFunnelProcStart), 0x18(%rcx)
|
||||
movq $(LONG_JUMP - RendezvousFunnelProcStart), 0x20(%rcx)
|
||||
movq $(RendezvousFunnelProcEnd - RendezvousFunnelProcStart), 0x28(%rcx)
|
||||
|
||||
ret
|
|
@ -0,0 +1,177 @@
|
|||
;------------------------------------------------------------------------------
|
||||
; X64 assembly file for AP startup vector.
|
||||
;
|
||||
; Copyright (c) 2009, Intel Corporation
|
||||
; All rights reserved. This program and the accompanying materials
|
||||
; are licensed and made available under the terms and conditions of the BSD License
|
||||
; which accompanies this distribution. The full text of the license may be found at
|
||||
; http://opensource.org/licenses/bsd-license.php
|
||||
;
|
||||
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
.code
|
||||
|
||||
include AsmInclude.inc
|
||||
;-------------------------------------------------------------------------------------
|
||||
|
||||
;-------------------------------------------------------------------------------------
|
||||
;RendezvousFunnelProc procedure follows. All APs execute their procedure. This
|
||||
;procedure serializes all the AP processors through an Init sequence. It must be
|
||||
;noted that APs arrive here very raw...ie: real mode, no stack.
|
||||
;ALSO THIS PROCEDURE IS EXECUTED BY APs ONLY ON 16 BIT MODE. HENCE THIS PROC
|
||||
;IS IN MACHINE CODE.
|
||||
;-------------------------------------------------------------------------------------
|
||||
;RendezvousFunnelProc (&WakeUpBuffer,MemAddress);
|
||||
|
||||
RendezvousFunnelProc PROC PUBLIC
|
||||
RendezvousFunnelProcStart::
|
||||
|
||||
; At this point CS = 0x(vv00) and ip= 0x0.
|
||||
|
||||
db 8ch, 0c8h ; mov ax, cs
|
||||
db 8eh, 0d8h ; mov ds, ax
|
||||
db 8eh, 0c0h ; mov es, ax
|
||||
db 8eh, 0d0h ; mov ss, ax
|
||||
db 33h, 0c0h ; xor ax, ax
|
||||
db 8eh, 0e0h ; mov fs, ax
|
||||
db 8eh, 0e8h ; mov gs, ax
|
||||
|
||||
; Switch to flat mode.
|
||||
|
||||
db 0BEh
|
||||
dw BufferStartLocation ; mov si, BufferStartLocation
|
||||
db 66h, 8Bh, 14h ; mov edx,dword ptr [si] ; EDX is keeping the start address of wakeup buffer
|
||||
|
||||
db 0BEh
|
||||
dw Cr3OffsetLocation ; mov si, Cr3Location
|
||||
db 66h, 8Bh, 0Ch ; mov ecx,dword ptr [si] ; ECX is keeping the value of CR3
|
||||
|
||||
db 0BEh
|
||||
dw GdtrLocation ; mov si, GdtrProfile
|
||||
db 66h ; db 66h
|
||||
db 2Eh, 0Fh, 01h, 14h ; lgdt fword ptr cs:[si]
|
||||
|
||||
db 33h, 0C0h ; xor ax, ax
|
||||
db 8Eh, 0D8h ; mov ds, ax
|
||||
|
||||
db 0Fh, 20h, 0C0h ; mov eax, cr0 ; Get control register 0
|
||||
db 66h, 83h, 0C8h, 01h ; or eax, 000000001h ; Set PE bit (bit #0)
|
||||
db 0Fh, 22h, 0C0h ; mov cr0, eax
|
||||
|
||||
FLAT32_JUMP::
|
||||
|
||||
db 66h, 67h, 0EAh ; far jump
|
||||
dd 0h ; 32-bit offset
|
||||
dw 20h ; 16-bit selector
|
||||
|
||||
ProtectedModeStart::
|
||||
|
||||
db 66h, 0B8h, 18h, 00h ; mov ax, 18h
|
||||
db 66h, 8Eh, 0D8h ; mov ds, ax
|
||||
db 66h, 8Eh, 0C0h ; mov es, ax
|
||||
db 66h, 8Eh, 0E0h ; mov fs, ax
|
||||
db 66h, 8Eh, 0E8h ; mov gs, ax
|
||||
db 66h, 8Eh, 0D0h ; mov ss, ax ; Flat mode setup.
|
||||
|
||||
db 0Fh, 20h, 0E0h ; mov eax, cr4
|
||||
db 0Fh, 0BAh, 0E8h, 05h ; bts eax, 5
|
||||
db 0Fh, 22h, 0E0h ; mov cr4, eax
|
||||
|
||||
db 0Fh, 22h, 0D9h ; mov cr3, ecx
|
||||
|
||||
db 8Bh, 0F2h ; mov esi, edx ; Save wakeup buffer address
|
||||
|
||||
db 0B9h
|
||||
dd 0C0000080h ; mov ecx, 0c0000080h ; EFER MSR number.
|
||||
db 0Fh, 32h ; rdmsr ; Read EFER.
|
||||
db 0Fh, 0BAh, 0E8h, 08h ; bts eax, 8 ; Set LME=1.
|
||||
db 0Fh, 30h ; wrmsr ; Write EFER.
|
||||
|
||||
db 0Fh, 20h, 0C0h ; mov eax, cr0 ; Read CR0.
|
||||
db 0Fh, 0BAh, 0E8h, 1Fh ; bts eax, 31 ; Set PG=1.
|
||||
db 0Fh, 22h, 0C0h ; mov cr0, eax ; Write CR0.
|
||||
|
||||
LONG_JUMP::
|
||||
|
||||
db 67h, 0EAh ; far jump
|
||||
dd 0h ; 32-bit offset
|
||||
dw 38h ; 16-bit selector
|
||||
|
||||
LongModeStart::
|
||||
|
||||
mov ax, 30h
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
mov ss, ax
|
||||
|
||||
mov edi, esi
|
||||
add edi, LockLocation
|
||||
mov al, NotVacantFlag
|
||||
TestLock::
|
||||
xchg byte ptr [edi], al
|
||||
cmp al, NotVacantFlag
|
||||
jz TestLock
|
||||
|
||||
ProgramStack::
|
||||
|
||||
mov edi, esi
|
||||
add edi, StackSizeLocation
|
||||
mov rax, qword ptr [edi]
|
||||
mov edi, esi
|
||||
add edi, StackStartAddressLocation
|
||||
add rax, qword ptr [edi]
|
||||
mov rsp, rax
|
||||
mov qword ptr [edi], rax
|
||||
|
||||
Releaselock::
|
||||
|
||||
mov al, VacantFlag
|
||||
mov edi, esi
|
||||
add edi, LockLocation
|
||||
xchg byte ptr [edi], al
|
||||
|
||||
;
|
||||
; Call C Function
|
||||
;
|
||||
mov edi, esi
|
||||
add edi, CProcedureLocation
|
||||
mov rax, qword ptr [edi]
|
||||
|
||||
test rax, rax
|
||||
jz GoToSleep
|
||||
|
||||
sub rsp, 20h
|
||||
call rax
|
||||
add rsp, 20h
|
||||
|
||||
GoToSleep::
|
||||
|
||||
cli
|
||||
hlt
|
||||
jmp $-2
|
||||
|
||||
RendezvousFunnelProc ENDP
|
||||
RendezvousFunnelProcEnd::
|
||||
|
||||
|
||||
;-------------------------------------------------------------------------------------
|
||||
; AsmGetAddressMap (&AddressMap);
|
||||
;-------------------------------------------------------------------------------------
|
||||
AsmGetAddressMap PROC
|
||||
|
||||
mov rax, offset RendezvousFunnelProcStart
|
||||
mov qword ptr [rcx], rax
|
||||
mov qword ptr [rcx+8h], ProtectedModeStart - RendezvousFunnelProcStart
|
||||
mov qword ptr [rcx+10h], FLAT32_JUMP - RendezvousFunnelProcStart
|
||||
mov qword ptr [rcx+18h], LongModeStart - RendezvousFunnelProcStart
|
||||
mov qword ptr [rcx+20h], LONG_JUMP - RendezvousFunnelProcStart
|
||||
mov qword ptr [rcx+28h], RendezvousFunnelProcEnd - RendezvousFunnelProcStart
|
||||
|
||||
ret
|
||||
|
||||
AsmGetAddressMap ENDP
|
||||
|
||||
END
|
|
@ -62,6 +62,7 @@ define GCC_MACRO = -DEFI_SPECIFICATION_VERSION=0x00020000 -DPI_S
|
|||
PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
|
||||
PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
|
||||
LanguageLib|EdkCompatibilityPkg/Compatibility/Library/UefiLanguageLib/UefiLanguageLib.inf
|
||||
DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf
|
||||
|
||||
[LibraryClasses.common.PEIM]
|
||||
HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
|
||||
|
@ -242,6 +243,7 @@ define GCC_MACRO = -DEFI_SPECIFICATION_VERSION=0x00020000 -DPI_S
|
|||
EdkCompatibilityPkg/Compatibility/UcOnUc2Thunk/UcOnUc2Thunk.inf
|
||||
EdkCompatibilityPkg/Compatibility/PrintThunk/PrintThunk.inf
|
||||
EdkCompatibilityPkg/Compatibility/LegacyRegion2OnLegacyRegionThunk/LegacyRegion2OnLegacyRegionThunk.inf
|
||||
EdkCompatibilityPkg/Compatibility/MpServicesOnFrameworkMpServicesThunk/MpServicesOnFrameworkMpServicesThunk.inf
|
||||
EdkCompatibilityPkg/Compatibility/CpuIo2OnCpuIoThunk/CpuIo2OnCpuIoThunk.inf
|
||||
|
||||
#
|
||||
|
|
Loading…
Reference in New Issue