54 lines
1.4 KiB
C
54 lines
1.4 KiB
C
#ifndef SOCKS_CONSOLE_H_
|
|
#define SOCKS_CONSOLE_H_
|
|
|
|
/* The console system
|
|
|
|
Consoles are like simplified TTYs. Their purpose is to serve as an output
|
|
sink for messages printed using printk.
|
|
|
|
a console_t could be used to represent a serial port, UART port, or even
|
|
a text-based framebuffer display. Anything where the job of displaying
|
|
or sending text can be abstracted to a simple write() call.
|
|
|
|
A secondary purpose of consoles is to allow input. For example, a console
|
|
representing a serial port may allow both sending AND receiving over the
|
|
port.
|
|
*/
|
|
#include <socks/queue.h>
|
|
#include <socks/locks.h>
|
|
#include <socks/status.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
typedef enum console_flags {
|
|
/* console is only used during the boot process. the console
|
|
will be automatically de-registered when the first
|
|
non-boot console is registered */
|
|
CON_BOOT = 0x01u,
|
|
} console_flags_t;
|
|
|
|
typedef struct console {
|
|
char c_name[16];
|
|
console_flags_t c_flags;
|
|
spin_lock_t c_lock;
|
|
|
|
void (*c_write)(struct console *, const char *, unsigned int);
|
|
int (*c_read)(struct console *, char *, unsigned int);
|
|
|
|
queue_entry_t c_list;
|
|
} console_t;
|
|
|
|
extern kern_status_t console_register(console_t *con);
|
|
extern kern_status_t console_unregister(console_t *con);
|
|
|
|
extern void console_write(console_t *con, const char *s, unsigned int len);
|
|
extern int console_read(console_t *con, char *s, unsigned int len);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|