iPXE
Functions | Variables
efi_snp_hii.c File Reference

EFI SNP HII protocol. More...

#include <string.h>
#include <strings.h>
#include <stdlib.h>
#include <stdio.h>
#include <wchar.h>
#include <errno.h>
#include <ipxe/settings.h>
#include <ipxe/nvo.h>
#include <ipxe/device.h>
#include <ipxe/netdevice.h>
#include <ipxe/version.h>
#include <ipxe/efi/efi.h>
#include <ipxe/efi/efi_hii.h>
#include <ipxe/efi/efi_snp.h>
#include <ipxe/efi/efi_strings.h>
#include <ipxe/efi/efi_utils.h>
#include <config/branding.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
 EFI_REQUEST_PROTOCOL (EFI_HII_DATABASE_PROTOCOL, &efihii)
 
static struct settingsefi_snp_hii_settings (struct efi_snp_device *snpdev)
 Identify settings to be exposed via HII. More...
 
static int efi_snp_hii_setting_applies (struct efi_snp_device *snpdev, struct setting *setting)
 Check whether or not setting is applicable. More...
 
static void efi_snp_hii_random_guid (EFI_GUID *guid)
 Generate a random GUID. More...
 
static void efi_snp_hii_questions (struct efi_snp_device *snpdev, struct efi_ifr_builder *ifr, unsigned int varstore_id)
 Generate EFI SNP questions. More...
 
static EFI_HII_PACKAGE_LIST_HEADERefi_snp_hii_package_list (struct efi_snp_device *snpdev)
 Build HII package list for SNP device. More...
 
static int efi_snp_hii_append (struct efi_snp_device *snpdev __unused, const char *key, const char *value, wchar_t **results)
 Append response to result string. More...
 
static int efi_snp_hii_fetch (struct efi_snp_device *snpdev, const char *key, const char *value, wchar_t **results, int *have_setting)
 Fetch HII setting. More...
 
static int efi_snp_hii_store (struct efi_snp_device *snpdev, const char *key, const char *value, wchar_t **results __unused, int *have_setting __unused)
 Fetch HII setting. More...
 
static int efi_snp_hii_process (struct efi_snp_device *snpdev, wchar_t *string, wchar_t **progress, wchar_t **results, int *have_setting, int(*process)(struct efi_snp_device *, const char *key, const char *value, wchar_t **results, int *have_setting))
 Process portion of HII configuration string. More...
 
static EFI_STATUS EFIAPI efi_snp_hii_extract_config (const EFI_HII_CONFIG_ACCESS_PROTOCOL *hii, EFI_STRING request, EFI_STRING *progress, EFI_STRING *results)
 Fetch configuration. More...
 
static EFI_STATUS EFIAPI efi_snp_hii_route_config (const EFI_HII_CONFIG_ACCESS_PROTOCOL *hii, EFI_STRING config, EFI_STRING *progress)
 Store configuration. More...
 
static EFI_STATUS EFIAPI efi_snp_hii_callback (const EFI_HII_CONFIG_ACCESS_PROTOCOL *hii, EFI_BROWSER_ACTION action __unused, EFI_QUESTION_ID question_id __unused, UINT8 type __unused, EFI_IFR_TYPE_VALUE *value __unused, EFI_BROWSER_ACTION_REQUEST *action_request __unused)
 Handle form actions. More...
 
int efi_snp_hii_install (struct efi_snp_device *snpdev)
 Install HII protocol and packages for SNP device. More...
 
void efi_snp_hii_uninstall (struct efi_snp_device *snpdev)
 Uninstall HII protocol and package for SNP device. More...
 

Variables

static EFI_GUID efi_hii_platform_setup_formset_guid = EFI_HII_PLATFORM_SETUP_FORMSET_GUID
 EFI platform setup formset GUID. More...
 
static EFI_GUID efi_hii_ibm_ucm_compliant_formset_guid = EFI_HII_IBM_UCM_COMPLIANT_FORMSET_GUID
 EFI IBM UCM compliant formset GUID. More...
 
static EFI_HII_DATABASE_PROTOCOLefihii
 EFI HII database protocol. More...
 
static EFI_HII_CONFIG_ACCESS_PROTOCOL efi_snp_device_hii
 HII configuration access protocol. More...
 

Detailed Description

EFI SNP HII protocol.

The HII protocols are some of the less-well designed parts of the entire EFI specification. This is a significant accomplishment.

The face-slappingly ludicrous query string syntax seems to be motivated by the desire to allow a caller to query multiple drivers simultaneously via the single-instance HII_CONFIG_ROUTING_PROTOCOL, which is supposed to pass relevant subsets of the query string to the relevant drivers.

Nobody uses the HII_CONFIG_ROUTING_PROTOCOL. Not even the EFI setup browser uses the HII_CONFIG_ROUTING_PROTOCOL. To the best of my knowledge, there has only ever been one implementation of the HII_CONFIG_ROUTING_PROTOCOL (as part of EDK2), and it just doesn't work. It's so badly broken that I can't even figure out what the code is trying to do.

Fundamentally, the problem seems to be that Javascript programmers should not be allowed to design APIs for C code.

Definition in file efi_snp_hii.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ EFI_REQUEST_PROTOCOL()

EFI_REQUEST_PROTOCOL ( EFI_HII_DATABASE_PROTOCOL  ,
efihii 
)

◆ efi_snp_hii_settings()

static struct settings* efi_snp_hii_settings ( struct efi_snp_device snpdev)
static

Identify settings to be exposed via HII.

Parameters
snpdevSNP device
Return values
settingsSettings, or NULL

Definition at line 87 of file efi_snp_hii.c.

