From nobody Fri Apr 26 07:32:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+54216+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+54216+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1581436489197644.3647183449795; Tue, 11 Feb 2020 07:54:49 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id Ci9jYY1788612xfbyQiPPe2x; Tue, 11 Feb 2020 07:54:48 -0800 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web09.11480.1581434759082953036 for ; Tue, 11 Feb 2020 07:25:59 -0800 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 C0D68FEC; Tue, 11 Feb 2020 07:25:58 -0800 (PST) X-Received: from usa.arm.com (a074939-lin.blr.arm.com [10.162.16.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 21DAD3F68E; Tue, 11 Feb 2020 07:25:56 -0800 (PST) From: "Vijayenthiran Subramaniam" To: devel@edk2.groups.io, leif@nuviainc.com, michael.d.kinney@intel.com Cc: thomas.abraham@arm.com Subject: [edk2-devel] [PATCH edk2-platforms 2/5] Platform/ARM/SgiPkg: Use lookup table to install ACPI table Date: Tue, 11 Feb 2020 20:55:34 +0530 Message-Id: <1581434737-11371-3-git-send-email-vijayenthiran.subramaniam@arm.com> In-Reply-To: <1581434737-11371-1-git-send-email-vijayenthiran.subramaniam@arm.com> References: <1581434737-11371-1-git-send-email-vijayenthiran.subramaniam@arm.com> Precedence: Bulk List-Unsubscribe: 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,vijayenthiran.subramaniam@arm.com X-Gm-Message-State: htoyt8ZAOE0SiPMUhCdHoqvFx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1581436488; bh=jh2bIIwRm165s4ZxWl4wwPRyEztYjpIU1BxydPVvocY=; h=Cc:Date:From:Reply-To:Subject:To; b=KXTsaXK9mWyFalF4sokuMoNC8546vlN3J1kXnisRYQu0Ruo9+4iTNvRUaU6k/wnhBaq RiFohlM9cXebtowVqVAKfxE1ZQ+nEA3+1Z7S/rV0MquWUIbzHZedfU+zaUxq4ExR9XNif PKkrl8iXEaHpA4ysZiV99GeWPYWf7gn9+c8= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Use lookup table to identify the platform and install corresponding ACPI tables. As the number of supported platforms grow, the existing platform identification using if..else does not scale well. Signed-off-by: Vijayenthiran Subramaniam --- Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c | 49 +++++++++++++++= +---- 1 file changed, 39 insertions(+), 10 deletions(-) diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c b/Platfo= rm/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c index 09e00e5d538b..4ab0dd768cd1 100644 --- a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c +++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c @@ -11,6 +11,35 @@ #include #include =20 +typedef struct { + SGI_PLATFORM_DESCRIPTOR SgiPlafromDescriptor; + CONST EFI_GUID* AcpiTableGuid; +} SGI_PLATFORM_ACPI_TABLE_GUID_LOOKUP; + +// Macro to construct the SGI_PLATFORM_ACPI_TABLE_GUID_LOOKUP structure +#define ACPI_GUID_LOOKUP(PART_NUM, CONFIG_NUM, GUID) = \ +{ = \ + { = \ + PART_NUM, CONFIG_NUM = \ + }, = \ + GUID = \ +} = \ + +STATIC SGI_PLATFORM_ACPI_TABLE_GUID_LOOKUP AcpiTableGuidLookup[] =3D { + ACPI_GUID_LOOKUP ( + SGI575_PART_NUM, + SGI575_CONF_NUM, + &gSgi575AcpiTablesFileGuid), + ACPI_GUID_LOOKUP ( + RD_N1E1_EDGE_PART_NUM, + RD_N1_EDGE_CONF_ID, + &gRdN1EdgeAcpiTablesFileGuid), + ACPI_GUID_LOOKUP ( + RD_N1E1_EDGE_PART_NUM, + RD_E1_EDGE_CONF_ID, + &gRdE1EdgeAcpiTablesFileGuid), +}; + VOID InitVirtioDevices ( VOID @@ -26,6 +55,7 @@ ArmSgiPkgEntryPoint ( EFI_STATUS Status; VOID *SystemIdHob; SGI_PLATFORM_DESCRIPTOR *HobData; + UINT8 i; UINT32 ConfigId; UINT32 PartNum; =20 @@ -40,16 +70,15 @@ ArmSgiPkgEntryPoint ( PartNum =3D HobData->PlatformId; ConfigId =3D HobData->ConfigId; =20 - if ((PartNum =3D=3D SGI575_PART_NUM) && (ConfigId =3D=3D SGI575_CONF_NUM= )) { - Status =3D LocateAndInstallAcpiFromFv (&gSgi575AcpiTablesFileGuid); - } else if ((PartNum =3D=3D RD_N1E1_EDGE_PART_NUM) && - (ConfigId =3D=3D RD_N1_EDGE_CONF_ID)) { - Status =3D LocateAndInstallAcpiFromFv (&gRdN1EdgeAcpiTablesFileGuid); - } else if ((PartNum =3D=3D RD_N1E1_EDGE_PART_NUM) && - (ConfigId =3D=3D RD_E1_EDGE_CONF_ID)) { - Status =3D LocateAndInstallAcpiFromFv (&gRdE1EdgeAcpiTablesFileGuid); - } else { - Status =3D EFI_UNSUPPORTED; + Status =3D EFI_UNSUPPORTED; + + // Walk through the AcpiTableGuidLookup lookup array + for (i =3D 0; i < ARRAY_SIZE (AcpiTableGuidLookup); i++) { + if ((PartNum =3D=3D AcpiTableGuidLookup[i].SgiPlafromDescriptor.Platfo= rmId) && + (ConfigId =3D=3D AcpiTableGuidLookup[i].SgiPlafromDescriptor.Confi= gId)) { + Status =3D LocateAndInstallAcpiFromFv (AcpiTableGuidLookup[i].AcpiTa= bleGuid); + break; + } } =20 if (EFI_ERROR (Status)) { --=20 2.7.4 -=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 (#54216): https://edk2.groups.io/g/devel/message/54216 Mute This Topic: https://groups.io/mt/71170110/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-