This commit is contained in:
2026-09-14 02:50:35 +02:00
parent cf3f1f9e99
commit 9e5ed517bc
45 changed files with 210 additions and 212 deletions
+2 -12
View File
@@ -1,7 +1,7 @@
#pragma once
#include <zinnia/status.h>
#include <bits/mem.h>
#include <kernel/types.h>
#include <stddef.h>
enum alloc_flags {
@@ -44,14 +44,4 @@ void slab_init();
void mem_phys_bootstrap(struct phys_mem* mem);
void mem_phys_init(struct phys_mem* map, size_t length);
uintptr_t arch_mem_hhdm_addr();
uintptr_t arch_vm_pfndb_addr();
uintptr_t arch_mem_mapping_addr();
size_t arch_mem_page_bits();
size_t arch_mem_page_size();
size_t arch_mem_level_bits();
size_t arch_mem_num_levels();
static inline size_t mem_high_shift() {
return arch_mem_level_bits() * arch_mem_num_levels() + arch_mem_page_bits();
}
size_t mem_high_shift();
+32
View File
@@ -0,0 +1,32 @@
#pragma once
#include <stddef.h>
#include <stdint.h>
void arch_start();
void arch_panic();
size_t arch_mem_page_size();
size_t arch_mem_page_bits();
size_t arch_mem_level_bits();
size_t arch_mem_num_levels();
uintptr_t arch_mem_hhdm_addr();
uintptr_t arch_mem_pfndb_addr();
uintptr_t arch_mem_mapping_addr();
#include <kernel/usercopy.h>
bool arch_usercopy_read(void* dst, const __user void* src, size_t len, struct usercopy_region** region);
bool arch_usercopy_write(__user void* dst, const void* src, size_t len, struct usercopy_region** region);
#include <kernel/irq.h>
void arch_irq_set_state(bool state);
bool arch_irq_get_state();
void arch_irq_wait();
#include <kernel/percpu.h>
struct percpu* arch_percpu_get();
void arch_percpu_bsp_init();
void arch_percpu_init();
-7
View File
@@ -1,7 +0,0 @@
#pragma once
#include <kernel/usercopy.h>
bool arch_usercopy_read(void* dst, const __user void* src, size_t len, struct usercopy_region** region);
bool arch_usercopy_write(__user void* dst, const void* src, size_t len, struct usercopy_region** region);
bool arch_usercopy_strlen(const __user char* str, size_t max, size_t* len, struct usercopy_region** region);
-5
View File
@@ -2,7 +2,6 @@
#include <common/compiler.h>
#include <kernel/list.h>
#include <bits/irq.h>
#include <stdint.h>
enum irq_status : uint8_t {
@@ -45,7 +44,3 @@ struct irq_percpu {
void irq_lock();
void irq_unlock();
bool irq_set_interrupted(bool is_interrupted);
void arch_irq_set_state(bool state);
bool arch_irq_get_state();
void arch_irq_wait();
+31 -4
View File
@@ -1,7 +1,34 @@
#pragma once
#include <stdint.h>
#include <kernel/types.h>
#include <stddef.h>
static inline uint8_t mmio_read8(void* ptr) {
return *((volatile uint8_t*)ptr);
}
void* mmio_new(phys_t addr, size_t length);
void mmio_free(void* ptr, size_t length);
static inline uint16_t mmio_read16(void* ptr) {
return *((volatile uint16_t*)ptr);
}
static inline uint32_t mmio_read32(void* ptr) {
return *((volatile uint32_t*)ptr);
}
static inline uint64_t mmio_read64(void* ptr) {
return *((volatile uint64_t*)ptr);
}
static inline void mmio_write8(void* ptr, uint8_t value) {
*((volatile uint8_t*)ptr) = value;
}
static inline void mmio_write16(void* ptr, uint16_t value) {
*((volatile uint16_t*)ptr) = value;
}
static inline void mmio_write32(void* ptr, uint32_t value) {
*((volatile uint32_t*)ptr) = value;
}
static inline void mmio_write64(void* ptr, uint64_t value) {
*((volatile uint64_t*)ptr) = value;
}
+3 -9
View File
@@ -28,16 +28,10 @@ extern struct percpu percpu_bsp;
struct percpu* percpu_new();
// Gets the per-CPU data on the current CPU.
static inline struct percpu* percpu_get() {
return arch_percpu_get();
}
struct percpu* percpu_get();
// Initializes the bootstrap processor.
static inline void percpu_bsp_init() {
arch_percpu_bsp_init();
}
void percpu_bsp_init();
// Initializes all processors.
static inline void percpu_init() {
arch_percpu_init();
}
void percpu_init();
+4 -6
View File
@@ -11,9 +11,6 @@
#include <stddef.h>
#include <stdint.h>
ASSERT_TYPE(struct arch_context);
ASSERT_TYPE(struct arch_task_context);
enum task_state {
TASK_STATE_RUNNING, // Task is active and running.
TASK_STATE_READY, // Task is active, but not currently scheduled.
@@ -26,19 +23,20 @@ enum task_state {
// A task is the smallest unit of the scheduler.
struct task {
tailq_link(struct task) next;
size_t id;
char name[TASK_NAME_MAX];
struct vas* space;
struct namespace* namespace;
enum task_state state;
struct arch_task_context context;
struct arch_task_context task_ctx;
struct arch_context ctx;
struct usercopy_region* usercopy_region;
uintptr_t kernel_stack;
uintptr_t user_stack;
size_t time_slice;
int8_t priority;
tailq_link(struct task) next;
};
// Per-CPU data for scheduling.
-4
View File
@@ -1,7 +1,6 @@
#pragma once
#include <common/compiler.h>
#include <kernel/percpu.h>
#include <stddef.h>
struct usercopy_region {
@@ -15,6 +14,3 @@ bool usercopy_read(void* dst, const __user void* src, size_t len);
// Copies a block of data from kernel to user memory.
bool usercopy_write(__user void* dst, const void* src, size_t len);
// Performs a strlen() on a user string.
bool usercopy_strlen(const __user char* str, size_t max, size_t* len);
-1
View File
@@ -8,7 +8,6 @@
// Virtual address space.
struct vas {
// Architecture-specific virtual memory map implementation.
struct pmap pmap;
};
+1 -3
View File
@@ -21,9 +21,7 @@ struct vdso_kernel_data {
#include <kernel/syscall_stubs.h>
// Export a function under the current API version.
#define VDSO_SYMBOL(fn) asm(".symver " #fn ",__vdso_" #fn "@@ZINNIA_0")
// Export a function as a symbol for an older API version.
#define VDSO_SYMBOL_LEGACY(fn, symbol, ver) asm(".symver " #fn ",__vdso_" #symbol "@ZINNIA_" ver)
#define VDSO_SYMBOL(fn) asm(".symver " #fn ",__vdso_" #fn "@@ZINNIA_0")
extern const volatile struct vdso_kernel_data vdso_data;
+2 -2
View File
@@ -21,8 +21,8 @@ struct page {
static_assert(0x1000 % sizeof(struct page) == 0, "struct must fit cleanly inside a page!");
static_assert(sizeof(struct page) <= 64, "struct must be smaller than 64 bytes!");
void* vm_alloc(size_t length);
void vm_free(void* addr, size_t length);
uintptr_t vm_alloc(size_t length);
void vm_free(uintptr_t addr, size_t length);
// Base address of the `struct page` array.
extern struct page* vm_pfndb;