diff options
author | Ian Moffett <ian@osmora.org> | 2024-06-24 22:55:29 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2024-06-24 22:55:29 -0400 |
commit | 236963e7563be3e3f8220dac7bb4af446928e194 (patch) | |
tree | e521ea226db0345bbb3679fffe09d96254b7dc73 /sys/include | |
parent | 214eadc62b5578f76c98a38a28f8b3d80ac4d6ad (diff) |
Clean out for expt
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/include')
96 files changed, 0 insertions, 7532 deletions
diff --git a/sys/include/arch/amd64/bus.h b/sys/include/arch/amd64/bus.h deleted file mode 100644 index 53d1fe2..0000000 --- a/sys/include/arch/amd64/bus.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _AMD64_BUS_H_ -#define _AMD64_BUS_H_ - -#include <sys/types.h> - -typedef uint64_t bus_addr_t; - -int bus_map(bus_addr_t addr, size_t size, int flags, void **vap); - -#endif /* !_AMD64_BUS_H_ */ diff --git a/sys/include/arch/amd64/cpu.h b/sys/include/arch/amd64/cpu.h deleted file mode 100644 index 3febf5a..0000000 --- a/sys/include/arch/amd64/cpu.h +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _AMD64_CPU_H_ -#define _AMD64_CPU_H_ - -#include <sys/types.h> -#include <sys/cdefs.h> -#include <sys/spinlock.h> -#include <sys/sched_state.h> -#include <sys/queue.h> -#include <sys/intr.h> -#include <machine/tss.h> -#include <machine/msr.h> -/* - * XXX: We are not using the PAUSE instruction for the sake of - * ensuring compatibility... PAUSE is F3 90, REP NOP is - * F3 90... REP NOP will be read as a PAUSE on processors - * that support it. - */ -#define hint_spinwait() __ASMV("rep; nop") - -#define this_cpu() amd64_this_cpu() -#define get_bsp() amd64_get_bsp() -#define is_intr_mask() amd64_is_intr_mask() -#define CPU_INFO_LOCK(info) spinlock_acquire(&(info->lock)) -#define CPU_INFO_UNLOCK(info) spinlock_release(&(info->lock)) - -/* - * Info about a specific processor. - * - * XXX: Spinlock must be acquired outside of this module! - * None of these module's internal functions should - * acquire the spinlock themselves! - */ -struct cpu_info { - /* Per-arch fields */ - void *pmap; /* Current pmap */ - uint32_t id; - uint32_t idx; - struct spinlock lock; - struct sched_state sched_state; - TAILQ_ENTRY(cpu_info) link; - - /* AMD64 */ - volatile size_t lapic_tmr_freq; - volatile void *lapic_base; - volatile bool has_x2apic; - volatile struct tss_entry *tss; - volatile uintptr_t tlb_flush_ptr; /* Address to flush */ - struct intr_info *tlb_shootdown; /* Shootdown interrupt info */ -}; - -/* - * Contains information for the current - * core. Stored in %GS. - * - * MUST REMAIN IN ORDER!!! - */ -struct cpu_ctx { - struct cpu_info *ci; -}; - -/* - * Returns true for this core if maskable - * interrupts are masked (CLI) and false if - * they aren't (STI). - */ -static inline bool -amd64_is_intr_mask(void) -{ - uint64_t flags; - - __ASMV("pushfq; pop %0" : "=rm" (flags) :: "memory"); - return !__TEST(flags, 1 << 9); -} - -static inline void -amd64_write_gs_base(uintptr_t val) -{ - wrmsr(IA32_KERNEL_GS_BASE, val); -} - -static inline uintptr_t -amd64_read_gs_base(void) -{ - return rdmsr(IA32_KERNEL_GS_BASE); -} - -static inline uint64_t -amd64_read_cr0(void) -{ - uint64_t cr0; - __ASMV("mov %%cr0, %0" : "=r" (cr0) :: "memory"); - return cr0; -} - -static inline void -amd64_write_cr0(uint64_t val) -{ - __ASMV("mov %0, %%cr0" :: "r" (val) : "memory"); -} - -static inline uint64_t -amd64_read_cr4(void) -{ - uint64_t cr4; - __ASMV("mov %%cr4, %0" : "=r" (cr4) :: "memory"); - return cr4; -} - -static inline void -amd64_write_cr4(uint64_t val) -{ - __ASMV("mov %0, %%cr4" :: "r" (val) : "memory"); -} - -static inline void -amd64_fxsave(void *area) -{ - __ASMV("fxsave (%0)" :: "r" (area) : "memory"); -} - -static inline void -amd64_fxrstor(void *area) -{ - __ASMV("fxrstor (%0)" :: "r" (area) : "memory"); -} - -struct cpu_info *amd64_this_cpu(void); - -#endif /* !_AMD64_CPU_H_ */ diff --git a/sys/include/arch/amd64/cpu_mp.h b/sys/include/arch/amd64/cpu_mp.h deleted file mode 100644 index 4047f3b..0000000 --- a/sys/include/arch/amd64/cpu_mp.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_CPU_AP_H_ -#define _SYS_CPU_AP_H_ - -#include <machine/cpu.h> -#include <sys/cdefs.h> -#include <sys/types.h> - -__weak void ap_bootstrap(struct cpu_info *ci); -__weak bool mp_supported(void); - -#endif /* !_SYS_CPU_AP_H_ */ diff --git a/sys/include/arch/amd64/cpuid.h b/sys/include/arch/amd64/cpuid.h deleted file mode 100644 index b193d60..0000000 --- a/sys/include/arch/amd64/cpuid.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _AMD64_CPUID_H_ -#define _AMD64_CPUID_H_ - -#include <sys/cdefs.h> - -#define __CPUID(level, a, b, c, d) \ - __ASMV("cpuid\n\t" \ - : "=a" (a), "=b" (b), "=c" (c), "=d" (d) \ - : "0" (level)) - -#endif /* !_AMD64_CPUID_H_ */ diff --git a/sys/include/arch/amd64/frame.h b/sys/include/arch/amd64/frame.h deleted file mode 100644 index 85edea9..0000000 --- a/sys/include/arch/amd64/frame.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _AMD64_FRAME_H_ -#define _AMD64_FRAME_H_ - -#if !defined(__ASSEMBLER__) - -#include <sys/types.h> - -struct trapframe { - uint64_t trapno; - uint64_t rax; - uint64_t rcx; - uint64_t rdx; - uint64_t rbx; - uint64_t rsi; - uint64_t rdi; - uint64_t rbp; - uint64_t r8; - uint64_t r9; - uint64_t r10; - uint64_t r11; - uint64_t r12; - uint64_t r13; - uint64_t r14; - uint64_t r15; - /* Pushed by hardware */ - uint64_t error_code; - uint64_t rip; - uint64_t cs; - uint64_t rflags; - uint64_t rsp; - uint64_t ss; -}; - -#define init_frame(FRAME, IP, SP) \ - (FRAME)->rip = IP; \ - (FRAME)->cs = 0x08; \ - (FRAME)->rflags = 0x202; \ - (FRAME)->rsp = SP; \ - (FRAME)->ss = 0x10; \ - -#define init_frame_user(FRAME, IP, SP) \ - (FRAME)->rip = IP; \ - (FRAME)->cs = 0x18 | 3; \ - (FRAME)->rflags = 0x202; \ - (FRAME)->rsp = SP; \ - (FRAME)->ss = 0x20 | 3; \ - -#define set_frame_sp(FRAME, SP) (FRAME)->rsp = SP -#define set_frame_ip(FRAME, IP) (FRAME)->rip = IP -#define get_frame_ip(FRAME) (FRAME)->rip - -#endif /* !defined(__ASSEMBLER__) */ -#endif /* !_AMD64_FRAME_H_ */ diff --git a/sys/include/arch/amd64/frameasm.h b/sys/include/arch/amd64/frameasm.h deleted file mode 100644 index cdcdd20..0000000 --- a/sys/include/arch/amd64/frameasm.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _AMD64_FRAMEASM_H_ -#define _AMD64_FRAMEASM_H_ - -/* - * If the interrupt has an error code, this macro shall - * be used to create the trapframe. - * - * XXX: A trapframe created with this must be popped with - * pop_trapframe_ec - */ -.macro push_trapframe_ec trapno - push %r15 - push %r14 - push %r13 - push %r12 - push %r11 - push %r10 - push %r9 - push %r8 - push %rbp - push %rdi - push %rsi - push %rbx - push %rdx - push %rcx - push %rax - push \trapno -.endm - -/* - * If the interrupt has an error code, this macro shall - * be used to cleanup the trapframe. - */ -.macro pop_trapframe_ec - add $8, %rsp /* Trapno */ - pop %rax - pop %rcx - pop %rdx - pop %rbx - pop %rsi - pop %rdi - pop %rbp - pop %r8 - pop %r9 - pop %r10 - pop %r11 - pop %r12 - pop %r13 - pop %r14 - pop %r15 -.endm - -/* - * If the interrupt has no error code, this macro - * shall be used to create the trapframe. - * - * XXX: A trapframe created with this must be popped - * with pop_trapframe - */ -.macro push_trapframe trapno - push $0 - push_trapframe_ec \trapno -.endm - - -/* - * If the interrupt has no error code, this macro shall - * be used to cleanup the trapframe. - */ -.macro pop_trapframe - pop_trapframe_ec - add $8, %rsp /* Pop error code */ -.endm -#endif /* !_AMD64_FRAMEASM_H_ */ diff --git a/sys/include/arch/amd64/gdt.h b/sys/include/arch/amd64/gdt.h deleted file mode 100644 index c3ea8e8..0000000 --- a/sys/include/arch/amd64/gdt.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef AMD64_GDT_H_ -#define AMD64_GDT_H_ - -#include <sys/types.h> -#include <sys/cdefs.h> - -#define GDT_TSS 5 -#define KERNEL_CS 0x8 -#define KERNEL_DS 0x10 - -struct __packed gdt_entry { - uint16_t limit; - uint16_t base_low; - uint8_t base_mid; - uint8_t access; - uint8_t granularity; - uint8_t base_hi; -}; - -struct __packed gdtr { - uint16_t limit; - uintptr_t offset; -}; - -static inline void -gdt_load(struct gdtr *gdtr) -{ - __asm("lgdt %0\n" - "push $8\n" /* Push CS */ - "lea 1f(%%rip), %%rax\n" /* Load 1 label address into RAX */ - "push %%rax\n" /* Push the return address (label 1) */ - "lretq\n" /* Far return to update CS */ - "1:\n" - " mov $0x10, %%eax\n" - " mov %%eax, %%ds\n" - " mov %%eax, %%es\n" - " mov %%eax, %%fs\n" - " mov %%eax, %%gs\n" - " mov %%eax, %%ss\n" - : - : "m" (*gdtr) - : "rax", "memory" - ); -} - -extern struct gdt_entry g_gdt[256]; -extern struct gdt_entry *g_gdt_tss; -extern struct gdtr g_gdtr; - -#endif /* !AMD64_GDT_H_ */ diff --git a/sys/include/arch/amd64/hpet.h b/sys/include/arch/amd64/hpet.h deleted file mode 100644 index dc4366c..0000000 --- a/sys/include/arch/amd64/hpet.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _TIMER_HPET_H_ -#define _TIMER_HPET_H_ - -#include <sys/types.h> - -int hpet_init(void); -int hpet_msleep(size_t ms); -int hpet_usleep(size_t us); -int hpet_nsleep(size_t ns); - -#endif /* !_TIMER_HPET_H_ */ diff --git a/sys/include/arch/amd64/idt.h b/sys/include/arch/amd64/idt.h deleted file mode 100644 index 36ce44e..0000000 --- a/sys/include/arch/amd64/idt.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _AMD64_IDT_H_ -#define _AMD64_IDT_H_ - -#include <sys/types.h> -#include <sys/cdefs.h> - -#define LIDT(idtr) __ASMV("lidt %0" \ - :: "m" (idtr)) - -#define IDT_TRAP_GATE_FLAGS 0x8F -#define IDT_INT_GATE_FLAGS 0x8E -#define IDT_INT_GATE_USER 0xEE - -/* - * AMD64 Interrupt Gate Descriptor. - */ -struct idt_entry { - uint16_t off_lo; /* Low 16 bits of ISR offset */ - uint16_t segsel; /* Segment selector, hardcode to kernel CS */ - uint8_t ist : 2; /* Interrupt stack table */ - uint8_t zero : 1; /* Unused: keep zero */ - uint8_t zero1 : 4; /* Unused: keep zero */ - uint8_t type : 4; /* Gate type */ - uint8_t zero2 : 1; /* Unused: keep zero */ - uint8_t dpl : 2; /* Descriptor privilege level */ - uint8_t p : 1; /* Present (keep 1 to mark as valid) */ - uint16_t off_mid; /* Middle 16 bits of ISR offset */ - uint32_t off_hi; /* High 32-bits of ISR offset */ - uint32_t reserved; /* Reserved: keep zero */ -}; - -struct __packed idtr { - uint16_t limit; - uintptr_t offset; -}; - - -void idt_set_desc(uint8_t vec, uint8_t type, uintptr_t isr, uint8_t ist); -void idt_load(void); - -#endif /* !_AMD64_IDT_H_ */ diff --git a/sys/include/arch/amd64/intr.h b/sys/include/arch/amd64/intr.h deleted file mode 100644 index d48a573..0000000 --- a/sys/include/arch/amd64/intr.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _AMD64_INTR_H_ -#define _AMD64_INTR_H_ - -#define IST_SCHED 1U -#define IST_HW_IRQ 2U -#define IST_SW_INT 3U - -#endif /* !_AMD64_INTR_H_ */ diff --git a/sys/include/arch/amd64/io.h b/sys/include/arch/amd64/io.h deleted file mode 100644 index c24c08d..0000000 --- a/sys/include/arch/amd64/io.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _AMD64_IO_H_ -#define _AMD64_IO_H_ - -#include <sys/types.h> -#include <sys/cdefs.h> - -static inline uint8_t -inb(uint16_t port) -{ - uint8_t result; - __asm__("in %%dx, %%al" : "=a" (result) : "d" (port)); - return result; -} - -static inline void -outb(uint16_t port, uint8_t data) -{ - __asm__("out %%al, %%dx" : :"a" (data), "d" (port)); -} - -static inline void -outw(uint16_t port, uint16_t data) -{ - __ASMV("outw %w0, %w1" : : "a" (data), "Nd" (port)); -} - -static inline uint16_t -inw(uint16_t port) -{ - uint16_t data; - __ASMV("inw %w1, %w0" : "=a" (data) : "Nd" (port)); - return data; -} - -static inline void -outl(uint16_t port, uint32_t data) -{ - __ASMV("outl %0, %w1" : : "a" (data), "Nd" (port)); -} - -static inline uint32_t -inl(uint16_t port) -{ - uint32_t data; - __ASMV("inl %w1, %0" : "=a" (data) : "Nd" (port)); - return data; -} - -#endif /* !_AMD64_IO_H_ */ diff --git a/sys/include/arch/amd64/ioapic.h b/sys/include/arch/amd64/ioapic.h deleted file mode 100644 index 0d86441..0000000 --- a/sys/include/arch/amd64/ioapic.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _AMD64_IOAPIC_H_ -#define _AMD64_IOAPIC_H_ - -#include <sys/types.h> - -void ioapic_irq_mask(uint8_t irq); -void ioapic_irq_unmask(uint8_t irq); -void ioapic_gsi_mask(uint8_t gsi); -void ioapic_gsi_unmask(uint8_t gsi); -void ioapic_set_base(void *mmio_base); -void ioapic_set_vec(uint8_t irq, uint8_t vector); -void ioapic_init(void); - -#endif /* !_AMD64_IOAPIC_H_ */ diff --git a/sys/include/arch/amd64/ioapicvar.h b/sys/include/arch/amd64/ioapicvar.h deleted file mode 100644 index 5128bc8..0000000 --- a/sys/include/arch/amd64/ioapicvar.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _AMD64_IOAPICVAR_H_ -#define _AMD64_IOAPICVAR_H_ - -#include <sys/types.h> - -/* Register offsets */ -#define IOREGSEL 0x00 -#define IOWIN 0x10 -#define IOAPICVER 0x01 -#define IOREDTBL 0x10 - -union ioapic_redentry { - struct { - uint8_t vector; - uint8_t delmod : 3; - uint8_t destmod : 1; - uint8_t delivs : 1; - uint8_t intpol : 1; - uint8_t remote_irr : 1; - uint8_t trigger_mode : 1; - uint8_t interrupt_mask : 1; - uint64_t reserved : 39; - uint8_t dest_field; - }; - uint64_t value; -}; - -#endif /* !_AMD64_IOAPICVAR_H_ */ diff --git a/sys/include/arch/amd64/isa/i8042regs.h b/sys/include/arch/amd64/isa/i8042regs.h deleted file mode 100644 index edef2ee..0000000 --- a/sys/include/arch/amd64/isa/i8042regs.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _AMD64_I8042REG_H_ -#define _AMD64_I8042REG_H_ - -#include <sys/cdefs.h> - -#define I8042_DATA 0x60 -#define I8042_STATUS 0x64 -#define I8042_COMMAND 0x64 - -/* Status register bits */ -#define I8042_OBUF_FULL __BIT(0) /* Output buffer full */ -#define I8042_IBUF_FULL __BIT(1) /* Input buffer full */ - -/* Commands */ -#define I8042_DISABLE_PORT0 0xAD -#define I8042_DISABLE_PORT1 0xA7 -#define I8042_ENABLE_PORT0 0xAE -#define I8042_ENABLE_PORT1 0xA8 -#define I8042_GET_CONFB 0x20 -#define I8042_SET_CONFB 0x60 -#define I8042_PORT1_SEND 0xD4 - -/* Controller config bits */ -#define I8042_PORT0_INTR __BIT(0) -#define I8042_PORT1_INTR __BIT(1) -#define I8042_PORT0_CLK __BIT(4) -#define I8042_PORT1_CLK __BIT(5) - -/* Aux commands */ -#define I8042_AUX_DEFAULTS 0xF5 -#define I8042_AUX_ENABLE 0xF4 -#define I8042_AUX_DISABLE 0xF5 -#define I8042_AUX_RESET 0xFF - -/* LED bits */ -#define I8042_LED_SCROLL __BIT(0) -#define I8042_LED_NUM __BIT(1) -#define I8042_LED_CAPS __BIT(2) - -#endif /* !_AMD64_I8042REG_H_ */ diff --git a/sys/include/arch/amd64/isa/i8254.h b/sys/include/arch/amd64/isa/i8254.h deleted file mode 100644 index 8215bf4..0000000 --- a/sys/include/arch/amd64/isa/i8254.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _AMD64_ISA_i8254_H_ -#define _AMD64_ISA_i8254_H_ - -#include <sys/types.h> - -#define i8254_COMMAND 0x43 -#define i8254_CHANNEL_0 0x40 -#define i8254_CHANNEL_2 0x42 -#define i8254_DIVIDEND 1193182ULL - -uint16_t i8254_get_count(void); -void i8254_set_reload(uint16_t val); -void i8254_set_frequency(uint64_t frequency_hz); - -#endif /* !_AMD64_ISA_i8254_H_ */ diff --git a/sys/include/arch/amd64/isa/spkr.h b/sys/include/arch/amd64/isa/spkr.h deleted file mode 100644 index 2691721..0000000 --- a/sys/include/arch/amd64/isa/spkr.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _ISA_SPKR_H_ -#define _ISA_SPKR_H_ - -#include <sys/types.h> - -int pcspkr_tone(uint16_t freq, uint32_t msec); - -#endif diff --git a/sys/include/arch/amd64/lapic.h b/sys/include/arch/amd64/lapic.h deleted file mode 100644 index c8a4de4..0000000 --- a/sys/include/arch/amd64/lapic.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _AMD64_LAPIC_H_ -#define _AMD64_LAPIC_H_ - -#include <sys/types.h> - -#define LAPIC_TMR_ONESHOT 0x00 -#define LAPIC_TMR_PERIODIC 0x01 - -/* IPI Destination Shorthands */ -enum { - IPI_SHORTHAND_NONE, - IPI_SHORTHAND_SELF, - IPI_SHORTHAND_ALL, - IPI_SHORTHAND_OTHERS -}; - -/* IPI Destination Modes */ -enum { - IPI_DEST_PHYSICAL, - IPI_DEST_LOGICAL -}; - -void lapic_timer_init(size_t *freq_out); -void lapic_timer_oneshot(bool mask, uint32_t count); -void lapic_timer_oneshot_us(size_t us); -void lapic_send_ipi(uint8_t id, uint8_t shorthand, uint8_t vector); -void lapic_send_eoi(void); -void lapic_init(void); - -#endif /* !_AMD64_LAPIC_H_ */ diff --git a/sys/include/arch/amd64/lapicvar.h b/sys/include/arch/amd64/lapicvar.h deleted file mode 100644 index 84f73d2..0000000 --- a/sys/include/arch/amd64/lapicvar.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _AMD64_LAPICVAR_H_ -#define _AMD64_LAPICVAR_H_ - -#include <sys/cdefs.h> - -/* LAPIC register offsets */ -#define LAPIC_ID 0x0020U /* ID Register */ -#define LAPIC_VERSION 0x0030U /* Version Register */ -#define LAPIC_TPR 0x0080U /* Task Priority Register */ -#define LAPIC_APR 0x0090U /* Arbitration Priority Register */ -#define LAPIC_PPR 0x00A0U /* Processor Priority Register */ -#define LAPIC_EOI 0x00B0U /* End Of Interrupt Register */ -#define LAPIC_RRD 0x00C0U /* Remote Read Register */ -#define LAPIC_LDR 0x00D0U /* Logical Destination Register */ -#define LAPIC_DFR 0x00E0U /* Destination Format Register */ -#define LAPIC_SVR 0x00F0U /* Spurious Vector Register */ -#define LAPIC_ISR 0x0100U /* In service register (max=0x0220) */ -#define LAPIC_TMR 0x0180U /* Trigger Mode Register (max=0x0220) */ -#define LAPIC_IRR 0x0200U /* Interrupt Request Register (max=0x0270) */ -#define LAPIC_ERR 0x0280U /* Error Status Register */ -#define LAPIC_ICRLO 0x0300U /* Interrupt Command Low Register */ -#define LAPIC_ICRHI 0x0310U /* Interrupt Command High Register */ -#define LAPIC_LVT_TMR 0x0320U /* LVT Timer Register */ -#define LAPIC_DCR 0x03E0U /* Divide Configuration Register (for timer) */ -#define LAPIC_INIT_CNT 0x0380U /* Initial Count Register (for timer) */ -#define LAPIC_CUR_CNT 0x0390U /* Current Count Register (for timer) */ - -#define IA32_APIC_BASE_MSR 0x1B - -/* - * The x2APIC register space is accessed via - * RDMSR/WRMSR instructions. The below defines - * the base MSR address for the register space. - */ -#define x2APIC_MSR_BASE 0x00000800 - -/* - * To hardware enable, OR the value - * of the IA32_APIC_BASE MSR with - * LAPIC_HW_ENABLE and rewrite it. - * - * To software enable, OR the value - * of the SVR with LAPIC_SW_ENABLE - * and rewrite it. - * - * LAPIC_SW_ENABLE has the low 8 bits set - * as some hardware requires the spurious - * vector to be hardwired to 1s so we'll - * go with that to be safe. - */ -#define LAPIC_HW_ENABLE __BIT(11) -#define LAPIC_SW_ENABLE (__BIT(8) | 0xFF) -#define x2APIC_ENABLE_SHIFT 10 - -/* - * The initial logical APIC ID to be set - * - * XXX: This value does *not* apply to processors - * that support x2APIC mode. In x2APIC mode - * the LDR register is readonly to system software. - */ -#define LAPIC_STARTUP_LID 0x1 - -/* LVT bits */ -#define LAPIC_LVT_MASK __BIT(16) -#define LVT_TMR_ONESHOT 0x00 -#define LVT_TMR_PERIODIC 0x01 -#define LVT_TMR_TSC_DEADLINE 0x02 - -/* LAPIC timer interrupt stack size in bytes */ -#define LAPIC_TMR_STACKSZ 4096 - -#endif /* !_AMD64_LAPICVAR_H_ */ diff --git a/sys/include/arch/amd64/msr.h b/sys/include/arch/amd64/msr.h deleted file mode 100644 index d36548b..0000000 --- a/sys/include/arch/amd64/msr.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _AMD64_MSR_H_ -#define _AMD64_MSR_H_ - -#include <sys/types.h> -#include <sys/cdefs.h> - -#define IA32_SPEC_CTL 0x00000048 -#define IA32_KERNEL_GS_BASE 0xC0000102 - -static inline uint64_t -rdmsr(uint32_t msr_addr) -{ - uint32_t lo, hi; - - __ASMV("rdmsr" - : "=a" (lo), "=d" (hi) - : "c" (msr_addr) - ); - return ((uint64_t)hi << 32) | lo; -} - -static inline void -wrmsr(uint32_t msr_addr, uint64_t value) -{ - uint32_t lo, hi; - - lo = (uint32_t)value; - hi = (uint32_t)(value >> 32); - - __ASMV("wrmsr" - : /* No outputs */ - : "a" (lo), "d" (hi), - "c" (msr_addr) - ); -} - -#endif /* !_AMD64_MSR_H_ */ diff --git a/sys/include/arch/amd64/pcb.h b/sys/include/arch/amd64/pcb.h deleted file mode 100644 index 0e0aab8..0000000 --- a/sys/include/arch/amd64/pcb.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _AMD64_PCB_H_ -#define _AMD64_PCB_H_ - -#include <sys/types.h> - -struct pcb { - uint8_t *fpu_state; -}; - -#endif /* !_AMD64_PCB_H_ */ diff --git a/sys/include/arch/amd64/spectre.h b/sys/include/arch/amd64/spectre.h deleted file mode 100644 index d12df21..0000000 --- a/sys/include/arch/amd64/spectre.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _AMD64_SPECTRE_H_ -#define _AMD64_SPECTRE_H_ - -#include <sys/cdefs.h> -#include <sys/errno.h> - -__weak int try_spectre_mitigate(void); - -#endif diff --git a/sys/include/arch/amd64/sysvec.h b/sys/include/arch/amd64/sysvec.h deleted file mode 100644 index 99a84c0..0000000 --- a/sys/include/arch/amd64/sysvec.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _AMD64_SYSVEC_H_ -#define _AMD64_SYSVEC_H_ - -#include <sys/cdefs.h> - -/* - * Interrupt vectors reserved - * to core system usage excluding - * device IRQs routed by 8259 PIC, - * I/O APIC, etc. - */ -typedef enum { - SYSVEC_LAPIC_TIMER = 0x21, /* Local APIC timer */ - SYSVEC_IPI, /* IPI vector */ - SYSVEC_HLT, /* Halt vector */ - SYSVEC_PCKBD, /* Keyboard vector */ - SYSVEC_TLB, /* TLB shootdown */ - - /* -- XXX: New vectors go above -- */ - NSYSVEC_BASE, /* Non-system vector base */ -} sysvec_t; - -/* Unlikely, but just in case */ -__STATIC_ASSERT(NSYSVEC_BASE <= 0xFF, "VECTOR OVERFLOW CAUGHT"); - -#endif /* !_AMD64_SYSVEC_H_ */ diff --git a/sys/include/arch/amd64/tlb.h b/sys/include/arch/amd64/tlb.h deleted file mode 100644 index c85e0e1..0000000 --- a/sys/include/arch/amd64/tlb.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _ASM_TLB_H_ -#define _ASM_TLB_H_ - -#include <sys/cdefs.h> - -#define tlb_flush(va) \ - __ASMV("invlpg (%0)" \ - : \ - : "r" (va) \ - : "memory" \ - ) - -#endif /* !_ASM_TLB_H_ */ diff --git a/sys/include/arch/amd64/trap.h b/sys/include/arch/amd64/trap.h deleted file mode 100644 index c75fa28..0000000 --- a/sys/include/arch/amd64/trap.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _AMD64_TRAP_H_ -#define _AMD64_TRAP_H_ - -#if !defined(__ASSEMBLER__) -#include <sys/types.h> -#include <machine/frame.h> -#endif /* !defined(__ASSEMBLER__) */ - -#define TRAP_NONE 0 /* Used for general interrupts */ -#define TRAP_BREAKPOINT 1 /* Breakpoint */ -#define TRAP_ARITH_ERR 2 /* Arithmetic error (e.g division by 0) */ -#define TRAP_OVERFLOW 3 /* Overflow */ -#define TRAP_BOUND_RANGE 4 /* BOUND range exceeded */ -#define TRAP_INVLOP 5 /* Invalid opcode */ -#define TRAP_DOUBLE_FAULT 6 /* Double fault */ -#define TRAP_INVLTSS 7 /* Invalid TSS */ -#define TRAP_SEGNP 8 /* Segment not present */ -#define TRAP_PROTFLT 9 /* General protection */ -#define TRAP_PAGEFLT 10 /* Page fault */ -#define TRAP_NMI 11 /* Non-maskable interrupt */ -#define TRAP_SS 12 /* Stack-segment fault */ - -/* Trap is coming from user mode */ -#define TRAP_USER 0x100 - -#if !defined(__ASSEMBLER__) -typedef void(*ftrap_handler_t)(void); - -void breakpoint_handler(void *sf); -void arith_err(void *sf); -void overflow(void *sf); -void bound_range(void *sf); -void invl_op(void *sf); -void double_fault(void *sf); -void invl_tss(void *sf); -void segnp(void *sf); -void general_prot(void *sf); -void page_fault(void *sf); -void nmi(void *sf); -void ss_fault(void *sf); -void trap_handler(struct trapframe *tf); -#else -.macro handle_trap - mov %rsp, %rdi - call trap_handler -.endm -#endif /* !defined(__ASSEMBLER__) */ - -#endif /* !_AMD64_TRAP_H_ */ diff --git a/sys/include/arch/amd64/tss.h b/sys/include/arch/amd64/tss.h deleted file mode 100644 index ca0ba57..0000000 --- a/sys/include/arch/amd64/tss.h +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _AMD64_TSS_H_ -#define _AMD64_TSS_H_ - -#include <sys/types.h> -#include <sys/cdefs.h> - -/* - * cpu_info is from machine/cpu.h - * - * XXX: machine/cpu.h includes this header - * so we must create this as including - * machine/cpu.h will not do anything... - */ -struct cpu_info; - -/* - * A TSS entry (64-bit) - * - * See Intel SDM Section 8.2.1 - Task-State Segment (TSS) - */ -struct __packed tss_entry { - uint32_t reserved1; - uint32_t rsp0_lo; - uint32_t rsp0_hi; - uint32_t rsp1_lo; - uint32_t rsp1_hi; - uint32_t rsp2_lo; - uint32_t rsp2_hi; - uint64_t reserved2; - uint32_t ist1_lo; - uint32_t ist1_hi; - uint32_t ist2_lo; - uint32_t ist2_hi; - uint32_t ist3_lo; - uint32_t ist3_hi; - uint32_t ist4_lo; - uint32_t ist4_hi; - uint32_t ist5_lo; - uint32_t ist5_hi; - uint32_t ist6_lo; - uint32_t ist6_hi; - uint32_t ist7_lo; - uint32_t ist7_hi; - uint64_t reserved3; - uint16_t reserved4; - uint16_t io_base; -}; - -/* - * TSS descriptor (64-bit) - * - * The TSS descriptor describes the location - * of the TSS segments among other things... - * - * See Intel SDM Section 8.2.3 - TSS Descriptor in 64-bit mode - */ -struct __packed tss_desc { - uint16_t seglimit; - uint16_t base_lo16; - uint8_t base_mid8; - uint8_t type : 4; - uint8_t zero : 1; - uint8_t dpl : 2; - uint8_t p : 1; - uint8_t seglimit_hi : 4; - uint8_t avl : 1; - uint8_t unused : 2; - uint8_t g : 1; - uint8_t base_hi_mid8; - uint32_t base_hi32; - uint32_t reserved; -}; - -/* - * Holds the address of the address pointing - * to the top of an interrupt stack. - */ -union tss_stack { - struct { - uint32_t top_lo; - uint32_t top_hi; - }; - uint64_t top; -}; - -int tss_alloc_stack(union tss_stack *entry_out, size_t size); -int tss_update_ist(struct cpu_info *ci, union tss_stack stack, uint8_t istno); -void write_tss(struct cpu_info *cpu, struct tss_desc *desc); -void tss_load(void); /* In tss.S */ - -#endif /* _!_AMD64_TSS_H_ */ diff --git a/sys/include/arch/amd64/uart.h b/sys/include/arch/amd64/uart.h deleted file mode 100644 index a49e626..0000000 --- a/sys/include/arch/amd64/uart.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* UART 8250 init logic */ - -#ifndef _UART_H_ -#define _UART_H_ - -#include <sys/types.h> - -int uart8250_try_init(void); -void uart8250_write(char byte); - -#endif diff --git a/sys/include/arch/amd64/vas.h b/sys/include/arch/amd64/vas.h deleted file mode 100644 index b8eef89..0000000 --- a/sys/include/arch/amd64/vas.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _AMD64_PMAP_H_ -#define _AMD64_PMAP_H_ - -#include <sys/types.h> -#include <sys/spinlock.h> - -/* - * VAS structure - describes a virtual address space - * - * XXX: This structure shall exist per-process. - * - * TODO: As of now, VAS operations are *not* serialized!!! - * This must change once Hyra becomes multi-threaded - * or things will go wrong *very* quickly. Ensure of - * this or you will suffer the consequences of undefined - * behavior and you will not like it! - */ -struct vas { - size_t cr3_flags; /* CR3 flags */ - uintptr_t top_level; /* PML5 if `use_l5_paging' true, otherwise PML4 */ - bool use_l5_paging; /* True if 5-level paging is supported */ - struct spinlock lock; -}; - -#endif /* !_AMD64_PMAP_H_ */ diff --git a/sys/include/dev/ic/ahciregs.h b/sys/include/dev/ic/ahciregs.h deleted file mode 100644 index b2da5b7..0000000 --- a/sys/include/dev/ic/ahciregs.h +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _AHCIREGS_H_ -#define _AHCIREGS_H_ - -#include <sys/types.h> -#include <sys/cdefs.h> - -struct hba_port { - volatile uint64_t clb; /* Command list base (1k-byte aligned) */ - volatile uint64_t fb; /* FIS base (256-byte aligned) */ - volatile uint32_t is; /* Interrupt status */ - volatile uint32_t ie; /* Interrupt enable */ - volatile uint32_t cmd; /* Command and status */ - volatile uint32_t rsvd0; /* Reserved */ - volatile uint32_t tfd; /* Task file data */ - volatile uint32_t sig; /* Signature */ - volatile uint32_t ssts; /* SATA status */ - volatile uint32_t sctl; /* SATA control */ - volatile uint32_t serr; /* SATA error */ - volatile uint32_t sact; /* SATA active */ - volatile uint32_t ci; /* Command issue */ - volatile uint32_t sntf; /* SATA notification */ - volatile uint32_t fbs; /* FIS-based switch control */ - volatile uint32_t rsvd1[11]; - volatile uint32_t vendor[4]; -}; - -struct hba_memspace { - volatile uint32_t cap; /* Host Capabilities */ - volatile uint32_t ghc; /* Global host control */ - volatile uint32_t is; /* Interrupt status */ - volatile uint32_t pi; /* Ports implemented */ - volatile uint32_t vs; /* Version */ - volatile uint32_t ccc_ctl; /* Command completion coalescing control */ - volatile uint32_t ccc_pts; /* Command completion coalescing ports */ - volatile uint32_t em_loc; /* Enclosure management location */ - volatile uint32_t em_ctl; /* Enclosure management control */ - volatile uint32_t cap2; /* Host capabilities extended */ - volatile uint32_t bohc; /* BIOS/OS Handoff Control and Status */ - volatile uint8_t rsvd[0x74]; /* Reserved */ - volatile uint8_t vendor[0x60]; /* Vendor specific */ - struct hba_port ports[1]; -}; - -/* Global host control bits */ -#define AHCI_GHC_AE __BIT(31) /* AHCI enable */ -#define AHCI_GHC_IE __BIT(1) /* Interrupt enable */ -#define AHCI_GHC_HR __BIT(0) /* HBA reset */ - -/* AHCI port signatures */ -#define AHCI_SIG_ATA 0x00000101 -#define AHCI_SIG_SEMB 0xC33C0101 -#define AHCI_SIG_PM 0x96690101 - -/* - * Port SATA status - * See section 3.3.10 of the AHCI spec. - */ -#define AHCI_PXSSTS_DET(SSTS) (SSTS & 0xF) -#define AHCI_PXSSTS_IPM(SSTS) ((SSTS >> 8) & 0xF) - -/* - * Port SATA control bits - * See section 3.3.11 of the AHCI spec. - */ -#define AHCI_PXSCTL_DET(SCTL) (SCTL & 0xF) - -/* - * Port command and status bits - * See section 3.3.7 of the AHCI spec. - */ -#define AHCI_PXCMD_ST __BIT(0) /* Start */ -#define AHCI_PXCMD_FRE __BIT(4) /* FIS Receive Enable */ -#define AHCI_PXCMD_FR __BIT(14) /* FIS Receive Running */ -#define AHCI_PXCMD_CR __BIT(15) /* Command List Running */ - -/* - * Interrupt status bits - * See section 3.3.5 of the AHCI spec. - */ -#define AHCI_PXIS_TFES __BIT(31) - -/* - * Task file data bits - * See section 3.3.8 of the AHCI spec. - */ -#define AHCI_PXTFD_ERR __BIT(0) -#define AHCI_PXTFD_DRQ __BIT(3) -#define AHCI_PXTFD_BSY __BIT(7) - -/* - * Capability bits - * See section 3.1.1 of the AHCI spec. - */ -#define AHCI_CAP_NP(CAP) (CAP & 0x1F) /* Number of ports */ -#define AHCI_CAP_NCS(CAP) ((CAP >> 8) & 0x1F) /* Number of command slots */ - -/* - * Device detection (DET) and Interface power - * management (IPM) values - * See section 3.3.10 of the AHCI spec. - */ -#define AHCI_DET_NULL 0 /* No device detected */ -#define AHCI_DET_PRESENT 1 /* Device present (no PHY comm) */ -#define AHCI_DET_COMM 3 /* Device present and phy comm established */ -#define AHCI_IPM_ACTIVE 1 - -/* - * Device detection initialization values - * See section 3.3.11 of the AHCI spec. - */ -#define AHCI_DET_COMRESET 1 - -#endif /* !_AHCIREGS_H_ */ diff --git a/sys/include/dev/ic/ahcivar.h b/sys/include/dev/ic/ahcivar.h deleted file mode 100644 index edef4f6..0000000 --- a/sys/include/dev/ic/ahcivar.h +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _AHCIVAR_H_ -#define _AHCIVAR_H_ - -#include <sys/types.h> -#include <sys/cdefs.h> -#include <sys/mutex.h> -#include <sys/queue.h> -#include <dev/ic/ahciregs.h> - -struct ata_identity { - uint16_t rsvd0 : 1; - uint16_t unused0 : 1; - uint16_t incomplete : 1; - uint16_t unused1 : 3; - uint16_t fixed_dev : 1; - uint16_t removable : 1; - uint16_t unused2 : 7; - uint16_t device_type : 1; - uint16_t ncylinders; - uint16_t specific_config; - uint16_t nheads; - uint16_t unused3[2]; - uint16_t sectors_per_track; - uint16_t vendor[3]; - char serial_number[20]; - uint16_t unused4[2]; - uint16_t unused5; - char firmware_rev[8]; - char model_number[40]; - char pad[256]; -}; - -/* Physical region descriptor table entry */ -struct ahci_prdt_entry { - uintptr_t dba; /* Data base address */ - uint32_t rsvd0; /* Reserved */ - uint32_t dbc : 22; /* Count */ - uint16_t rsvd1 : 9; /* Reserved */ - uint8_t i : 1; /* Interrupt on completion */ -}; - -/* Command header */ -struct ahci_cmd_hdr { - uint8_t cfl : 5; /* Command FIS length */ - uint8_t a : 1; /* ATAPI */ - uint8_t w : 1; /* Write */ - uint8_t p : 1; /* Prefetchable */ - uint8_t r : 1; /* Reset */ - uint8_t c : 1; /* Clear busy upon R_OK */ - uint8_t rsvd0 : 1; /* Reserved */ - uint8_t pmp : 4; /* Port multiplier port */ - uint16_t prdtl; /* PRDT length (in entries) */ - volatile uint32_t prdbc; /* PRDT bytes transferred count */ - uintptr_t ctba; /* Command table descriptor base addr */ - uint32_t rsvd1[4]; /* Reserved */ -}; - -/* Command table */ -struct ahci_cmdtab { - uint8_t cfis[64]; - uint8_t acmd[16]; - uint8_t rsvd[48]; - struct ahci_prdt_entry prdt[1]; -}; - -struct ahci_fis_h2d { - uint8_t type; - uint8_t pmp : 4; - uint8_t rsvd0 : 3; - uint8_t c : 1; - uint8_t command; - uint8_t featurel; - uint8_t lba0; - uint8_t lba1; - uint8_t lba2; - uint8_t device; - uint8_t lba3; - uint8_t lba4; - uint8_t lba5; - uint8_t featureh; - uint8_t countl; - uint8_t counth; - uint8_t icc; - uint8_t control; - uint8_t rsvd1[4]; -}; - -struct ahci_device { - struct ahci_hba *hba; - struct hba_port *port; - dev_t minor; - TAILQ_ENTRY(ahci_device) link; -}; - -struct ahci_hba { - struct hba_memspace *abar; - struct ahci_cmd_hdr *cmdlist; - uint32_t ncmdslots; - uint32_t nports; -}; - -/* Commands */ -#define ATA_CMD_NOP 0x00 -#define ATA_CMD_IDENTIFY 0xEC -#define ATA_CMD_READ_DMA 0x25 -#define ATA_CMD_WRITE_DMA 0x35 - -/* FIS types */ -#define FIS_TYPE_H2D 0x27 -#define FIS_TYPE_D2H 0x34 - -#define AHCI_TIMEOUT 500 -#define AHCI_FIS_SIZE 256 -#define AHCI_CMDTAB_SIZE 256 -#define AHCI_CMDENTRY_SIZE 32 - -#endif /* !_AHCIVAR_H_ */ diff --git a/sys/include/dev/ic/nvmevar.h b/sys/include/dev/ic/nvmevar.h deleted file mode 100644 index 4a40071..0000000 --- a/sys/include/dev/ic/nvmevar.h +++ /dev/null @@ -1,280 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _IC_NVMEVAR_H_ -#define _IC_NVMEVAR_H_ - -#include <sys/cdefs.h> - -/* Admin commands */ -#define NVME_OP_CREATE_IOSQ 0x01 -#define NVME_OP_CREATE_IOCQ 0x05 -#define NVME_OP_IDENTIFY 0x06 - -/* I/O commands */ -#define NVME_OP_WRITE 0x01 -#define NVME_OP_READ 0x02 - -/* Controller Capabilities */ -#define CAP_MPSMIN(caps) ((caps >> 48) & 0xF) -#define CAP_MPSMAX(caps) ((caps >> 52) & 0xF) -#define CAP_TIMEOUT(caps) ((caps >> 24) & 0xFF) -#define CAP_STRIDE(caps) ((caps >> 32) & 0xF) -#define CAP_MQES(caps) (caps & 0xFFFF) -#define CAP_CSS(caps) (caps & 0xFF) - -/* Controller Configuration */ -#define CONFIG_EN __BIT(0) -#define CONFIG_CSS_SHIFT 4 -#define CONFIG_IOSQES_SHIFT 16 -#define CONFIG_IOCQES_SHIFT 20 - -#define COMMAND_SIZE 64 /* In bytes (defined by spec) */ -#define STATUS_READY(status) (status & 1) - -struct nvme_common_cmd { - uint8_t opcode; - uint8_t flags; - uint16_t cid; - uint32_t nsid; - uint32_t cdw1[2]; - uint64_t metadata; - uint64_t prp1; - uint64_t prp2; - uint32_t cdw2[6]; -}; - -struct nvme_identify_cmd { - uint8_t opcode; - uint8_t flags; - uint16_t cid; - uint32_t nsid; - uint64_t unused1; - uint64_t unused2; - uint64_t prp1; - uint64_t prp2; - uint32_t cns; - uint32_t unused3[5]; -}; - -/* Read/write */ -struct nvme_rw_cmd { - uint8_t opcode; - uint8_t flags; - uint16_t cid; - uint32_t nsid; - uint64_t unused; - uint64_t metadata; - uint64_t prp1; - uint64_t prp2; - uint64_t slba; - uint16_t len; - uint16_t control; - uint32_t dsmgmt; - uint32_t ref; - uint16_t apptag; - uint16_t appmask; -}; - -/* Create I/O completion queue */ -struct nvme_create_iocq_cmd { - uint8_t opcode; - uint8_t flags; - uint16_t cid; - uint32_t unused1[5]; - uint64_t prp1; - uint64_t unused2; - uint16_t qid; - uint16_t qsize; - uint16_t qflags; - uint16_t irqvec; - uint64_t unused3[2]; -}; - -struct nvme_create_iosq_cmd { - uint8_t opcode; - uint8_t flags; - uint16_t cid; - uint32_t unused1[5]; - uint64_t prp1; - uint64_t unused2; - uint16_t sqid; - uint16_t qsize; - uint16_t qflags; - uint16_t cqid; - uint64_t unused3[2]; -}; - -struct nvme_cmd { - union { - struct nvme_identify_cmd identify; - struct nvme_common_cmd common; - struct nvme_create_iocq_cmd create_iocq; - struct nvme_create_iosq_cmd create_iosq; - struct nvme_rw_cmd rw; - }; -}; - -struct nvme_id { - uint16_t vid; - uint16_t ssvid; - char sn[20]; - char mn[40]; - char fr[8]; - uint8_t rab; - uint8_t ieee[3]; - uint8_t mic; - uint8_t mdts; - uint16_t ctrlid; - uint32_t version; - uint32_t unused1[43]; - uint16_t oacs; - uint8_t acl; - uint8_t aerl; - uint8_t fw; - uint8_t lpa; - uint8_t elpe; - uint8_t npss; - uint8_t avscc; - uint8_t apsta; - uint16_t wctemp; - uint16_t cctemp; - uint16_t unused2[121]; - uint8_t sqes; - uint8_t cqes; - uint16_t unused3; - uint32_t nn; - uint16_t oncs; - uint16_t fuses; - uint8_t fna; - uint8_t vwc; - uint16_t awun; - uint16_t awupf; - uint8_t nvscc; - uint8_t unused4; - uint16_t acwu; - uint16_t unused5; - uint32_t sgls; - uint32_t unused6[1401]; - uint8_t vs[1024]; -}; - -/* Command completion queue entry */ -struct nvme_cq_entry { - uint32_t res; - uint32_t unused; - uint16_t sqhead; - uint16_t sqid; - uint16_t cid; - uint16_t status; -}; - -/* NVMe controller */ -struct __packed nvme_bar { - uint64_t caps; - uint32_t version; - uint32_t intms; /* Interrupt mask set */ - uint32_t intmc; /* Interrupt mask clear */ - uint32_t config; - uint32_t unused1; - uint32_t status; - uint32_t unused2; - uint32_t aqa; /* Admin queue attributes */ - uint64_t asq; /* Admin submission queue */ - uint64_t acq; /* Admin completion queue */ -}; - -struct nvme_lbaf { - uint16_t ms; /* Number of metadata bytes per LBA */ - uint8_t ds; /* Data size */ - uint8_t rp; -}; - -/* Identify namespace data */ -struct nvme_id_ns { - uint64_t size; - uint64_t capabilities; - uint64_t nuse; - uint8_t features; - uint8_t nlbaf; - uint8_t flbas; - uint8_t mc; - uint8_t dpc; - uint8_t dps; - uint8_t nmic; - uint8_t rescap; - uint8_t fpi; - uint8_t unused1; - uint16_t nawun; - uint16_t nawupf; - uint16_t nacwu; - uint16_t nabsn; - uint16_t nabo; - uint16_t nabspf; - uint16_t unused2; - uint64_t nvmcap[2]; - uint64_t unusued3[5]; - uint8_t nguid[16]; - uint8_t eui64[8]; - struct nvme_lbaf lbaf[16]; - uint64_t unused3[24]; - uint8_t vs[3712]; -}; - -struct nvme_queue { - struct nvme_cmd *sq; /* Submission queue */ - struct nvme_cq_entry *cq; /* Completion queue */ - uint16_t sq_head; /* Submission queue head */ - uint16_t sq_tail; /* Submission queue tail */ - uint16_t cq_head; /* Completion queue head */ - uint8_t cq_phase : 1; /* Completion queue phase bit */ - uint16_t size; /* Size in elements */ - volatile uint32_t *sq_db; /* Submission doorbell */ - volatile uint32_t *cq_db; /* Completion doorbell */ -}; - -struct nvme_state { - struct nvme_queue adminq; - struct nvme_bar *bar; - dev_t major; -}; - -/* NVMe namespace */ -struct nvme_ns { - size_t nsid; /* Namespace ID */ - size_t lba_bsize; /* LBA block size */ - size_t size; /* Size in logical blocks */ - struct nvme_queue ioq; /* I/O queue */ - struct nvme_lbaf lba_fmt; /* LBA format */ - struct nvme_state *cntl; /* NVMe controller */ - dev_t dev_id; - TAILQ_ENTRY(nvme_ns) link; -}; - -#endif diff --git a/sys/include/dev/pci/pci.h b/sys/include/dev/pci/pci.h deleted file mode 100644 index d6edf3b..0000000 --- a/sys/include/dev/pci/pci.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _DEV_PCI_H_ -#define _DEV_PCI_H_ - -#include <sys/syscall.h> -#include <sys/queue.h> -#include <sys/cdefs.h> -#include <dev/pci/pciregs.h> -#include <vm/vm.h> - -/* Lookup bits */ -#define PCI_DEVICE_ID __BIT(0) -#define PCI_VENDOR_ID __BIT(1) -#define PCI_CLASS __BIT(2) -#define PCI_SUBCLASS __BIT(3) - -/* Base address masks for BARs */ -#define PCI_BAR_MEMMASK ~7 -#define PCI_BAR_IOMASK ~3 - -/* Macros to fetch base address from BAR */ -#define PCI_BAR_MEMBASE(BAR) PHYS_TO_VIRT(BAR & PCI_BAR_MEMMASK) -#define PCI_BAR_IOBASE(BAR) PHYS_TO_VIRT(BAR & PCI_BAR_IOMASK) - -/* For PCI lookups */ -struct pci_lookup { - uint16_t device_id; - uint16_t vendor_id; - uint8_t pci_class; - uint8_t pci_subclass; -}; - -struct pci_device { - uint8_t bus; - uint8_t slot; - uint8_t func; - - uint16_t device_id; - uint16_t vendor_id; - uint8_t pci_class; - uint8_t pci_subclass; - uint8_t prog_if; - uintptr_t bar[6]; - uint8_t irq_line; - TAILQ_ENTRY(pci_device) link; -}; - -int pci_init(void); -uint32_t pci_readl(struct pci_device *dev, uint32_t offset); -uint32_t pci_bar_size(struct pci_device *dev, uint8_t bar); -void pci_writel(struct pci_device *dev, uint32_t offset, uint32_t val); -void pci_set_cmdreg(struct pci_device *dev, uint16_t bits); -struct pci_device *pci_get_device(struct pci_lookup lookup, uint16_t lookup_type); - -#endif /* !_DEV_PCI_H_ */ diff --git a/sys/include/dev/pci/pciregs.h b/sys/include/dev/pci/pciregs.h deleted file mode 100644 index 13a9fc0..0000000 --- a/sys/include/dev/pci/pciregs.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _PCIREGS_H_ -#define _PCIREGS_H_ - -#include <sys/cdefs.h> - -#define PCIREG_VENDOR_ID 0x00 /* 16 bits */ -#define PCIREG_DEVICE_ID 0x02 /* 16 bits */ -#define PCIREG_CLASSREV 0x08 /* 32 bits */ -#define PCIREG_BAR0 0x10 /* 32 bits */ -#define PCIREG_BAR1 0x14 /* 32 bits */ -#define PCIREG_BAR2 0x18 /* 32 bits */ -#define PCIREG_BAR3 0x1C /* 32 bits */ -#define PCIREG_BAR4 0x20 /* 32 bits */ -#define PCIREG_BAR5 0x24 /* 32 bits */ -#define PCIREG_IRQLINE 0x3C /* 8 bits */ -#define PCIREG_CMDSTATUS 0x04 /* command (15:0), status (31:16) */ - -/* Macros to extract PCIREG_CLASSREV bits */ -#define PCIREG_CLASS(CLASSREV) (CLASSREV >> 24) -#define PCIREG_SUBCLASS(CLASSREV) ((CLASSREV >> 16) & 0xFF) -#define PCIREG_REVID(CLASSREV) (CLASSREV & 0xFF) -#define PCIREG_PROGIF(CLASSREV) ((CLASSREV >> 8) & 0xFF) - -/* Macros to extract PCIREG_CMDSTATUS bits */ -#define PCIREG_COMMAND(CMDSTATUS) (CMDSTATUS & 0xFFFF) -#define PCIREG_STATUS(CMDSTATUS) (CMDSTATUS >> 16) - -/* PCI command register bits */ -#define PCI_IO_SPACE __BIT(0) /* Respond to I/O space accesses */ -#define PCI_MEM_SPACE __BIT(1) /* Respond to mem space accesses */ -#define PCI_BUS_MASTERING __BIT(2) /* Enable bus mastering */ - -/* PCI status register bits */ -#define PCI_STATUS_CAPLIST __BIT(4) -#define PCI_STATUS_66MHZ __BIT(5) - -#endif /* !_PCIREGS_H_ */ diff --git a/sys/include/dev/pci/pcivar.h b/sys/include/dev/pci/pcivar.h deleted file mode 100644 index ba45a53..0000000 --- a/sys/include/dev/pci/pcivar.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _DEV_PCIVAR_H_ -#define _DEV_PCIVAR_H_ - -#include <sys/types.h> - -enum { - PCI_ACCESS_CAM, - PCI_ACCESS_ECAM -}; - -#endif /* !_DEV_PCIVAR_H_ */ diff --git a/sys/include/dev/usb/xhciregs.h b/sys/include/dev/usb/xhciregs.h deleted file mode 100644 index 0b07524..0000000 --- a/sys/include/dev/usb/xhciregs.h +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _USB_XHCIREGS_H_ -#define _USB_XHCIREGS_H_ - -#include <sys/types.h> -#include <sys/cdefs.h> - -/* - * Host Controller Capability Registers - * - * See xHCI spec, section 5.3, table 5-9 - */ -struct __packed xhci_caps { - volatile uint8_t caplength; - volatile uint8_t reserved; - volatile uint16_t hciversion; - volatile uint32_t hcsparams1; - volatile uint32_t hcsparams2; - volatile uint32_t hcsparams3; - volatile uint32_t hccparams1; - volatile uint32_t dboff; - volatile uint32_t rtsoff; - volatile uint32_t hccparams2; -}; - -/* - * Host Controller Operational Registers - * - * See xHCI spec, section 5.4, table 5-18 - */ -struct __packed xhci_opregs { - volatile uint32_t usbcmd; - volatile uint32_t usbsts; - volatile uint32_t pagesize; - volatile uint32_t reserved; - volatile uint32_t reserved1; - volatile uint32_t dnctrl; - volatile uint64_t cmd_ring; - volatile uint32_t reserved2[4]; - volatile uint64_t dcbaa_ptr; - volatile uint32_t config; -}; - -/* USBCMD bits */ -#define USBCMD_RUN __BIT(0) /* Run/stop */ -#define USBCMD_HCRST __BIT(1) /* xHC reset */ - -/* USBSTS bits */ -#define USBSTS_HCH __BIT(0) /* HC halted */ - -/* CAPS.HCSPARAMS1 fields */ -#define XHCI_MAXSLOTS(HCSPARAMS1) (HCSPARAMS1 & 0xFF) -#define XHCI_MAXPORTS(HCSPARAMS1) ((HCSPARAMS1 >> 24) & 0xFF) -#define XHCI_ECP(HCCPARAMS1) ((HCCPARAMS1 >> 16) & 0xFFFF) - -/* CAPS.HCSPARAMS2 fields */ -#define XHCI_MAX_SP_HI(HCSPARAMS2) ((HCSPARAMS2 >> 25) & 0x1F) -#define XHCI_MAX_SP_LO(HCSPARAMS2) ((HCSPARAMS2 >> 31) & 0x1F) - -/* PORTSC bits */ -#define XHCI_PORTSC_CCS __BIT(0) /* Current connect status */ -#define XHCI_PORTSC_PR __BIT(4) /* Port reset */ - -/* Registers */ -#define XHCI_BASE_OFF(BASE, OFF) (void *)((uintptr_t)BASE + OFF) -#define XHCI_CAPS(BASE) XHCI_BASE_OFF(BASE, 0) -#define XHCI_OPBASE(BASE, CAP_LEN) XHCI_BASE_OFF(BASE, CAP_LEN) -#define XHCI_RTS(BASE, RTSOFF) XHCI_BASE_OFF(BASE, RTSOFF) -#define XHCI_CMD_DB(BASE, DBOFF) XHCI_BASE_OFF(BASE, DBOFF) - -/* Support protocol cap fields */ -#define XHCI_PROTO_ID(PROTO) (PROTO & 0xFF) -#define XHCI_PROTO_MINOR(PROTO) ((PROTO >> 16) & 0xFF) -#define XHCI_PROTO_MAJOR(PROTO) ((PROTO >> 24) & 0xFF) -#define XHCI_PROTO_NEXT(PROTO) ((PROTO >> 8) & 0xFF) -#define XHCI_PROTO_PORTOFF(PROTO2) (PROTO2 & 0xFF) -#define XHCI_PROTO_PORTCNT(PROTO2) ((PROTO2 >> 8) & 0xFF) - -/* Extended cap IDs */ -#define XHCI_ECAP_PROTO 2 - -#endif /* !_USB_XHCIREGS_H_ */ diff --git a/sys/include/dev/usb/xhcivar.h b/sys/include/dev/usb/xhcivar.h deleted file mode 100644 index 71c1f20..0000000 --- a/sys/include/dev/usb/xhcivar.h +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _USB_XHCIVAR_H_ -#define _USB_XHCIVAR_H_ - -#include <sys/types.h> -#include <sys/cdefs.h> -#include <dev/usb/xhciregs.h> - -#define XHCI_TIMEOUT 500 /* In ms */ -#define XHCI_CMDRING_LEN 16 -#define XHCI_EVRING_LEN 16 -#define XHCI_TRB_SIZE 16 /* In bytes */ -#define XHCI_EVENTRING_LEN XHCI_CMDRING_LEN -#define XHCI_MAX_PROTOS 4 - -struct xhci_nop_trb { - uint32_t reserved; - uint32_t reserved1; - uint32_t reserved2; - uint8_t cycle : 1; - uint16_t reserved3 : 9; - uint8_t type : 6; - uint16_t reserved4; -}; - -/* - * xHCI Transfer Request Block - */ -struct xhci_trb { - union { - struct xhci_nop_trb nop; - struct { - uint32_t dword0; - uint32_t dword1; - uint32_t dword2; - uint32_t dword3; - }; - }; -}; - -/* - * USB proto (USB 2.0 or 3.0) - */ -struct xhci_proto { - uint8_t major; /* Revision major */ - uint8_t port_start; /* Port offset start */ - uint8_t port_count; /* Number of ports */ -}; - -/* - * xHCI event ring segment - * - * See xHCI spec, section 6.5, table 6-40 - */ -struct __packed xhci_evring_segment { - uint64_t base; - uint32_t size; - uint32_t reserved; -}; - -/* - * Host controller. - */ -struct xhci_hc { - void *base; - uint8_t caplen; - uint8_t maxslots; - size_t maxports; - size_t protocnt; - uintptr_t *dcbaap; - uint8_t cycle : 1; - uint16_t cmd_ptr; /* Command ring index */ - uint16_t cmd_count; /* Command ring entry count */ - uint32_t *cmd_ring; - uint32_t *event_ring; - struct xhci_opregs *opregs; - struct xhci_proto protos[XHCI_MAX_PROTOS]; - struct xhci_evring_segment *evring_seg; -}; - -/* TRB types */ -#define XHCI_ENABLE_SLOT 9 -#define XHCI_LINK 6 - -#endif /* !_USB_XHCIVAR_H_ */ diff --git a/sys/include/dev/vcons/vcons.h b/sys/include/dev/vcons/vcons.h deleted file mode 100644 index 492940f..0000000 --- a/sys/include/dev/vcons/vcons.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _DEV_VCONS_H_ -#define _DEV_VCONS_H_ - -#include <sys/types.h> -#include <sys/termios.h> -#include <dev/video/fbdev.h> -#include <sysfont.h> - -#define VCONS_TAB_WIDTH 4 -#define VCONS_CURSOR_WIDTH FONT_WIDTH -#define VCONS_CURSOR_HEIGHT FONT_HEIGHT - -struct vcons_cursor { - size_t xpos, ypos; - uint32_t rgb; - - /* Internal */ - uint32_t old_xpos, old_ypos; - volatile bool is_drawing; - volatile bool is_drawn; /* If it has been drawn before */ -}; - -struct vcons_screen { - size_t nrows, ncols; - size_t cpy_x, cpy_y; /* In chars */ - size_t cpy_len; - - uint32_t bg; - uint32_t fg; - void *fbdev_mem; - - struct fbdev fbdev; - struct vcons_cursor cursor; -}; - -#define is_cursor_drawing(screenptr) (screenptr)->cursor.is_drawing - -void vcons_attach(struct vcons_screen *scr); -int vcons_putch(struct vcons_screen *scr, char c); -int vcons_putstr(struct vcons_screen *scr, const char *s, size_t len); -void vcons_update_cursor(struct vcons_screen *scr); - -#endif /* !_DEV_VCONS_H_ */ diff --git a/sys/include/dev/vcons/vcons_io.h b/sys/include/dev/vcons/vcons_io.h deleted file mode 100644 index a75d811..0000000 --- a/sys/include/dev/vcons/vcons_io.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _VCONS_IO_H_ -#define _VCONS_IO_H_ - -#include <dev/vcons/vcons.h> - -int vcons_process_output(struct vcons_screen *scr, int c); - -#endif /* !_VCONS_IO_H_ */ diff --git a/sys/include/dev/video/fbdev.h b/sys/include/dev/video/fbdev.h deleted file mode 100644 index 5ad6bf6..0000000 --- a/sys/include/dev/video/fbdev.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _FBDEV_H_ -#define _FBDEV_H_ - -#include <sys/types.h> -#include <sys/fbdev.h> - -struct fbdev { - void *mem; - uint32_t width; - uint32_t height; - uint32_t pitch; -}; - -static inline size_t -fbdev_get_index(const struct fbdev *fbdev, uint32_t x, uint32_t y) -{ - return x + y * (fbdev->pitch/4); -} - -struct fbdev fbdev_get_front(void); - -#endif /* !_FBDEV_H_ */ diff --git a/sys/include/firmware/acpi/acpi.h b/sys/include/firmware/acpi/acpi.h deleted file mode 100644 index 66a955f..0000000 --- a/sys/include/firmware/acpi/acpi.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _ACPI_ACPI_H_ -#define _ACPI_ACPI_H_ - -#include <firmware/acpi/tables.h> -#include <machine/cpu.h> -#include <sys/types.h> - -void acpi_init(void); -uint32_t irq_to_gsi(uint8_t irq); -void *acpi_query(const char *query); -bool acpi_is_checksum_valid(struct acpi_header *hdr); -struct acpi_root_sdt *acpi_get_root_sdt(void); -size_t acpi_get_root_sdt_len(void); -void acpi_parse_madt(struct cpu_info *ci); -void *acpi_get_lapic_base(void); - -#endif /* !_ACPI_ACPI_H_ */ diff --git a/sys/include/firmware/acpi/tables.h b/sys/include/firmware/acpi/tables.h deleted file mode 100644 index 32fef09..0000000 --- a/sys/include/firmware/acpi/tables.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _ACPI_TABLES_H_ -#define _ACPI_TABLES_H_ - -#include <sys/types.h> -#include <sys/cdefs.h> - -#define OEMID_SIZE 6 - -struct __packed acpi_header { - char signature[4]; /* ASCII signature string */ - uint32_t length; /* Length of table in bytes */ - uint8_t revision; /* Revision of the structure */ - uint8_t checksum; /* Checksum of the header */ - char oemid[OEMID_SIZE]; /* OEM-supplied string that IDs the OEM */ - char oem_table_id[8]; /* OEM-supplied string (used by OEM) */ - uint32_t oem_revision; /* OEM-supplied revision number */ - uint32_t creator_id; /* Vendor ID of creator utility */ - uint32_t creator_revision; /* Revision of creator utility */ -}; - -struct __packed acpi_rsdp { - uint64_t signature; /* RSD PTR */ - uint8_t checksum; /* Structure checksum */ - char oemid[OEMID_SIZE]; /* OEM-supplied string that IDs the OEM */ - uint8_t revision; /* Revision of the structure */ - uint32_t rsdt_addr; /* RSDT physical address */ - - /* Reserved if revision < 2 */ - uint32_t length; /* Length of table in bytes */ - uint64_t xsdt_addr; /* XSDT physical address */ - uint8_t ext_checksum; /* Extended checksum */ - uint8_t reserved[3]; -}; - -/* - * XSDT or RSDT depending - * on what revision the header - * says. - */ -struct __packed acpi_root_sdt { - struct acpi_header hdr; - uint32_t tables[]; -}; - -struct __packed acpi_madt { - struct acpi_header hdr; - uint32_t lapic_addr; - uint32_t flags; -}; - -struct __packed apic_header { - uint8_t type; - uint8_t length; -}; - -struct __packed local_apic { - struct apic_header hdr; - uint8_t processor_id; - uint8_t apic_id; - uint32_t flags; -}; - -struct __packed ioapic { - struct apic_header hdr; - uint8_t ioapic_id; - uint8_t reserved; - uint32_t ioapic_addr; - uint32_t gsi_base; -}; - -struct __packed interrupt_override { - struct apic_header hdr; - uint8_t bus; - uint8_t source; /* IRQ */ - uint32_t interrupt; /* GSI */ - uint16_t flags; -}; - -struct __packed acpi_gas { - uint8_t address_space_id; - uint8_t register_bit_width; - uint8_t register_bit_offset; - uint8_t reserved; - uint64_t address; -}; - -struct __packed hpet { - struct acpi_header hdr; - uint8_t hardware_rev_id; - uint8_t comparator_count : 5; - uint8_t counter_size : 1; - uint8_t reserved : 1; - uint8_t legacy_replacement : 1; - uint16_t pci_vendor_id; - struct acpi_gas gas; - uint8_t hpet_number; - uint16_t minimum_tick; - uint8_t page_protection; -}; - -#endif /* !_ACPI_TABLES_H_ */ diff --git a/sys/include/fs/devfs.h b/sys/include/fs/devfs.h deleted file mode 100644 index 66128ef..0000000 --- a/sys/include/fs/devfs.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _FS_DEVFS_H_ -#define _FS_DEVFS_H_ - -#include <sys/vnode.h> -#include <sys/device.h> - -extern struct vfsops g_devfs_ops; -extern struct vops g_devfs_vops; - -int devfs_add_dev(const char *name, const struct device *dev); -int devfs_get_dev(struct vnode *vp, struct device **res); - -#endif diff --git a/sys/include/fs/initramfs.h b/sys/include/fs/initramfs.h deleted file mode 100644 index 223e962..0000000 --- a/sys/include/fs/initramfs.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _FS_INITRAMFS_H_ -#define _FS_INITRAMFS_H_ - -#include <sys/mount.h> -#include <sys/vnode.h> - -extern struct vfsops g_initramfs_ops; -extern struct vops g_initramfs_vops; - -const char *initramfs_open(const char *path); - -#endif /* !_FS_INITRAMFS_H_ */ diff --git a/sys/include/fs/procfs.h b/sys/include/fs/procfs.h deleted file mode 100644 index ed3a19f..0000000 --- a/sys/include/fs/procfs.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _PROCFS_H_ -#define _PROCFS_H_ - -#include <sys/types.h> -#include <sys/mount.h> -#include <sys/sio.h> - -struct proc_entry { - int(*read)(struct proc_entry *p, struct sio_txn *sio); - int(*write)(struct proc_entry *p, struct sio_txn *sio); -}; - -extern struct vfsops g_procfs_ops; -extern struct vops g_procfs_vops; - -int procfs_add_entry(const char *name, struct proc_entry *entry); -struct proc_entry *procfs_alloc_entry(void); - -/* procfs_subr.c */ -void procfs_populate(void); - -#endif /* !_PROCFS_H_ */ diff --git a/sys/include/lib/assert.h b/sys/include/lib/assert.h deleted file mode 100644 index 78ebe05..0000000 --- a/sys/include/lib/assert.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _LIB_ASSERT_H_ -#define _LIB_ASSERT_H_ - -#include <sys/panic.h> -#include <sys/types.h> - -#define __assert(condition) \ - if ((uintptr_t)(condition) == 0) { \ - panic("Assert \"%s\" failed (%s() at %s:%d)\n", #condition, \ - __func__, __FILE__, __LINE__); \ - } - -#endif /* !_LIB_ASSERT_H_ */ diff --git a/sys/include/lib/bitmap.h b/sys/include/lib/bitmap.h deleted file mode 100644 index da900a2..0000000 --- a/sys/include/lib/bitmap.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _LIB_BITMAP_H_ -#define _LIB_BITMAP_H_ - -#include <sys/types.h> -#include <sys/cdefs.h> - -typedef uint8_t *bitmap_t; - -static inline void -bitmap_set_bit(bitmap_t bitmap, size_t bit) -{ - bitmap[bit / 8] |= __BIT(bit % 8); -} - -static inline void -bitmap_unset_bit(bitmap_t bitmap, size_t bit) -{ - bitmap[bit / 8] &= ~(__BIT(bit % 8)); -} - -static inline bool -bitmap_test_bit(bitmap_t bitmap, size_t bit) -{ - return __TEST(bitmap[bit / 8], __BIT(bit % 8)); -} - -#endif /* !_LIB_BITMAP_H_ */ diff --git a/sys/include/lib/logo.h b/sys/include/lib/logo.h deleted file mode 100644 index c33d3d2..0000000 --- a/sys/include/lib/logo.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include <sys/types.h> -#include <sys/syslog.h> - -#define COPYRIGHT "Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team." - -#define PRINT_LOGO() \ - kprintf(OMIT_TIMESTAMP "%s v%s\n\n", g_logo, HYRA_VERSION); \ - kprintf(OMIT_TIMESTAMP "\t%s\n\n", COPYRIGHT); - -extern uint8_t g_logo[]; diff --git a/sys/include/lib/stdarg.h b/sys/include/lib/stdarg.h deleted file mode 100644 index 5a3d67d..0000000 --- a/sys/include/lib/stdarg.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _LIB_STDARG_H_ -#define _LIB_STDARG_H_ - -#ifndef __GNUC_VA_LIST -#define __GNUC_VA_LIST -typedef __builtin_va_list __gnuc_va_list; -#endif /* __GNUC_VA_LIST */ - -typedef __gnuc_va_list va_list; - -#define va_start(ap, last) __builtin_va_start((ap), last) -#define va_end(ap) __builtin_va_end((ap)) -#define va_arg(ap, type) __builtin_va_arg((ap), type) - -#endif /* !_LIB_STDARG_H_ */ diff --git a/sys/include/lib/string.h b/sys/include/lib/string.h deleted file mode 100644 index f4ee93d..0000000 --- a/sys/include/lib/string.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _LIB_STRING_H_ -#define _LIB_STRING_H_ - -#include <sys/types.h> -#include <stdarg.h> - -size_t strlen(const char *s); -char *itoa(int64_t value, char *buf, int base); -void *memmove(void *s1, const void *s2, size_t n); -void *memcpy(void *dest, const void *src, size_t n); -void *memcpy32(void *dest, const void *src, size_t n); -void *memset(void *s, int c, size_t n); -void *memset64(void *s, int c, size_t n); -int memcmp(const void *s1, const void *s2, size_t n); -int strcmp(const char *s1, const char *s2); -int vsnprintf(char *s, size_t size, const char *fmt, va_list ap); -int snprintf(char *s, size_t size, const char *fmt, ...); - -#endif /* !_LIB_STRING_H_ */ diff --git a/sys/include/lib/sysfont.h b/sys/include/lib/sysfont.h deleted file mode 100644 index 62b4ec0..0000000 --- a/sys/include/lib/sysfont.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _LIB_TTY_FONT_H_ -#define _LIB_TTY_FONT_H_ - -#include <sys/types.h> - -#define FONT_WIDTH 8 -#define FONT_HEIGHT 16 - -extern const uint8_t DEFAULT_FONT_DATA[]; - -#endif /* !_LIB_TTY_FONT_H_ */ diff --git a/sys/include/sys/ascii.h b/sys/include/sys/ascii.h deleted file mode 100644 index 2421c8c..0000000 --- a/sys/include/sys/ascii.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_ASCII_H_ -#define _SYS_ASCII_H_ - -#define ASCII_NUL 0x00 /* Nul */ -#define ASCII_BEL 0x07 /* Bell */ -#define ASCII_BS 0x08 /* Backspace */ -#define ASCII_HT 0x09 /* Horizontal tab */ -#define ASCII_LF 0x0A /* Line feed */ -#define ASCII_VT 0x0B /* Vertical tab */ -#define ASCII_FF 0x0C /* Form feed */ -#define ASCII_CR 0x0D /* Carriage return */ -#define ASCII_SO 0x0E /* Shift out */ -#define ASCII_SI 0x0F /* Shift in */ -#define ASCII_ESC 0x1B /* Escape */ - -#endif diff --git a/sys/include/sys/cdefs.h b/sys/include/sys/cdefs.h deleted file mode 100644 index 110205b..0000000 --- a/sys/include/sys/cdefs.h +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_CDEFS_H_ -#define _SYS_CDEFS_H_ - -#if !defined(__ASSEMBLER__) - -/* Misc helpers */ -#define __attr(x) __attribute__((x)) -#define __weak __attr(weak) -#define __used __attr(used) -#define __naked __attr(naked) -#define __noreturn __attr(noreturn) - -#define __likely(x) __builtin_expect(!!(x), 1) -#define __unlikely(x) __builtin_expect(!!(x), 0) - -/* Wrapper for inline asm */ -#define __ASMV __asm__ __volatile__ - -/* Pack a structure */ -#define __packed __attribute__((__packed__)) - -/* Align by `n` */ -#define __aligned(n) __attribute__((__aligned__(n))) - -/* - * Align to a cacheline-boundary which is - * typically 64 bytes. - * - * XXX: Should probably deal with the case of the - * cacheline alignment boundary not being 64 bytes. - */ -#define __cacheline_aligned __aligned(64) - -/* - * Memory barrier, ensure compiler doesn't reorder - * memory accesses. - */ -#define __mem_barrier() __ASMV("" ::: "memory") - -/* - * To be used when an empty body is required like: - * - * #ifdef DEBUG - * #define dprintf(a) printf(a) - * #else - * #define dprintf(a) __nothing - * #endif - */ -#define __nothing ((void)0) - -/* __BIT(n): Set nth bit, where __BIT(0) == 0x1 */ -#define __BIT(n) (1ULL << n) - -/* MASK(n): Sets first n bits, where __MASK(2) == 0b11 */ -#define __MASK(n) (__BIT(n) - 1) - -/* Max/min helpers */ -#define __MIN(a, b) ((a <= b) ? (a) : (b)) -#define __MAX(a, b) ((a >= b) ? (a) : (b)) - -/* Aligns up/down a value */ -#define __ALIGN_DOWN(value, align) ((value) & ~((align)-1)) -#define __ALIGN_UP(value, align) (((value) + (align)-1) & ~((align)-1)) - -/* Rounds up and divides */ -#define __DIV_ROUNDUP(value, div) __extension__ ({ \ - __auto_type __val = value; \ - __auto_type __div = div; \ - (__val + (__div - 1)) / __div; \ -}) - -/* Find least significant bit that is set */ -#define __LOWEST_SET_BIT(mask) ((((mask) - 1) & (mask)) ^ (mask)) - -/* Extract value with `mask` from `x` */ -#define __SHIFTOUT(x, mask) (((x) & (mask)) / __LOWEST_SET_BIT(mask)) - -/* Test if bits are set, where __TEST(0b1111, 0xF) == 1 */ -#define __TEST(a, mask) (__SHIFTOUT(a, mask) != 0) - -/* Return the number of elements within an array */ -#define __ARRAY_COUNT(x) (sizeof(x) / sizeof(x[0])) - -/* Suppress `variable set but not used' warnings */ -#define __USE(x) ((void)(x)) - -/* A cleaner wrapper over _Static_assert() */ -#define __STATIC_ASSERT _Static_assert - -/* Computes 2^x i.e 2 to the power of 'x' */ -#define __POW2(x) (1ULL << x) - -/* Combine two 8-bit values into a 16-bit value */ -#define __COMBINE8(HI, LO) ((uint16_t)((uint16_t)HI << 8) | LO) - -/* Combine two 16-bit values into a 32-bit value */ -#define __COMBINE16(HI, LO) ((uint32_t)((uint32_t)HI << 16) | LO) - -/* Combine two 32-bit values into a 64-bit value */ -#define __COMBINE32(HI, LO) ((uint64_t)((uint64_t)HI << 32) | LO) - -/* - * Used to give metadata to - * a specific module. Example - * metadata string: - * - * $Hyra$: module.c, Programmer Bob, A module that does stuff and things - * ~~~~~~ ~~~~~~~~ ~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * Cookie; Module Author of this A short description - * always name module - * first - * - * Example usage: - * - * __KERNEL_META("$Hyra$: module.c, Programmer Bob, " - * "A module that does stuff and things"); - * - * The above is the preferred style for this - * macro. - */ -#define __KERNEL_META(meta_str) \ - __asm__(".section .meta.note\n" \ - ".align 4\n" \ - ".string \"" meta_str "\"\n" \ - ".previous" \ - ) - -#define __MODULE_NAME(name) \ - __used static const char *__THIS_MODULE = name - -/* - * Attempts to call a __weak function. Does nothing - * if routine not implemented. - */ -#define __TRY_CALL(routine, ...) \ - if (routine != NULL) routine(__VA_ARGS__) - -#else - -/* - * XXX: Will work; however, maybe move this?? - */ -#if defined(__x86_64__) -.macro __KERNEL_META meta_str - .section .meta.note - .align 4 - .string "\meta_str" - .previous -.endm -#endif /* defined(__x86_64__) */ - -#endif /* !defined(__ASSEMBLER__) */ -#endif /* !_SYS_CDEFS_H_ */ diff --git a/sys/include/sys/cpu.h b/sys/include/sys/cpu.h deleted file mode 100644 index f22cba4..0000000 --- a/sys/include/sys/cpu.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_CPU_H_ -#define _SYS_CPU_H_ - -#include <machine/cpu.h> - -#define cpu_index(ci) ci->idx - -size_t cpu_count(void); -void cpu_attach(struct cpu_info *ci); -struct cpu_info *cpu_get(size_t i); - -#endif /* !_SYS_CPU_H_ */ diff --git a/sys/include/sys/device.h b/sys/include/sys/device.h deleted file mode 100644 index 1bca4a8..0000000 --- a/sys/include/sys/device.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_DEVICE_H_ -#define _SYS_DEVICE_H_ - -#include <sys/sio.h> -#include <sys/queue.h> -#include <sys/types.h> -#include <string.h> -#include <vm/dynalloc.h> - -struct device { - dev_t major, minor; - size_t blocksize; - int(*write)(struct device *dev, struct sio_txn *sio); - int(*read)(struct device *dev, struct sio_txn *sio); - int(*ioctl)(struct device *dev, uint32_t cmd, uintptr_t arg); - int(*open)(struct device *dev); - int(*close)(struct device *dev); - paddr_t(*mmap)(struct device *dev, off_t off, vm_prot_t prot); - TAILQ_ENTRY(device) link; -}; - -static inline struct device * -device_alloc(void) -{ - struct device *dev; - - dev = dynalloc(sizeof(struct device)); - if (dev == NULL) - return dev; - - memset(dev, 0, sizeof(struct device)); - return dev; -} - -struct device *device_fetch(dev_t major, dev_t minor); -dev_t device_alloc_major(void); -dev_t device_create(struct device *dev, dev_t major, dev_t minor); - -#endif diff --git a/sys/include/sys/driver.h b/sys/include/sys/driver.h deleted file mode 100644 index 415f4e2..0000000 --- a/sys/include/sys/driver.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_DRIVER_H_ -#define _SYS_DRIVER_H_ - -#include <sys/cdefs.h> - -#if defined(_KERNEL) - -struct driver { - int(*init)(void); -}; - -extern char __drivers_init_start[]; -extern char __drivers_init_end[]; - -#define DRIVER_EXPORT(INIT) \ - __attribute__((used, section(".drivers"))) \ - static struct driver __driver_desc = { \ - .init = INIT, \ - } - -#define DRIVERS_INIT() \ - for (struct driver *__d = (struct driver *)__drivers_init_start; \ - (uintptr_t)__d < (uintptr_t)__drivers_init_end; ++__d) \ - { \ - __d->init(); \ - } -#endif -#endif /* !_SYS_DRIVER_H_ */ diff --git a/sys/include/sys/elf.h b/sys/include/sys/elf.h deleted file mode 100644 index af2d65a..0000000 --- a/sys/include/sys/elf.h +++ /dev/null @@ -1,499 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_ELF_H_ -#define _SYS_ELF_H_ - -#include <sys/types.h> - -/* Type for a 16-bit quantity. */ -typedef uint16_t Elf32_Half; -typedef uint16_t Elf64_Half; - -/* Types for signed and unsigned 32-bit quantities. */ -typedef uint32_t Elf32_Word; -typedef int32_t Elf32_Sword; -typedef uint32_t Elf64_Word; -typedef int32_t Elf64_Sword; - -/* Types for signed and unsigned 64-bit quantities. */ -typedef uint64_t Elf32_Xword; -typedef int64_t Elf32_Sxword; -typedef uint64_t Elf64_Xword; -typedef int64_t Elf64_Sxword; - -/* Type of addresses. */ -typedef uint32_t Elf32_Addr; -typedef uint64_t Elf64_Addr; - -/* Type of file offsets. */ -typedef uint32_t Elf32_Off; -typedef uint64_t Elf64_Off; - -/* Type for section indices, which are 16-bit quantities. */ -typedef uint16_t Elf32_Section; -typedef uint16_t Elf64_Section; - -/* Type for version symbol information. */ -typedef Elf32_Half Elf32_Versym; -typedef Elf64_Half Elf64_Versym; - -#define EI_MAG0 0 /* File identification byte 0 index */ -#define ELFMAG0 0x7f /* Magic number byte 0 */ - -#define EI_MAG1 1 /* File identification byte 1 index */ -#define ELFMAG1 'E' /* Magic number byte 1 */ - -#define EI_MAG2 2 /* File identification byte 2 index */ -#define ELFMAG2 'L' /* Magic number byte 2 */ - -#define EI_MAG3 3 /* File identification byte 3 index */ -#define ELFMAG3 'F' /* Magic number byte 3 */ - -/* Conglomeration of the identification bytes, for easy testing as a word. */ -#define ELFMAG "\177ELF" -#define SELFMAG 4 - -#define EI_CLASS 4 /* File class byte index */ -#define ELFCLASSNONE 0 /* Invalid class */ -#define ELFCLASS32 1 /* 32-bit objects */ -#define ELFCLASS64 2 /* 64-bit objects */ -#define ELFCLASSNUM 3 - -#define EI_DATA 5 /* Data encoding byte index */ -#define ELFDATANONE 0 /* Invalid data encoding */ -#define ELFDATA2LSB 1 /* 2's complement, little endian */ -#define ELFDATA2MSB 2 /* 2's complement, big endian */ -#define ELFDATANUM 3 - -#define EI_VERSION 6 /* File version byte index */ - /* Value must be EV_CURRENT */ - -#define EI_OSABI 7 /* OS ABI identification */ -#define ELFOSABI_NONE 0 /* UNIX System V ABI */ -#define ELFOSABI_SYSV 0 /* Alias. */ -#define ELFOSABI_HPUX 1 /* HP-UX */ -#define ELFOSABI_NETBSD 2 /* NetBSD. */ -#define ELFOSABI_GNU 3 /* Object uses GNU ELF extensions. */ -#define ELFOSABI_LINUX ELFOSABI_GNU /* Compatibility alias. */ -#define ELFOSABI_SOLARIS 6 /* Sun Solaris. */ -#define ELFOSABI_AIX 7 /* IBM AIX. */ -#define ELFOSABI_IRIX 8 /* SGI Irix. */ -#define ELFOSABI_FREEBSD 9 /* FreeBSD. */ -#define ELFOSABI_TRU64 10 /* Compaq TRU64 UNIX. */ -#define ELFOSABI_MODESTO 11 /* Novell Modesto. */ -#define ELFOSABI_OPENBSD 12 /* OpenBSD. */ -#define ELFOSABI_ARM_AEABI 64 /* ARM EABI */ -#define ELFOSABI_ARM 97 /* ARM */ -#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */ - -#define EI_ABIVERSION 8 /* ABI version */ - -#define EI_PAD 9 /* Byte index of padding bytes */ - -/* Legal values for e_type (object file type). */ - -#define ET_NONE 0 /* No file type */ -#define ET_REL 1 /* Relocatable file */ -#define ET_EXEC 2 /* Executable file */ -#define ET_DYN 3 /* Shared object file */ -#define ET_CORE 4 /* Core file */ -#define ET_NUM 5 /* Number of defined types */ -#define ET_LOOS 0xfe00 /* OS-specific range start */ -#define ET_HIOS 0xfeff /* OS-specific range end */ -#define ET_LOPROC 0xff00 /* Processor-specific range start */ -#define ET_HIPROC 0xffff /* Processor-specific range end */ - -/* Legal values for e_machine (architecture). */ - -#define EM_NONE 0 /* No machine */ -#define EM_M32 1 /* AT&T WE 32100 */ -#define EM_SPARC 2 /* SUN SPARC */ -#define EM_386 3 /* Intel 80386 */ -#define EM_68K 4 /* Motorola m68k family */ -#define EM_88K 5 /* Motorola m88k family */ -#define EM_IAMCU 6 /* Intel MCU */ -#define EM_860 7 /* Intel 80860 */ -#define EM_MIPS 8 /* MIPS R3000 big-endian */ -#define EM_S370 9 /* IBM System/370 */ -#define EM_MIPS_RS3_LE 10 /* MIPS R3000 little-endian */ - /* reserved 11-14 */ -#define EM_PARISC 15 /* HPPA */ - /* reserved 16 */ -#define EM_VPP500 17 /* Fujitsu VPP500 */ -#define EM_SPARC32PLUS 18 /* Sun's "v8plus" */ -#define EM_960 19 /* Intel 80960 */ -#define EM_PPC 20 /* PowerPC */ -#define EM_PPC64 21 /* PowerPC 64-bit */ -#define EM_S390 22 /* IBM S390 */ -#define EM_SPU 23 /* IBM SPU/SPC */ - /* reserved 24-35 */ -#define EM_V800 36 /* NEC V800 series */ -#define EM_FR20 37 /* Fujitsu FR20 */ -#define EM_RH32 38 /* TRW RH-32 */ -#define EM_RCE 39 /* Motorola RCE */ -#define EM_ARM 40 /* ARM */ -#define EM_FAKE_ALPHA 41 /* Digital Alpha */ -#define EM_SH 42 /* Hitachi SH */ -#define EM_SPARCV9 43 /* SPARC v9 64-bit */ -#define EM_TRICORE 44 /* Siemens Tricore */ -#define EM_ARC 45 /* Argonaut RISC Core */ -#define EM_H8_300 46 /* Hitachi H8/300 */ -#define EM_H8_300H 47 /* Hitachi H8/300H */ -#define EM_H8S 48 /* Hitachi H8S */ -#define EM_H8_500 49 /* Hitachi H8/500 */ -#define EM_IA_64 50 /* Intel Merced */ -#define EM_MIPS_X 51 /* Stanford MIPS-X */ -#define EM_COLDFIRE 52 /* Motorola Coldfire */ -#define EM_68HC12 53 /* Motorola M68HC12 */ -#define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator */ -#define EM_PCP 55 /* Siemens PCP */ -#define EM_NCPU 56 /* Sony nCPU embeeded RISC */ -#define EM_NDR1 57 /* Denso NDR1 microprocessor */ -#define EM_STARCORE 58 /* Motorola Start*Core processor */ -#define EM_ME16 59 /* Toyota ME16 processor */ -#define EM_ST100 60 /* STMicroelectronic ST100 processor */ -#define EM_TINYJ 61 /* Advanced Logic Corp. Tinyj emb.fam */ -#define EM_X86_64 62 /* AMD x86-64 architecture */ -#define EM_PDSP 63 /* Sony DSP Processor */ -#define EM_PDP10 64 /* Digital PDP-10 */ -#define EM_PDP11 65 /* Digital PDP-11 */ -#define EM_FX66 66 /* Siemens FX66 microcontroller */ -#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 mc */ -#define EM_ST7 68 /* STmicroelectronics ST7 8 bit mc */ -#define EM_68HC16 69 /* Motorola MC68HC16 microcontroller */ -#define EM_68HC11 70 /* Motorola MC68HC11 microcontroller */ -#define EM_68HC08 71 /* Motorola MC68HC08 microcontroller */ -#define EM_68HC05 72 /* Motorola MC68HC05 microcontroller */ -#define EM_SVX 73 /* Silicon Graphics SVx */ -#define EM_ST19 74 /* STMicroelectronics ST19 8 bit mc */ -#define EM_VAX 75 /* Digital VAX */ -#define EM_CRIS 76 /* Axis Communications 32-bit emb.proc */ -#define EM_JAVELIN 77 /* Infineon Technologies 32-bit emb.proc */ -#define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor */ -#define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor */ -#define EM_MMIX 80 /* Donald Knuth's educational 64-bit proc */ -#define EM_HUANY 81 /* Harvard University machine-independent object files */ -#define EM_PRISM 82 /* SiTera Prism */ -#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */ -#define EM_FR30 84 /* Fujitsu FR30 */ -#define EM_D10V 85 /* Mitsubishi D10V */ -#define EM_D30V 86 /* Mitsubishi D30V */ -#define EM_V850 87 /* NEC v850 */ -#define EM_M32R 88 /* Mitsubishi M32R */ -#define EM_MN10300 89 /* Matsushita MN10300 */ -#define EM_MN10200 90 /* Matsushita MN10200 */ -#define EM_PJ 91 /* picoJava */ -#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */ -#define EM_ARC_COMPACT 93 /* ARC International ARCompact */ -#define EM_XTENSA 94 /* Tensilica Xtensa Architecture */ -#define EM_VIDEOCORE 95 /* Alphamosaic VideoCore */ -#define EM_TMM_GPP 96 /* Thompson Multimedia General Purpose Proc */ -#define EM_NS32K 97 /* National Semi. 32000 */ -#define EM_TPC 98 /* Tenor Network TPC */ -#define EM_SNP1K 99 /* Trebia SNP 1000 */ -#define EM_ST200 100 /* STMicroelectronics ST200 */ -#define EM_IP2K 101 /* Ubicom IP2xxx */ -#define EM_MAX 102 /* MAX processor */ -#define EM_CR 103 /* National Semi. CompactRISC */ -#define EM_F2MC16 104 /* Fujitsu F2MC16 */ -#define EM_MSP430 105 /* Texas Instruments msp430 */ -#define EM_BLACKFIN 106 /* Analog Devices Blackfin DSP */ -#define EM_SE_C33 107 /* Seiko Epson S1C33 family */ -#define EM_SEP 108 /* Sharp embedded microprocessor */ -#define EM_ARCA 109 /* Arca RISC */ -#define EM_UNICORE 110 /* PKU-Unity & MPRC Peking Uni. mc series */ -#define EM_EXCESS 111 /* eXcess configurable cpu */ -#define EM_DXP 112 /* Icera Semi. Deep Execution Processor */ -#define EM_ALTERA_NIOS2 113 /* Altera Nios II */ -#define EM_CRX 114 /* National Semi. CompactRISC CRX */ -#define EM_XGATE 115 /* Motorola XGATE */ -#define EM_C166 116 /* Infineon C16x/XC16x */ -#define EM_M16C 117 /* Renesas M16C */ -#define EM_DSPIC30F 118 /* Microchip Technology dsPIC30F */ -#define EM_CE 119 /* Freescale Communication Engine RISC */ -#define EM_M32C 120 /* Renesas M32C */ - /* reserved 121-130 */ -#define EM_TSK3000 131 /* Altium TSK3000 */ -#define EM_RS08 132 /* Freescale RS08 */ -#define EM_SHARC 133 /* Analog Devices SHARC family */ -#define EM_ECOG2 134 /* Cyan Technology eCOG2 */ -#define EM_SCORE7 135 /* Sunplus S+core7 RISC */ -#define EM_DSP24 136 /* New Japan Radio (NJR) 24-bit DSP */ -#define EM_VIDEOCORE3 137 /* Broadcom VideoCore III */ -#define EM_LATTICEMICO32 138 /* RISC for Lattice FPGA */ -#define EM_SE_C17 139 /* Seiko Epson C17 */ -#define EM_TI_C6000 140 /* Texas Instruments TMS320C6000 DSP */ -#define EM_TI_C2000 141 /* Texas Instruments TMS320C2000 DSP */ -#define EM_TI_C5500 142 /* Texas Instruments TMS320C55x DSP */ -#define EM_TI_ARP32 143 /* Texas Instruments App. Specific RISC */ -#define EM_TI_PRU 144 /* Texas Instruments Prog. Realtime Unit */ - /* reserved 145-159 */ -#define EM_MMDSP_PLUS 160 /* STMicroelectronics 64bit VLIW DSP */ -#define EM_CYPRESS_M8C 161 /* Cypress M8C */ -#define EM_R32C 162 /* Renesas R32C */ -#define EM_TRIMEDIA 163 /* NXP Semi. TriMedia */ -#define EM_QDSP6 164 /* QUALCOMM DSP6 */ -#define EM_8051 165 /* Intel 8051 and variants */ -#define EM_STXP7X 166 /* STMicroelectronics STxP7x */ -#define EM_NDS32 167 /* Andes Tech. compact code emb. RISC */ -#define EM_ECOG1X 168 /* Cyan Technology eCOG1X */ -#define EM_MAXQ30 169 /* Dallas Semi. MAXQ30 mc */ -#define EM_XIMO16 170 /* New Japan Radio (NJR) 16-bit DSP */ -#define EM_MANIK 171 /* M2000 Reconfigurable RISC */ -#define EM_CRAYNV2 172 /* Cray NV2 vector architecture */ -#define EM_RX 173 /* Renesas RX */ -#define EM_METAG 174 /* Imagination Tech. META */ -#define EM_MCST_ELBRUS 175 /* MCST Elbrus */ -#define EM_ECOG16 176 /* Cyan Technology eCOG16 */ -#define EM_CR16 177 /* National Semi. CompactRISC CR16 */ -#define EM_ETPU 178 /* Freescale Extended Time Processing Unit */ -#define EM_SLE9X 179 /* Infineon Tech. SLE9X */ -#define EM_L10M 180 /* Intel L10M */ -#define EM_K10M 181 /* Intel K10M */ - /* reserved 182 */ -#define EM_AARCH64 183 /* ARM AARCH64 */ - /* reserved 184 */ -#define EM_AVR32 185 /* Amtel 32-bit microprocessor */ -#define EM_STM8 186 /* STMicroelectronics STM8 */ -#define EM_TILE64 187 /* Tileta TILE64 */ -#define EM_TILEPRO 188 /* Tilera TILEPro */ -#define EM_MICROBLAZE 189 /* Xilinx MicroBlaze */ -#define EM_CUDA 190 /* NVIDIA CUDA */ -#define EM_TILEGX 191 /* Tilera TILE-Gx */ -#define EM_CLOUDSHIELD 192 /* CloudShield */ -#define EM_COREA_1ST 193 /* KIPO-KAIST Core-A 1st gen. */ -#define EM_COREA_2ND 194 /* KIPO-KAIST Core-A 2nd gen. */ -#define EM_ARC_COMPACT2 195 /* Synopsys ARCompact V2 */ -#define EM_OPEN8 196 /* Open8 RISC */ -#define EM_RL78 197 /* Renesas RL78 */ -#define EM_VIDEOCORE5 198 /* Broadcom VideoCore V */ -#define EM_78KOR 199 /* Renesas 78KOR */ -#define EM_56800EX 200 /* Freescale 56800EX DSC */ -#define EM_BA1 201 /* Beyond BA1 */ -#define EM_BA2 202 /* Beyond BA2 */ -#define EM_XCORE 203 /* XMOS xCORE */ -#define EM_MCHP_PIC 204 /* Microchip 8-bit PIC(r) */ - /* reserved 205-209 */ -#define EM_KM32 210 /* KM211 KM32 */ -#define EM_KMX32 211 /* KM211 KMX32 */ -#define EM_EMX16 212 /* KM211 KMX16 */ -#define EM_EMX8 213 /* KM211 KMX8 */ -#define EM_KVARC 214 /* KM211 KVARC */ -#define EM_CDP 215 /* Paneve CDP */ -#define EM_COGE 216 /* Cognitive Smart Memory Processor */ -#define EM_COOL 217 /* Bluechip CoolEngine */ -#define EM_NORC 218 /* Nanoradio Optimized RISC */ -#define EM_CSR_KALIMBA 219 /* CSR Kalimba */ -#define EM_Z80 220 /* Zilog Z80 */ -#define EM_VISIUM 221 /* Controls and Data Services VISIUMcore */ -#define EM_FT32 222 /* FTDI Chip FT32 */ -#define EM_MOXIE 223 /* Moxie processor */ -#define EM_AMDGPU 224 /* AMD GPU */ - /* reserved 225-242 */ -#define EM_RISCV 243 /* RISC-V */ - -#define EM_BPF 247 /* Linux BPF -- in-kernel virtual machine */ - -#define EM_NUM 248 - -/* Old spellings/synonyms. */ - -#define EM_ARC_A5 EM_ARC_COMPACT - -/* If it is necessary to assign new unofficial EM_* values, please - pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the - chances of collision with official or non-GNU unofficial values. */ - -#define EM_ALPHA 0x9026 - -/* Legal values for e_version (version). */ - -#define EV_NONE 0 /* Invalid ELF version */ -#define EV_CURRENT 1 /* Current version */ -#define EV_NUM 2 - -#define EI_NIDENT (16) - -#define PT_NULL 0 /* Program header table entry unused */ -#define PT_LOAD 1 /* Loadable program segment */ -#define PT_DYNAMIC 2 /* Dynamic linking information */ -#define PT_INTERP 3 /* Program interpreter */ -#define PT_NOTE 4 /* Auxiliary information */ -#define PT_SHLIB 5 /* Reserved */ -#define PT_PHDR 6 /* Entry for header table itself */ -#define PT_TLS 7 /* Thread-local storage segment */ -#define PT_NUM 8 /* Number of defined types */ -#define PT_LOOS 0x60000000 /* Start of OS-specific */ -#define PT_GNU_EH_FRAME 0x6474e550 /* GCC .eh_frame_hdr segment */ -#define PT_GNU_STACK 0x6474e551 /* Indicates stack executability */ -#define PT_GNU_RELRO 0x6474e552 /* Read-only after relocation */ -#define PT_LOSUNW 0x6ffffffa -#define PT_SUNWBSS 0x6ffffffa /* Sun Specific segment */ -#define PT_SUNWSTACK 0x6ffffffb /* Stack segment */ -#define PT_HISUNW 0x6fffffff -#define PT_HIOS 0x6fffffff /* End of OS-specific */ -#define PT_LOPROC 0x70000000 /* Start of processor-specific */ -#define PT_HIPROC 0x7fffffff /* End of processor-specific */ - -/* Legal values for p_flags (segment flags). */ - -#define PF_X (1 << 0) /* Segment is executable */ -#define PF_W (1 << 1) /* Segment is writable */ -#define PF_R (1 << 2) /* Segment is readable */ -#define PF_MASKOS 0x0ff00000 /* OS-specific */ -#define PF_MASKPROC 0xf0000000 /* Processor-specific */ - -/* Legal values for note segment descriptor types for core files. */ - -#define NT_PRSTATUS 1 /* Contains copy of prstatus struct */ -#define NT_PRFPREG 2 /* Contains copy of fpregset - struct. */ -#define NT_FPREGSET 2 /* Contains copy of fpregset struct */ -#define NT_PRPSINFO 3 /* Contains copy of prpsinfo struct */ -#define NT_PRXREG 4 /* Contains copy of prxregset struct */ -#define NT_TASKSTRUCT 4 /* Contains copy of task structure */ -#define NT_PLATFORM 5 /* String from sysinfo(SI_PLATFORM) */ -#define NT_AUXV 6 /* Contains copy of auxv array */ -#define NT_GWINDOWS 7 /* Contains copy of gwindows struct */ -#define NT_ASRS 8 /* Contains copy of asrset struct */ -#define NT_PSTATUS 10 /* Contains copy of pstatus struct */ -#define NT_PSINFO 13 /* Contains copy of psinfo struct */ -#define NT_PRCRED 14 /* Contains copy of prcred struct */ -#define NT_UTSNAME 15 /* Contains copy of utsname struct */ -#define NT_LWPSTATUS 16 /* Contains copy of lwpstatus struct */ -#define NT_LWPSINFO 17 /* Contains copy of lwpinfo struct */ -#define NT_PRFPXREG 20 /* Contains copy of fprxregset struct */ -#define NT_SIGINFO 0x53494749 /* Contains copy of siginfo_t, - size might increase */ -#define NT_FILE 0x46494c45 /* Contains information about mapped - files */ -#define NT_PRXFPREG 0x46e62b7f /* Contains copy of user_fxsr_struct */ -#define NT_PPC_VMX 0x100 /* PowerPC Altivec/VMX registers */ -#define NT_PPC_SPE 0x101 /* PowerPC SPE/EVR registers */ -#define NT_PPC_VSX 0x102 /* PowerPC VSX registers */ -#define NT_PPC_TAR 0x103 /* Target Address Register */ -#define NT_PPC_PPR 0x104 /* Program Priority Register */ -#define NT_PPC_DSCR 0x105 /* Data Stream Control Register */ -#define NT_PPC_EBB 0x106 /* Event Based Branch Registers */ -#define NT_PPC_PMU 0x107 /* Performance Monitor Registers */ -#define NT_PPC_TM_CGPR 0x108 /* TM checkpointed GPR Registers */ -#define NT_PPC_TM_CFPR 0x109 /* TM checkpointed FPR Registers */ -#define NT_PPC_TM_CVMX 0x10a /* TM checkpointed VMX Registers */ -#define NT_PPC_TM_CVSX 0x10b /* TM checkpointed VSX Registers */ -#define NT_PPC_TM_SPR 0x10c /* TM Special Purpose Registers */ -#define NT_PPC_TM_CTAR 0x10d /* TM checkpointed Target Address - Register */ -#define NT_PPC_TM_CPPR 0x10e /* TM checkpointed Program Priority - Register */ -#define NT_PPC_TM_CDSCR 0x10f /* TM checkpointed Data Stream Control - Register */ -#define NT_PPC_PKEY 0x110 /* Memory Protection Keys - registers. */ -#define NT_386_TLS 0x200 /* i386 TLS slots (struct user_desc) */ -#define NT_386_IOPERM 0x201 /* x86 io permission bitmap (1=deny) */ -#define NT_X86_XSTATE 0x202 /* x86 extended state using xsave */ -#define NT_S390_HIGH_GPRS 0x300 /* s390 upper register halves */ -#define NT_S390_TIMER 0x301 /* s390 timer register */ -#define NT_S390_TODCMP 0x302 /* s390 TOD clock comparator register */ -#define NT_S390_TODPREG 0x303 /* s390 TOD programmable register */ -#define NT_S390_CTRS 0x304 /* s390 control registers */ -#define NT_S390_PREFIX 0x305 /* s390 prefix register */ -#define NT_S390_LAST_BREAK 0x306 /* s390 breaking event address */ -#define NT_S390_SYSTEM_CALL 0x307 /* s390 system call restart data */ -#define NT_S390_TDB 0x308 /* s390 transaction diagnostic block */ -#define NT_S390_VXRS_LOW 0x309 /* s390 vector registers 0-15 - upper half. */ -#define NT_S390_VXRS_HIGH 0x30a /* s390 vector registers 16-31. */ -#define NT_S390_GS_CB 0x30b /* s390 guarded storage registers. */ -#define NT_S390_GS_BC 0x30c /* s390 guarded storage - broadcast control block. */ -#define NT_S390_RI_CB 0x30d /* s390 runtime instrumentation. */ -#define NT_ARM_VFP 0x400 /* ARM VFP/NEON registers */ -#define NT_ARM_TLS 0x401 /* ARM TLS register */ -#define NT_ARM_HW_BREAK 0x402 /* ARM hardware breakpoint registers */ -#define NT_ARM_HW_WATCH 0x403 /* ARM hardware watchpoint registers */ -#define NT_ARM_SYSTEM_CALL 0x404 /* ARM system call number */ -#define NT_ARM_SVE 0x405 /* ARM Scalable Vector Extension - registers */ -#define NT_VMCOREDD 0x700 /* Vmcore Device Dump Note. */ - -/* Legal values for the note segment descriptor types for object files. */ - -#define NT_VERSION 1 /* Contains a version string. */ - -typedef struct -{ - unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */ - Elf64_Half e_type; /* Object file type */ - Elf64_Half e_machine; /* Architecture */ - Elf64_Word e_version; /* Object file version */ - Elf64_Addr e_entry; /* Entry point virtual address */ - Elf64_Off e_phoff; /* Program header table file offset */ - Elf64_Off e_shoff; /* Section header table file offset */ - Elf64_Word e_flags; /* Processor-specific flags */ - Elf64_Half e_ehsize; /* ELF header size in bytes */ - Elf64_Half e_phentsize; /* Program header table entry size */ - Elf64_Half e_phnum; /* Program header table entry count */ - Elf64_Half e_shentsize; /* Section header table entry size */ - Elf64_Half e_shnum; /* Section header table entry count */ - Elf64_Half e_shstrndx; /* Section header string table index */ -} Elf64_Ehdr; - -typedef struct -{ - Elf64_Word p_type; /* Segment type */ - Elf64_Word p_flags; /* Segment flags */ - Elf64_Off p_offset; /* Segment file offset */ - Elf64_Addr p_vaddr; /* Segment virtual address */ - Elf64_Addr p_paddr; /* Segment physical address */ - Elf64_Xword p_filesz; /* Segment size in file */ - Elf64_Xword p_memsz; /* Segment size in memory */ - Elf64_Xword p_align; /* Segment alignment */ -} Elf64_Phdr; - -typedef struct { - Elf64_Addr r_offset; /* Location at which to apply the action */ - Elf64_Xword r_info; /* index and type of relocation */ -} Elf64_Rel; - -typedef struct { - Elf64_Word sh_name; /* Section name, index in string tbl */ - Elf64_Word sh_type; /* Type of section */ - Elf64_Xword sh_flags; /* Miscellaneous section attributes */ - Elf64_Addr sh_addr; /* Section virtual addr at execution */ - Elf64_Off sh_offset; /* Section file offset */ - Elf64_Xword sh_size; /* Size of section in bytes */ - Elf64_Word sh_link; /* Index of another section */ - Elf64_Word sh_info; /* Additional section information */ - Elf64_Xword sh_addralign; /* Section alignment */ - Elf64_Xword sh_entsize; /* Entry size if section holds table */ -} Elf64_Shdr; - -#endif /* _SYS_ELF_H_ */ diff --git a/sys/include/sys/errno.h b/sys/include/sys/errno.h deleted file mode 100644 index a93cf18..0000000 --- a/sys/include/sys/errno.h +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_ERRNO_H_ -#define _SYS_ERRNO_H_ - -#define EXIT_SUCCESS 0 -#define EXIT_FAILURE 1 - -#define EPERM 1 /* Not super-user */ -#define ENOENT 2 /* No such file or directory */ -#define ESRCH 3 /* No such process */ -#define EINTR 4 /* Interrupted system call */ -#define EIO 5 /* I/O error */ -#define ENXIO 6 /* No such device or address */ -#define E2BIG 7 /* Arg list too long */ -#define ENOEXEC 8 /* Exec format error */ -#define EBADF 9 /* Bad file number */ -#define ECHILD 10 /* No children */ -#define EAGAIN 11 /* No more processes */ -#define ENOMEM 12 /* Not enough core */ -#define EACCES 13 /* Permission denied */ -#define EFAULT 14 /* Bad address */ -#define ENOTBLK 15 /* Block device required */ -#define EBUSY 16 /* Mount device busy */ -#define EEXIST 17 /* File exists */ -#define EXDEV 18 /* Cross-device link */ -#define ENODEV 19 /* No such device */ -#define ENOTDIR 20 /* Not a directory */ -#define EISDIR 21 /* Is a directory */ -#define EINVAL 22 /* Invalid argument */ -#define ENFILE 23 /* Too many open files in system */ -#define EMFILE 24 /* Too many open files */ -#define ENOTTY 25 /* Not a typewriter */ -#define ETXTBSY 26 /* Text file busy */ -#define EFBIG 27 /* File too large */ -#define ENOSPC 28 /* No space left on device */ -#define ESPIPE 29 /* Illegal seek */ -#define EROFS 30 /* Read only file system */ -#define EMLINK 31 /* Too many links */ -#define EPIPE 32 /* Broken pipe */ -#define EDOM 33 /* Math arg out of domain of func */ -#define ERANGE 34 /* Math result not representable */ -#define ENOMSG 35 /* No message of desired type */ -#define EIDRM 36 /* Identifier removed */ -#define ECHRNG 37 /* Channel number out of range */ -#define EL2NSYNC 38 /* Level 2 not synchronized */ -#define EL3HLT 39 /* Level 3 halted */ -#define EL3RST 40 /* Level 3 reset */ -#define ELNRNG 41 /* Link number out of range */ -#define EUNATCH 42 /* Protocol driver not attached */ -#define ENOCSI 43 /* No CSI structure available */ -#define EL2HLT 44 /* Level 2 halted */ -#define EDEADLK 45 /* Deadlock condition */ -#define ENOLCK 46 /* No record locks available */ -#define EBADE 50 /* Invalid exchange */ -#define EBADR 51 /* Invalid request descriptor */ -#define EXFULL 52 /* Exchange full */ -#define ENOANO 53 /* No anode */ -#define EBADRQC 54 /* Invalid request code */ -#define EBADSLT 55 /* Invalid slot */ -#define EDEADLOCK 56 /* File locking deadlock error */ -#define EBFONT 57 /* Bad font file fmt */ -#define ENOSTR 60 /* Device not a stream */ -#define ENODATA 61 /* No data (for no delay io) */ -#define ETIME 62 /* Timer expired */ -#define ENOSR 63 /* Out of streams resources */ -#define ENONET 64 /* Machine is not on the network */ -#define ENOPKG 65 /* Package not installed */ -#define EREMOTE 66 /* The object is remote */ -#define ENOLINK 67 /* The link has been severed */ -#define EADV 68 /* Advertise error */ -#define ESRMNT 69 /* Srmount error */ -#define ECOMM 70 /* Communication error on send */ -#define EPROTO 71 /* Protocol error */ -#define EMULTIHOP 74 /* Multihop attempted */ -#define ELBIN 75 /* Inode is remote (not really error) */ -#define EDOTDOT 76 /* Cross mount point (not really error) */ -#define EBADMSG 77 /* Trying to read unreadable message */ -#define EFTYPE 79 /* Inappropriate file type or format */ -#define ENOTUNIQ 80 /* Given log. name not unique */ -#define EBADFD 81 /* f.d. invalid for this operation */ -#define EREMCHG 82 /* Remote address changed */ -#define ELIBACC 83 /* Can't access a needed shared lib */ -#define ELIBBAD 84 /* Accessing a corrupted shared lib */ -#define ELIBSCN 85 /* .lib section in a.out corrupted */ -#define ELIBMAX 86 /* Attempting to link in too many libs */ -#define ELIBEXEC 87 /* Attempting to exec a shared library */ -#define ENOSYS 88 /* Function not implemented */ -#define ENMFILE 89 /* No more files */ -#define ENOTEMPTY 90 /* Directory not empty */ -#define ENAMETOOLONG 91 /* File or path name too long */ -#define ELOOP 92 /* Too many symbolic links */ -#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ -#define EPFNOSUPPORT 96 /* Protocol family not supported */ -#define ECONNRESET 104 /* Connection reset by peer */ -#define ENOBUFS 105 /* No buffer space available */ -#define EAFNOSUPPORT 106 /* Address family not supported by protocol family */ -#define EPROTOTYPE 107 /* Protocol wrong type for socket */ -#define ENOTSOCK 108 /* Socket operation on non-socket */ -#define ENOPROTOOPT 109 /* Protocol not available */ -#define ESHUTDOWN 110 /* Can't send after socket shutdown */ -#define ECONNREFUSED 111 /* Connection refused */ -#define EADDRINUSE 112 /* Address already in use */ -#define ECONNABORTED 113 /* Connection aborted */ -#define ENETUNREACH 114 /* Network is unreachable */ -#define ENETDOWN 115 /* Network interface is not configured */ -#define ETIMEDOUT 116 /* Connection timed out */ -#define EHOSTDOWN 117 /* Host is down */ -#define EHOSTUNREACH 118 /* Host is unreachable */ -#define EINPROGRESS 119 /* Connection already in progress */ -#define EALREADY 120 /* Socket already connected */ -#define EDESTADDRREQ 121 /* Destination address required */ -#define EMSGSIZE 122 /* Message too long */ -#define EPROTONOSUPPORT 123 /* Unknown protocol */ -#define ESOCKTNOSUPPORT 124 /* Socket type not supported */ -#define EADDRNOTAVAIL 125 /* Address not available */ -#define ENETRESET 126 -#define EISCONN 127 /* Socket is already connected */ -#define ENOTCONN 128 /* Socket is not connected */ -#define ETOOMANYREFS 129 -#define EPROCLIM 130 -#define EUSERS 131 -#define EDQUOT 132 -#define ESTALE 133 -#define ENOTSUP 134 /* Not supported */ -#define ENOMEDIUM 135 /* No medium (in tape drive) */ -#define ENOSHARE 136 /* No such host or network path */ -#define ECASECLASH 137 /* Filename exists with different case */ -#define EILSEQ 138 -#define EOVERFLOW 139 /* Value too large for defined data type */ - -#endif diff --git a/sys/include/sys/exec.h b/sys/include/sys/exec.h deleted file mode 100644 index 5832a3f..0000000 --- a/sys/include/sys/exec.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_EXEC_H_ -#define _SYS_EXEC_H_ - -#include <sys/syscall.h> - -uint64_t sys_execv(struct syscall_args *args); - -#endif diff --git a/sys/include/sys/fbdev.h b/sys/include/sys/fbdev.h deleted file mode 100644 index 7308a92..0000000 --- a/sys/include/sys/fbdev.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_FBDEV_H_ -#define _SYS_FBDEV_H_ - -#if defined(_KERNEL) -#include <sys/types.h> -#else -#include <stdint.h> -#endif - -#define FBIOCTL_INFO 0x00000000 - -struct fbdev_info { - uint32_t width; - uint32_t height; - uint32_t pitch; - uint32_t bits_per_pixel; -}; - -#endif diff --git a/sys/include/sys/filedesc.h b/sys/include/sys/filedesc.h deleted file mode 100644 index f2c2778..0000000 --- a/sys/include/sys/filedesc.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_FILEDESC_H_ -#define _SYS_FILEDESC_H_ - -#include <sys/vnode.h> -#include <sys/mutex.h> -#include <sys/syscall.h> -#include <sys/types.h> - -#define O_RDONLY 0x00000 -#define O_WRONLY 0x00001 -#define O_RDWR 0x00002 - -#define SEEK_SET 0 -#define SEEK_CUR 1 -#define SEEK_END 2 - -struct proc; - -struct filedesc { - int fdno; - int oflag; - off_t offset; - bool is_dir; - struct vnode *vnode; - struct mutex lock; -}; - -#if defined(_KERNEL) -int fd_alloc(struct proc *td, struct filedesc **fd_out); -struct filedesc *fd_from_fdnum(const struct proc *td, int fdno); -void fd_close_fdnum(struct proc *td, int fdno); -ssize_t write(int fd, const void *buf, size_t count); -int open(const char *pathname, int oflag); -int read(int fd, void *buf, size_t count); -off_t lseek(int fd, off_t offset, int whence); - -uint64_t sys_write(struct syscall_args *args); -uint64_t sys_open(struct syscall_args *args); -uint64_t sys_close(struct syscall_args *args); -uint64_t sys_read(struct syscall_args *args); -uint64_t sys_lseek(struct syscall_args *args); -#endif -#endif diff --git a/sys/include/sys/intr.h b/sys/include/sys/intr.h deleted file mode 100644 index 0590f87..0000000 --- a/sys/include/sys/intr.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_INTR_H_ -#define _SYS_INTR_H_ - -#if defined(_KERNEL) -#include <sys/types.h> -#include <sys/spinlock.h> -#include <sys/queue.h> - -/* - * Interrupt information - */ -struct intr_info { - struct spinlock lock; - const char *source; - const char *device; - uint8_t affinity; - size_t count; /* Interrupt count */ - TAILQ_ENTRY(intr_info) link; -}; - -struct intr_info *intr_info_alloc(const char *source, const char *dev); -void intr_register(struct intr_info *info); -void intr_init_proc(void); - -#endif /* defined(_KERNEL) */ -#endif /* !_SYS_INTR_H_ */ diff --git a/sys/include/sys/ksyms.h b/sys/include/sys/ksyms.h deleted file mode 100644 index 2862cbc..0000000 --- a/sys/include/sys/ksyms.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_KSYMS_H_ -#define _SYS_KSYMS_H_ - -#include <sys/cdefs.h> - -#if defined(_KERNEL) -struct kernel_symbol { - uint64_t addr; - char* name; -}; - -__weak extern struct kernel_symbol g_ksym_table[]; - -#endif /* defined(_KERNEL) */ -#endif diff --git a/sys/include/sys/limine.h b/sys/include/sys/limine.h deleted file mode 100644 index f26d8c5..0000000 --- a/sys/include/sys/limine.h +++ /dev/null @@ -1,495 +0,0 @@ -/* BSD Zero Clause License */ - -/* Copyright (C) 2022-2023 mintsuki and contributors. - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _LIMINE_H -#define _LIMINE_H 1 - -#ifdef __cplusplus -extern "C" { -#endif - -#include <stdint.h> - -/* Misc */ - -#ifdef LIMINE_NO_POINTERS -# define LIMINE_PTR(TYPE) uint64_t -#else -# define LIMINE_PTR(TYPE) TYPE -#endif - -#ifdef __GNUC__ -# define LIMINE_DEPRECATED __attribute__((__deprecated__)) -# define LIMINE_DEPRECATED_IGNORE_START \ - _Pragma("GCC diagnostic push") \ - _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") -# define LIMINE_DEPRECATED_IGNORE_END \ - _Pragma("GCC diagnostic pop") -#else -# define LIMINE_DEPRECATED -# define LIMINE_DEPRECATED_IGNORE_START -# define LIMINE_DEPRECATED_IGNORE_END -#endif - -#define LIMINE_COMMON_MAGIC 0xc7b1dd30df4c8b88, 0x0a82e883a194f07b - -struct limine_uuid { - uint32_t a; - uint16_t b; - uint16_t c; - uint8_t d[8]; -}; - -#define LIMINE_MEDIA_TYPE_GENERIC 0 -#define LIMINE_MEDIA_TYPE_OPTICAL 1 -#define LIMINE_MEDIA_TYPE_TFTP 2 - -struct limine_file { - uint64_t revision; - LIMINE_PTR(void *) address; - uint64_t size; - LIMINE_PTR(char *) path; - LIMINE_PTR(char *) cmdline; - uint32_t media_type; - uint32_t unused; - uint32_t tftp_ip; - uint32_t tftp_port; - uint32_t partition_index; - uint32_t mbr_disk_id; - struct limine_uuid gpt_disk_uuid; - struct limine_uuid gpt_part_uuid; - struct limine_uuid part_uuid; -}; - -/* Boot info */ - -#define LIMINE_BOOTLOADER_INFO_REQUEST { LIMINE_COMMON_MAGIC, 0xf55038d8e2a1202f, 0x279426fcf5f59740 } - -struct limine_bootloader_info_response { - uint64_t revision; - LIMINE_PTR(char *) name; - LIMINE_PTR(char *) version; -}; - -struct limine_bootloader_info_request { - uint64_t id[4]; - uint64_t revision; - LIMINE_PTR(struct limine_bootloader_info_response *) response; -}; - -/* Stack size */ - -#define LIMINE_STACK_SIZE_REQUEST { LIMINE_COMMON_MAGIC, 0x224ef0460a8e8926, 0xe1cb0fc25f46ea3d } - -struct limine_stack_size_response { - uint64_t revision; -}; - -struct limine_stack_size_request { - uint64_t id[4]; - uint64_t revision; - LIMINE_PTR(struct limine_stack_size_response *) response; - uint64_t stack_size; -}; - -/* HHDM */ - -#define LIMINE_HHDM_REQUEST { LIMINE_COMMON_MAGIC, 0x48dcf1cb8ad2b852, 0x63984e959a98244b } - -struct limine_hhdm_response { - uint64_t revision; - uint64_t offset; -}; - -struct limine_hhdm_request { - uint64_t id[4]; - uint64_t revision; - LIMINE_PTR(struct limine_hhdm_response *) response; -}; - -/* Framebuffer */ - -#define LIMINE_FRAMEBUFFER_REQUEST { LIMINE_COMMON_MAGIC, 0x9d5827dcd881dd75, 0xa3148604f6fab11b } - -#define LIMINE_FRAMEBUFFER_RGB 1 - -struct limine_video_mode { - uint64_t pitch; - uint64_t width; - uint64_t height; - uint16_t bpp; - uint8_t memory_model; - uint8_t red_mask_size; - uint8_t red_mask_shift; - uint8_t green_mask_size; - uint8_t green_mask_shift; - uint8_t blue_mask_size; - uint8_t blue_mask_shift; -}; - -struct limine_framebuffer { - LIMINE_PTR(void *) address; - uint64_t width; - uint64_t height; - uint64_t pitch; - uint16_t bpp; - uint8_t memory_model; - uint8_t red_mask_size; - uint8_t red_mask_shift; - uint8_t green_mask_size; - uint8_t green_mask_shift; - uint8_t blue_mask_size; - uint8_t blue_mask_shift; - uint8_t unused[7]; - uint64_t edid_size; - LIMINE_PTR(void *) edid; - /* Response revision 1 */ - uint64_t mode_count; - LIMINE_PTR(struct limine_video_mode **) modes; -}; - -struct limine_framebuffer_response { - uint64_t revision; - uint64_t framebuffer_count; - LIMINE_PTR(struct limine_framebuffer **) framebuffers; -}; - -struct limine_framebuffer_request { - uint64_t id[4]; - uint64_t revision; - LIMINE_PTR(struct limine_framebuffer_response *) response; -}; - -/* Terminal */ - -#define LIMINE_TERMINAL_REQUEST { LIMINE_COMMON_MAGIC, 0xc8ac59310c2b0844, 0xa68d0c7265d38878 } - -#define LIMINE_TERMINAL_CB_DEC 10 -#define LIMINE_TERMINAL_CB_BELL 20 -#define LIMINE_TERMINAL_CB_PRIVATE_ID 30 -#define LIMINE_TERMINAL_CB_STATUS_REPORT 40 -#define LIMINE_TERMINAL_CB_POS_REPORT 50 -#define LIMINE_TERMINAL_CB_KBD_LEDS 60 -#define LIMINE_TERMINAL_CB_MODE 70 -#define LIMINE_TERMINAL_CB_LINUX 80 - -#define LIMINE_TERMINAL_CTX_SIZE ((uint64_t)(-1)) -#define LIMINE_TERMINAL_CTX_SAVE ((uint64_t)(-2)) -#define LIMINE_TERMINAL_CTX_RESTORE ((uint64_t)(-3)) -#define LIMINE_TERMINAL_FULL_REFRESH ((uint64_t)(-4)) - -/* Response revision 1 */ -#define LIMINE_TERMINAL_OOB_OUTPUT_GET ((uint64_t)(-10)) -#define LIMINE_TERMINAL_OOB_OUTPUT_SET ((uint64_t)(-11)) - -#define LIMINE_TERMINAL_OOB_OUTPUT_OCRNL (1 << 0) -#define LIMINE_TERMINAL_OOB_OUTPUT_OFDEL (1 << 1) -#define LIMINE_TERMINAL_OOB_OUTPUT_OFILL (1 << 2) -#define LIMINE_TERMINAL_OOB_OUTPUT_OLCUC (1 << 3) -#define LIMINE_TERMINAL_OOB_OUTPUT_ONLCR (1 << 4) -#define LIMINE_TERMINAL_OOB_OUTPUT_ONLRET (1 << 5) -#define LIMINE_TERMINAL_OOB_OUTPUT_ONOCR (1 << 6) -#define LIMINE_TERMINAL_OOB_OUTPUT_OPOST (1 << 7) - -LIMINE_DEPRECATED_IGNORE_START - -struct LIMINE_DEPRECATED limine_terminal; - -typedef void (*limine_terminal_write)(struct limine_terminal *, const char *, uint64_t); -typedef void (*limine_terminal_callback)(struct limine_terminal *, uint64_t, uint64_t, uint64_t, uint64_t); - -struct LIMINE_DEPRECATED limine_terminal { - uint64_t columns; - uint64_t rows; - LIMINE_PTR(struct limine_framebuffer *) framebuffer; -}; - -struct LIMINE_DEPRECATED limine_terminal_response { - uint64_t revision; - uint64_t terminal_count; - LIMINE_PTR(struct limine_terminal **) terminals; - LIMINE_PTR(limine_terminal_write) write; -}; - -struct LIMINE_DEPRECATED limine_terminal_request { - uint64_t id[4]; - uint64_t revision; - LIMINE_PTR(struct limine_terminal_response *) response; - LIMINE_PTR(limine_terminal_callback) callback; -}; - -LIMINE_DEPRECATED_IGNORE_END - -/* 5-level paging */ - -#define LIMINE_5_LEVEL_PAGING_REQUEST { LIMINE_COMMON_MAGIC, 0x94469551da9b3192, 0xebe5e86db7382888 } - -struct limine_5_level_paging_response { - uint64_t revision; -}; - -struct limine_5_level_paging_request { - uint64_t id[4]; - uint64_t revision; - LIMINE_PTR(struct limine_5_level_paging_response *) response; -}; - -/* SMP */ - -#define LIMINE_SMP_REQUEST { LIMINE_COMMON_MAGIC, 0x95a67b819a1b857e, 0xa0b61b723b6a73e0 } - -struct limine_smp_info; - -typedef void (*limine_goto_address)(struct limine_smp_info *); - -#if defined (__x86_64__) || defined (__i386__) - -#define LIMINE_SMP_X2APIC (1 << 0) - -struct limine_smp_info { - uint32_t processor_id; - uint32_t lapic_id; - uint64_t reserved; - LIMINE_PTR(limine_goto_address) goto_address; - uint64_t extra_argument; -}; - -struct limine_smp_response { - uint64_t revision; - uint32_t flags; - uint32_t bsp_lapic_id; - uint64_t cpu_count; - LIMINE_PTR(struct limine_smp_info **) cpus; -}; - -#elif defined (__aarch64__) - -struct limine_smp_info { - uint32_t processor_id; - uint32_t gic_iface_no; - uint64_t mpidr; - uint64_t reserved; - LIMINE_PTR(limine_goto_address) goto_address; - uint64_t extra_argument; -}; - -struct limine_smp_response { - uint64_t revision; - uint32_t flags; - uint64_t bsp_mpidr; - uint64_t cpu_count; - LIMINE_PTR(struct limine_smp_info **) cpus; -}; - -#else -#error Unknown architecture -#endif - -struct limine_smp_request { - uint64_t id[4]; - uint64_t revision; - LIMINE_PTR(struct limine_smp_response *) response; - uint64_t flags; -}; - -/* Memory map */ - -#define LIMINE_MEMMAP_REQUEST { LIMINE_COMMON_MAGIC, 0x67cf3d9d378a806f, 0xe304acdfc50c3c62 } - -#define LIMINE_MEMMAP_USABLE 0 -#define LIMINE_MEMMAP_RESERVED 1 -#define LIMINE_MEMMAP_ACPI_RECLAIMABLE 2 -#define LIMINE_MEMMAP_ACPI_NVS 3 -#define LIMINE_MEMMAP_BAD_MEMORY 4 -#define LIMINE_MEMMAP_BOOTLOADER_RECLAIMABLE 5 -#define LIMINE_MEMMAP_KERNEL_AND_MODULES 6 -#define LIMINE_MEMMAP_FRAMEBUFFER 7 - -struct limine_memmap_entry { - uint64_t base; - uint64_t length; - uint64_t type; -}; - -struct limine_memmap_response { - uint64_t revision; - uint64_t entry_count; - LIMINE_PTR(struct limine_memmap_entry **) entries; -}; - -struct limine_memmap_request { - uint64_t id[4]; - uint64_t revision; - LIMINE_PTR(struct limine_memmap_response *) response; -}; - -/* Entry point */ - -#define LIMINE_ENTRY_POINT_REQUEST { LIMINE_COMMON_MAGIC, 0x13d86c035a1cd3e1, 0x2b0caa89d8f3026a } - -typedef void (*limine_entry_point)(void); - -struct limine_entry_point_response { - uint64_t revision; -}; - -struct limine_entry_point_request { - uint64_t id[4]; - uint64_t revision; - LIMINE_PTR(struct limine_entry_point_response *) response; - LIMINE_PTR(limine_entry_point) entry; -}; - -/* Kernel File */ - -#define LIMINE_KERNEL_FILE_REQUEST { LIMINE_COMMON_MAGIC, 0xad97e90e83f1ed67, 0x31eb5d1c5ff23b69 } - -struct limine_kernel_file_response { - uint64_t revision; - LIMINE_PTR(struct limine_file *) kernel_file; -}; - -struct limine_kernel_file_request { - uint64_t id[4]; - uint64_t revision; - LIMINE_PTR(struct limine_kernel_file_response *) response; -}; - -/* Module */ - -#define LIMINE_MODULE_REQUEST { LIMINE_COMMON_MAGIC, 0x3e7e279702be32af, 0xca1c4f3bd1280cee } - -#define LIMINE_INTERNAL_MODULE_REQUIRED (1 << 0) - -struct limine_internal_module { - LIMINE_PTR(const char *) path; - LIMINE_PTR(const char *) cmdline; - uint64_t flags; -}; - -struct limine_module_response { - uint64_t revision; - uint64_t module_count; - LIMINE_PTR(struct limine_file **) modules; -}; - -struct limine_module_request { - uint64_t id[4]; - uint64_t revision; - LIMINE_PTR(struct limine_module_response *) response; - - /* Request revision 1 */ - uint64_t internal_module_count; - LIMINE_PTR(struct limine_internal_module **) internal_modules; -}; - -/* RSDP */ - -#define LIMINE_RSDP_REQUEST { LIMINE_COMMON_MAGIC, 0xc5e77b6b397e7b43, 0x27637845accdcf3c } - -struct limine_rsdp_response { - uint64_t revision; - LIMINE_PTR(void *) address; -}; - -struct limine_rsdp_request { - uint64_t id[4]; - uint64_t revision; - LIMINE_PTR(struct limine_rsdp_response *) response; -}; - -/* SMBIOS */ - -#define LIMINE_SMBIOS_REQUEST { LIMINE_COMMON_MAGIC, 0x9e9046f11e095391, 0xaa4a520fefbde5ee } - -struct limine_smbios_response { - uint64_t revision; - LIMINE_PTR(void *) entry_32; - LIMINE_PTR(void *) entry_64; -}; - -struct limine_smbios_request { - uint64_t id[4]; - uint64_t revision; - LIMINE_PTR(struct limine_smbios_response *) response; -}; - -/* EFI system table */ - -#define LIMINE_EFI_SYSTEM_TABLE_REQUEST { LIMINE_COMMON_MAGIC, 0x5ceba5163eaaf6d6, 0x0a6981610cf65fcc } - -struct limine_efi_system_table_response { - uint64_t revision; - LIMINE_PTR(void *) address; -}; - -struct limine_efi_system_table_request { - uint64_t id[4]; - uint64_t revision; - LIMINE_PTR(struct limine_efi_system_table_response *) response; -}; - -/* Boot time */ - -#define LIMINE_BOOT_TIME_REQUEST { LIMINE_COMMON_MAGIC, 0x502746e184c088aa, 0xfbc5ec83e6327893 } - -struct limine_boot_time_response { - uint64_t revision; - int64_t boot_time; -}; - -struct limine_boot_time_request { - uint64_t id[4]; - uint64_t revision; - LIMINE_PTR(struct limine_boot_time_response *) response; -}; - -/* Kernel address */ - -#define LIMINE_KERNEL_ADDRESS_REQUEST { LIMINE_COMMON_MAGIC, 0x71ba76863cc55f63, 0xb2644a48c516a487 } - -struct limine_kernel_address_response { - uint64_t revision; - uint64_t physical_base; - uint64_t virtual_base; -}; - -struct limine_kernel_address_request { - uint64_t id[4]; - uint64_t revision; - LIMINE_PTR(struct limine_kernel_address_response *) response; -}; - -/* Device Tree Blob */ - -#define LIMINE_DTB_REQUEST { LIMINE_COMMON_MAGIC, 0xb40ddb48fb54bac7, 0x545081493f81ffb7 } - -struct limine_dtb_response { - uint64_t revision; - LIMINE_PTR(void *) dtb_ptr; -}; - -struct limine_dtb_request { - uint64_t id[4]; - uint64_t revision; - LIMINE_PTR(struct limine_dtb_response *) response; -}; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/sys/include/sys/loader.h b/sys/include/sys/loader.h deleted file mode 100644 index 43ad36e..0000000 --- a/sys/include/sys/loader.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_LOADER_H_ -#define _SYS_LOADER_H_ - -#include <sys/types.h> -#include <vm/pmap.h> -#include <vm/vm.h> - -/* DANGER!: DO NOT CHANGE THESE DEFINES */ -#define AT_NULL 0 -#define AT_ENTRY 1 -#define AT_PHDR 2 -#define AT_PHENT 3 -#define AT_PHNUM 4 -#define AT_EXECPATH 5 -#define AT_SECURE 6 -#define AT_RANDOM 7 -#define AT_EXECFN 8 -#define AT_PAGESIZE 9 - -#define STACK_PUSH(ptr, val) *(--ptr) = val -#define AUXVAL(ptr, tag, val) __extension__ ({ \ - STACK_PUSH(ptr, val); \ - STACK_PUSH(ptr, tag); \ -}); - -/* Auxiliary Vector */ -struct auxval { - uint64_t at_entry; - uint64_t at_phdr; - uint64_t at_phent; - uint64_t at_phnum; -}; - -struct exec_args { - char **argp, **envp; - struct auxval auxv; - struct vas vas; -}; - -#if defined(_KERNEL) - -uintptr_t loader_init_stack(void *stack_top, struct exec_args args); -int loader_unload(struct vas vas, struct vm_range *exec_range); -int loader_load(struct vas vas, const void *dataptr, struct auxval *auxv, - size_t load_base, char **ld_path, struct vm_range *prog_range); - -#endif /* defined(_KERNEL) */ -#endif /* !_SYS_LOADER_H_ */ diff --git a/sys/include/sys/machdep.h b/sys/include/sys/machdep.h deleted file mode 100644 index 0ecb83e..0000000 --- a/sys/include/sys/machdep.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_MACHDEP_H_ -#define _SYS_MACHDEP_H_ - -#include <sys/types.h> -#include <sys/cdefs.h> -#include <sys/proc.h> - -#if defined(_KERNEL) - -#define MAXCPUS 32 - -int processor_init_pcb(struct proc *proc); -int processor_free_pcb(struct proc *proc); -void processor_switch_to(struct proc *old_td, struct proc *new_td); -void processor_init(void); -void processor_halt(void); -void intr_mask(void); -void intr_unmask(void); -void machine_panic(void); -__weak void chips_init(void); -__weak void pre_init(void); -__weak void serial_dbgch(char c); -__weak void cpu_halt_others(void); -__weak void cpu_reset(void); - -#endif /* defined(_KERNEL) */ -#endif /* !_SYS_MACHDEP_H_ */ diff --git a/sys/include/sys/mmio.h b/sys/include/sys/mmio.h deleted file mode 100644 index 69d8fd2..0000000 --- a/sys/include/sys/mmio.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * For documentation: See mmio(9) - */ - -#ifndef _SYS_MMIO_H_ -#define _SYS_MMIO_H_ - -#include <sys/types.h> -#include <sys/cdefs.h> -#include <vm/vm.h> - -/* - * mmio_write<n> - Writes to MMIO address with specific size - * - * @addr: Address to write to. - * @val: Value to write. - * - * These functions will add the higher half - * offset (VM_HIGHER_HALF) if the MMIO address - * is less than VM_HIGHER_HALF as it'll be safe - * to assume it's a physical address. Page faults - * from writes could be due to the resulting virtual - * address not being mapped. - */ -#define _MMIO_WRITE_TYPE(TYPE, SUFFIX) \ - static inline void \ - mmio_write##SUFFIX(volatile void *addr, TYPE val) \ - { \ - uintptr_t tmp; \ - \ - tmp = (uintptr_t)addr; \ - if (tmp < VM_HIGHER_HALF) { \ - tmp += VM_HIGHER_HALF; \ - } \ - *(volatile TYPE *)tmp = val; \ - __mem_barrier(); \ - } - -/* - * mmio_read<n> - Does the same as mmio_write<n> but for reading - * - * @addr: Address to read from. - */ -#define _MMIO_READ_TYPE(TYPE, SUFFIX) \ - static inline TYPE \ - mmio_read##SUFFIX(volatile void *addr) \ - { \ - uintptr_t tmp; \ - \ - tmp = (uintptr_t)addr; \ - if (tmp < VM_HIGHER_HALF) { \ - tmp += VM_HIGHER_HALF; \ - } \ - \ - __mem_barrier(); /* Ensure writes complete */ \ - return *(volatile TYPE *)tmp; \ - } - -/* - * To write to an MMIO address of, for example, - * 8 bits, use mmio_write8(addr, val) - */ -_MMIO_WRITE_TYPE(uint8_t, 8) -_MMIO_WRITE_TYPE(uint16_t, 16) -_MMIO_WRITE_TYPE(uint32_t, 32) -#if __SIZEOF_SIZE_T__ == 8 -_MMIO_WRITE_TYPE(uint64_t, 64) -#endif -__extension__ - -/* - * To read from an MMIO address of, for example, - * 8 bits, use mmio_read8(addr) - */ -_MMIO_READ_TYPE(uint8_t, 8) -_MMIO_READ_TYPE(uint16_t, 16) -_MMIO_READ_TYPE(uint32_t, 32) -#if __SIZEOF_SIZE_T__ == 8 -_MMIO_READ_TYPE(uint64_t, 64) -#endif -__extension__ - -#endif /* !_SYS_MMIO_H_ */ diff --git a/sys/include/sys/mount.h b/sys/include/sys/mount.h deleted file mode 100644 index b208bf7..0000000 --- a/sys/include/sys/mount.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_MOUNT_H_ -#define _SYS_MOUNT_H_ - -#include <sys/types.h> -#include <sys/queue.h> -#include <sys/vnode.h> -#include <sys/cdefs.h> - -#define FS_NAME_MAX 16 /* Max length of FS type name including nul */ - -struct fs_info; -struct mount; -struct vnode; - -struct vfsops { - int(*init)(struct fs_info *info, struct vnode *source); -}; - -struct mount { - int flags; - size_t phash; /* Path hash */ - struct fs_info *fs; - TAILQ_ENTRY(mount) link; -}; - -struct fs_info { - char name[FS_NAME_MAX]; /* Filesystem type name */ - struct vfsops *vfsops; /* Filesystem operations */ - struct vops *vops; /* Vops for our vnode */ - struct vnode *vnode; /* Vnode for this filesystem */ - struct mount *mp_root; - uint16_t caps; -}; - -/* - * Filesystem capabilities - */ -#define FSCAP_FULLPATH __BIT(0) /* Requires full path per lookup */ - -/* - * Mount flags - */ -#define MNT_RDONLY 0x00000001 - -#if defined(_KERNEL) -int vfs_mount(const char *path, int mntflags, struct fs_info *fs); -int vfs_get_mp(const char *path, struct mount **mp); -void vfs_mount_init(void); -#endif /* defined(_KERNEL) */ - -#endif /* !_SYS_MOUNT_H_ */ diff --git a/sys/include/sys/mutex.h b/sys/include/sys/mutex.h deleted file mode 100644 index dfd2dec..0000000 --- a/sys/include/sys/mutex.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include <sys/types.h> - -#ifndef _SYS_MUTEX_H_ -#define _SYS_MUTEX_H_ - -struct mutex { - volatile _Atomic bool lock; -}; - -void mutex_acquire(struct mutex *mutex); -void mutex_release(struct mutex *mutex); - -#endif /* !_SYS_MUTEX_H_ */ diff --git a/sys/include/sys/panic.h b/sys/include/sys/panic.h deleted file mode 100644 index 961e5d5..0000000 --- a/sys/include/sys/panic.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_PANIC_H_ -#define _SYS_PANIC_H_ - -#include <stdarg.h> - -#if defined(_KERNEL) - -void panic(const char *fmt, ...); - -#endif - -#endif diff --git a/sys/include/sys/proc.h b/sys/include/sys/proc.h deleted file mode 100644 index e3416f9..0000000 --- a/sys/include/sys/proc.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_PROC_H_ -#define _SYS_PROC_H_ - -#include <sys/types.h> -#include <sys/queue.h> -#include <sys/filedesc.h> -#include <sys/spinlock.h> -#include <sys/loader.h> -#include <machine/cpu.h> -#include <machine/frame.h> -#include <machine/pcb.h> -#include <vm/vm.h> -#include <vm/map.h> - -#define PROC_MAX_FDS 256 -#define PROC_MAX_ADDR_RANGE 4 - -#define PROC_STACK_PAGES 8 -#define PROC_STACK_SIZE (PROC_STACK_PAGES*vm_get_page_size()) - -/* - * The PHYS_TO_VIRT/VIRT_TO_PHYS macros convert - * addresses to lower and higher half addresses. - * Userspace addresses are on the lower half, - * therefore, we can just wrap over these to - * keep things simple. - * - * XXX: TODO: This won't work when not identity mapping - * lowerhalf addresses. Once that is updated, - * get rid of this. - */ -#define USER_TO_KERN(user) PHYS_TO_VIRT(user) -#define KERN_TO_USER(kern) VIRT_TO_PHYS(kern) - -enum { - ADDR_RANGE_EXEC = 0, /* Program address range */ - ADDR_RANGE_STACK /* Stack address range */ -}; - -/* - * A task running on the CPU e.g., a process or - * a thread. - */ -struct proc { - pid_t pid; - struct cpu_info *cpu; - struct trapframe *tf; - struct pcb pcb; - struct vas addrsp; - struct vm_range addr_range[PROC_MAX_ADDR_RANGE]; - struct spinlock lock; - uint8_t is_user; - uint8_t rested; - uint32_t signal; - uint32_t priority; - struct filedesc *fds[PROC_MAX_FDS]; - struct spinlock mapspace_lock; - struct vm_mapspace mapspace; - TAILQ_ENTRY(proc) link; -}; - -#endif /* !_SYS_PROC_H_ */ diff --git a/sys/include/sys/queue.h b/sys/include/sys/queue.h deleted file mode 100644 index 60231f4..0000000 --- a/sys/include/sys/queue.h +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include <sys/types.h> - -#ifndef _QUEUE_H_ -#define _QUEUE_H_ - -#define _Q_INVALIDATE(a) - -/* - * Tail queue definitions. - */ -#define TAILQ_HEAD(name, type) \ -struct name { \ - struct type *tqh_first; /* first element */ \ - struct type **tqh_last; /* addr of last next element */ \ - size_t nelem; /* Number of elements */ \ -} - -#define TAILQ_HEAD_INITIALIZER(head) \ - { NULL, &(head).tqh_first } - -#define TAILQ_ENTRY(type) \ -struct { \ - struct type *tqe_next; /* next element */ \ - struct type **tqe_prev; /* address of previous next element */ \ -} - -/* - * Tail queue access methods. - */ -#define TAILQ_NELEM(head) ((head)->nelem) -#define TAILQ_FIRST(head) ((head)->tqh_first) -#define TAILQ_END(head) NULL -#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) -#define TAILQ_LAST(head, headname) \ - (*(((struct headname *)((head)->tqh_last))->tqh_last)) -/* XXX */ -#define TAILQ_PREV(elm, headname, field) \ - (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) -#define TAILQ_EMPTY(head) \ - (TAILQ_FIRST(head) == TAILQ_END(head)) - -#define TAILQ_FOREACH(var, head, field) \ - for((var) = TAILQ_FIRST(head); \ - (var) != TAILQ_END(head); \ - (var) = TAILQ_NEXT(var, field)) - -#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \ - for ((var) = TAILQ_FIRST(head); \ - (var) != TAILQ_END(head) && \ - ((tvar) = TAILQ_NEXT(var, field), 1); \ - (var) = (tvar)) - - -#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \ - for((var) = TAILQ_LAST(head, headname); \ - (var) != TAILQ_END(head); \ - (var) = TAILQ_PREV(var, headname, field)) - -#define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar) \ - for ((var) = TAILQ_LAST(head, headname); \ - (var) != TAILQ_END(head) && \ - ((tvar) = TAILQ_PREV(var, headname, field), 1); \ - (var) = (tvar)) - -/* - * Tail queue functions. - */ -#define TAILQ_INIT(head) do { \ - (head)->tqh_first = NULL; \ - (head)->tqh_last = &(head)->tqh_first; \ - (head)->nelem = 0; \ -} while (0) - -#define TAILQ_INSERT_HEAD(head, elm, field) do { \ - if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \ - (head)->tqh_first->field.tqe_prev = \ - &(elm)->field.tqe_next; \ - else \ - (head)->tqh_last = &(elm)->field.tqe_next; \ - (head)->tqh_first = (elm); \ - (elm)->field.tqe_prev = &(head)->tqh_first; \ - ++(head)->nelem; \ -} while (0) - -#define TAILQ_INSERT_TAIL(head, elm, field) do { \ - (elm)->field.tqe_next = NULL; \ - (elm)->field.tqe_prev = (head)->tqh_last; \ - *(head)->tqh_last = (elm); \ - (head)->tqh_last = &(elm)->field.tqe_next; \ - ++(head)->nelem; \ -} while (0) - -#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ - if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\ - (elm)->field.tqe_next->field.tqe_prev = \ - &(elm)->field.tqe_next; \ - else \ - (head)->tqh_last = &(elm)->field.tqe_next; \ - (listelm)->field.tqe_next = (elm); \ - (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \ - ++(head)->nelem; \ -} while (0) - -#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \ - (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ - (elm)->field.tqe_next = (listelm); \ - *(listelm)->field.tqe_prev = (elm); \ - (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \ - ++(head)->nelem; \ -} while (0) - -#define TAILQ_REMOVE(head, elm, field) do { \ - if (((elm)->field.tqe_next) != NULL) \ - (elm)->field.tqe_next->field.tqe_prev = \ - (elm)->field.tqe_prev; \ - else \ - (head)->tqh_last = (elm)->field.tqe_prev; \ - *(elm)->field.tqe_prev = (elm)->field.tqe_next; \ - _Q_INVALIDATE((elm)->field.tqe_prev); \ - _Q_INVALIDATE((elm)->field.tqe_next); \ - --(head)->nelem; \ -} while (0) - -#define TAILQ_REPLACE(head, elm, elm2, field) do { \ - if (((elm2)->field.tqe_next = (elm)->field.tqe_next) != NULL) \ - (elm2)->field.tqe_next->field.tqe_prev = \ - &(elm2)->field.tqe_next; \ - else \ - (head)->tqh_last = &(elm2)->field.tqe_next; \ - (elm2)->field.tqe_prev = (elm)->field.tqe_prev; \ - *(elm2)->field.tqe_prev = (elm2); \ - _Q_INVALIDATE((elm)->field.tqe_prev); \ - _Q_INVALIDATE((elm)->field.tqe_next); \ -} while (0) - -#define TAILQ_CONCAT(head1, head2, field) do { \ - if (!TAILQ_EMPTY(head2)) { \ - *(head1)->tqh_last = (head2)->tqh_first; \ - (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \ - (head1)->tqh_last = (head2)->tqh_last; \ - TAILQ_INIT((head2)); \ - } \ -} while (0) -#endif /* _QUEUE_H_ */ diff --git a/sys/include/sys/reboot.h b/sys/include/sys/reboot.h deleted file mode 100644 index e09bd4f..0000000 --- a/sys/include/sys/reboot.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_REBOOT_H_ -#define _SYS_REBOOT_H_ - -#if defined(_KERNEL) -#include <sys/syscall.h> -#endif - -#define REBOOT_DEFAULT 0x0000 - -int reboot(int type); - -#if defined(_KERNEL) -uint64_t sys_reboot(struct syscall_args *args); -#endif /* defined(_KERNEL) */ - -#endif /* !_SYS_REBOOT_H_ */ diff --git a/sys/include/sys/sched.h b/sys/include/sys/sched.h deleted file mode 100644 index 06cf860..0000000 --- a/sys/include/sys/sched.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_SCHED_H_ -#define _SYS_SCHED_H_ - -#include <sys/proc.h> -#include <sys/queue.h> -#include <sys/types.h> -#include <sys/spinlock.h> -#include <sys/syscall.h> -#include <machine/cpu.h> -#include <machine/frame.h> - -struct proc *this_td(void); -void sched_init(void); -void sched_exit(void); -void sched_context_switch(struct trapframe *tf); -void sched_rest(void); - -__noreturn -void sched_enter(void); - -__noreturn -uint64_t sys_exit(struct syscall_args *args); - -#endif /* !_SYS_SCHED_H_ */ diff --git a/sys/include/sys/sched_state.h b/sys/include/sys/sched_state.h deleted file mode 100644 index 52d6c56..0000000 --- a/sys/include/sys/sched_state.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_SCHED_STATE_H_ -#define _SYS_SCHED_STATE_H_ - -#include <sys/proc.h> - -/* - * Scheduler state, per CPU. - */ -struct sched_state { - struct proc *td; /* Current_thread */ -}; - -#endif /* !_SYS_SCHED_STATE_H_ */ diff --git a/sys/include/sys/schedvar.h b/sys/include/sys/schedvar.h deleted file mode 100644 index 2a0a1fc..0000000 --- a/sys/include/sys/schedvar.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_SCHEDVAR_H_ -#define _SYS_SCHEDVAR_H_ - -#include <sys/cdefs.h> -#include <sys/proc.h> -#include <sys/queue.h> - -#define DEFAULT_TIMESLICE_USEC 3000 -#define SHORT_TIMESLICE_USEC 10 - -#define SCHED_POLICY_MLFQ 0x0000U /* Multilevel feedback queue */ -#define SCHED_POLICY_RR 0x0001U /* Round robin */ - -typedef uint8_t schedpolicy_t; - -/* Might be set by kconf(1) */ -#if defined(__SCHED_NQUEUE) -#define SCHED_NQUEUE __SCHED_NQUEUE -#else -#define SCHED_NQUEUE 4 -#endif - -/* Ensure SCHED_NQUEUE is an acceptable value */ -__STATIC_ASSERT(SCHED_NQUEUE <= 8, "SCHED_NQUEUE exceeds max"); -__STATIC_ASSERT(SCHED_NQUEUE > 0, "SCHED_NQUEUE cannot be zero"); - -struct sched_queue { - TAILQ_HEAD(, proc) q; - size_t nthread; -}; - -#endif /* !_SYS_SCHEDVAR_H_ */ diff --git a/sys/include/sys/signal.h b/sys/include/sys/signal.h deleted file mode 100644 index 640773d..0000000 --- a/sys/include/sys/signal.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_SIGNAL_H_ -#define _SYS_SIGNAL_H_ - -#if defined(_KERNEL) -#include <sys/proc.h> -#endif - -#define SIGFPE 8 /* Floating point exception */ -#define SIGKILL 9 /* Kill */ -#define SIGSEGV 11 /* Segmentation violation */ - -#if defined(_KERNEL) -void signal_handle(struct proc *curtd); -void signal_raise(struct proc *to, int signal); -#endif /* defined(_KERNEL) */ - -#endif /* !_SYS_SIGNAL_H_ */ diff --git a/sys/include/sys/sio.h b/sys/include/sys/sio.h deleted file mode 100644 index 6f13a09..0000000 --- a/sys/include/sys/sio.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SIO_H_ -#define _SIO_H_ - -#include <sys/types.h> - -#if defined(_KERNEL) -enum sio_type { - SIO_NONE, /* None specified */ - SIO_USER, /* Userspace related transaction */ - SIO_KERN, /* Kernel transaction */ -}; - -/* - * System I/O transaction - * - * This structure describes a system I/O transaction - * and contains common fields that are used - * with system I/O. - */ -struct sio_txn { - void *buf; /* Source/dest buffer */ - off_t offset; /* Transfer offset */ - size_t len; /* Length in bytes */ - enum sio_type type; /* Transaction type */ -}; - -#endif /* defined(_KERNEL) */ -#endif /* !_SIO_H_ */ diff --git a/sys/include/sys/spinlock.h b/sys/include/sys/spinlock.h deleted file mode 100644 index 98bc342..0000000 --- a/sys/include/sys/spinlock.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_SPINLOCK_H_ -#define _SYS_SPINLOCK_H_ - -#include <sys/types.h> - -struct spinlock { - volatile _Atomic bool lock; -}; - -static inline void -spinlock_acquire(struct spinlock *lock) -{ - while (__atomic_test_and_set(&lock->lock, __ATOMIC_ACQUIRE)); -} - -static inline void -spinlock_release(struct spinlock *lock) -{ - __atomic_clear(&lock->lock, __ATOMIC_RELEASE); -} - -#endif /* !_SYS_SPINLOCK_H_ */ diff --git a/sys/include/sys/syscall.h b/sys/include/sys/syscall.h deleted file mode 100644 index 4ef3666..0000000 --- a/sys/include/sys/syscall.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_SYSCALL_H_ -#define _SYS_SYSCALL_H_ - -#include <sys/types.h> -#if defined(_KERNEL) -#include <machine/frame.h> -#endif - -/* Do not reorder */ -enum { - SYS_exit = 1, - SYS_write, - SYS_open, - SYS_close, - SYS_read, - SYS_lseek, - SYS_mmap, - SYS_munmap, - SYS_ioctl, - SYS_execv, - SYS_mount, - SYS_reboot, - __MAX_SYSCALLS -}; - -struct syscall_args { - uint64_t code; - uint64_t arg0, arg1, arg2; - uint64_t arg3, arg4, arg5, arg6; - uint64_t ip; - uint64_t sp; -}; - -#if defined(_KERNEL) -extern uint64_t(*g_syscall_table[__MAX_SYSCALLS])(struct syscall_args *args); -void __syscall(struct trapframe *tf); -#endif - -#endif diff --git a/sys/include/sys/syslog.h b/sys/include/sys/syslog.h deleted file mode 100644 index 18948ee..0000000 --- a/sys/include/sys/syslog.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * For documentation: See syslog(9) - */ - -#ifndef _SYS_SYSLOG_H_ -#define _SYS_SYSLOG_H_ - -#include <sys/types.h> -#include <stdarg.h> -#include <dev/vcons/vcons.h> - -#if defined(_KERNEL) - -#define OMIT_TIMESTAMP "\x01" - -void syslog_init(void); -void syslog_init_proc(void); -void kprintf(const char *fmt, ...); -void vkprintf(const char *fmt, va_list *ap); - -extern struct vcons_screen g_syslog_screen; -extern bool g_syslog_use_tty; - -#endif /* defined(_KERNEL) */ - -#endif /* !_SYS_SYSLOG_H_ */ diff --git a/sys/include/sys/system.h b/sys/include/sys/system.h deleted file mode 100644 index 03ac710..0000000 --- a/sys/include/sys/system.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_SYSTEM_H_ -#define _SYS_SYSTEM_H_ - -#include <sys/types.h> -#include <sys/syscall.h> - -#if defined(_KERNEL) -int copyin(uintptr_t uaddr, void *kaddr, size_t len); -int copyout(const void *kaddr, uintptr_t uaddr, size_t len); -int copyinstr(uintptr_t uaddr, char *kaddr, size_t len); -uint64_t sys_ioctl(struct syscall_args *args); -#endif - -#endif /* !_SYS_SYSTEM_H_ */ diff --git a/sys/include/sys/termios.h b/sys/include/sys/termios.h deleted file mode 100644 index 1fda67e..0000000 --- a/sys/include/sys/termios.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_TERMIOS_H_ -#define _SYS_TERMIOS_H_ - -#if defined(_KERNEL) -#include <sys/types.h> -#else -#include <stdint.h> -#endif - -#define NCCS 20 - -/* - * Output flags - software output processing - */ -#define OPOST 0x00000001U /* Enable output processing */ -#if defined(_KERNEL) || defined(_HYRA_SOURCE) -#define OCRNL 0x00000002U /* Map NL to CR-NL */ -#endif /* defined(_KERNEL) || defined(_HYRA_SOURCE) */ - -/* - * Local flags - */ -#define ICANON 0x00000001U -#define ECHO 0x00000002U - -typedef uint32_t tcflag_t; -typedef uint32_t speed_t; -typedef uint8_t cc_t; - -struct termios { - tcflag_t c_iflag; /* Input flags */ - tcflag_t c_oflag; /* Output flags */ - tcflag_t c_cflag; /* Control flags */ - tcflag_t c_lflag; /* Local flags */ - cc_t c_cc[NCCS]; /* Control chars */ - int c_ispeed; /* Input speed */ - int c_ospeed; /* Output speed */ -}; - -#endif /* !_SYS_TERMIOS_H_ */ diff --git a/sys/include/sys/timer.h b/sys/include/sys/timer.h deleted file mode 100644 index e33b2d3..0000000 --- a/sys/include/sys/timer.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * For documentation: See timer(9) - */ - -#ifndef _SYS_TIMER_H_ -#define _SYS_TIMER_H_ - -#include <sys/types.h> - -/* Timer IDs */ -#define TIMER_SCHED 0x00000000U /* Scheduler reserved timer */ -#define TIMER_GP 0x00000001U /* General purpose timer */ - -/* Number of timer IDs, adjust when adding timer IDs */ -#define TIMER_ID_COUNT 2 - -/* Timer registry status */ -#define TMRR_SUCCESS 0x00000000U /* Successful */ -#define TMRR_HAS_ENTRY 0x00000001U /* Already has an entry */ -#define TMRR_INVALID_TYPE 0x00000002U /* Invalid timer id */ -#define TMRR_EMPTY_ENTRY 0x00000003U /* Entry is empty */ -#define TMRR_INVALID_ARG 0x00000004U /* Invalid iface arg */ - -/* See timer ID defines */ -typedef uint8_t timer_id_t; - -/* See timer registry status */ -typedef int tmrr_status_t; - -/* - * Represents a timer, pointer fields - * are optional and may be set to NULL, therefore - * it is paramount to verify any function or general - * pointer field within this struct is checked for - * a NULL value. Fields should be NULL if the timer - * driver implementation doesn't implement support - * for a functionality. - * - * XXX: The msleep, usleep, ... functions must return - * either EXIT_SUCCESS and EXIT_FAILURE from sys/errno.h - * ONLY. - */ -struct timer { - const char *name; /* e.g "HPET" */ - size_t(*calibrate)(void); /* Returns frequency, 0 for unspecified */ - size_t(*get_time_usec)(void); /* Time since init (microseconds) */ - size_t(*get_time_sec)(void); /* Time since init (seconds) */ - int(*msleep)(size_t ms); - int(*usleep)(size_t us); - int(*nsleep)(size_t ns); - void(*periodic_ms)(size_t ms); - void(*periodic_us)(size_t ms); - void(*oneshot_ms)(size_t ms); - void(*oneshot_us)(size_t ms); - void(*stop)(void); -}; - -tmrr_status_t register_timer(timer_id_t id, const struct timer *tmr); -tmrr_status_t tmr_registry_overwrite(timer_id_t, const struct timer *tmr); -tmrr_status_t req_timer(timer_id_t id, struct timer *tmr_out); - -#endif /* !_SYS_TIMER_H_ */ diff --git a/sys/include/sys/tty.h b/sys/include/sys/tty.h deleted file mode 100644 index 18583a5..0000000 --- a/sys/include/sys/tty.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_TTY_H_ -#define _SYS_TTY_H_ - -#include <sys/termios.h> -#if defined(_KERNEL) -#include <sys/types.h> -#include <sys/spinlock.h> -#include <sys/device.h> -#include <dev/vcons/vcons.h> -#endif - -/* TTY ioctl commands */ -#define TCSETS 0x00000000U -#define TCGETS 0x00000001U - -#if defined(_KERNEL) -#define TTY_RING_SIZE 32 -#define TTY_SOURCE_RAW 0x0001U /* Raw text */ -#define TTY_SOURCE_DEV 0x0002U /* Input from device (e.g keyboard) */ - -struct tty_ring { - char data[TTY_RING_SIZE]; /* Ring data */ - off_t enq_index; /* Enqueue index */ - off_t deq_index; /* Dequeue index */ -}; - -struct tty { - dev_t id; - struct vcons_screen *scr; /* Console screen */ - struct tty_ring ring; /* Input ring */ - struct tty_ring outring; /* Output ring */ - struct spinlock rlock; /* Ring lock */ - struct termios termios; /* Termios structure */ - struct device *dev; /* Device pointer */ -}; - -extern struct tty g_root_tty; - -dev_t tty_attach(struct tty *tty); -int tty_putc(struct tty *tty, int c, int flags); -int tty_putstr(struct tty *tty, const char *s, size_t count); -ssize_t tty_flush(struct tty *tty); - -#endif /* defined(_KERNEL) */ -#endif /* !_SYS_TTY_H_ */ diff --git a/sys/include/sys/types.h b/sys/include/sys/types.h deleted file mode 100644 index 8636d4b..0000000 --- a/sys/include/sys/types.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_TYPES_H_ -#define _SYS_TYPES_H_ - -#define NULL ((void *)0) -#define true 1 -#define false 0 - -typedef signed char int8_t; -typedef unsigned char uint8_t; -typedef short int16_t; -typedef unsigned short uint16_t; -typedef int int32_t; -typedef unsigned int uint32_t; -#if __SIZEOF_LONG__ == 8 -typedef long int64_t; -typedef unsigned long uint64_t; -#elif __SIZEOF_LONG__ == 4 -__extension__ -typedef long long int64_t; -__extension__ -typedef unsigned long long uint64_t; -#else -#error "Unsupported long size" -#endif - -#if __SIZEOF_SIZE_T__ == 8 -typedef uint64_t size_t; -typedef int64_t ssize_t; /* Byte count or error */ -#elif __SIZEOF_SIZE_T__ == 4 -typedef uint32_t size_t; -typedef int32_t ssize_t; /* Byte count or error */ -#else -#error "Unsupported size_t size" -#endif - -typedef _Bool bool; -typedef ssize_t off_t; -typedef size_t uintptr_t; -typedef int pid_t; -typedef int dev_t; - -#if defined(_KERNEL) -typedef uintptr_t vaddr_t; /* Virtual address */ -typedef uintptr_t paddr_t; /* Physical address */ -typedef uint32_t vm_prot_t; /* Access flags */ -#endif /* defined(_KERNEL) */ - -#endif /* !_SYS_TYPES_H_ */ diff --git a/sys/include/sys/vfs.h b/sys/include/sys/vfs.h deleted file mode 100644 index 1f7e423..0000000 --- a/sys/include/sys/vfs.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_VFS_H_ -#define _SYS_VFS_H_ - -#include <sys/mount.h> -#include <sys/vnode.h> -#include <sys/types.h> -#include <sys/sio.h> - -/* Max path length */ -#define PATH_MAX 1024 - -#if defined(_KERNEL) - -extern struct vnode *g_root_vnode; - -void vfs_init(void); -struct fs_info *vfs_byname(const char *name); - -int vfs_vget(struct vnode *parent, const char *name, struct vnode **vp); -int vfs_path_to_node(const char *path, struct vnode **vp); - -char *vfs_get_fname_at(const char *path, size_t idx); -int vfs_rootname(const char *path, char **new_path); - -bool vfs_is_valid_path(const char *path); -ssize_t vfs_hash_path(const char *path); - -ssize_t vfs_read(struct vnode *vp, struct sio_txn *sio); -ssize_t vfs_write(struct vnode *vp, struct sio_txn *sio); - -int vfs_getattr(struct vnode *vp, struct vattr *vattr); -int vfs_open(struct vnode *vp); - -int vfs_close(struct vnode *vp); -uint64_t sys_mount(struct syscall_args *args); - -#endif /* defined(_KERNEL) */ -#endif /* !_SYS_VFS_H_ */ diff --git a/sys/include/sys/vnode.h b/sys/include/sys/vnode.h deleted file mode 100644 index 8201f94..0000000 --- a/sys/include/sys/vnode.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_VNODE_H_ -#define _SYS_VNODE_H_ - -#include <sys/types.h> -#include <sys/queue.h> -#include <sys/mount.h> -#include <vm/obj.h> -#include <sys/sio.h> - -struct vnode; -struct vattr; - -struct vops { - int(*vget)(struct vnode *parent, const char *name, struct vnode **vp); - int(*read)(struct vnode *vp, struct sio_txn *sio); - int(*write)(struct vnode *vp, struct sio_txn *sio); - int(*getattr)(struct vnode *vp, struct vattr *vattr); - int(*open)(struct vnode *vp); - int(*close)(struct vnode *vp); -}; - -struct vattr { - size_t size; /* File size in bytes */ - int type; /* Vnode type */ -}; - -struct vnode { - int type; - int flags; - struct vm_object *vmobj; - struct mount *mp; /* Ptr to vfs vnode is in */ - struct vops *vops; - struct vnode *parent; - struct fs_info *fs; /* Filesystem this vnode belongs to, can be NULL */ - void *data; /* Filesystem specific data */ -}; - -/* - * Vnode type flags - */ -#define VREG 0x01 /* Regular file */ -#define VDIR 0x02 /* Directory */ -#define VCHR 0x03 /* Character device */ -#define VBLK 0x04 /* Block device */ - -#if defined(_KERNEL) -int vfs_alloc_vnode(struct vnode **vnode, struct mount *mp, int type); -#endif - -#endif diff --git a/sys/include/vm/dynalloc.h b/sys/include/vm/dynalloc.h deleted file mode 100644 index 44d2f5a..0000000 --- a/sys/include/vm/dynalloc.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * For documentation: See dynalloc(9) - */ - -#ifndef _VM_DYNALLOC_H_ -#define _VM_DYNALLOC_H_ - -#include <sys/types.h> - -void *dynalloc(size_t sz); -void *dynalloc_memalign(size_t sz, size_t align); -void *dynrealloc(void *old_ptr, size_t newsize); -void dynfree(void *ptr); - -#endif /* !_VM_DYNALLOC_H_ */ diff --git a/sys/include/vm/fault.h b/sys/include/vm/fault.h deleted file mode 100644 index f0e308c..0000000 --- a/sys/include/vm/fault.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _VM_FAULT_H_ -#define _VM_FAULT_H_ - -#include <sys/types.h> -#include <vm/pmap.h> - -int vm_fault(vaddr_t va, vm_prot_t access_type); - -#endif /* !_VM_FAULT_H_ */ diff --git a/sys/include/vm/map.h b/sys/include/vm/map.h deleted file mode 100644 index a1e74d9..0000000 --- a/sys/include/vm/map.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _VM_MMAP_H_ -#define _VM_MMAP_H_ - -#include <sys/types.h> -#include <sys/cdefs.h> -#include <sys/queue.h> -#include <sys/syscall.h> -#include <sys/spinlock.h> -#include <vm/pmap.h> -#include <vm/vm.h> - -#define MAP_SHARED 0x0001 -#define MAP_PRIVATE 0x0002 -#define MAP_ANONYMOUS 0x0010 -#define MAP_FAILED ((void *)-1) - -/* Memory map table entry count */ -#define MTAB_ENTRIES 32 - -struct vm_object; - -struct vm_mapping { - TAILQ_ENTRY(vm_mapping) link; - struct vm_range range; - struct vm_object *vmobj; - paddr_t physmem_base; - vm_prot_t prot; - - /* Private */ - size_t vhash; /* Virtual address hash */ -}; - -typedef TAILQ_HEAD(, vm_mapping) vm_mapq_t; - -struct vm_mapspace { - vm_mapq_t mtab[MTAB_ENTRIES]; /* Map table */ - size_t map_count; -}; - -/* Mapping operations */ -int vm_map_destroy(struct vas vas, vaddr_t va, size_t bytes); -int vm_map_create(struct vas vas, vaddr_t va, paddr_t pa, vm_prot_t prot, - size_t bytes); - -/* Syscalls */ -uint64_t sys_mmap(struct syscall_args *args); -uint64_t sys_munmap(struct syscall_args *args); - -/* Mapespace operations */ -void vm_mapspace_insert(struct vm_mapspace *ms, struct vm_mapping *mapping); -void vm_mapspace_remove(struct vm_mapspace *ms, struct vm_mapping *mapping); -struct vm_mapping *vm_mapping_fetch(struct vm_mapspace *ms, vaddr_t va); -void vm_free_mapq(vm_mapq_t *mapq); - -#endif /* !_VM_MMAP_H_ */ diff --git a/sys/include/vm/obj.h b/sys/include/vm/obj.h deleted file mode 100644 index 6e24516..0000000 --- a/sys/include/vm/obj.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _VM_OBJ_H_ -#define _VM_OBJ_H_ - -#include <sys/spinlock.h> -#include <sys/types.h> -#include <sys/vnode.h> -#include <vm/map.h> -#include <vm/pager.h> - -struct vm_object { - struct spinlock lock; /* Protects this object */ - struct vm_mapspace mapspace; /* Mapspace this object points to */ - struct vm_pagerops *pgops; /* Pager operations */ - - uint8_t is_anon : 1; /* Is an anonymous mapping */ - uint8_t demand : 1; /* Only mapped upon access */ - int ref; /* Ref count */ - struct vnode *vnode; /* Only used if `is_anon` is 0 */ -}; - -#define vm_object_ref(OBJPTR) (++(OBJPTR)->ref) -#define vm_object_unref(OBJPTR) do { \ - if ((OBJPTR)->ref > 0) { \ - --(OBJPTR)->ref; \ - } \ - } while (0); - -size_t vm_obj_count(void); -int vm_obj_init(struct vm_object **res, struct vnode *vnode); -int vm_obj_destroy(struct vm_object *obj); - -#endif /* !_VM_OBJ_H_ */ diff --git a/sys/include/vm/page.h b/sys/include/vm/page.h deleted file mode 100644 index 80fa74f..0000000 --- a/sys/include/vm/page.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _VM_PAGE_H_ -#define _VM_PAGE_H_ - -#include <sys/types.h> - -struct vm_page { - paddr_t physaddr; -}; - -void vm_zero_page(void *page, size_t page_count); - -#endif /* !_VM_PAGE_H_ */ diff --git a/sys/include/vm/pager.h b/sys/include/vm/pager.h deleted file mode 100644 index e57afe1..0000000 --- a/sys/include/vm/pager.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _VM_PAGER_H_ -#define _VM_PAGER_H_ - -#include <sys/types.h> -#include <vm/page.h> - -struct vm_object; - -struct vm_pagerops { - int(*get)(struct vm_object *obj, off_t off, size_t len, struct vm_page *pg); - int(*store)(struct vm_object *obj, off_t off, size_t len, struct vm_page *pg); - /* TODO: Remove this and add demand paging */ - int(*get_paddr)(struct vm_object *obj, paddr_t *paddr, vm_prot_t prot); -}; - -extern struct vm_pagerops g_vnode_pagerops; -extern struct vm_pagerops g_dev_pagerops; - -int vm_pager_get(struct vm_object *obj, off_t off, size_t len, struct vm_page *pg); -int vm_pager_paddr(struct vm_object *obj, paddr_t *paddr, vm_prot_t prot); - -#endif /* !_VM_PAGER_H_ */ diff --git a/sys/include/vm/physseg.h b/sys/include/vm/physseg.h deleted file mode 100644 index 956f82f..0000000 --- a/sys/include/vm/physseg.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _VM_VM_PHYSSEG_H_ -#define _VM_VM_PHYSSEG_H_ - -#include <sys/types.h> - -struct physmem_stat { - size_t reserved_kib; /* Reserved memory */ - size_t total_kib; /* Total memory */ - size_t avl_kib; /* Available memory */ - size_t alloc_kib; /* Allocated physical memory */ -}; - -void vm_physseg_init(void); -uintptr_t vm_alloc_pageframe(size_t count); - -void vm_free_pageframe(uintptr_t base, size_t count); -struct physmem_stat vm_phys_memstat(void); - -#endif /* !_VM_VM_PHYSSEG_H_ */ diff --git a/sys/include/vm/pmap.h b/sys/include/vm/pmap.h deleted file mode 100644 index cb18885..0000000 --- a/sys/include/vm/pmap.h +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _VM_PMAP_H_ -#define _VM_PMAP_H_ - -/* - * Each architecture is expected to implement - * this header. It should contain a `struct vas' - * which will contain information about a VAS - * (virtual address space) - * - * On AMD64 this struct contains: PML4, etc - * - * XXX: Compiler errors pointing to this include means you - * forgot to implement it!!! - * - * `struct vas' MUST have a `struct spinlock lock' field!!! - */ -#include <machine/vas.h> - -#include <vm/tlsf.h> -#include <sys/types.h> -#include <sys/spinlock.h> - -/* prot flags for mappings */ -#define PROT_WRITE __BIT(0) /* Writable */ -#define PROT_EXEC __BIT(1) /* Executable */ -#define PROT_USER __BIT(2) /* User accessible */ - -/* Caching types */ -#define VM_CACHE_UC 0x00000U /* Uncachable */ -#define VM_CACHE_WT 0x00001U /* Write-through */ - -#define is_vas_valid(vas) (vas.top_level != 0) - -/* - * vm_ctx - Per core virtual memory context - */ -struct vm_ctx { - uintptr_t dynalloc_pool_phys; - size_t dynalloc_pool_sz; /* In bytes */ - tlsf_t tlsf_ctx; - struct spinlock dynalloc_lock; -}; - -/* - * Mark a virtual address with a specific caching - * type. - */ -int pmap_set_cache(struct vm_ctx *, struct vas, vaddr_t, int); - -/* - * Create a virtual address space - * and return the descriptor. - */ -int pmap_create_vas(struct vm_ctx *, struct vas *); - -/* - * Switch the current virtual address space - * to another. - */ -void pmap_switch_vas(struct vm_ctx *, struct vas); - -/* - * Read virtual address space descriptor - * and return it. - */ -struct vas pmap_read_vas(void); - -/* - * Map a physical address to a virtual address. - */ -int pmap_map(struct vm_ctx *, struct vas, vaddr_t, paddr_t, vm_prot_t); - -/* - * Get rid of a virtual address space and free - * resources. - */ -int pmap_free_vas(struct vm_ctx *, struct vas); - -/* - * Unmap a page. - */ -int pmap_unmap(struct vm_ctx *, struct vas, vaddr_t); - -/* - * Architecture specific init code for pmap - */ -int pmap_init(struct vm_ctx *); -#endif /* _VM_PMAP_H_ */ diff --git a/sys/include/vm/tlsf.h b/sys/include/vm/tlsf.h deleted file mode 100644 index e9b5a91..0000000 --- a/sys/include/vm/tlsf.h +++ /dev/null @@ -1,90 +0,0 @@ -#ifndef INCLUDED_tlsf
-#define INCLUDED_tlsf
-
-/*
-** Two Level Segregated Fit memory allocator, version 3.1.
-** Written by Matthew Conte
-** http://tlsf.baisoku.org
-**
-** Based on the original documentation by Miguel Masmano:
-** http://www.gii.upv.es/tlsf/main/docs
-**
-** This implementation was written to the specification
-** of the document, therefore no GPL restrictions apply.
-**
-** Copyright (c) 2006-2016, Matthew Conte
-** All rights reserved.
-**
-** Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in the
-** documentation and/or other materials provided with the distribution.
-** * Neither the name of the copyright holder nor the
-** names of its contributors may be used to endorse or promote products
-** derived from this software without specific prior written permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-** DISCLAIMED. IN NO EVENT SHALL MATTHEW CONTE BE LIABLE FOR ANY
-** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#include <stddef.h>
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-/* tlsf_t: a TLSF structure. Can contain 1 to N pools. */
-/* pool_t: a block of memory that TLSF can manage. */
-typedef void* tlsf_t;
-typedef void* pool_t;
-
-/* Create/destroy a memory pool. */
-tlsf_t tlsf_create(void* mem);
-tlsf_t tlsf_create_with_pool(void* mem, size_t bytes);
-void tlsf_destroy(tlsf_t tlsf);
-pool_t tlsf_get_pool(tlsf_t tlsf);
-
-/* Add/remove memory pools. */
-pool_t tlsf_add_pool(tlsf_t tlsf, void* mem, size_t bytes);
-void tlsf_remove_pool(tlsf_t tlsf, pool_t pool);
-
-/* malloc/memalign/realloc/free replacements. */
-void* tlsf_malloc(tlsf_t tlsf, size_t bytes);
-void* tlsf_memalign(tlsf_t tlsf, size_t align, size_t bytes);
-void* tlsf_realloc(tlsf_t tlsf, void* ptr, size_t size);
-void tlsf_free(tlsf_t tlsf, void* ptr);
-
-/* Returns internal block size, not original request size */
-size_t tlsf_block_size(void* ptr);
-
-/* Overheads/limits of internal structures. */
-size_t tlsf_size(void);
-size_t tlsf_align_size(void);
-size_t tlsf_block_size_min(void);
-size_t tlsf_block_size_max(void);
-size_t tlsf_pool_overhead(void);
-size_t tlsf_alloc_overhead(void);
-
-/* Debugging. */
-typedef void (*tlsf_walker)(void* ptr, size_t size, int used, void* user);
-void tlsf_walk_pool(pool_t pool, tlsf_walker walker, void* user);
-/* Returns nonzero if any internal consistency check fails. */
-int tlsf_check(tlsf_t tlsf);
-int tlsf_check_pool(pool_t pool);
-
-#if defined(__cplusplus)
-};
-#endif
-
-#endif
diff --git a/sys/include/vm/vm.h b/sys/include/vm/vm.h deleted file mode 100644 index 1c23b8a..0000000 --- a/sys/include/vm/vm.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * For documentation: See vm(9) - */ - -#ifndef _VM_H_ -#define _VM_H_ - -#include <sys/types.h> -#include <sys/limine.h> -#include <sys/cdefs.h> -#include <vm/page.h> -#include <vm/pmap.h> -#include <vm/physseg.h> - -extern volatile struct limine_hhdm_request g_hhdm_request; - -#define VM_HIGHER_HALF (g_hhdm_request.response->offset) - -#define PHYS_TO_VIRT(phys) (void *)((uintptr_t)phys + VM_HIGHER_HALF) -#define VIRT_TO_PHYS(virt) ((uintptr_t)virt - VM_HIGHER_HALF) - -struct vm_range { - uintptr_t start; - uintptr_t end; -}; - -struct vm_memstat { - struct physmem_stat pmem_stat; - size_t vmobj_cnt; -}; - -/* - * Returns the machine's pagesize: - * - * XXX TODO: This needs to be moved to vmm_init.c - * while returning a non-constant value. - */ -static inline size_t -vm_get_page_size(void) -{ - return 4096; -} - -void vm_init(void); -struct vm_ctx *vm_get_ctx(void); -struct vas vm_get_kvas(void); -struct vm_memstat vm_memstat(void); - -#endif /* !_VM_H_ */ |