diff options
author | Jon Santmyer <jon@jonsantmyer.com> | 2025-08-10 15:40:19 -0400 |
---|---|---|
committer | Jon Santmyer <jon@jonsantmyer.com> | 2025-08-10 15:40:19 -0400 |
commit | c4f8ef91f18d854a4ede7a94e95b2eab898d6963 (patch) | |
tree | c2772c4f380a684b6fa347f03b13f9476bf9500c /include | |
parent | b905869a35f062a4e5072f10bec3a2ba3db0e365 (diff) | |
download | jove-kernel-c4f8ef91f18d854a4ede7a94e95b2eab898d6963.tar.gz jove-kernel-c4f8ef91f18d854a4ede7a94e95b2eab898d6963.tar.bz2 jove-kernel-c4f8ef91f18d854a4ede7a94e95b2eab898d6963.zip |
working usermode objdir iteration
Diffstat (limited to 'include')
-rw-r--r-- | include/arch/x86_64/object.h | 12 | ||||
-rw-r--r-- | include/arch/x86_64/page.h | 8 | ||||
-rw-r--r-- | include/arch/x86_64/syscall.h | 18 | ||||
-rw-r--r-- | include/device/uart.h | 3 | ||||
-rw-r--r-- | include/error.h | 17 | ||||
-rw-r--r-- | include/lock.h | 20 | ||||
-rw-r--r-- | include/memory.h | 3 | ||||
-rw-r--r-- | include/object.h | 22 | ||||
-rw-r--r-- | include/print.h | 2 | ||||
-rw-r--r-- | include/syscall.h | 44 |
10 files changed, 107 insertions, 42 deletions
diff --git a/include/arch/x86_64/object.h b/include/arch/x86_64/object.h index 8d5af33..6512049 100644 --- a/include/arch/x86_64/object.h +++ b/include/arch/x86_64/object.h @@ -3,15 +3,18 @@ #include <stdint.h> +#ifndef KERNEL_STACKBYTES +#define KERNEL_STACKBYTES 4096 +#endif + typedef struct jove_InitData { uint8_t log_object; - uint8_t untyped_data_dir; - uint8_t processor_dir; + uint16_t untyped_data_dir; + uint16_t processor_dir; uint8_t pm_object; //Page mapping object. - uint8_t initrd_dir; //Init ramdisk files directory. + uint16_t initrd_dir; //Init ramdisk files directory. uint8_t tcb_object; - uint8_t kernel_stack_object; uint8_t message_object; uintptr_t message_object_address; } init_data_t; @@ -21,6 +24,7 @@ typedef struct jove_ThreadControlBlock void *stack; uintptr_t sp, ksp; void *pml4; + uint8_t kstack[KERNEL_STACKBYTES]; } tcb_t; #endif diff --git a/include/arch/x86_64/page.h b/include/arch/x86_64/page.h index 99bc691..4460720 100644 --- a/include/arch/x86_64/page.h +++ b/include/arch/x86_64/page.h @@ -4,6 +4,11 @@ #include <stdint.h> #include "include/object.h" +#define PAGE_PRESENT (1ULL << 0) +#define PAGE_RW (1ULL << 1) +#define PAGE_US (1ULL << 2) +#define PAGE_XD (1ULL << 63) + typedef union jove_PageMapLevelEntry { struct { @@ -16,7 +21,7 @@ typedef union jove_PageMapLevelEntry uint8_t d : 1; /* Dirty */ uint8_t ps_pat : 1; uint8_t g : 1; /* Global */ - uint8_t _r0 : 2; + uint8_t osflg : 2; uint8_t r : 1; uint64_t paddr : 35; uint8_t _r1; @@ -35,6 +40,7 @@ uintptr_t vmem_ident_tophys(void *vptr); void *vmem_phys_tovirt(uintptr_t pptr); void *pmle_get_page(pmle_t entry); +uint8_t pmle_level(pmle_t entry); int untyped_retype_page(objdir_entry_t *untyped_entry, void **dest_ptr); diff --git a/include/arch/x86_64/syscall.h b/include/arch/x86_64/syscall.h new file mode 100644 index 0000000..2d5060e --- /dev/null +++ b/include/arch/x86_64/syscall.h @@ -0,0 +1,18 @@ +#ifndef _JOVE_ARCH_x86_64_SYSCALL_H +#define _JOVE_ARCH_x86_64_SYSCALL_H 1 + +/**@ENUM mapping invokes*/ +enum +{ + /*[target path][u8 funcid]*/ + INVOKE_MAPPING_RELEASE = 0, + /*[target path][u8 funcid][u16 pmli][dest path]*/ + INVOKE_MAPPING_GET, + /*[target path][u8 funcid][u16 pmli][untyped path][u64 flags]*/ + INVOKE_MAPPING_MAP, + /*[target path][u8 funcid][u16 pmli][mapped path]*/ + INVOKE_MAPPING_UNMAP +}; + + +#endif diff --git a/include/device/uart.h b/include/device/uart.h index 3d481a2..9e5c3d3 100644 --- a/include/device/uart.h +++ b/include/device/uart.h @@ -1,11 +1,10 @@ #ifndef _JOVE_DEVICE_UART_H #define _JOVE_DEVICE_UART_H 1 -#include <stdint.h> #include <stddef.h> #include "object.h" -void uart_write(objdir_t *dir, uint64_t entryi, const char *s, size_t w); +void uart_write(objdir_t *dir, path_byte_t *path, const char *s, size_t w); #endif diff --git a/include/error.h b/include/error.h index 8aa087c..40a39e2 100644 --- a/include/error.h +++ b/include/error.h @@ -5,4 +5,21 @@ #define E_BADOBJ 1 #define E_ARGUMENT 2 +enum +{ + KE_OK = 0, + KE_BADOBJ, + KE_BADFUNC, + KE_BADTYPE, + KE_BADMSG, + KE_BADCALL, + KE_FULL, + KE_TOOSMALL, + KE_OOB, + KE_DNE, + KE_ALIGN, + KE_BADSIZE, + KE_OCCUPIED +}; + #endif diff --git a/include/lock.h b/include/lock.h new file mode 100644 index 0000000..412aabf --- /dev/null +++ b/include/lock.h @@ -0,0 +1,20 @@ +#ifndef _JOVE_LOCK_H +#define _JOVE_LOCK_H 1 + +void _mtx_acquire(unsigned char *mtx); +void _mtx_release(unsigned char *mtx); + +#ifdef DBG_LOCK +#include "print.h" +#define mtx_acquire(mtx) \ + klogf("Lock %p\n", mtx); \ + _mtx_acquire(mtx) +#define mtx_release(mtx) \ + klogf("Release %p\n", mtx); \ + _mtx_release(mtx) +#else +#define mtx_acquire(mtx) _mtx_acquire(mtx) +#define mtx_release(mtx) _mtx_release(mtx) +#endif + +#endif diff --git a/include/memory.h b/include/memory.h index e29c41b..7e668ae 100644 --- a/include/memory.h +++ b/include/memory.h @@ -14,4 +14,7 @@ void vmem_setup(void); int untyped_retype_kernel_stack(objdir_entry_t *untyped_entry, objdir_entry_t *dest_entry); +void *ko_entry_data(objdir_entry_t *entry); +uintptr_t ko_data_toentry(uintptr_t vptr); + #endif diff --git a/include/object.h b/include/object.h index 0a71b5f..190b082 100644 --- a/include/object.h +++ b/include/object.h @@ -14,11 +14,9 @@ enum KO_OBJECT_DIRECTORY, KO_INIT_DATA, KO_MEMORY_UNTYPED, - KO_MEMORY_MAPPED_PAGE, //4KiB Fixed Width - KO_MEMORY_MAPPING_PAGE, //4Kib Fixed Width + KO_MEMORY_MAPPING, //4KiB aligned fixed width KO_INITRD_FILE, KO_TCB, - KO_KERNEL_STACK, KO_MESSAGE, /* Device objects*/ KO_DEV_INVALID = 0x100, @@ -26,7 +24,10 @@ enum KO_DEV_UART }; -typedef uintmax_t obj_path_t; +#define KO_MESSAGE_BYTES 4096 +#define KO_MESSAGE_ALIGN 0x1000 + +typedef uint8_t path_byte_t; typedef uint16_t obj_type_t; typedef struct jove_ObjectDirectoryEntry @@ -34,10 +35,9 @@ typedef struct jove_ObjectDirectoryEntry obj_type_t type; union { struct { - char lock : 1; - char u0 : 7; - char u1; -}; + unsigned char lock; + char u0; + }; unsigned short flg; }; uintmax_t data; @@ -45,9 +45,6 @@ typedef struct jove_ObjectDirectoryEntry #define OBJECT_DIRECTORY_MAX_ENTRIES 256 -//The first entry always represents itself, which allows the kernel to ignore -//some checks. -//The data variable also contains the next free index for this directory. typedef struct jove_ObjectDirectory { union { @@ -56,6 +53,7 @@ typedef struct jove_ObjectDirectory }; } objdir_t; -objdir_entry_t *objdir_seek(objdir_t *dir, uintmax_t index); +objdir_entry_t *objdir_seek(objdir_t *dir, uint8_t *path, unsigned long pathw); +unsigned long objdir_pathw(objdir_t *dir, uint8_t *path); #endif diff --git a/include/print.h b/include/print.h index f4c942c..988333f 100644 --- a/include/print.h +++ b/include/print.h @@ -14,4 +14,6 @@ int kvprintf(const char *fmt, va_list ap); int kvsprintf(char *s, const char *fmt, va_list ap); int kvsnprintf(char *s, int size, const char *fmt, va_list ap); +void kprint_objpath(unsigned char *path, int len); + #endif diff --git a/include/syscall.h b/include/syscall.h index c9c26d8..e70ba82 100644 --- a/include/syscall.h +++ b/include/syscall.h @@ -1,9 +1,7 @@ #ifndef _JOVE_SYSCALL_H #define _JOVE_SYSCALL_H 1 -#include <stdint.h> #include <stddef.h> -#include "object.h" enum { @@ -12,35 +10,35 @@ enum SYSCALL_SEND, SYSCALL_RECV, - SYSCALL_DEBUG_PUTC, - SYSCALL_DEBUG_IDENTIFY + SYSCALL_DEBUG_PUTC }; -typedef uint16_t invokeid_t; - -struct syscallInvokeHeader -{ - obj_path_t target_path; - invokeid_t func_id; -}; +/* Generic payload of SYSCALL_INVOKE: + * [ n bytes ][ uint8_t ][ payload ] + * target entry funcid + * */ +/**@ENUM objdir invokes*/ enum { + /*[target path][u8 funcid][u8 ret]*/ INVOKE_OBJDIR_NMEMB = 0, - INVOKE_OBJDIR_GETMEMB -}; - -struct syscallInvoke_objdir_nmemb -{ - struct syscallInvokeHeader header; - size_t value; + /*[target path][u8 funcid][u8 memb][u16 ret]*/ + INVOKE_OBJDIR_GETMEMB, + /*[target path][u8 funcid][u8 ret]*/ + INVOKE_OBJDIR_LASTFREE }; - -struct syscallInvoke_objdir_getmemb +/**@ENUM untyped invokes*/ +enum { - struct syscallInvokeHeader header; - uint8_t member; - obj_type_t value; + /*[target path][u8 funcid][size_t ret]*/ + INVOKE_UNTYPED_SIZE = 0, + /*[target path][u8 funcid][dest path][dest bytes]*/ + INVOKE_UNTYPED_SPLIT, + /*[first path][u8 funcid][second path]*/ + INVOKE_UNTYPED_MERGE, + /*[target path][u8 funcid][size_t ret]*/ + INVOKE_UNTYPED_ALIGNMENT }; #endif |