Changeset View
Changeset View
Standalone View
Standalone View
sys/sys/efi.h
| Show First 20 Lines • Show All 173 Lines • ▼ Show 20 Lines | |||||
| /* Internal MD EFI functions */ | /* Internal MD EFI functions */ | ||||
| int efi_arch_enter(void); | int efi_arch_enter(void); | ||||
| void efi_arch_leave(void); | void efi_arch_leave(void); | ||||
| vm_offset_t efi_phys_to_kva(vm_paddr_t); | vm_offset_t efi_phys_to_kva(vm_paddr_t); | ||||
| int efi_rt_arch_call(struct efirt_callinfo *); | int efi_rt_arch_call(struct efirt_callinfo *); | ||||
| bool efi_create_1t1_map(struct efi_md *, int, int); | bool efi_create_1t1_map(struct efi_md *, int, int); | ||||
| void efi_destroy_1t1_map(void); | void efi_destroy_1t1_map(void); | ||||
| struct efi_ops { | |||||
| /* | |||||
| * The EFI calls might be virtualized in some environments, requiring | |||||
| * FreeBSD to use a different interface (ie: hypercalls) in order to | |||||
| * access them. | |||||
| */ | |||||
| int (*rt_ok)(void); | |||||
| int (*get_table)(struct uuid *, void **); | |||||
| int (*get_time)(struct efi_tm *); | |||||
| int (*get_time_capabilities)(struct efi_tmcap *); | |||||
| int (*reset_system)(enum efi_reset); | |||||
| int (*set_time)(struct efi_tm *); | |||||
| int (*var_get)(uint16_t *, struct uuid *, uint32_t *, size_t *, | |||||
| void *); | |||||
| int (*var_nextname)(size_t *, uint16_t *, struct uuid *); | |||||
| int (*var_set)(uint16_t *, struct uuid *, uint32_t, size_t, void *); | |||||
| }; | |||||
| extern const struct efi_ops *active_efi_ops; | |||||
imp: Might make sense to add that we either call the real efi firmware, or virtualize it for VMs in… | |||||
| /* Public MI EFI functions */ | /* Public MI EFI functions */ | ||||
| int efi_rt_ok(void); | static inline int efi_rt_ok(void) | ||||
| int efi_get_table(struct uuid *uuid, void **ptr); | { | ||||
| int efi_get_time(struct efi_tm *tm); | |||||
| int efi_get_time_capabilities(struct efi_tmcap *tmcap); | |||||
| int efi_reset_system(enum efi_reset type); | |||||
| int efi_set_time(struct efi_tm *tm); | |||||
| int efi_var_get(uint16_t *name, struct uuid *vendor, uint32_t *attrib, | |||||
| size_t *datasize, void *data); | |||||
| int efi_var_nextname(size_t *namesize, uint16_t *name, struct uuid *vendor); | |||||
| int efi_var_set(uint16_t *name, struct uuid *vendor, uint32_t attrib, | |||||
| size_t datasize, void *data); | |||||
| if(active_efi_ops->rt_ok == NULL) | |||||
| return (ENXIO); | |||||
| return (active_efi_ops->rt_ok()); | |||||
| } | |||||
| static inline int efi_get_table(struct uuid *uuid, void **ptr) | |||||
| { | |||||
| if (active_efi_ops->get_table == NULL) | |||||
| return (ENXIO); | |||||
| return (active_efi_ops->get_table(uuid, ptr)); | |||||
| } | |||||
| static inline int efi_get_time(struct efi_tm *tm) | |||||
| { | |||||
| if (active_efi_ops->get_time == NULL) | |||||
| return (ENXIO); | |||||
| return (active_efi_ops->get_time(tm)); | |||||
| } | |||||
| static inline int efi_get_time_capabilities(struct efi_tmcap *tmcap) | |||||
| { | |||||
| if (active_efi_ops->get_time_capabilities == NULL) | |||||
| return (ENXIO); | |||||
| return (active_efi_ops->get_time_capabilities(tmcap)); | |||||
| } | |||||
| static inline int efi_reset_system(enum efi_reset type) | |||||
| { | |||||
| if (active_efi_ops->reset_system == NULL) | |||||
| return (ENXIO); | |||||
| return (active_efi_ops->reset_system(type)); | |||||
| } | |||||
| static inline int efi_set_time(struct efi_tm *tm) | |||||
| { | |||||
| if (active_efi_ops->set_time == NULL) | |||||
| return (ENXIO); | |||||
| return (active_efi_ops->set_time(tm)); | |||||
| } | |||||
| static inline int efi_var_get(uint16_t *name, struct uuid *vendor, | |||||
| uint32_t *attrib, size_t *datasize, void *data) | |||||
| { | |||||
| if (active_efi_ops->var_get == NULL) | |||||
| return (ENXIO); | |||||
| return (active_efi_ops->var_get(name, vendor, attrib, datasize, data)); | |||||
| } | |||||
| static inline int efi_var_nextname(size_t *namesize, uint16_t *name, | |||||
| struct uuid *vendor) | |||||
| { | |||||
| if (active_efi_ops->var_nextname == NULL) | |||||
| return (ENXIO); | |||||
| return (active_efi_ops->var_nextname(namesize, name, vendor)); | |||||
| } | |||||
| static inline int efi_var_set(uint16_t *name, struct uuid *vendor, | |||||
| uint32_t attrib, size_t datasize, void *data) | |||||
| { | |||||
| if (active_efi_ops->var_set == NULL) | |||||
| return (ENXIO); | |||||
| return (active_efi_ops->var_set(name, vendor, attrib, datasize, data)); | |||||
| } | |||||
| int efi_status_to_errno(efi_status status); | |||||
| #endif /* _KERNEL */ | #endif /* _KERNEL */ | ||||
| #endif /* _SYS_EFI_H_ */ | #endif /* _SYS_EFI_H_ */ | ||||
Might make sense to add that we either call the real efi firmware, or virtualize it for VMs in some kind of comment here.