Compare commits

...

3 Commits

Author SHA1 Message Date
marv7000 7826310f96 oops 2026-10-13 23:08:00 +02:00
marv7000 00b7cdb8d7 more uapi bits 2026-10-13 23:04:30 +02:00
marv7000 56d43a94a9 remove newlines in assert 2026-10-13 23:01:41 +02:00
15 changed files with 317 additions and 18 deletions
+1 -1
View File
@@ -49,7 +49,7 @@ void lapic_init(struct local_apic* lapic) {
uintptr_t vaddr = vm_alloc(0x1000);
pmap_map(&kernel_vma.pmap, vaddr, apic_msr & 0xFFFF'F000, PTE_READ | PTE_WRITE, CACHE_MMIO);
lapic->xapic_regs = (void*)vaddr;
assert(lapic->xapic_regs, "Failed to allocate virtual memory!\n");
assert(lapic->xapic_regs, "Failed to allocate virtual memory!");
}
asm_wrmsr(0x1B, apic_msr);
+1 -1
View File
@@ -74,7 +74,7 @@ static void hpet_init(struct boot_info*) {
uint64_t caps = mmio_read64(hpet_clock.regs + HPET_CAP);
hpet_clock.period = (caps >> 32) & 0xFFFF'FFFF;
assert(clock_switch(&hpet_clock.clock), "Unable to switch to HPET!\n");
assert(clock_switch(&hpet_clock.clock), "Unable to switch to HPET!");
}
INIT_TASK(hpet_stage, "arch.x86_64.hpet", hpet_init);
INIT_DEPENDS(hpet_stage, acpi_stage);
+2 -2
View File
@@ -96,9 +96,9 @@ void interrupt_handler(struct arch_context* ctx) {
default:
if (isr < 0x20)
panic("Unhandled exception %lu at %#lx, error: %#lx\n", isr, ctx->rip, ctx->error);
assert(isr - 0x20 < ARRAY_SIZE(arch_cpu->irq_lines), "Unhandled interrupt on ISR %lu\n", isr);
assert(isr - 0x20 < ARRAY_SIZE(arch_cpu->irq_lines), "Unhandled interrupt on ISR %lu", isr);
struct irq_line* line = arch_cpu->irq_lines[isr - 0x20];
assert(line, "Unhandled interrupt on ISR %lu\n", isr);
assert(line, "Unhandled interrupt on ISR %lu", isr);
irq_line_raise(line);
}
}
+1 -1
View File
@@ -84,7 +84,7 @@ void x86_64_cpu_setup(struct percpu* cpu) {
// Enable SSE.
cr0 &= ~CR0_EM;
cr0 |= CR0_MP;
cr0 |= CR0_MP | CR0_WP;
cr4 |= CR4_OSFXSR | CR4_OSXMMEXCPT;
if (cpuid1.ecx & CPUID_1C_XSAVE) {
+1 -1
View File
@@ -114,7 +114,7 @@ errno_t arch_task_init(
) {
struct arch_percpu* cpu = percpu_ref(arch_data);
assert((stack_start & 0xF) == 0, "Task stack is not 16-byte aligned!\n");
assert((stack_start & 0xF) == 0, "Task stack is not 16-byte aligned!");
// Prepare a dummy stack with an entry point function to return to.
struct task_frame* frame = (struct task_frame*)(stack_start - sizeof(uint64_t)) - 1;
+1 -1
View File
@@ -275,7 +275,7 @@ static errno_t build_temp_table(phys_t* out) {
void x86_64_smp_init() {
const size_t trampoline_size = smp_trampoline_end - smp_trampoline_start;
assert(trampoline_size <= arch_mem_page_size(), "SMP trampoline doesn't fit in a page\n");
assert(trampoline_size <= arch_mem_page_size(), "SMP trampoline doesn't fit in a page");
const size_t max_cpus = percpu_max_cpus();
if (max_cpus <= 1)
+6 -6
View File
@@ -66,7 +66,7 @@ void mem_init(struct phys_mem* map, size_t map_len, uintptr_t kernel_virt, phys_
// since we're likely going to map it at a different base address.
mem_hhdm_base = tmp_hhdm;
assert(pmap_new_kernel(&kernel_vma.pmap, 0) == 0, "Unable to allocate the kernel page table\n");
assert(pmap_new_kernel(&kernel_vma.pmap, 0) == 0, "Unable to allocate the kernel page table");
tailq_init(&kernel_vma.mappings);
// text
@@ -79,7 +79,7 @@ void mem_init(struct phys_mem* map, size_t map_len, uintptr_t kernel_virt, phys_
PTE_READ | PTE_EXEC,
CACHE_ANY
);
assert(!status, "Failed to map %p with error %i\n", p, status);
assert(!status, "Failed to map %p with error %i", p, status);
}
// rodata
@@ -92,7 +92,7 @@ void mem_init(struct phys_mem* map, size_t map_len, uintptr_t kernel_virt, phys_
PTE_READ,
CACHE_ANY
);
assert(!status, "Failed to map %p with error %i\n", p, status);
assert(!status, "Failed to map %p with error %i", p, status);
}
// data
@@ -105,7 +105,7 @@ void mem_init(struct phys_mem* map, size_t map_len, uintptr_t kernel_virt, phys_
PTE_READ | PTE_WRITE,
CACHE_ANY
);
assert(!status, "Failed to map %p with error %i\n", p, status);
assert(!status, "Failed to map %p with error %i", p, status);
}
// The kernel address space is divided into 4 segments.
@@ -124,7 +124,7 @@ void mem_init(struct phys_mem* map, size_t map_len, uintptr_t kernel_virt, phys_
uintptr_t vaddr = (uintptr_t)(map[i].address + p + tmp_hhdm);
phys_t paddr = (phys_t)(map[i].address + p);
errno_t status = pmap_map(&kernel_vma.pmap, vaddr, paddr, PTE_READ | PTE_WRITE, CACHE_ANY);
assert(!status, "Failed to map HHDM page %p to %p with error %i\n", (void*)vaddr, (void*)paddr, status);
assert(!status, "Failed to map HHDM page %p to %p with error %i", (void*)vaddr, (void*)paddr, status);
}
}
mem_hhdm_base = tmp_hhdm;
@@ -152,7 +152,7 @@ void mem_init(struct phys_mem* map, size_t map_len, uintptr_t kernel_virt, phys_
for (size_t page = 0; page < length; page += pgsz) {
phys_t paddr;
assert(!mem_phys_alloc(1, 0, &paddr), "Failed to allocate memory for PFNDB!\n");
assert(!mem_phys_alloc(1, 0, &paddr), "Failed to allocate memory for PFNDB!");
assert(
!pmap_map(&kernel_vma.pmap, vaddr + page, paddr, PTE_READ | PTE_WRITE, CACHE_ANY),
"Failed to map PFNDB memory"
+1 -1
View File
@@ -112,7 +112,7 @@ bool vma_page_fault(struct vma* v, const struct vma_fault_info* info) {
if (still_valid) {
errno_t status =
pmap_map(&v->pmap, faulty_page * page_size, vm_page_addr(page), prot_to_pte(v, prot), CACHE_ANY);
assert(status == 0, "Failed to map a demand-loaded page\n");
assert(status == 0, "Failed to map a demand-loaded page");
}
spin_unlock(&v->lock);
+3 -3
View File
@@ -37,11 +37,11 @@ void sched_to_user_context(uintptr_t ctx) {
void sched_init(struct scheduler* sched) {
struct task* idle_task;
assert(task_create("idle", &kernel_vma, idle_func, 0, &idle_task) == 0, "Unable to create idle task!\n");
assert(task_create("idle", &kernel_vma, idle_func, 0, &idle_task) == 0, "Unable to create idle task!");
sched->idle_task = idle_task;
struct task* boot_task = mem_alloc(sizeof(struct task), 0);
assert(boot_task != nullptr, "Unable to create boot task!\n");
assert(boot_task != nullptr, "Unable to create boot task!");
strncpy(boot_task->name, "boot", sizeof(boot_task->name));
boot_task->space = &kernel_vma;
sched->current = boot_task;
@@ -52,7 +52,7 @@ void sched_init(struct scheduler* sched) {
}
void sched_add_task(struct scheduler* sched, struct task* task) {
assert(task != nullptr, "Tried to add NULL to the run queue\n");
assert(task != nullptr, "Tried to add NULL to the run queue");
task->state = TASK_STATE_READY;
tailq_insert_tail(&sched->run_queue, task, next);
}
+41 -1
View File
@@ -2,6 +2,46 @@
#ifndef __ZINNIA_UAPI_IOCTLS_H
#define __ZINNIA_UAPI_IOCTLS_H
#define __FIONBIO 0x5421
#define __IOC_VOID 0x00000000U
#define __IOC_OUT 0x40000000U
#define __IOC_IN 0x80000000U
#define __IOC_INOUT (__IOC_IN | __IOC_OUT)
#define __IOC(inout, group, num, len) ((inout) | (((len) & 0x3FFF) << 16) | ((group) << 8) | (num))
#define __IO(group, num) __IOC(__IOC_VOID, (group), (num), 0)
#define __IOR(group, num, type) __IOC(__IOC_OUT, (group), (num), sizeof(type))
#define __IOW(group, num, type) __IOC(__IOC_IN, (group), (num), sizeof(type))
#define __TCGETS 0x5401
#define __TCSETS 0x5402
#define __TCSETSW 0x5403
#define __TCSETSF 0x5404
#define __TCFLSH 0x540B
#define __TIOCSCTTY 0x540E
#define __TIOCGPGRP 0x540F
#define __TIOCSPGRP 0x5410
#define __TIOCGWINSZ 0x5413
#define __TIOCSWINSZ 0x5414
#define __FIONREAD 0x541B
#define __TIOCPKT 0x5420
#define __FIONBIO 0x5421
#define __TIOCNOTTY 0x5422
#define __TIOCGSID 0x5429
#define __TIOCSIG 0x5436
#define __TIOCGPKT 0x5438
#define __TIOCGNAME 0x5470
#define __TIOCGPTN __IOR('T', 0x30, int)
#define __TIOCSPTLCK __IOW('T', 0x31, int)
#define __TIOCGPTLCK 3
#define __BLKGETSIZE64 __IOR('B', 0x00, unsigned long long)
#define __BLKSSZGET __IOR('B', 0x01, unsigned int)
#define __BLKRRPART __IO('B', 0x02)
#define __TIOCPKT_DATA 0
#define __TIOCPKT_FLUSHREAD 1
#define __TIOCPKT_FLUSHWRITE 2
#define __TIOCPKT_STOP 4
#define __TIOCPKT_START 8
#endif
+1
View File
@@ -5,5 +5,6 @@
#define __PATH_MAX 4096
#define __NAME_MAX 255
#define __SYMLINK_MAX 4096
#define __PIPE_BUF 4096
#endif
+30
View File
@@ -0,0 +1,30 @@
/* SPDX-License-Identifier: Unlicense */
#ifndef __ZINNIA_UAPI_RESOURCE_H
#define __ZINNIA_UAPI_RESOURCE_H
#include <uapi/types.h>
#define __PRIO_PROCESS 0
#define __PRIO_PGRP 1
#define __PRIO_USER 2
#define __RLIMIT_CPU 0
#define __RLIMIT_FSIZE 1
#define __RLIMIT_DATA 2
#define __RLIMIT_STACK 3
#define __RLIMIT_CORE 4
#define __RLIMIT_RSS 5
#define __RLIMIT_NPROC 6
#define __RLIMIT_NOFILE 7
#define __RLIMIT_MEMLOCK 8
#define __RLIMIT_AS 9
#define __RLIMIT_NLIMITS 16
#define __RLIM_INFINITY ((__rlim_t) - 1)
struct __rlimit {
__rlim_t rlim_cur;
__rlim_t rlim_max;
};
#endif
+128
View File
@@ -0,0 +1,128 @@
/* SPDX-License-Identifier: Unlicense */
#ifndef __ZINNIA_UAPI_SIGNAL_H
#define __ZINNIA_UAPI_SIGNAL_H
#include <stddef.h>
#include <uapi/types.h>
#define __SIGABRT 1
#define __SIGALRM 2
#define __SIGBUS 3
#define __SIGCHLD 4
#define __SIGCONT 5
#define __SIGFPE 6
#define __SIGHUP 7
#define __SIGILL 8
#define __SIGINT 9
#define __SIGKILL 10
#define __SIGPIPE 11
#define __SIGQUIT 12
#define __SIGSEGV 13
#define __SIGSTOP 14
#define __SIGTERM 15
#define __SIGTSTP 16
#define __SIGTTIN 17
#define __SIGTTOU 18
#define __SIGUSR1 19
#define __SIGUSR2 20
#define __SIGWINCH 21
#define __SIGSYS 22
#define __SIGTRAP 23
#define __SIGURG 24
#define __SIGVTALRM 25
#define __SIGXCPU 26
#define __SIGXFSZ 27
#define __SIGIO 28
#define __SIGPOLL 29
#define __SIGPROF 30
#define __SIGPWR 31
#define __SIGIOT 32
#define __SIGCANCEL 33
#define __SIGRTMIN 35
#define __SIGRTMAX 64
#define __NSIG 65
#define __SIG_DFL 0
#define __SIG_IGN 1
#define __SIG_BLOCK 1
#define __SIG_UNBLOCK 2
#define __SIG_SETMASK 3
#define __SA_NOCLDSTOP (1 << 0)
#define __SA_ONSTACK (1 << 1)
#define __SA_RESETHAND (1 << 2)
#define __SA_RESTART (1 << 3)
#define __SA_SIGINFO (1 << 4)
#define __SA_NOCLDWAIT (1 << 5)
#define __SA_NODEFER (1 << 6)
#define __MINSIGSTKSZ 2048
#define __SS_ONSTACK 1
#define __SS_DISABLE 2
#define __SIGEV_NONE 1
#define __SIGEV_SIGNAL 2
#define __SIGEV_THREAD 3
#define __SI_TKILL (-6)
#define __SI_TIMER (-2)
#define __SI_QUEUE (-1)
#define __SI_USER 0
#define __SI_KERNEL 128
#define __ILL_ILLOPC 1
#define __FPE_INTDIV 1
#define __SEGV_MAPERR 1
#define __SEGV_ACCERR 2
#define __BUS_ADRALN 1
#define __TRAP_BRKPT 1
#define __CLD_EXITED 1
#define __CLD_KILLED 2
#define __CLD_DUMPED 3
#define __CLD_TRAPPED 4
#define __CLD_STOPPED 5
#define __CLD_CONTINUED 6
typedef uint64_t __sigset_t;
union __sigval {
int sival_int;
void* sival_ptr;
};
struct __siginfo {
int si_signo;
int si_code;
int si_errno;
__pid_t si_pid;
__uid_t si_uid;
void* si_addr;
int si_status;
union __sigval si_value;
};
struct __sigaction {
uintptr_t sa_handler;
unsigned long sa_flags;
uintptr_t sa_restorer;
__sigset_t sa_mask;
};
struct __stack {
void* ss_sp;
size_t ss_size;
int ss_flags;
};
struct __sigevent {
union __sigval sigev_value;
int sigev_notify;
int sigev_signo;
void (*sigev_notify_function)(union __sigval);
void* sigev_notify_attributes;
__pid_t sigev_notify_thread_id;
};
#endif
+96
View File
@@ -0,0 +1,96 @@
/* SPDX-License-Identifier: Unlicense */
#ifndef __ZINNIA_UAPI_TERMIOS_H
#define __ZINNIA_UAPI_TERMIOS_H
#include <uapi/types.h>
#define __NCCS 32
#define __VINTR 0
#define __VQUIT 1
#define __VERASE 2
#define __VKILL 3
#define __VEOF 4
#define __VTIME 5
#define __VMIN 6
#define __VSWTC 7
#define __VSTART 8
#define __VSTOP 9
#define __VSUSP 10
#define __VEOL 11
#define __VREPRINT 12
#define __VDISCARD 13
#define __VWERASE 14
#define __VLNEXT 15
#define __VEOL2 16
#define __IGNBRK 0000001
#define __BRKINT 0000002
#define __IGNPAR 0000004
#define __PARMRK 0000010
#define __INPCK 0000020
#define __ISTRIP 0000040
#define __INLCR 0000100
#define __IGNCR 0000200
#define __ICRNL 0000400
#define __IUCLC 0001000
#define __IXON 0002000
#define __IXANY 0004000
#define __IXOFF 0010000
#define __OPOST 0000001
#define __OLCUC 0000002
#define __ONLCR 0000004
#define __OCRNL 0000010
#define __ONOCR 0000020
#define __ONLRET 0000040
#define __CSIZE 0000060
#define __CS5 0000000
#define __CS6 0000020
#define __CS7 0000040
#define __CS8 0000060
#define __CSTOPB 0000100
#define __CREAD 0000200
#define __PARENB 0000400
#define __PARODD 0001000
#define __HUPCL 0002000
#define __CLOCAL 0004000
#define __ISIG 0000001
#define __ICANON 0000002
#define __ECHO 0000010
#define __ECHOE 0000020
#define __ECHOK 0000040
#define __ECHONL 0000100
#define __NOFLSH 0000200
#define __TOSTOP 0000400
#define __IEXTEN 0100000
#define __TCIFLUSH 0
#define __TCOFLUSH 1
#define __TCIOFLUSH 2
typedef unsigned char __cc_t;
typedef unsigned int __speed_t;
typedef unsigned int __tcflag_t;
struct __termios {
__tcflag_t c_iflag;
__tcflag_t c_oflag;
__tcflag_t c_cflag;
__tcflag_t c_lflag;
__cc_t c_line;
__cc_t c_cc[__NCCS];
__speed_t c_ibaud;
__speed_t c_obaud;
};
struct __winsize {
unsigned short ws_row;
unsigned short ws_col;
unsigned short ws_xpixel;
unsigned short ws_ypixel;
};
#endif
+4
View File
@@ -9,4 +9,8 @@
#define __WCONTINUED 8
#define __WNOWAIT 0x01000000
#define __P_ALL 0
#define __P_PID 1
#define __P_PGID 2
#endif