浏览代码

[efi] Add support for HII

Some EFI platforms expect us to provide an HII interface to display
information about the driver.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 13 年前
父节点
当前提交
1c67e20261

+ 37
- 0
src/include/ipxe/efi/Guid/HiiPlatformSetupFormset.h 查看文件

@@ -0,0 +1,37 @@
1
+/** @file
2
+  GUID indicates that the form set contains forms designed to be used
3
+  for platform configuration and this form set will be displayed.
4
+
5
+Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
6
+This program and the accompanying materials are licensed and made available under
7
+the terms and conditions of the BSD License that accompanies this distribution.
8
+The full text of the license may be found at
9
+http://opensource.org/licenses/bsd-license.php.
10
+
11
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
+
14
+  @par Revision Reference:
15
+  GUID defined in UEFI 2.1.
16
+
17
+**/
18
+
19
+#ifndef __HII_PLATFORM_SETUP_FORMSET_GUID_H__
20
+#define __HII_PLATFORM_SETUP_FORMSET_GUID_H__
21
+
22
+FILE_LICENCE ( BSD3 );
23
+
24
+#define EFI_HII_PLATFORM_SETUP_FORMSET_GUID \
25
+  { 0x93039971, 0x8545, 0x4b04, { 0xb4, 0x5e, 0x32, 0xeb, 0x83, 0x26, 0x4, 0xe } }
26
+
27
+#define EFI_HII_DRIVER_HEALTH_FORMSET_GUID \
28
+  { 0xf22fc20c, 0x8cf4, 0x45eb, { 0x8e, 0x6, 0xad, 0x4e, 0x50, 0xb9, 0x5d, 0xd3 } }
29
+
30
+#define EFI_HII_USER_CREDENTIAL_FORMSET_GUID \
31
+  { 0x337f4407, 0x5aee, 0x4b83, { 0xb2, 0xa7, 0x4e, 0xad, 0xca, 0x30, 0x88, 0xcd } }
32
+
33
+extern EFI_GUID gEfiHiiPlatformSetupFormsetGuid;
34
+extern EFI_GUID gEfiHiiDriverHealthFormsetGuid;
35
+extern EFI_GUID gEfiHiiUserCredentialFormsetGuid;
36
+
37
+#endif

+ 222
- 0
src/include/ipxe/efi/Guid/MdeModuleHii.h 查看文件

@@ -0,0 +1,222 @@
1
+/** @file
2
+  EDKII extented HII IFR guid opcodes.
3
+
4
+Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
5
+This program and the accompanying materials are licensed and made available under
6
+the terms and conditions of the BSD License that accompanies this distribution.
7
+The full text of the license may be found at
8
+http://opensource.org/licenses/bsd-license.php.
9
+
10
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
+
13
+**/
14
+
15
+#ifndef __MDEMODULE_HII_H__
16
+#define __MDEMODULE_HII_H__
17
+
18
+FILE_LICENCE ( BSD3 );
19
+
20
+#define NARROW_CHAR         0xFFF0
21
+#define WIDE_CHAR           0xFFF1
22
+#define NON_BREAKING_CHAR   0xFFF2
23
+
24
+///
25
+/// State defined for password statemachine .
26
+///
27
+#define BROWSER_STATE_VALIDATE_PASSWORD  0
28
+#define BROWSER_STATE_SET_PASSWORD       1
29
+
30
+///
31
+/// GUIDed opcodes defined for EDKII implementation.
32
+///
33
+#define EFI_IFR_TIANO_GUID \
34
+  { 0xf0b1735, 0x87a0, 0x4193, {0xb2, 0x66, 0x53, 0x8c, 0x38, 0xaf, 0x48, 0xce} }
35
+
36
+#pragma pack(1)
37
+
38
+///
39
+/// EDKII implementation extension opcodes, new extension can be added here later.
40
+///
41
+#define EFI_IFR_EXTEND_OP_LABEL       0x0
42
+#define EFI_IFR_EXTEND_OP_BANNER      0x1
43
+#define EFI_IFR_EXTEND_OP_TIMEOUT     0x2
44
+#define EFI_IFR_EXTEND_OP_CLASS       0x3
45
+#define EFI_IFR_EXTEND_OP_SUBCLASS    0x4
46
+
47
+///
48
+/// Label opcode.
49
+///
50
+typedef struct _EFI_IFR_GUID_LABEL {
51
+  EFI_IFR_OP_HEADER   Header;
52
+  ///
53
+  /// EFI_IFR_TIANO_GUID.
54
+  ///
55
+  EFI_GUID            Guid;
56
+  ///
57
+  /// EFI_IFR_EXTEND_OP_LABEL.
58
+  ///
59
+  UINT8               ExtendOpCode;
60
+  ///
61
+  /// Label Number.
62
+  ///
63
+  UINT16              Number;
64
+} EFI_IFR_GUID_LABEL;
65
+
66
+#define EFI_IFR_BANNER_ALIGN_LEFT     0
67
+#define EFI_IFR_BANNER_ALIGN_CENTER   1
68
+#define EFI_IFR_BANNER_ALIGN_RIGHT    2
69
+
70
+///
71
+/// Banner opcode.
72
+///
73
+typedef struct _EFI_IFR_GUID_BANNER {
74
+  EFI_IFR_OP_HEADER   Header;
75
+  ///
76
+  /// EFI_IFR_TIANO_GUID.
77
+  ///
78
+  EFI_GUID            Guid;
79
+  ///
80
+  /// EFI_IFR_EXTEND_OP_BANNER
81
+  ///
82
+  UINT8               ExtendOpCode;
83
+  EFI_STRING_ID       Title;        ///< The string token for the banner title.
84
+  UINT16              LineNumber;   ///< 1-based line number.
85
+  UINT8               Alignment;    ///< left, center, or right-aligned.
86
+} EFI_IFR_GUID_BANNER;
87
+
88
+///
89
+/// Timeout opcode.
90
+///
91
+typedef struct _EFI_IFR_GUID_TIMEOUT {
92
+  EFI_IFR_OP_HEADER   Header;
93
+  ///
94
+  /// EFI_IFR_TIANO_GUID.
95
+  ///
96
+  EFI_GUID            Guid;
97
+  ///
98
+  /// EFI_IFR_EXTEND_OP_TIMEOUT.
99
+  ///
100
+  UINT8               ExtendOpCode;
101
+  UINT16              TimeOut;       ///< TimeOut Value.
102
+} EFI_IFR_GUID_TIMEOUT;
103
+
104
+#define EFI_NON_DEVICE_CLASS              0x00
105
+#define EFI_DISK_DEVICE_CLASS             0x01
106
+#define EFI_VIDEO_DEVICE_CLASS            0x02
107
+#define EFI_NETWORK_DEVICE_CLASS          0x04
108
+#define EFI_INPUT_DEVICE_CLASS            0x08
109
+#define EFI_ON_BOARD_DEVICE_CLASS         0x10
110
+#define EFI_OTHER_DEVICE_CLASS            0x20
111
+
112
+///
113
+/// Device Class opcode.
114
+///
115
+typedef struct _EFI_IFR_GUID_CLASS {
116
+  EFI_IFR_OP_HEADER   Header;
117
+  ///
118
+  /// EFI_IFR_TIANO_GUID.
119
+  ///
120
+  EFI_GUID            Guid;
121
+  ///
122
+  /// EFI_IFR_EXTEND_OP_CLASS.
123
+  ///
124
+  UINT8               ExtendOpCode;
125
+  UINT16              Class;           ///< Device Class from the above.
126
+} EFI_IFR_GUID_CLASS;
127
+
128
+#define EFI_SETUP_APPLICATION_SUBCLASS    0x00
129
+#define EFI_GENERAL_APPLICATION_SUBCLASS  0x01
130
+#define EFI_FRONT_PAGE_SUBCLASS           0x02
131
+#define EFI_SINGLE_USE_SUBCLASS           0x03
132
+
133
+///
134
+/// SubClass opcode
135
+///
136
+typedef struct _EFI_IFR_GUID_SUBCLASS {
137
+  EFI_IFR_OP_HEADER   Header;
138
+  ///
139
+  /// EFI_IFR_TIANO_GUID.
140
+  ///
141
+  EFI_GUID            Guid;
142
+  ///
143
+  /// EFI_IFR_EXTEND_OP_SUBCLASS.
144
+  ///
145
+  UINT8               ExtendOpCode;
146
+  UINT16              SubClass;      ///< Sub Class type from the above.
147
+} EFI_IFR_GUID_SUBCLASS;
148
+
149
+///
150
+/// GUIDed opcodes support for framework vfr.
151
+///
152
+#define EFI_IFR_FRAMEWORK_GUID \
153
+  { 0x31ca5d1a, 0xd511, 0x4931, { 0xb7, 0x82, 0xae, 0x6b, 0x2b, 0x17, 0x8c, 0xd7 } }
154
+
155
+///
156
+/// Two extended opcodes are added, and new extensions can be added here later.
157
+/// One is for framework OneOf question Option Key value;
158
+/// another is for framework vareqval.
159
+///
160
+#define EFI_IFR_EXTEND_OP_OPTIONKEY   0x0
161
+#define EFI_IFR_EXTEND_OP_VAREQNAME   0x1
162
+
163
+///
164
+/// Store the framework vfr option key value.
165
+///
166
+typedef struct _EFI_IFR_GUID_OPTIONKEY {
167
+  EFI_IFR_OP_HEADER   Header;
168
+  ///
169
+  /// EFI_IFR_FRAMEWORK_GUID.
170
+  ///
171
+  EFI_GUID            Guid;
172
+  ///
173
+  /// EFI_IFR_EXTEND_OP_OPTIONKEY.
174
+  ///
175
+  UINT8               ExtendOpCode;
176
+  ///
177
+  /// OneOf Questiond ID binded by OneOf Option.
178
+  ///
179
+  EFI_QUESTION_ID     QuestionId;
180
+  ///
181
+  /// The OneOf Option Value.
182
+  ///
183
+  EFI_IFR_TYPE_VALUE  OptionValue;
184
+  ///
185
+  /// The Framework OneOf Option Key Value.
186
+  ///
187
+  UINT16              KeyValue;
188
+} EFI_IFR_GUID_OPTIONKEY;
189
+
190
+///
191
+/// Store the framework vfr vareqval name number.
192
+///
193
+typedef struct _EFI_IFR_GUID_VAREQNAME {
194
+  EFI_IFR_OP_HEADER   Header;
195
+  ///
196
+  /// EFI_IFR_FRAMEWORK_GUID.
197
+  ///
198
+  EFI_GUID            Guid;
199
+  ///
200
+  /// EFI_IFR_EXTEND_OP_VAREQNAME.
201
+  ///
202
+  UINT8               ExtendOpCode;
203
+  ///
204
+  /// Question ID of the Numeric Opcode created.
205
+  ///
206
+  EFI_QUESTION_ID     QuestionId;
207
+  ///
208
+  /// For vareqval (0x100), NameId is 0x100.
209
+  /// This value will convert to a Unicode String following this rule;
210
+  ///            sprintf(StringBuffer, "%d", NameId) .
211
+  /// The the Unicode String will be used as a EFI Variable Name.
212
+  ///
213
+  UINT16              NameId;
214
+} EFI_IFR_GUID_VAREQNAME;
215
+
216
+#pragma pack()
217
+
218
+extern EFI_GUID gEfiIfrTianoGuid;
219
+extern EFI_GUID gEfiIfrFrameworkGuid;
220
+
221
+#endif
222
+

