public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ard Biesheuvel" <ardb@kernel.org>
To: devel@edk2.groups.io
Cc: quic_llindhol@quicinc.com, Ard Biesheuvel <ardb@kernel.org>
Subject: [edk2-devel] [PATCH edk2-platforms 2/2] Platform/Beagle: Remove secondary CPU handling
Date: Wed, 31 Jul 2024 12:42:04 +0200	[thread overview]
Message-ID: <20240731104204.5905-2-ardb@kernel.org> (raw)
In-Reply-To: <20240731104204.5905-1-ardb@kernel.org>

Beagle's PrePi fork rather pointlessly includes the handling of
secondary stacks, as it implements the UniCore flavor only, has its
PcdCoreCount set to the default value of 1, and does not actually exist
in a SMP configuration.

So drop this handling so we can retire it completely in EDK2.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
 Platform/BeagleBoard/BeagleBoardPkg/BeagleBoardPkg.dsc             |   1 -
 Platform/BeagleBoard/BeagleBoardPkg/PrePi/PeiUniCore.inf           |   3 -
 Platform/BeagleBoard/BeagleBoardPkg/PrePi/Arm/ModuleEntryPoint.S   |  29 +---
 Platform/BeagleBoard/BeagleBoardPkg/PrePi/Arm/ModuleEntryPoint.asm | 142 --------------------
 4 files changed, 4 insertions(+), 171 deletions(-)

diff --git a/Platform/BeagleBoard/BeagleBoardPkg/BeagleBoardPkg.dsc b/Platform/BeagleBoard/BeagleBoardPkg/BeagleBoardPkg.dsc
index a114c9b633d0..7d82f350bad6 100644
--- a/Platform/BeagleBoard/BeagleBoardPkg/BeagleBoardPkg.dsc
+++ b/Platform/BeagleBoard/BeagleBoardPkg/BeagleBoardPkg.dsc
@@ -31,7 +31,6 @@ [LibraryClasses.common]
   ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf
   ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
   ArmPlatformLib|Platform/BeagleBoard/BeagleBoardPkg/Library/BeagleBoardLib/BeagleBoardLib.inf
-  ArmPlatformStackLib|ArmPlatformPkg/Library/ArmPlatformStackLib/ArmPlatformStackLib.inf
   ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
 
   HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf
diff --git a/Platform/BeagleBoard/BeagleBoardPkg/PrePi/PeiUniCore.inf b/Platform/BeagleBoard/BeagleBoardPkg/PrePi/PeiUniCore.inf
index 03d8f4daab48..44f6ebd52c1d 100644
--- a/Platform/BeagleBoard/BeagleBoardPkg/PrePi/PeiUniCore.inf
+++ b/Platform/BeagleBoard/BeagleBoardPkg/PrePi/PeiUniCore.inf
@@ -33,7 +33,6 @@ [Packages]
 [LibraryClasses]
   ArmLib
   ArmPlatformLib
-  ArmPlatformStackLib
   BaseLib
   DebugLib
   DebugAgentLib
@@ -58,7 +57,6 @@ [Guids]
 
 [FeaturePcd]
   gEmbeddedTokenSpaceGuid.PcdPrePiProduceMemoryTypeInformationHob
