PrePeiCoreEntryPoint.asm 2.3 KB

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