87  {
88 
89  return find_child_settings ( netdev_settings ( snpdev->netdev ),
91 }
static struct settings * netdev_settings(struct net_device *netdev)
Get per-netdevice configuration settings block.
Definition: netdevice.h:577
struct net_device * netdev
The underlying iPXE network device.
Definition: efi_snp.h:31
#define NVO_SETTINGS_NAME
Name of non-volatile options settings block.
Definition: nvo.h:46
struct settings * find_child_settings(struct settings *parent, const char *name)
Find child settings block.
Definition: settings.c:279

References find_child_settings(), efi_snp_device::netdev, netdev_settings(), and NVO_SETTINGS_NAME.

Referenced by efi_snp_hii_fetch(), efi_snp_hii_setting_applies(), and efi_snp_hii_store().

◆ efi_snp_hii_setting_applies()

static int efi_snp_hii_setting_applies ( struct efi_snp_device snpdev,
struct setting setting 
)
static

Check whether or not setting is applicable.

Parameters
snpdevSNP device
settingSetting
Return values
appliesSetting applies

Definition at line 100 of file efi_snp_hii.c.

101  {
102 
103  return nvo_applies ( efi_snp_hii_settings ( snpdev ), setting );
104 }
int nvo_applies(struct settings *settings __unused, const struct setting *setting)
Check applicability of NVO setting.
Definition: nvo.c:199
static struct settings * efi_snp_hii_settings(struct efi_snp_device *snpdev)
Identify settings to be exposed via HII.
Definition: efi_snp_hii.c:87
A setting.
Definition: settings.h:23

References efi_snp_hii_settings(), and nvo_applies().

Referenced by efi_snp_hii_extract_config(), and efi_snp_hii_questions().

◆ efi_snp_hii_random_guid()

static void efi_snp_hii_random_guid ( EFI_GUID guid)
static

Generate a random GUID.

Parameters
guidGUID to fill in

Definition at line 111 of file efi_snp_hii.c.

111  {
112  uint8_t *byte = ( ( uint8_t * ) guid );
113  unsigned int i;
114 
115  for ( i = 0 ; i < sizeof ( *guid ) ; i++ )
116  *(byte++) = random();
117 }
long int random(void)
Generate a pseudo-random number between 0 and 2147483647L or 2147483562?
Definition: random.c:30
unsigned char uint8_t
Definition: stdint.h:10
uint64_t guid
GUID.
Definition: edd.h:30

References guid, and random().

Referenced by efi_snp_hii_install(), and efi_snp_hii_package_list().

◆ efi_snp_hii_questions()

static void efi_snp_hii_questions ( struct efi_snp_device snpdev,
struct efi_ifr_builder ifr,
unsigned int  varstore_id 
)
static

Generate EFI SNP questions.

Parameters
snpdevSNP device
ifrIFR builder
varstore_idVariable store identifier

Definition at line 126 of file efi_snp_hii.c.

128  {
129  struct setting *setting;
130  struct setting *previous = NULL;
131  unsigned int name_id;
132  unsigned int prompt_id;
133  unsigned int help_id;
134  unsigned int question_id;
135 
136  /* Add all applicable settings */
138  if ( ! efi_snp_hii_setting_applies ( snpdev, setting ) )
139  continue;
140  if ( previous && ( setting_cmp ( setting, previous ) == 0 ) )
141  continue;
142  previous = setting;
143  name_id = efi_ifr_string ( ifr, "%s", setting->name );
144  prompt_id = efi_ifr_string ( ifr, "%s", setting->description );
145  help_id = efi_ifr_string ( ifr, PRODUCT_SETTING_URI,
146  setting->name );
147  question_id = setting->tag;
148  efi_ifr_string_op ( ifr, prompt_id, help_id,
149  question_id, varstore_id, name_id,
150  0, 0x00, 0xff, 0 );
151  }
152 }
const char * description
Description.
Definition: settings.h:30
const char * name
Name.
Definition: settings.h:28
#define SETTINGS
Configuration setting table.
Definition: settings.h:53
void efi_ifr_string_op(struct efi_ifr_builder *ifr, unsigned int prompt_id, unsigned int help_id, unsigned int question_id, unsigned int varstore_id, unsigned int varstore_info, unsigned int vflags, unsigned int min_size, unsigned int max_size, unsigned int flags)
Add string opcode to IFR builder.
Definition: efi_hii.c:386
uint64_t tag
Setting tag, if applicable.
Definition: settings.h:43
#define PRODUCT_SETTING_URI
Definition: branding.h:170
static int efi_snp_hii_setting_applies(struct efi_snp_device *snpdev, struct setting *setting)
Check whether or not setting is applicable.
Definition: efi_snp_hii.c:100
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
Definition: tables.h:358
A setting.
Definition: settings.h:23
unsigned int efi_ifr_string(struct efi_ifr_builder *ifr, const char *fmt,...)
Add string to IFR builder.
Definition: efi_hii.c:45
int setting_cmp(const struct setting *a, const struct setting *b)
Compare two settings.
Definition: settings.c:1124
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References setting::description, efi_ifr_string(), efi_ifr_string_op(), efi_snp_hii_setting_applies(), for_each_table_entry, setting::name, NULL, PRODUCT_SETTING_URI, setting_cmp(), SETTINGS, and setting::tag.

Referenced by efi_snp_hii_package_list().

◆ efi_snp_hii_package_list()

static EFI_HII_PACKAGE_LIST_HEADER* efi_snp_hii_package_list ( struct efi_snp_device snpdev)
static

Build HII package list for SNP device.

Parameters
snpdevSNP device
Return values
packagePackage list, or NULL on error

Definition at line 161 of file efi_snp_hii.c.

