ArmPlatformStackLib.S 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. //
  2. // Copyright (c) 2012-2014, ARM Limited. All rights reserved.
  3. //
  4. // SPDX-License-Identifier: BSD-2-Clause-Patent
  5. //
  6. //
  7. #include <AsmMacroIoLibV8.h>
  8. //VOID
  9. //ArmPlatformStackSet (
  10. // IN UINTN StackBase,
  11. // IN UINTN MpId,
  12. // IN UINTN PrimaryStackSize,
  13. // IN UINTN SecondaryStackSize
  14. // );
  15. ASM_FUNC(ArmPlatformStackSet)
  16. // Save parameters
  17. mov x26, x3
  18. mov x25, x2
  19. mov x24, x1
  20. mov x23, x0
  21. // Save the Link register
  22. mov x27, x30
  23. // Identify Stack
  24. mov x0, x1
  25. bl ASM_PFX(ArmPlatformIsPrimaryCore)
  26. cmp x0, #1
  27. // Restore parameters
  28. mov x0, x23
  29. mov x1, x24
  30. mov x2, x25
  31. mov x3, x26
  32. // Restore the Link register
  33. mov x30, x27
  34. b.ne 0f
  35. b ASM_PFX(ArmPlatformStackSetPrimary)
  36. 0:b ASM_PFX(ArmPlatformStackSetSecondary)
  37. //VOID
  38. //ArmPlatformStackSetPrimary (
  39. // IN UINTN StackBase,
  40. // IN UINTN MpId,
  41. // IN UINTN PrimaryStackSize,
  42. // IN UINTN SecondaryStackSize
  43. // );
  44. ASM_FUNC(ArmPlatformStackSetPrimary)
  45. // Add size of primary stack to StackBase
  46. add x0, x0, x2
  47. // Compute SecondaryCoresCount * SecondaryCoreStackSize
  48. MOV32 (w1, FixedPcdGet32(PcdCoreCount) - 1)
  49. mul x3, x3, x1
  50. // Set Primary Stack ((StackBase + PrimaryStackSize) + (SecondaryCoresCount * SecondaryCoreStackSize))
  51. add sp, x0, x3
  52. ret
  53. //VOID
  54. //ArmPlatformStackSetSecondary (
  55. // IN UINTN StackBase,
  56. // IN UINTN MpId,
  57. // IN UINTN PrimaryStackSize,
  58. // IN UINTN SecondaryStackSize
  59. // );
  60. ASM_FUNC(ArmPlatformStackSetSecondary)
  61. // Save the Link register
  62. mov x24, x30
  63. mov sp, x0
  64. // Get Core Position
  65. mov x0, x1
  66. bl ASM_PFX(ArmPlatformGetCorePosition)
  67. mov x25, x0
  68. // Get Primary Core Position
  69. bl ASM_PFX(ArmPlatformGetPrimaryCoreMpId)
  70. bl ASM_PFX(ArmPlatformGetCorePosition)
  71. // Get Secondary Core Position. We should get consecutive secondary stack number from 1...(CoreCount-1)
  72. cmp x25, x0
  73. // Decrement the position if after the primary core
  74. cinc x25, x25, ls
  75. // Compute top of the secondary stack
  76. mul x3, x3, x25
  77. // Set stack
  78. add sp, sp, x3
  79. ret x24