ArmPlatformPkg Stack

Jordan Justen edited this page Nov 10, 2014 · 2 revisions
Clone this wiki locally

Stack Topology in ArmPlatformPkg

On MP Core system, the primary core is the core which is responsible for leading the execution in a software stack. In most cases, the primary core is the core 0. But because this is a software specific choice, it can be any core of the CPU. To save memory space in temporary memory, the primary core size has been made distinct from the secondary core stack size. And to make the algorithm simpler, all the cores have been assigned a secondary stack. It means the primary core has been reserved two stack regions, but only uses the primary one.


If the ARM Secure extension (ie: Trustzone) is supported in software, at least two set of stacks must be allocated on the platform. The stacks for the Secure World and the one for the Non Secure/Normal world.

  • PCDs to define stacks in PI/UEFI:
- Stack Base: gArmPlatformTokenSpaceGuid.PcdCPUCoresStackBase - Primary Core Size: gArmPlatformTokenSpaceGuid.PcdCPUCorePrimaryStackSize - Secondary Core Size: gArmPlatformTokenSpaceGuid.PcdCPUCoreSecondaryStackSize
  • If Secure World implemented by EDK2, PCDs to define the stacks:
- Stack Base: gArmPlatformTokenSpaceGuid.PcdCPUCoresSecStackBase - Primary Core Size: gArmPlatformTokenSpaceGuid.PcdCPUCoreSecPrimaryStackSize - Secondary Core Size: gArmPlatformTokenSpaceGuid.PcdCPUCoreSecSecondaryStackSize

Note: a separate region for Secure Monitor World stacks can also be defined with PCDs. In case of Secure Monitor stacks, no difference is made between primary and secondary stacks. All cores have the same size. - Secure Monitor Stack Base: gArmPlatformTokenSpaceGuid.PcdCPUCoresSecMonStackBase - Secure Monitor Stack Size: gArmPlatformTokenSpaceGuid.PcdCPUCoreSecMonStackSize

In case of UniCore system, only the primary stack size and stack base need to be defined.

Global Variable region

To make easier to port EDK2 to a new ARM platform, global variables needed during the XIP phase have been defined into common region of the temporary memory to avoid to have to set the base address of each of these global variables everytime we port EDK2 to a new platform. Global variables are defined by an offset in this region. The Global Variable region is automatically set at the top of the primary core stack.


Example to access the global variable B in Normal World, the calculation should be: PcdCPUCoresStackBase + PcdCPUCorePrimaryStackSize - PcdPeiGlobalVariableSize + PcdXipVariableBGlobalOffset