aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/efi.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/efi.h')
-rw-r--r--include/linux/efi.h99
1 files changed, 90 insertions, 9 deletions
diff --git a/include/linux/efi.h b/include/linux/efi.h
index 9bf2f1fcae27..2bc0ad78d058 100644
--- a/include/linux/efi.h
+++ b/include/linux/efi.h
@@ -333,6 +333,7 @@ typedef efi_status_t efi_query_capsule_caps_t(efi_capsule_header_t **capsules,
333 unsigned long count, 333 unsigned long count,
334 u64 *max_size, 334 u64 *max_size,
335 int *reset_type); 335 int *reset_type);
336typedef efi_status_t efi_query_variable_store_t(u32 attributes, unsigned long size);
336 337
337/* 338/*
338 * EFI Configuration Table and GUID definitions 339 * EFI Configuration Table and GUID definitions
@@ -575,9 +576,15 @@ extern void efi_enter_virtual_mode (void); /* switch EFI to virtual mode, if pos
575#ifdef CONFIG_X86 576#ifdef CONFIG_X86
576extern void efi_late_init(void); 577extern void efi_late_init(void);
577extern void efi_free_boot_services(void); 578extern void efi_free_boot_services(void);
579extern efi_status_t efi_query_variable_store(u32 attributes, unsigned long size);
578#else 580#else
579static inline void efi_late_init(void) {} 581static inline void efi_late_init(void) {}
580static inline void efi_free_boot_services(void) {} 582static inline void efi_free_boot_services(void) {}
583
584static inline efi_status_t efi_query_variable_store(u32 attributes, unsigned long size)
585{
586 return EFI_SUCCESS;
587}
581#endif 588#endif
582extern void __iomem *efi_lookup_mapped_addr(u64 phys_addr); 589extern void __iomem *efi_lookup_mapped_addr(u64 phys_addr);
583extern u64 efi_get_iobase (void); 590extern u64 efi_get_iobase (void);
@@ -663,6 +670,12 @@ static inline int efi_enabled(int facility)
663 EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS | \ 670 EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS | \
664 EFI_VARIABLE_APPEND_WRITE) 671 EFI_VARIABLE_APPEND_WRITE)
665/* 672/*
673 * Length of a GUID string (strlen("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"))
674 * not including trailing NUL
675 */
676#define EFI_VARIABLE_GUID_LEN 36
677
678/*
666 * The type of search to perform when calling boottime->locate_handle 679 * The type of search to perform when calling boottime->locate_handle
667 */ 680 */
668#define EFI_LOCATE_ALL_HANDLES 0 681#define EFI_LOCATE_ALL_HANDLES 0
@@ -719,7 +732,6 @@ static inline void memrange_efi_to_native(u64 *addr, u64 *npages)
719 *addr &= PAGE_MASK; 732 *addr &= PAGE_MASK;
720} 733}
721 734
722#if defined(CONFIG_EFI_VARS) || defined(CONFIG_EFI_VARS_MODULE)
723/* 735/*
724 * EFI Variable support. 736 * EFI Variable support.
725 * 737 *
@@ -731,7 +743,7 @@ struct efivar_operations {
731 efi_get_variable_t *get_variable; 743 efi_get_variable_t *get_variable;
732 efi_get_next_variable_t *get_next_variable; 744 efi_get_next_variable_t *get_next_variable;
733 efi_set_variable_t *set_variable; 745 efi_set_variable_t *set_variable;
734 efi_query_variable_info_t *query_variable_info; 746 efi_query_variable_store_t *query_variable_store;
735}; 747};
736 748
737struct efivars { 749struct efivars {
@@ -745,19 +757,88 @@ struct efivars {
745 * which is protected by the BKL, so that path is safe. 757 * which is protected by the BKL, so that path is safe.
746 */ 758 */
747 spinlock_t lock; 759 spinlock_t lock;
748 struct list_head list;
749 struct kset *kset; 760 struct kset *kset;
750 struct kobject *kobject; 761 struct kobject *kobject;
751 struct bin_attribute *new_var, *del_var;
752 const struct efivar_operations *ops; 762 const struct efivar_operations *ops;
753 struct efivar_entry *walk_entry;
754 struct pstore_info efi_pstore_info;
755}; 763};
756 764
757int register_efivars(struct efivars *efivars, 765/*
766 * The maximum size of VariableName + Data = 1024
767 * Therefore, it's reasonable to save that much
768 * space in each part of the structure,
769 * and we use a page for reading/writing.
770 */
771
772struct efi_variable {
773 efi_char16_t VariableName[1024/sizeof(efi_char16_t)];
774 efi_guid_t VendorGuid;
775 unsigned long DataSize;
776 __u8 Data[1024];
777 efi_status_t Status;
778 __u32 Attributes;
779} __attribute__((packed));
780
781struct efivar_entry {
782 struct efi_variable var;
783 struct list_head list;
784 struct kobject kobj;
785};
786
787extern struct list_head efivar_sysfs_list;
788
789static inline void
790efivar_unregister(struct efivar_entry *var)
791{
792 kobject_put(&var->kobj);
793}
794
795int efivars_register(struct efivars *efivars,
758 const struct efivar_operations *ops, 796 const struct efivar_operations *ops,
759 struct kobject *parent_kobj); 797 struct kobject *kobject);
760void unregister_efivars(struct efivars *efivars); 798int efivars_unregister(struct efivars *efivars);
799struct kobject *efivars_kobject(void);
800
801int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *),
802 void *data, bool atomic, bool duplicates,
803 struct list_head *head);
804
805void efivar_entry_add(struct efivar_entry *entry, struct list_head *head);
806void efivar_entry_remove(struct efivar_entry *entry);
807
808int __efivar_entry_delete(struct efivar_entry *entry);
809int efivar_entry_delete(struct efivar_entry *entry);
810
811int efivar_entry_size(struct efivar_entry *entry, unsigned long *size);
812int __efivar_entry_get(struct efivar_entry *entry, u32 *attributes,
813 unsigned long *size, void *data);
814int efivar_entry_get(struct efivar_entry *entry, u32 *attributes,
815 unsigned long *size, void *data);
816int efivar_entry_set(struct efivar_entry *entry, u32 attributes,
817 unsigned long size, void *data, struct list_head *head);
818int efivar_entry_set_get_size(struct efivar_entry *entry, u32 attributes,
819 unsigned long *size, void *data, bool *set);
820int efivar_entry_set_safe(efi_char16_t *name, efi_guid_t vendor, u32 attributes,
821 bool block, unsigned long size, void *data);
822
823void efivar_entry_iter_begin(void);
824void efivar_entry_iter_end(void);
825
826int __efivar_entry_iter(int (*func)(struct efivar_entry *, void *),
827 struct list_head *head, void *data,
828 struct efivar_entry **prev);
829int efivar_entry_iter(int (*func)(struct efivar_entry *, void *),
830 struct list_head *head, void *data);
831
832struct efivar_entry *efivar_entry_find(efi_char16_t *name, efi_guid_t guid,
833 struct list_head *head, bool remove);
834
835bool efivar_validate(struct efi_variable *var, u8 *data, unsigned long len);
836
837extern struct work_struct efivar_work;
838void efivar_run_worker(void);
839
840#if defined(CONFIG_EFI_VARS) || defined(CONFIG_EFI_VARS_MODULE)
841int efivars_sysfs_init(void);
761 842
762#endif /* CONFIG_EFI_VARS */ 843#endif /* CONFIG_EFI_VARS */
763 844