UefiCpuPkg/CpuDxe: Add StartApsStackless routine

This routine starts the APs and directs them to run the specified
code.

The specified code is entered without a stack being available.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
UefiCpuPkg/CpuDxe: introduce two PCD value

introduce PCD value: PcdCpuMaxLogicalProcessorNumber and PcdCpuApStackSize,
used for initialize APs stacks.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
UefiCpuPkg/CpuDxe: Switch Ap Stack to NewStack

All APs use the same common stack to initialization. after
initialization, APs should switch to the stack of its own.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
UefiCpuPkg/CpuDxe: introduce EFI_MP_SERVICES_PROTOCOL

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
UefiCpuPkg/CpuDxe: introduce MP_SYSTEM_DATA for Mp Service Protocol

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
UefiCpuPkg/CpuDxe: implement Mp Protocol: WhoAmI()

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
UefiCpuPkg/CpuDxe: implement Mp Protocol:GetNumberOfProcessors()

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
UefiCpuPkg/CpuDxe: implement Mp Services:GetProcessorInfo()

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
UefiCpuPkg/CpuDxe: implement Mp Protocol:EnableDisableAP()

Due to the implementation of  AcquireSpinLock() is not MP safe,
so we should use AcquireSpinLockOrFail directly instead.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
UefiCpuPkg/CpuDxe: implement Mp Protocol:StartupThisAP()

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
UefiCpuPkg/CpuDxe: implement Mp Services:StartupAllAPs()

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
UefiCpuPkg/CpuDxe: implement Mp Services:SwitchBSP()

by now, SwitchBSP() always return UNSUPPORTED

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
UefiCpuPkg/CpuDxe: Ap do loop routine to execute procedure

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
UefiCpuPkg/MpService: move settimer out to InitMpSystemData

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
UefiCpuPkg/MpService: Simply Lock usage

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
UefiCpuPkg/MpService: avoid next timer getting into CheckAllAPsStatus()

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
UefiCpuPkg/CpuDxe: split out StartupCode from StartApsStackless()

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
UefiCpuPkg/CpuDxe: introduce ResetApStackless()

If timeout expires before AP returns from Procedure, the AP should
be terminated, we introduce ResetApStackLess() to send init IPI
to let AP exit Procedurce and re-available.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
UefiCpuPkg/MpService: avoid reset AP still hold a lock

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
UefiCpuPkg/MpService: avoid dead lock caused by CheckAllAPsStatus

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>