PrePeiCoreEntryPoint.S 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. //
  2. // Copyright (c) 2011-2013, ARM Limited. All rights reserved.
  3. //
  4. // SPDX-License-Identifier: BSD-2-Clause-Patent
  5. //
  6. //
  7. #include <AsmMacroIoLib.h>
  8. ASM_FUNC(_ModuleEntryPoint)
  9. // Do early platform specific actions
  10. bl ASM_PFX(ArmPlatformPeiBootAction)
  11. // Identify CPU ID
  12. bl ASM_PFX(ArmReadMpidr)
  13. // Keep a copy of the MpId register value
  14. mov r5, r0
  15. // Is it the Primary Core ?
  16. bl ASM_PFX(ArmPlatformIsPrimaryCore)
  17. // Get the top of the primary stacks (and the base of the secondary stacks)
  18. MOV32 (r1, FixedPcdGet64(PcdCPUCoresStackBase) + FixedPcdGet32(PcdCPUCorePrimaryStackSize))
  19. // r0 is equal to 1 if I am the primary core
  20. cmp r0, #1
  21. beq _SetupPrimaryCoreStack
  22. _SetupSecondaryCoreStack:
  23. // r1 contains the base of the secondary stacks
  24. // Get the Core Position
  25. mov r6, r1 // Save base of the secondary stacks
  26. mov r0, r5
  27. bl ASM_PFX(ArmPlatformGetCorePosition)
  28. // The stack starts at the top of the stack region. Add '1' to the Core Position to get the top of the stack
  29. add r0, r0, #1
  30. // StackOffset = CorePos * StackSize
  31. MOV32 (r2, FixedPcdGet32(PcdCPUCoreSecondaryStackSize))
  32. mul r0, r0, r2
  33. // SP = StackBase + StackOffset
  34. add sp, r6, r0
  35. _PrepareArguments:
  36. // The PEI Core Entry Point has been computed by GenFV and stored in the second entry of the Reset Vector
  37. MOV32 (r2, FixedPcdGet32(PcdFvBaseAddress))
  38. ldr r1, [r2, #4]
  39. // Move sec startup address into a data register
  40. // Ensure we're jumping to FV version of the code (not boot remapped alias)
  41. ldr r3, =ASM_PFX(CEntryPoint)
  42. // Jump to PrePeiCore C code
  43. // r0 = mp_id
  44. // r1 = pei_core_address
  45. mov r0, r5
  46. blx r3
  47. _SetupPrimaryCoreStack:
  48. mov sp, r1
  49. MOV32 (r8, FixedPcdGet64 (PcdCPUCoresStackBase))
  50. MOV32 (r9, FixedPcdGet32 (PcdInitValueInTempStack))
  51. mov r10, r9
  52. mov r11, r9
  53. mov r12, r9
  54. 0:stm r8!, {r9-r12}
  55. cmp r8, r1
  56. blt 0b
  57. b _PrepareArguments
  58. _NeverReturn:
  59. b _NeverReturn