move framebuffer_info struct into include/kernel-public
This commit is contained in:
parent
645cc90b4d
commit
2eafff563e
5 changed files with 41 additions and 23 deletions
|
|
@ -17,15 +17,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <kernel-public/framebuffer.h>
|
||||||
|
|
||||||
[[noreturn]] void end_thread();
|
[[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);
|
void map_framebuffer(struct framebuffer_info *info_out);
|
||||||
|
|
|
||||||
27
include/kernel-public/framebuffer.h
Normal file
27
include/kernel-public/framebuffer.h
Normal 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;
|
||||||
|
};
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
* with this program. If not, see <https://www.gnu.org/licenses/>.
|
* 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 "framebuffer.h"
|
||||||
#include "interrupts.h"
|
#include "interrupts.h"
|
||||||
#include "scheduler.h"
|
#include "scheduler.h"
|
||||||
|
|
|
||||||
|
|
@ -16,25 +16,29 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "framebuffer.h"
|
#include "framebuffer.h"
|
||||||
#include "fs.h"
|
|
||||||
#include "scheduler.h"
|
#include "scheduler.h"
|
||||||
#include "process.h"
|
#include "process.h"
|
||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
#include "paging.h"
|
#include "paging.h"
|
||||||
#include "panic.h"
|
#include "panic.h"
|
||||||
#include "heap.h"
|
#include "heap.h"
|
||||||
|
#include "fs.h"
|
||||||
|
|
||||||
void create_process(struct process *process_out) {
|
void create_process(struct process *process_out) {
|
||||||
|
|
||||||
process_out->p4_physical_base = take_free_physical_page();
|
process_out->p4_physical_base = take_free_physical_page();
|
||||||
process_out->p4_virtual_base = find_free_kernel_region(4096);
|
process_out->p4_virtual_base = find_free_kernel_region(4096);
|
||||||
map_in_kernel_page_table(
|
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_physical_base = take_free_physical_page();
|
||||||
process_out->p3_virtual_base = find_free_kernel_region(4096);
|
process_out->p3_virtual_base = find_free_kernel_region(4096);
|
||||||
map_in_kernel_page_table(
|
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[0] = process_out->p3_physical_base | 0x7;
|
||||||
process_out->p4_virtual_base[511] = kernel_p3_physical_address | 0x3;
|
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(
|
if (!is_mapped_writable(
|
||||||
running_thread->process, info_out,
|
running_thread->process,
|
||||||
sizeof(struct syscall_framebuffer_info)))
|
info_out, sizeof(struct framebuffer_info)))
|
||||||
panic("bad syscall");
|
panic("bad syscall");
|
||||||
|
|
||||||
uint64_t pages_needed = (fb_pitch * fb_height - 1) / 4096 + 1;
|
uint64_t pages_needed = (fb_pitch * fb_height - 1) / 4096 + 1;
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <kernel-public/framebuffer.h>
|
||||||
#include "fs.h"
|
#include "fs.h"
|
||||||
|
|
||||||
struct process {
|
struct process {
|
||||||
|
|
@ -76,11 +77,4 @@ int is_mapped_writable(struct process *process, void *start, uint64_t length);
|
||||||
|
|
||||||
[[noreturn]] void syscall_end_thread();
|
[[noreturn]] void syscall_end_thread();
|
||||||
|
|
||||||
struct syscall_framebuffer_info {
|
void syscall_map_framebuffer(struct framebuffer_info *info_out);
|
||||||
uint8_t *fb_base;
|
|
||||||
int fb_width;
|
|
||||||
int fb_height;
|
|
||||||
int fb_pitch;
|
|
||||||
};
|
|
||||||
|
|
||||||
void syscall_map_framebuffer(struct syscall_framebuffer_info *info_out);
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue