adds some debug flags for GDB support
This commit is contained in:
5
Makefile
5
Makefile
@ -2,7 +2,10 @@
|
||||
# or maybe add it to a bash script instead? im not sure
|
||||
|
||||
CC = i686-elf-gcc
|
||||
CFLAGS = -m32 -ffreestanding -Wall -Wextra -Werror -Wpedantic --sysroot=$(PWD)/sysroot -isystem=/usr/include -Iinclude -MD -D__TESTING__
|
||||
|
||||
DEBUG_FLAGS = -D__TESTING__ -g
|
||||
|
||||
CFLAGS = -m32 -ffreestanding -Wall -Wextra -Werror -Wpedantic --sysroot=$(PWD)/sysroot -isystem=/usr/include -Iinclude -MD $(DEBUG_FLAGS)
|
||||
|
||||
AS = nasm
|
||||
ASFLAGS = -f elf
|
||||
|
@ -41,6 +41,7 @@ void init_kb(void)
|
||||
puts("Initializing keyboard driver!");
|
||||
#endif
|
||||
keyb_state.ready = false;
|
||||
keyb_state.waiting_for_commands = true;
|
||||
init_queue(&kb_cmd_queue);
|
||||
|
||||
keyb_state.leds = 0;
|
||||
@ -51,9 +52,17 @@ void init_kb(void)
|
||||
queue_kb_command(KEYB_CMD_SET_TYPEMATIC);
|
||||
queue_kb_command(0x1F);
|
||||
|
||||
queue_kb_command(KEYB_CMD_DO_SCAN_CODE);
|
||||
/**
|
||||
* TODO: look into this further,
|
||||
* this is setting scan code 2, but the scan code this results in (on my hardware) is scan code set 1 according to https://wiki.osdev.org/PS/2_Keyboard
|
||||
*/
|
||||
queue_kb_command(0x2); // lets use scan code set 1
|
||||
|
||||
send_kb_commands();
|
||||
|
||||
keyb_state.ready = true;
|
||||
keyb_state.waiting_for_commands = false;
|
||||
|
||||
|
||||
#ifdef __TESTING__
|
||||
@ -92,13 +101,30 @@ void send_kb_commands(void)
|
||||
|
||||
|
||||
kb_key_code_t decode_scancode(uint8_t scancode)
|
||||
{return (kb_key_code_t) scancode;}
|
||||
{
|
||||
switch (scancode) {
|
||||
case KEYB_RESP_ERR:
|
||||
case KEYB_RESP_SELF_TEST_PASSED:
|
||||
case KEYB_RESP_ECHO:
|
||||
case KEYB_RESP_ACK:
|
||||
case KEYB_RESP_SELF_TEST_FAILED:
|
||||
case KEYB_RESP_SELF_TEST_FAILED_TWO:
|
||||
case KEYB_RESP_RESEND:
|
||||
case KEYB_RESP_ERR_TWO:
|
||||
keyb_state.waiting_for_commands = false;
|
||||
return KEY_NONE;
|
||||
default:
|
||||
keyb_state.waiting_for_commands = false;
|
||||
return (kb_key_code_t) scancode;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
key_press_t do_keypress(kb_key_code_t keycode)
|
||||
{
|
||||
key_press_t packet;
|
||||
|
||||
if (!keyb_state.ready) {
|
||||
if (!keyb_state.ready || keycode == KEY_NONE) {
|
||||
packet.key_code = KEY_NONE;
|
||||
return packet;
|
||||
}
|
||||
|
@ -7,44 +7,47 @@
|
||||
|
||||
#define KEYB_CMD_RETRIES 3
|
||||
|
||||
#define KEYB_CMD_SET_LEDS (0xED)
|
||||
#define KEYB_CMD_ECHO (0xEE)
|
||||
#define KEYB_CMD_DO_SCAN_CODE (0xF0)
|
||||
#define KEYB_CMD_IDENTIFY_KEYB (0xF2)
|
||||
#define KEYB_CMD_SET_TYPEMATIC (0xF3)
|
||||
#define KEYB_CMD_ENABLE_SCANNING (0xF4)
|
||||
#define KEYB_CMD_DISABLE_SCANNING (0xF5)
|
||||
#define KEYB_CMD_SET_DEFAULT_PARAMS (0xF6)
|
||||
#define KEYB_CMD_TYPEMATIC_AUTOREPEAT_3 (0xF7)
|
||||
#define KEYB_CMD_ALL_MAKE_RELEASE_3 (0xF8)
|
||||
#define KEYB_CMD_MAKE_ONLY_3 (0xF9)
|
||||
#define KEYB_CMD_TYPE_AUTOREPEAT_MAKE_RELEASE_3 (0xFA)
|
||||
#define KEYB_CMD_KEY_TYPEMATIC_AUTOREPEAT_3 (0xFB)
|
||||
#define KEYB_CMD_KEY_MAKE_RELEASE_3 (0xFC)
|
||||
#define KEYB_CMD_KEY_MAKE_3 (0xFD)
|
||||
#define KEYB_RESEND_LAST_BYTE (0xFE)
|
||||
#define KEYB_RESET_SELF_TEST (0xFF)
|
||||
|
||||
typedef enum {
|
||||
KEYB_CMD_SET_LEDS = 0xED,
|
||||
KEYB_CMD_ECHO = 0xEE,
|
||||
KEYB_CMD_DO_SCAN_CODE = 0xF0,
|
||||
KEYB_CMD_IDENTIFY_KEYB = 0xF2,
|
||||
KEYB_CMD_SET_TYPEMATIC = 0xF3,
|
||||
KEYB_CMD_ENABLE_SCANNING = 0xF4,
|
||||
KEYB_CMD_DISABLE_SCANNING = 0xF5,
|
||||
KEYB_CMD_SET_DEFAULT_PARAMS = 0xF6,
|
||||
KEYB_CMD_TYPEMATIC_AUTOREPEAT_3 = 0xF7,
|
||||
KEYB_CMD_ALL_MAKE_RELEASE_3 = 0xF8,
|
||||
KEYB_CMD_MAKE_ONLY_3 = 0xF9,
|
||||
KEYB_CMD_TYPE_AUTOREPEAT_MAKE_RELEASE_3 = 0xFA,
|
||||
KEYB_CMD_KEY_TYPEMATIC_AUTOREPEAT_3 = 0xFB,
|
||||
KEYB_CMD_KEY_MAKE_RELEASE_3 = 0xFC,
|
||||
KEYB_CMD_KEY_MAKE_3 = 0xFD,
|
||||
KEYB_RESEND_LAST_BYTE = 0xFE,
|
||||
KEYB_RESET_SELF_TEST = 0xFF
|
||||
} keyb_cmd_t;
|
||||
|
||||
#define KEYB_LED_SCRL_LCK (1 << 0)
|
||||
#define KEYB_LED_NUM_LCK (1 << 1)
|
||||
#define KEYB_LED_CAP_LCK (1 << 2)
|
||||
|
||||
|
||||
// TODO investigate
|
||||
#define KEYB_GET_SCAN_SET (0x00)
|
||||
#define KEYB_SET_SCAN_1 (0x01)
|
||||
#define KEYB_SET_SCAN_2 (0x02)
|
||||
#define KEYB_SET_SCAN_3 (0x03)
|
||||
|
||||
|
||||
#define KEYB_RESP_ERR (0x00)
|
||||
#define KEYB_RESP_SELF_TEST_PASSED (0xAA)
|
||||
#define KEYB_RESP_ECHO (0xEE)
|
||||
#define KEYB_RESP_ACK (0xFA)
|
||||
#define KEYB_RESP_SELF_TEST_FAILED (0xFC)
|
||||
#define KEYB_RESP_SELF_TEST_FAILED_TWO (0xFD)
|
||||
#define KEYB_RESP_RESEND (0xFE)
|
||||
#define KEYB_RESP_ERR_TWO (0xFF)
|
||||
|
||||
typedef enum {
|
||||
KEYB_RESP_ERR = 0x00,
|
||||
KEYB_RESP_SELF_TEST_PASSED = 0xAA,
|
||||
KEYB_RESP_ECHO = 0xEE,
|
||||
KEYB_RESP_ACK = 0xFA,
|
||||
KEYB_RESP_SELF_TEST_FAILED = 0xFC,
|
||||
KEYB_RESP_SELF_TEST_FAILED_TWO = 0xFD,
|
||||
KEYB_RESP_RESEND = 0xFE,
|
||||
KEYB_RESP_ERR_TWO = 0xFF
|
||||
} keyb_resp_t;
|
||||
|
||||
#define STATUS_FLAG_RSHIFT (1 << 0)
|
||||
#define STATUS_FLAG_LSHIFT (1 << 1)
|
||||
@ -121,6 +124,9 @@ typedef struct {
|
||||
|
||||
struct keyboard_state {
|
||||
bool ready;
|
||||
|
||||
bool waiting_for_commands;
|
||||
|
||||
uint8_t leds;
|
||||
uint8_t flags;
|
||||
};
|
||||
|
Reference in New Issue
Block a user