+ 177
- 0
src/include/ipxe/efi/Protocol/FormBrowser2.h 查看文件

@@ -0,0 +1,177 @@
1
+/** @file
2
+  This protocol is defined in UEFI spec.
3
+
4
+  The EFI_FORM_BROWSER2_PROTOCOL is the interface to call for drivers to
5
+  leverage the EFI configuration driver interface.
6
+
7
+Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
8
+This program and the accompanying materials are licensed and made available under
9
+the terms and conditions of the BSD License that accompanies this distribution.
10
+The full text of the license may be found at
11
+http://opensource.org/licenses/bsd-license.php.
12
+
13
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15
+
16
+**/
17
+
18
+#ifndef __EFI_FORM_BROWSER2_H__
19
+#define __EFI_FORM_BROWSER2_H__
20
+
21
+FILE_LICENCE ( BSD3 );
22
+
23
+#include <ipxe/efi/Guid/HiiPlatformSetupFormset.h>
24
+
25
+#define EFI_FORM_BROWSER2_PROTOCOL_GUID \
26
+  {0xb9d4c360, 0xbcfb, 0x4f9b, {0x92, 0x98, 0x53, 0xc1, 0x36, 0x98, 0x22, 0x58 }}
27
+
28
+
29
+typedef struct _EFI_FORM_BROWSER2_PROTOCOL   EFI_FORM_BROWSER2_PROTOCOL;
30
+
31
+
32
+
33
+/**
34
+
35
+  @param LeftColumn   The value that designates the text column
36
+                      where the browser window will begin from
37
+                      the left-hand side of the screen
38
+
39
+  @param RightColumn  The value that designates the text
40
+                      column where the browser window will end
41
+                      on the right-hand side of the screen.
42
+
43
+  @param TopRow       The value that designates the text row from the
44
+                      top of the screen where the browser window
45
+                      will start.
46
+
47
+  @param BottomRow    The value that designates the text row from the
48
+                      bottom of the screen where the browser
49
+                      window will end.
50
+**/
51
+typedef struct {
52
+  UINTN   LeftColumn;
53
+  UINTN   RightColumn;
54
+  UINTN   TopRow;
55
+  UINTN   BottomRow;
56
+} EFI_SCREEN_DESCRIPTOR;
57
+
58
+typedef UINTN EFI_BROWSER_ACTION_REQUEST;
59
+
60
+#define EFI_BROWSER_ACTION_REQUEST_NONE   0
61
+#define EFI_BROWSER_ACTION_REQUEST_RESET  1
62
+#define EFI_BROWSER_ACTION_REQUEST_SUBMIT 2
63
+#define EFI_BROWSER_ACTION_REQUEST_EXIT   3
64
+
65
+
66
+/**
67
+  Initialize the browser to display the specified configuration forms.
68
+
69
+  This function is the primary interface to the internal forms-based browser.
70
+  The forms browser will display forms associated with the specified Handles.
71
+  The browser will select all forms in packages which have the specified Type
72
+  and (for EFI_HII_PACKAGE_TYPE_GUID) the specified PackageGuid.
73
+
74
+  @param This            A pointer to the EFI_FORM_BROWSER2_PROTOCOL instance
75
+
76
+  @param Handles         A pointer to an array of Handles. This value should correspond
77
+                         to the value of the HII form package that is required to be displayed.
78
+
79
+  @param HandleCount     The number of Handles specified in Handle.
80
+
81
+  @param FormSetGuid     This field points to the EFI_GUID which must match the Guid field or one of the
82
+                         elements of the ClassId field  in the EFI_IFR_FORM_SET op-code.  If
83
+                         FormsetGuid is NULL, then this function will display the the form set class
84
+                         EFI_HII_PLATFORM_SETUP_FORMSET_GUID.
85
+
86
+  @param FormId          This field specifies the identifier of the form within the form set to render as the first
87
+                         displayable page. If this field has a value of 0x0000, then the Forms Browser will
88
+                         render the first enabled form in the form set.
89
+
90
+  @param ScreenDimensions Points to recommended form dimensions, including any non-content area, in
91
+                          characters.
92
+
93
+  @param ActionRequest   Points to the action recommended by the form.
94
+
95
+  @retval EFI_SUCCESS           The function completed successfully
96
+
97
+  @retval EFI_NOT_FOUND         The variable was not found.
98
+
99
+  @retval EFI_INVALID_PARAMETER One of the parameters has an
100
+                                invalid value.
101
+**/
102
+typedef
103
+EFI_STATUS
104
+(EFIAPI *EFI_SEND_FORM2)(
105
+  IN CONST  EFI_FORM_BROWSER2_PROTOCOL  *This,
106
+  IN        EFI_HII_HANDLE              *Handle,
107
+  IN        UINTN                      HandleCount,
108
+  IN        EFI_GUID                   *FormSetGuid, OPTIONAL
109
+  IN        EFI_FORM_ID                FormId, OPTIONAL
110
+  IN CONST  EFI_SCREEN_DESCRIPTOR      *ScreenDimensions, OPTIONAL
111
+  OUT       EFI_BROWSER_ACTION_REQUEST *ActionRequest  OPTIONAL
112
+);
113
+
114
+
115
+/**
116
+  This function is called by a callback handler to retrieve uncommitted state data from the browser.
117
+
118
+  This routine is called by a routine which was called by the
119
+  browser. This routine called this service in the browser to
120
+  retrieve or set certain uncommitted state information.
121
+
122
+  @param This           A pointer to the EFI_FORM_BROWSER2_PROTOCOL instance.
123
+
124
+  @param ResultsDataSize  A pointer to the size of the buffer
125
+                          associated with ResultsData. On input, the size in
126
+                          bytes of ResultsData. On output, the size of data
127
+                          returned in ResultsData.
128
+
129
+  @param ResultsData    A string returned from an IFR browser or
130
+                        equivalent. The results string will have
131
+                        no routing information in them.
132
+
133
+  @param RetrieveData   A BOOLEAN field which allows an agent to
134
+                        retrieve (if RetrieveData = TRUE) data
135
+                        from the uncommitted browser state
136
+                        information or set (if RetrieveData =
137
+                        FALSE) data in the uncommitted browser
138
+                        state information.
139
+
140
+  @param VariableGuid   An optional field to indicate the target
141
+                        variable GUID name to use.
142
+
143
+  @param VariableName   An optional field to indicate the target
144
+                        human-readable variable name.
145
+
146
+  @retval EFI_SUCCESS           The results have been distributed or are
147
+                                awaiting distribution.
148
+
149
+  @retval EFI_OUT_OF_RESOURCES  The ResultsDataSize specified
150
+                                was too small to contain the
151
+                                results data.
152
+
153
+**/
154
+typedef
155
+EFI_STATUS
156
+(EFIAPI *EFI_BROWSER_CALLBACK2)(
157
+  IN CONST  EFI_FORM_BROWSER2_PROTOCOL *This,
158
+  IN OUT    UINTN                     *ResultsDataSize,
159
+  IN OUT    EFI_STRING                ResultsData,
160
+  IN CONST  BOOLEAN                   RetrieveData,
161
+  IN CONST  EFI_GUID                  *VariableGuid, OPTIONAL
162
+  IN CONST  CHAR16                    *VariableName OPTIONAL
163
+);
164
+
165
+///
166
+/// This interface will allow the caller to direct the configuration
167
+/// driver to use either the HII database or use the passed-in packet of data.
168
+///
169
+struct _EFI_FORM_BROWSER2_PROTOCOL {
170
+  EFI_SEND_FORM2         SendForm;
171
+  EFI_BROWSER_CALLBACK2  BrowserCallback;
172
+} ;
173
+
174
+extern EFI_GUID gEfiFormBrowser2ProtocolGuid;
175
+
176
+#endif
177
+

+ 221
- 0
src/include/ipxe/efi/Protocol/HiiConfigAccess.h 查看文件

