From nobody Mon May 6 09:11:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.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; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1524632389872106.97223458548581; Tue, 24 Apr 2018 21:59:49 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 9694C22512154; Tue, 24 Apr 2018 21:59:48 -0700 (PDT) Received: from mail-pf0-x243.google.com (mail-pf0-x243.google.com [IPv6:2607:f8b0:400e:c00::243]) (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 38F172282E592 for ; Tue, 24 Apr 2018 21:59:48 -0700 (PDT) Received: by mail-pf0-x243.google.com with SMTP id o16so14145416pfk.9 for ; Tue, 24 Apr 2018 21:59:48 -0700 (PDT) Received: from localhost.localdomain ([64.64.108.65]) by smtp.gmail.com with ESMTPSA id 142sm18061455pgg.86.2018.04.24.21.59.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 24 Apr 2018 21:59:46 -0700 (PDT) X-Original-To: edk2-devel@lists.01.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; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:400e:c00::243; helo=mail-pf0-x243.google.com; envelope-from=haojian.zhuang@linaro.org; receiver=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:in-reply-to:references; bh=i7Do5+HGUtwoCcBxsTSt7D3rWDkbVmu9VZ262071FwE=; b=T2K1AAotqmVrEbO4TSGSNik2Rag7waCpmLey2eafYL3pmI8wNsSkfZ2KnWgjkrERU9 1kZaBNamuoD/7Rge5AmtDRTK9Sym9yfkKVGE04ZqD2re8rRWAYDsCC69fQE8axftaY+A 675FbsGJdkq6gp1csJ30FgLNVgu5My8zXxMPw= 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:in-reply-to :references; bh=i7Do5+HGUtwoCcBxsTSt7D3rWDkbVmu9VZ262071FwE=; b=AZghG7ApmsUEDVzMqt7G6QoDKdryu3uYvE7aHiMMSvJ4FBbWOvl7wzGoZjB0gtPmGt kDIK/fLf2yVBVOfBQURuz0ueBR/F4M0W4Z7IgWMZT1N6rohyRvuaGwiI2FeKjgDmBlBw buGKox30Iuvy4aofMXMZlacxcR3+XXiHIP89GR0nFYYN6IjGL9i/J8d/kzlMrH765sMz XgBJBW7KYXsFq0kaAQjDNk9U3uYnUZECao08jRpaKOmSya3sAQ+BC+nZ15Wprl46UEfn DGfwZwnPkVYRBVzE9pCn5yoQTb0M8kPTsaQK03d1lwFSiuvFTLAkRHP2QTj1k+lulVQc Pm/g== X-Gm-Message-State: ALQs6tAPdimEJd0X9ObKHoG60FaRUeXcYqqxfVIdQMs1g0zvL+Q2bijc kInDCbiKnYMIUuZWxcgOzja4w8xZ4nY= X-Google-Smtp-Source: AB8JxZrMzFAsFEPQbtu/zWvLXdxETwuHMhInjlld2bBOGBtsdNU8rQhQayGS9sD22ZnMS15KrWECbA== X-Received: by 2002:a17:902:d88a:: with SMTP id b10-v6mr5551685plz.81.1524632387569; Tue, 24 Apr 2018 21:59:47 -0700 (PDT) From: Haojian Zhuang To: edk2-devel@lists.01.org Date: Wed, 25 Apr 2018 12:59:35 +0800 Message-Id: <1524632376-23501-2-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1524632376-23501-1-git-send-email-haojian.zhuang@linaro.org> References: <1524632376-23501-1-git-send-email-haojian.zhuang@linaro.org> Subject: [edk2] [PATCH edk2-platforms v5 1/2] Platform/HiKey960: register predefined boot options X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laszlo Ersek , Haojian Zhuang , Leif Lindholm , 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" Create 4 boot options on HiKey960 platform. They're "Boot from SD", "Grub", "Android Boot" and "Android Fastboot". Cc: Laszlo Ersek Cc: Leif Lindholm Cc: Ard Biesheuvel Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Haojian Zhuang Acked-by: Laszlo Ersek --- Platform/Hisilicon/HiKey960/HiKey960.dec | 35 +++++ Platform/Hisilicon/HiKey960/HiKey960.dsc | 6 + .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c | 172 +++++++++++++++++= ++++ .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf | 11 ++ 4 files changed, 224 insertions(+) create mode 100644 Platform/Hisilicon/HiKey960/HiKey960.dec diff --git a/Platform/Hisilicon/HiKey960/HiKey960.dec b/Platform/Hisilicon/= HiKey960/HiKey960.dec new file mode 100644 index 000000000000..922d7199c5a5 --- /dev/null +++ b/Platform/Hisilicon/HiKey960/HiKey960.dec @@ -0,0 +1,35 @@ +# +# Copyright (c) 2018, 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. +# + +[Defines] + DEC_SPECIFICATION =3D 0x00010019 + PACKAGE_NAME =3D HiKey960 + PACKAGE_GUID =3D 1892b5b5-d18d-47a3-8fab-e3ae6b4226b0 + PACKAGE_VERSION =3D 0.1 + +##########################################################################= ###### +# +# Include Section - list of Include Paths that are provided by this packag= e. +# Comments are used for Keywords and Module Types. +# +# Supported Module Types: +# BASE SEC PEI_CORE PEIM DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_D= RIVER DXE_SAL_DRIVER UEFI_DRIVER UEFI_APPLICATION +# +##########################################################################= ###### +[Guids.common] + gHiKey960TokenSpaceGuid =3D { 0x99a14446, 0xaad7, 0xe460, {0xb4, = 0xe5, 0x1f, 0x79, 0xaa, 0xa4, 0x93, 0xfd } } + +[PcdsFixedAtBuild.common] + gHiKey960TokenSpaceGuid.PcdAndroidBootDevicePath|L""|VOID*|0x00000001 + gHiKey960TokenSpaceGuid.PcdAndroidBootFile|{ 0x36, 0x8b, 0x73, 0x3a, 0xc= 5, 0xb9, 0x63, 0x47, 0xab, 0xbd, 0x6c, 0xbd, 0x4b, 0x25, 0xf9, 0xff }|VOID*= |0x00000002 + gHiKey960TokenSpaceGuid.PcdAndroidFastbootFile|{ 0x2a, 0x50, 0x88, 0x95,= 0x70, 0x53, 0xe3, 0x11, 0x86, 0x31, 0xd7, 0xc5, 0x95, 0x13, 0x64, 0xc8 }|V= OID*|0x00000003 + gHiKey960TokenSpaceGuid.PcdSdBootDevicePath|L""|VOID*|0x00000004 diff --git a/Platform/Hisilicon/HiKey960/HiKey960.dsc b/Platform/Hisilicon/= HiKey960/HiKey960.dsc index 859ab84f8415..4097fbfd77f5 100644 --- a/Platform/Hisilicon/HiKey960/HiKey960.dsc +++ b/Platform/Hisilicon/HiKey960/HiKey960.dsc @@ -132,6 +132,12 @@ [PcdsFixedAtBuild.common] gEmbeddedTokenSpaceGuid.PcdAndroidFastbootUsbVendorId|0x18d1 gEmbeddedTokenSpaceGuid.PcdAndroidFastbootUsbProductId|0xd00d =20 + # + # Android Loader + # + gHiKey960TokenSpaceGuid.PcdAndroidBootDevicePath|L"VenHw(0D51905B-B77E-4= 52A-A2C0-ECA0CC8D514A,00003BFF0000000000)/UFS(0x0,0x3)/HD(7,GPT,D3340696-9B= 95-4C64-8DF6-E6D4548FBA41,0x12100,0x4000)/\\EFI\\BOOT\\GRUBAA64.EFI" + gHiKey960TokenSpaceGuid.PcdSdBootDevicePath|L"VenHw(0D51905B-B77E-452A-A= 2C0-ECA0CC8D514A,00F037FF0000000000)/SD(0x0)" + ##########################################################################= ###### # # Components Section - list of all EDK II Modules needed by this Platform diff --git a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c b/Platfo= rm/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c index 473d61ed384e..413423e75569 100644 --- a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c +++ b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c @@ -30,10 +30,16 @@ #include #include #include +#include #include +#include #include =20 +#include +#include #include +#include +#include #include =20 #define ADC_ADCIN0 0 @@ -86,6 +92,10 @@ =20 #define DETECT_SW_FASTBOOT 68 // GPIO8_4 =20 +#define HIKEY960_BOOT_OPTION_NUM 4 + +#define GRUB_FILE_NAME L"\\EFI\\BOOT\\GRUBAA64.EFI" + typedef struct { UINT64 Magic; UINT64 Data; @@ -359,6 +369,158 @@ OnEndOfDxe ( } } =20 +STATIC +EFI_STATUS +CreatePlatformBootOptionFromPath ( + IN CHAR16 *PathStr, + IN CHAR16 *Description, + IN OUT EFI_BOOT_MANAGER_LOAD_OPTION *BootOption + ) +{ + EFI_STATUS Status; + EFI_DEVICE_PATH *DevicePath; + + DevicePath =3D (EFI_DEVICE_PATH *)ConvertTextToDevicePath (PathStr); + ASSERT (DevicePath !=3D NULL); + Status =3D EfiBootManagerInitializeLoadOption ( + BootOption, + LoadOptionNumberUnassigned, + LoadOptionTypeBoot, + LOAD_OPTION_ACTIVE, + Description, + DevicePath, + NULL, + 0 + ); + if (EFI_ERROR (Status)) { + return Status; + } + FreePool (DevicePath); + return Status; +} + +STATIC +EFI_STATUS +CreatePlatformBootOptionFromGuid ( + IN EFI_GUID *FileGuid, + IN CHAR16 *Description, + IN OUT EFI_BOOT_MANAGER_LOAD_OPTION *BootOption + ) +{ + EFI_STATUS Status; + EFI_DEVICE_PATH *DevicePath; + EFI_DEVICE_PATH *TempDevicePath; + EFI_LOADED_IMAGE_PROTOCOL *LoadedImage; + MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode; + + Status =3D gBS->HandleProtocol ( + gImageHandle, + &gEfiLoadedImageProtocolGuid, + (VOID **) &LoadedImage + ); + ASSERT_EFI_ERROR (Status); + EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid); + TempDevicePath =3D DevicePathFromHandle (LoadedImage->DeviceHandle); + ASSERT (TempDevicePath !=3D NULL); + DevicePath =3D AppendDevicePathNode ( + TempDevicePath, + (EFI_DEVICE_PATH_PROTOCOL *) &FileNode + ); + ASSERT (DevicePath !=3D NULL); + Status =3D EfiBootManagerInitializeLoadOption ( + BootOption, + LoadOptionNumberUnassigned, + LoadOptionTypeBoot, + LOAD_OPTION_ACTIVE, + Description, + DevicePath, + NULL, + 0 + ); + if (EFI_ERROR (Status)) { + return Status; + } + FreePool (DevicePath); + return Status; +} + +STATIC +EFI_STATUS +GetPlatformBootOptionsAndKeys ( + OUT UINTN *BootCount, + OUT EFI_BOOT_MANAGER_LOAD_OPTION **BootOptions, + OUT EFI_INPUT_KEY **BootKeys + ) +{ + EFI_GUID *FileGuid; + CHAR16 *PathStr; + EFI_STATUS Status; + UINTN Size; + + Size =3D sizeof (EFI_BOOT_MANAGER_LOAD_OPTION) * HIKEY960_BOOT_OPTION_NU= M; + *BootOptions =3D (EFI_BOOT_MANAGER_LOAD_OPTION *)AllocateZeroPool (Size); + if (*BootOptions =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "Failed to allocate memory for BootOptions\n")); + return EFI_OUT_OF_RESOURCES; + } + Size =3D sizeof (EFI_INPUT_KEY) * HIKEY960_BOOT_OPTION_NUM; + *BootKeys =3D (EFI_INPUT_KEY *)AllocateZeroPool (Size); + if (*BootKeys =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "Failed to allocate memory for BootKeys\n")); + Status =3D EFI_OUT_OF_RESOURCES; + goto Error; + } + + PathStr =3D (CHAR16 *)PcdGetPtr (PcdSdBootDevicePath); + ASSERT (PathStr !=3D NULL); + Status =3D CreatePlatformBootOptionFromPath ( + PathStr, + L"Boot from SD", + &(*BootOptions)[0] + ); + ASSERT_EFI_ERROR (Status); + + PathStr =3D (CHAR16 *)PcdGetPtr (PcdAndroidBootDevicePath); + ASSERT (PathStr !=3D NULL); + Status =3D CreatePlatformBootOptionFromPath ( + PathStr, + L"Grub", + &(*BootOptions)[1] + ); + ASSERT_EFI_ERROR (Status); + + FileGuid =3D PcdGetPtr (PcdAndroidBootFile); + ASSERT (FileGuid !=3D NULL); + Status =3D CreatePlatformBootOptionFromGuid ( + FileGuid, + L"Android Boot", + &(*BootOptions)[2] + ); + ASSERT_EFI_ERROR (Status); + + FileGuid =3D PcdGetPtr (PcdAndroidFastbootFile); + ASSERT (FileGuid !=3D NULL); + Status =3D CreatePlatformBootOptionFromGuid ( + FileGuid, + L"Android Fastboot", + &(*BootOptions)[3] + ); + ASSERT_EFI_ERROR (Status); + (*BootKeys)[3].ScanCode =3D SCAN_NULL; + (*BootKeys)[3].UnicodeChar =3D 'f'; + + *BootCount =3D 4; + + return EFI_SUCCESS; +Error: + FreePool (*BootOptions); + return Status; +} + +PLATFORM_BOOT_MANAGER_PROTOCOL mPlatformBootManager =3D { + GetPlatformBootOptionsAndKeys +}; + EFI_STATUS EFIAPI VirtualKeyboardRegister ( @@ -487,5 +649,15 @@ HiKey960EntryPoint ( EFI_NATIVE_INTERFACE, &mVirtualKeyboard ); + if (EFI_ERROR (Status)) { + return Status; + } + + Status =3D gBS->InstallProtocolInterface ( + &ImageHandle, + &gPlatformBootManagerProtocolGuid, + EFI_NATIVE_INTERFACE, + &mPlatformBootManager + ); return Status; } diff --git a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf b/Plat= form/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf index cc517656b340..5adedd79d3e8 100644 --- a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf +++ b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf @@ -25,6 +25,7 @@ [Packages] EmbeddedPkg/EmbeddedPkg.dec MdePkg/MdePkg.dec MdeModulePkg/MdeModulePkg.dec + Platform/Hisilicon/HiKey960/HiKey960.dec =20 [LibraryClasses] BaseMemoryLib @@ -37,15 +38,25 @@ [LibraryClasses] PrintLib SerialPortLib TimerLib + UefiBootManagerLib UefiBootServicesTableLib UefiDriverEntryPoint UefiLib UefiRuntimeServicesTableLib =20 [Protocols] + gEfiDevicePathFromTextProtocolGuid + gEfiLoadedImageProtocolGuid gEmbeddedGpioProtocolGuid + gPlatformBootManagerProtocolGuid gPlatformVirtualKeyboardProtocolGuid =20 +[Pcd] + gHiKey960TokenSpaceGuid.PcdAndroidBootDevicePath + gHiKey960TokenSpaceGuid.PcdAndroidBootFile + gHiKey960TokenSpaceGuid.PcdAndroidFastbootFile + gHiKey960TokenSpaceGuid.PcdSdBootDevicePath + [Guids] gEfiEndOfDxeEventGroupGuid gEfiFileInfoGuid --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Mon May 6 09:11:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.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; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1524632393802136.65805720714218; Tue, 24 Apr 2018 21:59:53 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id C6B742277AF0D; Tue, 24 Apr 2018 21:59:52 -0700 (PDT) Received: from mail-pf0-x242.google.com (mail-pf0-x242.google.com [IPv6:2607:f8b0:400e:c00::242]) (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 99C9B220E8E16 for ; Tue, 24 Apr 2018 21:59:51 -0700 (PDT) Received: by mail-pf0-x242.google.com with SMTP id a14so3647645pfi.1 for ; Tue, 24 Apr 2018 21:59:51 -0700 (PDT) Received: from localhost.localdomain ([64.64.108.65]) by smtp.gmail.com with ESMTPSA id 142sm18061455pgg.86.2018.04.24.21.59.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 24 Apr 2018 21:59:50 -0700 (PDT) X-Original-To: edk2-devel@lists.01.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; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:400e:c00::242; helo=mail-pf0-x242.google.com; envelope-from=haojian.zhuang@linaro.org; receiver=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:in-reply-to:references; bh=kdm/N3Pm04hD9KAFFE4fxZUJ31eeBD5cnLVb0RFts6g=; b=IHeiJ4TqenBEDkK8ClTyMhfjL1AlP68Ibm50KY2jxdfICJdFhKncoDxBwMksv5HL3P S5xN+FsAFge1dt9HcJ1IT/AsUNDVTFrmpUqUyWDjGOnkRubbcmDG4lnY6scjjTLrdL3w f08f359NExLdfI6jhm796RFt5RK/kjk18mEEU= 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:in-reply-to :references; bh=kdm/N3Pm04hD9KAFFE4fxZUJ31eeBD5cnLVb0RFts6g=; b=SGFRLGxd45oDTJ8tAnx0updZ/xeFcRJ2UJHGGGGkq1JjV5sfJ4oeWaDlUjMAXLJyxE mjT4+ET/sX/QHlXvC7CPwttl/mdUhltRg8Nic6og3B53plOP/JF/bdksWMOD9apZw7md a5lIyFLTI6X1qOKfP+L0nHeDG0g44LAEkJus1B76BFS91p4zRfJMZ8zD75uXl9aScA1l EYQ7MDJSs/QgUpArVBbUlT3rRV2Y99a+vHtSbnSKhmxIyRZea6Jb+GFSCtzwWcRLveoJ 9FFgJc7cNrGVv1Yf53zzeg0qkhGDQguca+tBv5OmDbBjvGULhExqjdhjsjkG0rriVk9H PKxQ== X-Gm-Message-State: ALQs6tC3KEflIMDvIPdVJAWr030WU6RCU39KxTPV9f/hdQvgADEbUWDV ZYpz+V/XVQqbPa3ZbmKcMWReUzQqFzk= X-Google-Smtp-Source: AIpwx4+mbLvIto65Yt9CYwxRHaeq7vHVVnHP6Jjq7L66kZFHmwtDRtM4WOKxUrQh+z49qC2fnQ46IA== X-Received: by 10.101.82.133 with SMTP id y5mr22313959pgp.27.1524632390897; Tue, 24 Apr 2018 21:59:50 -0700 (PDT) From: Haojian Zhuang To: edk2-devel@lists.01.org Date: Wed, 25 Apr 2018 12:59:36 +0800 Message-Id: <1524632376-23501-3-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1524632376-23501-1-git-send-email-haojian.zhuang@linaro.org> References: <1524632376-23501-1-git-send-email-haojian.zhuang@linaro.org> Subject: [edk2] [PATCH edk2-platforms v5 2/2] Platform/HiKey: create 4 boot options X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laszlo Ersek , Haojian Zhuang , Leif Lindholm , 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" Create 4 predefined boot options for HiKey. They're "Boot from SD", "Grub", "Android Boot" and "Android Fastboot". Cc: Laszlo Ersek Cc: Leif Lindholm Cc: Ard Biesheuvel Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Haojian Zhuang Acked-by: Laszlo Ersek --- Platform/Hisilicon/HiKey/HiKey.dec | 8 +- Platform/Hisilicon/HiKey/HiKey.dsc | 7 + Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c | 171 +++++++++++++++++++++= ++++ Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf | 11 ++ 4 files changed, 194 insertions(+), 3 deletions(-) diff --git a/Platform/Hisilicon/HiKey/HiKey.dec b/Platform/Hisilicon/HiKey/= HiKey.dec index 537138eb45a1..bb94c5cab13f 100644 --- a/Platform/Hisilicon/HiKey/HiKey.dec +++ b/Platform/Hisilicon/HiKey/HiKey.dec @@ -1,5 +1,5 @@ # -# Copyright (c) 2014-2017, Linaro Limited. All rights reserved. +# Copyright (c) 2014-2018, 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 @@ -32,5 +32,7 @@ [Guids.common] gHiKeyTokenSpaceGuid =3D { 0x91148425, 0xcdd2, 0x4830, { 0x8b,= 0xd0, 0xc6, 0x1c, 0x6d, 0xea, 0x36, 0x21 } } =20 [PcdsFixedAtBuild.common] - gHiKeyTokenSpaceGuid.PcdAndroidFastbootNvmDevicePath|L""|VOID*|0x00000001 - gHiKeyTokenSpaceGuid.PcdArmFastbootFlashLimit|L""|VOID*|0x00000002 + gHiKeyTokenSpaceGuid.PcdAndroidBootDevicePath|L""|VOID*|0x00000001 + gHiKeyTokenSpaceGuid.PcdAndroidBootFile|{ 0x36, 0x8b, 0x73, 0x3a, 0xc5, = 0xb9, 0x63, 0x47, 0xab, 0xbd, 0x6c, 0xbd, 0x4b, 0x25, 0xf9, 0xff }|VOID*|0x= 00000002 + gHiKeyTokenSpaceGuid.PcdAndroidFastbootFile|{ 0x2a, 0x50, 0x88, 0x95, 0x= 70, 0x53, 0xe3, 0x11, 0x86, 0x31, 0xd7, 0xc5, 0x95, 0x13, 0x64, 0xc8 }|VOID= *|0x00000003 + gHiKeyTokenSpaceGuid.PcdSdBootDevicePath|L""|VOID*|0x00000004 diff --git a/Platform/Hisilicon/HiKey/HiKey.dsc b/Platform/Hisilicon/HiKey/= HiKey.dsc index 83dd68a820b1..9c1fc2e1b40d 100644 --- a/Platform/Hisilicon/HiKey/HiKey.dsc +++ b/Platform/Hisilicon/HiKey/HiKey.dsc @@ -138,6 +138,13 @@ [PcdsFixedAtBuild.common] gEmbeddedTokenSpaceGuid.PcdAndroidFastbootUsbVendorId|0x18d1 gEmbeddedTokenSpaceGuid.PcdAndroidFastbootUsbProductId|0xd00d =20 + # + # Android Loader + # + gHiKeyTokenSpaceGuid.PcdAndroidBootDevicePath|L"VenHw(0D51905B-B77E-452A= -A2C0-ECA0CC8D514A,00D023F70000000000)/eMMC(0x0)/Ctrl(0x0)/HD(6,GPT,5C0F213= C-17E1-4149-88C8-8B50FB4EC70E,0x7000,0x20000)/\\EFI\\BOOT\\GRUBAA64.EFI" + gHiKeyTokenSpaceGuid.PcdSdBootDevicePath|L"VenHw(0D51905B-B77E-452A-A2C0= -ECA0CC8D514A,00E023F70000000000)/SD(0x0)" + + ##########################################################################= ###### # # Components Section - list of all EDK II Modules needed by this Platform diff --git a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c b/Platform/Hisili= con/HiKey/HiKeyDxe/HiKeyDxe.c index 65e800116b76..e20538bd77bf 100644 --- a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c +++ b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c @@ -18,12 +18,18 @@ #include #include #include +#include #include +#include #include #include #include =20 +#include +#include #include +#include +#include #include =20 #include @@ -42,6 +48,9 @@ #define ADB_REBOOT_BOOTLOADER 0x77665500 #define ADB_REBOOT_NONE 0x77665501 =20 +#define HIKEY_BOOT_OPTION_NUM 4 + +#define GRUB_FILE_NAME L"\\EFI\\BOOT\\GRUBAA64.EFI" =20 typedef struct { UINT64 Magic; @@ -121,6 +130,158 @@ HiKeyInitPeripherals ( return EFI_SUCCESS; } =20 +STATIC +EFI_STATUS +CreatePlatformBootOptionFromPath ( + IN CHAR16 *PathStr, + IN CHAR16 *Description, + IN OUT EFI_BOOT_MANAGER_LOAD_OPTION *BootOption + ) +{ + EFI_STATUS Status; + EFI_DEVICE_PATH *DevicePath; + + DevicePath =3D (EFI_DEVICE_PATH *)ConvertTextToDevicePath (PathStr); + ASSERT (DevicePath !=3D NULL); + Status =3D EfiBootManagerInitializeLoadOption ( + BootOption, + LoadOptionNumberUnassigned, + LoadOptionTypeBoot, + LOAD_OPTION_ACTIVE, + Description, + DevicePath, + NULL, + 0 + ); + if (EFI_ERROR (Status)) { + return Status; + } + FreePool (DevicePath); + return Status; +} + +STATIC +EFI_STATUS +CreatePlatformBootOptionFromGuid ( + IN EFI_GUID *FileGuid, + IN CHAR16 *Description, + IN OUT EFI_BOOT_MANAGER_LOAD_OPTION *BootOption + ) +{ + EFI_STATUS Status; + EFI_DEVICE_PATH *DevicePath; + EFI_DEVICE_PATH *TempDevicePath; + EFI_LOADED_IMAGE_PROTOCOL *LoadedImage; + MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode; + + Status =3D gBS->HandleProtocol ( + gImageHandle, + &gEfiLoadedImageProtocolGuid, + (VOID **) &LoadedImage + ); + ASSERT_EFI_ERROR (Status); + EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid); + TempDevicePath =3D DevicePathFromHandle (LoadedImage->DeviceHandle); + ASSERT (TempDevicePath !=3D NULL); + DevicePath =3D AppendDevicePathNode ( + TempDevicePath, + (EFI_DEVICE_PATH_PROTOCOL *) &FileNode + ); + ASSERT (DevicePath !=3D NULL); + Status =3D EfiBootManagerInitializeLoadOption ( + BootOption, + LoadOptionNumberUnassigned, + LoadOptionTypeBoot, + LOAD_OPTION_ACTIVE, + Description, + DevicePath, + NULL, + 0 + ); + if (EFI_ERROR (Status)) { + return Status; + } + FreePool (DevicePath); + return Status; +} + +STATIC +EFI_STATUS +GetPlatformBootOptionsAndKeys ( + OUT UINTN *BootCount, + OUT EFI_BOOT_MANAGER_LOAD_OPTION **BootOptions, + OUT EFI_INPUT_KEY **BootKeys + ) +{ + EFI_GUID *FileGuid; + CHAR16 *PathStr; + EFI_STATUS Status; + UINTN Size; + + Size =3D sizeof (EFI_BOOT_MANAGER_LOAD_OPTION) * HIKEY_BOOT_OPTION_NUM; + *BootOptions =3D (EFI_BOOT_MANAGER_LOAD_OPTION *)AllocateZeroPool (Size); + if (*BootOptions =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "Failed to allocate memory for BootOptions\n")); + return EFI_OUT_OF_RESOURCES; + } + Size =3D sizeof (EFI_INPUT_KEY) * HIKEY_BOOT_OPTION_NUM; + *BootKeys =3D (EFI_INPUT_KEY *)AllocateZeroPool (Size); + if (*BootKeys =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "Failed to allocate memory for BootKeys\n")); + Status =3D EFI_OUT_OF_RESOURCES; + goto Error; + } + + PathStr =3D (CHAR16 *)PcdGetPtr (PcdSdBootDevicePath); + ASSERT (PathStr !=3D NULL); + Status =3D CreatePlatformBootOptionFromPath ( + PathStr, + L"Boot from SD", + &(*BootOptions)[0] + ); + ASSERT_EFI_ERROR (Status); + + PathStr =3D (CHAR16 *)PcdGetPtr (PcdAndroidBootDevicePath); + ASSERT (PathStr !=3D NULL); + Status =3D CreatePlatformBootOptionFromPath ( + PathStr, + L"Grub", + &(*BootOptions)[1] + ); + ASSERT_EFI_ERROR (Status); + + FileGuid =3D PcdGetPtr (PcdAndroidBootFile); + ASSERT (FileGuid !=3D NULL); + Status =3D CreatePlatformBootOptionFromGuid ( + FileGuid, + L"Android Boot", + &(*BootOptions)[2] + ); + ASSERT_EFI_ERROR (Status); + + FileGuid =3D PcdGetPtr (PcdAndroidFastbootFile); + ASSERT (FileGuid !=3D NULL); + Status =3D CreatePlatformBootOptionFromGuid ( + FileGuid, + L"Android Fastboot", + &(*BootOptions)[3] + ); + ASSERT_EFI_ERROR (Status); + (*BootKeys)[3].ScanCode =3D SCAN_NULL; + (*BootKeys)[3].UnicodeChar =3D 'f'; + + *BootCount =3D 4; + + return EFI_SUCCESS; +Error: + FreePool (*BootOptions); + return Status; +} + +PLATFORM_BOOT_MANAGER_PROTOCOL mPlatformBootManager =3D { + GetPlatformBootOptionsAndKeys +}; + EFI_STATUS EFIAPI VirtualKeyboardRegister ( @@ -225,5 +386,15 @@ HiKeyEntryPoint ( EFI_NATIVE_INTERFACE, &mVirtualKeyboard ); + if (EFI_ERROR (Status)) { + return Status; + } + + Status =3D gBS->InstallProtocolInterface ( + &ImageHandle, + &gPlatformBootManagerProtocolGuid, + EFI_NATIVE_INTERFACE, + &mPlatformBootManager + ); return Status; } diff --git a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf b/Platform/Hisi= licon/HiKey/HiKeyDxe/HiKeyDxe.inf index 702fdb1eebf0..e97afab8785a 100644 --- a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf +++ b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf @@ -27,6 +27,7 @@ [Packages] EmbeddedPkg/EmbeddedPkg.dec MdePkg/MdePkg.dec MdeModulePkg/MdeModulePkg.dec + Platform/Hisilicon/HiKey/HiKey.dec =20 [LibraryClasses] BaseMemoryLib @@ -40,15 +41,25 @@ [LibraryClasses] PrintLib SerialPortLib TimerLib + UefiBootManagerLib UefiBootServicesTableLib UefiRuntimeServicesTableLib UefiLib UefiDriverEntryPoint =20 [Protocols] + gEfiDevicePathFromTextProtocolGuid + gEfiLoadedImageProtocolGuid gEmbeddedGpioProtocolGuid + gPlatformBootManagerProtocolGuid gPlatformVirtualKeyboardProtocolGuid =20 +[Pcd] + gHiKeyTokenSpaceGuid.PcdAndroidBootDevicePath + gHiKeyTokenSpaceGuid.PcdAndroidBootFile + gHiKeyTokenSpaceGuid.PcdAndroidFastbootFile + gHiKeyTokenSpaceGuid.PcdSdBootDevicePath + [Guids] gEfiEndOfDxeEventGroupGuid gEfiFileInfoGuid --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel