<commit_before>/** @file
*
*  Copyright (c) 2015, Linaro Ltd. All rights reserved.
*  Copyright (c) 2015, Hisilicon 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.
*
**/

#include <Library/BaseMemoryLib.h>
#include <Library/BdsLib.h>
#include <Library/DevicePathLib.h>
#include <Library/IoLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/PrintLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>

#include <Protocol/DevicePathFromText.h>
#include <Protocol/DevicePathToText.h>
#include <Protocol/EmbeddedGpio.h>

#include <Guid/Fdt.h>
#include <Guid/EventGroup.h>
#include <Guid/GlobalVariable.h>
#include <Guid/HiKeyVariable.h>
#include <Guid/VariableFormat.h>

#include "HiKeyDxeInternal.h"

#define MAX_BOOT_ENTRIES         16
// Jumper on pin5-6 of J15 determines whether boot to fastboot
#define DETECT_J15_FASTBOOT      24    // GPIO 3_0

#define USER_LED1                32    // GPIO 4_0
#define USER_LED2                33    // GPIO 4_1
#define USER_LED3                34    // GPIO 4_2
#define USER_LED4                35    // GPIO 4_3

struct HiKeyBootEntry {
  CHAR16    *Path;
  CHAR16    *Args;
  CHAR16    *Description;
  UINT16     LoadType;
};

STATIC CONST BOOLEAN mIsEndOfDxeEvent = TRUE;
STATIC UINT16 *mBootOrder = NULL;
STATIC UINT16 mBootCount = 0;
STATIC UINT16 mBootIndex = 0;

#define HIKEY_BOOT_ENTRY_FASTBOOT          0
#define HIKEY_BOOT_ENTRY_BOOT_EMMC         1    /* boot from eMMC */
#define HIKEY_BOOT_ENTRY_BOOT_SD           2    /* boot from SD card */

STATIC struct HiKeyBootEntry Entries[] = {
  [HIKEY_BOOT_ENTRY_FASTBOOT] = {
    L"FvFile(9588502a-5370-11e3-8631-d7c5951364c8)",
    //L"VenHw(B549F005-4BD4-4020-A0CB-06F42BDA68C3)/HD(6,GPT,5C0F213C-17E1-4149-88C8-8B50FB4EC70E,0x7000,0x20000)/\\EFI\\BOOT\\FASTBOOT.EFI",
    NULL,
    L"fastboot",
    LOAD_OPTION_CATEGORY_APP
  },
  [HIKEY_BOOT_ENTRY_BOOT_EMMC] = {
    L"VenHw(B549F005-4BD4-4020-A0CB-06F42BDA68C3)/HD(6,GPT,5C0F213C-17E1-4149-88C8-8B50FB4EC70E,0x7000,0x20000)/\\EFI\\BOOT\\GRUBAA64.EFI",
    NULL,
    L"boot from eMMC",
    LOAD_OPTION_CATEGORY_APP
  },
  [HIKEY_BOOT_ENTRY_BOOT_SD] = {
    L"VenHw(594BFE73-5E18-4F12-8119-19DB8C5FC849)/HD(1,MBR,0x00000000,0x3F,0x21FC0)/Image",
    L"dtb=hi6220-hikey.dtb console=ttyAMA3,115200 earlycon=pl011,0xf7113000 root=/dev/mmcblk1p2 rw rootwait initrd=initrd.img efi=noruntime",
    L"boot from SD card",
    LOAD_OPTION_CATEGORY_BOOT
  }
};