@@ -0,0 +1,221 @@
1
+/** @file
2
+
3
+  The EFI HII results processing protocol invokes this type of protocol
4
+  when it needs to forward results to a driver's configuration handler.
5
+  This protocol is published by drivers providing and requesting
6
+  configuration data from HII. It may only be invoked by HII.
7
+
8
+Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
9
+This program and the accompanying materials are licensed and made available under
10
+the terms and conditions of the BSD License that accompanies this distribution.
11
+The full text of the license may be found at
12
+http://opensource.org/licenses/bsd-license.php.
13
+
14
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
15
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16
+
17
+**/
18
+
19
+
20
+#ifndef __EFI_HII_CONFIG_ACCESS_H__
21
+#define __EFI_HII_CONFIG_ACCESS_H__
22
+
23
+FILE_LICENCE ( BSD3 );
24
+
25
+#include <ipxe/efi/Protocol/FormBrowser2.h>
26
+
27
+#define EFI_HII_CONFIG_ACCESS_PROTOCOL_GUID  \
28
+  { 0x330d4706, 0xf2a0, 0x4e4f, { 0xa3, 0x69, 0xb6, 0x6f, 0xa8, 0xd5, 0x43, 0x85 } }
29
+
30
+typedef struct _EFI_HII_CONFIG_ACCESS_PROTOCOL  EFI_HII_CONFIG_ACCESS_PROTOCOL;
31
+
32
+typedef UINTN EFI_BROWSER_ACTION;
33
+
34
+#define EFI_BROWSER_ACTION_CHANGING   0
35
+#define EFI_BROWSER_ACTION_CHANGED    1
36
+#define EFI_BROWSER_ACTION_RETRIEVE   2
37
+#define EFI_BROWSER_ACTION_FORM_OPEN  3
38
+#define EFI_BROWSER_ACTION_FORM_CLOSE 4
39
+
40
+/**
41
+
42
+  This function allows the caller to request the current
43
+  configuration for one or more named elements. The resulting
44
+  string is in <ConfigAltResp> format. Any and all alternative
45
+  configuration strings shall also be appended to the end of the
46
+  current configuration string. If they are, they must appear
47
+  after the current configuration. They must contain the same
48
+  routing (GUID, NAME, PATH) as the current configuration string.
49
+  They must have an additional description indicating the type of
50
+  alternative configuration the string represents,
51
+  "ALTCFG=<StringToken>". That <StringToken> (when
52
+  converted from Hex UNICODE to binary) is a reference to a
53
+  string in the associated string pack.
54
+
55
+  @param This       Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
56
+
57
+  @param Request    A null-terminated Unicode string in
58
+                    <ConfigRequest> format. Note that this
59
+                    includes the routing information as well as
60
+                    the configurable name / value pairs. It is
61
+                    invalid for this string to be in
62
+                    <MultiConfigRequest> format.
63
+                    If a NULL is passed in for the Request field,
64
+                    all of the settings being abstracted by this function
65
+                    will be returned in the Results field.  In addition,
66
+                    if a ConfigHdr is passed in with no request elements,
67
+                    all of the settings being abstracted for that particular
68
+                    ConfigHdr reference will be returned in the Results Field.
69
+
70
+  @param Progress   On return, points to a character in the
71
+                    Request string. Points to the string's null
72
+                    terminator if request was successful. Points
73
+                    to the most recent "&" before the first
74
+                    failing name / value pair (or the beginning
75
+                    of the string if the failure is in the first
76
+                    name / value pair) if the request was not
77
+                    successful.
78
+
79
+  @param Results    A null-terminated Unicode string in
80
+                    <MultiConfigAltResp> format which has all values
81
+                    filled in for the names in the Request string.
82
+                    String to be allocated by the called function.
83
+
84
+  @retval EFI_SUCCESS             The Results string is filled with the
85
+                                  values corresponding to all requested
86
+                                  names.
87
+
88
+  @retval EFI_OUT_OF_RESOURCES    Not enough memory to store the
89
+                                  parts of the results that must be
90
+                                  stored awaiting possible future
91
+                                  protocols.
92
+
93
+  @retval EFI_NOT_FOUND           Routing data doesn't match any
94
+                                  known driver. Progress set to the
95
+                                  first character in the routing header.
96
+                                  Note: There is no requirement that the
97
+                                  driver validate the routing data. It
98
+                                  must skip the <ConfigHdr> in order to
99
+                                  process the names.
100
+
101
+  @retval EFI_INVALID_PARAMETER   Illegal syntax. Progress set
102
+                                  to most recent "&" before the
103
+                                  error or the beginning of the
104
+                                  string.
105
+
106
+  @retval EFI_INVALID_PARAMETER   Unknown name. Progress points
107
+                                  to the & before the name in
108
+                                  question.
109
+
110
+**/
111
+typedef
112
+EFI_STATUS
113
+(EFIAPI * EFI_HII_ACCESS_EXTRACT_CONFIG)(
114
+  IN CONST  EFI_HII_CONFIG_ACCESS_PROTOCOL  *This,
115
+  IN CONST  EFI_STRING                      Request,
116
+  OUT       EFI_STRING                      *Progress,
117
+  OUT       EFI_STRING                      *Results
118
+);
119
+
120
+
121
+/**
122
+
123
+  This function applies changes in a driver's configuration.
124
+  Input is a Configuration, which has the routing data for this
125
+  driver followed by name / value configuration pairs. The driver
126
+  must apply those pairs to its configurable storage. If the
127
+  driver's configuration is stored in a linear block of data
128
+  and the driver's name / value pairs are in <BlockConfig>
129
+  format, it may use the ConfigToBlock helper function (above) to
130
+  simplify the job.
131
+
132
+  @param This           Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
133
+
134
+  @param Configuration  A null-terminated Unicode string in
135
+                        <ConfigString> format.
136
+
137
+  @param Progress       A pointer to a string filled in with the
138
+                        offset of the most recent '&' before the
139
+                        first failing name / value pair (or the
140
+                        beginn ing of the string if the failure
141
+                        is in the first name / value pair) or
142
+                        the terminating NULL if all was
143
+                        successful.
144
+
145
+  @retval EFI_SUCCESS             The results have been distributed or are
146
+                                  awaiting distribution.
147
+
148
+  @retval EFI_OUT_OF_RESOURCES    Not enough memory to store the
149
+                                  parts of the results that must be
150
+                                  stored awaiting possible future
151
+                                  protocols.
152
+
153
+  @retval EFI_INVALID_PARAMETERS  Passing in a NULL for the
154
+                                  Results parameter would result
155
+                                  in this type of error.
156
+
157
+  @retval EFI_NOT_FOUND           Target for the specified routing data
158
+                                  was not found
159
+
160
+**/
161
+typedef
162
+EFI_STATUS
163
+(EFIAPI * EFI_HII_ACCESS_ROUTE_CONFIG)(
164
+  IN CONST  EFI_HII_CONFIG_ACCESS_PROTOCOL  *This,
165
+  IN CONST  EFI_STRING                      Configuration,
166
+  OUT       EFI_STRING                      *Progress
167
+);
168
+
169
+/**
170
+
171
+  This function is called to provide results data to the driver.
172
+  This data consists of a unique key that is used to identify
173
+  which data is either being passed back or being asked for.
174
+
175
+  @param  This                   Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
176
+  @param  Action                 Specifies the type of action taken by the browser.
177
+  @param  QuestionId             A unique value which is sent to the original
178
+                                 exporting driver so that it can identify the type
179
+                                 of data to expect. The format of the data tends to
180
+                                 vary based on the opcode that generated the callback.
181
+  @param  Type                   The type of value for the question.
182
+  @param  Value                  A pointer to the data being sent to the original
183
+                                 exporting driver.
184
+  @param  ActionRequest          On return, points to the action requested by the
185
+                                 callback function.
186
+
187
+  @retval EFI_SUCCESS            The callback successfully handled the action.
188
+  @retval EFI_OUT_OF_RESOURCES   Not enough storage is available to hold the
189
+                                 variable and its data.
190
+  @retval EFI_DEVICE_ERROR       The variable could not be saved.
191
+  @retval EFI_UNSUPPORTED        The specified Action is not supported by the
192
+                                 callback.
193
+**/
194
+typedef
195
+EFI_STATUS
196
+(EFIAPI *EFI_HII_ACCESS_FORM_CALLBACK)(
197
+  IN     CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,
198
+  IN     EFI_BROWSER_ACTION                     Action,
199
+  IN     EFI_QUESTION_ID                        QuestionId,
200
+  IN     UINT8                                  Type,
201
+  IN OUT EFI_IFR_TYPE_VALUE                     *Value,
202
+  OUT    EFI_BROWSER_ACTION_REQUEST             *ActionRequest
203
+  )
204
+  ;
205
+
206
+///
207
+/// This protocol provides a callable interface between the HII and
208
+/// drivers. Only drivers which provide IFR data to HII are required
209
+/// to publish this protocol.
210
+///
211
+struct _EFI_HII_CONFIG_ACCESS_PROTOCOL {
212
+  EFI_HII_ACCESS_EXTRACT_CONFIG     ExtractConfig;
213
+  EFI_HII_ACCESS_ROUTE_CONFIG       RouteConfig;
214
+  EFI_HII_ACCESS_FORM_CALLBACK      Callback;
215
+} ;
216
+
217
+extern EFI_GUID gEfiHiiConfigAccessProtocolGuid;
218
+
219
+#endif
220
+
221
+

+ 519
- 0
src/include/ipxe/efi/Protocol/HiiDatabase.h 查看文件

