From nobody Fri Nov 1 04:30:11 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 152446457715493.63745209699982; Sun, 22 Apr 2018 23:22:57 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 281962251212C; Sun, 22 Apr 2018 23:22:56 -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 6D3D9226CD635 for ; Sun, 22 Apr 2018 23:22:55 -0700 (PDT) Received: by mail-pf0-x242.google.com with SMTP id l27so8387364pfk.12 for ; Sun, 22 Apr 2018 23:22:55 -0700 (PDT) Received: from localhost.localdomain ([64.64.108.101]) by smtp.gmail.com with ESMTPSA id t80sm9373430pfg.0.2018.04.22.23.22.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 22 Apr 2018 23:22:53 -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=B6bGL/3aBTVR5dyBUd+uoKlvOCnCinEFBZsA8Hi/Eqc=; b=bHHkGCCRe69oBy26rCyZzx0ez9jgCice0CqnvsVZ7VtyfJ0Xk6wxyfDsi3n3NSeCFk znQjQgOdJfz5lyhUhsd72/ne1UJqYnS6r8ju1e5P8AToyaDikOe58iHUxM+THS7OeT0C wHD5zU+Hj3pht/tMiaWMFWbZuAHspX9uhJqAI= 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=B6bGL/3aBTVR5dyBUd+uoKlvOCnCinEFBZsA8Hi/Eqc=; b=coO2QYtnTWN+Zc/z60m9n0nJiQIpP1UZOkxg6vvwn4xMyjvN3YrtfqWNG1Y2QEpkPn 4kCiJwOjYMyTo1l5taabJWURXrzst1tRyoAGXGWMptlPYJJYFrSYlmguMHE98o6bBOkh MptoQSBSb/P7LwVttA/6rA4Eic7Tl9wJgM24OIE6LyIQCofrewPYJdgzffBS4mBN9J7J ZUhaevuGwIKSLVEzX9fCRWq75tLfvVq+XdCtBcGsjgxLZmRGZySvHZnYe5d+e7Rse3bd uP3gEWUAF4lqI075EjeTxc2O7vvdx4W8OkQqSHezmqGfx995xI31e7MWnl4ZGgHjr8j+ 695Q== X-Gm-Message-State: ALQs6tDOwDOzyPZhSKfop5OL5Wlt+u4JoKPBzEvimEBpMtLZmjkIOR21 yFOhiomyvnEhhWpf2rbute2jOOWtACI= X-Google-Smtp-Source: AIpwx48CC+ruh2DSzFSRmbnB1Uzi7MFny539UPAn2JaQukt+zxVmGttQqoCchAO6EcQJ6LenhQjnoQ== X-Received: by 10.99.117.71 with SMTP id f7mr6866575pgn.204.1524464574780; Sun, 22 Apr 2018 23:22:54 -0700 (PDT) From: Haojian Zhuang To: edk2-devel@lists.01.org Date: Mon, 23 Apr 2018 14:22:39 +0800 Message-Id: <1524464559-14549-3-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1524464559-14549-1-git-send-email-haojian.zhuang@linaro.org> References: <1524464559-14549-1-git-send-email-haojian.zhuang@linaro.org> Subject: [edk2] [PATCH edk2-platforms v4 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 --- Platform/Hisilicon/HiKey/HiKey.dec | 8 +- Platform/Hisilicon/HiKey/HiKey.dsc | 7 + Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c | 181 +++++++++++++++++++++= ++++ Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf | 11 ++ 4 files changed, 204 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..5b5dc48a693a 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)" + 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..6273bc0b213a 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,168 @@ HiKeyInitPeripherals ( return EFI_SUCCESS; } =20 +STATIC +EFI_STATUS +GetPlatformBootOptionsAndKeys ( + OUT UINTN *BootCount, + OUT EFI_BOOT_MANAGER_LOAD_OPTION **BootOptions, + OUT EFI_INPUT_KEY **BootKeys + ) +{ + EFI_DEVICE_PATH *DevicePath; + EFI_DEVICE_PATH *FileDevicePath; + EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL *DPProtocol; + FILEPATH_DEVICE_PATH *FilePath; + EFI_GUID *FileGuid; + EFI_LOADED_IMAGE_PROTOCOL *LoadedImage; + MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode; + CHAR16 *PathStr; + EFI_STATUS Status; + UINTN Size; + + if ((BootCount =3D=3D NULL) || (BootOptions =3D=3D NULL) || (BootKeys = =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + 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_BUFFER_TOO_SMALL; + } + 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")); + FreePool (*BootOptions); + return EFI_BUFFER_TOO_SMALL; + } + + PathStr =3D (CHAR16 *)PcdGetPtr (PcdSdBootDevicePath); + ASSERT (PathStr !=3D NULL); + Status =3D gBS->LocateProtocol (&gEfiDevicePathFromTextProtocolGuid, + NULL, + (VOID **)&DPProtocol + ); + ASSERT_EFI_ERROR (Status); + DevicePath =3D (EFI_DEVICE_PATH *)DPProtocol->ConvertTextToDevicePath (P= athStr); + ASSERT (DevicePath !=3D NULL); + Status =3D EfiBootManagerInitializeLoadOption ( + &(*BootOptions)[0], + LoadOptionNumberUnassigned, + LoadOptionTypeBoot, + LOAD_OPTION_ACTIVE, + L"Boot from SD", + DevicePath, + NULL, + 0 + ); + ASSERT_EFI_ERROR (Status); + FreePool (DevicePath); + + PathStr =3D (CHAR16 *)PcdGetPtr (PcdAndroidBootDevicePath); + ASSERT (PathStr !=3D NULL); + Status =3D gBS->LocateProtocol (&gEfiDevicePathFromTextProtocolGuid, + NULL, + (VOID **)&DPProtocol + ); + ASSERT_EFI_ERROR (Status); + DevicePath =3D (EFI_DEVICE_PATH *)DPProtocol->ConvertTextToDevicePath (P= athStr); + ASSERT (DevicePath !=3D NULL); + Size =3D StrSize (GRUB_FILE_NAME); + FileDevicePath =3D AllocatePool (Size + SIZE_OF_FILEPATH_DEVICE_PATH + E= ND_DEVICE_PATH_LENGTH); + if (FileDevicePath !=3D NULL) { + FilePath =3D (FILEPATH_DEVICE_PATH *) FileDevicePath; + FilePath->Header.Type =3D MEDIA_DEVICE_PATH; + FilePath->Header.SubType =3D MEDIA_FILEPATH_DP; + CopyMem (&FilePath->PathName, GRUB_FILE_NAME, Size); + SetDevicePathNodeLength (&FilePath->Header, Size + SIZE_OF_FILEPATH_DE= VICE_PATH); + SetDevicePathEndNode (NextDevicePathNode (&FilePath->Header)); + + DevicePath =3D AppendDevicePath (DevicePath, FileDevicePath); + FreePool (FileDevicePath); + } + Status =3D EfiBootManagerInitializeLoadOption ( + &(*BootOptions)[1], + LoadOptionNumberUnassigned, + LoadOptionTypeBoot, + LOAD_OPTION_ACTIVE, + L"Grub", + DevicePath, + NULL, + 0 + ); + ASSERT_EFI_ERROR (Status); + FreePool (DevicePath); + + FileGuid =3D PcdGetPtr (PcdAndroidBootFile); + ASSERT (FileGuid !=3D NULL); + Status =3D gBS->HandleProtocol ( + gImageHandle, + &gEfiLoadedImageProtocolGuid, + (VOID **) &LoadedImage + ); + ASSERT_EFI_ERROR (Status); + EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid); + DevicePath =3D DevicePathFromHandle (LoadedImage->DeviceHandle); + ASSERT (DevicePath !=3D NULL); + DevicePath =3D AppendDevicePathNode ( + DevicePath, + (EFI_DEVICE_PATH_PROTOCOL *) &FileNode + ); + ASSERT (DevicePath !=3D NULL); + Status =3D EfiBootManagerInitializeLoadOption ( + &(*BootOptions)[2], + LoadOptionNumberUnassigned, + LoadOptionTypeBoot, + LOAD_OPTION_ACTIVE, + L"Android Boot", + DevicePath, + NULL, + 0 + ); + ASSERT_EFI_ERROR (Status); + FreePool (DevicePath); + + FileGuid =3D PcdGetPtr (PcdAndroidFastbootFile); + ASSERT (FileGuid !=3D NULL); + Status =3D gBS->HandleProtocol ( + gImageHandle, + &gEfiLoadedImageProtocolGuid, + (VOID **) &LoadedImage + ); + ASSERT_EFI_ERROR (Status); + EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid); + DevicePath =3D DevicePathFromHandle (LoadedImage->DeviceHandle); + ASSERT (DevicePath !=3D NULL); + DevicePath =3D AppendDevicePathNode ( + DevicePath, + (EFI_DEVICE_PATH_PROTOCOL *) &FileNode + ); + ASSERT (DevicePath !=3D NULL); + Status =3D EfiBootManagerInitializeLoadOption ( + &(*BootOptions)[3], + LoadOptionNumberUnassigned, + LoadOptionTypeBoot, + LOAD_OPTION_ACTIVE, + L"Android Fastboot", + DevicePath, + NULL, + 0 + ); + ASSERT_EFI_ERROR (Status); + FreePool (DevicePath); + (*BootKeys)[3].ScanCode =3D SCAN_NULL; + (*BootKeys)[3].UnicodeChar =3D 'f'; + + *BootCount =3D 4; + + return EFI_SUCCESS; +} + +PLATFORM_BOOT_MANAGER_PROTOCOL mPlatformBootManager =3D { + GetPlatformBootOptionsAndKeys +}; + EFI_STATUS EFIAPI VirtualKeyboardRegister ( @@ -225,5 +396,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