STATIC
BOOLEAN
EFIAPI
HiKeyVerifyBootEntry (
  IN CHAR16          *BootVariableName,
  IN CHAR16          *BootDevicePathText,
  IN CHAR16          *BootArgs,
  IN CHAR16          *BootDescription,
  IN UINT16           LoadOptionAttr
  )
{
  EFI_DEVICE_PATH_TO_TEXT_PROTOCOL   *DevicePathToTextProtocol;
  CHAR16                             *DevicePathText;
  UINTN                               EfiLoadOptionSize;<commit_msg>HiKey: revert the grub path<commit_after>/** @file
*
*  Copyright (c) 2015, Linaro Ltd. All rights reserved.
*  Copyright (c) 2015, Hisilicon 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.
*
**/

#include <Library/BaseMemoryLib.h>
#include <Library/BdsLib.h>
#include <Library/DevicePathLib.h>
#include <Library/IoLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/PrintLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>

#include <Protocol/DevicePathFromText.h>
#include <Protocol/DevicePathToText.h>
#include <Protocol/EmbeddedGpio.h>

#include <Guid/Fdt.h>
#include <Guid/EventGroup.h>
#include <Guid/GlobalVariable.h>
#include <Guid/HiKeyVariable.h>
#include <Guid/VariableFormat.h>

#include "HiKeyDxeInternal.h"

#define MAX_BOOT_ENTRIES         16
// Jumper on pin5-6 of J15 determines whether boot to fastboot
#define DETECT_J15_FASTBOOT      24    // GPIO 3_0

#define USER_LED1                32    // GPIO 4_0
#define USER_LED2                33    // GPIO 4_1
#define USER_LED3                34    // GPIO 4_2
#define USER_LED4                35    // GPIO 4_3

struct HiKeyBootEntry {
  CHAR16    *Path;
  CHAR16    *Args;
  CHAR16    *Description;
  UINT16     LoadType;
};

STATIC CONST BOOLEAN mIsEndOfDxeEvent = TRUE;
STATIC UINT16 *mBootOrder = NULL;
STATIC UINT16 mBootCount = 0;
STATIC UINT16 mBootIndex = 0;

#define HIKEY_BOOT_ENTRY_FASTBOOT          0
#define HIKEY_BOOT_ENTRY_BOOT_EMMC         1    /* boot from eMMC */
#define HIKEY_BOOT_ENTRY_BOOT_SD           2    /* boot from SD card */

STATIC struct HiKeyBootEntry Entries[] = {
  [HIKEY_BOOT_ENTRY_FASTBOOT] = {
    L"FvFile(9588502a-5370-11e3-8631-d7c5951364c8)",
    //L"VenHw(B549F005-4BD4-4020-A0CB-06F42BDA68C3)/HD(6,GPT,5C0F213C-17E1-4149-88C8-8B50FB4EC70E,0x7000,0x20000)/FASTBOOT.EFI",
    NULL,
    L"fastboot",
    LOAD_OPTION_CATEGORY_APP
  },
  [HIKEY_BOOT_ENTRY_BOOT_EMMC] = {
    L"VenHw(B549F005-4BD4-4020-A0CB-06F42BDA68C3)/HD(6,GPT,5C0F213C-17E1-4149-88C8-8B50FB4EC70E,0x7000,0x20000)/GRUBAA64.EFI",
    NULL,
    L"boot from eMMC",
    LOAD_OPTION_CATEGORY_APP
  },
  [HIKEY_BOOT_ENTRY_BOOT_SD] = {
    L"VenHw(594BFE73-5E18-4F12-8119-19DB8C5FC849)/HD(1,MBR,0x00000000,0x3F,0x21FC0)/Image",
    L"dtb=hi6220-hikey.dtb console=ttyAMA3,115200 earlycon=pl011,0xf7113000 root=/dev/mmcblk1p2 rw rootwait initrd=initrd.img efi=noruntime",
    L"boot from SD card",
    LOAD_OPTION_CATEGORY_BOOT
  }
};

STATIC
BOOLEAN
EFIAPI
HiKeyVerifyBootEntry (
  IN CHAR16          *BootVariableName,
  IN CHAR16          *BootDevicePathText,
  IN CHAR16          *BootArgs,
  IN CHAR16          *BootDescription,
  IN UINT16           LoadOptionAttr
  )
{
  EFI_DEVICE_PATH_TO_TEXT_PROTOCOL   *DevicePathToTextProtocol;
  CHAR16                             *DevicePathText;
  UINTN                               EfiLoadOptionSize;
{'fraction_non_alphanumeric': 0.09897559505875264, 'fraction_numerical': 0.08074721301596867, 'mean_word_length': 3.3764007910349374, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '525047', 'n_tokens_mistral': 2859, 'n_tokens_neox': 2557, 'n_words': 505}