LumaOS  v0.1.116
An experimental x86-64 OS
Loading...
Searching...
No Matches
console.h
Go to the documentation of this file.
1
9#ifndef KERNEL_DRIVERS_CONSOLE_H
10#define KERNEL_DRIVERS_CONSOLE_H
11
12#include <limine/limine.h>
13#include <stddef.h>
14#include <stdbool.h>
15#include <lib/kstring.h>
16#include <lib/color.h>
17
18#define FONT_PSF1 0
19#define FONT_PSF2 1
20
22struct psf1_header {
23 uint8_t magic[2];
24 uint8_t mode;
25 uint8_t charsize;
26};
27
29struct psf2_header {
30 uint32_t magic;
31 uint32_t version;
32 uint32_t headersize;
33 uint32_t flags;
34 uint32_t length;
35 uint32_t charsize;
36 uint32_t height;
37 uint32_t width;
38};
39
41struct console {
43 struct rgb bg_color;
44
46 struct rgb fg_color;
47
48
51
54
55
57 uint8_t cols, rows;
58
60 uint8_t cursor_row, cursor_col;
61
64
67
70};
71
72extern uint8_t _binary_font_psf_start[];
73extern uint8_t _binary_font_psf_end[];
74
79bool get_console_status(void);
80
84void console_init(void);
85
89void console_clear(void);
90
97void draw_char(char c, uint8_t col, uint8_t row);
98
103void console_putc(char c);
104
110void console_puts(char* str);
111
115void scroll_up(void);
116
122void console_print_int(uint64_t value);
123
128void set_bg_color (struct rgb color);
129
134void set_fg_color (struct rgb color);
135
140struct rgb get_default_bg_color (void);
141
146struct rgb get_default_fg_color (void);
147
152struct rgb get_bg_color (void);
153
158struct rgb get_fg_color (void);
159
166void fill32(uint32_t *dest, uint32_t value, size_t count);
167
168#endif
Color utilities.
struct rgb get_default_bg_color(void)
Gets the default bg colour.
Definition console.c:108
struct rgb get_fg_color(void)
Gets the current fg colour.
Definition console.c:106
struct rgb get_bg_color(void)
Gets the current bg colour.
Definition console.c:105
struct rgb get_default_fg_color(void)
Gets the default fg colour.
Definition console.c:109
void fill32(uint32_t *dest, uint32_t value, size_t count)
Fills 32 bytes count times starting at dest with value.
Definition console.c:172
void set_bg_color(struct rgb color)
Sets the background colour.
Definition console.c:102
void console_putc(char c)
Arranges the cursor and prints characters.
Definition console.c:178
void draw_char(char c, uint8_t col, uint8_t row)
Draws a character to the console.
Definition console.c:111
void scroll_up(void)
Scrolls the whole console up.
Definition console.c:28
bool get_console_status(void)
Returns the status of the console (initialized or uninitialized).
Definition console.c:23
void console_puts(char *str)
Prints a non-formatted string.
Definition console.c:219
void console_clear(void)
Clears the console (fills with bg color).
Definition console.c:235
void set_fg_color(struct rgb color)
Sets the foreground colour.
Definition console.c:103
void console_print_int(uint64_t value)
Prints an int to the console.
Definition console.c:246
void console_init(void)
Initializes the console struct and fills all the properties.
Definition console.c:68
Utilities for memory and string operations.
Console structure, holds all the information about the console.
Definition console.h:41
struct psf1_header font_psf1_info
PSF1 Header (set if used).
Definition console.h:66
struct rgb bg_color
Current Background color.
Definition console.h:43
struct limine_framebuffer * fb
Framebuffer address.
Definition console.h:63
struct psf2_header font_psf2_info
PSF2 Header (set if used).
Definition console.h:69
struct rgb original_bg_color
The original background color.
Definition console.h:50
struct rgb original_fg_color
The original foreground color.
Definition console.h:53
struct rgb fg_color
Current Foreground color.
Definition console.h:46
uint8_t cols
Console glyph size.
Definition console.h:57
uint8_t cursor_row
Current cursor position.
Definition console.h:60
The PSF1 font header structure.
Definition console.h:22
The PSF2 font header structure.
Definition console.h:29
RGB color values.
Definition color.h:15