MOS Source Code
Loading...
Searching...
No Matches
console.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-3.0-or-later
2
3#pragma once
4
5#include <ansi_colors.h>
6#include <mos/io/io.h>
10#include <mos/tasks/wait.h>
11#include <mos/types.h>
12
23
25
26typedef struct _console
27{
30 struct console_ops *ops;
31 const char *name;
33 waitlist_t waitlist; // waitlist for read
34
35 struct
36 {
40 size_t size;
41 } read;
42
43 struct
44 {
45 spinlock_t lock;
46 } write;
47
49} console_t;
50
51typedef struct console_ops
52{
53 bool (*extra_setup)(console_t *con);
54
55 size_t (*write)(console_t *con, const char *data, size_t size);
56
57 bool (*get_size)(console_t *con, u32 *width, u32 *height);
58
59 bool (*set_cursor)(console_t *con, bool show);
60 bool (*move_cursor)(console_t *con, u32 x, u32 y);
61 bool (*get_cursor)(console_t *con, u32 *x, u32 *y);
62
63 // VGA standard color codes
64 bool (*get_color)(console_t *con, standard_color_t *fg, standard_color_t *bg);
65 bool (*set_color)(console_t *con, standard_color_t fg, standard_color_t bg);
66
67 bool (*clear)(console_t *con);
69
70extern list_head consoles;
71
74console_t *console_get(const char *name);
75console_t *console_get_by_prefix(const char *prefix);
76
77size_t console_write(console_t *con, const char *data, size_t size);
78size_t console_write_color(console_t *con, const char *data, size_t size, standard_color_t fg, standard_color_t bg);
79
80void console_putc(console_t *con, u8 c);
size_t console_write_color(console_t *con, const char *data, size_t size, standard_color_t fg, standard_color_t bg)
Definition console.c:132
console_t * console_get_by_prefix(const char *prefix)
Definition console.c:114
console_caps
Definition console.h:14
@ CONSOLE_CAP_COLOR
Definition console.h:15
@ CONSOLE_CAP_READ
console supports read
Definition console.h:21
@ CONSOLE_CAP_CLEAR
Definition console.h:16
@ CONSOLE_CAP_EXTRA_SETUP
extra setup required
Definition console.h:20
@ CONSOLE_CAP_GET_SIZE
Definition console.h:17
@ CONSOLE_CAP_CURSOR_MOVE
Definition console.h:19
@ CONSOLE_CAP_CURSOR_HIDE
Definition console.h:18
size_t console_write(console_t *con, const char *data, size_t size)
Definition console.c:124
console_t * console_get(const char *name)
Definition console.c:101
__BEGIN_DECLS void console_register(console_t *con)
Definition console.c:71
void console_putc(console_t *con, u8 c)
Definition console.c:148
list_head consoles
Definition console.c:16
standard_color_t
Definition ansi_colors.h:18
list_node_t list_head
A linked list head.
Definition list.h:23
#define __END_DECLS
Definition mos_global.h:23
#define MOS_ENUM_OPERATORS(_enum)
Definition mos_global.h:173
#define __BEGIN_DECLS
Definition mos_global.h:22
int bool
Definition pb_syshdr.h:57
uint32_t size_t
Definition pb_syshdr.h:42
struct _console console_t
Definition platform.h:37
size_t size
Definition slab.c:30
const char * name
Definition slab.c:31
console_caps caps
Definition console.h:32
struct console_ops * ops
Definition console.h:30
as_linked_list
Definition console.h:28
ring_buffer_pos_t pos
Definition console.h:38
io_t io
Definition console.h:29
spinlock_t lock
Definition console.h:37
size_t size
Definition console.h:40
const char * name
Definition console.h:31
standard_color_t default_bg
Definition console.h:48
waitlist_t waitlist
Definition console.h:33
u8 * buf
Definition console.h:39
Definition io.h:46
unsigned int u32
Definition types.h:21
unsigned char u8
Definition types.h:19