Skip to content

Commit 24b2455

Browse files
nir9Daniel Thompson
authored andcommitted
kdb: fix ctrl+e/a/f/b/d/p/n broken in keyboard mode
Problem: When using kdb via keyboard it does not react to control characters which are supported in serial mode. Example: Chords such as ctrl+a/e/d/p do not work in keyboard mode Solution: Before disregarding non-printable key characters, check if they are one of the supported control characters, I have took the control characters from the switch case upwards in this function that translates scan codes of arrow keys/backspace/home/.. to the control characters. Suggested-by: Douglas Anderson <[email protected]> Signed-off-by: Nir Lichtman <[email protected]> Reviewed-by: Douglas Anderson <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Daniel Thompson <[email protected]>
1 parent 9c98750 commit 24b2455

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

kernel/debug/kdb/kdb_keyboard.c

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#define KBD_STAT_OBF 0x01 /* Keyboard output buffer full */
2626
#define KBD_STAT_MOUSE_OBF 0x20 /* Mouse output buffer full */
2727

28+
#define CTRL(c) ((c) - 64)
29+
2830
static int kbd_exists;
2931
static int kbd_last_ret;
3032

@@ -123,24 +125,24 @@ int kdb_get_kbd_char(void)
123125
return 8;
124126
}
125127

126-
/* Special Key */
128+
/* Translate special keys to equivalent CTRL control characters */
127129
switch (scancode) {
128130
case 0xF: /* Tab */
129-
return 9;
131+
return CTRL('I');
130132
case 0x53: /* Del */
131-
return 4;
133+
return CTRL('D');
132134
case 0x47: /* Home */
133-
return 1;
135+
return CTRL('A');
134136
case 0x4F: /* End */
135-
return 5;
137+
return CTRL('E');
136138
case 0x4B: /* Left */
137-
return 2;
139+
return CTRL('B');
138140
case 0x48: /* Up */
139-
return 16;
141+
return CTRL('P');
140142
case 0x50: /* Down */
141-
return 14;
143+
return CTRL('N');
142144
case 0x4D: /* Right */
143-
return 6;
145+
return CTRL('F');
144146
}
145147

146148
if (scancode == 0xe0)
@@ -172,6 +174,19 @@ int kdb_get_kbd_char(void)
172174
switch (KTYP(keychar)) {
173175
case KT_LETTER:
174176
case KT_LATIN:
177+
switch (keychar) {
178+
/* non-printable supported control characters */
179+
case CTRL('A'): /* Home */
180+
case CTRL('B'): /* Left */
181+
case CTRL('D'): /* Del */
182+
case CTRL('E'): /* End */
183+
case CTRL('F'): /* Right */
184+
case CTRL('I'): /* Tab */
185+
case CTRL('N'): /* Down */
186+
case CTRL('P'): /* Up */
187+
return keychar;
188+
}
189+
175190
if (isprint(keychar))
176191
break; /* printable characters */
177192
fallthrough;

0 commit comments

Comments
 (0)