move framebuffer_info struct into include/kernel-public

This commit is contained in:
Benji Dial 2025-12-27 20:53:45 -05:00
parent 645cc90b4d
commit 2eafff563e
5 changed files with 41 additions and 23 deletions

View file

@ -17,15 +17,8 @@
#pragma once
#include <stdint.h>
#include <kernel-public/framebuffer.h>
[[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);

View file

@ -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 <https://www.gnu.org/licenses/>.
*/
#pragma once
#include <stdint.h>
struct framebuffer_info {
uint8_t *fb_base;
int fb_width;
int fb_height;
int fb_pitch;
};

View file

@ -15,7 +15,7 @@
* with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "kernel-public/syscall-numbers.h"
#include <kernel-public/syscall-numbers.h>
#include "framebuffer.h"
#include "interrupts.h"
#include "scheduler.h"

View file

@ -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;

View file

@ -17,6 +17,7 @@
#pragma once
#include <kernel-public/framebuffer.h>
#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);