-
Notifications
You must be signed in to change notification settings - Fork 9
/
kbd.h
43 lines (37 loc) · 1.21 KB
/
kbd.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef KBD_H_
#define KBD_H_
#include <stdint.h>
#include "ioapic.h"
#define KBD_BUF_SIZE 255
#define KBD_STATUS_IN 2
#define NO 0
/*
* Status Register
* |_b_|_meaning________________________________________|
* | 0 | Output Buffer: 0=empty / 1=full *a |
* | 1 | Input Buffer: 0=empty / 1=full *b |
* | 2 | System Flag: 0 on reset / 1 after passing POST |
* | 3 | Command/Data: 0=data 1=command for device |
* | 4 | Chipset specific |
* | 5 | Chipset specific |
* | 6 | Time-out Error: 0=noerror / 1=error |
* | 7 | Parity Error: 0=noerror / 1=error |
* |____________________________________________________|
* a. must be set before attempting to read data from IO port 0x60
* b. must be clear before attempting to write data to IO port 0x60 or IO port 0x64
*/
typedef struct
{
uint8_t status;
IOAPIC *ioapic;
unsigned int buf[256];
uint8_t buf_index;
uint8_t buf_out_index;
uint8_t buf_index_reset;
} KBD;
void init_kbd(IOAPIC *ioapic);
uint8_t get_kbd_status();
uint8_t get_kbd_data();
void write_ps2_output_port(uint8_t value);
void write_ps2_config_byte(uint8_t value);
#endif