class StubBootServices
Defined at line 28 of file ../../zircon/kernel/lib/efi/testing/include/lib/efi/testing/stub_boot_services.h
Boot services EFI stubs.
The boot services EFI table is complicated enough that it would be
difficult to fake out all the APIs properly. Instead, we provide these stubs
to allow tests to easily mock out the functionality they need, either with
gmock or by subclassing and implementing the functions they need.
Some of the more trivial functionality will be implemented, but can still
be overridden by subclasses.
Tests that are willing to use gmock should generally prefer to use
MockBootServices instead, which hooks up the proper mock wrappers and adds
some additional utility functions.
Public Methods
void StubBootServices (const StubBootServices & )
Not copyable or movable.
Defined at line 37 of file ../../zircon/kernel/lib/efi/testing/include/lib/efi/testing/stub_boot_services.h
StubBootServices & operator= (const StubBootServices & )
Defined at line 38 of file ../../zircon/kernel/lib/efi/testing/include/lib/efi/testing/stub_boot_services.h
efi_boot_services * services ()
Returns the underlying efi_boot_services struct.
Defined at line 41 of file ../../zircon/kernel/lib/efi/testing/include/lib/efi/testing/stub_boot_services.h
void StubBootServices ()
IMPORTANT: only ONE StubBootServices can exist at a time. Since this is
intended to be a global singleton in EFI this shouldn't be a problem,
but if a test does attempt to create a second it will cause an exit().
Defined at line 46 of file ../../zircon/kernel/lib/efi/testing/stub_boot_services.cc
efi_status GetMemoryMap (size_t * memory_map_size, efi_memory_descriptor * memory_map, size_t * map_key, size_t * desc_size, uint32_t * desc_version)
Defined at line 59 of file ../../zircon/kernel/lib/efi/testing/include/lib/efi/testing/stub_boot_services.h
efi_status CreateEvent (uint32_t type, efi_tpl notify_tpl, efi_event_notify notify_fn, void * notify_ctx, efi_event * event)
Defined at line 68 of file ../../zircon/kernel/lib/efi/testing/include/lib/efi/testing/stub_boot_services.h
efi_status SetTimer (efi_event event, efi_timer_delay type, uint64_t trigger_time)
Defined at line 72 of file ../../zircon/kernel/lib/efi/testing/include/lib/efi/testing/stub_boot_services.h
void ~StubBootServices ()
Defined at line 73 of file ../../zircon/kernel/lib/efi/testing/stub_boot_services.cc
efi_status AllocatePages (efi_allocate_type type, efi_memory_type memory_type, size_t pages, efi_physical_addr * memory)
Default page allocation implementation is just to call malloc/free.
|type| and |memory_type| are ignored, and freeing a different number of
pages than were initially allocated is unsupported.
Also initializes memory to some non-zero value.
Defined at line 75 of file ../../zircon/kernel/lib/efi/testing/stub_boot_services.cc
efi_status CloseEvent (efi_event event)
efi_status (*WaitForEvent)(size_t num_events, efi_event* event, size_t* index);
efi_status (*SignalEvent)(efi_event event);
Defined at line 79 of file ../../zircon/kernel/lib/efi/testing/include/lib/efi/testing/stub_boot_services.h
efi_status CheckEvent (efi_event event)
Defined at line 80 of file ../../zircon/kernel/lib/efi/testing/include/lib/efi/testing/stub_boot_services.h
efi_status FreePages (efi_physical_addr memory, size_t pages)
Defined at line 83 of file ../../zircon/kernel/lib/efi/testing/stub_boot_services.cc
efi_status AllocatePool (efi_memory_type pool_type, size_t size, void ** buf)
Default pool allocation implementation is just to call malloc/free.
Defined at line 88 of file ../../zircon/kernel/lib/efi/testing/stub_boot_services.cc
efi_status LocateHandle (efi_locate_search_type search_type, const efi_guid * protocol, void * search_key, size_t * buf_size, efi_handle * buf)
efi_status (*InstallProtocolInterface)(efi_handle* handle, const efi_guid* protocol,
efi_interface_type intf_type, void* intf);
efi_status (*ReinstallProtocolInterface)(efi_handle hadle, const efi_guid* protocol,
void* old_intf, void* new_intf);
efi_status (*UninstallProtocolInterface)(efi_handle handle, const efi_guid* protocol, void*
intf); efi_status (*HandleProtocol)(efi_handle handle, const efi_guid* protocol, void**
intf); efi_status (*RegisterProtocolNotify)(const efi_guid* protocol, efi_event event,
void** registration);
Defined at line 91 of file ../../zircon/kernel/lib/efi/testing/include/lib/efi/testing/stub_boot_services.h
efi_status FreePool (void * buf)
Defined at line 101 of file ../../zircon/kernel/lib/efi/testing/stub_boot_services.cc
void CopyMem (void * dest, const void * src, size_t len)
Default implementation is memmove()/memset().
UEFI documentation doesn't mention whether the pointers have to be valid
when length is 0, so to be cautious the default implementation will also
explicitly fail the test if the pointers are invalid.
Defined at line 106 of file ../../zircon/kernel/lib/efi/testing/stub_boot_services.cc
void SetMem (void * buf, size_t len, uint8_t val)
Defined at line 114 of file ../../zircon/kernel/lib/efi/testing/stub_boot_services.cc
efi_status OpenProtocol (efi_handle handle, const efi_guid * protocol, void ** intf, efi_handle agent_handle, efi_handle controller_handle, uint32_t attributes)
efi_status (*LocateDevicePath)(const efi_guid* protocol, efi_device_path_protocol** path,
efi_handle* device);
efi_status (*InstallConfigurationTable)(const efi_guid* guid, void* table);
efi_status (*LoadImage)(bool boot_policy, efi_handle parent_image_handle,
efi_device_path_protocol* path, void* src, size_t src_size,
efi_handle* image_handle);
efi_status (*StartImage)(efi_handle image_handle, size_t* exit_data_size,
char16_t** exit_data);
efi_status (*Exit)(efi_handle image_handle, efi_status exit_status, size_t exit_data_size,
char16_t* exit_data);
efi_status (*UnloadImage)(efi_handle image_handle);
efi_status (*ExitBootServices)(efi_handle image_handle, size_t map_key);
efi_status (*GetNextMonotonicCount)(uint64_t* count);
efi_status (*Stall)(size_t microseconds);
efi_status (*SetWatchdogTimer)(size_t timeout, uint64_t watchdog_code, size_t data_size,
char16_t* watchdog_data);
efi_status (*ConnectController)(efi_handle controller_handle,
efi_handle* driver_image_handle,
efi_device_path_protocol* remaining_path, bool recursive);
efi_status (*DisconnectController)(efi_handle controller_handle,
efi_handle driver_image_handle,
efi_handle child_handle);
Defined at line 119 of file ../../zircon/kernel/lib/efi/testing/include/lib/efi/testing/stub_boot_services.h
efi_status CloseProtocol (efi_handle handle, const efi_guid * protocol, efi_handle agent_handle, efi_handle controller_handle)
Defined at line 124 of file ../../zircon/kernel/lib/efi/testing/include/lib/efi/testing/stub_boot_services.h
efi_status LocateHandleBuffer (efi_locate_search_type search_type, const efi_guid * protocol, void * search_key, size_t * num_handles, efi_handle ** buf)
efi_status (*OpenProtocolInformation)(efi_handle handle, const efi_guid* protocol,
efi_open_protocol_information_entry** entry_buf,
size_t* entry_count);
efi_status (*ProtocolsPerHandle)(efi_handle handle, efi_guid*** protocol_buf,
size_t* protocol_buf_count);
Defined at line 135 of file ../../zircon/kernel/lib/efi/testing/include/lib/efi/testing/stub_boot_services.h
efi_status LocateProtocol (const efi_guid * protocol, void * registration, void ** intf)
Defined at line 141 of file ../../zircon/kernel/lib/efi/testing/include/lib/efi/testing/stub_boot_services.h