1 /* Copyright (c) 2012 The Regents of the University of California
2 * Barret Rhoden <brho@cs.berkeley.edu>
3 * See LICENSE for details.
5 * Console (Keyboard/serial/whatever) related functions. */
13 #define KB_BUF_SIZE 256 /* Make sure this is a power of 2 */
15 /* Ring buffer for keyboard/character devices. Might make a more generic
16 * version in the future (allowing both sides to block, etc). Adding will drop
17 * any overflow, and getting will block til the full amount is read. */
19 unsigned int prod_idx;
20 unsigned int cons_idx;
22 struct semaphore buf_sem;
23 char buf[KB_BUF_SIZE];
25 extern struct kb_buffer cons_buf; /* kernel's console buffer */
27 void kb_buf_init(struct kb_buffer *kb);
28 /* These are not irq-safe. and get will block. */
29 void kb_add_to_buf(struct kb_buffer *kb, char c);
30 void kb_get_from_buf(struct kb_buffer *kb, char *dst, size_t cnt);
32 /* Kernel messages associated with the console. Arch-specific interrupt
33 * handlers need to call these. For add char, a0 = &cons_buf and a1 = the char
34 * you read. Call __run_mon on your 'magic' input. */
35 void __cons_add_char(uint32_t srcid, long a0, long a1, long a2);
36 void __run_mon(uint32_t srcid, long a0, long a1, long a2);
38 /* function to run one command. */
39 int onecmd(int argc, char *argv[], struct hw_trapframe *hw_tf);