-  gArmPlatformTokenSpaceGuid.PcdSendSgiToBringUpSecondaryCores
 
 [Pcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString
@@ -73,7 +71,6 @@ [FixedPcd]
   gArmTokenSpaceGuid.PcdFvSize
 
   gArmPlatformTokenSpaceGuid.PcdCPUCorePrimaryStackSize
-  gArmPlatformTokenSpaceGuid.PcdCPUCoreSecondaryStackSize
 
   gArmPlatformTokenSpaceGuid.PcdSystemMemoryUefiRegionSize
 
diff --git a/Platform/BeagleBoard/BeagleBoardPkg/PrePi/Arm/ModuleEntryPoint.S b/Platform/BeagleBoard/BeagleBoardPkg/PrePi/Arm/ModuleEntryPoint.S
index ff7e3a454853..46c1498b969f 100644
--- a/Platform/BeagleBoard/BeagleBoardPkg/PrePi/Arm/ModuleEntryPoint.S
+++ b/Platform/BeagleBoard/BeagleBoardPkg/PrePi/Arm/ModuleEntryPoint.S
@@ -13,11 +13,6 @@ ASM_FUNC(_ModuleEntryPoint)
   // Do early platform specific actions
   bl    ASM_PFX(ArmPlatformPeiBootAction)
 
-  // Get ID of this CPU in Multicore system
-  bl    ASM_PFX(ArmReadMpidr)
-  // Keep a copy of the MpId register value
-  mov   r8, r0
-
 _SetSVCMode:
   // Enter SVC mode, Disable FIQ and IRQ
   mov     r1, #(CPSR_MODE_SVC | CPSR_IRQ | CPSR_FIQ)
@@ -82,33 +77,17 @@ _GetBaseUefiMemory:
 
 _GetStackBase:
   // r1 = The top of the Mpcore Stacks
+  mov   sp, r1
+
   // Stack for the primary core = PrimaryCoreStack
   MOV32 (r2, FixedPcdGet32(PcdCPUCorePrimaryStackSize))
   sub   r10, r1, r2
 
-  // Stack for the secondary core = Number of Cores - 1
-  MOV32 (r1, (FixedPcdGet32(PcdCoreCount) - 1) * FixedPcdGet32(PcdCPUCoreSecondaryStackSize))
-  sub   r10, r10, r1
+  // Get ID of this CPU in Multicore system
+  bl    ASM_PFX(ArmReadMpidr)
 
-  // r10 = The base of the MpCore Stacks (primary stack & secondary stacks)
-  mov   r0, r10
-  mov   r1, r8
-  //ArmPlatformStackSet(StackBase, MpId, PrimaryStackSize, SecondaryStackSize)
-  MOV32 (r2, FixedPcdGet32(PcdCPUCorePrimaryStackSize))
-  MOV32 (r3, FixedPcdGet32(PcdCPUCoreSecondaryStackSize))
-  bl    ASM_PFX(ArmPlatformStackSet)
-
-  // Is it the Primary Core ?
-  mov   r0, r8
-  bl    ASM_PFX(ArmPlatformIsPrimaryCore)
-  cmp   r0, #1
-  bne   _PrepareArguments
-
-_PrepareArguments:
-  mov   r0, r8
   mov   r1, r9
   mov   r2, r10
-  mov   r3, sp
 
   // Move sec startup address into a data register
   // Ensure we're jumping to FV version of the code (not boot remapped alias)
diff --git a/Platform/BeagleBoard/BeagleBoardPkg/PrePi/Arm/ModuleEntryPoint.asm b/Platform/BeagleBoard/BeagleBoardPkg/PrePi/Arm/ModuleEntryPoint.asm
deleted file mode 100644
index 3da789205124..000000000000
--- a/Platform/BeagleBoard/BeagleBoardPkg/PrePi/Arm/ModuleEntryPoint.asm
+++ /dev/null
@@ -1,142 +0,0 @@
-//
-//  Copyright (c) 2011-2015, ARM Limited. All rights reserved.
-//
-//  SPDX-License-Identifier: BSD-2-Clause-Patent
-//
-//
-
-#include <AutoGen.h>
-#include <Chipset/ArmV7.h>
-
-  INCLUDE AsmMacroIoLib.inc
-
-  IMPORT  CEntryPoint
-  IMPORT  ArmPlatformIsPrimaryCore
-  IMPORT  ArmReadMpidr
-  IMPORT  ArmPlatformPeiBootAction
-  IMPORT  ArmPlatformStackSet
-  IMPORT  mSystemMemoryEnd
-
-  EXPORT  _ModuleEntryPoint
-
-  PRESERVE8
-  AREA    PrePiCoreEntryPoint, CODE, READONLY
-
-StartupAddr        DCD      CEntryPoint
-
-_ModuleEntryPoint
-  // Do early platform specific actions
-  bl    ArmPlatformPeiBootAction
-
-  // Get ID of this CPU in Multicore system
-  bl    ArmReadMpidr
-  // Keep a copy of the MpId register value
-  mov   r8, r0
-
-_SetSVCMode
-  // Enter SVC mode, Disable FIQ and IRQ
-  mov     r1, #(CPSR_MODE_SVC :OR: CPSR_IRQ :OR: CPSR_FIQ)
-  msr     CPSR_c, r1
-
-// Check if we can install the stack at the top of the System Memory or if we need
-// to install the stacks at the bottom of the Firmware Device (case the FD is located
-// at the top of the DRAM)
-_SystemMemoryEndInit
-  adrll r1, mSystemMemoryEnd
-  ldrd  r2, r3, [r1]
-  teq   r3, #0
-  moveq r1, r2
-  mvnne r1, #0
-
-_SetupStackPosition
-  // r1 = SystemMemoryTop
-
-  // Calculate Top of the Firmware Device
-  mov32 r2, FixedPcdGet32(PcdFdBaseAddress)
-  mov32 r3, FixedPcdGet32(PcdFdSize)
-  sub   r3, r3, #1
-  add   r3, r3, r2      // r3 = FdTop = PcdFdBaseAddress + PcdFdSize
-
-  // UEFI Memory Size (stacks are allocated in this region)
-  mov32 r4, FixedPcdGet32(PcdSystemMemoryUefiRegionSize)
-
-  //
-  // Reserve the memory for the UEFI region (contain stacks on its top)
-  //
-
-  // Calculate how much space there is between the top of the Firmware and the Top of the System Memory
-  subs  r0, r1, r3      // r0 = SystemMemoryTop - FdTop
-  bmi   _SetupStack     // Jump if negative (FdTop > SystemMemoryTop). Case when the PrePi is in XIP memory outside of the DRAM
-  cmp   r0, r4
-  bge   _SetupStack
-
-  // Case the top of stacks is the FdBaseAddress
-  mov   r1, r2
-
-_SetupStack
-  // r1 contains the top of the stack (and the UEFI Memory)
-
-  // Because the 'push' instruction is equivalent to 'stmdb' (decrement before), we need to increment
-  // one to the top of the stack. We check if incrementing one does not overflow (case of DRAM at the
-  // top of the memory space)
-  adds  r9, r1, #1
-  bcs   _SetupOverflowStack
-
-_SetupAlignedStack
-  mov   r1, r9
-  b     _GetBaseUefiMemory
-
-_SetupOverflowStack
-  // Case memory at the top of the address space. Ensure the top of the stack is EFI_PAGE_SIZE
-  // aligned (4KB)
-  mov32 r9, EFI_PAGE_MASK
-  and   r9, r9, r1
-  sub   r1, r1, r9
-
-_GetBaseUefiMemory
-  // Calculate the Base of the UEFI Memory
-  sub   r9, r1, r4
-
-_GetStackBase
-  // r1 = The top of the Mpcore Stacks
-  // Stack for the primary core = PrimaryCoreStack
-  mov32 r2, FixedPcdGet32(PcdCPUCorePrimaryStackSize)
-  sub   r10, r1, r2
-
-  // Stack for the secondary core = Number of Cores - 1
-  mov32 r1, (FixedPcdGet32(PcdCoreCount) - 1) * FixedPcdGet32(PcdCPUCoreSecondaryStackSize)
-  sub   r10, r10, r1
-
-  // r10 = The base of the MpCore Stacks (primary stack & secondary stacks)
-  mov   r0, r10
-  mov   r1, r8
-  //ArmPlatformStackSet(StackBase, MpId, PrimaryStackSize, SecondaryStackSize)
-  mov32 r2, FixedPcdGet32(PcdCPUCorePrimaryStackSize)
-  mov32 r3, FixedPcdGet32(PcdCPUCoreSecondaryStackSize)
-  bl    ArmPlatformStackSet
-
-  // Is it the Primary Core ?
-  mov   r0, r8
-  bl    ArmPlatformIsPrimaryCore
-  cmp   r0, #1
-  bne   _PrepareArguments
-
-_PrepareArguments
-  mov   r0, r8
-  mov   r1, r9
-  mov   r2, r10
-
-  // Move sec startup address into a data register
-  // Ensure we're jumping to FV version of the code (not boot remapped alias)
-  ldr   r4, StartupAddr
-
-  // Jump to PrePiCore C code
-  //    r0 = MpId
-  //    r1 = UefiMemoryBase
-  //    r2 = StacksBase
-  blx   r4
-
-_NeverReturn
-  b _NeverReturn
-
-  END
-- 
2.46.0.rc1.232.g9752f9e123-goog



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#120141): https://edk2.groups.io/g/devel/message/120141
Mute This Topic: https://groups.io/mt/107643742/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



  reply	other threads:[~2024-07-31 10:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-31 10:42 [edk2-devel] [PATCH edk2-platforms 1/2] Platform/Beagle: Fix DSC line endings Ard Biesheuvel
2024-07-31 10:42 ` Ard Biesheuvel [this message]
2024-07-31 10:55 ` Leif Lindholm
2024-07-31 23:56 ` Rebecca Cran

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240731104204.5905-2-ardb@kernel.org \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox