PatchworkOS  966e257
A non-POSIX operating system.
Loading...
Searching...
No Matches
log_screen.h
Go to the documentation of this file.
1#pragma once
2
3#include <kernel/config.h>
4#include <kernel/log/glyphs.h>
5#include <kernel/utils/ring.h>
6
7#include <boot/boot_info.h>
8
9#include <stdint.h>
10
11/**
12 * @brief Screen logging
13 * @defgroup kernel_log_screen Screen
14 * @ingroup kernel_log
15 *
16 * @{
17 */
18
19/**
20 * @brief Number of spaces to indent when a line wraps.
21 *
22 * Header length (15) + 2 for indentation
23 */
24#define SCREEN_WRAP_INDENT 17
25
26/**
27 * @brief Maximum number of characters in a single line.
28 */
29#define SCREEN_LINE_MAX_LENGTH (130)
30
31/**
32 * @brief The stride of a screen line in pixels.
33 */
34#define SCREEN_LINE_STRIDE (SCREEN_LINE_MAX_LENGTH * GLYPH_WIDTH)
35
36/**
37 * @brief Represents a position on the screen in character coordinates.
38 */
39typedef struct
40{
44
45/**
46 * @brief A single line in the screen buffer.
47 */
48typedef struct
49{
50 uint64_t length; ///< The distance from the start of the line to the end of the furthest away char, in chars.
51 uint32_t pixels[GLYPH_HEIGHT * SCREEN_LINE_STRIDE]; ///< The pixel data for the line.
53
54/**
55 * @brief The screen buffer.
56 */
57typedef struct
58{
59 uint64_t width; ///< The width of the buffer in chars.
60 uint64_t height; ///< The height of the buffer in chars.
61 uint64_t firstLineIndex; ///< The index of the first line in the buffer.
63 invalidStart; ///< The start of the invalid region in the buffer, forms a rectangle with invalidEnd.
64 log_screen_pos_t invalidEnd; ///< The end of the invalid region in the buffer, forms a rectangle with invalidStart.
65 log_screen_line_t lines[CONFIG_SCREEN_MAX_LINES]; ///< The lines in the buffer, acts as a circular buffer.
67
68/**
69 * @brief Initialize the screen logging.
70 *
71 * @param bootGop Pointer to the bootloader-provided GOP information for screen logging.
72 */
73void log_screen_init(const boot_gop_t* bootGop);
74
75/**
76 * @brief Clear the screen.
77 */
78void log_screen_clear(void);
79
80/**
81 * @brief Get screen width in characters.
82 */
84
85/**
86 * @brief Get screen height in characters.
87 */
89
90/**
91 * @brief Write a string to the screen.
92 *
93 * @param screen The screen state.
94 * @param string The string to write.
95 * @param length The length of the string.
96 */
97void log_screen_write(const char* string, uint64_t length);
98
99/** @} */
#define GLYPH_HEIGHT
Definition glyphs.h:7
void log_screen_write(const char *string, uint64_t length)
Write a string to the screen.
Definition log_screen.c:204
uint64_t log_screen_get_width(void)
Get screen width in characters.
Definition log_screen.c:194
void log_screen_init(const boot_gop_t *bootGop)
Initialize the screen logging.
Definition log_screen.c:83
void log_screen_clear(void)
Clear the screen.
Definition log_screen.c:172
uint64_t log_screen_get_height(void)
Get screen height in characters.
Definition log_screen.c:199
#define SCREEN_LINE_STRIDE
The stride of a screen line in pixels.
Definition log_screen.h:34
#define CONFIG_SCREEN_MAX_LINES
Maximum screen lines configuration.
Definition config.h:130
__UINT32_TYPE__ uint32_t
Definition stdint.h:15
__UINT64_TYPE__ uint64_t
Definition stdint.h:17
A single line in the screen buffer.
Definition log_screen.h:49
uint64_t length
The distance from the start of the line to the end of the furthest away char, in chars.
Definition log_screen.h:50
Represents a position on the screen in character coordinates.
Definition log_screen.h:40
The screen buffer.
Definition log_screen.h:58
log_screen_pos_t invalidStart
The start of the invalid region in the buffer, forms a rectangle with invalidEnd.
Definition log_screen.h:63
log_screen_pos_t invalidEnd
The end of the invalid region in the buffer, forms a rectangle with invalidStart.
Definition log_screen.h:64
uint64_t height
The height of the buffer in chars.
Definition log_screen.h:60
uint64_t width
The width of the buffer in chars.
Definition log_screen.h:59
uint64_t firstLineIndex
The index of the first line in the buffer.
Definition log_screen.h:61