feat: implement PS/2 keyboard & shell, dynamic heap (malloc/new), Zero-Copy SHM, and SMP multicore initialization
This commit is contained in:
+36
-2
@@ -6,12 +6,14 @@
|
||||
#define SYS_IPC_CALL 1 /* Synchronous call: send message & wait for reply */
|
||||
#define SYS_IPC_REPLY_RECV 2 /* Server fast-path: reply to current and wait next */
|
||||
#define SYS_IPC_SEND 3 /* Asynchronous/non-blocking send */
|
||||
#define SYS_IPC_RECV 4 /* Block waiting for incoming message */
|
||||
#define SYS_MEM_MAP 5 /* Map memory / shared memory region */
|
||||
#define SYS_MEM_SHARE 4 /* Map shared physical memory between processes */
|
||||
#define SYS_MEM_ALLOC 5 /* Dynamically allocate virtual pages in process space */
|
||||
#define SYS_CAP_GRANT 6 /* Delegate capability to CNode */
|
||||
#define SYS_THREAD_YIELD 7 /* Yield CPU slice */
|
||||
#define SYS_THREAD_EXIT 8 /* Terminate current thread */
|
||||
#define SYS_LOG_DEBUG 9 /* Direct Ring 0 debug print */
|
||||
#define SYS_KEY_READ 10 /* Read character from keyboard buffer */
|
||||
#define SYS_SYSINFO 11 /* Query system/memory/thread information */
|
||||
|
||||
#ifndef __ASSEMBLER__
|
||||
|
||||
@@ -69,6 +71,38 @@ static inline sysret_t sys_ipc_reply_recv_raw(cap_t listen_ep, uint64_t reply_to
|
||||
return (sysret_t)rax;
|
||||
}
|
||||
|
||||
static inline void *sys_mem_alloc(size_t size_bytes) {
|
||||
register uint64_t rax __asm__("rax") = SYS_MEM_ALLOC;
|
||||
register uint64_t rdi __asm__("rdi") = (uint64_t)size_bytes;
|
||||
__asm__ volatile("syscall" : "+r"(rax) : "r"(rdi) : "rcx", "r11", "memory");
|
||||
return (void *)rax;
|
||||
}
|
||||
|
||||
static inline sysret_t sys_mem_share(uint64_t target_tid, uintptr_t src_vaddr, size_t size, uintptr_t target_vaddr) {
|
||||
register uint64_t rax __asm__("rax") = SYS_MEM_SHARE;
|
||||
register uint64_t rdi __asm__("rdi") = target_tid;
|
||||
register uint64_t rsi __asm__("rsi") = (uint64_t)src_vaddr;
|
||||
register uint64_t rdx __asm__("rdx") = (uint64_t)size;
|
||||
register uint64_t r8 __asm__("r8") = (uint64_t)target_vaddr;
|
||||
__asm__ volatile("syscall" : "+r"(rax) : "r"(rdi), "r"(rsi), "r"(rdx), "r"(r8) : "rcx", "r11", "memory");
|
||||
return (sysret_t)rax;
|
||||
}
|
||||
|
||||
static inline int sys_key_read(void) {
|
||||
register uint64_t rax __asm__("rax") = SYS_KEY_READ;
|
||||
__asm__ volatile("syscall" : "+r"(rax) : : "rcx", "r11", "memory");
|
||||
return (int)rax;
|
||||
}
|
||||
|
||||
static inline sysret_t sys_sysinfo(uint64_t info_type, void *out_buf, size_t max_len) {
|
||||
register uint64_t rax __asm__("rax") = SYS_SYSINFO;
|
||||
register uint64_t rdi __asm__("rdi") = info_type;
|
||||
register uint64_t rsi __asm__("rsi") = (uint64_t)out_buf;
|
||||
register uint64_t rdx __asm__("rdx") = (uint64_t)max_len;
|
||||
__asm__ volatile("syscall" : "+r"(rax) : "r"(rdi), "r"(rsi), "r"(rdx) : "rcx", "r11", "memory");
|
||||
return (sysret_t)rax;
|
||||
}
|
||||
|
||||
static inline sysret_t sys_yield(void) {
|
||||
register uint64_t rax __asm__("rax") = SYS_THREAD_YIELD;
|
||||
__asm__ volatile("syscall" : "+r"(rax) : : "rcx", "r11", "memory");
|
||||
|
||||
Reference in New Issue
Block a user