[edk2-platforms][PATCH V1 03/11] Platform/ARM/Morello: Add PlatformDxe for Morello SoC


chandni cherukuri
 

This patch adds PlatformDxe support for Morello SoC platform.
It includes the registration of ramdisk device.

Signed-off-by: Chandni Cherukuri <chandni.cherukuri@arm.com>
---
Platform/ARM/Morello/Drivers/PlatformDxe/PlatformDxeSoc.inf | 43 +++++++++++++
Platform/ARM/Morello/Drivers/PlatformDxe/PlatformDxeSoc.c | 67 ++++++++++++++++++++
2 files changed, 110 insertions(+)

diff --git a/Platform/ARM/Morello/Drivers/PlatformDxe/PlatformDxeSoc.inf b/Platform/ARM/Morello/Drivers/PlatformDxe/PlatformDxeSoc.inf
new file mode 100644
index 000000000000..a5d8ac36a3f2
--- /dev/null
+++ b/Platform/ARM/Morello/Drivers/PlatformDxe/PlatformDxeSoc.inf
@@ -0,0 +1,43 @@
+## @file
+# Platform DXE driver for Morello SoC Platform
+#
+# Copyright (c) 2021, ARM Limited. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x0001001B
+ BASE_NAME = PlatformDxe
+ FILE_GUID = D75DB98F-5750-47C8-A46F-3140965537FC
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ ENTRY_POINT = ArmMorelloEntryPoint
+
+[Sources.common]
+ PlatformDxeSoc.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ OvmfPkg/OvmfPkg.dec
+ Platform/ARM/Morello/MorelloPlatform.dec
+
+[LibraryClasses]
+ UefiDriverEntryPoint
+
+[Protocols]
+ gEfiRamDiskProtocolGuid
+
+[FeaturePcd]
+ gArmMorelloTokenSpaceGuid.PcdRamDiskSupported
+
+[FixedPcd]
+ gArmMorelloTokenSpaceGuid.PcdRamDiskBase
+ gArmMorelloTokenSpaceGuid.PcdRamDiskSize
+
+[Depex]
+ gEfiRamDiskProtocolGuid
+
+[Guids]
+ gEfiVirtualCdGuid ## SOMETIMES_CONSUMES ## GUID
diff --git a/Platform/ARM/Morello/Drivers/PlatformDxe/PlatformDxeSoc.c b/Platform/ARM/Morello/Drivers/PlatformDxe/PlatformDxeSoc.c
new file mode 100644
index 000000000000..358c80acc7ee
--- /dev/null
+++ b/Platform/ARM/Morello/Drivers/PlatformDxe/PlatformDxeSoc.c
@@ -0,0 +1,67 @@
+/** @file
+
+ Copyright (c) 2021, ARM Limited. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include <Library/DebugLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Protocol/RamDisk.h>
+
+/**
+ Entrypoint of Platform Dxe Driver
+
+ @param ImageHandle[in] The firmware allocated handle for the EFI image.
+ @param SystemTable[in] A pointer to the EFI System Table.
+
+ @retval EFI_SUCCESS The entry point is executed successfully.
+**/
+EFI_STATUS
+EFIAPI
+ArmMorelloEntryPoint (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+ EFI_RAM_DISK_PROTOCOL *RamDisk;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+
+ Status = EFI_SUCCESS;
+
+ if (FeaturePcdGet (PcdRamDiskSupported)) {
+ Status = gBS->LocateProtocol (
+ &gEfiRamDiskProtocolGuid,
+ NULL,
+ (VOID **)&RamDisk
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((
+ DEBUG_ERROR,
+ "Couldn't find the RAM Disk protocol %r\n",
+ __FUNCTION__,
+ Status
+ ));
+ return Status;
+ }
+
+ Status = RamDisk->Register (
+ (UINTN)PcdGet32 (PcdRamDiskBase),
+ (UINTN)PcdGet32 (PcdRamDiskSize),
+ &gEfiVirtualCdGuid,
+ NULL,
+ &DevicePath
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: Failed to register RAM Disk - %r\n",
+ __FUNCTION__,
+ Status
+ ));
+ }
+ }
+
+ return Status;
+}
--
2.17.1


Sami Mujawar
 

Hi Chandni,

