From nobody Tue Feb 10 05:41:59 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+74243+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+74243+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1618810872; cv=none; d=zohomail.com; s=zohoarc; b=HsShBp4UXq6AB+QuKFevVkQtaWZ1mL985ADNzJ0nsPExBVe7DpMoUDwZgGPMdUOKQKplqk5hHZwMSQHJZXCuWB0N2LYyN4rwR2Rt6LhL057aEEzk5K2W9+E0HLqAEYz7lZ9i7sx/OmH5bEK/X1Z0F0VmpbIbHJ8psDENlque9Uc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618810872; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=TklQzQcELFMLYUgAkBSr1hiUy+aiAvTQMr+CfzbDXn8=; b=WGDEwXOZmMrM26WW/WIMv9QRwAXQIEjdv8LNF9ELxKemqdR0og/+TiZhup1ybHNlG/UQxqpP5E44lMGsUWjTM3xTLeKP/YEl9qFkXCY7Vt4+iwsKJkw1MlgEq+XHOmoJMHd+lRmokCNHZ9qYLuXBeOp/lCa+DE9CCWTYI1ZCv1g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+74243+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 161881087230117.801310664749735; Sun, 18 Apr 2021 22:41:12 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id KV0SYY1788612x9H6d5giwfL; Sun, 18 Apr 2021 22:41:12 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.5035.1618810866438495009 for ; Sun, 18 Apr 2021 22:41:06 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0C701101E; Sun, 18 Apr 2021 22:41:06 -0700 (PDT) X-Received: from usa.arm.com (a074744.blr.arm.com [10.162.17.16]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 60D883F800; Sun, 18 Apr 2021 22:41:04 -0700 (PDT) From: "chandni cherukuri" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Leif Lindholm , Sami Mujawar , Chandni Cherukuri Subject: [edk2-devel] [edk2-platforms][PATCH V3 3/7] Platform/ARM/Morello: Add PlatformDxe driver for Morello Date: Mon, 19 Apr 2021 11:10:39 +0530 Message-Id: <20210419054043.21909-4-chandni.cherukuri@arm.com> In-Reply-To: <20210419054043.21909-1-chandni.cherukuri@arm.com> References: <20210419054043.21909-1-chandni.cherukuri@arm.com> Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,chandni.cherukuri@arm.com X-Gm-Message-State: Rs0yBkZdrPulq4zmov6uJ63Ex1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1618810872; bh=gdvl5G7ro3kvmH2Zge53tg8RvGbK5Liq6C7/7Gh5e2w=; h=Cc:Date:From:Reply-To:Subject:To; b=W9JberFGwmeoWprO4H2SxPpLyVMyAYMZhfI7Oo+rhXjjmpWa4+e9Lozl2sktHLjZcTS r9NyBP4MIBJTJ43y5AWoyOXkjlBioy35AEjX7k+UMI2k7+PK8SWunQLSPi/G+Z3CBlnSs hBk5Q+L2hhOVO5jnvr84yXGGbjNpfUq5BAY= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Anurag Koul This patch adds the PlatformDxe Driver for Morello platform. It includes the registration of the ramdisk device. Co-authored-by: Chandni Cherukuri Signed-off-by: Chandni Cherukuri Reviewed-by: Sami Mujawar --- Platform/ARM/Morello/Drivers/PlatformDxe/PlatformDxeFvp.inf | 44 +++++= +++++ Platform/ARM/Morello/Include/Guid/MorelloVirtioDevicesFormSet.h | 14 +++ Platform/ARM/Morello/Drivers/PlatformDxe/PlatformDxeFvp.c | 66 +++++= +++++++++ Platform/ARM/Morello/Drivers/PlatformDxe/VirtioDevices.c | 90 +++++= +++++++++++++++ 4 files changed, 214 insertions(+) diff --git a/Platform/ARM/Morello/Drivers/PlatformDxe/PlatformDxeFvp.inf b/= Platform/ARM/Morello/Drivers/PlatformDxe/PlatformDxeFvp.inf new file mode 100644 index 000000000000..e4882343fc77 --- /dev/null +++ b/Platform/ARM/Morello/Drivers/PlatformDxe/PlatformDxeFvp.inf @@ -0,0 +1,44 @@ +## @file +# Platform DXE driver for Morello FVP Platform +# +# Copyright (c) 2021, ARM Limited. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x0001001B + BASE_NAME =3D PlatformDxe + FILE_GUID =3D 11FC8B5A-377D-47A8-AEE9-0093D3D3407F + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D ArmMorelloEntryPoint + +[Sources.common] + PlatformDxeFvp.c + VirtioDevices.c + +[Packages] + MdePkg/MdePkg.dec + OvmfPkg/OvmfPkg.dec + Platform/ARM/Morello/MorelloPlatform.dec + +[LibraryClasses] + UefiDriverEntryPoint + VirtioMmioDeviceLib + +[Protocols] + gEfiRamDiskProtocolGuid + +[FeaturePcd] + gArmMorelloTokenSpaceGuid.PcdRamDiskSupported + gArmMorelloTokenSpaceGuid.PcdVirtioBlkSupported + +[FixedPcd] + gArmMorelloTokenSpaceGuid.PcdRamDiskBase + gArmMorelloTokenSpaceGuid.PcdRamDiskSize + gArmMorelloTokenSpaceGuid.PcdVirtioBlkBaseAddress + +[Depex] + gEfiRamDiskProtocolGuid diff --git a/Platform/ARM/Morello/Include/Guid/MorelloVirtioDevicesFormSet.= h b/Platform/ARM/Morello/Include/Guid/MorelloVirtioDevicesFormSet.h new file mode 100644 index 000000000000..77adffbfd984 --- /dev/null +++ b/Platform/ARM/Morello/Include/Guid/MorelloVirtioDevicesFormSet.h @@ -0,0 +1,14 @@ +/** @file + + Copyright (c) 2021, ARM Limited. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef MORELLO_VIRTIO_DEVICES_FORMSET_H_ +#define MORELLO_VIRTIO_DEVICES_FORMSET_H_ + +#define MORELLO_VIRTIO_BLOCK_GUID \ + { 0x2B6E62D0, 0x9346, 0x4E1A, { 0xAA, 0x1E, 0xCB, 0x01, 0xC3, 0x23, 0x4A= , 0x00 } } + +#endif //MORELLO_VIRTIO_DEVICES_FORMSET_H_ diff --git a/Platform/ARM/Morello/Drivers/PlatformDxe/PlatformDxeFvp.c b/Pl= atform/ARM/Morello/Drivers/PlatformDxe/PlatformDxeFvp.c new file mode 100644 index 000000000000..93c5ec670197 --- /dev/null +++ b/Platform/ARM/Morello/Drivers/PlatformDxe/PlatformDxeFvp.c @@ -0,0 +1,66 @@ +/** @file + + Copyright (c) 2021, ARM Limited. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include +#include +#include + +VOID +InitVirtioDevices ( + VOID + ); + +/** + 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 =3D EFI_SUCCESS; + + InitVirtioDevices (); + + if (FeaturePcdGet (PcdRamDiskSupported)) { + Status =3D 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 =3D 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; +} diff --git a/Platform/ARM/Morello/Drivers/PlatformDxe/VirtioDevices.c b/Pla= tform/ARM/Morello/Drivers/PlatformDxe/VirtioDevices.c new file mode 100644 index 000000000000..72d02b2b3bd2 --- /dev/null +++ b/Platform/ARM/Morello/Drivers/PlatformDxe/VirtioDevices.c @@ -0,0 +1,90 @@ +/** @file + + Copyright (c) 2021, ARM Limited. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include +#include +#include +#include + +#pragma pack (1) +typedef struct { + VENDOR_DEVICE_PATH VendorDevicePath; + EFI_DEVICE_PATH_PROTOCOL End; +} VIRTIO_DEVICE_PATH; +#pragma pack () + +STATIC VIRTIO_DEVICE_PATH mVirtioBlockDevicePath =3D +{ + { + { + HARDWARE_DEVICE_PATH, + HW_VENDOR_DP, + { + (UINT8)(sizeof (VENDOR_DEVICE_PATH)), + (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8) + } + }, + MORELLO_VIRTIO_BLOCK_GUID, + }, + { + END_DEVICE_PATH_TYPE, + END_ENTIRE_DEVICE_PATH_SUBTYPE, + { + sizeof (EFI_DEVICE_PATH_PROTOCOL), + 0 + } + } +}; + +/** + Initialize platform Virtio devices. + +**/ +VOID +InitVirtioDevices ( + VOID + ) +{ + EFI_STATUS Status; + EFI_HANDLE mVirtIoBlkController; + + mVirtIoBlkController =3D NULL; + + // Install protocol interface for storage device + if (FeaturePcdGet (PcdVirtioBlkSupported)) { + + Status =3D gBS->InstallProtocolInterface ( + &mVirtIoBlkController, + &gEfiDevicePathProtocolGuid, + EFI_NATIVE_INTERFACE, + &mVirtioBlockDevicePath + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Failed to install EFI_DEVICE_PATH protocol= " + "for Virtio Block device (Status =3D %r)\n", + __FUNCTION__, Status)); + } else { + // Declare the Virtio BlockIo device + Status =3D VirtioMmioInstallDevice ( + FixedPcdGet32 (PcdVirtioBlkBaseAddress), + mVirtIoBlkController + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Unable to find Virtio Block MMIO device " + "(Status =3D %r)\n", __FUNCTION__, Status)); + gBS->UninstallProtocolInterface ( + mVirtIoBlkController, + &gEfiDevicePathProtocolGuid, + &mVirtioBlockDevicePath + ); + } else { + DEBUG ((DEBUG_INIT, "%a: Installed Virtio Block device\n", + __FUNCTION__)); + } + } + } +} --=20 2.17.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#74243): https://edk2.groups.io/g/devel/message/74243 Mute This Topic: https://groups.io/mt/82202482/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-