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()

TODO: terminate AP's task and reset to idle state.

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/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/CpuDxe: Startup APs

This sequence should happen:
* CpuMp.c: Allocate a stack for the APs
* ApStartup.c: Send Start IPI to wake APs in 16-bit real mode
* MpAsm.S: AP enters CpuDxe driver code without stack
  - AP grabs a lock
  - AP sets up stack
  - AP calls CpuMp.c:ApEntryPointInC

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
UefiCpuPkg/CpuDxe: install Mp Service protocol

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
UefiCpuPkg/CpuDxe: add Mp Service TestCase (!upstream)

NOTE: this patches is for testing temporary.
      So it should be ignore when adding to main tree.

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