feat(ipc): implement synchronous Rendezvous IPC and multi-thread cooperative scheduler
This commit is contained in:
@@ -45,6 +45,30 @@ static inline sysret_t sys_ipc_call_raw(cap_t dest_cap, uint64_t msg_code,
|
||||
return (sysret_t)rax;
|
||||
}
|
||||
|
||||
static inline sysret_t sys_ipc_reply_recv_raw(cap_t listen_ep, uint64_t reply_to_tid,
|
||||
uint64_t reply_val0, uint64_t reply_val1,
|
||||
uint64_t *sender_tid, uint64_t *opcode,
|
||||
uint64_t *arg0, uint64_t *arg1) {
|
||||
register uint64_t rax __asm__("rax") = SYS_IPC_REPLY_RECV;
|
||||
register uint64_t rdi __asm__("rdi") = listen_ep;
|
||||
register uint64_t rsi __asm__("rsi") = reply_to_tid;
|
||||
register uint64_t rdx __asm__("rdx") = reply_val0;
|
||||
register uint64_t r8 __asm__("r8") = reply_val1;
|
||||
|
||||
__asm__ volatile(
|
||||
"syscall"
|
||||
: "+r"(rax), "+r"(rdi), "+r"(rsi), "+r"(rdx), "+r"(r8)
|
||||
:
|
||||
: "rcx", "r11", "memory"
|
||||
);
|
||||
|
||||
if (sender_tid) *sender_tid = rdi;
|
||||
if (opcode) *opcode = rsi;
|
||||
if (arg0) *arg0 = rdx;
|
||||
if (arg1) *arg1 = r8;
|
||||
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");
|
||||
|
||||
+7
-5
@@ -30,9 +30,11 @@ typedef uint32_t tid_t; /* Thread ID */
|
||||
|
||||
/* Standard Special Capabilities */
|
||||
#define CAP_NULL 0
|
||||
#define CAP_KERNEL_CONTROL 1
|
||||
#define CAP_SELF_TASK 1
|
||||
#define CAP_SELF_THREAD 2
|
||||
#define CAP_SELF_VMSPACE 3
|
||||
#define CAP_ROOT_CSPACE 4
|
||||
#define CAP_ROOT_IRQ 5
|
||||
#define CAP_ROOT_IO 6
|
||||
#define CAP_ROOT_SERVER 2
|
||||
#define CAP_SELF_THREAD 3
|
||||
#define CAP_SELF_VMSPACE 4
|
||||
#define CAP_ROOT_CSPACE 5
|
||||
#define CAP_ROOT_IRQ 6
|
||||
#define CAP_ROOT_IO 7
|
||||
|
||||
Reference in New Issue
Block a user