summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHeinrich Schuchardt <xypron.glpk@gmx.de>2017-10-26 19:25:59 +0200
committerAlexander Graf <agraf@suse.de>2017-12-01 13:22:56 +0100
commitebb4dd5bc3d39b3a2109970936c7e74556110915 (patch)
treededc3e5e11297ba20a5aee43b4978aaa198c69c4 /lib
parent48b66230eef074c7335eab8c82b1f9c561b54794 (diff)
downloadu-boot-ebb4dd5bc3d39b3a2109970936c7e74556110915.tar.gz
u-boot-ebb4dd5bc3d39b3a2109970936c7e74556110915.tar.bz2
u-boot-ebb4dd5bc3d39b3a2109970936c7e74556110915.zip
efi_loader: efi_console: use helper functions
Use helper functions efi_created_handle and efi_add_protocol for creating the console handles and instaling the respective protocols. This change is needed if we want to move from an array of protocols to a linked list of protocols. Eliminate EFI_PROTOCOL_OBJECT which is not used anymore. Currently we have not defined protocol interfaces to be const. So efi_con_out and efi_console_control cannot be defined as const. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/efi_loader/efi_console.c48
1 files changed, 35 insertions, 13 deletions
diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c
index 01732aafea..98497db612 100644
--- a/lib/efi_loader/efi_console.c
+++ b/lib/efi_loader/efi_console.c
@@ -46,6 +46,10 @@ static struct cout_mode efi_cout_modes[] = {
};
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"
@@ -81,7 +85,7 @@ static efi_status_t EFIAPI efi_cin_lock_std_in(
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,
@@ -374,7 +378,7 @@ static efi_status_t EFIAPI efi_cout_enable_cursor(
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,
@@ -490,23 +494,38 @@ static void EFIAPI efi_console_timer_notify(struct efi_event *event,
}
-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) {
@@ -525,4 +544,7 @@ int efi_console_register(void)
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;
}