mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-24 21:54:01 +00:00
efi_loader: separate UEFI variable API from implemementation
Separate the remaining UEFI variable API functions GetNextVariableName and QueryVariableInfo() from internal functions implementing them. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
This commit is contained in:
parent
2a79c352ca
commit
01df8cf336
4 changed files with 133 additions and 79 deletions
|
@ -40,4 +40,43 @@ efi_status_t efi_set_variable_int(u16 *variable_name, const efi_guid_t *vendor,
|
||||||
u32 attributes, efi_uintn_t data_size,
|
u32 attributes, efi_uintn_t data_size,
|
||||||
const void *data, bool ro_check);
|
const void *data, bool ro_check);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* efi_get_next_variable_name_int() - enumerate the current variable names
|
||||||
|
*
|
||||||
|
* @variable_name_size: size of variable_name buffer in byte
|
||||||
|
* @variable_name: name of uefi variable's name in u16
|
||||||
|
* @vendor: vendor's guid
|
||||||
|
*
|
||||||
|
* See the Unified Extensible Firmware Interface (UEFI) specification for
|
||||||
|
* details.
|
||||||
|
*
|
||||||
|
* Return: status code
|
||||||
|
*/
|
||||||
|
efi_status_t efi_get_next_variable_name_int(efi_uintn_t *variable_name_size,
|
||||||
|
u16 *variable_name,
|
||||||
|
efi_guid_t *vendor);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* efi_query_variable_info_int() - get information about EFI variables
|
||||||
|
*
|
||||||
|
* This function implements the QueryVariableInfo() runtime service.
|
||||||
|
*
|
||||||
|
* See the Unified Extensible Firmware Interface (UEFI) specification for
|
||||||
|
* details.
|
||||||
|
*
|
||||||
|
* @attributes: bitmask to select variables to be
|
||||||
|
* queried
|
||||||
|
* @maximum_variable_storage_size: maximum size of storage area for the
|
||||||
|
* selected variable types
|
||||||
|
* @remaining_variable_storage_size: remaining size of storage are for the
|
||||||
|
* selected variable types
|
||||||
|
* @maximum_variable_size: maximum size of a variable of the
|
||||||
|
* selected type
|
||||||
|
* Returns: status code
|
||||||
|
*/
|
||||||
|
efi_status_t efi_query_variable_info_int(u32 attributes,
|
||||||
|
u64 *maximum_variable_storage_size,
|
||||||
|
u64 *remaining_variable_storage_size,
|
||||||
|
u64 *maximum_variable_size);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -76,3 +76,65 @@ efi_status_t EFIAPI efi_set_variable(u16 *variable_name,
|
||||||
|
|
||||||
return EFI_EXIT(ret);
|
return EFI_EXIT(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* efi_get_next_variable_name() - enumerate the current variable names
|
||||||
|
*
|
||||||
|
* @variable_name_size: size of variable_name buffer in byte
|
||||||
|
* @variable_name: name of uefi variable's name in u16
|
||||||
|
* @vendor: vendor's guid
|
||||||
|
*
|
||||||
|
* See the Unified Extensible Firmware Interface (UEFI) specification for
|
||||||
|
* details.
|
||||||
|
*
|
||||||
|
* Return: status code
|
||||||
|
*/
|
||||||
|
efi_status_t EFIAPI efi_get_next_variable_name(efi_uintn_t *variable_name_size,
|
||||||
|
u16 *variable_name,
|
||||||
|
efi_guid_t *vendor)
|
||||||
|
{
|
||||||
|
efi_status_t ret;
|
||||||
|
|
||||||
|
EFI_ENTRY("%p \"%ls\" %pUl", variable_name_size, variable_name, vendor);
|
||||||
|
|
||||||
|
ret = efi_get_next_variable_name_int(variable_name_size, variable_name,
|
||||||
|
vendor);
|
||||||
|
|
||||||
|
return EFI_EXIT(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* efi_query_variable_info() - get information about EFI variables
|
||||||
|
*
|
||||||
|
* This function implements the QueryVariableInfo() runtime service.
|
||||||
|
*
|
||||||
|
* See the Unified Extensible Firmware Interface (UEFI) specification for
|
||||||
|
* details.
|
||||||
|
*
|
||||||
|
* @attributes: bitmask to select variables to be
|
||||||
|
* queried
|
||||||
|
* @maximum_variable_storage_size: maximum size of storage area for the
|
||||||
|
* selected variable types
|
||||||
|
* @remaining_variable_storage_size: remaining size of storage are for the
|
||||||
|
* selected variable types
|
||||||
|
* @maximum_variable_size: maximum size of a variable of the
|
||||||
|
* selected type
|
||||||
|
* Returns: status code
|
||||||
|
*/
|
||||||
|
efi_status_t EFIAPI efi_query_variable_info(
|
||||||
|
u32 attributes, u64 *maximum_variable_storage_size,
|
||||||
|
u64 *remaining_variable_storage_size,
|
||||||
|
u64 *maximum_variable_size)
|
||||||
|
{
|
||||||
|
efi_status_t ret;
|
||||||
|
|
||||||
|
EFI_ENTRY("%x %p %p %p", attributes, maximum_variable_storage_size,
|
||||||
|
remaining_variable_storage_size, maximum_variable_size);
|
||||||
|
|
||||||
|
ret = efi_query_variable_info_int(attributes,
|
||||||
|
maximum_variable_storage_size,
|
||||||
|
remaining_variable_storage_size,
|
||||||
|
maximum_variable_size);
|
||||||
|
|
||||||
|
return EFI_EXIT(ret);
|
||||||
|
}
|
||||||
|
|
|
@ -745,23 +745,9 @@ static efi_status_t parse_uboot_variable(char *variable,
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
efi_status_t efi_get_next_variable_name_int(efi_uintn_t *variable_name_size,
|
||||||
* efi_get_next_variable_name() - enumerate the current variable names
|
u16 *variable_name,
|
||||||
*
|
efi_guid_t *vendor)
|
||||||
* @variable_name_size: size of variable_name buffer in byte
|
|
||||||
* @variable_name: name of uefi variable's name in u16
|
|
||||||
* @vendor: vendor's guid
|
|
||||||
*
|
|
||||||
* This function implements the GetNextVariableName service.
|
|
||||||
*
|
|
||||||
* See the Unified Extensible Firmware Interface (UEFI) specification for
|
|
||||||
* details.
|
|
||||||
*
|
|
||||||
* Return: status code
|
|
||||||
*/
|
|
||||||
efi_status_t EFIAPI efi_get_next_variable_name(efi_uintn_t *variable_name_size,
|
|
||||||
u16 *variable_name,
|
|
||||||
efi_guid_t *vendor)
|
|
||||||
{
|
{
|
||||||
char *native_name, *variable;
|
char *native_name, *variable;
|
||||||
ssize_t name_len, list_len;
|
ssize_t name_len, list_len;
|
||||||
|
@ -771,10 +757,8 @@ efi_status_t EFIAPI efi_get_next_variable_name(efi_uintn_t *variable_name_size,
|
||||||
int i;
|
int i;
|
||||||
efi_status_t ret;
|
efi_status_t ret;
|
||||||
|
|
||||||
EFI_ENTRY("%p \"%ls\" %pUl", variable_name_size, variable_name, vendor);
|
|
||||||
|
|
||||||
if (!variable_name_size || !variable_name || !vendor)
|
if (!variable_name_size || !variable_name || !vendor)
|
||||||
return EFI_EXIT(EFI_INVALID_PARAMETER);
|
return EFI_INVALID_PARAMETER;
|
||||||
|
|
||||||
if (variable_name[0]) {
|
if (variable_name[0]) {
|
||||||
/* check null-terminated string */
|
/* check null-terminated string */
|
||||||
|
@ -782,12 +766,12 @@ efi_status_t EFIAPI efi_get_next_variable_name(efi_uintn_t *variable_name_size,
|
||||||
if (!variable_name[i])
|
if (!variable_name[i])
|
||||||
break;
|
break;
|
||||||
if (i >= *variable_name_size)
|
if (i >= *variable_name_size)
|
||||||
return EFI_EXIT(EFI_INVALID_PARAMETER);
|
return EFI_INVALID_PARAMETER;
|
||||||
|
|
||||||
/* search for the last-returned variable */
|
/* search for the last-returned variable */
|
||||||
ret = efi_to_native(&native_name, variable_name, vendor);
|
ret = efi_to_native(&native_name, variable_name, vendor);
|
||||||
if (ret)
|
if (ret)
|
||||||
return EFI_EXIT(ret);
|
return ret;
|
||||||
|
|
||||||
name_len = strlen(native_name);
|
name_len = strlen(native_name);
|
||||||
for (variable = efi_variables_list; variable && *variable;) {
|
for (variable = efi_variables_list; variable && *variable;) {
|
||||||
|
@ -802,14 +786,14 @@ efi_status_t EFIAPI efi_get_next_variable_name(efi_uintn_t *variable_name_size,
|
||||||
|
|
||||||
free(native_name);
|
free(native_name);
|
||||||
if (!(variable && *variable))
|
if (!(variable && *variable))
|
||||||
return EFI_EXIT(EFI_INVALID_PARAMETER);
|
return EFI_INVALID_PARAMETER;
|
||||||
|
|
||||||
/* next variable */
|
/* next variable */
|
||||||
variable = strchr(variable, '\n');
|
variable = strchr(variable, '\n');
|
||||||
if (variable)
|
if (variable)
|
||||||
variable++;
|
variable++;
|
||||||
if (!(variable && *variable))
|
if (!(variable && *variable))
|
||||||
return EFI_EXIT(EFI_NOT_FOUND);
|
return EFI_NOT_FOUND;
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
*new search: free a list used in the previous search
|
*new search: free a list used in the previous search
|
||||||
|
@ -824,7 +808,7 @@ efi_status_t EFIAPI efi_get_next_variable_name(efi_uintn_t *variable_name_size,
|
||||||
&efi_variables_list, 0, 1, regexlist);
|
&efi_variables_list, 0, 1, regexlist);
|
||||||
|
|
||||||
if (list_len <= 1)
|
if (list_len <= 1)
|
||||||
return EFI_EXIT(EFI_NOT_FOUND);
|
return EFI_NOT_FOUND;
|
||||||
|
|
||||||
variable = efi_variables_list;
|
variable = efi_variables_list;
|
||||||
}
|
}
|
||||||
|
@ -832,7 +816,7 @@ efi_status_t EFIAPI efi_get_next_variable_name(efi_uintn_t *variable_name_size,
|
||||||
ret = parse_uboot_variable(variable, variable_name_size, variable_name,
|
ret = parse_uboot_variable(variable, variable_name_size, variable_name,
|
||||||
vendor, &attributes);
|
vendor, &attributes);
|
||||||
|
|
||||||
return EFI_EXIT(ret);
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
efi_status_t efi_set_variable_int(u16 *variable_name, const efi_guid_t *vendor,
|
efi_status_t efi_set_variable_int(u16 *variable_name, const efi_guid_t *vendor,
|
||||||
|
@ -1057,13 +1041,17 @@ err:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
efi_status_t efi_query_variable_info_int(u32 attributes,
|
||||||
|
u64 *maximum_variable_storage_size,
|
||||||
|
u64 *remaining_variable_storage_size,
|
||||||
|
u64 *maximum_variable_size)
|
||||||
|
{
|
||||||
|
return EFI_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* efi_query_variable_info() - get information about EFI variables
|
* efi_query_variable_info_runtime() - runtime implementation of
|
||||||
*
|
* QueryVariableInfo()
|
||||||
* This function implements the QueryVariableInfo() runtime service.
|
|
||||||
*
|
|
||||||
* See the Unified Extensible Firmware Interface (UEFI) specification for
|
|
||||||
* details.
|
|
||||||
*
|
*
|
||||||
* @attributes: bitmask to select variables to be
|
* @attributes: bitmask to select variables to be
|
||||||
* queried
|
* queried
|
||||||
|
@ -1075,7 +1063,7 @@ err:
|
||||||
* selected type
|
* selected type
|
||||||
* Returns: status code
|
* Returns: status code
|
||||||
*/
|
*/
|
||||||
efi_status_t __efi_runtime EFIAPI efi_query_variable_info(
|
efi_status_t __efi_runtime EFIAPI efi_query_variable_info_runtime(
|
||||||
u32 attributes,
|
u32 attributes,
|
||||||
u64 *maximum_variable_storage_size,
|
u64 *maximum_variable_storage_size,
|
||||||
u64 *remaining_variable_storage_size,
|
u64 *remaining_variable_storage_size,
|
||||||
|
@ -1144,6 +1132,8 @@ void efi_variables_boot_exit_notify(void)
|
||||||
efi_runtime_services.get_next_variable_name =
|
efi_runtime_services.get_next_variable_name =
|
||||||
efi_get_next_variable_name_runtime;
|
efi_get_next_variable_name_runtime;
|
||||||
efi_runtime_services.set_variable = efi_set_variable_runtime;
|
efi_runtime_services.set_variable = efi_set_variable_runtime;
|
||||||
|
efi_runtime_services.query_variable_info =
|
||||||
|
efi_query_variable_info_runtime;
|
||||||
efi_update_table_header_crc32(&efi_runtime_services.hdr);
|
efi_update_table_header_crc32(&efi_runtime_services.hdr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -312,23 +312,9 @@ out:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
efi_status_t efi_get_next_variable_name_int(efi_uintn_t *variable_name_size,
|
||||||
* efi_get_next_variable_name() - enumerate the current variable names
|
u16 *variable_name,
|
||||||
*
|
efi_guid_t *guid)
|
||||||
* @variable_name_size: size of variable_name buffer in bytes
|
|
||||||
* @variable_name: name of uefi variable's name in u16
|
|
||||||
* @guid: vendor's guid
|
|
||||||
*
|
|
||||||
* This function implements the GetNextVariableName service.
|
|
||||||
*
|
|
||||||
* See the Unified Extensible Firmware Interface (UEFI) specification for
|
|
||||||
* details.
|
|
||||||
*
|
|
||||||
* Return: status code
|
|
||||||
*/
|
|
||||||
efi_status_t EFIAPI efi_get_next_variable_name(efi_uintn_t *variable_name_size,
|
|
||||||
u16 *variable_name,
|
|
||||||
efi_guid_t *guid)
|
|
||||||
{
|
{
|
||||||
struct smm_variable_getnext *var_getnext;
|
struct smm_variable_getnext *var_getnext;
|
||||||
efi_uintn_t payload_size;
|
efi_uintn_t payload_size;
|
||||||
|
@ -338,8 +324,6 @@ efi_status_t EFIAPI efi_get_next_variable_name(efi_uintn_t *variable_name_size,
|
||||||
u8 *comm_buf = NULL;
|
u8 *comm_buf = NULL;
|
||||||
efi_status_t ret;
|
efi_status_t ret;
|
||||||
|
|
||||||
EFI_ENTRY("%p \"%ls\" %pUl", variable_name_size, variable_name, guid);
|
|
||||||
|
|
||||||
if (!variable_name_size || !variable_name || !guid) {
|
if (!variable_name_size || !variable_name || !guid) {
|
||||||
ret = EFI_INVALID_PARAMETER;
|
ret = EFI_INVALID_PARAMETER;
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -396,7 +380,7 @@ efi_status_t EFIAPI efi_get_next_variable_name(efi_uintn_t *variable_name_size,
|
||||||
|
|
||||||
out:
|
out:
|
||||||
free(comm_buf);
|
free(comm_buf);
|
||||||
return EFI_EXIT(ret);
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
efi_status_t efi_set_variable_int(u16 *variable_name, const efi_guid_t *vendor,
|
efi_status_t efi_set_variable_int(u16 *variable_name, const efi_guid_t *vendor,
|
||||||
|
@ -448,37 +432,16 @@ out:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
efi_status_t efi_query_variable_info_int(u32 attributes,
|
||||||
* efi_query_variable_info() - get information about EFI variables
|
u64 *max_variable_storage_size,
|
||||||
*
|
u64 *remain_variable_storage_size,
|
||||||
* This function implements the QueryVariableInfo() runtime service.
|
u64 *max_variable_size)
|
||||||
*
|
|
||||||
* See the Unified Extensible Firmware Interface (UEFI) specification for
|
|
||||||
* details.
|
|
||||||
*
|
|
||||||
* @attributes: bitmask to select variables to be
|
|
||||||
* queried
|
|
||||||
* @maximum_variable_storage_size: maximum size of storage area for the
|
|
||||||
* selected variable types
|
|
||||||
* @remaining_variable_storage_size: remaining size of storage are for the
|
|
||||||
* selected variable types
|
|
||||||
* @maximum_variable_size: maximum size of a variable of the
|
|
||||||
* selected type
|
|
||||||
* Returns: status code
|
|
||||||
*/
|
|
||||||
efi_status_t EFIAPI __efi_runtime
|
|
||||||
efi_query_variable_info(u32 attributes, u64 *max_variable_storage_size,
|
|
||||||
u64 *remain_variable_storage_size,
|
|
||||||
u64 *max_variable_size)
|
|
||||||
{
|
{
|
||||||
struct smm_variable_query_info *mm_query_info;
|
struct smm_variable_query_info *mm_query_info;
|
||||||
efi_uintn_t payload_size;
|
efi_uintn_t payload_size;
|
||||||
efi_status_t ret;
|
efi_status_t ret;
|
||||||
u8 *comm_buf;
|
u8 *comm_buf;
|
||||||
|
|
||||||
EFI_ENTRY("%x %p %p %p", attributes, max_variable_storage_size,
|
|
||||||
remain_variable_storage_size, max_variable_size);
|
|
||||||
|
|
||||||
payload_size = sizeof(*mm_query_info);
|
payload_size = sizeof(*mm_query_info);
|
||||||
comm_buf = setup_mm_hdr((void **)&mm_query_info, payload_size,
|
comm_buf = setup_mm_hdr((void **)&mm_query_info, payload_size,
|
||||||
SMM_VARIABLE_FUNCTION_QUERY_VARIABLE_INFO,
|
SMM_VARIABLE_FUNCTION_QUERY_VARIABLE_INFO,
|
||||||
|
@ -497,7 +460,7 @@ efi_query_variable_info(u32 attributes, u64 *max_variable_storage_size,
|
||||||
|
|
||||||
out:
|
out:
|
||||||
free(comm_buf);
|
free(comm_buf);
|
||||||
return EFI_EXIT(ret);
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue