1/** @file
2  The boot manager reference implementation
3
4Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
5This program and the accompanying materials are licensed and made available under
6the terms and conditions of the BSD License that accompanies this distribution.
7The full text of the license may be found at
8http://opensource.org/licenses/bsd-license.php.
9
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13**/
14
15#ifndef _EFI_BOOT_MANAGER_H_
16#define _EFI_BOOT_MANAGER_H_
17
18#include <Guid/MdeModuleHii.h>
19#include <Guid/GlobalVariable.h>
20
21#include <Protocol/HiiConfigAccess.h>
22#include <Protocol/DevicePathToText.h>
23
24#include <Library/PrintLib.h>
25#include <Library/DebugLib.h>
26#include <Library/BaseMemoryLib.h>
27#include <Library/UefiBootServicesTableLib.h>
28#include <Library/UefiLib.h>
29#include <Library/MemoryAllocationLib.h>
30#include <Library/UefiRuntimeServicesTableLib.h>
31#include <Library/HiiLib.h>
32#include <Library/DevicePathLib.h>
33#include <Library/UefiBootManagerLib.h>
34
35#pragma pack(1)
36
37///
38/// HII specific Vendor Device Path definition.
39///
40typedef struct {
41  VENDOR_DEVICE_PATH             VendorDevicePath;
42  EFI_DEVICE_PATH_PROTOCOL       End;
43} HII_VENDOR_DEVICE_PATH;
44#pragma pack()
45
46//
47// These are defined as the same with vfr file
48//
49#define BOOT_MANAGER_FORMSET_GUID \
50  { \
51  0x847bc3fe, 0xb974, 0x446d, {0x94, 0x49, 0x5a, 0xd5, 0x41, 0x2e, 0x99, 0x3b} \
52  }
53
54#define BOOT_MANAGER_FORM_ID     0x1000
55
56#define LABEL_BOOT_OPTION        0x00
57#define LABEL_BOOT_OPTION_END    0x01
58
59//
60// Variable created with this flag will be "Efi:...."
61//
62#define VAR_FLAG  EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE
63
64//
65// These are the VFR compiler generated data representing our VFR data.
66//
67extern UINT8 BootManagerVfrBin[];
68
69#define BOOT_MANAGER_CALLBACK_DATA_SIGNATURE  SIGNATURE_32 ('B', 'M', 'C', 'B')
70
71typedef struct {
72  UINTN                           Signature;
73
74  //
75  // HII relative handles
76  //
77  EFI_HII_HANDLE                  HiiHandle;
78  EFI_HANDLE                      DriverHandle;
79
80  //
81  // Produced protocols
82  //
83  EFI_HII_CONFIG_ACCESS_PROTOCOL   ConfigAccess;
84} BOOT_MANAGER_CALLBACK_DATA;
85
86/**
87  This call back function is registered with Boot Manager formset.
88  When user selects a boot option, this call back function will
89  be triggered. The boot option is saved for later processing.
90
91
92  @param This            Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
93  @param Action          Specifies the type of action taken by the browser.
94  @param QuestionId      A unique value which is sent to the original exporting driver
95                         so that it can identify the type of data to expect.
96  @param Type            The type of value for the question.
97  @param Value           A pointer to the data being sent to the original exporting driver.
98  @param ActionRequest   On return, points to the action requested by the callback function.
99
100  @retval  EFI_SUCCESS           The callback successfully handled the action.
101  @retval  EFI_INVALID_PARAMETER The setup browser call this function with invalid parameters.
102
103**/
104EFI_STATUS
105EFIAPI
106BootManagerCallback (
107  IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,
108  IN  EFI_BROWSER_ACTION                     Action,
109  IN  EFI_QUESTION_ID                        QuestionId,
110  IN  UINT8                                  Type,
111  IN  EFI_IFR_TYPE_VALUE                     *Value,
112  OUT EFI_BROWSER_ACTION_REQUEST             *ActionRequest
113  );
114
115/**
116  This function allows a caller to extract the current configuration for one
117  or more named elements from the target driver.
118
119
120  @param This            - Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
121  @param Request         - A null-terminated Unicode string in <ConfigRequest> format.
122  @param Progress        - On return, points to a character in the Request string.
123                         Points to the string's null terminator if request was successful.
124                         Points to the most recent '&' before the first failing name/value
125                         pair (or the beginning of the string if the failure is in the
126                         first name/value pair) if the request was not successful.
127  @param Results         - A null-terminated Unicode string in <ConfigAltResp> format which
128                         has all values filled in for the names in the Request string.
129                         String to be allocated by the called function.
130
131  @retval  EFI_SUCCESS            The Results is filled with the requested values.
132  @retval  EFI_OUT_OF_RESOURCES   Not enough memory to store the results.
133  @retval  EFI_INVALID_PARAMETER  Request is NULL, illegal syntax, or unknown name.
134  @retval  EFI_NOT_FOUND          Routing data doesn't match any storage in this driver.
135
136**/
137EFI_STATUS
138EFIAPI
139BootManagerExtractConfig (
140  IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,
141  IN  CONST EFI_STRING                       Request,
142  OUT EFI_STRING                             *Progress,
143  OUT EFI_STRING                             *Results
144  );
145
146/**
147  This function processes the results of changes in configuration.
148
149
150  @param This            - Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
151  @param Configuration   - A null-terminated Unicode string in <ConfigResp> format.
152  @param Progress        - A pointer to a string filled in with the offset of the most
153                         recent '&' before the first failing name/value pair (or the
154                         beginning of the string if the failure is in the first
155                         name/value pair) or the terminating NULL if all was successful.
156
157  @retval  EFI_SUCCESS            The Results is processed successfully.
158  @retval  EFI_INVALID_PARAMETER  Configuration is NULL.
159  @retval  EFI_NOT_FOUND          Routing data doesn't match any storage in this driver.
160
161**/
162EFI_STATUS
163EFIAPI
164BootManagerRouteConfig (
165  IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,
166  IN  CONST EFI_STRING                       Configuration,
167  OUT EFI_STRING                             *Progress
168  );
169
170#endif
171