MCPcopy Create free account
hub / github.com/RPCSX/rpcsx / sys_mutex_create

Function sys_mutex_create

kernel/cellos/src/sys_mutex.cpp:31–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29}
30
31error_code sys_mutex_create(ppu_thread &ppu, vm::ptr<u32> mutex_id,
32 vm::ptr<sys_mutex_attribute_t> attr) {
33 ppu.state += cpu_flag::wait;
34
35 sys_mutex.trace("sys_mutex_create(mutex_id=*0x%x, attr=*0x%x)", mutex_id,
36 attr);
37
38 if (!mutex_id || !attr) {
39 return CELL_EFAULT;
40 }
41
42 const auto _attr = *attr;
43
44 const u64 ipc_key = lv2_obj::get_key(_attr);
45
46 if (ipc_key) {
47 sys_mutex.warning(
48 "sys_mutex_create(mutex_id=*0x%x, attr=*0x%x): IPC=0x%016x", mutex_id,
49 attr, ipc_key);
50 }
51
52 switch (_attr.protocol) {
53 case SYS_SYNC_FIFO:
54 break;
55 case SYS_SYNC_PRIORITY:
56 break;
57 case SYS_SYNC_PRIORITY_INHERIT:
58 sys_mutex.warning("sys_mutex_create(): SYS_SYNC_PRIORITY_INHERIT");
59 break;
60 default: {
61 sys_mutex.error("sys_mutex_create(): unknown protocol (0x%x)",
62 _attr.protocol);
63 return CELL_EINVAL;
64 }
65 }
66
67 switch (_attr.recursive) {
68 case SYS_SYNC_RECURSIVE:
69 break;
70 case SYS_SYNC_NOT_RECURSIVE:
71 break;
72 default: {
73 sys_mutex.error("sys_mutex_create(): unknown recursive (0x%x)",
74 _attr.recursive);
75 return CELL_EINVAL;
76 }
77 }
78
79 if (_attr.adaptive != SYS_SYNC_NOT_ADAPTIVE) {
80 sys_mutex.todo("sys_mutex_create(): unexpected adaptive (0x%x)",
81 _attr.adaptive);
82 }
83
84 if (auto error = lv2_obj::create<lv2_mutex>(
85 _attr.pshared, _attr.ipc_key, _attr.flags, [&]() {
86 return make_shared<lv2_mutex>(_attr.protocol, _attr.recursive,
87 _attr.adaptive, ipc_key,
88 _attr.name_u64);

Callers 8

sys_initialize_tlsFunction · 0.85
sys_lwmutex_createFunction · 0.85
adecOpenFunction · 0.85
sys_mempool_createFunction · 0.85
initMethod · 0.85
initMethod · 0.85

Calls 2

errorMethod · 0.80
check_stateMethod · 0.45

Tested by

no test coverage detected