this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Implement psynch with darlingserver

Like I stated in the corresponding darlingserver commit, this is the initial implementation, with more changes and fixes sure to be needed later. But for now, it certainly works!

+78 -156
-1
src/kernel/emulation/linux/CMakeLists.txt
··· 282 282 bsdthread/pthread_fchdir.c 283 283 bsdthread/pthread_markcancel.c 284 284 bsdthread/pthread_canceled.c 285 - psynch/psynch_errno.c 286 285 psynch/psynch_rw_rdlock.c 287 286 psynch/psynch_rw_wrlock.c 288 287 psynch/psynch_rw_unlock.c
+10 -14
src/kernel/emulation/linux/psynch/psynch_cvbroad.c
··· 1 1 #include "psynch_cvbroad.h" 2 2 #include "../base.h" 3 - #include "psynch_errno.h" 4 3 #include <linux-syscalls/linux.h> 5 - #include "../mach/lkm.h" 6 - #include "../../../../external/lkm/api.h" 4 + #include <darlingserver/rpc.h> 5 + #include "../simple.h" 7 6 8 7 long sys_psynch_cvbroad(void* cv, uint64_t cvlsgen, uint64_t cvudgen, uint32_t flags, void* mutex, uint64_t mugen, 9 8 uint64_t tid) 10 9 { 11 - struct psynch_cvbroad_args args = { 12 - .cv = cv, 13 - .cvlsgen = cvlsgen, 14 - .cvudgen = cvudgen, 15 - .mutex = mutex, 16 - .mugen = mugen, 17 - .tid = tid, 18 - .flags = flags, 19 - }; 10 + uint32_t retval; 11 + int ret = dserver_rpc_psynch_cvbroad(cv, cvlsgen, cvudgen, flags, mugen, mugen, tid, &retval); 20 12 21 - int rv = lkm_call_raw(NR_psynch_cvbroad_trap, &args); 22 - return psynch_errno(rv); 13 + if (ret < 0) { 14 + __simple_printf("psynch_cvbroad failed internally: %d", ret); 15 + __simple_abort(); 16 + } 17 + 18 + return (ret) ? ret : retval; 23 19 } 24 20
+9 -14
src/kernel/emulation/linux/psynch/psynch_cvclrprepost.c
··· 1 1 #include "psynch_cvclrprepost.h" 2 2 #include "../base.h" 3 - #include "psynch_errno.h" 4 3 #include <linux-syscalls/linux.h> 5 - #include "../mach/lkm.h" 6 - #include "../../../../external/lkm/api.h" 4 + #include <darlingserver/rpc.h> 7 5 #include "../simple.h" 8 6 9 7 long sys_psynch_cvclrprepost(void* cv, uint32_t cvgen, uint32_t cvugen, uint32_t cvsgen, uint32_t prepocnt, uint32_t preposeq, uint32_t flags) 10 8 { 11 - struct psynch_cvclrprepost_args args = { 12 - .cv = cv, 13 - .cvgen = cvgen, 14 - .cvugen = cvugen, 15 - .cvsgen = cvsgen, 16 - .prepocnt = prepocnt, 17 - .preposeq = preposeq, 18 - .flags = flags 19 - }; 9 + uint32_t retval; 10 + int ret = dserver_rpc_psynch_cvclrprepost(cv, cvgen, cvugen, cvsgen, prepocnt, preposeq, flags, &retval); 11 + 12 + if (ret < 0) { 13 + __simple_printf("psynch_cvclrprepost failed internally: %d", ret); 14 + __simple_abort(); 15 + } 20 16 21 - int rv = lkm_call_raw(NR_psynch_cvclrprepost, &args); 22 - return psynch_errno(rv); 17 + return (ret) ? ret : retval; 23 18 } 24 19
+8 -16
src/kernel/emulation/linux/psynch/psynch_cvsignal.c
··· 1 1 #include "psynch_cvsignal.h" 2 2 #include "../base.h" 3 - #include "psynch_errno.h" 4 3 #include <linux-syscalls/linux.h> 5 - #include "../mach/lkm.h" 6 - #include "../../../../external/lkm/api.h" 4 + #include <darlingserver/rpc.h> 7 5 #include "../simple.h" 8 6 9 7 long sys_psynch_cvsignal(void* cv, uint32_t cvlsgen, uint32_t cvugen, int thread_port, void* mutex, uint32_t mugen, 10 8 uint64_t tid, uint32_t flags) 11 9 { 12 - struct psynch_cvsignal_args args = { 13 - .cv = cv, 14 - .cvlsgen = cvlsgen, 15 - .cvugen = cvugen, 16 - .mutex = mutex, 17 - .mugen = mugen, 18 - .tid = tid, 19 - .thread_port = thread_port, 20 - .flags = flags, 21 - }; 10 + uint32_t retval; 11 + int ret = dserver_rpc_psynch_cvsignal(cv, cvlsgen, cvugen, thread_port, mutex, mugen, tid, flags, &retval); 22 12 23 - // __simple_printf("sys_psynch_mutexwait(mutex=%p, mgen=%x)\n", mutex, mgen); 13 + if (ret < 0) { 14 + __simple_printf("psynch_cvsignal failed internally: %d", ret); 15 + __simple_abort(); 16 + } 24 17 25 - int rv = lkm_call_raw(NR_psynch_cvsignal_trap, &args); 26 - return psynch_errno(rv); 18 + return (ret) ? ret : retval; 27 19 } 28 20
+8 -16
src/kernel/emulation/linux/psynch/psynch_cvwait.c
··· 1 1 #include "psynch_cvwait.h" 2 2 #include "../base.h" 3 - #include "psynch_errno.h" 4 3 #include <linux-syscalls/linux.h> 5 - #include "../mach/lkm.h" 6 - #include "../../../../external/lkm/api.h" 4 + #include <darlingserver/rpc.h> 7 5 #include "../simple.h" 8 6 9 7 10 8 long sys_psynch_cvwait(void* cv, uint64_t cvlsgen, uint32_t cvugen, void * mutex, uint64_t mugen, 11 9 uint32_t flags, int64_t sec, uint32_t nsec) 12 10 { 13 - struct psynch_cvwait_args args = { 14 - .cv = cv, 15 - .cvlsgen = cvlsgen, 16 - .cvugen = cvugen, 17 - .mutex = mutex, 18 - .mugen = mugen, 19 - .flags = flags, 20 - .sec = sec, 21 - .nsec = nsec, 22 - }; 11 + uint32_t retval; 12 + int ret = dserver_rpc_psynch_cvwait(cv, cvlsgen, cvugen, mutex, mugen, flags, sec, nsec, &retval); 23 13 24 - // __simple_printf("sys_psynch_mutexwait(mutex=%p, mgen=%x)\n", mutex, mgen); 14 + if (ret < 0) { 15 + __simple_printf("psynch_cvwait failed internally: %d", ret); 16 + __simple_abort(); 17 + } 25 18 26 - int rv = lkm_call_raw(NR_psynch_cvwait_trap, &args); 27 - return psynch_errno(rv); 19 + return (ret) ? ret : retval; 28 20 } 29 21
-26
src/kernel/emulation/linux/psynch/psynch_errno.c
··· 1 - #include "../errno.h" 2 - 3 - #ifndef USE_NEW_PSYNC_CODE 4 - #define USE_NEW_PSYNC_CODE 0 5 - #endif 6 - 7 - // psynch syscalls send back extra bits and leave only the bottom 8 bits for errors 8 - // So we have to filter out the top 24 bits, translate errno and put the 24 bits back. 9 - int psynch_errno(int rv) 10 - { 11 - int top; 12 - if (rv >= 0) 13 - return rv; 14 - 15 - rv = -rv; 16 - top = rv & 0xffffff00; 17 - #if USE_NEW_PSYNC_CODE 18 - rv = rv & 0xff; 19 - #else 20 - rv = errno_linux_to_bsd(rv & 0xff); 21 - #endif 22 - rv |= top; 23 - 24 - return -rv; 25 - } 26 -
-7
src/kernel/emulation/linux/psynch/psynch_errno.h
··· 1 - #ifndef _PSYNCH_ERRNO_H 2 - #define _PSYNCH_ERRNO_H 3 - 4 - int psynch_errno(int rv); 5 - 6 - #endif 7 -
+8 -13
src/kernel/emulation/linux/psynch/psynch_mutexdrop.c
··· 1 1 #include "psynch_mutexdrop.h" 2 2 #include "../base.h" 3 - #include "psynch_errno.h" 4 3 #include <linux-syscalls/linux.h> 5 - #include "../mach/lkm.h" 6 - #include "../../../../external/lkm/api.h" 4 + #include <darlingserver/rpc.h> 7 5 #include "../simple.h" 8 6 9 7 long sys_psynch_mutexdrop(void* mutex, uint32_t mgen, uint32_t ugen, uint64_t tid, uint32_t flags) 10 8 { 11 - struct psynch_mutexdrop_args args = { 12 - .mutex = (unsigned long) mutex, 13 - .mgen = mgen, 14 - .ugen = ugen, 15 - .tid = tid, 16 - .flags = flags 17 - }; 9 + uint32_t retval; 10 + int ret = dserver_rpc_psynch_mutexdrop(mutex, mgen, ugen, tid, flags, &retval); 18 11 19 - // __simple_printf("sys_psynch_mutexdrop(mutex=%p, mgen=%x)\n", mutex, mgen); 12 + if (ret < 0) { 13 + __simple_printf("psynch_mutexdrop failed internally: %d", ret); 14 + __simple_abort(); 15 + } 20 16 21 - int rv = lkm_call_raw(NR_psynch_mutexdrop_trap, &args); 22 - return psynch_errno(rv); 17 + return (ret) ? ret : retval; 23 18 } 24 19
+8 -13
src/kernel/emulation/linux/psynch/psynch_mutexwait.c
··· 1 1 #include "psynch_mutexwait.h" 2 2 #include "../base.h" 3 - #include "psynch_errno.h" 4 3 #include <linux-syscalls/linux.h> 5 - #include "../mach/lkm.h" 6 - #include "../../../../external/lkm/api.h" 4 + #include <darlingserver/rpc.h> 7 5 #include "../simple.h" 8 6 9 7 long sys_psynch_mutexwait(void* mutex, uint32_t mgen, uint32_t ugen, uint64_t tid, uint32_t flags) 10 8 { 11 - struct psynch_mutexwait_args args = { 12 - .mutex = (unsigned long) mutex, 13 - .mgen = mgen, 14 - .ugen = ugen, 15 - .tid = tid, 16 - .flags = flags 17 - }; 9 + uint32_t retval; 10 + int ret = dserver_rpc_psynch_mutexwait(mutex, mgen, ugen, tid, flags, &retval); 18 11 19 - // __simple_printf("sys_psynch_mutexwait(mutex=%p, mgen=%x)\n", mutex, mgen); 12 + if (ret < 0) { 13 + __simple_printf("psynch_mutexwait failed internally: %d", ret); 14 + __simple_abort(); 15 + } 20 16 21 - int rv = lkm_call_raw(NR_psynch_mutexwait_trap, &args); 22 - return psynch_errno(rv); 17 + return (ret) ? ret : retval; 23 18 } 24 19
+9 -12
src/kernel/emulation/linux/psynch/psynch_rw_rdlock.c
··· 1 1 #include "psynch_rw_rdlock.h" 2 2 #include "../base.h" 3 - #include "psynch_errno.h" 4 3 #include <linux-syscalls/linux.h> 5 - #include "../mach/lkm.h" 6 - #include "../../../../external/lkm/api.h" 4 + #include <darlingserver/rpc.h> 7 5 #include "../simple.h" 8 6 9 7 long sys_psynch_rw_rdlock(void* rwlock, uint32_t lgenval, uint32_t ugenval, uint32_t rw_wc, int flags) 10 8 { 11 - struct psynch_rw_rdlock_args args = { 12 - .rwlock = rwlock, 13 - .lgenval = lgenval, 14 - .ugenval = ugenval, 15 - .rw_wc = rw_wc, 16 - .flags = flags 17 - }; 9 + uint32_t retval; 10 + int ret = dserver_rpc_psynch_rw_rdlock(rwlock, lgenval, ugenval, rw_wc, flags, &retval); 11 + 12 + if (ret < 0) { 13 + __simple_printf("psynch_rw_rdlock failed internally: %d", ret); 14 + __simple_abort(); 15 + } 18 16 19 - int rv = lkm_call_raw(NR_psynch_rw_rdlock, &args); 20 - return psynch_errno(rv); 17 + return (ret) ? ret : retval; 21 18 } 22 19
+9 -12
src/kernel/emulation/linux/psynch/psynch_rw_unlock.c
··· 1 1 #include "psynch_rw_unlock.h" 2 2 #include "../base.h" 3 - #include "psynch_errno.h" 4 3 #include <linux-syscalls/linux.h> 5 - #include "../mach/lkm.h" 6 - #include "../../../../external/lkm/api.h" 4 + #include <darlingserver/rpc.h> 7 5 #include "../simple.h" 8 6 9 7 long sys_psynch_rw_unlock(void* rwlock, uint32_t lgenval, uint32_t ugenval, uint32_t rw_wc, int flags) 10 8 { 11 - struct psynch_rw_unlock_args args = { 12 - .rwlock = rwlock, 13 - .lgenval = lgenval, 14 - .ugenval = ugenval, 15 - .rw_wc = rw_wc, 16 - .flags = flags 17 - }; 9 + uint32_t retval; 10 + int ret = dserver_rpc_psynch_rw_unlock(rwlock, lgenval, ugenval, rw_wc, flags, &retval); 11 + 12 + if (ret < 0) { 13 + __simple_printf("psynch_rw_unlock failed internally: %d", ret); 14 + __simple_abort(); 15 + } 18 16 19 - int rv = lkm_call_raw(NR_psynch_rw_unlock, &args); 20 - return psynch_errno(rv); 17 + return (ret) ? ret : retval; 21 18 } 22 19
+9 -12
src/kernel/emulation/linux/psynch/psynch_rw_wrlock.c
··· 1 1 #include "psynch_rw_wrlock.h" 2 2 #include "../base.h" 3 - #include "psynch_errno.h" 4 3 #include <linux-syscalls/linux.h> 5 - #include "../mach/lkm.h" 6 - #include "../../../../external/lkm/api.h" 4 + #include <darlingserver/rpc.h> 7 5 #include "../simple.h" 8 6 9 7 long sys_psynch_rw_wrlock(void* rwlock, uint32_t lgenval, uint32_t ugenval, uint32_t rw_wc, int flags) 10 8 { 11 - struct psynch_rw_wrlock_args args = { 12 - .rwlock = rwlock, 13 - .lgenval = lgenval, 14 - .ugenval = ugenval, 15 - .rw_wc = rw_wc, 16 - .flags = flags 17 - }; 9 + uint32_t retval; 10 + int ret = dserver_rpc_psynch_rw_wrlock(rwlock, lgenval, ugenval, rw_wc, flags, &retval); 11 + 12 + if (ret < 0) { 13 + __simple_printf("psynch_rw_wrlock failed internally: %d", ret); 14 + __simple_abort(); 15 + } 18 16 19 - int rv = lkm_call_raw(NR_psynch_rw_wrlock, &args); 20 - return psynch_errno(rv); 17 + return (ret) ? ret : retval; 21 18 } 22 19