@@ -0,0 +1,519 @@
1
+/** @file
2
+  The file provides Database manager for HII-related data
3
+  structures.
4
+
5
+Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
6
+This program and the accompanying materials are licensed and made available under
7
+the terms and conditions of the BSD License that accompanies this distribution.
8
+The full text of the license may be found at
9
+http://opensource.org/licenses/bsd-license.php.
10
+
11
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
+
14
+**/
15
+
16
+#ifndef __HII_DATABASE_H__
17
+#define __HII_DATABASE_H__
18
+
19
+FILE_LICENCE ( BSD3 );
20
+
21
+#define EFI_HII_DATABASE_PROTOCOL_GUID \
22
+  { 0xef9fc172, 0xa1b2, 0x4693, { 0xb3, 0x27, 0x6d, 0x32, 0xfc, 0x41, 0x60, 0x42 } }
23
+
24
+
25
+typedef struct _EFI_HII_DATABASE_PROTOCOL EFI_HII_DATABASE_PROTOCOL;
26
+
27
+
28
+///
29
+/// EFI_HII_DATABASE_NOTIFY_TYPE.
30
+///
31
+typedef UINTN   EFI_HII_DATABASE_NOTIFY_TYPE;
32
+
33
+#define EFI_HII_DATABASE_NOTIFY_NEW_PACK    0x00000001
34
+#define EFI_HII_DATABASE_NOTIFY_REMOVE_PACK 0x00000002
35
+#define EFI_HII_DATABASE_NOTIFY_EXPORT_PACK 0x00000004
36
+#define EFI_HII_DATABASE_NOTIFY_ADD_PACK    0x00000008
37
+/**
38
+
39
+  Functions which are registered to receive notification of
40
+  database events have this prototype. The actual event is encoded
41
+  in NotifyType. The following table describes how PackageType,
42
+  PackageGuid, Handle, and Package are used for each of the
43
+  notification types.
44
+
45
+  @param PackageType  Package type of the notification.
46
+
47
+  @param PackageGuid  If PackageType is
48
+                      EFI_HII_PACKAGE_TYPE_GUID, then this is
49
+                      the pointer to the GUID from the Guid
50
+                      field of EFI_HII_PACKAGE_GUID_HEADER.
51
+                      Otherwise, it must be NULL.
52
+
53
+  @param Package      Points to the package referred to by the notification.
54
+
55
+  @param Handle       The handle of the package
56
+                      list which contains the specified package.
57
+
58
+  @param NotifyType   The type of change concerning the
59
+                      database. See
60
+                      EFI_HII_DATABASE_NOTIFY_TYPE.
61
+
62
+**/
63
+typedef
64
+EFI_STATUS
65
+(EFIAPI *EFI_HII_DATABASE_NOTIFY)(
66
+  IN        UINT8                         PackageType,
67
+  IN CONST  EFI_GUID                      *PackageGuid,
68
+  IN CONST  EFI_HII_PACKAGE_HEADER        *Package,
69
+  IN        EFI_HII_HANDLE                 Handle,
70
+  IN        EFI_HII_DATABASE_NOTIFY_TYPE  NotifyType
71
+);
72
+
73
+/**
74
+
75
+  This function adds the packages in the package list to the
76
+  database and returns a handle. If there is a
77
+  EFI_DEVICE_PATH_PROTOCOL associated with the DriverHandle, then
78
+  this function will create a package of type
79
+  EFI_PACKAGE_TYPE_DEVICE_PATH and add it to the package list. For
80
+  each package in the package list, registered functions with the
81
+  notification type NEW_PACK and having the same package type will
82
+  be called. For each call to NewPackageList(), there should be a
83
+  corresponding call to
84
+  EFI_HII_DATABASE_PROTOCOL.RemovePackageList().
85
+
86
+  @param This           A pointer to the EFI_HII_DATABASE_PROTOCOL instance.
87
+
88
+  @param PackageList    A pointer to an EFI_HII_PACKAGE_LIST_HEADER structure.
89
+
90
+  @param DriverHandle   Associate the package list with this EFI handle.
91
+                        If a NULL is specified, this data will not be associate
92
+                        with any drivers and cannot have a callback induced.
93
+
94
+  @param Handle         A pointer to the EFI_HII_HANDLE instance.
95
+
96
+  @retval EFI_SUCCESS           The package list associated with the
97
+                                Handle was added to the HII database.
98
+
99
+  @retval EFI_OUT_OF_RESOURCES  Unable to allocate necessary
100
+                                resources for the new database
101
+                                contents.
102
+
103
+  @retval EFI_INVALID_PARAMETER PackageList is NULL, or Handle is NULL.
104
+
105
+**/
106
+typedef
107
+EFI_STATUS
108
+(EFIAPI *EFI_HII_DATABASE_NEW_PACK)(
109
+  IN CONST  EFI_HII_DATABASE_PROTOCOL   *This,
110
+  IN CONST  EFI_HII_PACKAGE_LIST_HEADER *PackageList,
111
+  IN        EFI_HANDLE                  DriverHandle, OPTIONAL
112
+  OUT       EFI_HII_HANDLE               *Handle
113
+);
114
+
115
+
116
+/**
117
+
118
+  This function removes the package list that is associated with a
119
+  handle Handle from the HII database. Before removing the
120
+  package, any registered functions with the notification type
121
+  REMOVE_PACK and the same package type will be called. For each
122
+  call to EFI_HII_DATABASE_PROTOCOL.NewPackageList(), there should
123
+  be a corresponding call to RemovePackageList.
124
+
125
+  @param This             A pointer to the EFI_HII_DATABASE_PROTOCOL instance.
126
+
127
+  @param Handle           The handle that was registered to the data
128
+                          that is requested for removal.
129
+
130
+  @retval EFI_SUCCESS     The data associated with the Handle was
131
+                          removed from the HII database.
132
+  @retval EFI_NOT_FOUND   The specified Handle is not in database.
133
+
134
+**/
135
+typedef
136
+EFI_STATUS
137
+(EFIAPI *EFI_HII_DATABASE_REMOVE_PACK)(
138
+  IN CONST  EFI_HII_DATABASE_PROTOCOL *This,
139
+  IN        EFI_HII_HANDLE             Handle
140
+);
141
+
142
+
143
+/**
144
+
145
+  This function updates the existing package list (which has the
146
+  specified Handle) in the HII databases, using the new package
147
+  list specified by PackageList. The update process has the
148
+  following steps: Collect all the package types in the package
149
+  list specified by PackageList. A package type consists of the
150
+  Type field of EFI_HII_PACKAGE_HEADER and, if the Type is
151
+  EFI_HII_PACKAGE_TYPE_GUID, the Guid field, as defined in
152
+  EFI_HII_PACKAGE_GUID_HEADER. Iterate through the packages within
153
+  the existing package list in the HII database specified by
154
+  Handle. If a package's type matches one of the collected types collected
155
+  in step 1, then perform the following steps:
156
+  - Call any functions registered with the notification type
157
+  REMOVE_PACK.
158
+  - Remove the package from the package list and the HII
159
+  database.
160
+  Add all of the packages within the new package list specified
161
+  by PackageList, using the following steps:
162
+  - Add the package to the package list and the HII database.
163
+  - Call any functions registered with the notification type
164
+  ADD_PACK.
165
+
166
+  @param This         A pointer to the EFI_HII_DATABASE_PROTOCOL instance.
167
+
168
+  @param Handle       The handle that was registered to the data
169
+                      that is requested for removal.
170
+
171
+  @param PackageList  A pointer to an EFI_HII_PACKAGE_LIST
172
+                      package.
173
+
174
+  @retval EFI_SUCCESS            The HII database was successfully updated.
175
+
176
+  @retval EFI_OUT_OF_RESOURCES   Unable to allocate enough memory
177
+                                 for the updated database.
178
+
179
+  @retval EFI_INVALID_PARAMETER  PackageList was NULL.
180
+  @retval EFI_NOT_FOUND          The specified Handle is not in database.
181
+
182
+**/
183
+typedef
184
+EFI_STATUS
185
+(EFIAPI *EFI_HII_DATABASE_UPDATE_PACK)(
186
+  IN CONST  EFI_HII_DATABASE_PROTOCOL   *This,
187
+  IN        EFI_HII_HANDLE               Handle,
188
+  IN CONST  EFI_HII_PACKAGE_LIST_HEADER *PackageList
189
+);
190
+
191
+
192
+/**
193
+
194
+  This function returns a list of the package handles of the
195
+  specified type that are currently active in the database. The
196
+  pseudo-type EFI_HII_PACKAGE_TYPE_ALL will cause all package
197
+  handles to be listed.
198
+
199
+  @param This                 A pointer to the EFI_HII_DATABASE_PROTOCOL instance.
200
+
201
+  @param PackageType          Specifies the package type of the packages
202
+                              to list or EFI_HII_PACKAGE_TYPE_ALL for
203
+                              all packages to be listed.
204
+
205
+  @param PackageGuid          If PackageType is
206
+                              EFI_HII_PACKAGE_TYPE_GUID, then this is
207
+                              the pointer to the GUID which must match
208
+                              the Guid field of
209
+                              EFI_HII_PACKAGE_GUID_HEADER. Otherwise, it
210
+                              must be NULL.
211
+
212
+  @param HandleBufferLength   On input, a pointer to the length
213
+                              of the handle buffer. On output,
214
+                              the length of the handle buffer
215
+                              that is required for the handles found.
216
+
217
+  @param Handle               An array of EFI_HII_HANDLE instances returned.
218
+
219
+  @retval EFI_SUCCESS           The matching handles are outputed successfully.
220
+                                HandleBufferLength is updated with the actual length.
221
+  @retval EFI_BUFFER_TOO_SMALL  The HandleBufferLength parameter
222
+                                indicates that Handle is too
223
+                                small to support the number of
224
+                                handles. HandleBufferLength is
225
+                                updated with a value that will
226
+                                enable the data to fit.
227
+  @retval EFI_NOT_FOUND         No matching handle could be found in database.
228
+  @retval EFI_INVALID_PARAMETER Handle or HandleBufferLength was NULL.
229
+  @retval EFI_INVALID_PARAMETER PackageType is not a EFI_HII_PACKAGE_TYPE_GUID but
230
+                                PackageGuid is not NULL, PackageType is a EFI_HII_
231
+                                PACKAGE_TYPE_GUID but PackageGuid is NULL.
232
+**/
233
+typedef
234
+EFI_STATUS
235
+(EFIAPI *EFI_HII_DATABASE_LIST_PACKS)(
236
+  IN CONST  EFI_HII_DATABASE_PROTOCOL *This,
237
+  IN        UINT8                     PackageType,
238
+  IN CONST  EFI_GUID                  *PackageGuid,
239
+  IN OUT    UINTN                     *HandleBufferLength,
240
+  OUT       EFI_HII_HANDLE            *Handle
241
+);
242
+
243
+/**
244
+
245
+  This function will export one or all package lists in the
246
+  database to a buffer. For each package list exported, this
247
+  function will call functions registered with EXPORT_PACK and
248
+  then copy the package list to the buffer. The registered
249
+  functions may call EFI_HII_DATABASE_PROTOCOL.UpdatePackageList()
250
+  to modify the package list before it is copied to the buffer. If
251
+  the specified BufferSize is too small, then the status
252
+  EFI_OUT_OF_RESOURCES will be returned and the actual package
253
+  size will be returned in BufferSize.
254
+
255
+  @param This         A pointer to the EFI_HII_DATABASE_PROTOCOL instance.
256
+
257
+
258
+  @param Handle       An EFI_HII_HANDLE  that corresponds to the
259
+                      desired package list in the HII database to
260
+                      export or NULL to indicate all package lists
261
+                      should be exported.
262
+
263
+  @param BufferSize   On input, a pointer to the length of the
264
+                      buffer. On output, the length of the
265
+                      buffer that is required for the exported
266
+                      data.
267
+
268
+  @param Buffer       A pointer to a buffer that will contain the
269
+                      results of the export function.
270
+
271
+
272
+  @retval EFI_SUCCESS           Package exported.
273
+
274
+  @retval EFI_OUT_OF_RESOURCES  BufferSize is too small to hold the package.
275
+
276
+**/
277
+typedef
278
+EFI_STATUS
279
+(EFIAPI *EFI_HII_DATABASE_EXPORT_PACKS)(
280
+  IN CONST  EFI_HII_DATABASE_PROTOCOL      *This,
281
+  IN        EFI_HII_HANDLE                 Handle,
282
+  IN OUT    UINTN                          *BufferSize,
283
+  OUT       EFI_HII_PACKAGE_LIST_HEADER    *Buffer
284
+);
285
+
286
+
287
+/**
288
+
289
+
290
+  This function registers a function which will be called when
291
+  specified actions related to packages of the specified type
292
+  occur in the HII database. By registering a function, other
293
+  HII-related drivers are notified when specific package types
294
+  are added, removed or updated in the HII database. Each driver
295
+  or application which registers a notification should use
296
+  EFI_HII_DATABASE_PROTOCOL.UnregisterPackageNotify() before
297
+  exiting.
298
+
299
+
300
+  @param This             A pointer to the EFI_HII_DATABASE_PROTOCOL instance.
301
+
302
+  @param PackageType      The package type. See
303
+                          EFI_HII_PACKAGE_TYPE_x in EFI_HII_PACKAGE_HEADER.
304
+
305
+  @param PackageGuid      If PackageType is
306
+                          EFI_HII_PACKAGE_TYPE_GUID, then this is
307
+                          the pointer to the GUID which must match
308
+                          the Guid field of
309
+                          EFI_HII_PACKAGE_GUID_HEADER. Otherwise, it
310
+                          must be NULL.
311
+
312
+  @param PackageNotifyFn  Points to the function to be called
313
+                          when the event specified by
314
+                          NotificationType occurs. See
315
+                          EFI_HII_DATABASE_NOTIFY.
316
+
317
+  @param NotifyType       Describes the types of notification which
318
+                          this function will be receiving. See
319
+                          EFI_HII_DATABASE_NOTIFY_TYPE for a
320
+                          list of types.
321
+
322
+  @param NotifyHandle     Points to the unique handle assigned to
323
+                          the registered notification. Can be used
324
+                          in EFI_HII_DATABASE_PROTOCOL.UnregisterPack
325
+                          to stop notifications.
326
+
327
+
328
+  @retval EFI_SUCCESS           Notification registered successfully.
329
+
330
+  @retval EFI_OUT_OF_RESOURCES  Unable to allocate necessary
331
+                                data structures.
332
+
333
+  @retval EFI_INVALID_PARAMETER PackageGuid is not NULL when
334
+                                PackageType is not
335
+                                EFI_HII_PACKAGE_TYPE_GUID.
336
+
337
+**/
338
+typedef
339
+EFI_STATUS
340
+(EFIAPI *EFI_HII_DATABASE_REGISTER_NOTIFY)(
341
+  IN CONST  EFI_HII_DATABASE_PROTOCOL     *This,
342
+  IN        UINT8                         PackageType,
343
+  IN CONST  EFI_GUID                      *PackageGuid,
344
+  IN        EFI_HII_DATABASE_NOTIFY       PackageNotifyFn,
345
+  IN        EFI_HII_DATABASE_NOTIFY_TYPE  NotifyType,
346
+  OUT       EFI_HANDLE                    *NotifyHandle
347
+);
348
+
349
+
350
+/**
351
+
352
+  Removes the specified HII database package-related notification.
353
+
354
+  @param This                 A pointer to the EFI_HII_DATABASE_PROTOCOL instance.
355
+
356
+  @param NotificationHandle   The handle of the notification
357
+                              function being unregistered.
358
+
359
+  @retval EFI_SUCCESS   Successsfully unregistered the notification.
360
+
361
+  @retval EFI_NOT_FOUND The incoming notification handle does not exist
362
+                        in the current hii database.
363
+
364
+**/
365
+typedef
366
+EFI_STATUS
367
+(EFIAPI *EFI_HII_DATABASE_UNREGISTER_NOTIFY)(
368
+  IN CONST  EFI_HII_DATABASE_PROTOCOL *This,
369
+  IN        EFI_HANDLE                NotificationHandle
370
+);
371
+
372
+
373
+/**
374
+
375
+  This routine retrieves an array of GUID values for each keyboard
376
+  layout that was previously registered in the system.
377
+
378
+  @param This                 A pointer to the EFI_HII_PROTOCOL instance.
379
+
380
+  @param KeyGuidBufferLength  On input, a pointer to the length
381
+                              of the keyboard GUID buffer. On
382
+                              output, the length of the handle
383
+                              buffer that is required for the
384
+                              handles found.
385
+
386
+  @param KeyGuidBuffer        An array of keyboard layout GUID
387
+                              instances returned.
388
+
389
+  @retval EFI_SUCCESS           KeyGuidBuffer was updated successfully.
390
+
391
+  @retval EFI_BUFFER_TOO_SMALL  The KeyGuidBufferLength
392
+                                parameter indicates that
393
+                                KeyGuidBuffer is too small to
394
+                                support the number of GUIDs.
395
+                                KeyGuidBufferLength is updated
396
+                                with a value that will enable
397
+                                the data to fit.
398
+
399
+**/
400
+typedef
401
+EFI_STATUS
402
+(EFIAPI *EFI_HII_FIND_KEYBOARD_LAYOUTS)(
403
+  IN CONST  EFI_HII_DATABASE_PROTOCOL *This,
404
+  IN OUT    UINT16                    *KeyGuidBufferLength,
405
+  OUT       EFI_GUID                  *KeyGuidBuffer
406
+);
407
+
408
+
409
+/**
410
+
411
+  This routine retrieves the requested keyboard layout. The layout
412
+  is a physical description of the keys on a keyboard, and the
413
+  character(s) that are associated with a particular set of key
414
+  strokes.
415
+
416
+  @param This                   A pointer to the EFI_HII_PROTOCOL instance.
417
+
418
+  @param KeyGuid                A pointer to the unique ID associated with a
419
+                                given keyboard layout. If KeyGuid is NULL then
420
+                                the current layout will be retrieved.
421
+
422
+  @param KeyboardLayoutLength   On input, a pointer to the length of the
423
+                                KeyboardLayout buffer.  On output, the length of
424
+                                the data placed into KeyboardLayout.
425
+
426
+  @param KeyboardLayout         A pointer to a buffer containing the
427
+                                retrieved keyboard layout.
428
+
429
+  @retval EFI_SUCCESS   The keyboard layout was retrieved
430
+                        successfully.
431
+
432
+  @retval EFI_NOT_FOUND The requested keyboard layout was not found.
433
+
434
+**/
435
+typedef
436
+EFI_STATUS
437
+(EFIAPI *EFI_HII_GET_KEYBOARD_LAYOUT)(
438
+  IN CONST  EFI_HII_DATABASE_PROTOCOL *This,
439
+  IN CONST  EFI_GUID                  *KeyGuid,
440
+  IN OUT UINT16                       *KeyboardLayoutLength,
441
+  OUT       EFI_HII_KEYBOARD_LAYOUT   *KeyboardLayout
442
+);
443
+
444
+/**
445
+
446
+  This routine sets the default keyboard layout to the one
447
+  referenced by KeyGuid. When this routine is called, an event
448
+  will be signaled of the EFI_HII_SET_KEYBOARD_LAYOUT_EVENT_GUID
449
+  group type. This is so that agents which are sensitive to the
450
+  current keyboard layout being changed can be notified of this
451
+  change.
452
+
453
+  @param This      A pointer to the EFI_HII_PROTOCOL instance.
454
+
455
+  @param KeyGuid   A pointer to the unique ID associated with a
456
+                   given keyboard layout.
457
+
458
+  @retval EFI_SUCCESS    The current keyboard layout was successfully set.
459
+
460
+  @retval EFI_NOT_FOUND  The referenced keyboard layout was not
461
+                         found, so action was taken.
462
+
463
+**/
464
+typedef
465
+EFI_STATUS
466
+(EFIAPI *EFI_HII_SET_KEYBOARD_LAYOUT)(
467
+  IN CONST  EFI_HII_DATABASE_PROTOCOL *This,
468
+  IN CONST  EFI_GUID                  *KeyGuid
469
+);
470
+
471
+/**
472
+
473
+  Return the EFI handle associated with a package list.
474
+
475
+  @param This               A pointer to the EFI_HII_PROTOCOL instance.
476
+
477
+  @param PackageListHandle  An EFI_HII_HANDLE  that corresponds
478
+                            to the desired package list in the
479
+                            HIIdatabase.
480
+
481
+  @param DriverHandle       On return, contains the EFI_HANDLE which
482
+                            was registered with the package list in
483
+                            NewPackageList().
484
+
485
+  @retval EFI_SUCCESS            The DriverHandle was returned successfully.
486
+
487
+  @retval EFI_INVALID_PARAMETER  The PackageListHandle was not valid.
488
+
489
+**/
490
+typedef
491
+EFI_STATUS
492
+(EFIAPI *EFI_HII_DATABASE_GET_PACK_HANDLE)(
493
+  IN CONST  EFI_HII_DATABASE_PROTOCOL *This,
494
+  IN        EFI_HII_HANDLE             PackageListHandle,
495
+  OUT       EFI_HANDLE                *DriverHandle
496
+);
497
+
498
+///
499
+/// Database manager for HII-related data structures.
500
+///
501
+struct _EFI_HII_DATABASE_PROTOCOL {
502
+  EFI_HII_DATABASE_NEW_PACK           NewPackageList;
503
+  EFI_HII_DATABASE_REMOVE_PACK        RemovePackageList;
504
+  EFI_HII_DATABASE_UPDATE_PACK        UpdatePackageList;
505
+  EFI_HII_DATABASE_LIST_PACKS         ListPackageLists;
506
+  EFI_HII_DATABASE_EXPORT_PACKS       ExportPackageLists;
507
+  EFI_HII_DATABASE_REGISTER_NOTIFY    RegisterPackageNotify;
508
+  EFI_HII_DATABASE_UNREGISTER_NOTIFY  UnregisterPackageNotify;
509
+  EFI_HII_FIND_KEYBOARD_LAYOUTS       FindKeyboardLayouts;
510
+  EFI_HII_GET_KEYBOARD_LAYOUT         GetKeyboardLayout;
511
+  EFI_HII_SET_KEYBOARD_LAYOUT         SetKeyboardLayout;
512
+  EFI_HII_DATABASE_GET_PACK_HANDLE    GetPackageListHandle;
513
+};
514
+
515
+extern EFI_GUID gEfiHiiDatabaseProtocolGuid;
516
+
517
+#endif
518
+
519
+

