mirror of
https://xff.cz/git/u-boot/
synced 2025-09-26 04:51:17 +02:00
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>
This commit is contained in:
committed by
Alexander Graf
parent
48b66230ee
commit
ebb4dd5bc3
@@ -78,9 +78,9 @@ const char *__efi_nesting_dec(void);
|
|||||||
extern struct efi_runtime_services efi_runtime_services;
|
extern struct efi_runtime_services efi_runtime_services;
|
||||||
extern struct efi_system_table systab;
|
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 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;
|
extern const struct efi_device_path_to_text_protocol efi_device_path_to_text;
|
||||||
|
|
||||||
uint16_t *efi_dp_str(struct efi_device_path *dp);
|
uint16_t *efi_dp_str(struct efi_device_path *dp);
|
||||||
@@ -121,14 +121,6 @@ struct efi_object {
|
|||||||
void *handle;
|
void *handle;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define EFI_PROTOCOL_OBJECT(_guid, _protocol) (struct efi_object){ \
|
|
||||||
.protocols = {{ \
|
|
||||||
.guid = &(_guid), \
|
|
||||||
.protocol_interface = (void *)(_protocol), \
|
|
||||||
}}, \
|
|
||||||
.handle = (void *)(_protocol), \
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* struct efi_event
|
* struct efi_event
|
||||||
*
|
*
|
||||||
|
@@ -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_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 cESC '\x1b'
|
||||||
#define ESC "\x1b"
|
#define ESC "\x1b"
|
||||||
@@ -81,7 +85,7 @@ static efi_status_t EFIAPI efi_cin_lock_std_in(
|
|||||||
return EFI_EXIT(EFI_UNSUPPORTED);
|
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,
|
.get_mode = efi_cin_get_mode,
|
||||||
.set_mode = efi_cin_set_mode,
|
.set_mode = efi_cin_set_mode,
|
||||||
.lock_std_in = efi_cin_lock_std_in,
|
.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);
|
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,
|
.reset = efi_cout_reset,
|
||||||
.output_string = efi_cout_output_string,
|
.output_string = efi_cout_output_string,
|
||||||
.test_string = efi_cout_test_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(). */
|
/* This gets called from do_bootefi_exec(). */
|
||||||
int efi_console_register(void)
|
int efi_console_register(void)
|
||||||
{
|
{
|
||||||
efi_status_t r;
|
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 */
|
/* Create handles */
|
||||||
list_add_tail(&efi_console_control_obj.link, &efi_obj_list);
|
r = efi_create_handle((void **)&efi_console_control_obj);
|
||||||
list_add_tail(&efi_console_output_obj.link, &efi_obj_list);
|
if (r != EFI_SUCCESS)
|
||||||
list_add_tail(&efi_console_input_obj.link, &efi_obj_list);
|
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,
|
r = efi_create_event(EVT_NOTIFY_WAIT, TPL_CALLBACK,
|
||||||
efi_key_notify, NULL, &efi_con_in.wait_for_key);
|
efi_key_notify, NULL, &efi_con_in.wait_for_key);
|
||||||
if (r != EFI_SUCCESS) {
|
if (r != EFI_SUCCESS) {
|
||||||
@@ -525,4 +544,7 @@ int efi_console_register(void)
|
|||||||
if (r != EFI_SUCCESS)
|
if (r != EFI_SUCCESS)
|
||||||
printf("ERROR: Failed to set console timer\n");
|
printf("ERROR: Failed to set console timer\n");
|
||||||
return r;
|
return r;
|
||||||
|
out_of_memory:
|
||||||
|
printf("ERROR: Out of meemory\n");
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user