Files
mango/include/socks/console.h

57 lines
1.5 KiB
C
Raw Normal View History

#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 struct console 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>
2023-03-20 20:41:39 +00:00
#ifdef __cplusplus
extern "C" {
#endif
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,
};
struct console {
char c_name[16];
enum console_flags c_flags;
spin_lock_t c_lock;
void (*c_write)(struct console *, const char *, unsigned int);
int (*c_read)(struct console *, char *, unsigned int);
struct queue_entry c_list;
};
extern kern_status_t console_register(struct console *con);
extern kern_status_t console_unregister(struct console *con);
extern struct queue *get_consoles(unsigned long *flags);
extern void put_consoles(struct queue *consoles, unsigned long flags);
extern void console_write(struct console *con, const char *s, unsigned int len);
extern int console_read(struct console *con, char *s, unsigned int len);
2023-03-20 20:41:39 +00:00
#ifdef __cplusplus
}
#endif
#endif