.cursor_visible = 1,
};
+static int term_get_char(s32 *c)
+{
+ u64 timeout;
+
+ /* Wait up to 100 ms for a character */
+ timeout = timer_get_us() + 100000;
+
+ while (!tstc())
+ if (timer_get_us() > timeout)
+ return 1;
+
+ *c = getc();
+ return 0;
+}
+
/*
* Receive and parse a reply from the terminal.
*
*/
static int term_read_reply(int *n, int num, char end_char)
{
- char c;
+ s32 c;
int i = 0;
- c = getc();
- if (c != cESC)
+ if (term_get_char(&c) || c != cESC)
return -1;
- c = getc();
- if (c != '[')
+
+ if (term_get_char(&c) || c != '[')
return -1;
n[0] = 0;
while (1) {
- c = getc();
- if (c == ';') {
- i++;
- if (i >= num)
+ if (!term_get_char(&c)) {
+ if (c == ';') {
+ i++;
+ if (i >= num)
+ return -1;
+ n[i] = 0;
+ continue;
+ } else if (c == end_char) {
+ break;
+ } else if (c > '9' || c < '0') {
return -1;
- n[i] = 0;
- continue;
- } else if (c == end_char) {
- break;
- } else if (c > '9' || c < '0') {
+ }
+
+ /* Read one more decimal position */
+ n[i] *= 10;
+ n[i] += c - '0';
+ } else {
return -1;
}
-
- /* Read one more decimal position */
- n[i] *= 10;
- n[i] += c - '0';
}
if (i != num - 1)
return -1;
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;
{
int ret = 0;
int n[2];
- u64 timeout;
/* Empty input buffer */
while (tstc())
/*
* Not all terminals understand CSI [18t for querying the console size.
* We should adhere to escape sequences documented in the console_codes
- * manpage and the ECMA-48 standard.
+ * man page and the ECMA-48 standard.
*
* So here we follow a different approach. We position the cursor to the
* bottom right and query its position. Before leaving the function we
ESC "[999;999H" /* Move to bottom right corner */
ESC "[6n"); /* Query cursor position */
- /* Allow up to one second for a response */
- timeout = timer_get_us() + 1000000;
- while (!tstc())
- if (timer_get_us() > timeout) {
- ret = -1;
- goto out;
- }
-
/* Read {rows,cols} */
if (term_read_reply(n, 2, 'R')) {
ret = 1;
EFI_ENTRY("%p, %d", this, enable);
printf(ESC"[?25%c", enable ? 'h' : 'l');
+ efi_con_mode.cursor_visible = !!enable;
return EFI_EXIT(EFI_SUCCESS);
}
*
* This gets called when we have already parsed CSI.
*
- * @modifiers: bitmask (shift, alt, ctrl)
+ * @modifiers: bit mask (shift, alt, ctrl)
* @return: the unmodified code
*/
static int analyze_modifiers(struct efi_key_state *key_state)
ret = EFI_NOT_READY;
goto out;
}
+ /*
+ * CTRL+A - CTRL+Z have to be signaled as a - z.
+ * SHIFT+CTRL+A - SHIFT+CTRL+Z have to be signaled as A - Z.
+ */
+ switch (next_key.key.unicode_char) {
+ case 0x01 ... 0x07:
+ case 0x0b ... 0x0c:
+ case 0x0e ... 0x1a:
+ if (!(next_key.key_state.key_toggle_state &
+ EFI_CAPS_LOCK_ACTIVE) ^
+ !(next_key.key_state.key_shift_state &
+ (EFI_LEFT_SHIFT_PRESSED | EFI_RIGHT_SHIFT_PRESSED)))
+ next_key.key.unicode_char += 0x40;
+ else
+ next_key.key.unicode_char += 0x60;
+ }
*key_data = next_key;
key_available = false;
efi_con_in.wait_for_key->is_signaled = false;
+
out:
return EFI_EXIT(ret);
}
* 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
*/
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.