+ 140
- 0
src/include/ipxe/efi/efi_hii.h 查看文件

@@ -0,0 +1,140 @@
1
+#ifndef _IPXE_EFI_HII_H
2
+#define _IPXE_EFI_HII_H
3
+
4
+/** @file
5
+ *
6
+ * EFI human interface infrastructure
7
+ */
8
+
9
+FILE_LICENCE ( GPL2_OR_LATER );
10
+
11
+#include <ipxe/efi/Uefi/UefiInternalFormRepresentation.h>
12
+#include <ipxe/efi/Guid/MdeModuleHii.h>
13
+
14
+/**
15
+ * Define an EFI IFR form set type
16
+ *
17
+ * @v num_class_guids	Number of class GUIDs
18
+ * @ret type		Form set type
19
+ */
20
+#define EFI_IFR_FORM_SET_TYPE( num_class_guids )			   \
21
+	struct {							   \
22
+		EFI_IFR_FORM_SET FormSet;				   \
23
+		EFI_GUID ClassGuid[num_class_guids];			   \
24
+	} __attribute__ (( packed ))
25
+
26
+/**
27
+ * Define an EFI IFR form set
28
+ *
29
+ * @v guid		GUID
30
+ * @v title		Title string
31
+ * @v help		Help string
32
+ * @v type		Form set type (as returned by EFI_IFR_FORM_SET_TYPE())
33
+ * @ret ifr		Form set
34
+ *
35
+ * This definition opens a new scope, which must be closed by an
36
+ * EFI_IFR_END().
37
+ */
38
+#define EFI_IFR_FORM_SET( guid, title, help, type, ... ) {		   \
39
+	.FormSet = {							   \
40
+		.Header = {						   \
41
+			.OpCode = EFI_IFR_FORM_SET_OP,			   \
42
+			.Length = sizeof ( type ),			   \
43
+			.Scope = 1,					   \
44
+		},							   \
45
+		.Guid = guid,						   \
46
+		.FormSetTitle = title,					   \
47
+		.Help = help,						   \
48
+		.Flags = ( sizeof ( ( ( type * ) NULL )->ClassGuid ) /	   \
49
+			   sizeof ( ( ( type * ) NULL )->ClassGuid[0] ) ), \
50
+	},								   \
51
+	.ClassGuid = {							   \
52
+		__VA_ARGS__						   \
53
+	},								   \
54
+	}
55
+
56
+/**
57
+ * Define an EFI IFR GUID class
58
+ *
59
+ * @v class		Class
60
+ * @ret ifr		GUID class
61
+ */
62
+#define EFI_IFR_GUID_CLASS( class ) {					   \
63
+	.Header = {							   \
64
+		.OpCode = EFI_IFR_GUID_OP,				   \
65
+		.Length = sizeof ( EFI_IFR_GUID_CLASS ),		   \
66
+	},								   \
67
+	.Guid = EFI_IFR_TIANO_GUID,					   \
68
+	.ExtendOpCode = EFI_IFR_EXTEND_OP_CLASS,			   \
69
+	.Class = class,							   \
70
+	}
71
+
72
+/**
73
+ * Define an EFI IFR GUID subclass
74
+ *
75
+ * @v subclass		Subclass
76
+ * @ret ifr		GUID subclass
77
+ */
78
+#define EFI_IFR_GUID_SUBCLASS( subclass ) {				   \
79
+	.Header = {							   \
80
+		.OpCode = EFI_IFR_GUID_OP,				   \
81
+		.Length = sizeof ( EFI_IFR_GUID_SUBCLASS ),		   \
82
+	},								   \
83
+	.Guid = EFI_IFR_TIANO_GUID,					   \
84
+	.ExtendOpCode = EFI_IFR_EXTEND_OP_SUBCLASS,			   \
85
+	.SubClass = subclass,						   \
86
+	}
87
+
88
+/**
89
+ * Define an EFI IFR form
90
+ *
91
+ * @v formid		Form ID
92
+ * @v title		Title string
93
+ * @ret ifr		Form
94
+ *
95
+ * This definition opens a new scope, which must be closed by an
96
+ * EFI_IFR_END().
97
+ */
98
+#define EFI_IFR_FORM( formid, title ) {					   \
99
+	.Header = {							   \
100
+		.OpCode = EFI_IFR_FORM_OP,				   \
101
+		.Length = sizeof ( EFI_IFR_FORM ),			   \
102
+		.Scope = 1,						   \
103
+	},								   \
104
+	.FormId = formid,						   \
105
+	.FormTitle = title,						   \
106
+	}
107
+
108
+/**
109
+ * Define an EFI IFR text widget
110
+ *
111
+ * @v prompt		Prompt string
112
+ * @v help		Help string
113
+ * @v text		Text string
114
+ * @ret ifr		Text widget
115
+ */
116
+#define EFI_IFR_TEXT( prompt, help, text ) {				   \
117
+	.Header = {							   \
118
+		.OpCode = EFI_IFR_TEXT_OP,				   \
119
+		.Length = sizeof ( EFI_IFR_TEXT ),			   \
120
+	},								   \
121
+	.Statement = {							   \
122
+		.Prompt = prompt,					   \
123
+		.Help = help,						   \
124
+	},								   \
125
+	.TextTwo = text,						   \
126
+	}
127
+
128
+/**
129
+ * Define an EFI IFR end marker
130
+ *
131
+ * @ret ifr		End marker
132
+ */
133
+#define EFI_IFR_END() {							   \
134
+	.Header = {							   \
135
+		.OpCode = EFI_IFR_END_OP,				   \
136
+		.Length = sizeof ( EFI_IFR_END ),			   \
137
+	},								   \
138
+	}
139
+
140
+#endif /* _IPXE_EFI_HII_H */

