Skip to content

Commit 2ef5606

Browse files
committed
feat: improve logging colors
thanks kevin :D
1 parent 61b9f09 commit 2ef5606

File tree

3 files changed

+112
-4
lines changed

3 files changed

+112
-4
lines changed

kernel/src/dev/term.c

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,33 @@
2525
static struct flanterm_context *ft_ctx;
2626
static spinlock_t term_lock;
2727

28+
static uint32_t ft_ansi_colours[8] = {
29+
0x00282828, /* black - dark0 (#282828) */
30+
0x00cc241d, /* red - neutral_red (#cc241d) */
31+
0x0098971a, /* green - neutral_green (#98971a) */
32+
0x00d79921, /* yellow - neutral_yellow (#d79921) */
33+
0x00458588, /* blue - neutral_blue (#458588) */
34+
0x00b16286, /* magenta - neutral_purple (#b16286) */
35+
0x00689d6a, /* cyan - neutral_aqua (#689d6a) */
36+
0x00a89984, /* white - light4 (#a89984) */
37+
};
38+
39+
static uint32_t ft_ansi_bright_colours[8] = {
40+
0x00928374, /* bright black - gray_245 (#928374) */
41+
0x00fb4934, /* bright red - bright_red (#fb4934) */
42+
0x00b8bb26, /* bright green - bright_green (#b8bb26) */
43+
0x00fabd2f, /* bright yellow- bright_yellow (#fabd2f) */
44+
0x0083a598, /* bright blue - bright_blue (#83a598) */
45+
0x00d3869b, /* bright magenta- bright_purple (#d3869b) */
46+
0x008ec07c, /* bright cyan - bright_aqua (#8ec07c) */
47+
0x00fbf1c7, /* bright white - light0 (#fbf1c7) */
48+
};
49+
50+
static uint32_t ft_default_bg = 0x00282828; /* dark0 (#282828) */
51+
static uint32_t ft_default_fg = 0x00ebdbb2; /* light1 (#ebdbb2) */
52+
static uint32_t ft_default_bg_bright = 0x003c3836; /* dark1 (#3c3836) */
53+
static uint32_t ft_default_fg_bright = 0x00fbf1c7; /* light0 (#fbf1c7) */
54+
2855
void term_init(volatile struct limine_framebuffer_request *framebuffer_request)
2956
{
3057
spinlock_init(&term_lock);
@@ -37,10 +64,11 @@ void term_init(volatile struct limine_framebuffer_request *framebuffer_request)
3764

3865
struct limine_framebuffer *fb = framebuffer_request->response->framebuffers[0];
3966

40-
ft_ctx = flanterm_fb_init(NULL, NULL, fb->address, fb->width, fb->height, fb->pitch,
41-
fb->red_mask_size, fb->red_mask_shift, fb->green_mask_size,
42-
fb->green_mask_shift, fb->blue_mask_size, fb->blue_mask_shift, NULL,
43-
NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 1, 0, 0, 0, 0);
67+
ft_ctx = flanterm_fb_init(
68+
NULL, NULL, fb->address, fb->width, fb->height, fb->pitch, fb->red_mask_size,
69+
fb->red_mask_shift, fb->green_mask_size, fb->green_mask_shift, fb->blue_mask_size,
70+
fb->blue_mask_shift, NULL, ft_ansi_colours, ft_ansi_bright_colours, &ft_default_bg,
71+
&ft_default_fg, &ft_default_bg_bright, &ft_default_fg_bright, NULL, 0, 0, 1, 0, 0, 0, 0);
4472
}
4573

4674
void term_write(const char *buf, size_t len)

kernel/src/hal/vfs.h

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Zeronix - A Minimal Kernel
3+
* Copyright (C) 2024-present Viktor Popp and contributors
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*/
18+
19+
#pragma once
20+
21+
typedef struct vfs vfs_t;
22+
23+
typedef enum
24+
{
25+
VNODE_NONE,
26+
VNODE_REG,
27+
VNODE_DIR,
28+
VNODE_BLOCK,
29+
VNODE_CHAR,
30+
VNODE_LINK,
31+
VNODE_SOCKET,
32+
VNODE_BAD,
33+
} vnode_type_t;
34+
35+
typedef struct
36+
{
37+
} vnode_ops_t;
38+
39+
typedef struct
40+
{
41+
} vfs_ops_t;
42+
43+
typedef struct
44+
{
45+
vnode_type_t type;
46+
void *data;
47+
vnode_ops_t *ops;
48+
49+
vfs_t *vfs_here;
50+
vfs_t *vfs_root;
51+
} vnode_t;
52+
53+
typedef struct vfs
54+
{
55+
struct vfs *next;
56+
vfs_ops_t *ops;
57+
vnode_t *root_node;
58+
void *data;
59+
} vfs_t;

kernel/src/kernel.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,26 @@ void kstart()
6262

6363
enable_interrupts();
6464

65+
kprintf("\n"
66+
"\t"
67+
"\x1b[40m \x1b[0m"
68+
"\x1b[41m \x1b[0m"
69+
"\x1b[42m \x1b[0m"
70+
"\x1b[43m \x1b[0m"
71+
"\x1b[44m \x1b[0m"
72+
"\x1b[45m \x1b[0m"
73+
"\x1b[46m \x1b[0m"
74+
"\x1b[47m \x1b[0m\n"
75+
"\t"
76+
"\x1b[100m \x1b[0m"
77+
"\x1b[101m \x1b[0m"
78+
"\x1b[102m \x1b[0m"
79+
"\x1b[103m \x1b[0m"
80+
"\x1b[104m \x1b[0m"
81+
"\x1b[105m \x1b[0m"
82+
"\x1b[106m \x1b[0m"
83+
"\x1b[107m \x1b[0m\n"
84+
"\n");
85+
6586
halt_loop();
6687
}

0 commit comments

Comments
 (0)