diff options
| author | gparikh <gparikh@qti.qualcomm.com> | 2026-07-17 05:56:57 +0300 |
|---|---|---|
| committer | Vishal Oliyil Kunnil <vishalo@users.noreply.github.com> | 2026-09-03 02:48:11 +0300 |
| commit | 061beb4c4bd259c073743f5ac01b5a1da4ce2010 (patch) | |
| tree | a8437a5323a9b6a6850b32012ba1b72683dc0471 /Platform/Qualcomm/QualcommMinPlatformPkg | |
| parent | c8295e076affae5cf04fd4234db13a0e025f44e1 (diff) | |
| download | edk2-platforms-master.tar.xz | |
Add Qualcomm SMEM lib implementation.
Signed-off-by: gparikh <gparikh@qti.qualcomm.com>
Diffstat (limited to 'Platform/Qualcomm/QualcommMinPlatformPkg')
5 files changed, 35 insertions, 36 deletions
diff --git a/Platform/Qualcomm/QualcommMinPlatformPkg/Library/ArmPlatformLib/ArmPlatformLib.inf b/Platform/Qualcomm/QualcommMinPlatformPkg/Library/ArmPlatformLib/ArmPlatformLib.inf index 3b3e4e8c96..faf3d798bd 100644 --- a/Platform/Qualcomm/QualcommMinPlatformPkg/Library/ArmPlatformLib/ArmPlatformLib.inf +++ b/Platform/Qualcomm/QualcommMinPlatformPkg/Library/ArmPlatformLib/ArmPlatformLib.inf @@ -43,6 +43,7 @@ PlatformInfoLib
RamPartitionTableLib
SortLib
+ QualcommSmemLib
[Sources.common]
ArmPlatformLib.c
diff --git a/Platform/Qualcomm/QualcommMinPlatformPkg/Library/ArmPlatformLib/ArmPlatformLibMem.c b/Platform/Qualcomm/QualcommMinPlatformPkg/Library/ArmPlatformLib/ArmPlatformLibMem.c index 331a1cce52..c7a8f90db7 100644 --- a/Platform/Qualcomm/QualcommMinPlatformPkg/Library/ArmPlatformLib/ArmPlatformLibMem.c +++ b/Platform/Qualcomm/QualcommMinPlatformPkg/Library/ArmPlatformLib/ArmPlatformLibMem.c @@ -25,8 +25,8 @@ #include <Library/HobLib.h>
#include <Library/PcdLib.h>
#include <Library/PlatformInfoLib.h>
+#include <Library/QualcommSmemLib.h>
#include <Library/RamPartitionTableLib.h>
-#include <Library/SmemLib.h>
#include <PiPei.h>
#include <Pi/PiHob.h>
@@ -641,7 +641,7 @@ ArmPlatformGetVirtualMemoryMap ( /* Reserved DDR Region for T32 CMM Script */
ArmPlatformSetupDebugBuffer ();
- SmemInit ();
+ QualcommSmemInit ();
DEBUG ((DEBUG_INFO, "SmemInit\n"));
/* Print Chip and Platform Information */
@@ -654,13 +654,13 @@ ArmPlatformGetVirtualMemoryMap ( goto ExitError;
}
- Status = RamPartitionInitRamPartitionTableLib();
+ Status = RamPartitionInitRamPartitionTableLib ();
if (Status != EFI_SUCCESS) {
DEBUG ((DEBUG_ERROR, "InitRamPartitionTableLib failed\n"));
goto ExitError;
}
- DisplayRamPartitionInformation();
+ DisplayRamPartitionInformation ();
/* Try DT-based platform configuration first */
Status = LoadPlatformConfigFromDeviceTree ();
diff --git a/Platform/Qualcomm/QualcommMinPlatformPkg/Library/RamPartitionTableLib/RamPartitionTableLib.c b/Platform/Qualcomm/QualcommMinPlatformPkg/Library/RamPartitionTableLib/RamPartitionTableLib.c index d4c4e02609..3a8985ec34 100644 --- a/Platform/Qualcomm/QualcommMinPlatformPkg/Library/RamPartitionTableLib/RamPartitionTableLib.c +++ b/Platform/Qualcomm/QualcommMinPlatformPkg/Library/RamPartitionTableLib/RamPartitionTableLib.c @@ -15,7 +15,7 @@ #include <Library/DebugLib.h>
#include <Library/RamPartitionTableLib.h>
-#include <Library/SmemLib.h>
+#include <Library/QualcommSmemLib.h>
#include <MemRegionInfo.h>
#include <RamPartition.h>
@@ -87,8 +87,15 @@ RamPartitionGetRamPartitionTable ( BufferSize = 0;
/* Get the RAM partition table */
- *RamPartitionTable = SmemGetAddr (SmemUsableRamPartitionTable, (UINT32 *)&BufferSize);
- if (*RamPartitionTable == NULL) {
+ Status = QualcommSmemLookup (
+ QUALCOMM_SMEM_HOST_COMMON,
+ SMEM_USABLE_RAM_PARTITION_TABLE,
+ QUALCOMM_SMEM_FLAG_NONE,
+ RamPartitionTable,
+ (VOID *)&BufferSize
+ );
+
+ if (Status != EFI_SUCCESS) {
DEBUG ((DEBUG_ERROR, "WARNING: Unable to read memory partition table from SMEM\n"));
return EFI_NOT_READY;
}
@@ -129,8 +136,8 @@ RamPartitionGetInstalledSdramMemory ( UINT32 Index;
UINT32 Version;
- RamPartitionTable = NULL;
- Version = 0;
+ RamPartitionTable = NULL;
+ Version = 0;
if (MemoryCapacity == NULL) {
return EFI_INVALID_PARAMETER;
@@ -188,7 +195,6 @@ RamPartitionGetInstalledPhysicalMemory ( return EFI_INVALID_PARAMETER;
}
-
Status = RamPartitionGetRamPartitionTable (&RamPartitionTable, &Version);
if (Status != EFI_SUCCESS) {
return Status;
@@ -276,7 +282,7 @@ RamPartitionGetLowestPhysicalStartAddress ( SetMem (EntryList, sizeof (EntryList), 0);
EntryCount = RAM_NUM_PART_ENTRIES;
- Status = RamPartitionGetRamPartitions (&EntryCount, EntryList);
+ Status = RamPartitionGetRamPartitions (&EntryCount, EntryList);
if (Status != EFI_SUCCESS) {
return Status;
}
@@ -472,7 +478,6 @@ RamPartitionGetHighestBankBit ( return EFI_INVALID_PARAMETER;
}
-
Status = RamPartitionGetRamPartitionTable (&RamPartitionTable, &Version);
if (Status != EFI_SUCCESS) {
return Status;
@@ -661,9 +666,9 @@ RamPartitionInitRamPartitionTableLib ( RAM_PARTITION_TYPE PartitionType;
UINT64 StartAddr;
- PartitionCategory = Table->RamPartEntry[Index].PartitionCategory;
- PartitionType = Table->RamPartEntry[Index].PartitionType;
- StartAddr = Table->RamPartEntry[Index].StartAddress;
+ PartitionCategory = Table->RamPartEntry[Index].PartitionCategory;
+ PartitionType = Table->RamPartEntry[Index].PartitionType;
+ StartAddr = Table->RamPartEntry[Index].StartAddress;
if ((PartitionType == RamPartitionSysMemory) &&
(PartitionCategory == RamPartitionSdram))
@@ -685,7 +690,6 @@ RamPartitionInitRamPartitionTableLib ( }
}
-
TableEntry = &mRamPartitionTable[mRamPartitionTableEntryCount];
AsciiStrCpyS (TableEntry->Name, MAX_MEM_LABEL_NAME, "RAM Partition");
@@ -762,14 +766,13 @@ RamPartitionGetMinPasrSize ( UINT32 Index;
UINT32 Version;
- RamPartitionTable = NULL;
- Version = 0;
+ RamPartitionTable = NULL;
+ Version = 0;
if (MinPasrSize == NULL) {
return EFI_INVALID_PARAMETER;
}
-
Status = RamPartitionGetRamPartitionTable (&RamPartitionTable, &Version);
if (Status != EFI_SUCCESS) {
return Status;
diff --git a/Platform/Qualcomm/QualcommMinPlatformPkg/Library/RamPartitionTableLib/RamPartitionTableLib.inf b/Platform/Qualcomm/QualcommMinPlatformPkg/Library/RamPartitionTableLib/RamPartitionTableLib.inf index 7dfc956024..683989b445 100644 --- a/Platform/Qualcomm/QualcommMinPlatformPkg/Library/RamPartitionTableLib/RamPartitionTableLib.inf +++ b/Platform/Qualcomm/QualcommMinPlatformPkg/Library/RamPartitionTableLib/RamPartitionTableLib.inf @@ -33,7 +33,7 @@ [LibraryClasses]
DebugLib
- SmemLib
+ QualcommSmemLib
[FixedPcd]
gArmTokenSpaceGuid.PcdSystemMemoryBase
diff --git a/Platform/Qualcomm/QualcommMinPlatformPkg/README.md b/Platform/Qualcomm/QualcommMinPlatformPkg/README.md index 84764e0a1a..a951eefa36 100644 --- a/Platform/Qualcomm/QualcommMinPlatformPkg/README.md +++ b/Platform/Qualcomm/QualcommMinPlatformPkg/README.md @@ -35,7 +35,7 @@ Power-on ├─ Populates RAM Partition Table in SMEM
├─ Writes IMEM cookies to on-chip SRAM
└─► UEFI (QualcommMinPlatformPkg / QualcommSiliconPkg)
- ├─ Reads SMEM via SmemLib
+ ├─ Reads SMEM via QualcommSmemLib
├─ Reads RAM Partition Table from SMEM
├─ Reads IMEM cookies for boot state
└─► HLOS (Linux/Android)
@@ -52,8 +52,7 @@ re-initialize them; it reads what XBL has already established. SMEM is a DDR region that acts as a message-passing bus between the
Application Processor (UEFI/HLOS), Modem, DSPs, RPM, TrustZone, and other
-subsystems. Each item in SMEM is identified by a numeric ID from the
-`SMEM_MEM_TYPE` enum defined in `Silicon/Qualcomm/QualcommSiliconPkg/Include/SmemType.h`.
+subsystems.
### Hardware Configuration
@@ -64,16 +63,12 @@ UEFI locates SMEM using platform-specific PCDs: | `PcdSmemBaseAddress` | `UINT64` | Physical base address of the SMEM DDR region |
| `PcdSmemSize` | `UINT32` | Size of the SMEM region in bytes |
| `PcdSmemMaxItems` | `UINT16` | Maximum number of allocatable SMEM items |
-| `PcdSmemTcsrBase` | `UINT32` | Base address of TCSR registers (spinlock support) |
-| `PcdSmemMutexRegBase` | `UINT32` | Base address of hardware mutex registers |
-| `PcdSmemWonceRegBase` | `UINT32` | Base address of Write-Once registers |
-| `PcdSmemTargetInfoWonceReg` | `UINT32` | Offset of target info register within WONCE space |
### Initialization Contract
XBL initializes SMEM before transferring control to UEFI. UEFI calls
-`SmemInit()` early in `ArmPlatformGetVirtualMemoryMap()` to set up its
-local view of the SMEM region. UEFI must not call `SmemInit()` more than
+`QualcommSmemInit()` early in `ArmPlatformGetVirtualMemoryMap()` to set up its
+local view of the SMEM region. UEFI must not call `QualcommSmemInit()` more than
once.
### SMEM Version Protocol
@@ -92,21 +87,21 @@ A minor version mismatch is tolerated. ### UEFI Usage
UEFI uses SMEM exclusively to retrieve the RAM Partition Table (see §2).
-The relevant SMEM item ID is `SmemUsableRamPartitionTable` (value `402`).
+The relevant SMEM item ID is `SMEM_USABLE_RAM_PARTITION_TABLE` (value `402`).
```c
// Retrieve RAM partition table pointer from SMEM
-RamPartitionTable = SmemGetAddr(SmemUsableRamPartitionTable, &BufferSize);
+QualcommSmemLookup(QUALCOMM_SMEM_HOST_COMMON,
+ SMEM_USABLE_RAM_PARTITION_TABLE,
+ QUALCOMM_SMEM_FLAG_NONE, RamPartitionTable,
+ (VOID *)&BufferSize);
```
### Compatibility Requirements
- The physical address and size of SMEM **must not change** between XBL and
UEFI for a given target. They are fixed at SoC integration time.
-- The `SMEM_MEM_TYPE` enum values are an ABI shared with all subsystems.
- All entries carry **explicit numeric assignments** to prevent accidental
- value shifts when new entries are added.
-- SMEM item IDs used by UEFI (`SmemUsableRamPartitionTable`) must remain
+- SMEM item IDs used by UEFI (`SMEM_USABLE_RAM_PARTITION_TABLE`) must remain
stable across XBL versions.
---
@@ -121,7 +116,7 @@ memory map and build HOBs for the DXE phase. ### Location
-Stored in SMEM at item ID `SmemUsableRamPartitionTable` (value `402`).
+Stored in SMEM at item ID `SMEM_USABLE_RAM_PARTITION_TABLE` (value `402`).
### Structure
|
