1 #include "devices/input.h"
3 #include "devices/intq.h"
4 #include "devices/serial.h"
6 /* Stores keys from the keyboard and serial port. */
7 static struct intq buffer
;
9 /* Initializes the input buffer. */
16 /* Adds a key to the input buffer.
17 Interrupts must be off and the buffer must not be full. */
19 input_putc (uint8_t key
)
21 ASSERT (intr_get_level () == INTR_OFF
);
22 ASSERT (!intq_full (&buffer
));
24 intq_putc (&buffer
, key
);
28 /* Retrieves a key from the input buffer.
29 If the buffer is empty, waits for a key to be pressed. */
33 enum intr_level old_level
;
36 old_level
= intr_disable ();
37 key
= intq_getc (&buffer
);
39 intr_set_level (old_level
);
44 /* Returns true if the input buffer is full,
46 Interrupts must be off. */
50 ASSERT (intr_get_level () == INTR_OFF
);
51 return intq_full (&buffer
);