kernel: don't use typedef for enums or non-opaque structs
This commit is contained in:
@@ -13,9 +13,9 @@
|
||||
buffered user input.
|
||||
|
||||
A TTY object is split into 2 parts:
|
||||
- tty_t: This represents the terminal session, and tracks things like the cursor
|
||||
- struct tty: This represents the terminal session, and tracks things like the cursor
|
||||
position, input buffer, flags, etc.
|
||||
- tty_driver_t: This is a set of function callbacks that the TTY can use to
|
||||
- struct tty_driver: This is a set of function callbacks that the TTY can use to
|
||||
manipulate the output device. This could represent a char-based framebuffer
|
||||
device, a serial port, etc.
|
||||
*/
|
||||
@@ -27,66 +27,66 @@ extern "C" {
|
||||
/* opaque context pointer for use by the tty driver */
|
||||
typedef void *tty_driver_ctx_t;
|
||||
|
||||
typedef enum tty_driver_type {
|
||||
enum tty_driver_type {
|
||||
/* For TTYs operating on simple IO devices like serial ports.
|
||||
Allows writing characters, receiving characters, and not much else. */
|
||||
TTY_DRIVER_SIMPLE,
|
||||
/* For TTYs operating on more capable display interfaces.
|
||||
Allows putting characters at arbitrary locations, scrolling, etc */
|
||||
TTY_DRIVER_FULL,
|
||||
} tty_driver_type_t;
|
||||
};
|
||||
|
||||
/* TTY cursor status. The extra cursor styles are just for completeness,
|
||||
the important one to support (if possible), is TTY_CURSOR_NONE.
|
||||
The others can be interpreted as "just turn on a cursor of any style". */
|
||||
typedef enum tty_cursor {
|
||||
enum tty_cursor {
|
||||
TTY_CURSOR_ULINE,
|
||||
TTY_CURSOR_BLOCK,
|
||||
TTY_CURSOR_NONE,
|
||||
} tty_cursor_t;
|
||||
};
|
||||
|
||||
/* direction to use for scrolling. The important one to support is
|
||||
TTY_SCROLL_DOWN for when output overflows the display */
|
||||
typedef enum tty_scroll_dir {
|
||||
enum tty_scroll_dir {
|
||||
TTY_SCROLL_DOWN,
|
||||
TTY_SCROLL_UP,
|
||||
} tty_scroll_dir_t;
|
||||
};
|
||||
|
||||
/* character attribute. this could be as simple as VGA's 16-colour palette
|
||||
plus an extra bit for bright, or a full 24-bit RGB value with bold and underline
|
||||
support, depending on what the driver supports. */
|
||||
typedef uint64_t tty_attrib_t;
|
||||
|
||||
typedef struct tty_driver {
|
||||
struct tty_driver {
|
||||
char tty_name[16];
|
||||
tty_driver_type_t tty_type;
|
||||
queue_entry_t tty_list;
|
||||
enum tty_driver_type tty_type;
|
||||
struct queue_entry tty_list;
|
||||
|
||||
void (*tty_init)(tty_driver_ctx_t *ctx);
|
||||
void (*tty_deinit)(tty_driver_ctx_t ctx);
|
||||
void (*tty_clear)(tty_driver_ctx_t ctx, int x, int y, int width, int height);
|
||||
void (*tty_putc)(tty_driver_ctx_t ctx, int c, int xpos, int ypos, tty_attrib_t attrib);
|
||||
void (*tty_set_cursor)(tty_driver_ctx_t ctx, tty_cursor_t cur);
|
||||
void (*tty_set_cursor)(tty_driver_ctx_t ctx, enum tty_cursor cur);
|
||||
void (*tty_move_cursor)(tty_driver_ctx_t ctx, int x, int y);
|
||||
void (*tty_scroll)(tty_driver_ctx_t ctx, tty_scroll_dir_t dir, int lines);
|
||||
} tty_driver_t;
|
||||
void (*tty_scroll)(tty_driver_ctx_t ctx, enum tty_scroll_dir dir, int lines);
|
||||
};
|
||||
|
||||
typedef struct tty {
|
||||
struct tty {
|
||||
int tty_xcur, tty_ycur;
|
||||
unsigned int tty_iflag, tty_oflag, tty_lflag;
|
||||
|
||||
tty_driver_ctx_t tty_dctx;
|
||||
const tty_driver_t *tty_driver;
|
||||
} tty_t;
|
||||
const struct tty_driver *tty_driver;
|
||||
};
|
||||
|
||||
extern kern_status_t tty_driver_register(tty_driver_t *drv);
|
||||
extern kern_status_t tty_driver_unregister(tty_driver_t *drv);
|
||||
extern kern_status_t tty_driver_register(struct tty_driver *drv);
|
||||
extern kern_status_t tty_driver_unregister(struct tty_driver *drv);
|
||||
|
||||
extern tty_t *tty_create(void);
|
||||
extern void tty_destroy(tty_t *tty);
|
||||
extern struct tty *tty_create(void);
|
||||
extern void tty_destroy(struct tty *tty);
|
||||
|
||||
extern int tty_read(tty_t *tty, char *s, unsigned long len);
|
||||
extern int tty_write(tty_t *tty, const char *s, unsigned long len);
|
||||
extern int tty_read(struct tty *tty, char *s, unsigned long len);
|
||||
extern int tty_write(struct tty *tty, const char *s, unsigned long len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user