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. */
7 #ifndef ROS_KERN_CONSOLE_H
8 #define ROS_KERN_CONSOLE_H
14 #define KB_BUF_SIZE 256 /* Make sure this is a power of 2 */
16 /* Ring buffer for keyboard/character devices. Might make a more generic
17 * version in the future (allowing both sides to block, etc). Adding will drop
18 * any overflow, and getting will block til the full amount is read. */
20 unsigned int prod_idx;
21 unsigned int cons_idx;
23 struct semaphore buf_sem;
24 char buf[KB_BUF_SIZE];
26 extern struct kb_buffer cons_buf; /* kernel's console buffer */
28 void kb_buf_init(struct kb_buffer *kb);
29 /* These are not irq-safe. and get will block. */
30 void kb_add_to_buf(struct kb_buffer *kb, char c);
31 void kb_get_from_buf(struct kb_buffer *kb, char *dst, size_t cnt);
33 /* Kernel messages associated with the console. Arch-specific interrupt
34 * handlers need to call these. For add char, a0 = &cons_buf and a1 = the char
35 * you read. Call __run_mon on your 'magic' input. */
36 void __cons_add_char(uint32_t srcid, long a0, long a1, long a2);
37 void __run_mon(uint32_t srcid, long a0, long a1, long a2);
39 #endif /* ROS_KERN_CONSOLE_H */