mirror of
https://github.com/JannisHeydemann/BoredOS.git
synced 2026-05-30 10:26:59 +00:00
FEAT: Verbose boot
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include "io.h"
|
||||
#include "font_manager.h"
|
||||
#include "../mem/memory_manager.h"
|
||||
#include "sys/spinlock.h"
|
||||
|
||||
static struct limine_framebuffer *g_fb = NULL;
|
||||
static uint32_t g_bg_color = 0xFF696969;
|
||||
@@ -25,6 +26,7 @@ static int g_bg_image_h = 0;
|
||||
static bool g_use_image = false;
|
||||
|
||||
static DirtyRect g_dirty = {0, 0, 0, 0, false};
|
||||
static spinlock_t graphics_lock = SPINLOCK_INIT;
|
||||
|
||||
|
||||
#define MAX_FB_WIDTH 2048
|
||||
@@ -163,15 +165,19 @@ void graphics_mark_dirty(int x, int y, int w, int h) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint64_t flags = spinlock_acquire_irqsave(&graphics_lock);
|
||||
merge_dirty_rect(x, y, w, h);
|
||||
spinlock_release_irqrestore(&graphics_lock, flags);
|
||||
}
|
||||
|
||||
void graphics_mark_screen_dirty(void) {
|
||||
uint64_t flags = spinlock_acquire_irqsave(&graphics_lock);
|
||||
g_dirty.x = 0;
|
||||
g_dirty.y = 0;
|
||||
g_dirty.w = get_screen_width();
|
||||
g_dirty.h = get_screen_height();
|
||||
g_dirty.active = true;
|
||||
spinlock_release_irqrestore(&graphics_lock, flags);
|
||||
}
|
||||
|
||||
DirtyRect graphics_get_dirty_rect(void) {
|
||||
@@ -179,11 +185,9 @@ DirtyRect graphics_get_dirty_rect(void) {
|
||||
}
|
||||
|
||||
void graphics_clear_dirty(void) {
|
||||
extern uint64_t wm_lock_acquire(void);
|
||||
extern void wm_lock_release(uint64_t);
|
||||
uint64_t rflags = wm_lock_acquire();
|
||||
uint64_t flags = spinlock_acquire_irqsave(&graphics_lock);
|
||||
g_dirty.active = false;
|
||||
wm_lock_release(rflags);
|
||||
spinlock_release_irqrestore(&graphics_lock, flags);
|
||||
}
|
||||
|
||||
void graphics_clear_dirty_no_lock(void) {
|
||||
@@ -796,12 +800,22 @@ void graphics_clear_back_buffer(uint32_t color) {
|
||||
}
|
||||
|
||||
void graphics_flip_buffer(void) {
|
||||
if (!g_fb || !g_dirty.active) return;
|
||||
if (!g_fb) return;
|
||||
|
||||
uint64_t flags = spinlock_acquire_irqsave(&graphics_lock);
|
||||
if (!g_dirty.active) {
|
||||
spinlock_release_irqrestore(&graphics_lock, flags);
|
||||
return;
|
||||
}
|
||||
|
||||
int x = g_dirty.x;
|
||||
int y = g_dirty.y;
|
||||
int w = g_dirty.w;
|
||||
int h = g_dirty.h;
|
||||
|
||||
// Clear dirty state
|
||||
g_dirty.active = false;
|
||||
spinlock_release_irqrestore(&graphics_lock, flags);
|
||||
|
||||
if (x < 0) { w += x; x = 0; }
|
||||
if (y < 0) { h += y; y = 0; }
|
||||
@@ -1021,3 +1035,26 @@ void graphics_blit_buffer(uint32_t *src, int dst_x, int dst_y, int w, int h) {
|
||||
}
|
||||
}
|
||||
}
|
||||
void graphics_scroll_back_buffer(int lines) {
|
||||
if (!g_fb || lines <= 0 || lines >= (int)g_fb->height) return;
|
||||
|
||||
extern uint64_t wm_lock_acquire(void);
|
||||
extern void wm_lock_release(uint64_t);
|
||||
uint64_t rflags = wm_lock_acquire();
|
||||
|
||||
int sw = (int)g_fb->width;
|
||||
int sh = (int)g_fb->height;
|
||||
|
||||
for (int y = 0; y < sh - lines; y++) {
|
||||
uint32_t *dst = &g_back_buffer[y * sw];
|
||||
uint32_t *src = &g_back_buffer[(y + lines) * sw];
|
||||
for (int x = 0; x < sw; x++) dst[x] = src[x];
|
||||
}
|
||||
|
||||
for (int y = sh - lines; y < sh; y++) {
|
||||
uint32_t *dst = &g_back_buffer[y * sw];
|
||||
for (int x = 0; x < sw; x++) dst[x] = 0;
|
||||
}
|
||||
|
||||
wm_lock_release(rflags);
|
||||
}
|
||||
|
||||
@@ -56,6 +56,7 @@ void graphics_clear_dirty_no_lock(void);
|
||||
// Double buffering
|
||||
void graphics_flip_buffer(void);
|
||||
void graphics_clear_back_buffer(uint32_t color);
|
||||
void graphics_scroll_back_buffer(int lines);
|
||||
|
||||
// Clipping
|
||||
void graphics_set_clipping(int x, int y, int w, int h);
|
||||
|
||||
@@ -107,7 +107,7 @@ void wallpaper_process_pending(void) {
|
||||
const char *path = (const char *)pending_wallpaper_path;
|
||||
pending_wallpaper_path = NULL;
|
||||
|
||||
serial_str("[WP] Processing wallpaper: ");
|
||||
serial_str("[WM] Processing wallpaper: ");
|
||||
serial_str(path);
|
||||
serial_str("\n");
|
||||
|
||||
|
||||
25
src/wm/wm.c
25
src/wm/wm.c
@@ -21,6 +21,7 @@
|
||||
#include "disk.h"
|
||||
#include "../sys/work_queue.h"
|
||||
#include "../sys/smp.h"
|
||||
#include "../core/kconsole.h"
|
||||
|
||||
|
||||
// Hello developer,
|
||||
@@ -44,6 +45,8 @@ void wm_lock_release(uint64_t flags) {
|
||||
}
|
||||
|
||||
extern void serial_write(const char *str);
|
||||
extern void log_ok(const char *msg);
|
||||
extern void log_fail(const char *msg);
|
||||
|
||||
static bool str_eq(const char *s1, const char *s2) {
|
||||
if (!s1 || !s2) return false;
|
||||
@@ -1919,7 +1922,7 @@ void wm_remove_window(Window *win) {
|
||||
force_redraw = true;
|
||||
} else {
|
||||
wm_lock_release(rflags);
|
||||
serial_write("WM: Window not found in all_windows list!\n");
|
||||
log_fail("Window not found in all_windows list!");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3096,25 +3099,33 @@ void wm_process_deferred_thumbs(void) {
|
||||
|
||||
void wm_init(void) {
|
||||
disk_manager_init();
|
||||
log_ok("Disk Manager ready");
|
||||
|
||||
disk_manager_scan();
|
||||
log_ok("Disk scanning complete");
|
||||
|
||||
cmd_init();
|
||||
log_ok("Command CLI ready");
|
||||
|
||||
explorer_init();
|
||||
log_ok("Explorer ready");
|
||||
|
||||
wallpaper_init();
|
||||
log_ok("Wallpaper engine ready");
|
||||
|
||||
file_index_init();
|
||||
log_ok("File Indexer ready");
|
||||
|
||||
// Try to load the file index from persistent cache
|
||||
// If it doesn't exist, queue an async build
|
||||
if (!file_index_load()) {
|
||||
// No cache exists - queue async build to background
|
||||
log_ok("No Index cache, background build started");
|
||||
work_queue_submit(build_file_index_async, NULL);
|
||||
} else {
|
||||
// Cache loaded - mark as ready
|
||||
log_ok("Index cache loaded");
|
||||
lumos_index_built = true;
|
||||
}
|
||||
|
||||
refresh_desktop_icons();
|
||||
log_ok("Desktop icons refreshed");
|
||||
|
||||
// Initialize z-indices
|
||||
win_cmd.z_index = 0;
|
||||
@@ -3131,6 +3142,10 @@ void wm_init(void) {
|
||||
win_cmd.visible = false;
|
||||
|
||||
force_redraw = true;
|
||||
|
||||
serial_write("[WM] Initialization complete, transitioning to GUI\n");
|
||||
kconsole_set_active(false);
|
||||
graphics_flip_buffer();
|
||||
}
|
||||
|
||||
uint32_t wm_get_ticks(void) {
|
||||
|
||||
Reference in New Issue
Block a user