Hi,
I send v2 of PciEmulation + USB + SATA support. The changes from v1 are significant. The driver was adjusted to cooperate with NonDiscoverablePciDeviceDxe driver, based on: [PATCH v2 0/5] MdeModulePkg: add support for non-discoverable devices
Debug showed that the above patchset had to be modified in a minor way in order to allow XHCI and SD/MMC driver (will be sent later) to operate properly:
--- a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c +++ b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c @@ -942,7 +942,7 @@ InitializePciIoProtocol ( Dev->ConfigSpace.Hdr.ClassCode[1] = PCI_CLASS_SERIAL_USB; Dev->ConfigSpace.Hdr.ClassCode[2] = PCI_CLASS_SERIAL; Dev->BarIndex = 0; - Dev->BarSize = SIZE_2KB; + Dev->BarSize = SIZE_16KB; break;
case NonDiscoverableDeviceTypeAhci: @@ -958,7 +958,7 @@ InitializePciIoProtocol ( Dev->ConfigSpace.Hdr.ClassCode[1] = PCI_SUBCLASS_SD_HOST_CONTROLLER; Dev->ConfigSpace.Hdr.ClassCode[2] = PCI_CLASS_SYSTEM_PERIPHERAL; Dev->BarIndex = 0; - Dev->BarSize = 0x100; + Dev->BarSize = 0x300; break;
I let know about above on EDK2 mailing lists.
As a result the submitted code is greatly simplified and it allows for very flexible adding new devices (currently AHCI, XHCI, SDHCI) - only via PCD, without need of touching the driver.
NOTE: AHCI wasn't tested yet, I'm waiting for the board with the silicon revision, which is supposed to comprise quirkless AHCI IP (it should arrive in coming days).
Please let me know your opinion. Despite NonDiscoverablePciDeviceDxe is not yet in the tree, I'm looking forward to your review and remarks, so that we would be ready on OPP side for this to happen.
Best regards, Marcin
Jan Dąbroś (4): Platforms/Marvell: Enable PciEmulation driver for Armada70x0 platform Platforms/Marvell: Enable USB stack for Armada70x0 platform Platforms/Marvell: Enable two xHCI ports for Armada70x0 board Platforms/Marvell: Enable SATA stack for Armada70x0 platform
Marcin Wojtas (2): Platforms/Marvell: Add PciEmulation driver Platforms/Marvell: Enable SATA port for Armada70x0 board
.../Marvell/PortingGuide/PciEmulation.txt | 46 +++++++++ Platforms/Marvell/Armada/Armada.dsc.inc | 19 ++++ Platforms/Marvell/Armada/Armada70x0.dsc | 10 ++ Platforms/Marvell/Armada/Armada70x0.fdf | 18 ++++ Platforms/Marvell/Marvell.dec | 6 ++ Platforms/Marvell/PciEmulation/PciEmulation.c | 112 +++++++++++++++++++++ Platforms/Marvell/PciEmulation/PciEmulation.inf | 60 +++++++++++ 7 files changed, 271 insertions(+) create mode 100644 Documentation/Marvell/PortingGuide/PciEmulation.txt create mode 100644 Platforms/Marvell/PciEmulation/PciEmulation.c create mode 100644 Platforms/Marvell/PciEmulation/PciEmulation.inf
In order to use numerous UEFI drivers based on PCI bus, PciEmulation driver is implemented. It enables proper registration of platform devices as NonDiscoverableDevices and use generic EDK2 PciEmulation solution.
Configuration and setting amount of devices is enabled via PCD.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Marcin Wojtas mw@semihalf.com Signed-off-by: Jan Dabros jsd@semihalf.com --- .../Marvell/PortingGuide/PciEmulation.txt | 46 +++++++++ Platforms/Marvell/Marvell.dec | 6 ++ Platforms/Marvell/PciEmulation/PciEmulation.c | 112 +++++++++++++++++++++ Platforms/Marvell/PciEmulation/PciEmulation.inf | 60 +++++++++++ 4 files changed, 224 insertions(+) create mode 100644 Documentation/Marvell/PortingGuide/PciEmulation.txt create mode 100644 Platforms/Marvell/PciEmulation/PciEmulation.c create mode 100644 Platforms/Marvell/PciEmulation/PciEmulation.inf
diff --git a/Documentation/Marvell/PortingGuide/PciEmulation.txt b/Documentation/Marvell/PortingGuide/PciEmulation.txt new file mode 100644 index 0000000..14dc9dc --- /dev/null +++ b/Documentation/Marvell/PortingGuide/PciEmulation.txt @@ -0,0 +1,46 @@ +PciEmulation configuration +-------------------------- +Installation of various NonDiscoverable devices via PciEmulation driver is performed +via set of PCDs. Following are available: + + gMarvellTokenSpaceGuid.PcdPciEDevCount + +Indicates amount of used devices. + +Below PCD is an unicode string format, containing settings for all devices +separated with semicolon. It indicates base address of register space: + + gMarvellTokenSpaceGuid.PcdPciEDevBaseAddress + +Devices' types are represented in an array comprising hexadecimal values: + + gMarvellTokenSpaceGuid.PcdPciEDevType + +They correspond to DEV_TYPE enum: + typedef enum { + 0 DEV_XHCI, + 1 DEV_AHCI, + 2 DEV_SDHCI, + 3 DEV_MAX + } DEV_TYPE; + +Devices' DMA types are represented in an array comprising hexadecimal values: + + gMarvellTokenSpaceGuid.PcdPciEDmaType + +They correspond to DMA_TYPE enum: + typedef enum { + 0 DMA_COHERENT, + 1 DMA_NONCOHERENT, + 2 DMA_TYPE_MAX + } DMA_TYPE; + +Examples +-------- +Assuming that there are two XHCI controllers with register space starting at +0xF2500000 and 0xF2510000, with coherent DMA, following PCD values should be set: + + gMarvellTokenSpaceGuid.PcdPciEDevCount|2 + gMarvellTokenSpaceGuid.PcdPciEDevBaseAddress|L"0xF2500000;0xF2510000" + gMarvellTokenSpaceGuid.PcdPciEDevType|{ 0x0, 0x0 } + gMarvellTokenSpaceGuid.PcdPciEDmaType|{ 0x0, 0x0 } diff --git a/Platforms/Marvell/Marvell.dec b/Platforms/Marvell/Marvell.dec index db99230..13fffbb 100644 --- a/Platforms/Marvell/Marvell.dec +++ b/Platforms/Marvell/Marvell.dec @@ -209,6 +209,12 @@ gMarvellTokenSpaceGuid.PcdPp2XlgBaseAddress|0|UINT64|0x3000031 gMarvellTokenSpaceGuid.PcdPp2XlgDevSize|0|UINT32|0x3000032
+#PciEmulation + gMarvellTokenSpaceGuid.PcdPciEDevBaseAddress|{ 0x0 }|VOID*|0x30000058 + gMarvellTokenSpaceGuid.PcdPciEDevCount|0|UINT32|0x30000059 + gMarvellTokenSpaceGuid.PcdPciEDevType|{ 0x0 }|VOID*|0x3000005A + gMarvellTokenSpaceGuid.PcdPciEDmaType|{ 0x0 }|VOID*|0x3000005B + #ResetLib gMarvellTokenSpaceGuid.PcdResetRegAddress|0|UINT64|0x40000050 gMarvellTokenSpaceGuid.PcdResetRegMask|0|UINT32|0x4000051 diff --git a/Platforms/Marvell/PciEmulation/PciEmulation.c b/Platforms/Marvell/PciEmulation/PciEmulation.c new file mode 100644 index 0000000..437dec9 --- /dev/null +++ b/Platforms/Marvell/PciEmulation/PciEmulation.c @@ -0,0 +1,112 @@ +/** @file + + Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR> + Copyright (c) 2016, Marvell. All rights reserved. + + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD + License which accompanies this distribution. The full text of the license + may be found at http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include <PiDxe.h> + +#include <Library/BaseLib.h> +#include <Library/DebugLib.h> +#include <Library/IoLib.h> +#include <Library/NonDiscoverableDeviceRegistrationLib.h> +#include <Library/ParsePcdLib.h> +#include <Library/UefiBootServicesTableLib.h> + +#include <Protocol/EmbeddedExternalDevice.h> + +typedef enum { + DEV_XHCI, + DEV_AHCI, + DEV_SDHCI, + DEV_MAX +} DEV_TYPE; + +typedef enum { + DMA_COHERENT, + DMA_NONCOHERENT, + DMA_TYPE_MAX, +} DMA_TYPE; + +// +// Below function is used to parse devices information from PCD strings. +// Once obtained, the resources are used for registration of +// NonDiscoverable devices. +// +EFI_STATUS +EFIAPI +PciEmulationEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + UINT8 i; + UINT8 DevCount = PcdGet32 (PcdPciEDevCount); + UINT8 *DeviceType = PcdGetPtr (PcdPciEDevType); + UINT8 *DmaType = PcdGetPtr (PcdPciEDmaType); + UINTN BaseAddrTable[PcdGet32 (PcdPciEDevCount)]; + NON_DISCOVERABLE_DEVICE_TYPE DeviceTypeTable[PcdGet32 (PcdPciEDevCount)]; + NON_DISCOVERABLE_DEVICE_DMA_TYPE DmaTypeTable[PcdGet32 (PcdPciEDevCount)]; + + ASSERT (PcdGetSize (PcdPciEDevType) == DevCount); + ASSERT (PcdGetSize (PcdPciEDmaType) == DevCount); + + Status = ParsePcdString ((CHAR16 *) PcdGetPtr (PcdPciEDevBaseAddress), DevCount, BaseAddrTable, NULL); + if (EFI_ERROR(Status)) { + DEBUG((DEBUG_ERROR, "PciEmulation: Wrong PcdPciEDevBaseAddress format\n")); + return EFI_INVALID_PARAMETER; + } + + for (i = 0; i < DevCount; i++) { + switch (DeviceType[i]) { + case DEV_XHCI: + DeviceTypeTable[i] = NonDiscoverableDeviceTypeXhci; + break; + case DEV_AHCI: + DeviceTypeTable[i] = NonDiscoverableDeviceTypeAhci; + break; + case DEV_SDHCI: + DeviceTypeTable[i] = NonDiscoverableDeviceTypeSdhci; + break; + default: + DEBUG((DEBUG_ERROR, "PciEmulation: Unsupported device type with ID=%d\n", i)); + return EFI_INVALID_PARAMETER; + } + + switch (DmaType[i]) { + case DMA_COHERENT: + DmaTypeTable[i] = NonDiscoverableDeviceDmaTypeCoherent; + break; + case DMA_NONCOHERENT: + DmaTypeTable[i] = NonDiscoverableDeviceDmaTypeNonCoherent; + break; + default: + DEBUG((DEBUG_ERROR, "PciEmulation: Unsupported DMA type with ID=%d\n", i)); + return EFI_INVALID_PARAMETER; + } + + Status = RegisterNonDiscoverableDevice ( + BaseAddrTable[i], + DeviceTypeTable[i], + DmaTypeTable[i], + NULL, + NULL + ); + + if (EFI_ERROR(Status)) { + DEBUG((DEBUG_ERROR, "PciEmulation: Cannot install device with ID=%d\n", i)); + } + } + + return Status; +} diff --git a/Platforms/Marvell/PciEmulation/PciEmulation.inf b/Platforms/Marvell/PciEmulation/PciEmulation.inf new file mode 100644 index 0000000..9021d1e --- /dev/null +++ b/Platforms/Marvell/PciEmulation/PciEmulation.inf @@ -0,0 +1,60 @@ +/** @file + + Copyright (c) 2009, Apple Inc. All rights reserved.<BR> + Copyright (c) 2016, Marvell. All rights reserved. + + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD + License which accompanies this distribution. The full text of the license may + be found at http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +[Defines] + INF_VERSION = 0x00010019 + BASE_NAME = PciEmulation + FILE_GUID = 3dfa08da-923b-4841-9435-c77a604d7493 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + + ENTRY_POINT = PciEmulationEntryPoint + +[Sources.common] + PciEmulation.c + +[Packages] + ArmPkg/ArmPkg.dec + EmbeddedPkg/EmbeddedPkg.dec + IntelFrameworkPkg/IntelFrameworkPkg.dec + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + OpenPlatformPkg/Platforms/Marvell/Marvell.dec + ShellPkg/ShellPkg.dec + +[LibraryClasses] + BaseLib + DebugLib + IoLib + NonDiscoverableDeviceRegistrationLib + ParsePcdLib + UefiBootServicesTableLib + UefiDriverEntryPoint + +[Protocols] + gEfiDevicePathProtocolGuid + gEfiPciHostBridgeResourceAllocationProtocolGuid + gEfiPciIoProtocolGuid + gEfiPciRootBridgeIoProtocolGuid + gEmbeddedExternalDeviceProtocolGuid + +[Pcd] + gMarvellTokenSpaceGuid.PcdPciEDevBaseAddress + gMarvellTokenSpaceGuid.PcdPciEDevCount + gMarvellTokenSpaceGuid.PcdPciEDevType + gMarvellTokenSpaceGuid.PcdPciEDmaType + +[Depex] + TRUE
On 15 November 2016 at 03:15, Marcin Wojtas mw@semihalf.com wrote:
In order to use numerous UEFI drivers based on PCI bus, PciEmulation driver is implemented. It enables proper registration of platform devices as NonDiscoverableDevices and use generic EDK2 PciEmulation solution.
Configuration and setting amount of devices is enabled via PCD.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Marcin Wojtas mw@semihalf.com Signed-off-by: Jan Dabros jsd@semihalf.com
.../Marvell/PortingGuide/PciEmulation.txt | 46 +++++++++ Platforms/Marvell/Marvell.dec | 6 ++ Platforms/Marvell/PciEmulation/PciEmulation.c | 112 +++++++++++++++++++++ Platforms/Marvell/PciEmulation/PciEmulation.inf | 60 +++++++++++ 4 files changed, 224 insertions(+) create mode 100644 Documentation/Marvell/PortingGuide/PciEmulation.txt create mode 100644 Platforms/Marvell/PciEmulation/PciEmulation.c create mode 100644 Platforms/Marvell/PciEmulation/PciEmulation.inf
diff --git a/Documentation/Marvell/PortingGuide/PciEmulation.txt b/Documentation/Marvell/PortingGuide/PciEmulation.txt new file mode 100644 index 0000000..14dc9dc --- /dev/null +++ b/Documentation/Marvell/PortingGuide/PciEmulation.txt @@ -0,0 +1,46 @@ +PciEmulation configuration +-------------------------- +Installation of various NonDiscoverable devices via PciEmulation driver is performed +via set of PCDs. Following are available:
- gMarvellTokenSpaceGuid.PcdPciEDevCount
+Indicates amount of used devices.
+Below PCD is an unicode string format, containing settings for all devices +separated with semicolon. It indicates base address of register space:
- gMarvellTokenSpaceGuid.PcdPciEDevBaseAddress
+Devices' types are represented in an array comprising hexadecimal values:
- gMarvellTokenSpaceGuid.PcdPciEDevType
+They correspond to DEV_TYPE enum:
- typedef enum {
- 0 DEV_XHCI,
- 1 DEV_AHCI,
- 2 DEV_SDHCI,
- 3 DEV_MAX
- } DEV_TYPE;
+Devices' DMA types are represented in an array comprising hexadecimal values:
- gMarvellTokenSpaceGuid.PcdPciEDmaType
+They correspond to DMA_TYPE enum:
- typedef enum {
- 0 DMA_COHERENT,
- 1 DMA_NONCOHERENT,
- 2 DMA_TYPE_MAX
- } DMA_TYPE;
+Examples +-------- +Assuming that there are two XHCI controllers with register space starting at +0xF2500000 and 0xF2510000, with coherent DMA, following PCD values should be set:
- gMarvellTokenSpaceGuid.PcdPciEDevCount|2
- gMarvellTokenSpaceGuid.PcdPciEDevBaseAddress|L"0xF2500000;0xF2510000"
- gMarvellTokenSpaceGuid.PcdPciEDevType|{ 0x0, 0x0 }
- gMarvellTokenSpaceGuid.PcdPciEDmaType|{ 0x0, 0x0 }
diff --git a/Platforms/Marvell/Marvell.dec b/Platforms/Marvell/Marvell.dec index db99230..13fffbb 100644 --- a/Platforms/Marvell/Marvell.dec +++ b/Platforms/Marvell/Marvell.dec @@ -209,6 +209,12 @@ gMarvellTokenSpaceGuid.PcdPp2XlgBaseAddress|0|UINT64|0x3000031 gMarvellTokenSpaceGuid.PcdPp2XlgDevSize|0|UINT32|0x3000032
+#PciEmulation
- gMarvellTokenSpaceGuid.PcdPciEDevBaseAddress|{ 0x0 }|VOID*|0x30000058
- gMarvellTokenSpaceGuid.PcdPciEDevCount|0|UINT32|0x30000059
- gMarvellTokenSpaceGuid.PcdPciEDevType|{ 0x0 }|VOID*|0x3000005A
- gMarvellTokenSpaceGuid.PcdPciEDmaType|{ 0x0 }|VOID*|0x3000005B
#ResetLib gMarvellTokenSpaceGuid.PcdResetRegAddress|0|UINT64|0x40000050 gMarvellTokenSpaceGuid.PcdResetRegMask|0|UINT32|0x4000051 diff --git a/Platforms/Marvell/PciEmulation/PciEmulation.c b/Platforms/Marvell/PciEmulation/PciEmulation.c new file mode 100644 index 0000000..437dec9 --- /dev/null +++ b/Platforms/Marvell/PciEmulation/PciEmulation.c @@ -0,0 +1,112 @@ +/** @file
- Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
- Copyright (c) 2016, Marvell. All rights reserved.
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD
- License which accompanies this distribution. The full text of the license
- may be found at http://opensource.org/licenses/bsd-license.php
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+**/
+#include <PiDxe.h>
+#include <Library/BaseLib.h> +#include <Library/DebugLib.h> +#include <Library/IoLib.h> +#include <Library/NonDiscoverableDeviceRegistrationLib.h> +#include <Library/ParsePcdLib.h> +#include <Library/UefiBootServicesTableLib.h>
+#include <Protocol/EmbeddedExternalDevice.h>
+typedef enum {
- DEV_XHCI,
- DEV_AHCI,
- DEV_SDHCI,
- DEV_MAX
+} DEV_TYPE;
+typedef enum {
- DMA_COHERENT,
- DMA_NONCOHERENT,
- DMA_TYPE_MAX,
+} DMA_TYPE;
+// +// Below function is used to parse devices information from PCD strings. +// Once obtained, the resources are used for registration of +// NonDiscoverable devices. +// +EFI_STATUS +EFIAPI +PciEmulationEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
+{
- EFI_STATUS Status;
- UINT8 i;
- UINT8 DevCount = PcdGet32 (PcdPciEDevCount);
- UINT8 *DeviceType = PcdGetPtr (PcdPciEDevType);
- UINT8 *DmaType = PcdGetPtr (PcdPciEDmaType);
Please get rid of these initializers, and use ordinary assignments.
- UINTN BaseAddrTable[PcdGet32 (PcdPciEDevCount)];
- NON_DISCOVERABLE_DEVICE_TYPE DeviceTypeTable[PcdGet32 (PcdPciEDevCount)];
- NON_DISCOVERABLE_DEVICE_DMA_TYPE DmaTypeTable[PcdGet32 (PcdPciEDevCount)];
- ASSERT (PcdGetSize (PcdPciEDevType) == DevCount);
- ASSERT (PcdGetSize (PcdPciEDmaType) == DevCount);
If you are allowing dynamic PCDs for these values, these should not be asserts but runtime errors.
So either switch to FixedPcdGetXXX everywhere (and use a [FixedPcd] section in the .inf), or return an error here if the PCDs are not of the expected format (Note that ASSERT()s are compiled out in RELEASE mode). Note that that would also allow you to move DevCount/*DeviceType/*DmaType out of the function, and keep the static initializers.
- Status = ParsePcdString ((CHAR16 *) PcdGetPtr (PcdPciEDevBaseAddress), DevCount, BaseAddrTable, NULL);
- if (EFI_ERROR(Status)) {
- DEBUG((DEBUG_ERROR, "PciEmulation: Wrong PcdPciEDevBaseAddress format\n"));
- return EFI_INVALID_PARAMETER;
- }
- for (i = 0; i < DevCount; i++) {
- switch (DeviceType[i]) {
- case DEV_XHCI:
DeviceTypeTable[i] = NonDiscoverableDeviceTypeXhci;
break;
- case DEV_AHCI:
DeviceTypeTable[i] = NonDiscoverableDeviceTypeAhci;
break;
- case DEV_SDHCI:
DeviceTypeTable[i] = NonDiscoverableDeviceTypeSdhci;
break;
- default:
DEBUG((DEBUG_ERROR, "PciEmulation: Unsupported device type with ID=%d\n", i));
return EFI_INVALID_PARAMETER;
- }
- switch (DmaType[i]) {
- case DMA_COHERENT:
DmaTypeTable[i] = NonDiscoverableDeviceDmaTypeCoherent;
break;
- case DMA_NONCOHERENT:
DmaTypeTable[i] = NonDiscoverableDeviceDmaTypeNonCoherent;
break;
- default:
DEBUG((DEBUG_ERROR, "PciEmulation: Unsupported DMA type with ID=%d\n", i));
return EFI_INVALID_PARAMETER;
- }
- Status = RegisterNonDiscoverableDevice (
BaseAddrTable[i],
DeviceTypeTable[i],
DmaTypeTable[i],
NULL,
NULL
);
- if (EFI_ERROR(Status)) {
DEBUG((DEBUG_ERROR, "PciEmulation: Cannot install device with ID=%d\n", i));
- }
- }
- return Status;
You are ignoring failures (except for printing a DEBUG message) so you should return EFI_SUCCESS here. Otherwise, the return value depends only on the last registered device, which is odd.
+} diff --git a/Platforms/Marvell/PciEmulation/PciEmulation.inf b/Platforms/Marvell/PciEmulation/PciEmulation.inf new file mode 100644 index 0000000..9021d1e --- /dev/null +++ b/Platforms/Marvell/PciEmulation/PciEmulation.inf @@ -0,0 +1,60 @@ +/** @file
- Copyright (c) 2009, Apple Inc. All rights reserved.<BR>
- Copyright (c) 2016, Marvell. All rights reserved.
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD
- License which accompanies this distribution. The full text of the license may
- be found at http://opensource.org/licenses/bsd-license.php
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+**/
+[Defines]
- INF_VERSION = 0x00010019
- BASE_NAME = PciEmulation
- FILE_GUID = 3dfa08da-923b-4841-9435-c77a604d7493
- MODULE_TYPE = DXE_DRIVER
- VERSION_STRING = 1.0
- ENTRY_POINT = PciEmulationEntryPoint
+[Sources.common]
- PciEmulation.c
+[Packages]
- ArmPkg/ArmPkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
- IntelFrameworkPkg/IntelFrameworkPkg.dec
- MdeModulePkg/MdeModulePkg.dec
- MdePkg/MdePkg.dec
- OpenPlatformPkg/Platforms/Marvell/Marvell.dec
- ShellPkg/ShellPkg.dec
Do we really need all of these?
+[LibraryClasses]
- BaseLib
- DebugLib
- IoLib
- NonDiscoverableDeviceRegistrationLib
- ParsePcdLib
- UefiBootServicesTableLib
- UefiDriverEntryPoint
Same here
+[Protocols]
- gEfiDevicePathProtocolGuid
- gEfiPciHostBridgeResourceAllocationProtocolGuid
- gEfiPciIoProtocolGuid
- gEfiPciRootBridgeIoProtocolGuid
- gEmbeddedExternalDeviceProtocolGuid
+[Pcd]
- gMarvellTokenSpaceGuid.PcdPciEDevBaseAddress
- gMarvellTokenSpaceGuid.PcdPciEDevCount
- gMarvellTokenSpaceGuid.PcdPciEDevType
- gMarvellTokenSpaceGuid.PcdPciEDmaType
+[Depex]
- TRUE
-- 1.8.3.1
From: Jan Dąbroś jsd@semihalf.com
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jan Dabros jsd@semihalf.com Signed-off-by: Marcin Wojtas mw@semihalf.com --- Platforms/Marvell/Armada/Armada.dsc.inc | 4 ++++ Platforms/Marvell/Armada/Armada70x0.fdf | 4 ++++ 2 files changed, 8 insertions(+)
diff --git a/Platforms/Marvell/Armada/Armada.dsc.inc b/Platforms/Marvell/Armada/Armada.dsc.inc index 76c5d6d..3ebee0d 100644 --- a/Platforms/Marvell/Armada/Armada.dsc.inc +++ b/Platforms/Marvell/Armada/Armada.dsc.inc @@ -170,6 +170,7 @@ SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf + NonDiscoverableDeviceRegistrationLib|MdeModulePkg/Library/NonDiscoverableDeviceRegistrationLib/NonDiscoverableDeviceRegistrationLib.inf
[LibraryClasses.common.UEFI_APPLICATION] UefiDecompressLib|IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.inf @@ -417,6 +418,9 @@ EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf
+ OpenPlatformPkg/Platforms/Marvell/PciEmulation/PciEmulation.inf + MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.inf + # Console packages MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf diff --git a/Platforms/Marvell/Armada/Armada70x0.fdf b/Platforms/Marvell/Armada/Armada70x0.fdf index 64c3440..2403b71 100644 --- a/Platforms/Marvell/Armada/Armada70x0.fdf +++ b/Platforms/Marvell/Armada/Armada70x0.fdf @@ -123,6 +123,10 @@ FvNameGuid = 5eda4200-2c5f-43cb-9da3-0baf74b1b30c INF OpenPlatformPkg/Drivers/Net/Phy/MvPhyDxe/MvPhyDxe.inf INF OpenPlatformPkg/Drivers/Net/Pp2Dxe/Pp2Dxe.inf
+ # PciEmulation + INF OpenPlatformPkg/Platforms/Marvell/PciEmulation/PciEmulation.inf + INF MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.inf + # Multiple Console IO support INF MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf INF MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf
From: Jan Dąbroś jsd@semihalf.com
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jan Dabros jsd@semihalf.com Signed-off-by: Marcin Wojtas mw@semihalf.com --- Platforms/Marvell/Armada/Armada.dsc.inc | 5 +++++ Platforms/Marvell/Armada/Armada70x0.fdf | 5 +++++ 2 files changed, 10 insertions(+)
diff --git a/Platforms/Marvell/Armada/Armada.dsc.inc b/Platforms/Marvell/Armada/Armada.dsc.inc index 3ebee0d..470cf81 100644 --- a/Platforms/Marvell/Armada/Armada.dsc.inc +++ b/Platforms/Marvell/Armada/Armada.dsc.inc @@ -421,6 +421,11 @@ OpenPlatformPkg/Platforms/Marvell/PciEmulation/PciEmulation.inf MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.inf
+ # USB + MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf + MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf + MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf + # Console packages MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf diff --git a/Platforms/Marvell/Armada/Armada70x0.fdf b/Platforms/Marvell/Armada/Armada70x0.fdf index 2403b71..2c4f833 100644 --- a/Platforms/Marvell/Armada/Armada70x0.fdf +++ b/Platforms/Marvell/Armada/Armada70x0.fdf @@ -127,6 +127,11 @@ FvNameGuid = 5eda4200-2c5f-43cb-9da3-0baf74b1b30c INF OpenPlatformPkg/Platforms/Marvell/PciEmulation/PciEmulation.inf INF MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.inf
+ # USB + INF MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf + INF MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf + INF MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf + # Multiple Console IO support INF MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf INF MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf
From: Jan Dąbroś jsd@semihalf.com
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jan Dabros jsd@semihalf.com Signed-off-by: Marcin Wojtas mw@semihalf.com --- Platforms/Marvell/Armada/Armada70x0.dsc | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/Platforms/Marvell/Armada/Armada70x0.dsc b/Platforms/Marvell/Armada/Armada70x0.dsc index 2f2b278..5e07161 100644 --- a/Platforms/Marvell/Armada/Armada70x0.dsc +++ b/Platforms/Marvell/Armada/Armada70x0.dsc @@ -139,6 +139,13 @@ gMarvellTokenSpaceGuid.PcdPp2XlgBaseAddress|0xf2130f00 gMarvellTokenSpaceGuid.PcdPp2XlgDevSize|0x1000
+ #PciEmulation + gMarvellTokenSpaceGuid.PcdPciEDevCount|2 + ## XHCI1 XHCI2 + gMarvellTokenSpaceGuid.PcdPciEDevBaseAddress|L"0xF2500000;0xF2510000" + gMarvellTokenSpaceGuid.PcdPciEDevType|{ 0x0, 0x0 } + gMarvellTokenSpaceGuid.PcdPciEDmaType|{ 0x0, 0x0 } + #ResetLib gMarvellTokenSpaceGuid.PcdResetRegAddress|0xf06f0084 gMarvellTokenSpaceGuid.PcdResetRegMask|0x1
From: Jan Dąbroś jsd@semihalf.com
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jan Dabros jsd@semihalf.com Signed-off-by: Marcin Wojtas mw@semihalf.com --- Platforms/Marvell/Armada/Armada.dsc.inc | 10 ++++++++++ Platforms/Marvell/Armada/Armada70x0.fdf | 9 +++++++++ 2 files changed, 19 insertions(+)
diff --git a/Platforms/Marvell/Armada/Armada.dsc.inc b/Platforms/Marvell/Armada/Armada.dsc.inc index 470cf81..0b1c50d 100644 --- a/Platforms/Marvell/Armada/Armada.dsc.inc +++ b/Platforms/Marvell/Armada/Armada.dsc.inc @@ -82,6 +82,7 @@ ArmPlatformStackLib|ArmPlatformPkg/Library/ArmPlatformStackLib/ArmPlatformStackLib.inf ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf + UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf
# Serial port libraries SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf @@ -421,6 +422,15 @@ OpenPlatformPkg/Platforms/Marvell/PciEmulation/PciEmulation.inf MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.inf
+ # SCSI + MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf + MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf + + # SATA + MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf + MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf + OvmfPkg/SataControllerDxe/SataControllerDxe.inf + # USB MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf diff --git a/Platforms/Marvell/Armada/Armada70x0.fdf b/Platforms/Marvell/Armada/Armada70x0.fdf index 2c4f833..b420153 100644 --- a/Platforms/Marvell/Armada/Armada70x0.fdf +++ b/Platforms/Marvell/Armada/Armada70x0.fdf @@ -127,6 +127,15 @@ FvNameGuid = 5eda4200-2c5f-43cb-9da3-0baf74b1b30c INF OpenPlatformPkg/Platforms/Marvell/PciEmulation/PciEmulation.inf INF MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.inf
+ # SCSI + INF MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf + INF MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf + + # SATA + INF MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf + INF MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf + INF OvmfPkg/SataControllerDxe/SataControllerDxe.inf + # USB INF MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf INF MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jan Dabros jsd@semihalf.com Signed-off-by: Marcin Wojtas mw@semihalf.com --- Platforms/Marvell/Armada/Armada70x0.dsc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/Platforms/Marvell/Armada/Armada70x0.dsc b/Platforms/Marvell/Armada/Armada70x0.dsc index 5e07161..60a86a0 100644 --- a/Platforms/Marvell/Armada/Armada70x0.dsc +++ b/Platforms/Marvell/Armada/Armada70x0.dsc @@ -140,12 +140,15 @@ gMarvellTokenSpaceGuid.PcdPp2XlgDevSize|0x1000
#PciEmulation - gMarvellTokenSpaceGuid.PcdPciEDevCount|2 - ## XHCI1 XHCI2 - gMarvellTokenSpaceGuid.PcdPciEDevBaseAddress|L"0xF2500000;0xF2510000" - gMarvellTokenSpaceGuid.PcdPciEDevType|{ 0x0, 0x0 } - gMarvellTokenSpaceGuid.PcdPciEDmaType|{ 0x0, 0x0 } + gMarvellTokenSpaceGuid.PcdPciEDevCount|3 + ## XHCI1 XHCI2 SATA + gMarvellTokenSpaceGuid.PcdPciEDevBaseAddress|L"0xF2500000;0xF2510000;0xF2540000" + gMarvellTokenSpaceGuid.PcdPciEDevType|{ 0x0, 0x0, 0x1 } + gMarvellTokenSpaceGuid.PcdPciEDmaType|{ 0x0, 0x0, 0x0 }
#ResetLib gMarvellTokenSpaceGuid.PcdResetRegAddress|0xf06f0084 gMarvellTokenSpaceGuid.PcdResetRegMask|0x1 + + #SATA + gMarvellTokenSpaceGuid.PcdSataBaseAddress|0xF2540000
Hi Marcin,
On 15 November 2016 at 03:15, Marcin Wojtas mw@semihalf.com wrote:
Hi,
I send v2 of PciEmulation + USB + SATA support. The changes from v1 are significant. The driver was adjusted to cooperate with NonDiscoverablePciDeviceDxe driver, based on: [PATCH v2 0/5] MdeModulePkg: add support for non-discoverable devices
Debug showed that the above patchset had to be modified in a minor way in order to allow XHCI and SD/MMC driver (will be sent later) to operate properly:
a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c +++ b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c @@ -942,7 +942,7 @@ InitializePciIoProtocol ( Dev->ConfigSpace.Hdr.ClassCode[1] = PCI_CLASS_SERIAL_USB; Dev->ConfigSpace.Hdr.ClassCode[2] = PCI_CLASS_SERIAL; Dev->BarIndex = 0;
- Dev->BarSize = SIZE_2KB;
Dev->BarSize = SIZE_16KB; break;
case NonDiscoverableDeviceTypeAhci:
@@ -958,7 +958,7 @@ InitializePciIoProtocol ( Dev->ConfigSpace.Hdr.ClassCode[1] = PCI_SUBCLASS_SD_HOST_CONTROLLER; Dev->ConfigSpace.Hdr.ClassCode[2] = PCI_CLASS_SYSTEM_PERIPHERAL; Dev->BarIndex = 0;
- Dev->BarSize = 0x100;
- Dev->BarSize = 0x300; break;
I let know about above on EDK2 mailing lists.
Thanks. I will add these changes when I spin the next version.
As a result the submitted code is greatly simplified and it allows for very flexible adding new devices (currently AHCI, XHCI, SDHCI) - only via PCD, without need of touching the driver.
NOTE: AHCI wasn't tested yet, I'm waiting for the board with the silicon revision, which is supposed to comprise quirkless AHCI IP (it should arrive in coming days).
Please let me know your opinion. Despite NonDiscoverablePciDeviceDxe is not yet in the tree, I'm looking forward to your review and remarks, so that we would be ready on OPP side for this to happen.
Hi Ard,
Thanks. I also wrote my remark about AHCI. I hope my comments will do some backing for the solution and it gets faster to the tree. Anyway, do you have any comments to our patchset?
Best regards, Marcin
2016-11-15 12:20 GMT+01:00 Ard Biesheuvel ard.biesheuvel@linaro.org:
Hi Marcin,
On 15 November 2016 at 03:15, Marcin Wojtas mw@semihalf.com wrote:
Hi,
I send v2 of PciEmulation + USB + SATA support. The changes from v1 are significant. The driver was adjusted to cooperate with NonDiscoverablePciDeviceDxe driver, based on: [PATCH v2 0/5] MdeModulePkg: add support for non-discoverable devices
Debug showed that the above patchset had to be modified in a minor way in order to allow XHCI and SD/MMC driver (will be sent later) to operate properly:
a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c +++ b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c @@ -942,7 +942,7 @@ InitializePciIoProtocol ( Dev->ConfigSpace.Hdr.ClassCode[1] = PCI_CLASS_SERIAL_USB; Dev->ConfigSpace.Hdr.ClassCode[2] = PCI_CLASS_SERIAL; Dev->BarIndex = 0;
- Dev->BarSize = SIZE_2KB;
Dev->BarSize = SIZE_16KB; break;
case NonDiscoverableDeviceTypeAhci:
@@ -958,7 +958,7 @@ InitializePciIoProtocol ( Dev->ConfigSpace.Hdr.ClassCode[1] = PCI_SUBCLASS_SD_HOST_CONTROLLER; Dev->ConfigSpace.Hdr.ClassCode[2] = PCI_CLASS_SYSTEM_PERIPHERAL; Dev->BarIndex = 0;
- Dev->BarSize = 0x100;
- Dev->BarSize = 0x300; break;
I let know about above on EDK2 mailing lists.
Thanks. I will add these changes when I spin the next version.
As a result the submitted code is greatly simplified and it allows for very flexible adding new devices (currently AHCI, XHCI, SDHCI) - only via PCD, without need of touching the driver.
NOTE: AHCI wasn't tested yet, I'm waiting for the board with the silicon revision, which is supposed to comprise quirkless AHCI IP (it should arrive in coming days).
Please let me know your opinion. Despite NonDiscoverablePciDeviceDxe is not yet in the tree, I'm looking forward to your review and remarks, so that we would be ready on OPP side for this to happen.
On 15 November 2016 at 12:03, Marcin Wojtas mw@semihalf.com wrote:
Hi Ard,
Thanks. I also wrote my remark about AHCI. I hope my comments will do some backing for the solution and it gets faster to the tree. Anyway, do you have any comments to our patchset?
I'm happy with patches 2 - 6
Reviewed-by: Ard Biesheuvel ard.biesheuvel@linaro.org
I have commented on patch 1
Thanks, Ard.
2016-11-15 14:02 GMT+01:00 Ard Biesheuvel ard.biesheuvel@linaro.org:
On 15 November 2016 at 12:03, Marcin Wojtas mw@semihalf.com wrote:
Hi Ard,
Thanks. I also wrote my remark about AHCI. I hope my comments will do some backing for the solution and it gets faster to the tree. Anyway, do you have any comments to our patchset?
I'm happy with patches 2 - 6
Reviewed-by: Ard Biesheuvel ard.biesheuvel@linaro.org
I have commented on patch 1
Thanks a lot, I'll push v3 asap.
Best regards, Marcin