From patchwork Mon Jun 4 05:44:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 137615 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1084851lji; Sun, 3 Jun 2018 22:44:56 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJf8pblSBC0dWkOKZFso6F/86IBcgSrZ1HqWpVmTU7F5pZ6VuzSdk6WwYqInq6qiDVohEFk X-Received: by 2002:a62:c61d:: with SMTP id m29-v6mr2909001pfg.26.1528091095992; Sun, 03 Jun 2018 22:44:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528091095; cv=none; d=google.com; s=arc-20160816; b=yi+uo29Tz2AROn/nx5e/5Tp1q3+N280Rq4XI6St5tJjBSgHkGA1YdpdxO8NbrMngO8 D/VFVnIfj7RPCDxTUb98GyVDOCQhrAMD9gCNil5hI6EBMd8H8qIf+dU2etkCbfsyXQf9 ijxxyjGfl+YoJAhnUU1xXejJv5YhccFuMVN96rYTbPiP5IzPaOmypNnv6+IIOeU+8m2i CKqed6Fsv9H9UIlSHBiNSPQTwEV5wKjvBNBOXSFCbiKfdodkhYQSM/Nz07L7KNRmLZqV 5yfZek7NZ16cxcQAgFa4NrxpV2iQCRrDR56P3X9s4088mmX2ykpj7Gs9+amnUqcg4D6Y 77sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=taVo0uR8W3bOUB0nyQejvnoQc9/6oU1HJ9OjqbCeZ2U=; b=qi5SJOO/M/3fhov4cU1wjYOwY6Elf9GvlrO4qoeQbmRYddUmJaeOZt5j/PvHdyi27t yqo3sjuQFiJBQQhi21fZh4IbVOaiayViQggylnvTRSmCsAojfkbPyZSdYl8PuEv+pOJ7 dlYM45+VY+wFmuthIiXwMHSXrZnaWAGQwCE6REUgUFyOdvrexYMcFbY3G+8Nhjy2b/1U MErdx+aB6QtjRqh+gCGHCCV/q0GOADHzHhjETqybO8iLvSMMdV5Rc6bsYEHBscgXbXJj PQzlINVpBukUlQByiByWhfTyF005AtCpc9h6hJHPUmImT0pen9nm0FUCjHRvsE6olK7p HgUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=QLXGKKBJ; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id 7-v6si46937601pll.212.2018.06.03.22.44.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Jun 2018 22:44:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=QLXGKKBJ; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 931802096F344; Sun, 3 Jun 2018 22:44:55 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:400e:c01::244; helo=mail-pl0-x244.google.com; envelope-from=haojian.zhuang@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pl0-x244.google.com (mail-pl0-x244.google.com [IPv6:2607:f8b0:400e:c01::244]) (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 B63062096F336 for ; Sun, 3 Jun 2018 22:44:53 -0700 (PDT) Received: by mail-pl0-x244.google.com with SMTP id n10-v6so18978017plp.0 for ; Sun, 03 Jun 2018 22:44:53 -0700 (PDT) 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=FGK05yYtNZ1ivdbsmcXzXBibciViZ61klFgngoVfyn4=; b=QLXGKKBJi9zejzpYpYSlk2g9jHM2UmpqSdEovzZuL1js3tB9TYoaTiL8GeaElzLD4s LBgj+LArjJQv6t5K863e2oOTDQUw1pal0JXjuCyq4TRFQCQ41Xk2GsuCOvGo1yEuPNfN muK2PYwbvDOIR9TmBK4ZYY9K05Py22uNiPR58= 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=FGK05yYtNZ1ivdbsmcXzXBibciViZ61klFgngoVfyn4=; b=V10JQpgR/Iq+P+IVJsZjMwMA+++4haE0JNNgJX2LnAa8XFk9JX9DiN2A7hRzk4oStp vSOk0uGSevVrpYKGxRBhalwuLohRH4+BRpC/f1g0kwfC++FwiD7N1bX7MbdBNK3i2a+6 eoTDNecDzfV0nLx1yN7qKSJRcOq1Ek1jyYf9PonlPYY86XZ14Drd9Hw4x2kzRCYkLBwX 1ex8R9XQ8mznPC863+YXK6RtVcpSwVOgJg3PmpsfasG8litT3jmKQdc7P2k461uobf2G pb4JKy9LE6lBdP6sPQ7ZxWjSbsDml3ji2h/HAlBkgGk4hROSgALHgtNYEqyytb/8at0Y qLTA== X-Gm-Message-State: ALKqPweTdlFWC6yMKV2P2IJI8EyI1eumQIyfj34ZP/Zy9ZP12C/Y1pYw 4NAUoXaNdquJQVrgCwjJSvJeufY6QPs= X-Received: by 2002:a17:902:422:: with SMTP id 31-v6mr21055471ple.320.1528091093082; Sun, 03 Jun 2018 22:44:53 -0700 (PDT) Received: from localhost.localdomain ([64.64.108.95]) by smtp.gmail.com with ESMTPSA id x4-v6sm76669262pfb.99.2018.06.03.22.44.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 03 Jun 2018 22:44:52 -0700 (PDT) From: Haojian Zhuang To: edk2-devel@lists.01.org Date: Mon, 4 Jun 2018 13:44:37 +0800 Message-Id: <1528091078-20889-2-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1528091078-20889-1-git-send-email-haojian.zhuang@linaro.org> References: <1528091078-20889-1-git-send-email-haojian.zhuang@linaro.org> Subject: [edk2] [PATCH v8 edk-platforms 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 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" 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 Acked-by: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Haojian Zhuang --- Platform/Hisilicon/HiKey960/HiKey960.dec | 35 +++++ Platform/Hisilicon/HiKey960/HiKey960.dsc | 6 + Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf | 11 ++ Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h | 20 +-- Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c | 166 ++++++++++++++++++++ 5 files changed, 220 insertions(+), 18 deletions(-) -- 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/Platform/Hisilicon/HiKey960/HiKey960.dec b/Platform/Hisilicon/HiKey960/HiKey960.dec new file mode 100644 index 000000000000..aa5a0caf52e5 --- /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 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] + DEC_SPECIFICATION = 0x0001001a + PACKAGE_NAME = HiKey960 + PACKAGE_GUID = 1892b5b5-d18d-47a3-8fab-e3ae6b4226b0 + PACKAGE_VERSION = 0.1 + +################################################################################ +# +# Include Section - list of Include Paths that are provided by this package. +# 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_DRIVER DXE_SAL_DRIVER UEFI_DRIVER UEFI_APPLICATION +# +################################################################################ +[Guids.common] + gHiKey960TokenSpaceGuid = { 0x99a14446, 0xaad7, 0xe460, {0xb4, 0xe5, 0x1f, 0x79, 0xaa, 0xa4, 0x93, 0xfd } } + +[PcdsFixedAtBuild.common] + gHiKey960TokenSpaceGuid.PcdAndroidBootDevicePath|L""|VOID*|0x00000001 + gHiKey960TokenSpaceGuid.PcdAndroidBootFile|{ 0x36, 0x8b, 0x73, 0x3a, 0xc5, 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 }|VOID*|0x00000003 + gHiKey960TokenSpaceGuid.PcdSdBootDevicePath|L""|VOID*|0x00000004 diff --git a/Platform/Hisilicon/HiKey960/HiKey960.dsc b/Platform/Hisilicon/HiKey960/HiKey960.dsc index 79e68754976d..be13714b9c19 100644 --- a/Platform/Hisilicon/HiKey960/HiKey960.dsc +++ b/Platform/Hisilicon/HiKey960/HiKey960.dsc @@ -129,6 +129,12 @@ [PcdsFixedAtBuild.common] gEmbeddedTokenSpaceGuid.PcdAndroidFastbootUsbVendorId|0x18d1 gEmbeddedTokenSpaceGuid.PcdAndroidFastbootUsbProductId|0xd00d + # + # Android Loader + # + gHiKey960TokenSpaceGuid.PcdAndroidBootDevicePath|L"VenHw(0D51905B-B77E-452A-A2C0-ECA0CC8D514A,00003BFF0000000000)/UFS(0x0,0x3)/HD(7,GPT,D3340696-9B95-4C64-8DF6-E6D4548FBA41,0x12100,0x4000)/\\EFI\\BOOT\\GRUBAA64.EFI" + gHiKey960TokenSpaceGuid.PcdSdBootDevicePath|L"VenHw(0D51905B-B77E-452A-A2C0-ECA0CC8D514A,00F037FF0000000000)/SD(0x0)" + ################################################################################ # # Components Section - list of all EDK II Modules needed by this Platform diff --git a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf index 46a9a5803e3d..54105bdb3c94 100644 --- a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf +++ b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf @@ -25,6 +25,7 @@ [Packages] EmbeddedPkg/EmbeddedPkg.dec MdeModulePkg/MdeModulePkg.dec MdePkg/MdePkg.dec + Platform/Hisilicon/HiKey960/HiKey960.dec Silicon/Hisilicon/Hi3660/Hi3660.dec [LibraryClasses] @@ -34,13 +35,23 @@ [LibraryClasses] IoLib PcdLib TimerLib + UefiBootManagerLib UefiDriverEntryPoint UefiLib [Protocols] + gEfiDevicePathFromTextProtocolGuid + gEfiLoadedImageProtocolGuid gEmbeddedGpioProtocolGuid + gPlatformBootManagerProtocolGuid gPlatformVirtualKeyboardProtocolGuid +[Pcd] + gHiKey960TokenSpaceGuid.PcdAndroidBootDevicePath + gHiKey960TokenSpaceGuid.PcdAndroidBootFile + gHiKey960TokenSpaceGuid.PcdAndroidFastbootFile + gHiKey960TokenSpaceGuid.PcdSdBootDevicePath + [Guids] gEfiEndOfDxeEventGroupGuid diff --git a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h index 211eea55aa54..630aabcb2397 100644 --- a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h +++ b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h @@ -15,30 +15,14 @@ #ifndef __HIKEY960DXE_H__ #define __HIKEY960DXE_H__ -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - #define ADB_REBOOT_ADDRESS 0x32100000 #define ADB_REBOOT_BOOTLOADER 0x77665500 #define ADB_REBOOT_NONE 0x77665501 #define DETECT_SW_FASTBOOT 68 // GPIO8_4 +#define HIKEY960_BOOT_OPTION_NUM 4 + enum { BOOT_MODE_RECOVERY = 0, BOOT_MODE_MASK = 1, diff --git a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c index b205be97db29..47ec879861bd 100644 --- a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c +++ b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c @@ -18,14 +18,24 @@ #include #include +#include #include +#include #include +#include #include #include #include +#include #include #include +#include +#include +#include +#include +#include + #include "HiKey960Dxe.h" STATIC EMBEDDED_GPIO *mGpio; @@ -172,6 +182,152 @@ OnEndOfDxe ( } } +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 = (EFI_DEVICE_PATH *)ConvertTextToDevicePath (PathStr); + ASSERT (DevicePath != NULL); + Status = EfiBootManagerInitializeLoadOption ( + BootOption, + LoadOptionNumberUnassigned, + LoadOptionTypeBoot, + LOAD_OPTION_ACTIVE, + Description, + DevicePath, + NULL, + 0 + ); + 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 = gBS->HandleProtocol ( + gImageHandle, + &gEfiLoadedImageProtocolGuid, + (VOID **) &LoadedImage + ); + ASSERT_EFI_ERROR (Status); + EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid); + TempDevicePath = DevicePathFromHandle (LoadedImage->DeviceHandle); + ASSERT (TempDevicePath != NULL); + DevicePath = AppendDevicePathNode ( + TempDevicePath, + (EFI_DEVICE_PATH_PROTOCOL *) &FileNode + ); + ASSERT (DevicePath != NULL); + Status = EfiBootManagerInitializeLoadOption ( + BootOption, + LoadOptionNumberUnassigned, + LoadOptionTypeBoot, + LOAD_OPTION_ACTIVE, + Description, + DevicePath, + NULL, + 0 + ); + 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 = sizeof (EFI_BOOT_MANAGER_LOAD_OPTION) * HIKEY960_BOOT_OPTION_NUM; + *BootOptions = (EFI_BOOT_MANAGER_LOAD_OPTION *)AllocateZeroPool (Size); + if (*BootOptions == NULL) { + DEBUG ((DEBUG_ERROR, "Failed to allocate memory for BootOptions\n")); + return EFI_OUT_OF_RESOURCES; + } + Size = sizeof (EFI_INPUT_KEY) * HIKEY960_BOOT_OPTION_NUM; + *BootKeys = (EFI_INPUT_KEY *)AllocateZeroPool (Size); + if (*BootKeys == NULL) { + DEBUG ((DEBUG_ERROR, "Failed to allocate memory for BootKeys\n")); + Status = EFI_OUT_OF_RESOURCES; + goto Error; + } + + PathStr = (CHAR16 *)PcdGetPtr (PcdSdBootDevicePath); + ASSERT (PathStr != NULL); + Status = CreatePlatformBootOptionFromPath ( + PathStr, + L"Boot from SD", + &(*BootOptions)[0] + ); + ASSERT_EFI_ERROR (Status); + + PathStr = (CHAR16 *)PcdGetPtr (PcdAndroidBootDevicePath); + ASSERT (PathStr != NULL); + Status = CreatePlatformBootOptionFromPath ( + PathStr, + L"Grub", + &(*BootOptions)[1] + ); + ASSERT_EFI_ERROR (Status); + + FileGuid = PcdGetPtr (PcdAndroidBootFile); + ASSERT (FileGuid != NULL); + Status = CreatePlatformBootOptionFromGuid ( + FileGuid, + L"Android Boot", + &(*BootOptions)[2] + ); + ASSERT_EFI_ERROR (Status); + + FileGuid = PcdGetPtr (PcdAndroidFastbootFile); + ASSERT (FileGuid != NULL); + Status = CreatePlatformBootOptionFromGuid ( + FileGuid, + L"Android Fastboot", + &(*BootOptions)[3] + ); + ASSERT_EFI_ERROR (Status); + (*BootKeys)[3].ScanCode = SCAN_NULL; + (*BootKeys)[3].UnicodeChar = 'f'; + + *BootCount = 4; + + return EFI_SUCCESS; +Error: + FreePool (*BootOptions); + return Status; +} + +PLATFORM_BOOT_MANAGER_PROTOCOL mPlatformBootManager = { + GetPlatformBootOptionsAndKeys +}; + EFI_STATUS EFIAPI VirtualKeyboardRegister ( @@ -297,5 +453,15 @@ HiKey960EntryPoint ( EFI_NATIVE_INTERFACE, &mVirtualKeyboard ); + if (EFI_ERROR (Status)) { + return Status; + } + + Status = gBS->InstallProtocolInterface ( + &ImageHandle, + &gPlatformBootManagerProtocolGuid, + EFI_NATIVE_INTERFACE, + &mPlatformBootManager + ); return Status; } From patchwork Mon Jun 4 05:44:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 137616 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1084888lji; Sun, 3 Jun 2018 22:44:59 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKMlW9aq4Zxp8B8hSEzNtOFlqlZRaeU4rEz/rUO5edNwaqkRl5qarlYPKph80JhNnyB1J0w X-Received: by 2002:a63:63c4:: with SMTP id x187-v6mr16365893pgb.9.1528091099204; Sun, 03 Jun 2018 22:44:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528091099; cv=none; d=google.com; s=arc-20160816; b=z54aBqh7tsZtWb2mefnFTaHyKK8KWpiw7ZWFOITd7887d0PX0gCsLaRH1b69nHTxkW NrYT6bJmIPuimz6zn8H78bQHn2gSs3n4GbBQHLageD4EiUkR6RW+IcacZXetG8MfYXYB Fbj1EwWDImr1V2y2ApUw6HAsPSFx48YMPaxEFDivERwz6U1oelmHQb8tKBlEssxRedBT 9QOAOR5cxI+S7xSV2VCAWGcePJqCqcWqn5gH0xBtf7ovtEgqMiuH1qlxhw+Irl9evSMT Ie9O9A+FgQfUG+oOYJt08ZlnIoFZHI13G6JWavoqtZL3rPcVngG8InjUurCurJaXggQq 7V/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=FBoq6yJjGDa/8YLUfRsmAQELD8Aiu5flPvbgjUnTDmw=; b=GpCRGL9aG3/UzfLHIaHsDr2Bjsz7tICVPdeI7WZDWzryop6ZUGYxmd/vXbUu/V9kBe WiJHRvkRpfJ04iGodjhhzFUbwv8T8QEJ5VtkIJQKv0asOjhTZ/CallzxPDsNE+3RYhdr ZORhBHYbG2tHKopMDKqQK3m/ja//ByPxcSOr5q24zIv2OvNp2qE+2+uylvO7a16ih5o9 9WCNM4XXCTGhLZcyUWSg6jV8UAyv3K9zFmNv/dlVtnai/36SIauDrqULtbQtN3e4ee1h bO46pws3iOXOheTm8ZjB2ITxXxlCoz9a+BkjBFxz3qQZ8EeQHAlPonF7Hcn33R859s3W hQsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=GhREkBPQ; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id a185-v6si35923506pgc.586.2018.06.03.22.44.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Jun 2018 22:44:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=GhREkBPQ; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id C7DCE2096F352; Sun, 3 Jun 2018 22:44:58 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:400e:c01::243; helo=mail-pl0-x243.google.com; envelope-from=haojian.zhuang@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pl0-x243.google.com (mail-pl0-x243.google.com [IPv6:2607:f8b0:400e:c01::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 C8BB22096F349 for ; Sun, 3 Jun 2018 22:44:57 -0700 (PDT) Received: by mail-pl0-x243.google.com with SMTP id c23-v6so7686124plz.12 for ; Sun, 03 Jun 2018 22:44:57 -0700 (PDT) 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=ua+k/msnerWPSGGaQA9cF8dogw6N25laESv/S4QnTIk=; b=GhREkBPQ5xFZl0Hx9I1JonwjI1PLzLSsgSGkHkMhS0KiWbfPpdd1ihe6JWssR3+X30 R/JKqNlLNmV2G+g9TSn9D+3KkBRm9k3IJ/qMMKQLF6RCdgI1/DnbsxWLxbYu3Xd8+u3P Xn2BYZ3dNeTMf+0qG+1igO9NX/4rMTA9vCVJc= 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=ua+k/msnerWPSGGaQA9cF8dogw6N25laESv/S4QnTIk=; b=qp5nO8EM2Rwr2Jpyr1BBollSh9jRhxagcx8jXcCFmoq/qM+douOMYwt9KYHKUEzhGU sEcxqx8Ez9my4pRXARWrbGmZ3gt03PCRdljXvqW8acduQVlFzUADyJ4+BYYNZIfq5pKp l3Ke2HtST7khFj30fTl0mjuH1Zb7w/0REVGwS2kIImzMIbeB+zNAW3bbozmvPFWBKx9c /wGTYef/6crhxQlZtTa2Z2DYiq/0uHFjBprYSpRhgJHA8WZkSZyzq2JrZEoN7b85jvev SNNMWHnKuSb1UfEVd9hira2GVIhuw56RtoT0vV2DmSlKmJNy8T1ioh7Jgj1EneDV4NUH irAw== X-Gm-Message-State: APt69E1HJWAx0lZdPyuPPoR5uaE8d1NrIJmzczSk9H1P1+cW+d3kQgy4 b8w9oNSrtGYcwM8lMcqyHsl70co+4r8= X-Received: by 2002:a17:902:5409:: with SMTP id d9-v6mr9012032pli.0.1528091097009; Sun, 03 Jun 2018 22:44:57 -0700 (PDT) Received: from localhost.localdomain ([64.64.108.95]) by smtp.gmail.com with ESMTPSA id x4-v6sm76669262pfb.99.2018.06.03.22.44.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 03 Jun 2018 22:44:55 -0700 (PDT) From: Haojian Zhuang To: edk2-devel@lists.01.org Date: Mon, 4 Jun 2018 13:44:38 +0800 Message-Id: <1528091078-20889-3-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1528091078-20889-1-git-send-email-haojian.zhuang@linaro.org> References: <1528091078-20889-1-git-send-email-haojian.zhuang@linaro.org> Subject: [edk2] [PATCH v8 edk-platforms 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 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" 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 Acked-by: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Haojian Zhuang --- Platform/Hisilicon/HiKey/HiKey.dec | 10 +- Platform/Hisilicon/HiKey/HiKey.dsc | 7 + Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf | 11 ++ Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.h | 2 + Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c | 164 ++++++++++++++++++++ 5 files changed, 190 insertions(+), 4 deletions(-) -- 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/Platform/Hisilicon/HiKey/HiKey.dec b/Platform/Hisilicon/HiKey/HiKey.dec index 537138eb45a1..d5de1a165910 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 BSD License @@ -11,7 +11,7 @@ # [Defines] - DEC_SPECIFICATION = 0x00010019 + DEC_SPECIFICATION = 0x0001001a PACKAGE_NAME = HiKey PACKAGE_GUID = d6db414d-ea67-4312-94d5-9c9e5b224d25 PACKAGE_VERSION = 0.1 @@ -32,5 +32,7 @@ [Guids.common] gHiKeyTokenSpaceGuid = { 0x91148425, 0xcdd2, 0x4830, { 0x8b, 0xd0, 0xc6, 0x1c, 0x6d, 0xea, 0x36, 0x21 } } [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*|0x00000002 + gHiKeyTokenSpaceGuid.PcdAndroidFastbootFile|{ 0x2a, 0x50, 0x88, 0x95, 0x70, 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 + # + # Android Loader + # + gHiKeyTokenSpaceGuid.PcdAndroidBootDevicePath|L"VenHw(0D51905B-B77E-452A-A2C0-ECA0CC8D514A,00D023F70000000000)/eMMC(0x0)/Ctrl(0x0)/HD(6,GPT,5C0F213C-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.inf b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf index 41aa7f8081ed..4c4644a0fe51 100644 --- a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf +++ b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf @@ -26,18 +26,29 @@ [Packages] EmbeddedPkg/EmbeddedPkg.dec MdeModulePkg/MdeModulePkg.dec MdePkg/MdePkg.dec + Platform/Hisilicon/HiKey/HiKey.dec [LibraryClasses] CacheMaintenanceLib DebugLib IoLib + UefiBootManagerLib UefiLib UefiDriverEntryPoint [Protocols] + gEfiDevicePathFromTextProtocolGuid + gEfiLoadedImageProtocolGuid gEmbeddedGpioProtocolGuid + gPlatformBootManagerProtocolGuid gPlatformVirtualKeyboardProtocolGuid +[Pcd] + gHiKeyTokenSpaceGuid.PcdAndroidBootDevicePath + gHiKeyTokenSpaceGuid.PcdAndroidBootFile + gHiKeyTokenSpaceGuid.PcdAndroidFastbootFile + gHiKeyTokenSpaceGuid.PcdSdBootDevicePath + [Guids] gEfiEndOfDxeEventGroupGuid diff --git a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.h b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.h index 104048135f27..0ababfa32eab 100644 --- a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.h +++ b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.h @@ -21,4 +21,6 @@ #define ADB_REBOOT_BOOTLOADER 0x77665500 #define ADB_REBOOT_NONE 0x77665501 +#define HIKEY_BOOT_OPTION_NUM 4 + #endif /* __HIKEYDXE_H__ */ diff --git a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c index 832615f9cc80..2162b68529bd 100644 --- a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c +++ b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c @@ -14,11 +14,19 @@ #include #include +#include #include +#include +#include +#include #include #include +#include +#include #include +#include +#include #include #include @@ -99,6 +107,152 @@ HiKeyInitPeripherals ( return EFI_SUCCESS; } +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 = (EFI_DEVICE_PATH *)ConvertTextToDevicePath (PathStr); + ASSERT (DevicePath != NULL); + Status = EfiBootManagerInitializeLoadOption ( + BootOption, + LoadOptionNumberUnassigned, + LoadOptionTypeBoot, + LOAD_OPTION_ACTIVE, + Description, + DevicePath, + NULL, + 0 + ); + 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 = gBS->HandleProtocol ( + gImageHandle, + &gEfiLoadedImageProtocolGuid, + (VOID **) &LoadedImage + ); + ASSERT_EFI_ERROR (Status); + EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid); + TempDevicePath = DevicePathFromHandle (LoadedImage->DeviceHandle); + ASSERT (TempDevicePath != NULL); + DevicePath = AppendDevicePathNode ( + TempDevicePath, + (EFI_DEVICE_PATH_PROTOCOL *) &FileNode + ); + ASSERT (DevicePath != NULL); + Status = EfiBootManagerInitializeLoadOption ( + BootOption, + LoadOptionNumberUnassigned, + LoadOptionTypeBoot, + LOAD_OPTION_ACTIVE, + Description, + DevicePath, + NULL, + 0 + ); + 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 = sizeof (EFI_BOOT_MANAGER_LOAD_OPTION) * HIKEY_BOOT_OPTION_NUM; + *BootOptions = (EFI_BOOT_MANAGER_LOAD_OPTION *)AllocateZeroPool (Size); + if (*BootOptions == NULL) { + DEBUG ((DEBUG_ERROR, "Failed to allocate memory for BootOptions\n")); + return EFI_OUT_OF_RESOURCES; + } + Size = sizeof (EFI_INPUT_KEY) * HIKEY_BOOT_OPTION_NUM; + *BootKeys = (EFI_INPUT_KEY *)AllocateZeroPool (Size); + if (*BootKeys == NULL) { + DEBUG ((DEBUG_ERROR, "Failed to allocate memory for BootKeys\n")); + Status = EFI_OUT_OF_RESOURCES; + goto Error; + } + + PathStr = (CHAR16 *)PcdGetPtr (PcdSdBootDevicePath); + ASSERT (PathStr != NULL); + Status = CreatePlatformBootOptionFromPath ( + PathStr, + L"Boot from SD", + &(*BootOptions)[0] + ); + ASSERT_EFI_ERROR (Status); + + PathStr = (CHAR16 *)PcdGetPtr (PcdAndroidBootDevicePath); + ASSERT (PathStr != NULL); + Status = CreatePlatformBootOptionFromPath ( + PathStr, + L"Grub", + &(*BootOptions)[1] + ); + ASSERT_EFI_ERROR (Status); + + FileGuid = PcdGetPtr (PcdAndroidBootFile); + ASSERT (FileGuid != NULL); + Status = CreatePlatformBootOptionFromGuid ( + FileGuid, + L"Android Boot", + &(*BootOptions)[2] + ); + ASSERT_EFI_ERROR (Status); + + FileGuid = PcdGetPtr (PcdAndroidFastbootFile); + ASSERT (FileGuid != NULL); + Status = CreatePlatformBootOptionFromGuid ( + FileGuid, + L"Android Fastboot", + &(*BootOptions)[3] + ); + ASSERT_EFI_ERROR (Status); + (*BootKeys)[3].ScanCode = SCAN_NULL; + (*BootKeys)[3].UnicodeChar = 'f'; + + *BootCount = 4; + + return EFI_SUCCESS; +Error: + FreePool (*BootOptions); + return Status; +} + +PLATFORM_BOOT_MANAGER_PROTOCOL mPlatformBootManager = { + GetPlatformBootOptionsAndKeys +}; + EFI_STATUS EFIAPI VirtualKeyboardRegister ( @@ -203,5 +357,15 @@ HiKeyEntryPoint ( EFI_NATIVE_INTERFACE, &mVirtualKeyboard ); + if (EFI_ERROR (Status)) { + return Status; + } + + Status = gBS->InstallProtocolInterface ( + &ImageHandle, + &gPlatformBootManagerProtocolGuid, + EFI_NATIVE_INTERFACE, + &mPlatformBootManager + ); return Status; }