Skip to content

Commit

Permalink
AmpereAltraPkg/ArmPlatformLib: Map entire PCIe config space
Browse files Browse the repository at this point in the history
In theory, the entire PCIe Root Complex configuration space has to be
mapped as a device memory. However, with the recent changes of the new
PCie driver code, only CSR spaces are mapped. So, this adds the full
configuration space into the UEFI memory map.

Signed-off-by: Nhi Pham <[email protected]>
  • Loading branch information
nhivp committed Oct 11, 2024
1 parent 15d91fe commit d3c2499
Show file tree
Hide file tree
Showing 2 changed files with 290 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @file
Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved.<BR>
Copyright (c) 2020 - 2024, Ampere Computing LLC. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
Expand Down Expand Up @@ -88,6 +88,15 @@ ArmPlatformGetVirtualMemoryMap (
VirtualMemoryTable[Index].Length = AC01_RCA0_DEVICE_MEMORY_S0_SIZE;
VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;

/*
* - 2P/PCIe Socket0 RCA0 32-bit Device memory
* - 1P/PCIe consolidated to RCB2 32-bit Device memory
*/
VirtualMemoryTable[++Index].PhysicalBase = AC01_RCA0_32_BIT_DEVICE_MEMORY_S0_BASE;
VirtualMemoryTable[Index].VirtualBase = AC01_RCA0_32_BIT_DEVICE_MEMORY_S0_BASE;
VirtualMemoryTable[Index].Length = AC01_RCA0_32_BIT_DEVICE_MEMORY_S0_SIZE;
VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;

/*
* - PCIe RCA1 Device memory
*/
Expand All @@ -96,6 +105,15 @@ ArmPlatformGetVirtualMemoryMap (
VirtualMemoryTable[Index].Length = AC01_RCA1_DEVICE_MEMORY_S0_SIZE;
VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;

/*
* - 2P/PCIe Socket0 RCA1 32-bit Device memory
* - 1P/PCIe consolidated to RCB2 32-bit Device memory
*/
VirtualMemoryTable[++Index].PhysicalBase = AC01_RCA1_32_BIT_DEVICE_MEMORY_S0_BASE;
VirtualMemoryTable[Index].VirtualBase = AC01_RCA1_32_BIT_DEVICE_MEMORY_S0_BASE;
VirtualMemoryTable[Index].Length = AC01_RCA1_32_BIT_DEVICE_MEMORY_S0_SIZE;
VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;

/*
* - PCIe RCA2 Device memory
*/
Expand All @@ -104,6 +122,15 @@ ArmPlatformGetVirtualMemoryMap (
VirtualMemoryTable[Index].Length = AC01_RCA2_DEVICE_MEMORY_S0_SIZE;
VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;

/*
* - 2P/PCIe Socket0 RCA2 32-bit Device memory
* - 1P/PCIe consolidated to RCB3 32-bit Device memory
*/
VirtualMemoryTable[++Index].PhysicalBase = AC01_RCA2_32_BIT_DEVICE_MEMORY_S0_BASE;
VirtualMemoryTable[Index].VirtualBase = AC01_RCA2_32_BIT_DEVICE_MEMORY_S0_BASE;
VirtualMemoryTable[Index].Length = AC01_RCA2_32_BIT_DEVICE_MEMORY_S0_SIZE;
VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;

/*
* - PCIe RCA3 Device memory
*/
Expand All @@ -112,6 +139,15 @@ ArmPlatformGetVirtualMemoryMap (
VirtualMemoryTable[Index].Length = AC01_RCA3_DEVICE_MEMORY_S0_SIZE;
VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;

/*
* - 2P/PCIe Socket0 RCA3 32-bit Device memory
* - 1P/PCIe consolidated to RCB3 32-bit Device memory
*/
VirtualMemoryTable[++Index].PhysicalBase = AC01_RCA3_32_BIT_DEVICE_MEMORY_S0_BASE;
VirtualMemoryTable[Index].VirtualBase = AC01_RCA3_32_BIT_DEVICE_MEMORY_S0_BASE;
VirtualMemoryTable[Index].Length = AC01_RCA3_32_BIT_DEVICE_MEMORY_S0_SIZE;
VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;

/*
* - PCIe RCB0 Device memory
*/
Expand All @@ -120,6 +156,15 @@ ArmPlatformGetVirtualMemoryMap (
VirtualMemoryTable[Index].Length = AC01_RCB0_DEVICE_MEMORY_S0_SIZE;
VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;

/*
* - 2P/PCIe Socket0 RCB0 32-bit Device memory
* - 1P/PCIe consolidated to RCB0 32-bit Device memory
*/
VirtualMemoryTable[++Index].PhysicalBase = AC01_RCB0_32_BIT_DEVICE_MEMORY_S0_BASE;
VirtualMemoryTable[Index].VirtualBase = AC01_RCB0_32_BIT_DEVICE_MEMORY_S0_BASE;
VirtualMemoryTable[Index].Length = AC01_RCB0_32_BIT_DEVICE_MEMORY_S0_SIZE;
VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;

/*
* - PCIe RCB1 Device memory
*/
Expand All @@ -128,6 +173,15 @@ ArmPlatformGetVirtualMemoryMap (
VirtualMemoryTable[Index].Length = AC01_RCB1_DEVICE_MEMORY_S0_SIZE;
VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;

/*
* - 2P/PCIe Socket0 RCB1 32-bit Device memory
* - 1P/PCIe consolidated to RCB0 32-bit Device memory
*/
VirtualMemoryTable[++Index].PhysicalBase = AC01_RCB1_32_BIT_DEVICE_MEMORY_S0_BASE;
VirtualMemoryTable[Index].VirtualBase = AC01_RCB1_32_BIT_DEVICE_MEMORY_S0_BASE;
VirtualMemoryTable[Index].Length = AC01_RCB1_32_BIT_DEVICE_MEMORY_S0_SIZE;
VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;

/*
* - PCIe RCB2 Device memory
*/
Expand All @@ -136,6 +190,15 @@ ArmPlatformGetVirtualMemoryMap (
VirtualMemoryTable[Index].Length = AC01_RCB2_DEVICE_MEMORY_S0_SIZE;
VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;

/*
* - 2P/PCIe Socket0 RCB2 32-bit Device memory
* - 1P/PCIe consolidated to RCB1 32-bit Device memory
*/
VirtualMemoryTable[++Index].PhysicalBase = AC01_RCB2_32_BIT_DEVICE_MEMORY_S0_BASE;
VirtualMemoryTable[Index].VirtualBase = AC01_RCB2_32_BIT_DEVICE_MEMORY_S0_BASE;
VirtualMemoryTable[Index].Length = AC01_RCB2_32_BIT_DEVICE_MEMORY_S0_SIZE;
VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;

/*
* - PCIe RCB3 Device memory
*/
Expand All @@ -144,6 +207,15 @@ ArmPlatformGetVirtualMemoryMap (
VirtualMemoryTable[Index].Length = AC01_RCB3_DEVICE_MEMORY_S0_SIZE;
VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;

/*
* - 2P/PCIe Socket0 RCB3 32-bit Device memory
* - 1P/PCIe consolidated to RCB1 32-bit Device memory
*/
VirtualMemoryTable[++Index].PhysicalBase = AC01_RCB3_32_BIT_DEVICE_MEMORY_S0_BASE;
VirtualMemoryTable[Index].VirtualBase = AC01_RCB3_32_BIT_DEVICE_MEMORY_S0_BASE;
VirtualMemoryTable[Index].Length = AC01_RCB3_32_BIT_DEVICE_MEMORY_S0_SIZE;
VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;

if (IsSlaveSocketActive ()) {
// Slave socket exist

Expand All @@ -155,6 +227,15 @@ ArmPlatformGetVirtualMemoryMap (
VirtualMemoryTable[Index].Length = AC01_RCA0_DEVICE_MEMORY_S1_SIZE;
VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;

/*
* - 2P/PCIe Socket1 RCA0 32-bit Device memory
* - 1P/PCIe consolidated to RCA2 32-bit Device memory
*/
VirtualMemoryTable[++Index].PhysicalBase = AC01_RCA0_32_BIT_DEVICE_MEMORY_S1_BASE;
VirtualMemoryTable[Index].VirtualBase = AC01_RCA0_32_BIT_DEVICE_MEMORY_S1_BASE;
VirtualMemoryTable[Index].Length = AC01_RCA0_32_BIT_DEVICE_MEMORY_S1_SIZE;
VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;

/*
* - PCIe RCA1 Device memory
*/
Expand All @@ -163,6 +244,15 @@ ArmPlatformGetVirtualMemoryMap (
VirtualMemoryTable[Index].Length = AC01_RCA1_DEVICE_MEMORY_S1_SIZE;
VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;

/*
* - 2P/PCIe Socket1 RCA1 32-bit Device memory
* - 1P/PCIe consolidated to RCA2 32-bit Device memory
*/
VirtualMemoryTable[++Index].PhysicalBase = AC01_RCA1_32_BIT_DEVICE_MEMORY_S1_BASE;
VirtualMemoryTable[Index].VirtualBase = AC01_RCA1_32_BIT_DEVICE_MEMORY_S1_BASE;
VirtualMemoryTable[Index].Length = AC01_RCA1_32_BIT_DEVICE_MEMORY_S1_SIZE;
VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;

/*
* - PCIe RCA2 Device memory
*/
Expand All @@ -171,6 +261,15 @@ ArmPlatformGetVirtualMemoryMap (
VirtualMemoryTable[Index].Length = AC01_RCA2_DEVICE_MEMORY_S1_SIZE;
VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;

/*
* - 2P/PCIe Socket1 RCA2 32-bit Device memory
* - 1P/PCIe consolidated to RCA3 32-bit Device memory
*/
VirtualMemoryTable[++Index].PhysicalBase = AC01_RCA2_32_BIT_DEVICE_MEMORY_S1_BASE;
VirtualMemoryTable[Index].VirtualBase = AC01_RCA2_32_BIT_DEVICE_MEMORY_S1_BASE;
VirtualMemoryTable[Index].Length = AC01_RCA2_32_BIT_DEVICE_MEMORY_S1_SIZE;
VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;

/*
* - PCIe RCA3 Device memory
*/
Expand All @@ -179,6 +278,15 @@ ArmPlatformGetVirtualMemoryMap (
VirtualMemoryTable[Index].Length = AC01_RCA3_DEVICE_MEMORY_S1_SIZE;
VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;

/*
* - 2P/PCIe Socket1 RCA3 32-bit Device memory
* - 1P/PCIe consolidated to RCA3 32-bit Device memory
*/
VirtualMemoryTable[++Index].PhysicalBase = AC01_RCA3_32_BIT_DEVICE_MEMORY_S1_BASE;
VirtualMemoryTable[Index].VirtualBase = AC01_RCA3_32_BIT_DEVICE_MEMORY_S1_BASE;
VirtualMemoryTable[Index].Length = AC01_RCA3_32_BIT_DEVICE_MEMORY_S1_SIZE;
VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;

/*
* - PCIe RCB0 Device memory
*/
Expand All @@ -187,6 +295,15 @@ ArmPlatformGetVirtualMemoryMap (
VirtualMemoryTable[Index].Length = AC01_RCB0_DEVICE_MEMORY_S1_SIZE;
VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;

/*
* - 2P/PCIe Socket1 RCB0 32-bit Device memory
* - 1P/PCIe consolidated to RCA0 32-bit Device memory
*/
VirtualMemoryTable[++Index].PhysicalBase = AC01_RCB0_32_BIT_DEVICE_MEMORY_S1_BASE;
VirtualMemoryTable[Index].VirtualBase = AC01_RCB0_32_BIT_DEVICE_MEMORY_S1_BASE;
VirtualMemoryTable[Index].Length = AC01_RCB0_32_BIT_DEVICE_MEMORY_S1_SIZE;
VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;

/*
* - PCIe RCB1 Device memory
*/
Expand All @@ -195,6 +312,15 @@ ArmPlatformGetVirtualMemoryMap (
VirtualMemoryTable[Index].Length = AC01_RCB1_DEVICE_MEMORY_S1_SIZE;
VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;

/*
* - 2P/PCIe Socket1 RCB1 32-bit Device memory
* - 1P/PCIe consolidated to RCA0 32-bit Device memory
*/
VirtualMemoryTable[++Index].PhysicalBase = AC01_RCB1_32_BIT_DEVICE_MEMORY_S1_BASE;
VirtualMemoryTable[Index].VirtualBase = AC01_RCB1_32_BIT_DEVICE_MEMORY_S1_BASE;
VirtualMemoryTable[Index].Length = AC01_RCB1_32_BIT_DEVICE_MEMORY_S1_SIZE;
VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;

/*
* - PCIe RCB2 Device memory
*/
Expand All @@ -203,13 +329,31 @@ ArmPlatformGetVirtualMemoryMap (
VirtualMemoryTable[Index].Length = AC01_RCB2_DEVICE_MEMORY_S1_SIZE;
VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;

/*
* - 2P/PCIe Socket1 RCB2 32-bit Device memory
* - 1P/PCIe consolidated to RCA1 32-bit Device memory
*/
VirtualMemoryTable[++Index].PhysicalBase = AC01_RCB2_32_BIT_DEVICE_MEMORY_S1_BASE;
VirtualMemoryTable[Index].VirtualBase = AC01_RCB2_32_BIT_DEVICE_MEMORY_S1_BASE;
VirtualMemoryTable[Index].Length = AC01_RCB2_32_BIT_DEVICE_MEMORY_S1_SIZE;
VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;

/*
* - PCIe RCB3 Device memory
*/
VirtualMemoryTable[++Index].PhysicalBase = AC01_RCB3_DEVICE_MEMORY_S1_BASE;
VirtualMemoryTable[Index].VirtualBase = AC01_RCB3_DEVICE_MEMORY_S1_BASE;
VirtualMemoryTable[Index].Length = AC01_RCB3_DEVICE_MEMORY_S1_SIZE;
VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;

/*
* - 2P/PCIe Socket1 RCB3 32-bit Device memory
* - 1P/PCIe consolidated to RCA1 32-bit Device memory
*/
VirtualMemoryTable[++Index].PhysicalBase = AC01_RCB3_32_BIT_DEVICE_MEMORY_S1_BASE;
VirtualMemoryTable[Index].VirtualBase = AC01_RCB3_32_BIT_DEVICE_MEMORY_S1_BASE;
VirtualMemoryTable[Index].Length = AC01_RCB3_32_BIT_DEVICE_MEMORY_S1_SIZE;
VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
}

/*
Expand Down
Loading

0 comments on commit d3c2499

Please sign in to comment.