Project

General

Profile

Statistics
| Revision:

root / lab3 / kbc_func.h @ 36

History | View | Annotate | Download (1.9 KB)

1
#ifndef _KBC_FUNC_H_
2
#define _KBC_FUNC_H_
3

    
4
#include <stdint.h>
5

    
6
#define GET         0 /* @brief Argument to get counter without incrementing */
7
#define INCREMENT   1 /* @brief Argument for incrementing counter */
8

    
9
/**
10
 * @brief Subscribes KBC Interrupts and disables Minix Default Keyboard IH
11
 * @param interrupt_bit Bit of Interrupt Vector that will be set when KBC Interrupt is pending
12
 * @param interrupt_id KBC Interrupt ID to specify the KBC Interrupt in other calls
13
 * @return Whether operation was sucessful or not
14
 */
15
int (subscribe_kbc_interrupt)(uint8_t interrupt_bit, int *interrupt_id);
16

    
17
/**
18
 * @brief Unsubcribes KBC Interrupts
19
 * @param interrupt_id KBC Interrupt ID, value via arguments on subscription of the interrupt_id
20
 * @see subscribe_kbc_interrupt
21
 * @return Whether operation was sucessful or not
22
 */
23
int (unsubscribe_kbc_interrupt)(int *interrupt_id);
24

    
25
/**
26
 * @brief KBC Interrupt Handler
27
 */
28
void (kbc_ih)(void);
29

    
30
/**
31
 * @brief Counter for sys_inb calls
32
 * @param increment Whether the value should be incremented or not
33
 * @return The current value of the counter
34
 */
35
uint32_t (sys_inb_counter)(int get_increment);
36

    
37
/**
38
 * @brief High-level function that polls keyboard for scancode
39
 * High-level function that polls keyboard for scancode of up to 2 bytes. If
40
 * scancode has only 1 byte, the second byte is set to 0x00.
41
 * @param bytes Array of at least 2 bytes to store scancode
42
 * @param size Size of scancode in bytes
43
 * @return 0 if operation was successful, 1 otherwise
44
 */
45
int (kbd_poll)(uint8_t bytes[], uint8_t *size);
46

    
47
/**
48
 * @brief Low-level function for reading byte from keyboard
49
 * Low-level function for reading byte from keyboard. Waits until output buffer
50
 * is full
51
 * @param value Pointer to variable where byte read from keyboard will be stored
52
 * @return 0 if operation was successful, 1 otherwise
53
 */
54
int (kbd_read_byte)(uint8_t *value);
55

    
56
#endif