161  {
162  struct net_device *netdev = snpdev->netdev;
163  struct device *dev = netdev->dev;
164  struct efi_ifr_builder ifr;
166  const char *name;
167  EFI_GUID package_guid;
168  EFI_GUID formset_guid;
169  EFI_GUID varstore_guid;
170  unsigned int title_id;
171  unsigned int varstore_id;
172 
173  /* Initialise IFR builder */
174  efi_ifr_init ( &ifr );
175 
176  /* Determine product name */
178 
179  /* Generate GUIDs */
180  efi_snp_hii_random_guid ( &package_guid );
181  efi_snp_hii_random_guid ( &formset_guid );
182  efi_snp_hii_random_guid ( &varstore_guid );
183 
184  /* Generate title string (used more than once) */
185  title_id = efi_ifr_string ( &ifr, "%s (%s)", name,
186  netdev_addr ( netdev ) );
187 
188  /* Generate opcodes */
189  efi_ifr_form_set_op ( &ifr, &formset_guid, title_id,
190  efi_ifr_string ( &ifr, "Configure %s",
195  efi_ifr_guid_subclass_op ( &ifr, 0x03 );
196  varstore_id = efi_ifr_varstore_name_value_op ( &ifr, &varstore_guid );
197  efi_ifr_form_op ( &ifr, title_id );
198  efi_ifr_text_op ( &ifr,
199  efi_ifr_string ( &ifr, "Name" ),
200  efi_ifr_string ( &ifr, "Firmware product name" ),
201  efi_ifr_string ( &ifr, "%s", name ) );
202  efi_ifr_text_op ( &ifr,
203  efi_ifr_string ( &ifr, "Version" ),
204  efi_ifr_string ( &ifr, "Firmware version" ),
205  efi_ifr_string ( &ifr, "%s", product_version ) );
206  efi_ifr_text_op ( &ifr,
207  efi_ifr_string ( &ifr, "Driver" ),
208  efi_ifr_string ( &ifr, "Firmware driver" ),
209  efi_ifr_string ( &ifr, "%s", dev->driver_name ) );
210  efi_ifr_text_op ( &ifr,
211  efi_ifr_string ( &ifr, "Device" ),
212  efi_ifr_string ( &ifr, "Hardware device" ),
213  efi_ifr_string ( &ifr, "%s", dev->name ) );
214  efi_snp_hii_questions ( snpdev, &ifr, varstore_id );
215  efi_ifr_end_op ( &ifr );
216  efi_ifr_end_op ( &ifr );
217 
218  /* Build package */
219  package = efi_ifr_package ( &ifr, &package_guid, "en-us",
220  efi_ifr_string ( &ifr, "English" ) );
221  if ( ! package ) {
222  DBGC ( snpdev, "SNPDEV %p could not build IFR package\n",
223  snpdev );
224  efi_ifr_free ( &ifr );
225  return NULL;
226  }
227 
228  /* Free temporary storage */
229  efi_ifr_free ( &ifr );
230  return package;
231 }
const char product_short_name[]
Product short name string.
Definition: version.c:75
const char * name
Definition: ath9k_hw.c:1984
void efi_ifr_form_set_op(struct efi_ifr_builder *ifr, const EFI_GUID *guid, unsigned int title_id, unsigned int help_id,...)
Add formset opcode to IFR builder.
Definition: efi_hii.c:194
static void efi_ifr_init(struct efi_ifr_builder *ifr)
Initialise IFR builder.
Definition: efi_hii.h:48
void efi_ifr_end_op(struct efi_ifr_builder *ifr)
Add end opcode to IFR builder.
Definition: efi_hii.c:132
static void efi_snp_hii_random_guid(EFI_GUID *guid)
Generate a random GUID.
Definition: efi_snp_hii.c:111
unsigned int efi_ifr_varstore_name_value_op(struct efi_ifr_builder *ifr, const EFI_GUID *guid)
Add name/value store opcode to IFR builder.
Definition: efi_hii.c:481
static EFI_GUID efi_hii_ibm_ucm_compliant_formset_guid
EFI IBM UCM compliant formset GUID.
Definition: efi_snp_hii.c:75
128 bit buffer containing a unique identifier value.
Definition: Base.h:263
#define DBGC(...)
Definition: compiler.h:505
char name[40]
Name.
Definition: device.h:75
static const char * netdev_addr(struct net_device *netdev)
Get printable network device link-layer address.
Definition: netdevice.h:521
struct net_device * netdev
The underlying iPXE network device.
Definition: efi_snp.h:31
A hardware device.
Definition: device.h:73
static void efi_snp_hii_questions(struct efi_snp_device *snpdev, struct efi_ifr_builder *ifr, unsigned int varstore_id)
Generate EFI SNP questions.
Definition: efi_snp_hii.c:126
void efi_ifr_guid_subclass_op(struct efi_ifr_builder *ifr, unsigned int subclass)
Add GUID subclass opcode to IFR builder.
Definition: efi_hii.c:288
static struct net_device * netdev
Definition: gdbudp.c:52
void efi_ifr_text_op(struct efi_ifr_builder *ifr, unsigned int prompt_id, unsigned int help_id, unsigned int text_id)
Add text opcode to IFR builder.
Definition: efi_hii.c:440
unsigned int efi_ifr_form_op(struct efi_ifr_builder *ifr, unsigned int title_id)
Add form opcode to IFR builder.
Definition: efi_hii.c:166
const char * driver_name
Driver name.
Definition: device.h:77
static EFI_GUID efi_hii_platform_setup_formset_guid
EFI platform setup formset GUID.
Definition: efi_snp_hii.c:71
unsigned int varstore_id
Current variable store identifier.
Definition: efi_hii.h:33
A network device.
Definition: netdevice.h:348
const char product_version[]
Product version string.
Definition: version.c:69
void efi_ifr_free(struct efi_ifr_builder *ifr)
Free memory used by IFR builder.
Definition: efi_hii.c:505
void efi_ifr_guid_class_op(struct efi_ifr_builder *ifr, unsigned int class)
Add GUID class opcode to IFR builder.
Definition: efi_hii.c:265
struct device * dev
Underlying hardware device.
Definition: netdevice.h:360
unsigned int efi_ifr_string(struct efi_ifr_builder *ifr, const char *fmt,...)
Add string to IFR builder.
Definition: efi_hii.c:45
#define EFI_NETWORK_DEVICE_CLASS
Definition: MdeModuleHii.h:107
An EFI IFR builder.
Definition: efi_hii.h:21
const char product_name[]
Product name string.
Definition: version.c:72
The header found at the start of each package list.
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References DBGC, net_device::dev, device::driver_name, efi_hii_ibm_ucm_compliant_formset_guid, efi_hii_platform_setup_formset_guid, efi_ifr_end_op(), efi_ifr_form_op(), efi_ifr_form_set_op(), efi_ifr_free(), efi_ifr_guid_class_op(), efi_ifr_guid_subclass_op(), efi_ifr_init(), efi_ifr_string(), efi_ifr_text_op(), efi_ifr_varstore_name_value_op(), EFI_NETWORK_DEVICE_CLASS, efi_snp_hii_questions(), efi_snp_hii_random_guid(), device::name, name, efi_snp_device::netdev, netdev, netdev_addr(), NULL, product_name, product_short_name, product_version, and efi_ifr_builder::varstore_id.

Referenced by efi_snp_hii_install().

◆ efi_snp_hii_append()

static int efi_snp_hii_append ( struct efi_snp_device *snpdev  __unused,
const char *  key,
const char *  value,
wchar_t **  results 
)
static

Append response to result string.

Parameters
snpdevSNP device
keyKey
valueValue
resultsResult string
Return values
rcReturn status code

The result string is allocated dynamically using BootServices::AllocatePool(), and the caller is responsible for eventually calling BootServices::FreePool().

Definition at line 246 of file efi_snp_hii.c.

248  {
250  EFI_STATUS efirc;
251  size_t len;
252  void *new;
253 
254  /* Allocate new string */
255  len = ( ( *results ? ( wcslen ( *results ) + 1 /* "&" */ ) : 0 ) +
256  strlen ( key ) + 1 /* "=" */ + strlen ( value ) + 1 /* NUL */ );
257  if ( ( efirc = bs->AllocatePool ( EfiBootServicesData,
258  ( len * sizeof ( wchar_t ) ),
259  &new ) ) != 0 )
260  return -EEFI ( efirc );
261 
262  /* Populate string */
263  efi_snprintf ( new, len, "%ls%s%s=%s", ( *results ? *results : L"" ),
264  ( *results ? L"&" : L"" ), key, value );
265  bs->FreePool ( *results );
266  *results = new;
267 
268  return 0;
269 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:159
size_t wcslen(const wchar_t *string)
Calculate length of wide-character string.
Definition: wchar.c:41
int efi_snprintf(wchar_t *wbuf, size_t wsize, const char *fmt,...)
Write a formatted string to a buffer.
Definition: efi_strings.c:104
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
EFI Boot Services Table.
Definition: UefiSpec.h:1836
size_t strlen(const char *src)
Get length of string.
Definition: string.c:228
EFI_FREE_POOL FreePool
Definition: UefiSpec.h:1855
uint32_t len
Length.
Definition: ena.h:14
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
EFI_SYSTEM_TABLE * efi_systab
The data portions of a loaded Boot Serves Driver, and the default data allocation type used by a Boot...
union @376 key
Sense key.
Definition: scsi.h:18
EFI_ALLOCATE_POOL AllocatePool
Definition: UefiSpec.h:1854

References EFI_BOOT_SERVICES::AllocatePool, EFI_SYSTEM_TABLE::BootServices, EEFI, efi_snprintf(), efi_systab, EfiBootServicesData, EFI_BOOT_SERVICES::FreePool, key, len, strlen(), value, and wcslen().

Referenced by efi_snp_hii_fetch().

◆ efi_snp_hii_fetch()

static int efi_snp_hii_fetch ( struct efi_snp_device snpdev,
const char *  key,
const char *  value,
wchar_t **  results,
int *  have_setting 
)
static

Fetch HII setting.

Parameters
snpdevSNP device
keyKey
valueValue
resultsResult string
have_settingFlag indicating detection of a setting
Return values
rcReturn status code

Definition at line 281 of file efi_snp_hii.c.

283  {
284  struct settings *settings = efi_snp_hii_settings ( snpdev );
285  struct settings *origin;
286  struct setting *setting;
287  struct setting fetched;
288  int len;
289  char *buf;
290  char *encoded;
291  int i;
292  int rc;
293 
294  /* Handle ConfigHdr components */
295  if ( ( strcasecmp ( key, "GUID" ) == 0 ) ||
296  ( strcasecmp ( key, "NAME" ) == 0 ) ||
297  ( strcasecmp ( key, "PATH" ) == 0 ) ) {
298  return efi_snp_hii_append ( snpdev, key, value, results );
299  }
300  if ( have_setting )
301  *have_setting = 1;
302 
303  /* Do nothing more unless we have a settings block */
304  if ( ! settings ) {
305  rc = -ENOTSUP;
306  goto err_no_settings;
307  }
308 
309  /* Identify setting */
310  setting = find_setting ( key );
311  if ( ! setting ) {
312  DBGC ( snpdev, "SNPDEV %p no such setting \"%s\"\n",
313  snpdev, key );
314  rc = -ENODEV;
315  goto err_find_setting;
316  }
317 
318  /* Encode value */
319  if ( setting_exists ( settings, setting ) ) {
320 
321  /* Calculate formatted length */
322  len = fetchf_setting ( settings, setting, &origin, &fetched,
323  NULL, 0 );
324  if ( len < 0 ) {
325  rc = len;
326  DBGC ( snpdev, "SNPDEV %p could not fetch %s: %s\n",
327  snpdev, setting->name, strerror ( rc ) );
328  goto err_fetchf_len;
329  }
330 
331  /* Allocate buffer for formatted value and HII-encoded value */
332  buf = zalloc ( len + 1 /* NUL */ + ( len * 4 ) + 1 /* NUL */ );
333  if ( ! buf ) {
334  rc = -ENOMEM;
335  goto err_alloc;
336  }
337  encoded = ( buf + len + 1 /* NUL */ );
338 
339  /* Format value */
340  fetchf_setting ( origin, &fetched, NULL, NULL, buf,
341  ( len + 1 /* NUL */ ) );
342  for ( i = 0 ; i < len ; i++ ) {
343  sprintf ( ( encoded + ( 4 * i ) ), "%04x",
344  *( ( uint8_t * ) buf + i ) );
345  }
346 
347  } else {
348 
349  /* Non-existent or inapplicable setting */
350  buf = NULL;
351  encoded = "";
352  }
353 
354  /* Append results */
355  if ( ( rc = efi_snp_hii_append ( snpdev, key, encoded,
356  results ) ) != 0 ) {
357  goto err_append;
358  }
359 
360  /* Success */
361  rc = 0;
362 
363  err_append:
364  free ( buf );
365  err_alloc:
366  err_fetchf_len:
367  err_find_setting:
368  err_no_settings:
369  return rc;
370 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
uint64_t origin
Origin.
Definition: hyperv.h:20
int fetchf_setting(struct settings *settings, const struct setting *setting, struct settings **origin, struct setting *fetched, char *buf, size_t len)
Fetch formatted value of setting.
Definition: settings.c:1233
static struct settings * efi_snp_hii_settings(struct efi_snp_device *snpdev)
Identify settings to be exposed via HII.
Definition: efi_snp_hii.c:87
#define sprintf(buf, fmt,...)
Write a formatted string to a buffer.
Definition: stdio.h:36
static int efi_snp_hii_append(struct efi_snp_device *snpdev __unused, const char *key, const char *value, wchar_t **results)
Append response to result string.
Definition: efi_snp_hii.c:246
#define DBGC(...)
Definition: compiler.h:505
int strcasecmp(const char *first, const char *second)
Compare case-insensitive strings.
Definition: string.c:207
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
const char * name
Name.
Definition: settings.h:28
#define ENOMEM
Not enough space.
Definition: errno.h:534
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
#define ENODEV
No such device.
Definition: errno.h:509
A settings block.
Definition: settings.h:132
unsigned char uint8_t
Definition: stdint.h:10
A setting.
Definition: settings.h:23
static int setting_exists(struct settings *settings, const struct setting *setting)
Check existence of predefined setting.
Definition: settings.h:538
uint32_t len
Length.
Definition: ena.h:14
struct setting * find_setting(const char *name)
Find predefined setting.
Definition: settings.c:1470
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
union @376 key
Sense key.
Definition: scsi.h:18

References DBGC, efi_snp_hii_append(), efi_snp_hii_settings(), ENODEV, ENOMEM, ENOTSUP, fetchf_setting(), find_setting(), free, key, len, setting::name, NULL, origin, rc, setting_exists(), sprintf, strcasecmp(), strerror(), value, and zalloc().

Referenced by efi_snp_hii_extract_config().

◆ efi_snp_hii_store()

static int efi_snp_hii_store ( struct efi_snp_device snpdev,
const char *  key,
const char *  value,
wchar_t **results  __unused,
int *have_setting  __unused 
)
static

Fetch HII setting.

Parameters
snpdevSNP device
keyKey
valueValue
resultsResult string (unused)
have_settingFlag indicating detection of a setting (unused)
Return values
rcReturn status code

Definition at line 382 of file efi_snp_hii.c.

385  {
386  struct settings *settings = efi_snp_hii_settings ( snpdev );
387  struct setting *setting;
388  char *buf;
389  char tmp[5];
390  char *endp;
391  int len;
392  int i;
393  int rc;
394 
395  /* Handle ConfigHdr components */
396  if ( ( strcasecmp ( key, "GUID" ) == 0 ) ||
397  ( strcasecmp ( key, "NAME" ) == 0 ) ||
398  ( strcasecmp ( key, "PATH" ) == 0 ) ) {
399  /* Nothing to do */
400  return 0;
401  }
402 
403  /* Do nothing more unless we have a settings block */
404  if ( ! settings ) {
405  rc = -ENOTSUP;
406  goto err_no_settings;
407  }
408 
409  /* Identify setting */
410  setting = find_setting ( key );
411  if ( ! setting ) {
412  DBGC ( snpdev, "SNPDEV %p no such setting \"%s\"\n",
413  snpdev, key );
414  rc = -ENODEV;
415  goto err_find_setting;
416  }
417 
418  /* Allocate buffer */
419  len = ( strlen ( value ) / 4 );
420  buf = zalloc ( len + 1 /* NUL */ );
421  if ( ! buf ) {
422  rc = -ENOMEM;
423  goto err_alloc;
424  }
425 
426  /* Decode value */
427  tmp[4] = '\0';
428  for ( i = 0 ; i < len ; i++ ) {
429  memcpy ( tmp, ( value + ( i * 4 ) ), 4 );
430  buf[i] = strtoul ( tmp, &endp, 16 );
431  if ( endp != &tmp[4] ) {
432  DBGC ( snpdev, "SNPDEV %p invalid character %s\n",
433  snpdev, tmp );
434  rc = -EINVAL;
435  goto err_inval;
436  }
437  }
438 
439  /* Store value */
440  if ( ( rc = storef_setting ( settings, setting, buf ) ) != 0 ) {
441  DBGC ( snpdev, "SNPDEV %p could not store \"%s\" into %s: %s\n",
442  snpdev, buf, setting->name, strerror ( rc ) );
443  goto err_storef;
444  }
445 
446  /* Success */
447  rc = 0;
448 
449  err_storef:
450  err_inval:
451  free ( buf );
452  err_alloc:
453  err_find_setting:
454  err_no_settings:
455  return rc;
456 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
unsigned long strtoul(const char *string, char **endp, int base)
Convert string to numeric value.
Definition: string.c:456
static struct settings * efi_snp_hii_settings(struct efi_snp_device *snpdev)
Identify settings to be exposed via HII.
Definition: efi_snp_hii.c:87
#define DBGC(...)
Definition: compiler.h:505
int strcasecmp(const char *first, const char *second)
Compare case-insensitive strings.
Definition: string.c:207
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
const char * name
Name.
Definition: settings.h:28
#define ENOMEM
Not enough space.
Definition: errno.h:534
void * memcpy(void *dest, const void *src, size_t len) __nonnull
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
int storef_setting(struct settings *settings, const struct setting *setting, const char *value)
Store formatted value of setting.
Definition: settings.c:1323
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
uint8_t * tmp
Definition: entropy.h:156
#define ENODEV
No such device.
Definition: errno.h:509
size_t strlen(const char *src)
Get length of string.
Definition: string.c:228
A settings block.
Definition: settings.h:132
A setting.
Definition: settings.h:23
uint32_t len
Length.
Definition: ena.h:14
struct setting * find_setting(const char *name)
Find predefined setting.
Definition: settings.c:1470
union @376 key
Sense key.
Definition: scsi.h:18

References DBGC, efi_snp_hii_settings(), EINVAL, ENODEV, ENOMEM, ENOTSUP, find_setting(), free, key, len, memcpy(), setting::name, rc, storef_setting(), strcasecmp(), strerror(), strlen(), strtoul(), tmp, value, and zalloc().

Referenced by efi_snp_hii_route_config().

◆ efi_snp_hii_process()

static int efi_snp_hii_process ( struct efi_snp_device snpdev,
wchar_t string,
wchar_t **  progress,
wchar_t **  results,
int *  have_setting,
int(*)(struct efi_snp_device *, const char *key, const char *value, wchar_t **results, int *have_setting)  process 
)
static

Process portion of HII configuration string.

Parameters
snpdevSNP device
stringHII configuration string
progressProgress through HII configuration string
resultsResults string
have_settingFlag indicating detection of a setting (unused)
processFunction used to process key=value pairs
Return values
rcReturn status code

Definition at line 469 of file efi_snp_hii.c.

476  {
477  wchar_t *wkey = string;
478  wchar_t *wend = string;
479  wchar_t *wvalue = NULL;
480  size_t key_len;
481  size_t value_len;
482  void *temp;
483  char *key;
484  char *value;
485  int rc;
486 
487  /* Locate key, value (if any), and end */
488  while ( *wend ) {
489  if ( *wend == L'&' )
490  break;
491  if ( *(wend++) == L'=' )
492  wvalue = wend;
493  }
494 
495  /* Allocate memory for key and value */
496  key_len = ( ( wvalue ? ( wvalue - 1 ) : wend ) - wkey );
497  value_len = ( wvalue ? ( wend - wvalue ) : 0 );
498  temp = zalloc ( key_len + 1 /* NUL */ + value_len + 1 /* NUL */ );
499  if ( ! temp )
500  return -ENOMEM;
501  key = temp;
502  value = ( temp + key_len + 1 /* NUL */ );
503 
504  /* Copy key and value */
505  while ( key_len-- )
506  key[key_len] = wkey[key_len];
507  while ( value_len-- )
508  value[value_len] = wvalue[value_len];
509 
510  /* Process key and value */
511  if ( ( rc = process ( snpdev, key, value, results,
512  have_setting ) ) != 0 ) {
513  goto err;
514  }
515 
516  /* Update progress marker */
517  *progress = wend;
518 
519  err:
520  /* Free temporary storage */
521  free ( temp );
522 
523  return rc;
524 }
A process.
Definition: process.h:17
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
uint32_t string
Definition: multiboot.h:14
#define ENOMEM
Not enough space.
Definition: errno.h:534
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
union @376 key
Sense key.
Definition: scsi.h:18

References ENOMEM, free, key, NULL, rc, string, value, and zalloc().

Referenced by efi_snp_hii_extract_config(), and efi_snp_hii_route_config().

◆ efi_snp_hii_extract_config()

static EFI_STATUS EFIAPI efi_snp_hii_extract_config ( const EFI_HII_CONFIG_ACCESS_PROTOCOL hii,
EFI_STRING  request,
EFI_STRING progress,
EFI_STRING results 
)
static

Fetch configuration.

Parameters
hiiHII configuration access protocol
requestConfiguration to fetch
Return values
progressProgress made through configuration to fetch
resultsQuery results
efircEFI status code

Definition at line 536 of file efi_snp_hii.c.

538  {
539  struct efi_snp_device *snpdev =
540  container_of ( hii, struct efi_snp_device, hii );
541  int have_setting = 0;
542  wchar_t *pos;
543  int rc;
544 
545  DBGC ( snpdev, "SNPDEV %p ExtractConfig request \"%ls\"\n",
546  snpdev, request );
547 
548  /* Initialise results */
549  *results = NULL;
550 
551  /* Work around apparently broken UEFI specification */
552  if ( ! ( request && request[0] ) ) {
553  DBGC ( snpdev, "SNPDEV %p ExtractConfig ignoring malformed "
554  "request\n", snpdev );
555  return EFI_INVALID_PARAMETER;
556  }
557 
558  /* Process all request fragments */
559  for ( pos = *progress = request ; *progress && **progress ;
560  pos = *progress + 1 ) {
561  if ( ( rc = efi_snp_hii_process ( snpdev, pos, progress,
562  results, &have_setting,
563  efi_snp_hii_fetch ) ) != 0 ) {
564  return EFIRC ( rc );
565  }
566  }
567 
568  /* If we have no explicit request, return all settings */
569  if ( ! have_setting ) {
570  struct setting *setting;
571 
573  if ( ! efi_snp_hii_setting_applies ( snpdev, setting ) )
574  continue;
575  if ( ( rc = efi_snp_hii_fetch ( snpdev, setting->name,
576  NULL, results,
577  NULL ) ) != 0 ) {
578  return EFIRC ( rc );
579  }
580  }
581  }
582 
583  DBGC ( snpdev, "SNPDEV %p ExtractConfig results \"%ls\"\n",
584  snpdev, *results );
585  return 0;
586 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGC(...)
Definition: compiler.h:505
EFI_HII_CONFIG_ACCESS_PROTOCOL hii
HII configuration access protocol.
Definition: efi_snp.h:59
const char * name
Name.
Definition: settings.h:28
#define SETTINGS
Configuration setting table.
Definition: settings.h:53
static int efi_snp_hii_process(struct efi_snp_device *snpdev, wchar_t *string, wchar_t **progress, wchar_t **results, int *have_setting, int(*process)(struct efi_snp_device *, const char *key, const char *value, wchar_t **results, int *have_setting))
Process portion of HII configuration string.
Definition: efi_snp_hii.c:469
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
static int efi_snp_hii_fetch(struct efi_snp_device *snpdev, const char *key, const char *value, wchar_t **results, int *have_setting)
Fetch HII setting.
Definition: efi_snp_hii.c:281
static int efi_snp_hii_setting_applies(struct efi_snp_device *snpdev, struct setting *setting)
Check whether or not setting is applicable.
Definition: efi_snp_hii.c:100
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
Definition: tables.h:358
An SNP device.
Definition: efi_snp.h:27
#define EFI_INVALID_PARAMETER
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:122
A setting.
Definition: settings.h:23
u8 request[0]
List of IEs requested.
Definition: ieee80211.h:16
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
#define EFIRC(rc)
Convert an iPXE status code to an EFI status code.
Definition: efi.h:151

References container_of, DBGC, EFI_INVALID_PARAMETER, efi_snp_hii_fetch(), efi_snp_hii_process(), efi_snp_hii_setting_applies(), EFIRC, for_each_table_entry, efi_snp_device::hii, setting::name, NULL, rc, request, and SETTINGS.

◆ efi_snp_hii_route_config()

static EFI_STATUS EFIAPI efi_snp_hii_route_config ( const EFI_HII_CONFIG_ACCESS_PROTOCOL hii,
EFI_STRING  config,
EFI_STRING progress 
)
static

Store configuration.

Parameters
hiiHII configuration access protocol
configConfiguration to store
Return values
progressProgress made through configuration to store
efircEFI status code

Definition at line 597 of file efi_snp_hii.c.

598  {
599  struct efi_snp_device *snpdev =
600  container_of ( hii, struct efi_snp_device, hii );
601  wchar_t *pos;
602  int rc;
603 
604  DBGC ( snpdev, "SNPDEV %p RouteConfig \"%ls\"\n", snpdev, config );
605 
606  /* Process all request fragments */
607  for ( pos = *progress = config ; *progress && **progress ;
608  pos = *progress + 1 ) {
609  if ( ( rc = efi_snp_hii_process ( snpdev, pos, progress,
610  NULL, NULL,
611  efi_snp_hii_store ) ) != 0 ) {
612  return EFIRC ( rc );
613  }
614  }
615 
616  return 0;
617 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGC(...)
Definition: compiler.h:505
EFI_HII_CONFIG_ACCESS_PROTOCOL hii
HII configuration access protocol.
Definition: efi_snp.h:59
static int efi_snp_hii_process(struct efi_snp_device *snpdev, wchar_t *string, wchar_t **progress, wchar_t **results, int *have_setting, int(*process)(struct efi_snp_device *, const char *key, const char *value, wchar_t **results, int *have_setting))
Process portion of HII configuration string.
Definition: efi_snp_hii.c:469
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
static int efi_snp_hii_store(struct efi_snp_device *snpdev, const char *key, const char *value, wchar_t **results __unused, int *have_setting __unused)
Fetch HII setting.
Definition: efi_snp_hii.c:382
An SNP device.
Definition: efi_snp.h:27
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
#define EFIRC(rc)
Convert an iPXE status code to an EFI status code.
Definition: efi.h:151

References container_of, DBGC, efi_snp_hii_process(), efi_snp_hii_store(), EFIRC, efi_snp_device::hii, NULL, and rc.

◆ efi_snp_hii_callback()

static EFI_STATUS EFIAPI efi_snp_hii_callback ( const EFI_HII_CONFIG_ACCESS_PROTOCOL hii,
EFI_BROWSER_ACTION action  __unused,
EFI_QUESTION_ID question_id  __unused,
UINT8 type  __unused,
EFI_IFR_TYPE_VALUE *value  __unused,
EFI_BROWSER_ACTION_REQUEST *action_request  __unused 
)
static

Handle form actions.

Parameters
hiiHII configuration access protocol
actionForm browser action
question_idQuestion ID
typeType of value
valueValue
Return values
action_requestAction requested by driver
efircEFI status code

Definition at line 631 of file efi_snp_hii.c.

635  {
636  struct efi_snp_device *snpdev =
637  container_of ( hii, struct efi_snp_device, hii );
638 
639  DBGC ( snpdev, "SNPDEV %p Callback\n", snpdev );
640  return EFI_UNSUPPORTED;
641 }
#define EFI_UNSUPPORTED
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:123
#define DBGC(...)
Definition: compiler.h:505
EFI_HII_CONFIG_ACCESS_PROTOCOL hii
HII configuration access protocol.
Definition: efi_snp.h:59
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
An SNP device.
Definition: efi_snp.h:27

References container_of, DBGC, EFI_UNSUPPORTED, and efi_snp_device::hii.

◆ efi_snp_hii_install()

int efi_snp_hii_install ( struct efi_snp_device snpdev)

Install HII protocol and packages for SNP device.

Parameters
snpdevSNP device
Return values
rcReturn status code

Definition at line 656 of file efi_snp_hii.c.

656  {
658  VENDOR_DEVICE_PATH *vendor_path;
659  EFI_DEVICE_PATH_PROTOCOL *path_end;
660  size_t path_prefix_len;
661  int efirc;
662  int rc;
663 
664  /* Do nothing if HII database protocol is not supported */
665  if ( ! efihii ) {
666  rc = -ENOTSUP;
667  goto err_no_hii;
668  }
669 
670  /* Initialise HII protocol */
671  memcpy ( &snpdev->hii, &efi_snp_device_hii, sizeof ( snpdev->hii ) );
672 
673  /* Create HII package list */
674  snpdev->package_list = efi_snp_hii_package_list ( snpdev );
675  if ( ! snpdev->package_list ) {
676  DBGC ( snpdev, "SNPDEV %p could not create HII package list\n",
677  snpdev );
678  rc = -ENOMEM;
679  goto err_build_package_list;
680  }
681 
682  /* Allocate the new device path */
683  path_prefix_len = efi_devpath_len ( snpdev->path );
684  snpdev->hii_child_path = zalloc ( path_prefix_len +
685  sizeof ( *vendor_path ) +
686  sizeof ( *path_end ) );
687  if ( ! snpdev->hii_child_path ) {
688  DBGC ( snpdev,
689  "SNPDEV %p could not allocate HII child device path\n",
690  snpdev );
691  rc = -ENOMEM;
692  goto err_alloc_child_path;
693  }
694 
695  /* Populate the device path */
696  memcpy ( snpdev->hii_child_path, snpdev->path, path_prefix_len );
697  vendor_path = ( ( ( void * ) snpdev->hii_child_path ) +
698  path_prefix_len );
699  vendor_path->Header.Type = HARDWARE_DEVICE_PATH;
700  vendor_path->Header.SubType = HW_VENDOR_DP;
701  vendor_path->Header.Length[0] = sizeof ( *vendor_path );
702  efi_snp_hii_random_guid ( &vendor_path->Guid );
703  path_end = ( ( void * ) ( vendor_path + 1 ) );
704  path_end->Type = END_DEVICE_PATH_TYPE;
706  path_end->Length[0] = sizeof ( *path_end );
707 
708  /* Create device path and child handle for HII association */
709  if ( ( efirc = bs->InstallMultipleProtocolInterfaces (
710  &snpdev->hii_child_handle,
712  NULL ) ) != 0 ) {
713  rc = -EEFI ( efirc );
714  DBGC ( snpdev, "SNPDEV %p could not create HII child handle: "
715  "%s\n", snpdev, strerror ( rc ) );
716  goto err_hii_child_handle;
717  }
718 
719  /* Add HII packages */
720  if ( ( efirc = efihii->NewPackageList ( efihii, snpdev->package_list,
721  snpdev->hii_child_handle,
722  &snpdev->hii_handle ) ) != 0 ) {
723  rc = -EEFI ( efirc );
724  DBGC ( snpdev, "SNPDEV %p could not add HII packages: %s\n",
725  snpdev, strerror ( rc ) );
726  goto err_new_package_list;
727  }
728 
729  /* Install HII protocol */
730  if ( ( efirc = bs->InstallMultipleProtocolInterfaces (
731  &snpdev->hii_child_handle,
733  NULL ) ) != 0 ) {
734  rc = -EEFI ( efirc );
735  DBGC ( snpdev, "SNPDEV %p could not install HII protocol: %s\n",
736  snpdev, strerror ( rc ) );
737  goto err_install_protocol;
738  }
739 
740  /* Add as child of handle with SNP instance */
741  if ( ( rc = efi_child_add ( snpdev->handle,
742  snpdev->hii_child_handle ) ) != 0 ) {
743  DBGC ( snpdev,
744  "SNPDEV %p could not adopt HII child handle: %s\n",
745  snpdev, strerror ( rc ) );
746  goto err_efi_child_add;
747  }
748 
749  return 0;
750 
751  efi_child_del ( snpdev->handle, snpdev->hii_child_handle );
752  err_efi_child_add:
754  snpdev->hii_child_handle,
756  NULL );
757  err_install_protocol:
759  err_new_package_list:
761  snpdev->hii_child_handle,
763  NULL );
764  err_hii_child_handle:
765  free ( snpdev->hii_child_path );
766  snpdev->hii_child_path = NULL;
767  err_alloc_child_path:
768  free ( snpdev->package_list );
769  snpdev->package_list = NULL;
770  err_build_package_list:
771  err_no_hii:
772  return rc;
773 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:159
#define END_DEVICE_PATH_TYPE
Definition: DevicePath.h:1327
static void efi_snp_hii_random_guid(EFI_GUID *guid)
Generate a random GUID.
Definition: efi_snp_hii.c:111
EFI_HII_DATABASE_REMOVE_PACK RemovePackageList
Definition: HiiDatabase.h:517
#define HARDWARE_DEVICE_PATH
Hardware Device Paths.
Definition: DevicePath.h:77
#define DBGC(...)
Definition: compiler.h:505
EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES InstallMultipleProtocolInterfaces
Definition: UefiSpec.h:1915
size_t efi_devpath_len(EFI_DEVICE_PATH_PROTOCOL *path)
Find length of device path (excluding terminator)
Definition: efi_utils.c:59
This protocol can be used on any device handle to obtain generic path/location information concerning...
Definition: DevicePath.h:51
int efi_child_add(EFI_HANDLE parent, EFI_HANDLE child)
Add EFI device as child of another EFI device.
Definition: efi_utils.c:124
EFI_HANDLE hii_child_handle
EFI child handle for HII association.
Definition: efi_snp.h:63
EFI_HII_CONFIG_ACCESS_PROTOCOL hii
HII configuration access protocol.
Definition: efi_snp.h:59
EFI_HANDLE handle
EFI device handle.
Definition: efi_snp.h:35
EFI_GUID efi_hii_config_access_protocol_guid
HII configuration access protocol GUID.
Definition: efi_guid.c:156
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
void efi_child_del(EFI_HANDLE parent, EFI_HANDLE child)
Remove EFI device as child of another EFI device.
Definition: efi_utils.c:158
EFI_HII_HANDLE hii_handle
HII handle.
Definition: efi_snp.h:67
EFI_GUID Guid
Vendor-assigned GUID that defines the data that follows.
Definition: DevicePath.h:154
#define ENOMEM
Not enough space.
Definition: errno.h:534
void * memcpy(void *dest, const void *src, size_t len) __nonnull
EFI_DEVICE_PATH_PROTOCOL Header
Definition: DevicePath.h:150
EFI_HII_PACKAGE_LIST_HEADER * package_list
HII package list.
Definition: efi_snp.h:61
#define HW_VENDOR_DP
Hardware Vendor Device Path SubType.
Definition: DevicePath.h:142
The Vendor Device Path allows the creation of vendor-defined Device Paths.
Definition: DevicePath.h:149
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
EFI Boot Services Table.
Definition: UefiSpec.h:1836
EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES UninstallMultipleProtocolInterfaces
Definition: UefiSpec.h:1916
static EFI_HII_PACKAGE_LIST_HEADER * efi_snp_hii_package_list(struct efi_snp_device *snpdev)
Build HII package list for SNP device.
Definition: efi_snp_hii.c:161
EFI_DEVICE_PATH_PROTOCOL * hii_child_path
Device path of HII child handle.
Definition: efi_snp.h:65
static EFI_HII_CONFIG_ACCESS_PROTOCOL efi_snp_device_hii
HII configuration access protocol.
Definition: efi_snp_hii.c:644
EFI_GUID efi_device_path_protocol_guid
Device path protocol GUID.
Definition: efi_guid.c:132
#define END_ENTIRE_DEVICE_PATH_SUBTYPE
Definition: DevicePath.h:1328
UINT8 Length[2]
Specific Device Path data.
Definition: DevicePath.h:64
UINT8 SubType
Varies by Type 0xFF End Entire Device Path, or 0x01 End This Instance of a Device Path and start a ne...
Definition: DevicePath.h:59
EFI_HII_DATABASE_NEW_PACK NewPackageList
Definition: HiiDatabase.h:516
UINT8 Type
0x01 Hardware Device Path.
Definition: DevicePath.h:52
EFI_SYSTEM_TABLE * efi_systab
EFI_DEVICE_PATH_PROTOCOL * path
The device path.
Definition: efi_snp.h:75
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
static EFI_HII_DATABASE_PROTOCOL * efihii
EFI HII database protocol.
Definition: efi_snp_hii.c:78

References EFI_SYSTEM_TABLE::BootServices, DBGC, EEFI, efi_child_add(), efi_child_del(), efi_device_path_protocol_guid, efi_devpath_len(), efi_hii_config_access_protocol_guid, efi_snp_device_hii, efi_snp_hii_package_list(), efi_snp_hii_random_guid(), efi_systab, efihii, END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, ENOMEM, ENOTSUP, free, VENDOR_DEVICE_PATH::Guid, efi_snp_device::handle, HARDWARE_DEVICE_PATH, VENDOR_DEVICE_PATH::Header, efi_snp_device::hii, efi_snp_device::hii_child_handle, efi_snp_device::hii_child_path, efi_snp_device::hii_handle, HW_VENDOR_DP, EFI_BOOT_SERVICES::InstallMultipleProtocolInterfaces, EFI_DEVICE_PATH_PROTOCOL::Length, memcpy(), _EFI_HII_DATABASE_PROTOCOL::NewPackageList, NULL, efi_snp_device::package_list, efi_snp_device::path, rc, _EFI_HII_DATABASE_PROTOCOL::RemovePackageList, strerror(), EFI_DEVICE_PATH_PROTOCOL::SubType, EFI_DEVICE_PATH_PROTOCOL::Type, EFI_BOOT_SERVICES::UninstallMultipleProtocolInterfaces, and zalloc().

Referenced by efi_snp_probe().

◆ efi_snp_hii_uninstall()

void efi_snp_hii_uninstall ( struct efi_snp_device snpdev)

Uninstall HII protocol and package for SNP device.

Parameters
snpdevSNP device

Definition at line 780 of file efi_snp_hii.c.

780  {
782 
783  /* Do nothing if HII database protocol is not supported */
784  if ( ! efihii )
785  return;
786 
787  /* Uninstall protocols and remove package list */
788  efi_child_del ( snpdev->handle, snpdev->hii_child_handle );
790  snpdev->hii_child_handle,
792  NULL );
795  snpdev->hii_child_handle,
797  NULL );
798  free ( snpdev->hii_child_path );
799  snpdev->hii_child_path = NULL;
800  free ( snpdev->package_list );
801  snpdev->package_list = NULL;
802 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
EFI_HII_DATABASE_REMOVE_PACK RemovePackageList
Definition: HiiDatabase.h:517
EFI_HANDLE hii_child_handle
EFI child handle for HII association.
Definition: efi_snp.h:63
EFI_HII_CONFIG_ACCESS_PROTOCOL hii
HII configuration access protocol.
Definition: efi_snp.h:59
EFI_HANDLE handle
EFI device handle.
Definition: efi_snp.h:35
EFI_GUID efi_hii_config_access_protocol_guid
HII configuration access protocol GUID.
Definition: efi_guid.c:156
void efi_child_del(EFI_HANDLE parent, EFI_HANDLE child)
Remove EFI device as child of another EFI device.
Definition: efi_utils.c:158
EFI_HII_HANDLE hii_handle
HII handle.
Definition: efi_snp.h:67
EFI_HII_PACKAGE_LIST_HEADER * package_list
HII package list.
Definition: efi_snp.h:61
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
EFI Boot Services Table.
Definition: UefiSpec.h:1836
EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES UninstallMultipleProtocolInterfaces
Definition: UefiSpec.h:1916
EFI_DEVICE_PATH_PROTOCOL * hii_child_path
Device path of HII child handle.
Definition: efi_snp.h:65
EFI_GUID efi_device_path_protocol_guid
Device path protocol GUID.
Definition: efi_guid.c:132
EFI_SYSTEM_TABLE * efi_systab
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
static EFI_HII_DATABASE_PROTOCOL * efihii
EFI HII database protocol.
Definition: efi_snp_hii.c:78

References EFI_SYSTEM_TABLE::BootServices, efi_child_del(), efi_device_path_protocol_guid, efi_hii_config_access_protocol_guid, efi_systab, efihii, free, efi_snp_device::handle, efi_snp_device::hii, efi_snp_device::hii_child_handle, efi_snp_device::hii_child_path, efi_snp_device::hii_handle, NULL, efi_snp_device::package_list, _EFI_HII_DATABASE_PROTOCOL::RemovePackageList, and EFI_BOOT_SERVICES::UninstallMultipleProtocolInterfaces.

Referenced by efi_snp_probe(), and efi_snp_remove().

Variable Documentation

◆ efi_hii_platform_setup_formset_guid

EFI_GUID efi_hii_platform_setup_formset_guid = EFI_HII_PLATFORM_SETUP_FORMSET_GUID
static

EFI platform setup formset GUID.

Definition at line 71 of file efi_snp_hii.c.

Referenced by efi_snp_hii_package_list().

◆ efi_hii_ibm_ucm_compliant_formset_guid

EFI_GUID efi_hii_ibm_ucm_compliant_formset_guid = EFI_HII_IBM_UCM_COMPLIANT_FORMSET_GUID
static

EFI IBM UCM compliant formset GUID.

Definition at line 75 of file efi_snp_hii.c.

Referenced by efi_snp_hii_package_list().

◆ efihii

EFI_HII_DATABASE_PROTOCOL* efihii
static

EFI HII database protocol.

Definition at line 78 of file efi_snp_hii.c.

Referenced by efi_snp_hii_install(), and efi_snp_hii_uninstall().

◆ efi_snp_device_hii

EFI_HII_CONFIG_ACCESS_PROTOCOL efi_snp_device_hii
static
Initial value:
= {
.ExtractConfig = efi_snp_hii_extract_config,
.RouteConfig = efi_snp_hii_route_config,
.Callback = efi_snp_hii_callback,
}
static EFI_STATUS EFIAPI efi_snp_hii_route_config(const EFI_HII_CONFIG_ACCESS_PROTOCOL *hii, EFI_STRING config, EFI_STRING *progress)
Store configuration.
Definition: efi_snp_hii.c:597
static EFI_STATUS EFIAPI efi_snp_hii_extract_config(const EFI_HII_CONFIG_ACCESS_PROTOCOL *hii, EFI_STRING request, EFI_STRING *progress, EFI_STRING *results)
Fetch configuration.
Definition: efi_snp_hii.c:536
static EFI_STATUS EFIAPI efi_snp_hii_callback(const EFI_HII_CONFIG_ACCESS_PROTOCOL *hii, EFI_BROWSER_ACTION action __unused, EFI_QUESTION_ID question_id __unused, UINT8 type __unused, EFI_IFR_TYPE_VALUE *value __unused, EFI_BROWSER_ACTION_REQUEST *action_request __unused)
Handle form actions.
Definition: efi_snp_hii.c:631

HII configuration access protocol.

Definition at line 644 of file efi_snp_hii.c.

Referenced by efi_snp_hii_install().