From nobody Sat Nov 2 10:26:55 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; dkim=fail spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1490717720439432.9719873465848; Tue, 28 Mar 2017 09:15:20 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 334AD21DFA7BB; Tue, 28 Mar 2017 09:15:17 -0700 (PDT) Received: from mail-wm0-x22c.google.com (mail-wm0-x22c.google.com [IPv6:2a00:1450:400c:c09::22c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 4CA9D21DFA7BA for ; Tue, 28 Mar 2017 09:15:16 -0700 (PDT) Received: by mail-wm0-x22c.google.com with SMTP id w204so13680453wmd.1 for ; Tue, 28 Mar 2017 09:15:16 -0700 (PDT) Received: from localhost.localdomain ([196.81.160.3]) by smtp.gmail.com with ESMTPSA id o15sm4217828wmd.10.2017.03.28.09.15.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Mar 2017 09:15:13 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=nGWVN8z0K/l9z5t1GO3E8Qq32RvYvoqB9o7c6/5jNaY=; b=cd9F9KCRA+UAbYgJnVr6t2IKAo12plb2VcNO/qCZZUscYGjgmr2pRjbYt4af5hlHET rsrtzPIat92Cafvclf2kY7UOxeJ8LASJrg1Q0302p2QqbJ3VQ+xDz1c3/gsbkJjsYQK8 aULcFmgpZ7p1juTmgEQy+LJ4vKSSh5zuIzDOE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=nGWVN8z0K/l9z5t1GO3E8Qq32RvYvoqB9o7c6/5jNaY=; b=hLAe2R+GuMiY7WXpVWnXYyJlZDEDIa6XgYgG99hXztMTlAINuzR19ofSG4igFNQjyA z80muaPAWsGVOrAJba2ECRqsWZj1YVZlIWSBz2M3nbwylCivUqSIibpfK0hle/38Dqj5 CIkLfOb6ovXEnkokfYgZmmxll1+sWwUCOta5PGidyMHojcqirEljTYRFHbrPrVwboJ9Y xzyON7UTH9BDw6xDMeXiRHSYfHVruXfE5eyPU+j43j2LXWiyOtdxFhSXObSe4kn6rsVR o0rz1k3mIkRXTELlYNAoPrrau0dilzLnMlvGjh/fLEjoy8uC82I4XbFoI2xrYVZ4u1hN tPGw== X-Gm-Message-State: AFeK/H0nOad/C/K3jc3ZbpwU50YzTKPve20Peo3pLhwUXcCYnABd7cRySgSRvHe5v+ES2sPb X-Received: by 10.28.211.131 with SMTP id k125mr14894361wmg.41.1490717714124; Tue, 28 Mar 2017 09:15:14 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, lersek@redhat.com Date: Tue, 28 Mar 2017 17:15:00 +0100 Message-Id: <20170328161500.2737-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 Subject: [edk2] [PATCH v2] EmbeddedPkg: add DT platform driver to select between DT and ACPI X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mwojtas@semihalf.com, leif.lindholm@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" As a follow up to the changes proposed by Laszlo to make ACPI and DT mutually exclusive on ArmVirtQemu, this patch proposed a DT platform DXE driver that either installs the NULL protocol PlatformHasAcpiGuid, or installs the FV embedded DTB binary as a configuration table under the appropriate GUID, depending on a preference setting recorded as a UEFI variable, and configurable via a HII screen. The DTB binary can be embedded in the firmware image by adding the following to the platform .fdf file: FILE FREEFORM =3D 25462CDA-221F-47DF-AC1D-259CFAA4E326 { SECTION RAW =3D SomePkg/path/to/foo.dtb } Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel Reviewed-by: Laszlo Ersek --- v2: fixup various errors and rough edges pointed out by Laszlo EmbeddedPkg/EmbeddedPkg.dec | 6 + EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.inf | 65 ++++++ EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.h | 31 +++ EmbeddedPkg/Include/Guid/DtPlatformDefaultDtbFile.h | 23 +++ EmbeddedPkg/Include/Guid/DtPlatformFormSet.h | 23 +++ EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformHii.vfr | 51 +++++ EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.c | 216 ++++++++++++++++= ++++ EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformHii.uni | 27 +++ 8 files changed, 442 insertions(+) diff --git a/EmbeddedPkg/EmbeddedPkg.dec b/EmbeddedPkg/EmbeddedPkg.dec index 29736fb4a71d..871fc5ff4016 100644 --- a/EmbeddedPkg/EmbeddedPkg.dec +++ b/EmbeddedPkg/EmbeddedPkg.dec @@ -62,6 +62,12 @@ [Guids.common] ## Include/Guid/PlatformHasDeviceTree.h gEdkiiPlatformHasDeviceTreeGuid =3D { 0x7ebb920d, 0x1aaf, 0x46d9, { 0xb2= , 0xaf, 0x54, 0x1e, 0x1d, 0xce, 0x14, 0x8b } } =20 + # HII form set GUID for DtPlatformDxe driver + gDtPlatformFormSetGuid =3D { 0x2b7a240d, 0xd5ad, 0x4fd6, { 0xbe, 0x1c, 0= xdf, 0xa4, 0x41, 0x5f, 0x55, 0x26 } } + + # File GUID for default DTB image embedded in the firmware volume + gDtPlatformDefaultDtbFileGuid =3D { 0x25462cda, 0x221f, 0x47df, { 0xac, = 0x1d, 0x25, 0x9c, 0xfa, 0xa4, 0xe3, 0x26 } } + [Protocols.common] gHardwareInterruptProtocolGuid =3D { 0x2890B3EA, 0x053D, 0x1643, { 0xAD= , 0x0C, 0xD6, 0x48, 0x08, 0xDA, 0x3F, 0xF1 } } gEfiDebugSupportPeriodicCallbackProtocolGuid =3D { 0x9546e07c, 0x2cbb, 0= x4c88, { 0x98, 0x6c, 0xcd, 0x34, 0x10, 0x86, 0xf0, 0x44 } } diff --git a/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.inf b/Embedded= Pkg/Drivers/DtPlatformDxe/DtPlatformDxe.inf new file mode 100644 index 000000000000..aa1d3abb4012 --- /dev/null +++ b/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.inf @@ -0,0 +1,65 @@ +## @file +# +# Copyright (c) 2017, Linaro, Ltd. 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 =3D 0x00010019 + BASE_NAME =3D DtPlatformDxe + FILE_GUID =3D FC097B3C-2EBD-4A75-A3DA-121DCAB365CC + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D DtPlatformDxeEntryPoint + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D IA32 X64 ARM AARCH64 +# + +[Sources] + DtPlatformDxe.c + DtPlatformHii.vfr + DtPlatformHii.uni + +[Packages] + EmbeddedPkg/EmbeddedPkg.dec + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + +[LibraryClasses] + BaseLib + DebugLib + UefiLib + UefiDriverEntryPoint + UefiBootServicesTableLib + UefiRuntimeServicesTableLib + UefiHiiServicesLib + MemoryAllocationLib + HiiLib + PcdLib + DxeServicesLib + +[Guids] + gDtPlatformFormSetGuid + gEdkiiPlatformHasAcpiGuid + gDtPlatformDefaultDtbFileGuid + gFdtTableGuid + +[Protocols] + gEfiHiiConfigAccessProtocolGuid ## PRODUCES + +[Depex] + gEfiHiiDatabaseProtocolGuid AND + gEfiVariableArchProtocolGuid AND + gEfiVariableWriteArchProtocolGuid diff --git a/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.h b/EmbeddedPk= g/Drivers/DtPlatformDxe/DtPlatformDxe.h new file mode 100644 index 000000000000..2369367277b0 --- /dev/null +++ b/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.h @@ -0,0 +1,31 @@ +/** @file +* +* Copyright (c) 2017, Linaro Limited. All rights reserved. +* +* This program and the accompanying materials +* are licensed and made available under the terms and conditions of the B= SD 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 IM= PLIED. +* +**/ + +#ifndef __DT_PLATFORM_DXE_H__ +#define __DT_PLATFORM_DXE_H__ + +#include +#include + +#define DT_ACPI_SELECT_DT 0x0 +#define DT_ACPI_SELECT_ACPI 0x1 + +#define DT_ACPI_VARIABLE_NAME L"DtAcpiPref" + +typedef struct { + UINT8 Pref; + UINT8 Reserved[3]; +} DT_ACPI_VARSTORE_DATA; + +#endif diff --git a/EmbeddedPkg/Include/Guid/DtPlatformDefaultDtbFile.h b/Embedded= Pkg/Include/Guid/DtPlatformDefaultDtbFile.h new file mode 100644 index 000000000000..c44b4d9522fe --- /dev/null +++ b/EmbeddedPkg/Include/Guid/DtPlatformDefaultDtbFile.h @@ -0,0 +1,23 @@ +/** @file +* +* Copyright (c) 2017, Linaro Limited. All rights reserved. +* +* This program and the accompanying materials +* are licensed and made available under the terms and conditions of the B= SD 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 IM= PLIED. +* +**/ + +#ifndef __DT_PLATFORM_DEFAULT_DTB_FILE_H__ +#define __DT_PLATFORM_DEFAULT_DTB_FILE_H__ + +#define DT_PLATFORM_DEFAULT_DTB_FILE_GUID \ + { 0x25462cda, 0x221f, 0x47df, { 0xac, 0x1d, 0x25, 0x9c, 0xfa, 0xa4, 0xe3= , 0x26 } } + +extern EFI_GUID gDtPlatformDefaultDtbFileGuid; + +#endif diff --git a/EmbeddedPkg/Include/Guid/DtPlatformFormSet.h b/EmbeddedPkg/Inc= lude/Guid/DtPlatformFormSet.h new file mode 100644 index 000000000000..71e3e7ebf7f3 --- /dev/null +++ b/EmbeddedPkg/Include/Guid/DtPlatformFormSet.h @@ -0,0 +1,23 @@ +/** @file +* +* Copyright (c) 2017, Linaro Limited. All rights reserved. +* +* This program and the accompanying materials +* are licensed and made available under the terms and conditions of the B= SD 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 IM= PLIED. +* +**/ + +#ifndef __DT_PLATFORM_FORMSET_H__ +#define __DT_PLATFORM_FORMSET_H__ + +#define DT_PLATFORM_FORMSET_GUID \ + { 0x2b7a240d, 0xd5ad, 0x4fd6, { 0xbe, 0x1c, 0xdf, 0xa4, 0x41, 0x5f, 0x55= , 0x26 } } + +extern EFI_GUID gDtPlatformFormSetGuid; + +#endif diff --git a/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformHii.vfr b/Embedded= Pkg/Drivers/DtPlatformDxe/DtPlatformHii.vfr new file mode 100644 index 000000000000..3516746c4d84 --- /dev/null +++ b/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformHii.vfr @@ -0,0 +1,51 @@ +/** @file +* +* Copyright (c) 2017, Linaro, Ltd. All rights reserved. +* +* This program and the accompanying materials +* are licensed and made available under the terms and conditions of the B= SD 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 IM= PLIED. +* +**/ + +#include "DtPlatformDxe.h" + +// +// EFI Variable attributes +// +#define EFI_VARIABLE_NON_VOLATILE 0x00000001 +#define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002 +#define EFI_VARIABLE_RUNTIME_ACCESS 0x00000004 +#define EFI_VARIABLE_READ_ONLY 0x00000008 + +formset + guid =3D DT_PLATFORM_FORMSET_GUID, + title =3D STRING_TOKEN(STR_FORM_SET_TITLE), + help =3D STRING_TOKEN(STR_FORM_SET_TITLE_HELP), + classguid =3D EFI_HII_PLATFORM_SETUP_FORMSET_GUID, + + efivarstore DT_ACPI_VARSTORE_DATA, + attribute =3D EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLAT= ILE, // EFI variable attributes + name =3D DtAcpiPref, + guid =3D DT_PLATFORM_FORMSET_GUID; + + form formid =3D 0x1000, + title =3D STRING_TOKEN(STR_MAIN_FORM_TITLE); + + oneof varid =3D DtAcpiPref.Pref, + prompt =3D STRING_TOKEN(STR_DT_ACPI_SELECT_PROMPT), + help =3D STRING_TOKEN(STR_DT_ACPI_SELECT_HELP), + flags =3D NUMERIC_SIZE_1 | INTERACTIVE | RESET_REQUIRED, + option text =3D STRING_TOKEN(STR_DT_ACPI_SELECT_DT), value =3D DT_= ACPI_SELECT_DT, flags =3D DEFAULT; + option text =3D STRING_TOKEN(STR_DT_ACPI_SELECT_ACPI), value =3D D= T_ACPI_SELECT_ACPI, flags =3D 0; + endoneof; + + subtitle text =3D STRING_TOKEN(STR_NULL_STRING); + + endform; + +endformset; diff --git a/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.c b/EmbeddedPk= g/Drivers/DtPlatformDxe/DtPlatformDxe.c new file mode 100644 index 000000000000..f714551213c2 --- /dev/null +++ b/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.c @@ -0,0 +1,216 @@ +/** @file +* +* Copyright (c) 2017, Linaro, Ltd. All rights reserved. +* +* This program and the accompanying materials +* are licensed and made available under the terms and conditions of the B= SD 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 IM= PLIED. +* +**/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "DtPlatformDxe.h" + +extern UINT8 DtPlatformHiiBin[]; +extern UINT8 DtPlatformDxeStrings[]; + +typedef struct { + VENDOR_DEVICE_PATH VendorDevicePath; + EFI_DEVICE_PATH_PROTOCOL End; +} HII_VENDOR_DEVICE_PATH; + +STATIC HII_VENDOR_DEVICE_PATH mDtPlatformDxeVendorDevicePath =3D { + { + { + HARDWARE_DEVICE_PATH, + HW_VENDOR_DP, + { + (UINT8) (sizeof (VENDOR_DEVICE_PATH)), + (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8) + } + }, + DT_PLATFORM_FORMSET_GUID + }, + { + END_DEVICE_PATH_TYPE, + END_ENTIRE_DEVICE_PATH_SUBTYPE, + { + (UINT8) (END_DEVICE_PATH_LENGTH), + (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8) + } + } +}; + +STATIC +EFI_STATUS +InstallHiiPages ( + VOID + ) +{ + EFI_STATUS Status; + EFI_HII_HANDLE HiiHandle; + EFI_HANDLE DriverHandle; + + DriverHandle =3D NULL; + Status =3D gBS->InstallMultipleProtocolInterfaces (&DriverHandle, + &gEfiDevicePathProtocolGuid, + &mDtPlatformDxeVendorDevicePath, + NULL); + if (EFI_ERROR (Status)) { + return Status; + } + + HiiHandle =3D HiiAddPackages (&gDtPlatformFormSetGuid, + DriverHandle, + DtPlatformDxeStrings, + DtPlatformHiiBin, + NULL); + + if (HiiHandle =3D=3D NULL) { + gBS->UninstallMultipleProtocolInterfaces (DriverHandle, + &gEfiDevicePathProtocolGuid, + &mDtPlatformDxeVendorDevicePath, + NULL); + return EFI_OUT_OF_RESOURCES; + } + return EFI_SUCCESS; +} + +/** + The entry point for DtPlatformDxe driver. + + @param[in] ImageHandle The image handle of the driver. + @param[in] SystemTable The system table. + + @retval EFI_ALREADY_STARTED The driver already exists in system. + @retval EFI_OUT_OF_RESOURCES Fail to execute entry point due to lack = of + resources. + @retval EFI_SUCCES All the related protocols are installed = on + the driver. + +**/ +EFI_STATUS +EFIAPI +DtPlatformDxeEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + DT_ACPI_VARSTORE_DATA DtAcpiPref; + UINTN BufferSize; + VOID *Dtb; + UINTN DtbSize; + VOID *DtbCopy; + + // + // Check whether a DTB blob is included in the firmware image. + // + Dtb =3D NULL; + Status =3D GetSectionFromAnyFv (&gDtPlatformDefaultDtbFileGuid, + EFI_SECTION_RAW, 0, &Dtb, &DtbSize); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_WARN, "%a: no DTB blob found, defaulting to ACPI\n", + __FUNCTION__)); + DtAcpiPref.Pref =3D DT_ACPI_SELECT_ACPI; + } else { + // + // Get the current DT/ACPI preference from the DtAcpiPref variable. + // + BufferSize =3D sizeof (DtAcpiPref); + Status =3D gRT->GetVariable(DT_ACPI_VARIABLE_NAME, &gDtPlatformFormSet= Guid, + NULL, &BufferSize, &DtAcpiPref); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_WARN, "%a: no DT/ACPI preference found, defaulting to = DT\n", + __FUNCTION__)); + DtAcpiPref.Pref =3D DT_ACPI_SELECT_DT; + } + } + + if (!EFI_ERROR (Status) && + DtAcpiPref.Pref !=3D DT_ACPI_SELECT_ACPI && + DtAcpiPref.Pref !=3D DT_ACPI_SELECT_DT) { + DEBUG ((DEBUG_WARN, "%a: invalid value for DtAcpiPref, defaulting to D= T\n", + __FUNCTION__)); + DtAcpiPref.Pref =3D DT_ACPI_SELECT_DT; + Status =3D EFI_INVALID_PARAMETER; // trigger setvar below + } + + // + // Write the newly selected default value back to the variable store. + // + if (EFI_ERROR (Status)) { + Status =3D gRT->SetVariable(DT_ACPI_VARIABLE_NAME, &gDtPlatformFormSet= Guid, + EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_A= CCESS, + sizeof (DtAcpiPref), &DtAcpiPref); + if (EFI_ERROR (Status)) { + return Status; + } + } + + if (DtAcpiPref.Pref =3D=3D DT_ACPI_SELECT_ACPI) { + // + // ACPI was selected: install the gEdkiiPlatformHasAcpiGuid GUID as a + // NULL protocol to unlock dispatch of ACPI related drivers. + // + Status =3D gBS->InstallMultipleProtocolInterfaces (&ImageHandle, + &gEdkiiPlatformHasAcpiGuid, NULL, NULL); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, + "%a: failed to install gEdkiiPlatformHasAcpiGuid as a protocol\n", + __FUNCTION__)); + return Status; + } + } else if (DtAcpiPref.Pref =3D=3D DT_ACPI_SELECT_DT) { + // + // DT was selected: copy the blob into newly allocated memory and inst= all + // a reference to it as the FDT configuration table. + // + DtbCopy =3D AllocateCopyPool (DtbSize, Dtb); + if (DtbCopy =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + Status =3D gBS->InstallConfigurationTable (&gFdtTableGuid, DtbCopy); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: failed to install FDT configuration table\= n", + __FUNCTION__)); + FreePool (DtbCopy); + return Status; + } + } else { + ASSERT (FALSE); + } + + // + // No point in installing the HII pages if ACPI is the only description + // we have + // + if (Dtb =3D=3D NULL) { + return EFI_SUCCESS; + } + + // + // Note that we don't uninstall the gEdkiiPlatformHasAcpiGuid protocol n= or + // the FDT configuration table if the following call fails. While that w= ill + // cause loading of this driver to fail, proceeding with ACPI and DT both + // disabled will guarantee a failed boot, and so it is better to leave t= hem + // installed in that case. + // + return InstallHiiPages (); +} diff --git a/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformHii.uni b/Embedded= Pkg/Drivers/DtPlatformDxe/DtPlatformHii.uni new file mode 100644 index 000000000000..bc995c1d0fbd --- /dev/null +++ b/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformHii.uni @@ -0,0 +1,27 @@ +/** @file +* +* Copyright (c) 2017, Linaro, Ltd. All rights reserved. +* +* This program and the accompanying materials +* are licensed and made available under the terms and conditions of the B= SD 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 IM= PLIED. +* +**/ + +#langdef en-US "English" + +#string STR_FORM_SET_TITLE #language en-US "O/S Hardware Descr= iption Selection" +#string STR_FORM_SET_TITLE_HELP #language en-US "Press to c= hoose between ACPI and DT hardware descriptions." + +#string STR_MAIN_FORM_TITLE #language en-US "O/S Hardware Descr= iption Selection" +#string STR_NULL_STRING #language en-US "" + +#string STR_DT_ACPI_SELECT_PROMPT #language en-US "O/S Hardware Descr= iption" +#string STR_DT_ACPI_SELECT_HELP #language en-US "Select the hardwar= e description that will be exposed to the O/S." + +#string STR_DT_ACPI_SELECT_DT #language en-US "Device Tree" +#string STR_DT_ACPI_SELECT_ACPI #language en-US "ACPI" --=20 2.9.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel