extern struct efi_runtime_services efi_runtime_services;
extern struct efi_system_table systab;
-extern const struct efi_simple_text_output_protocol efi_con_out;
+extern struct efi_simple_text_output_protocol efi_con_out;
extern struct efi_simple_input_interface efi_con_in;
-extern const struct efi_console_control_protocol efi_console_control;
+extern struct efi_console_control_protocol efi_console_control;
extern const struct efi_device_path_to_text_protocol efi_device_path_to_text;
uint16_t *efi_dp_str(struct efi_device_path *dp);
void *handle;
};
-#define EFI_PROTOCOL_OBJECT(_guid, _protocol) (struct efi_object){ \
- .protocols = {{ \
- .guid = &(_guid), \
- .protocol_interface = (void *)(_protocol), \
- }}, \
- .handle = (void *)(_protocol), \
-}
-
/**
* struct efi_event
*
};
const efi_guid_t efi_guid_console_control = CONSOLE_CONTROL_GUID;
+const efi_guid_t efi_guid_text_output_protocol =
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID;
+const efi_guid_t efi_guid_text_input_protocol =
+ EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID;
#define cESC '\x1b'
#define ESC "\x1b"
return EFI_EXIT(EFI_UNSUPPORTED);
}
-const struct efi_console_control_protocol efi_console_control = {
+struct efi_console_control_protocol efi_console_control = {
.get_mode = efi_cin_get_mode,
.set_mode = efi_cin_set_mode,
.lock_std_in = efi_cin_lock_std_in,
return EFI_EXIT(EFI_SUCCESS);
}
-const struct efi_simple_text_output_protocol efi_con_out = {
+struct efi_simple_text_output_protocol efi_con_out = {
.reset = efi_cout_reset,
.output_string = efi_cout_output_string,
.test_string = efi_cout_test_string,
}
-static struct efi_object efi_console_control_obj =
- EFI_PROTOCOL_OBJECT(efi_guid_console_control, &efi_console_control);
-static struct efi_object efi_console_output_obj =
- EFI_PROTOCOL_OBJECT(EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID, &efi_con_out);
-static struct efi_object efi_console_input_obj =
- EFI_PROTOCOL_OBJECT(EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID, &efi_con_in);
-
/* This gets called from do_bootefi_exec(). */
int efi_console_register(void)
{
efi_status_t r;
+ struct efi_object *efi_console_control_obj;
+ struct efi_object *efi_console_output_obj;
+ struct efi_object *efi_console_input_obj;
- /* Hook up to the device list */
- list_add_tail(&efi_console_control_obj.link, &efi_obj_list);
- list_add_tail(&efi_console_output_obj.link, &efi_obj_list);
- list_add_tail(&efi_console_input_obj.link, &efi_obj_list);
+ /* Create handles */
+ r = efi_create_handle((void **)&efi_console_control_obj);
+ if (r != EFI_SUCCESS)
+ goto out_of_memory;
+ r = efi_add_protocol(efi_console_control_obj->handle,
+ &efi_guid_console_control, &efi_console_control);
+ if (r != EFI_SUCCESS)
+ goto out_of_memory;
+ r = efi_create_handle((void **)&efi_console_output_obj);
+ if (r != EFI_SUCCESS)
+ goto out_of_memory;
+ r = efi_add_protocol(efi_console_output_obj->handle,
+ &efi_guid_text_output_protocol, &efi_con_out);
+ if (r != EFI_SUCCESS)
+ goto out_of_memory;
+ r = efi_create_handle((void **)&efi_console_input_obj);
+ if (r != EFI_SUCCESS)
+ goto out_of_memory;
+ r = efi_add_protocol(efi_console_input_obj->handle,
+ &efi_guid_text_input_protocol, &efi_con_in);
+ if (r != EFI_SUCCESS)
+ goto out_of_memory;
+ /* Create console events */
r = efi_create_event(EVT_NOTIFY_WAIT, TPL_CALLBACK,
efi_key_notify, NULL, &efi_con_in.wait_for_key);
if (r != EFI_SUCCESS) {
if (r != EFI_SUCCESS)
printf("ERROR: Failed to set console timer\n");
return r;
+out_of_memory:
+ printf("ERROR: Out of meemory\n");
+ return r;
}