Please find my feedback inline marked [SAMI].

With that fixed,

Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>

Regards,

Sami Mujawar

On 04/12/2021 12:30 PM, Chandni Cherukuri wrote:
This patch adds PlatformDxe support for Morello SoC platform.
It includes the registration of ramdisk device.

Signed-off-by: Chandni Cherukuri <chandni.cherukuri@arm.com>
---
Platform/ARM/Morello/Drivers/PlatformDxe/PlatformDxeSoc.inf | 43 +++++++++++++
Platform/ARM/Morello/Drivers/PlatformDxe/PlatformDxeSoc.c | 67 ++++++++++++++++++++
2 files changed, 110 insertions(+)

diff --git a/Platform/ARM/Morello/Drivers/PlatformDxe/PlatformDxeSoc.inf b/Platform/ARM/Morello/Drivers/PlatformDxe/PlatformDxeSoc.inf
new file mode 100644
index 000000000000..a5d8ac36a3f2
--- /dev/null
+++ b/Platform/ARM/Morello/Drivers/PlatformDxe/PlatformDxeSoc.inf
@@ -0,0 +1,43 @@
+## @file
+# Platform DXE driver for Morello SoC Platform
+#
+# Copyright (c) 2021, ARM Limited. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x0001001B
+ BASE_NAME = PlatformDxe
+ FILE_GUID = D75DB98F-5750-47C8-A46F-3140965537FC
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ ENTRY_POINT = ArmMorelloEntryPoint
+
+[Sources.common]
+ PlatformDxeSoc.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ OvmfPkg/OvmfPkg.dec
+ Platform/ARM/Morello/MorelloPlatform.dec
+
+[LibraryClasses]
+ UefiDriverEntryPoint
+
+[Protocols]
+ gEfiRamDiskProtocolGuid
+
+[FeaturePcd]
+ gArmMorelloTokenSpaceGuid.PcdRamDiskSupported
+
+[FixedPcd]
+ gArmMorelloTokenSpaceGuid.PcdRamDiskBase
+ gArmMorelloTokenSpaceGuid.PcdRamDiskSize
+
+[Depex]
+ gEfiRamDiskProtocolGuid
+
+[Guids]
+ gEfiVirtualCdGuid ## SOMETIMES_CONSUMES ## GUID
diff --git a/Platform/ARM/Morello/Drivers/PlatformDxe/PlatformDxeSoc.c b/Platform/ARM/Morello/Drivers/PlatformDxe/PlatformDxeSoc.c
new file mode 100644
index 000000000000..358c80acc7ee
--- /dev/null
+++ b/Platform/ARM/Morello/Drivers/PlatformDxe/PlatformDxeSoc.c
@@ -0,0 +1,67 @@
+/** @file
+
+ Copyright (c) 2021, ARM Limited. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include <Library/DebugLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Protocol/RamDisk.h>
+
+/**
+ Entrypoint of Platform Dxe Driver
+
+ @param ImageHandle[in] The firmware allocated handle for the EFI image.
+ @param SystemTable[in] A pointer to the EFI System Table.
+
+ @retval EFI_SUCCESS The entry point is executed successfully.
+**/
+EFI_STATUS
+EFIAPI
+ArmMorelloEntryPoint (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+ EFI_RAM_DISK_PROTOCOL *RamDisk;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+
+ Status = EFI_SUCCESS;
+
+ if (FeaturePcdGet (PcdRamDiskSupported)) {
+ Status = gBS->LocateProtocol (
+ &gEfiRamDiskProtocolGuid,
+ NULL,
+ (VOID **)&RamDisk
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((
+ DEBUG_ERROR,
+ "Couldn't find the RAM Disk protocol %r\n",
[SAMI] One print format specifier appears to be missing in the above line. [/SAMI]
+ __FUNCTION__,
+ Status
+ ));
+ return Status;
+ }
+
+ Status = RamDisk->Register (
+ (UINTN)PcdGet32 (PcdRamDiskBase),
+ (UINTN)PcdGet32 (PcdRamDiskSize),
+ &gEfiVirtualCdGuid,
+ NULL,
+ &DevicePath
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: Failed to register RAM Disk - %r\n",
+ __FUNCTION__,
+ Status
+ ));
+ }
+ }
+
+ return Status;
+}