+ 374
- 0
src/interface/efi/efi_snp.c 查看文件

@@ -31,9 +31,13 @@ FILE_LICENCE ( GPL2_OR_LATER );
31 31
 #include <ipxe/efi/efi_pci.h>
32 32
 #include <ipxe/efi/efi_driver.h>
33 33
 #include <ipxe/efi/efi_strings.h>
34
+#include <ipxe/efi/efi_hii.h>
34 35
 #include <ipxe/efi/Protocol/SimpleNetwork.h>
35 36
 #include <ipxe/efi/Protocol/NetworkInterfaceIdentifier.h>
36 37
 #include <ipxe/efi/Protocol/DevicePath.h>
38
+#include <ipxe/efi/Protocol/HiiConfigAccess.h>
39
+#include <ipxe/efi/Protocol/HiiDatabase.h>
40
+#include <config/general.h>
37 41
 
38 42
 /** @file
39 43
  *
@@ -71,6 +75,12 @@ struct efi_snp_device {
71 75
 	unsigned int rx_count_events;
72 76
 	/** The network interface identifier */
73 77
 	EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL nii;
78
+	/** HII configuration access protocol */
79
+	EFI_HII_CONFIG_ACCESS_PROTOCOL hii;
80
+	/** HII package list */
81
+	EFI_HII_PACKAGE_LIST_HEADER *package_list;
82
+	/** HII handle */
83
+	EFI_HII_HANDLE hii_handle;
74 84
 	/** Device name */
75 85
 	wchar_t name[ sizeof ( ( ( struct net_device * ) NULL )->name ) ];
