- Main Page
- Related Pages
- Data Structures
- Files

- File List
- Globals

# include/console/driver.h

Go to the documentation of this file.

    00001
    00041 #ifndef CONSOLE_DRIVER_H_INCLUDED
    00042 #define CONSOLE_DRIVER_H_INCLUDED
    00043
    00044 #include <ring.h>
    00045 #include <stddef.h>
    00046
    00050 #define CONSOLE_BUF_SIZE        64
    00051
    00055 struct console_buffer {
    00057         struct ring_head ring;
    00059         char data[CONSOLE_BUF_SIZE];
    00060 };
    00061
    00070 static inline void console_buf_insert_char(struct console_buffer *buf, char c)
    00071 {
    00072         buf->data[ring_get_head(&buf->ring, CONSOLE_BUF_SIZE)] = c;
    00073         ring_insert_entries(&buf->ring, 1);
    00074 }
    00075
    00084 static inline char console_buf_extract_char(struct console_buffer *buf)
    00085 {
    00086         unsigned long tail = ring_get_tail(&buf->ring, CONSOLE_BUF_SIZE);
    00087         ring_extract_entries(&buf->ring, 1);
    00088         return buf->data[tail];
    00089 }
    00090
    00099 static inline unsigned long console_buf_unused(struct console_buffer *buf)
    00100 {
    00101         return ring_entries_unused(&buf->ring, CONSOLE_BUF_SIZE);
    00102 }
    00103
    00112 static inline unsigned long console_buf_unused_before_end(
    00113                 struct console_buffer *buf)
    00114 {
    00115         return ring_entries_unused_before_end(&buf->ring, CONSOLE_BUF_SIZE);
    00116 }
    00117
    00126 static inline unsigned long console_buf_used(struct console_buffer *buf)
    00127 {
    00128         return ring_entries_used(&buf->ring, CONSOLE_BUF_SIZE);
    00129 }
    00130
    00138 struct console_driver {
    00140         void (*tx_commit)(struct console_driver *drv);
    00142         void (*tx_make_room)(struct console_driver *drv, size_t goal);
    00143
    00150         struct console_buffer tx_buf;
    00151 };
    00152
    00153 #endif /* CONSOLE_DRIVER_H_INCLUDED */