Merge tag 'efi-2019-07-rc5-2' of git://git.denx.de/u-boot-efi
[platform/kernel/u-boot.git] / lib / efi_loader / efi_console.c
index 051fc1d..706e6ad 100644 (file)
@@ -136,6 +136,11 @@ static efi_status_t EFIAPI efi_cout_output_string(
 
        EFI_ENTRY("%p, %p", this, string);
 
+       if (!this || !string) {
+               ret = EFI_INVALID_PARAMETER;
+               goto out;
+       }
+
        buf = malloc(utf16_utf8_strlen(string) + 1);
        if (!buf) {
                ret = EFI_OUT_OF_RESOURCES;
@@ -311,23 +316,6 @@ static efi_status_t EFIAPI efi_cout_query_mode(
        return EFI_EXIT(EFI_SUCCESS);
 }
 
-static efi_status_t EFIAPI efi_cout_set_mode(
-                       struct efi_simple_text_output_protocol *this,
-                       unsigned long mode_number)
-{
-       EFI_ENTRY("%p, %ld", this, mode_number);
-
-
-       if (mode_number > efi_con_mode.max_mode)
-               return EFI_EXIT(EFI_UNSUPPORTED);
-
-       efi_con_mode.mode = mode_number;
-       efi_con_mode.cursor_column = 0;
-       efi_con_mode.cursor_row = 0;
-
-       return EFI_EXIT(EFI_SUCCESS);
-}
-
 static const struct {
        unsigned int fg;
        unsigned int bg;
@@ -353,6 +341,7 @@ static efi_status_t EFIAPI efi_cout_set_attribute(
 
        EFI_ENTRY("%p, %lx", this, attribute);
 
+       efi_con_mode.attribute = attribute;
        if (attribute)
                printf(ESC"[%u;%u;%um", bold, color[fg].fg, color[bg].bg);
        else
@@ -373,6 +362,20 @@ static efi_status_t EFIAPI efi_cout_clear_screen(
        return EFI_EXIT(EFI_SUCCESS);
 }
 
+static efi_status_t EFIAPI efi_cout_set_mode(
+                       struct efi_simple_text_output_protocol *this,
+                       unsigned long mode_number)
+{
+       EFI_ENTRY("%p, %ld", this, mode_number);
+
+       if (mode_number >= efi_con_mode.max_mode)
+               return EFI_EXIT(EFI_UNSUPPORTED);
+       efi_con_mode.mode = mode_number;
+       EFI_CALL(efi_cout_clear_screen(this));
+
+       return EFI_EXIT(EFI_SUCCESS);
+}
+
 static efi_status_t EFIAPI efi_cout_reset(
                        struct efi_simple_text_output_protocol *this,
                        char extended_verification)
@@ -382,6 +385,7 @@ static efi_status_t EFIAPI efi_cout_reset(
        /* Clear screen */
        EFI_CALL(efi_cout_clear_screen(this));
        /* Set default colors */
+       efi_con_mode.attribute = 0x07;
        printf(ESC "[0;37;40m");
 
        return EFI_EXIT(EFI_SUCCESS);
@@ -425,6 +429,7 @@ static efi_status_t EFIAPI efi_cout_enable_cursor(
        EFI_ENTRY("%p, %d", this, enable);
 
        printf(ESC"[?25%c", enable ? 'h' : 'l');
+       efi_con_mode.cursor_visible = !!enable;
 
        return EFI_EXIT(EFI_SUCCESS);
 }
@@ -698,7 +703,7 @@ static void efi_cin_check(void)
        efi_status_t ret;
 
        if (key_available) {
-               efi_signal_event(efi_con_in.wait_for_key, true);
+               efi_signal_event(efi_con_in.wait_for_key);
                return;
        }
 
@@ -712,7 +717,7 @@ static void efi_cin_check(void)
 
                        /* Queue the wait for key event */
                        if (key_available)
-                               efi_signal_event(efi_con_in.wait_for_key, true);
+                               efi_signal_event(efi_con_in.wait_for_key);
                }
        }
 }
@@ -825,7 +830,7 @@ out:
  * efi_cin_set_state() - set toggle key state
  *
  * @this:              instance of the EFI_SIMPLE_TEXT_INPUT_PROTOCOL
- * @key_toggle_state:  key toggle state
+ * @key_toggle_state:  pointer to key toggle state
  * Return:             status code
  *
  * This function implements the SetState service of the
@@ -836,9 +841,9 @@ out:
  */
 static efi_status_t EFIAPI efi_cin_set_state(
                struct efi_simple_text_input_ex_protocol *this,
-               u8 key_toggle_state)
+               u8 *key_toggle_state)
 {
-       EFI_ENTRY("%p, %u", this, key_toggle_state);
+       EFI_ENTRY("%p, %p", this, key_toggle_state);
        /*
         * U-Boot supports multiple console input sources like serial and
         * net console for which a key toggle state cannot be set at all.