76 86
 	/** The device path
@@ -744,6 +754,339 @@ static EFI_SIMPLE_NETWORK_PROTOCOL efi_snp_device_snp = {
744 754
 	.Receive	= efi_snp_receive,
745 755
 };
746 756
 
757
+/******************************************************************************
758
+ *
759
+ * Human Interface Infrastructure
760
+ *
761
+ ******************************************************************************
762
+ */
763
+
764
+/** EFI configuration access protocol GUID */
765
+static EFI_GUID efi_hii_config_access_protocol_guid
766
+	= EFI_HII_CONFIG_ACCESS_PROTOCOL_GUID;
767
+
768
+/** EFI HII database protocol */
769
+static EFI_HII_DATABASE_PROTOCOL *efihii;
770
+EFI_REQUIRE_PROTOCOL ( EFI_HII_DATABASE_PROTOCOL, &efihii );
771
+
772
+/** Local GUID used for our EFI SNP formset */
773
+#define EFI_SNP_FORMSET_GUID						\
774
+	{ 0xc4f84019, 0x6dfd, 0x4a27,					\
775
+	  { 0x9b, 0x94, 0xb7, 0x2e, 0x1f, 0xbc, 0xad, 0xca } }
776
+
777
+/** Form identifiers used for our EFI SNP HII */
778
+enum efi_snp_hii_form_id {
779
+	EFI_SNP_FORM = 0x0001,		/**< The only form */
780
+};
781
+
782
+/** String identifiers used for our EFI SNP HII */
783
+enum efi_snp_hii_string_id {
784
+	/* Language name */
785
+	EFI_SNP_LANGUAGE_NAME = 0x0001,
786
+	/* Formset */
787
+	EFI_SNP_FORMSET_TITLE, EFI_SNP_FORMSET_HELP,
788
+	/* Product name */
789
+	EFI_SNP_PRODUCT_PROMPT, EFI_SNP_PRODUCT_HELP, EFI_SNP_PRODUCT_TEXT,
790
+	/* Version */
791
+	EFI_SNP_VERSION_PROMPT, EFI_SNP_VERSION_HELP, EFI_SNP_VERSION_TEXT,
792
+	/* Driver */
793
+	EFI_SNP_DRIVER_PROMPT, EFI_SNP_DRIVER_HELP, EFI_SNP_DRIVER_TEXT,
794
+	/* Device */
795
+	EFI_SNP_DEVICE_PROMPT, EFI_SNP_DEVICE_HELP, EFI_SNP_DEVICE_TEXT,
796
+	/* End of list */
797
+	EFI_SNP_MAX_STRING_ID
798
+};
799
+
800
+/** EFI SNP formset */
801
+struct efi_snp_formset {
802
+	EFI_HII_PACKAGE_HEADER Header;
803
+	EFI_IFR_FORM_SET_TYPE(1) FormSet;
804
+	EFI_IFR_GUID_CLASS Class;
805
+	EFI_IFR_GUID_SUBCLASS SubClass;
806
+	EFI_IFR_FORM Form;
807
+	EFI_IFR_TEXT ProductText;
808
+	EFI_IFR_TEXT VersionText;
809
+	EFI_IFR_TEXT DriverText;
810
+	EFI_IFR_TEXT DeviceText;
811
+	EFI_IFR_END EndForm;
812
+	EFI_IFR_END EndFormSet;
813
+} __attribute__ (( packed )) efi_snp_formset = {
814
+	.Header = {
815
+		.Length = sizeof ( efi_snp_formset ),
816
+		.Type = EFI_HII_PACKAGE_FORMS,
817
+	},
818
+	.FormSet = EFI_IFR_FORM_SET ( EFI_SNP_FORMSET_GUID,
819
+				      EFI_SNP_FORMSET_TITLE,
820
+				      EFI_SNP_FORMSET_HELP,
821
+				      typeof ( efi_snp_formset.FormSet ),
822
+				      EFI_HII_PLATFORM_SETUP_FORMSET_GUID ),
823
+	.Class = EFI_IFR_GUID_CLASS ( EFI_NETWORK_DEVICE_CLASS ),
824
+	.SubClass = EFI_IFR_GUID_SUBCLASS ( 0x03 ),
825
+	.Form = EFI_IFR_FORM ( EFI_SNP_FORM, EFI_SNP_FORMSET_TITLE ),
826
+	.ProductText = EFI_IFR_TEXT ( EFI_SNP_PRODUCT_PROMPT,
827
+				      EFI_SNP_PRODUCT_HELP,
828
+				      EFI_SNP_PRODUCT_TEXT ),
829
+	.VersionText = EFI_IFR_TEXT ( EFI_SNP_VERSION_PROMPT,
830
+				      EFI_SNP_VERSION_HELP,
831
+				      EFI_SNP_VERSION_TEXT ),
832
+	.DriverText = EFI_IFR_TEXT ( EFI_SNP_DRIVER_PROMPT,
833
+				     EFI_SNP_DRIVER_HELP,
834
+				     EFI_SNP_DRIVER_TEXT ),
835
+	.DeviceText = EFI_IFR_TEXT ( EFI_SNP_DEVICE_PROMPT,
836
+				     EFI_SNP_DEVICE_HELP,
837
+				     EFI_SNP_DEVICE_TEXT ),
838
+	.EndForm = EFI_IFR_END(),
839
+	.EndFormSet = EFI_IFR_END(),
840
+};
841
+
842
+/**
843
+ * Generate EFI SNP string
844
+ *
845
+ * @v wbuf		Buffer
846
+ * @v swlen		Size of buffer (in wide characters)
847
+ * @v snpdev		SNP device
848
+ * @ret wlen		Length of string (in wide characters)
849
+ */
850
+static int efi_snp_string ( wchar_t *wbuf, ssize_t swlen,
851
+			    enum efi_snp_hii_string_id id,
852
+			    struct efi_snp_device *snpdev ) {
853
+	struct net_device *netdev = snpdev->netdev;
854
+	struct device *dev = netdev->dev;
855
+
856
+	switch ( id ) {
857
+	case EFI_SNP_LANGUAGE_NAME:
858
+		return efi_ssnprintf ( wbuf, swlen, "English" );
859
+	case EFI_SNP_FORMSET_TITLE:
860
+		return efi_ssnprintf ( wbuf, swlen, "%s (%s)",
861
+				       ( PRODUCT_NAME[0] ?
862
+					 PRODUCT_NAME : PRODUCT_SHORT_NAME ),
863
+				       netdev_addr ( netdev ) );
864
+	case EFI_SNP_FORMSET_HELP:
865
+		return efi_ssnprintf ( wbuf, swlen,
866
+				       "Configure " PRODUCT_SHORT_NAME );
867
+	case EFI_SNP_PRODUCT_PROMPT:
868
+		return efi_ssnprintf ( wbuf, swlen, "Name" );
869
+	case EFI_SNP_PRODUCT_HELP:
870
+		return efi_ssnprintf ( wbuf, swlen, "Firmware product name" );
871
+	case EFI_SNP_PRODUCT_TEXT:
872
+		return efi_ssnprintf ( wbuf, swlen, "%s",
873
+				       ( PRODUCT_NAME[0] ?
874
+					 PRODUCT_NAME : PRODUCT_SHORT_NAME ) );
875
+	case EFI_SNP_VERSION_PROMPT:
876
+		return efi_ssnprintf ( wbuf, swlen, "Version" );
877
+	case EFI_SNP_VERSION_HELP:
878
+		return efi_ssnprintf ( wbuf, swlen, "Firmware version" );
879
+	case EFI_SNP_VERSION_TEXT:
880
+		return efi_ssnprintf ( wbuf, swlen, VERSION );
881
+	case EFI_SNP_DRIVER_PROMPT:
882
+		return efi_ssnprintf ( wbuf, swlen, "Driver" );
883
+	case EFI_SNP_DRIVER_HELP:
884
+		return efi_ssnprintf ( wbuf, swlen, "Firmware driver" );
885
+	case EFI_SNP_DRIVER_TEXT:
886
+		return efi_ssnprintf ( wbuf, swlen, "%s", dev->driver_name );
887
+	case EFI_SNP_DEVICE_PROMPT:
888
+		return efi_ssnprintf ( wbuf, swlen, "Device" );
889
+	case EFI_SNP_DEVICE_HELP:
890
+		return efi_ssnprintf ( wbuf, swlen, "Hardware device" );
891
+	case EFI_SNP_DEVICE_TEXT:
892
+		return efi_ssnprintf ( wbuf, swlen, "%s", dev->name );
893
+	default:
894
+		assert ( 0 );
895
+		return 0;
896
+	}
897
+}
898
+
899
+/**
900
+ * Generate EFI SNP string package
901
+ *
902
+ * @v strings		String package header buffer
903
+ * @v max_len		Buffer length
904
+ * @v snpdev		SNP device
905
+ * @ret len		Length of string package
906
+ */
907
+static int efi_snp_strings ( EFI_HII_STRING_PACKAGE_HDR *strings,
908
+			     size_t max_len, struct efi_snp_device *snpdev ) {
909
+	static const char language[] = "en-us";
910
+	void *buf = strings;
911
+	ssize_t remaining = max_len;
912
+	size_t hdrsize;
913
+	EFI_HII_SIBT_STRING_UCS2_BLOCK *string;
914
+	ssize_t wremaining;
915
+	size_t string_wlen;
916
+	unsigned int id;
917
+	EFI_HII_STRING_BLOCK *end;
918
+	size_t len;
919
+
920
+	/* Calculate header size */
921
+	hdrsize = ( offsetof ( typeof ( *strings ), Language ) +
922
+		    sizeof ( language ) );
923
+	buf += hdrsize;
924
+	remaining -= hdrsize;
925
+
926
+	/* Fill in strings */
927
+	for ( id = 1 ; id < EFI_SNP_MAX_STRING_ID ; id++ ) {
928
+		string = buf;
929
+		if ( remaining >= ( ( ssize_t ) sizeof ( string->Header ) ) )
930
+			string->Header.BlockType = EFI_HII_SIBT_STRING_UCS2;
931
+		buf += offsetof ( typeof ( *string ), StringText );
932
+		remaining -= offsetof ( typeof ( *string ), StringText );
933
+		wremaining = ( remaining /
934
+			       ( ( ssize_t ) sizeof ( string->StringText[0] )));
935
+		assert ( ! ( ( remaining <= 0 ) && ( wremaining > 0 ) ) );
936
+		string_wlen = efi_snp_string ( string->StringText, wremaining,
937
+					       id, snpdev );
938
+		buf += ( ( string_wlen + 1 /* wNUL */ ) *
939
+			 sizeof ( string->StringText[0] ) );
940
+		remaining -= ( ( string_wlen + 1 /* wNUL */ ) *
941
+			       sizeof ( string->StringText[0] ) );
942
+	}
943
+
944
+	/* Fill in end marker */
945
+	end = buf;
946
+	if ( remaining >= ( ( ssize_t ) sizeof ( *end ) ) )
947
+		end->BlockType = EFI_HII_SIBT_END;
948
+	buf += sizeof ( *end );
949
+	remaining -= sizeof ( *end );
950
+
951
+	/* Calculate overall length */
952
+	len = ( max_len - remaining );
953
+
954
+	/* Fill in string package header */
955
+	if ( strings ) {
956
+		memset ( strings, 0, sizeof ( *strings ) );
957
+		strings->Header.Length = len;
958
+		strings->Header.Type = EFI_HII_PACKAGE_STRINGS;
959
+		strings->HdrSize = hdrsize;
960
+		strings->StringInfoOffset = hdrsize;
961
+		strings->LanguageName = EFI_SNP_LANGUAGE_NAME;
962
+		memcpy ( strings->Language, language, sizeof ( language ) );
963
+	}
964
+
965
+	return len;
966
+}
967
+
968
+/**
969
+ * Generate EFI SNP package list
970
+ *
971
+ * @v snpdev		SNP device
972
+ * @ret package_list	Package list, or NULL on error
973
+ *
974
+ * The package list is allocated using malloc(), and must eventually
975
+ * be freed by the caller.
976
+ */
977
+static EFI_HII_PACKAGE_LIST_HEADER *
978
+efi_snp_package_list ( struct efi_snp_device *snpdev ) {
979
+	size_t strings_len = efi_snp_strings ( NULL, 0, snpdev );
980
+	struct {
981
+		EFI_HII_PACKAGE_LIST_HEADER header;
982
+		struct efi_snp_formset formset;
983
+		union {
984
+			EFI_HII_STRING_PACKAGE_HDR strings;
985
+			uint8_t pad[strings_len];
986
+		} __attribute__ (( packed )) strings;
987
+		EFI_HII_PACKAGE_HEADER end;
988
+	} __attribute__ (( packed )) *package_list;
989
+
990
+	/* Allocate package list */
991
+	package_list = zalloc ( sizeof ( *package_list ) );
992
+	if ( ! package_list )
993
+		return NULL;
994
+
995
+	/* Populate package list */
996
+	memcpy ( &package_list->header.PackageListGuid,
997
+		 &efi_snp_formset.FormSet.FormSet.Guid,
998
+		 sizeof ( package_list->header.PackageListGuid ) );
999
+	package_list->header.PackageLength = sizeof ( *package_list );
1000
+	memcpy ( &package_list->formset, &efi_snp_formset,
1001
+		 sizeof ( package_list->formset ) );
1002
+	efi_snp_strings ( &package_list->strings.strings,
1003
+			  sizeof ( package_list->strings ), snpdev );
1004
+	package_list->end.Length = sizeof ( package_list->end );
1005
+	package_list->end.Type = EFI_HII_PACKAGE_END;
1006
+
1007
+	return &package_list->header;
1008
+}
1009
+
1010
+/**
1011
+ * Fetch configuration
1012
+ *
1013
+ * @v hii		HII configuration access protocol
1014
+ * @v request		Configuration to fetch
1015
+ * @ret progress	Progress made through configuration to fetch
1016
+ * @ret results		Query results
1017
+ * @ret efirc		EFI status code
1018
+ */
1019
+static EFI_STATUS EFIAPI
1020
+efi_snp_hii_extract_config ( const EFI_HII_CONFIG_ACCESS_PROTOCOL *hii,
1021
+			     EFI_STRING request, EFI_STRING *progress,
1022
+			     EFI_STRING *results __unused ) {
1023
+	struct efi_snp_device *snpdev =
1024
+		container_of ( hii, struct efi_snp_device, hii );
1025
+
1026
+	DBGC ( snpdev, "SNPDEV %p ExtractConfig\n", snpdev );
1027
+
1028
+	*progress = request;
1029
+	return EFI_INVALID_PARAMETER;
1030
+}
1031
+
1032
+/**
1033
+ * Store configuration
1034
+ *
1035
+ * @v hii		HII configuration access protocol
1036
+ * @v config		Configuration to store
1037
+ * @ret progress	Progress made through configuration to store
1038
+ * @ret efirc		EFI status code
1039
+ */
1040
+static EFI_STATUS EFIAPI
1041
+efi_snp_hii_route_config ( const EFI_HII_CONFIG_ACCESS_PROTOCOL *hii,
1042
+			   EFI_STRING config, EFI_STRING *progress ) {
1043
+	struct efi_snp_device *snpdev =
1044
+		container_of ( hii, struct efi_snp_device, hii );
1045
+
1046
+	DBGC ( snpdev, "SNPDEV %p RouteConfig\n", snpdev );
1047
+
1048
+	*progress = config;
1049
+	return EFI_INVALID_PARAMETER;
1050
+}
1051
+
1052
+/**
1053
+ * Handle form actions
1054
+ *
1055
+ * @v hii		HII configuration access protocol
1056
+ * @v action		Form browser action
1057
+ * @v question_id	Question ID
1058
+ * @v type		Type of value
1059
+ * @v value		Value
1060
+ * @ret action_request	Action requested by driver
1061
+ * @ret efirc		EFI status code
1062
+ */
1063
+static EFI_STATUS EFIAPI
1064
+efi_snp_hii_callback ( const EFI_HII_CONFIG_ACCESS_PROTOCOL *hii,
1065
+		       EFI_BROWSER_ACTION action __unused,
1066
+		       EFI_QUESTION_ID question_id __unused,
1067
+		       UINT8 type __unused, EFI_IFR_TYPE_VALUE *value __unused,
1068
+		       EFI_BROWSER_ACTION_REQUEST *action_request __unused ) {
1069
+	struct efi_snp_device *snpdev =
1070
+		container_of ( hii, struct efi_snp_device, hii );
1071
+
1072
+	DBGC ( snpdev, "SNPDEV %p Callback\n", snpdev );
1073
+	return EFI_UNSUPPORTED;
1074
+}
1075
+
1076
+/** HII configuration access protocol */
1077
+static EFI_HII_CONFIG_ACCESS_PROTOCOL efi_snp_device_hii = {
1078
+	.ExtractConfig	= efi_snp_hii_extract_config,
1079
+	.RouteConfig	= efi_snp_hii_route_config,
1080
+	.Callback	= efi_snp_hii_callback,
1081
+};
1082
+
1083
+/******************************************************************************
1084
+ *
1085
+ * iPXE network driver
1086
+ *
1087
+ ******************************************************************************
1088
+ */
1089
+
747 1090
 /**
748 1091
  * Locate SNP device corresponding to network device
749 1092
  *
@@ -830,6 +1173,9 @@ static int efi_snp_probe ( struct net_device *netdev ) {
830 1173
 	strncpy ( snpdev->nii.StringId, "iPXE",
831 1174
 		  sizeof ( snpdev->nii.StringId ) );
832 1175
 
1176
+	/* Populate the HII configuration access structure */
1177
+	memcpy ( &snpdev->hii, &efi_snp_device_hii, sizeof ( snpdev->hii ) );
1178
+
833 1179
 	/* Populate the device name */
