this repo has no description
1
fork

Configure Feed

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

Initial psynch_mutex* syscall implementation

+126 -22
+2
src/kernel/emulation/linux/CMakeLists.txt
··· 138 138 bsdthread/bsdthread_create.c 139 139 bsdthread/bsdthread_terminate.c 140 140 bsdthread/disable_threadsignal.c 141 + psynch/psynch_mutexwait.c 142 + psynch/psynch_mutexdrop.c 141 143 syscalls-amd64.asm 142 144 ) 143 145
+23
src/kernel/emulation/linux/psynch/psynch_mutexdrop.c
··· 1 + #include "psynch_mutexdrop.h" 2 + #include "../base.h" 3 + #include "../errno.h" 4 + #include <asm/unistd.h> 5 + #include "../../../mach_server/client/lkm.h" 6 + #include "../../../../lkm/api.h" 7 + #include "../simple.h" 8 + 9 + long sys_psynch_mutexdrop(void* mutex, uint32_t mgen, uint32_t ugen, uint64_t tid, uint32_t flags) 10 + { 11 + struct psynch_mutexdrop_args args = { 12 + .mutex = (unsigned long) mutex, 13 + .mgen = mgen, 14 + .ugen = ugen, 15 + .tid = tid, 16 + .flags = flags 17 + }; 18 + 19 + // __simple_printf("sys_psynch_mutexdrop(mutex=%p, mgen=%x)\n", mutex, mgen); 20 + 21 + return lkm_call(NR_psynch_mutexdrop_trap, &args); 22 + } 23 +
+8
src/kernel/emulation/linux/psynch/psynch_mutexdrop.h
··· 1 + #ifndef LINUX_PSYNCH_MUTEXDROP_H 2 + #define LINUX_PSYNCH_MUTEXDROP_H 3 + #include <stdint.h> 4 + 5 + long sys_psynch_mutexdrop(void* mutex, uint32_t mgen, uint32_t ugen, uint64_t tid, uint32_t flags); 6 + 7 + #endif 8 +
+23
src/kernel/emulation/linux/psynch/psynch_mutexwait.c
··· 1 + #include "psynch_mutexwait.h" 2 + #include "../base.h" 3 + #include "../errno.h" 4 + #include <asm/unistd.h> 5 + #include "../../../mach_server/client/lkm.h" 6 + #include "../../../../lkm/api.h" 7 + #include "../simple.h" 8 + 9 + long sys_psynch_mutexwait(void* mutex, uint32_t mgen, uint32_t ugen, uint64_t tid, uint32_t flags) 10 + { 11 + struct psynch_mutexwait_args args = { 12 + .mutex = (unsigned long) mutex, 13 + .mgen = mgen, 14 + .ugen = ugen, 15 + .tid = tid, 16 + .flags = flags 17 + }; 18 + 19 + // __simple_printf("sys_psynch_mutexwait(mutex=%p, mgen=%x)\n", mutex, mgen); 20 + 21 + return lkm_call(NR_psynch_mutexwait_trap, &args); 22 + } 23 +
+8
src/kernel/emulation/linux/psynch/psynch_mutexwait.h
··· 1 + #ifndef LINUX_PSYNCH_MUTEXWAIT_H 2 + #define LINUX_PSYNCH_MUTEXWAIT_H 3 + #include <stdint.h> 4 + 5 + long sys_psynch_mutexwait(void* mutex, uint32_t mgen, uint32_t ugen, uint64_t tid, uint32_t flags); 6 + 7 + #endif 8 +
+53 -22
src/kernel/emulation/linux/simple.c
··· 30 30 *buf++ = '%'; 31 31 break; 32 32 case 's': 33 + { 34 + const char* str = va_arg(vl, const char*); 35 + while (*str) 33 36 { 34 - const char* str = va_arg(vl, const char*); 35 - while (*str) 36 - { 37 - *buf++ = *str; 38 - str++; 39 - } 40 - break; 37 + *buf++ = *str; 38 + str++; 41 39 } 40 + break; 41 + } 42 42 case 'd': 43 + { 44 + int num = va_arg(vl, int); 45 + char temp[16]; 46 + int count = 0; 47 + 48 + if (num < 0) 49 + *buf++ = '-'; 50 + 51 + do 43 52 { 44 - int num = va_arg(vl, int); 45 - char temp[16]; 46 - int count = 0; 53 + temp[count++] = '0' + (num % 10); 54 + num /= 10; 55 + } 56 + while (num > 0); 57 + 58 + while (count--) 59 + *buf++ = temp[count]; 60 + 61 + break; 62 + } 63 + case 'p': 64 + case 'x': 65 + { 66 + unsigned long num = va_arg(vl, unsigned long); 67 + char temp[40]; 68 + int count = 0; 47 69 48 - if (num < 0) 49 - *buf++ = '-'; 70 + if (*format == 'p') 71 + { 72 + *buf++ = '0'; 73 + *buf++ = 'x'; 74 + } 50 75 51 - do 52 - { 53 - temp[count++] = '0' + (num % 10); 54 - num /= 10; 55 - } 56 - while (num > 0); 57 - 58 - while (count--) 59 - *buf++ = temp[count]; 76 + do 77 + { 78 + int c = (num % 16); 60 79 61 - break; 80 + if (c < 10) 81 + temp[count++] = '0' + c; 82 + else 83 + temp[count++] = 'A' + (c - 10); 84 + num /= 16; 62 85 } 86 + while (num > 0); 87 + 88 + while (count--) 89 + *buf++ = temp[count]; 90 + 91 + break; 92 + 93 + } 63 94 } 64 95 65 96 format++;
+4
src/kernel/emulation/linux/syscalls.c
··· 101 101 #include "xattr/setxattr.h" 102 102 #include "xattr/fsetxattr.h" 103 103 #include "select/select.h" 104 + #include "psynch/psynch_mutexwait.h" 105 + #include "psynch/psynch_mutexdrop.h" 104 106 105 107 void* __bsd_syscall_table[512] = { 106 108 [1] = sys_exit, ··· 209 211 [239] = sys_fremovexattr, 210 212 [240] = sys_listxattr, 211 213 [241] = sys_flistxattr, 214 + [301] = sys_psynch_mutexwait, 215 + [302] = sys_psynch_mutexdrop, 212 216 [331] = sys_disable_threadsignal, 213 217 [334] = sys_semwait_signal, 214 218 [338] = sys_stat64,
+4
src/kernel/mach_server/client/lkm.c
··· 30 30 } 31 31 } 32 32 33 + int lkm_call(int call_nr, void* arg) 34 + { 35 + return __real_ioctl(driver_fd, call_nr, arg); 36 + } 33 37
+1
src/kernel/mach_server/client/lkm.h
··· 2 2 #define _LKM_H 3 3 4 4 void mach_driver_init(void); 5 + int lkm_call(int call_nr, void* arg); 5 6 6 7 __attribute__((visibility("hidden"))) 7 8 extern int driver_fd;