|
1 | 1 | //! UEFI services available during boot.
|
2 | 2 |
|
3 |
| -use crate::{Event, PhysicalAddress, VirtualAddress}; |
| 3 | +use crate::protocol::device_path::DevicePathProtocol; |
| 4 | +use crate::table::Header; |
| 5 | +use crate::{Char16, Event, Guid, Handle, PhysicalAddress, Status, VirtualAddress}; |
4 | 6 | use bitflags::bitflags;
|
5 | 7 | use core::ffi::c_void;
|
6 | 8 |
|
| 9 | +/// Table of pointers to all the boot services. |
| 10 | +#[repr(C)] |
| 11 | +pub struct BootServices { |
| 12 | + pub header: Header, |
| 13 | + |
| 14 | + // Task Priority services |
| 15 | + pub raise_tpl: unsafe extern "efiapi" fn(new_tpl: Tpl) -> Tpl, |
| 16 | + pub restore_tpl: unsafe extern "efiapi" fn(old_tpl: Tpl), |
| 17 | + |
| 18 | + // Memory allocation functions |
| 19 | + pub allocate_pages: unsafe extern "efiapi" fn( |
| 20 | + alloc_ty: u32, |
| 21 | + mem_ty: MemoryType, |
| 22 | + count: usize, |
| 23 | + addr: *mut PhysicalAddress, |
| 24 | + ) -> Status, |
| 25 | + pub free_pages: unsafe extern "efiapi" fn(addr: PhysicalAddress, pages: usize) -> Status, |
| 26 | + pub get_memory_map: unsafe extern "efiapi" fn( |
| 27 | + size: *mut usize, |
| 28 | + map: *mut MemoryDescriptor, |
| 29 | + key: *mut usize, |
| 30 | + desc_size: *mut usize, |
| 31 | + desc_version: *mut u32, |
| 32 | + ) -> Status, |
| 33 | + pub allocate_pool: unsafe extern "efiapi" fn( |
| 34 | + pool_type: MemoryType, |
| 35 | + size: usize, |
| 36 | + buffer: *mut *mut u8, |
| 37 | + ) -> Status, |
| 38 | + pub free_pool: unsafe extern "efiapi" fn(buffer: *mut u8) -> Status, |
| 39 | + |
| 40 | + // Event & timer functions |
| 41 | + pub create_event: unsafe extern "efiapi" fn( |
| 42 | + ty: EventType, |
| 43 | + notify_tpl: Tpl, |
| 44 | + notify_func: Option<EventNotifyFn>, |
| 45 | + notify_ctx: *mut c_void, |
| 46 | + out_event: *mut Event, |
| 47 | + ) -> Status, |
| 48 | + pub set_timer: unsafe extern "efiapi" fn(event: Event, ty: u32, trigger_time: u64) -> Status, |
| 49 | + pub wait_for_event: unsafe extern "efiapi" fn( |
| 50 | + number_of_events: usize, |
| 51 | + events: *mut Event, |
| 52 | + out_index: *mut usize, |
| 53 | + ) -> Status, |
| 54 | + pub signal_event: unsafe extern "efiapi" fn(event: Event) -> Status, |
| 55 | + pub close_event: unsafe extern "efiapi" fn(event: Event) -> Status, |
| 56 | + pub check_event: unsafe extern "efiapi" fn(event: Event) -> Status, |
| 57 | + |
| 58 | + // Protocol handlers |
| 59 | + pub install_protocol_interface: unsafe extern "efiapi" fn( |
| 60 | + handle: *mut Handle, |
| 61 | + guid: *const Guid, |
| 62 | + interface_type: InterfaceType, |
| 63 | + interface: *mut c_void, |
| 64 | + ) -> Status, |
| 65 | + pub reinstall_protocol_interface: unsafe extern "efiapi" fn( |
| 66 | + handle: Handle, |
| 67 | + protocol: *const Guid, |
| 68 | + old_interface: *mut c_void, |
| 69 | + new_interface: *mut c_void, |
| 70 | + ) -> Status, |
| 71 | + pub uninstall_protocol_interface: unsafe extern "efiapi" fn( |
| 72 | + handle: Handle, |
| 73 | + protocol: *const Guid, |
| 74 | + interface: *mut c_void, |
| 75 | + ) -> Status, |
| 76 | + pub handle_protocol: unsafe extern "efiapi" fn( |
| 77 | + handle: Handle, |
| 78 | + proto: *const Guid, |
| 79 | + out_proto: *mut *mut c_void, |
| 80 | + ) -> Status, |
| 81 | + pub reserved: *mut c_void, |
| 82 | + pub register_protocol_notify: unsafe extern "efiapi" fn( |
| 83 | + protocol: *const Guid, |
| 84 | + event: Event, |
| 85 | + registration: *mut *const c_void, |
| 86 | + ) -> Status, |
| 87 | + pub locate_handle: unsafe extern "efiapi" fn( |
| 88 | + search_ty: i32, |
| 89 | + proto: *const Guid, |
| 90 | + key: *const c_void, |
| 91 | + buf_sz: *mut usize, |
| 92 | + buf: *mut Handle, |
| 93 | + ) -> Status, |
| 94 | + pub locate_device_path: unsafe extern "efiapi" fn( |
| 95 | + proto: *const Guid, |
| 96 | + device_path: *mut *const DevicePathProtocol, |
| 97 | + out_handle: *mut Handle, |
| 98 | + ) -> Status, |
| 99 | + pub install_configuration_table: |
| 100 | + unsafe extern "efiapi" fn(guid_entry: *const Guid, table_ptr: *const c_void) -> Status, |
| 101 | + |
| 102 | + // Image services |
| 103 | + pub load_image: unsafe extern "efiapi" fn( |
| 104 | + boot_policy: u8, |
| 105 | + parent_image_handle: Handle, |
| 106 | + device_path: *const DevicePathProtocol, |
| 107 | + source_buffer: *const u8, |
| 108 | + source_size: usize, |
| 109 | + image_handle: *mut Handle, |
| 110 | + ) -> Status, |
| 111 | + pub start_image: unsafe extern "efiapi" fn( |
| 112 | + image_handle: Handle, |
| 113 | + exit_data_size: *mut usize, |
| 114 | + exit_data: *mut *mut Char16, |
| 115 | + ) -> Status, |
| 116 | + pub exit: unsafe extern "efiapi" fn( |
| 117 | + image_handle: Handle, |
| 118 | + exit_status: Status, |
| 119 | + exit_data_size: usize, |
| 120 | + exit_data: *mut Char16, |
| 121 | + ) -> !, |
| 122 | + pub unload_image: unsafe extern "efiapi" fn(image_handle: Handle) -> Status, |
| 123 | + pub exit_boot_services: |
| 124 | + unsafe extern "efiapi" fn(image_handle: Handle, map_key: usize) -> Status, |
| 125 | + |
| 126 | + // Misc services |
| 127 | + pub get_next_monotonic_count: usize, |
| 128 | + pub stall: unsafe extern "efiapi" fn(microseconds: usize) -> Status, |
| 129 | + pub set_watchdog_timer: unsafe extern "efiapi" fn( |
| 130 | + timeout: usize, |
| 131 | + watchdog_code: u64, |
| 132 | + data_size: usize, |
| 133 | + watchdog_data: *const u16, |
| 134 | + ) -> Status, |
| 135 | + |
| 136 | + // Driver support services |
| 137 | + pub connect_controller: unsafe extern "efiapi" fn( |
| 138 | + controller: Handle, |
| 139 | + driver_image: Handle, |
| 140 | + // TODO |
| 141 | + remaining_device_path: *const c_void, |
| 142 | + recursive: bool, |
| 143 | + ) -> Status, |
| 144 | + pub disconnect_controller: unsafe extern "efiapi" fn( |
| 145 | + controller: Handle, |
| 146 | + driver_image: Handle, |
| 147 | + child: Handle, |
| 148 | + ) -> Status, |
| 149 | + |
| 150 | + // Protocol open / close services |
| 151 | + pub open_protocol: unsafe extern "efiapi" fn( |
| 152 | + handle: Handle, |
| 153 | + protocol: *const Guid, |
| 154 | + interface: *mut *mut c_void, |
| 155 | + agent_handle: Handle, |
| 156 | + controller_handle: Handle, |
| 157 | + attributes: u32, |
| 158 | + ) -> Status, |
| 159 | + pub close_protocol: unsafe extern "efiapi" fn( |
| 160 | + handle: Handle, |
| 161 | + protocol: *const Guid, |
| 162 | + agent_handle: Handle, |
| 163 | + controller_handle: Handle, |
| 164 | + ) -> Status, |
| 165 | + pub open_protocol_information: usize, |
| 166 | + |
| 167 | + // Library services |
| 168 | + pub protocols_per_handle: unsafe extern "efiapi" fn( |
| 169 | + handle: Handle, |
| 170 | + protocol_buffer: *mut *mut *const Guid, |
| 171 | + protocol_buffer_count: *mut usize, |
| 172 | + ) -> Status, |
| 173 | + pub locate_handle_buffer: unsafe extern "efiapi" fn( |
| 174 | + search_ty: i32, |
| 175 | + proto: *const Guid, |
| 176 | + key: *const c_void, |
| 177 | + no_handles: *mut usize, |
| 178 | + buf: *mut *mut Handle, |
| 179 | + ) -> Status, |
| 180 | + pub locate_protocol: unsafe extern "efiapi" fn( |
| 181 | + proto: *const Guid, |
| 182 | + registration: *mut c_void, |
| 183 | + out_proto: *mut *mut c_void, |
| 184 | + ) -> Status, |
| 185 | + pub install_multiple_protocol_interfaces: usize, |
| 186 | + pub uninstall_multiple_protocol_interfaces: usize, |
| 187 | + |
| 188 | + // CRC services |
| 189 | + pub calculate_crc32: usize, |
| 190 | + |
| 191 | + // Misc services |
| 192 | + pub copy_mem: unsafe extern "efiapi" fn(dest: *mut u8, src: *const u8, len: usize), |
| 193 | + pub set_mem: unsafe extern "efiapi" fn(buffer: *mut u8, len: usize, value: u8), |
| 194 | + |
| 195 | + // New event functions (UEFI 2.0 or newer) |
| 196 | + pub create_event_ex: unsafe extern "efiapi" fn( |
| 197 | + ty: EventType, |
| 198 | + notify_tpl: Tpl, |
| 199 | + notify_fn: Option<EventNotifyFn>, |
| 200 | + notify_ctx: *mut c_void, |
| 201 | + event_group: *mut Guid, |
| 202 | + out_event: *mut Event, |
| 203 | + ) -> Status, |
| 204 | +} |
| 205 | + |
7 | 206 | bitflags! {
|
8 | 207 | /// Flags describing the type of an UEFI event and its attributes.
|
9 | 208 | #[repr(transparent)]
|
|
0 commit comments