diff options
Diffstat (limited to 'include/linux/efi.h')
-rw-r--r-- | include/linux/efi.h | 90 |
1 files changed, 82 insertions, 8 deletions
diff --git a/include/linux/efi.h b/include/linux/efi.h index 3d7df3d32c66..2bc0ad78d058 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -670,6 +670,12 @@ static inline int efi_enabled(int facility) EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS | \ EFI_VARIABLE_APPEND_WRITE) /* + * Length of a GUID string (strlen("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")) + * not including trailing NUL + */ +#define EFI_VARIABLE_GUID_LEN 36 + +/* * The type of search to perform when calling boottime->locate_handle */ #define EFI_LOCATE_ALL_HANDLES 0 @@ -726,7 +732,6 @@ static inline void memrange_efi_to_native(u64 *addr, u64 *npages) *addr &= PAGE_MASK; } -#if defined(CONFIG_EFI_VARS) || defined(CONFIG_EFI_VARS_MODULE) /* * EFI Variable support. * @@ -752,19 +757,88 @@ struct efivars { * which is protected by the BKL, so that path is safe. */ spinlock_t lock; - struct list_head list; struct kset *kset; struct kobject *kobject; - struct bin_attribute *new_var, *del_var; const struct efivar_operations *ops; - struct efivar_entry *walk_entry; - struct pstore_info efi_pstore_info; }; -int register_efivars(struct efivars *efivars, +/* + * The maximum size of VariableName + Data = 1024 + * Therefore, it's reasonable to save that much + * space in each part of the structure, + * and we use a page for reading/writing. + */ + +struct efi_variable { + efi_char16_t VariableName[1024/sizeof(efi_char16_t)]; + efi_guid_t VendorGuid; + unsigned long DataSize; + __u8 Data[1024]; + efi_status_t Status; + __u32 Attributes; +} __attribute__((packed)); + +struct efivar_entry { + struct efi_variable var; + struct list_head list; + struct kobject kobj; +}; + +extern struct list_head efivar_sysfs_list; + +static inline void +efivar_unregister(struct efivar_entry *var) +{ + kobject_put(&var->kobj); +} + +int efivars_register(struct efivars *efivars, const struct efivar_operations *ops, - struct kobject *parent_kobj); -void unregister_efivars(struct efivars *efivars); + struct kobject *kobject); +int efivars_unregister(struct efivars *efivars); +struct kobject *efivars_kobject(void); + +int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *), + void *data, bool atomic, bool duplicates, + struct list_head *head); + +void efivar_entry_add(struct efivar_entry *entry, struct list_head *head); +void efivar_entry_remove(struct efivar_entry *entry); + +int __efivar_entry_delete(struct efivar_entry *entry); +int efivar_entry_delete(struct efivar_entry *entry); + +int efivar_entry_size(struct efivar_entry *entry, unsigned long *size); +int __efivar_entry_get(struct efivar_entry *entry, u32 *attributes, + unsigned long *size, void *data); +int efivar_entry_get(struct efivar_entry *entry, u32 *attributes, + unsigned long *size, void *data); +int efivar_entry_set(struct efivar_entry *entry, u32 attributes, + unsigned long size, void *data, struct list_head *head); +int efivar_entry_set_get_size(struct efivar_entry *entry, u32 attributes, + unsigned long *size, void *data, bool *set); +int efivar_entry_set_safe(efi_char16_t *name, efi_guid_t vendor, u32 attributes, + bool block, unsigned long size, void *data); + +void efivar_entry_iter_begin(void); +void efivar_entry_iter_end(void); + +int __efivar_entry_iter(int (*func)(struct efivar_entry *, void *), + struct list_head *head, void *data, + struct efivar_entry **prev); +int efivar_entry_iter(int (*func)(struct efivar_entry *, void *), + struct list_head *head, void *data); + +struct efivar_entry *efivar_entry_find(efi_char16_t *name, efi_guid_t guid, + struct list_head *head, bool remove); + +bool efivar_validate(struct efi_variable *var, u8 *data, unsigned long len); + +extern struct work_struct efivar_work; +void efivar_run_worker(void); + +#if defined(CONFIG_EFI_VARS) || defined(CONFIG_EFI_VARS_MODULE) +int efivars_sysfs_init(void); #endif /* CONFIG_EFI_VARS */ |