EFI: Can't install the graphics output interface.
Posted: Mon Feb 02, 2015 11:49 am
To learn about EFI programming I decided to write a small implementation of a EFI C library for writing EFI applications.
Here's my EFI system table structure:
Here's the boot services:
And the problem:
install_proto() returns EFI_SUCCESS, points the handle somewhere, but the hexdump() function outputs something strange (see in the attachments).
Here's my EFI system table structure:
Code: Select all
typedef struct {
efi_tab_hdr_t header;
char16_t *vendor;
uint32_t revision;
void *con_in_handle;
efi_txt_input_proto_t *con_in;
void *con_out_handle;
efi_txt_output_proto_t *con_out;
void *con_err_handle;
efi_txt_output_proto_t *con_err;
efi_rtsrv_t *rtsrv;
efi_bsrv_t *bsrv;
} efi_systab_t;
Code: Select all
typedef struct {
efi_tab_hdr_t hdr;
efi_tpl_t (*raise_tpl)(efi_tpl_t);
void (*rstor_tpl)(efi_tpl_t);
efi_status_t (*alloc_pages)(efi_alloc_type_t, efi_memory_type_t, native_int_t pages, native_int_t *memory);
efi_status_t (*free_pages)(native_int_t, native_int_t);
efi_status_t (*get_mmap)(native_int_t*, efi_mem_t*, native_int_t*, native_int_t*, uint32_t*);
efi_status_t (*alloc_pool)(efi_memory_type_t, native_int_t, void**);
efi_status_t (*free_pool)(void*);
efi_status_t (*create_evt)(uint32_t, efi_tpl_t, efi_evt_notify_t, void*, void**);
efi_status_t (*set_timer)(void*, efi_timer_delay_t, uint64_t);
efi_status_t (*wait_evt)(native_int_t, void**, native_int_t*);
efi_status_t (*sig_evt)(void*);
efi_status_t (*close_evt)(void*);
efi_status_t (*check_evt)(void*);
efi_status_t (*install_proto)(void*, efi_guid_t*, efi_interface_t, void*);
} efi_bsrv_t;
Code: Select all
void *graphics_handle = 0;
efi_guid_t graphics_guid = EFI_GRAPHICS_PROTO_GUID;
efi_graphics_proto_t *graphics = malloc(sizeof(efi_graphics_proto_t));
status = efi_systab->bsrv->install_proto(&graphics_handle, &graphics_guid, EFI_NATIVE_INTERFACE, graphics);
if (status != EFI_SUCCESS)
{
puts(L"Failed to install the graphics interface.");
halt();
}
puts(L"Successfully installed the graphics interface.\n\r");
hexdump(graphics, sizeof(efi_graphics_proto_t));
halt();