834 1180
 	efi_snprintf ( snpdev->name, ( sizeof ( snpdev->name ) /
835 1181
 				       sizeof ( snpdev->name[0] ) ),
@@ -858,6 +1204,7 @@ static int efi_snp_probe ( struct net_device *netdev ) {
858 1204
 			&efi_device_path_protocol_guid, &snpdev->path,
859 1205
 			&efi_nii_protocol_guid, &snpdev->nii,
860 1206
 			&efi_nii31_protocol_guid, &snpdev->nii,
1207
+			&efi_hii_config_access_protocol_guid, &snpdev->hii,
861 1208
 			NULL ) ) != 0 ) {
862 1209
 		DBGC ( snpdev, "SNPDEV %p could not install protocols: "
863 1210
 		       "%s\n", snpdev, efi_strerror ( efirc ) );
@@ -874,6 +1221,25 @@ static int efi_snp_probe ( struct net_device *netdev ) {
874 1221
 		goto err_efipci_child_add;
875 1222
 	}
876 1223
 
1224
+	/* Create HII package list */
1225
+	snpdev->package_list = efi_snp_package_list ( snpdev );
1226
+	if ( ! snpdev->package_list ) {
1227
+		DBGC ( snpdev, "SNPDEV %p could not create HII package list\n",
1228
+		       snpdev );
1229
+		rc = -ENOMEM;
1230
+		goto err_create_hii;
1231
+	}
1232
+
1233
+	/* Add HII packages */
1234
+	if ( ( efirc = efihii->NewPackageList ( efihii, snpdev->package_list,
1235
+						snpdev->handle,
1236
+						&snpdev->hii_handle ) ) != 0 ) {
1237
+		DBGC ( snpdev, "SNPDEV %p could not add HII packages: %s\n",
1238
+		       snpdev, efi_strerror ( efirc ) );
1239
+		rc = EFIRC_TO_RC ( efirc );
1240
+		goto err_register_hii;
1241
+	}
1242
+
877 1243
 	/* Add to list of SNP devices */
878 1244
 	list_add ( &snpdev->list, &efi_snp_devices );
879 1245
 
@@ -881,6 +1247,10 @@ static int efi_snp_probe ( struct net_device *netdev ) {
881 1247
 	       snpdev, netdev->name, snpdev->handle );
882 1248
 	return 0;
883 1249
 
1250
+	efihii->RemovePackageList ( efihii, snpdev->hii_handle );
1251
+ err_register_hii:
1252
+	free ( snpdev->package_list );
1253
+ err_create_hii:
884 1254
 	efipci_child_del ( efipci, snpdev->handle );
885 1255
  err_efipci_child_add:
886 1256
 	bs->UninstallMultipleProtocolInterfaces (
@@ -889,6 +1259,7 @@ static int efi_snp_probe ( struct net_device *netdev ) {
889 1259
 			&efi_device_path_protocol_guid, &snpdev->path,
890 1260
 			&efi_nii_protocol_guid, &snpdev->nii,
891 1261
 			&efi_nii31_protocol_guid, &snpdev->nii,
1262
+			&efi_hii_config_access_protocol_guid, &snpdev->hii,
892 1263
 			NULL );
893 1264
  err_install_protocol_interface:
894 1265
 	bs->CloseEvent ( snpdev->snp.WaitForPacket );
@@ -927,6 +1298,8 @@ static void efi_snp_remove ( struct net_device *netdev ) {
927 1298
 	}
928 1299
 
929 1300
 	/* Uninstall the SNP */
1301
+	efihii->RemovePackageList ( efihii, snpdev->hii_handle );
1302
+	free ( snpdev->package_list );
930 1303
 	efipci_child_del ( snpdev->efipci, snpdev->handle );
931 1304
 	list_del ( &snpdev->list );
932 1305
 	bs->UninstallMultipleProtocolInterfaces (
@@ -935,6 +1308,7 @@ static void efi_snp_remove ( struct net_device *netdev ) {
935 1308
 			&efi_device_path_protocol_guid, &snpdev->path,
936 1309
 			&efi_nii_protocol_guid, &snpdev->nii,
937 1310
 			&efi_nii31_protocol_guid, &snpdev->nii,
1311
+			&efi_hii_config_access_protocol_guid, &snpdev->hii,
938 1312
 			NULL );
939 1313
 	bs->CloseEvent ( snpdev->snp.WaitForPacket );
940 1314
 	netdev_put ( snpdev->netdev );

正在加载...
取消
保存