From 2eafff563e173f67145622e48cb193a5eef2358b Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Sat, 27 Dec 2025 20:53:45 -0500 Subject: [PATCH] move framebuffer_info struct into include/kernel-public --- include/calcite/calcite.h | 9 +-------- include/kernel-public/framebuffer.h | 27 +++++++++++++++++++++++++++ src/kernel/entry.c | 2 +- src/kernel/process.c | 16 ++++++++++------ src/kernel/process.h | 10 ++-------- 5 files changed, 41 insertions(+), 23 deletions(-) create mode 100644 include/kernel-public/framebuffer.h diff --git a/include/calcite/calcite.h b/include/calcite/calcite.h index 7f9b4d7..60f4597 100644 --- a/include/calcite/calcite.h +++ b/include/calcite/calcite.h @@ -17,15 +17,8 @@ #pragma once -#include +#include [[noreturn]] void end_thread(); -struct framebuffer_info { - uint8_t *fb_base; - int fb_width; - int fb_height; - int fb_pitch; -}; - void map_framebuffer(struct framebuffer_info *info_out); diff --git a/include/kernel-public/framebuffer.h b/include/kernel-public/framebuffer.h new file mode 100644 index 0000000..6ee1267 --- /dev/null +++ b/include/kernel-public/framebuffer.h @@ -0,0 +1,27 @@ +/* Calcite, include/kernel-public/framebuffer.h + * Copyright 2025 Benji Dial + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#pragma once + +#include + +struct framebuffer_info { + uint8_t *fb_base; + int fb_width; + int fb_height; + int fb_pitch; +}; diff --git a/src/kernel/entry.c b/src/kernel/entry.c index 49506a8..d921382 100644 --- a/src/kernel/entry.c +++ b/src/kernel/entry.c @@ -15,7 +15,7 @@ * with this program. If not, see . */ -#include "kernel-public/syscall-numbers.h" +#include #include "framebuffer.h" #include "interrupts.h" #include "scheduler.h" diff --git a/src/kernel/process.c b/src/kernel/process.c index 925c112..25d8178 100644 --- a/src/kernel/process.c +++ b/src/kernel/process.c @@ -16,25 +16,29 @@ */ #include "framebuffer.h" -#include "fs.h" #include "scheduler.h" #include "process.h" #include "utility.h" #include "paging.h" #include "panic.h" #include "heap.h" +#include "fs.h" void create_process(struct process *process_out) { process_out->p4_physical_base = take_free_physical_page(); process_out->p4_virtual_base = find_free_kernel_region(4096); map_in_kernel_page_table( - process_out->p4_physical_base, process_out->p4_virtual_base, 1, 0); + process_out->p4_physical_base, + process_out->p4_virtual_base, + 1, 0); process_out->p3_physical_base = take_free_physical_page(); process_out->p3_virtual_base = find_free_kernel_region(4096); map_in_kernel_page_table( - process_out->p3_physical_base, process_out->p3_virtual_base, 1, 0); + process_out->p3_physical_base, + process_out->p3_virtual_base, + 1, 0); process_out->p4_virtual_base[0] = process_out->p3_physical_base | 0x7; process_out->p4_virtual_base[511] = kernel_p3_physical_address | 0x3; @@ -359,11 +363,11 @@ struct thread *running_thread = 0; } -void syscall_map_framebuffer(struct syscall_framebuffer_info *info_out) { +void syscall_map_framebuffer(struct framebuffer_info *info_out) { if (!is_mapped_writable( - running_thread->process, info_out, - sizeof(struct syscall_framebuffer_info))) + running_thread->process, + info_out, sizeof(struct framebuffer_info))) panic("bad syscall"); uint64_t pages_needed = (fb_pitch * fb_height - 1) / 4096 + 1; diff --git a/src/kernel/process.h b/src/kernel/process.h index e10bf0a..2e93612 100644 --- a/src/kernel/process.h +++ b/src/kernel/process.h @@ -17,6 +17,7 @@ #pragma once +#include #include "fs.h" struct process { @@ -76,11 +77,4 @@ int is_mapped_writable(struct process *process, void *start, uint64_t length); [[noreturn]] void syscall_end_thread(); -struct syscall_framebuffer_info { - uint8_t *fb_base; - int fb_width; - int fb_height; - int fb_pitch; -}; - -void syscall_map_framebuffer(struct syscall_framebuffer_info *info_out); +void syscall_map_framebuffer(struct framebuffer_info *info_out);