removed excessive stuff

This commit is contained in:
Nekotekina 2014-12-28 16:15:22 +03:00
parent dabac03820
commit 653db28675
14 changed files with 54 additions and 133 deletions

View file

@ -249,7 +249,7 @@ bool waiter_map_t::is_stopped(u64 signal_id)
{
if (Emu.IsStopped())
{
LOG_WARNING(Log::HLE, "%s.waiter_op() aborted (signal_id=0x%llx)", m_name.c_str(), signal_id);
LOG_WARNING(Log::HLE, "%s: waiter_op() aborted (signal_id=0x%llx)", m_name.c_str(), signal_id);
return true;
}
return false;

View file

@ -169,8 +169,10 @@ class squeue_t
atomic_le_t<squeue_sync_var_t> m_sync;
mutable std::mutex m_rcv_mutex, m_wcv_mutex;
mutable std::condition_variable m_rcv, m_wcv;
mutable std::mutex m_rcv_mutex;
mutable std::mutex m_wcv_mutex;
mutable std::condition_variable m_rcv;
mutable std::condition_variable m_wcv;
T m_data[sq_size];

View file

@ -46,8 +46,6 @@ s32 cellFsOpen(vm::ptr<const char> path, s32 flags, vm::ptr<be_t<u32>> fd, vm::p
const std::string _path = path.get_ptr();
LV2_LOCK(0);
s32 _oflags = flags;
if (flags & CELL_O_CREAT)
{
@ -129,8 +127,6 @@ s32 cellFsRead(u32 fd, vm::ptr<void> buf, u64 nbytes, vm::ptr<be_t<u64>> nread)
sys_fs->Log("cellFsRead(fd=%d, buf_addr=0x%x, nbytes=0x%llx, nread_addr=0x%x)",
fd, buf.addr(), nbytes, nread.addr());
LV2_LOCK(0);
std::shared_ptr<vfsStream> file;
if (!sys_fs->CheckId(fd, file))
return CELL_ESRCH;
@ -152,8 +148,6 @@ s32 cellFsWrite(u32 fd, vm::ptr<const void> buf, u64 nbytes, vm::ptr<u64> nwrite
sys_fs->Log("cellFsWrite(fd=%d, buf_addr=0x%x, nbytes=0x%llx, nwrite_addr=0x%x)",
fd, buf.addr(), nbytes, nwrite.addr());
LV2_LOCK(0);
std::shared_ptr<vfsStream> file;
if (!sys_fs->CheckId(fd, file)) return CELL_ESRCH;
@ -172,8 +166,6 @@ s32 cellFsClose(u32 fd)
{
sys_fs->Warning("cellFsClose(fd=%d)", fd);
LV2_LOCK(0);
if (!Emu.GetIdManager().RemoveID(fd))
return CELL_ESRCH;
@ -183,8 +175,6 @@ s32 cellFsClose(u32 fd)
s32 cellFsOpendir(vm::ptr<const char> path, vm::ptr<u32> fd)
{
sys_fs->Warning("cellFsOpendir(path=\"%s\", fd_addr=0x%x)", path.get_ptr(), fd.addr());
LV2_LOCK(0);
std::shared_ptr<vfsDirBase> dir(Emu.GetVFS().OpenDir(path.get_ptr()));
if (!dir || !dir->IsOpened())
@ -200,8 +190,6 @@ s32 cellFsReaddir(u32 fd, vm::ptr<CellFsDirent> dir, vm::ptr<u64> nread)
{
sys_fs->Warning("cellFsReaddir(fd=%d, dir_addr=0x%x, nread_addr=0x%x)", fd, dir.addr(), nread.addr());
LV2_LOCK(0);
std::shared_ptr<vfsDirBase> directory;
if (!sys_fs->CheckId(fd, directory))
return CELL_ESRCH;
@ -226,8 +214,6 @@ s32 cellFsClosedir(u32 fd)
{
sys_fs->Warning("cellFsClosedir(fd=%d)", fd);
LV2_LOCK(0);
if (!Emu.GetIdManager().RemoveID(fd))
return CELL_ESRCH;
@ -238,8 +224,6 @@ s32 cellFsStat(vm::ptr<const char> path, vm::ptr<CellFsStat> sb)
{
sys_fs->Warning("cellFsStat(path=\"%s\", sb_addr=0x%x)", path.get_ptr(), sb.addr());
LV2_LOCK(0);
const std::string _path = path.get_ptr();
u32 mode = 0;
@ -316,8 +300,6 @@ s32 cellFsFstat(u32 fd, vm::ptr<CellFsStat> sb)
{
sys_fs->Warning("cellFsFstat(fd=%d, sb_addr=0x%x)", fd, sb.addr());
LV2_LOCK(0);
IDType type;
std::shared_ptr<vfsStream> file;
if (!sys_fs->CheckId(fd, file, type) || type != TYPE_FS_FILE)
@ -344,8 +326,6 @@ s32 cellFsMkdir(vm::ptr<const char> path, u32 mode)
{
sys_fs->Warning("cellFsMkdir(path=\"%s\", mode=0x%x)", path.get_ptr(), mode);
LV2_LOCK(0);
const std::string _path = path.get_ptr();
if (vfsDir().IsExists(_path))
@ -361,8 +341,6 @@ s32 cellFsRename(vm::ptr<const char> from, vm::ptr<const char> to)
{
sys_fs->Warning("cellFsRename(from='%s', to='%s')", from.get_ptr(), to.get_ptr());
LV2_LOCK(0);
std::string _from = from.get_ptr();
std::string _to = to.get_ptr();
@ -395,8 +373,6 @@ s32 cellFsChmod(vm::ptr<const char> path, u32 mode)
{
sys_fs->Todo("cellFsChmod(path=\"%s\", mode=0x%x)", path.get_ptr(), mode);
LV2_LOCK(0);
// TODO:
return CELL_OK;
@ -406,8 +382,6 @@ s32 cellFsFsync(u32 fd)
{
sys_fs->Todo("cellFsFsync(fd=0x%x)", fd);
LV2_LOCK(0);
// TODO:
return CELL_OK;
@ -417,8 +391,6 @@ s32 cellFsRmdir(vm::ptr<const char> path)
{
sys_fs->Warning("cellFsRmdir(path=\"%s\")", path.get_ptr());
LV2_LOCK(0);
std::string _path = path.get_ptr();
vfsDir d;
@ -435,8 +407,6 @@ s32 cellFsUnlink(vm::ptr<const char> path)
{
sys_fs->Warning("cellFsUnlink(path=\"%s\")", path.get_ptr());
LV2_LOCK(0);
std::string _path = path.get_ptr();
if (vfsDir().IsExists(_path))
@ -455,8 +425,6 @@ s32 cellFsLseek(u32 fd, s64 offset, u32 whence, vm::ptr<be_t<u64>> pos)
{
sys_fs->Log("cellFsLseek(fd=%d, offset=0x%llx, whence=0x%x, pos_addr=0x%x)", fd, offset, whence, pos.addr());
LV2_LOCK(0);
vfsSeekMode seek_mode;
switch(whence)
{
@ -480,8 +448,6 @@ s32 cellFsLseek(u32 fd, s64 offset, u32 whence, vm::ptr<be_t<u64>> pos)
s32 cellFsFtruncate(u32 fd, u64 size)
{
sys_fs->Warning("cellFsFtruncate(fd=%d, size=%lld)", fd, size);
LV2_LOCK(0);
IDType type;
std::shared_ptr<vfsStream> file;
@ -512,8 +478,6 @@ s32 cellFsTruncate(vm::ptr<const char> path, u64 size)
{
sys_fs->Warning("cellFsTruncate(path=\"%s\", size=%lld)", path.get_ptr(), size);
LV2_LOCK(0);
vfsFile f(path.get_ptr(), vfsReadWrite);
if (!f.IsOpened())
{
@ -562,8 +526,6 @@ s32 cellFsGetBlockSize(vm::ptr<const char> path, vm::ptr<u64> sector_size, vm::p
sys_fs->Warning("cellFsGetBlockSize(file='%s', sector_size_addr=0x%x, block_size_addr=0x%x)",
path.get_ptr(), sector_size.addr(), block_size.addr());
LV2_LOCK(0);
*sector_size = 4096; // ?
*block_size = 4096; // ?
@ -575,8 +537,6 @@ s32 cellFsGetFreeSize(vm::ptr<const char> path, vm::ptr<u32> block_size, vm::ptr
sys_fs->Warning("cellFsGetFreeSize(path=\"%s\", block_size_addr=0x%x, block_count_addr=0x%x)",
path.get_ptr(), block_size.addr(), block_count.addr());
LV2_LOCK(0);
// TODO: Get real values. Currently, it always returns 40 GB of free space divided in 4 KB blocks
*block_size = 4096; // ?
*block_count = 10 * 1024 * 1024; // ?
@ -589,8 +549,6 @@ s32 cellFsGetDirectoryEntries(u32 fd, vm::ptr<CellFsDirectoryEntry> entries, u32
sys_fs->Warning("cellFsGetDirectoryEntries(fd=%d, entries_addr=0x%x, entries_size=0x%x, data_count_addr=0x%x)",
fd, entries.addr(), entries_size, data_count.addr());
LV2_LOCK(0);
std::shared_ptr<vfsDirBase> directory;
if (!sys_fs->CheckId(fd, directory))
return CELL_ESRCH;
@ -627,8 +585,6 @@ s32 cellFsStReadInit(u32 fd, vm::ptr<CellFsRingBuffer> ringbuf)
{
sys_fs->Warning("cellFsStReadInit(fd=%d, ringbuf_addr=0x%x)", fd, ringbuf.addr());
LV2_LOCK(0);
std::shared_ptr<vfsStream> file;
if (!sys_fs->CheckId(fd, file))
return CELL_ESRCH;
@ -654,8 +610,6 @@ s32 cellFsStReadFinish(u32 fd)
{
sys_fs->Warning("cellFsStReadFinish(fd=%d)", fd);
LV2_LOCK(0);
std::shared_ptr<vfsStream> file;
if (!sys_fs->CheckId(fd, file))
return CELL_ESRCH;
@ -670,8 +624,6 @@ s32 cellFsStReadGetRingBuf(u32 fd, vm::ptr<CellFsRingBuffer> ringbuf)
{
sys_fs->Warning("cellFsStReadGetRingBuf(fd=%d, ringbuf_addr=0x%x)", fd, ringbuf.addr());
LV2_LOCK(0);
std::shared_ptr<vfsStream> file;
if (!sys_fs->CheckId(fd, file))
return CELL_ESRCH;
@ -687,8 +639,6 @@ s32 cellFsStReadGetStatus(u32 fd, vm::ptr<u64> status)
{
sys_fs->Warning("cellFsStReadGetRingBuf(fd=%d, status_addr=0x%x)", fd, status.addr());
LV2_LOCK(0);
std::shared_ptr<vfsStream> file;
if (!sys_fs->CheckId(fd, file))
return CELL_ESRCH;
@ -702,8 +652,6 @@ s32 cellFsStReadGetRegid(u32 fd, vm::ptr<u64> regid)
{
sys_fs->Warning("cellFsStReadGetRingBuf(fd=%d, regid_addr=0x%x)", fd, regid.addr());
LV2_LOCK(0);
std::shared_ptr<vfsStream> file;
if (!sys_fs->CheckId(fd, file))
return CELL_ESRCH;
@ -717,8 +665,6 @@ s32 cellFsStReadStart(u32 fd, u64 offset, u64 size)
{
sys_fs->Todo("cellFsStReadStart(fd=%d, offset=0x%llx, size=0x%llx)", fd, offset, size);
LV2_LOCK(0);
std::shared_ptr<vfsStream> file;
if (!sys_fs->CheckId(fd, file))
return CELL_ESRCH;
@ -733,8 +679,6 @@ s32 cellFsStReadStop(u32 fd)
{
sys_fs->Warning("cellFsStReadStop(fd=%d)", fd);
LV2_LOCK(0);
std::shared_ptr<vfsStream> file;
if (!sys_fs->CheckId(fd, file))
return CELL_ESRCH;
@ -747,8 +691,6 @@ s32 cellFsStReadStop(u32 fd)
s32 cellFsStRead(u32 fd, u32 buf_addr, u64 size, vm::ptr<u64> rsize)
{
sys_fs->Warning("cellFsStRead(fd=%d, buf_addr=0x%x, size=0x%llx, rsize_addr=0x%x)", fd, buf_addr, size, rsize.addr());
LV2_LOCK(0);
std::shared_ptr<vfsStream> file;
if (!sys_fs->CheckId(fd, file))
@ -769,8 +711,6 @@ s32 cellFsStReadGetCurrentAddr(u32 fd, vm::ptr<u32> addr, vm::ptr<u64> size)
{
sys_fs->Todo("cellFsStReadGetCurrentAddr(fd=%d, addr_addr=0x%x, size_addr=0x%x)", fd, addr.addr(), size.addr());
LV2_LOCK(0);
std::shared_ptr<vfsStream> file;
if (!sys_fs->CheckId(fd, file))
return CELL_ESRCH;
@ -781,8 +721,6 @@ s32 cellFsStReadGetCurrentAddr(u32 fd, vm::ptr<u32> addr, vm::ptr<u64> size)
s32 cellFsStReadPutCurrentAddr(u32 fd, u32 addr_addr, u64 size)
{
sys_fs->Todo("cellFsStReadPutCurrentAddr(fd=%d, addr_addr=0x%x, size=0x%llx)", fd, addr_addr, size);
LV2_LOCK(0);
std::shared_ptr<vfsStream> file;
if (!sys_fs->CheckId(fd, file))
@ -794,8 +732,6 @@ s32 cellFsStReadPutCurrentAddr(u32 fd, u32 addr_addr, u64 size)
s32 cellFsStReadWait(u32 fd, u64 size)
{
sys_fs->Todo("cellFsStReadWait(fd=%d, size=0x%llx)", fd, size);
LV2_LOCK(0);
std::shared_ptr<vfsStream> file;
if (!sys_fs->CheckId(fd, file))
@ -808,8 +744,6 @@ s32 cellFsStReadWaitCallback(u32 fd, u64 size, vm::ptr<void (*)(int xfd, u64 xsi
{
sys_fs->Todo("cellFsStReadWaitCallback(fd=%d, size=0x%llx, func_addr=0x%x)", fd, size, func.addr());
LV2_LOCK(0);
std::shared_ptr<vfsStream> file;
if (!sys_fs->CheckId(fd, file))
return CELL_ESRCH;
@ -971,8 +905,6 @@ void fsAioRead(u32 fd, vm::ptr<CellFsAio> aio, int xid, vm::ptr<void(*)(vm::ptr<
u32 error = CELL_OK;
u64 res = 0;
{
LV2_LOCK(0);
std::shared_ptr<vfsStream> orig_file;
if (!sys_fs->CheckId(fd, orig_file))
{
@ -1018,8 +950,6 @@ int cellFsAioRead(vm::ptr<CellFsAio> aio, vm::ptr<u32> aio_id, vm::ptr<void(*)(v
{
sys_fs->Warning("cellFsAioRead(aio_addr=0x%x, id_addr=0x%x, func_addr=0x%x)", aio.addr(), aio_id.addr(), func.addr());
LV2_LOCK(0);
if (!aio_init)
{
return CELL_ENXIO;
@ -1049,8 +979,6 @@ int cellFsAioWrite(vm::ptr<CellFsAio> aio, vm::ptr<u32> aio_id, vm::ptr<void(*)(
{
sys_fs->Todo("cellFsAioWrite(aio_addr=0x%x, id_addr=0x%x, func_addr=0x%x)", aio.addr(), aio_id.addr(), func.addr());
LV2_LOCK(0);
// TODO:
return CELL_OK;
@ -1060,8 +988,6 @@ int cellFsAioInit(vm::ptr<const char> mount_point)
{
sys_fs->Warning("cellFsAioInit(mount_point_addr=0x%x (%s))", mount_point.addr(), mount_point.get_ptr());
LV2_LOCK(0);
aio_init = true;
return CELL_OK;
}
@ -1070,8 +996,6 @@ int cellFsAioFinish(vm::ptr<const char> mount_point)
{
sys_fs->Warning("cellFsAioFinish(mount_point_addr=0x%x (%s))", mount_point.addr(), mount_point.get_ptr());
LV2_LOCK(0);
aio_init = false;
return CELL_OK;
}
@ -1081,8 +1005,6 @@ int cellFsReadWithOffset(u32 fd, u64 offset, vm::ptr<void> buf, u64 buffer_size,
sys_fs->Warning("cellFsReadWithOffset(fd=%d, offset=0x%llx, buf_addr=0x%x, buffer_size=%lld nread=0x%llx)",
fd, offset, buf.addr(), buffer_size, nread.addr());
LV2_LOCK(0);
int ret;
vm::var<be_t<u64>> oldPos, newPos;
ret = cellFsLseek(fd, 0, CELL_SEEK_CUR, oldPos); // Save the current position

View file

@ -13,7 +13,7 @@ sleep_queue_t::~sleep_queue_t()
{
for (auto& tid : m_list)
{
LOG_NOTICE(HLE, "~sleep_queue_t(): thread %d", tid);
LOG_NOTICE(HLE, "~sleep_queue_t('%s'): m_list[%lld]=%d", m_name.c_str(), &tid - m_list.data(), tid);
}
}

View file

@ -30,6 +30,7 @@ class sleep_queue_t
{
std::vector<u32> m_list;
std::mutex m_mutex;
std::string m_name;
public:
const u64 name;
@ -41,6 +42,9 @@ public:
~sleep_queue_t();
void set_full_name(const std::string& name) { m_name = name; }
const std::string& get_full_name() { return m_name; }
void push(u32 tid, u32 protocol);
u32 pop(u32 protocol);
bool invalidate(u32 tid);

View file

@ -15,10 +15,7 @@ SysCallBase sys_cond("sys_cond");
s32 sys_cond_create(vm::ptr<u32> cond_id, u32 mutex_id, vm::ptr<sys_cond_attribute> attr)
{
sys_cond.Log("sys_cond_create(cond_id_addr=0x%x, mutex_id=%d, attr_addr=0x%x)",
cond_id.addr(), mutex_id, attr.addr());
LV2_LOCK(0);
sys_cond.Log("sys_cond_create(cond_id_addr=0x%x, mutex_id=%d, attr_addr=0x%x)", cond_id.addr(), mutex_id, attr.addr());
if (attr->pshared.ToBE() != se32(0x200))
{
@ -33,11 +30,13 @@ s32 sys_cond_create(vm::ptr<u32> cond_id, u32 mutex_id, vm::ptr<sys_cond_attribu
}
std::shared_ptr<Cond> cond(new Cond(mutex, attr->name_u64));
const u32 id = sys_cond.GetNewId(cond, TYPE_COND);
*cond_id = id;
mutex->cond_count++;
sys_cond.Warning("*** condition created [%s] (mutex_id=%d): id = %d", std::string(attr->name, 8).c_str(), mutex_id, id);
const u32 id = sys_cond.GetNewId(cond, TYPE_COND);
cond->queue.set_full_name(fmt::Format("Cond(%d, mutex_id=%d)", id, mutex_id));
*cond_id = id;
mutex->cond_count++; // TODO: check safety
sys_cond.Warning("*** condition created [%s] (mutex_id=%d): id = %d", std::string(attr->name, 8).c_str(), mutex_id, id);
return CELL_OK;
}
@ -45,8 +44,6 @@ s32 sys_cond_destroy(u32 cond_id)
{
sys_cond.Warning("sys_cond_destroy(cond_id=%d)", cond_id);
LV2_LOCK(0);
std::shared_ptr<Cond> cond;
if (!Emu.GetIdManager().GetIDData(cond_id, cond))
{
@ -58,7 +55,7 @@ s32 sys_cond_destroy(u32 cond_id)
return CELL_EBUSY;
}
cond->mutex->cond_count--;
cond->mutex->cond_count--; // TODO: check safety
Emu.GetIdManager().RemoveID(cond_id);
return CELL_OK;
}
@ -73,9 +70,7 @@ s32 sys_cond_signal(u32 cond_id)
return CELL_ESRCH;
}
std::shared_ptr<Mutex> mutex = cond->mutex;
if (u32 target = cond->queue.pop(mutex->protocol))
if (u32 target = cond->queue.pop(cond->mutex->protocol))
{
cond->signal.push(target);
@ -98,7 +93,7 @@ s32 sys_cond_signal_all(u32 cond_id)
return CELL_ESRCH;
}
std::shared_ptr<Mutex> mutex = cond->mutex;
Mutex* mutex = cond->mutex.get();
while (u32 target = cond->queue.pop(mutex->protocol))
{
@ -134,8 +129,6 @@ s32 sys_cond_signal_to(u32 cond_id, u32 thread_id)
return CELL_EPERM;
}
std::shared_ptr<Mutex> mutex = cond->mutex;
u32 target = thread_id;
{
cond->signal.push(target);
@ -159,7 +152,7 @@ s32 sys_cond_wait(PPUThread& CPU, u32 cond_id, u64 timeout)
return CELL_ESRCH;
}
std::shared_ptr<Mutex> mutex = cond->mutex;
Mutex* mutex = cond->mutex.get();
const u32 tid = CPU.GetId();
if (mutex->owner.read_sync() != tid)

View file

@ -21,7 +21,8 @@ u32 event_queue_create(u32 protocol, s32 type, u64 name_u64, u64 event_queue_key
return 0;
}
u32 id = sys_event.GetNewId(eq, TYPE_EVENT_QUEUE);
const u32 id = sys_event.GetNewId(eq, TYPE_EVENT_QUEUE);
eq->sq.set_full_name(fmt::Format("EventQueue(%d)", id));
sys_event.Warning("*** event_queue created [%s] (protocol=0x%x, type=0x%x, key=0x%llx, size=0x%x): id = %d",
std::string((const char*)&name_u64, 8).c_str(), protocol, type, event_queue_key, size, id);
return id;

View file

@ -14,11 +14,11 @@ SysCallBase sys_lwcond("sys_lwcond");
s32 lwcond_create(sys_lwcond_t& lwcond, sys_lwmutex_t& lwmutex, u64 name_u64)
{
LV2_LOCK(0);
std::shared_ptr<Lwcond> lw(new Lwcond(name_u64, Memory.RealToVirtualAddr(&lwcond)));
std::shared_ptr<Lwcond> lw(new Lwcond(name_u64));
u32 id = sys_lwcond.GetNewId(lw, TYPE_LWCOND);
u32 addr = Memory.RealToVirtualAddr(&lwmutex);
const u32 id = sys_lwcond.GetNewId(lw, TYPE_LWCOND);
const u32 addr = Memory.RealToVirtualAddr(&lwmutex);
lw->queue.set_full_name(fmt::Format("Lwcond(%d, addr=0x%x)", id, lw->addr));
lwcond.lwmutex.set(addr);
lwcond.lwcond_queue = id;
@ -38,8 +38,6 @@ s32 sys_lwcond_destroy(vm::ptr<sys_lwcond_t> lwcond)
{
sys_lwcond.Warning("sys_lwcond_destroy(lwcond_addr=0x%x)", lwcond.addr());
LV2_LOCK(0);
u32 id = lwcond->lwcond_queue;
std::shared_ptr<Lwcond> lw;

View file

@ -22,8 +22,11 @@ struct Lwcond
squeue_t<u32, 32> signal;
sleep_queue_t queue;
Lwcond(u64 name)
const u32 addr;
Lwcond(u64 name, u32 addr)
: queue(name)
, addr(addr)
{
}
};

View file

@ -14,8 +14,6 @@ SysCallBase sys_lwmutex("sys_lwmutex");
s32 lwmutex_create(sys_lwmutex_t& lwmutex, u32 protocol, u32 recursive, u64 name_u64)
{
LV2_LOCK(0);
std::shared_ptr<sleep_queue_t> sq(new sleep_queue_t(name_u64));
lwmutex.owner.write_relaxed(be_t<u32>::make(0));
@ -24,6 +22,7 @@ s32 lwmutex_create(sys_lwmutex_t& lwmutex, u32 protocol, u32 recursive, u64 name
lwmutex.recursive_count.write_relaxed(be_t<u32>::make(0));
u32 sq_id = sys_lwmutex.GetNewId(sq, TYPE_LWMUTEX);
lwmutex.sleep_queue = sq_id;
sq->set_full_name(fmt::Format("Lwmutex(%d, addr=0x%x)", sq_id, Memory.RealToVirtualAddr(&lwmutex)));
sys_lwmutex.Notice("*** lwmutex created [%s] (attribute=0x%x): sq_id = %d", std::string((const char*)&name_u64, 8).c_str(), protocol | recursive, sq_id);
return CELL_OK;

View file

@ -29,8 +29,6 @@ s32 sys_mutex_create(PPUThread& CPU, vm::ptr<u32> mutex_id, vm::ptr<sys_mutex_at
{
sys_mutex.Log("sys_mutex_create(mutex_id_addr=0x%x, attr_addr=0x%x)", mutex_id.addr(), attr.addr());
LV2_LOCK(0);
switch (attr->protocol.ToBE())
{
case se32(SYS_SYNC_FIFO): break;
@ -55,12 +53,14 @@ s32 sys_mutex_create(PPUThread& CPU, vm::ptr<u32> mutex_id, vm::ptr<sys_mutex_at
}
std::shared_ptr<Mutex> mutex(new Mutex((u32)attr->protocol, is_recursive, attr->name_u64));
const u32 id = sys_mutex.GetNewId(mutex, TYPE_MUTEX);
mutex->id.exchange(id);
*mutex_id = id;
mutex->queue.set_full_name(fmt::Format("Mutex(%d)", id));
sys_mutex.Warning("*** mutex created [%s] (protocol=0x%x, recursive=%s): id = %d",
std::string(attr->name, 8).c_str(), (u32) attr->protocol, (is_recursive ? "true" : "false"), id);
// TODO: unlock mutex when owner thread does exit
return CELL_OK;
}
@ -69,15 +69,14 @@ s32 sys_mutex_destroy(PPUThread& CPU, u32 mutex_id)
{
sys_mutex.Warning("sys_mutex_destroy(mutex_id=%d)", mutex_id);
LV2_LOCK(0);
std::shared_ptr<Mutex> mutex;
if (!Emu.GetIdManager().GetIDData(mutex_id, mutex))
{
return CELL_ESRCH;
}
if (mutex->cond_count) // check if associated condition variable exists
// check if associated condition variable exists
if (mutex->cond_count) // TODO: check safety
{
return CELL_EPERM;
}

View file

@ -7,7 +7,7 @@ struct sys_mutex_attribute
be_t<u32> pshared; // always 0x200 (not shared)
be_t<u32> adaptive;
be_t<u64> ipc_key;
be_t<int> flags;
be_t<s32> flags;
be_t<u32> pad;
union
{

View file

@ -14,10 +14,11 @@ SysCallBase sys_semaphore("sys_semaphore");
u32 semaphore_create(s32 initial_count, s32 max_count, u32 protocol, u64 name_u64)
{
LV2_LOCK(0);
std::shared_ptr<Semaphore> sem(new Semaphore(initial_count, max_count, protocol, name_u64));
const u32 id = sys_semaphore.GetNewId(sem, TYPE_SEMAPHORE);
sem->queue.set_full_name(fmt::Format("Semaphore(%d)", id));
sys_semaphore.Notice("*** semaphore created [%s] (protocol=0x%x): id = %d", std::string((const char*)&name_u64, 8).c_str(), protocol, id);
return id;
}
@ -27,15 +28,17 @@ s32 sys_semaphore_create(vm::ptr<u32> sem, vm::ptr<sys_semaphore_attribute> attr
sys_semaphore.Warning("sys_semaphore_create(sem_addr=0x%x, attr_addr=0x%x, initial_count=%d, max_count=%d)",
sem.addr(), attr.addr(), initial_count, max_count);
if (sem.addr() == NULL) {
sys_semaphore.Error("sys_semaphore_create(): invalid memory access (sem_addr=0x%x)", sem.addr());
return CELL_EFAULT;
}
if (!sem)
{
sys_semaphore.Error("sys_semaphore_create(): invalid memory access (sem_addr=0x%x)", sem.addr());
return CELL_EFAULT;
}
if (attr.addr() == NULL) {
sys_semaphore.Error("sys_semaphore_create(): An invalid argument value is specified (attr_addr=0x%x)", attr.addr());
return CELL_EFAULT;
}
if (!attr)
{
sys_semaphore.Error("sys_semaphore_create(): An invalid argument value is specified (attr_addr=0x%x)", attr.addr());
return CELL_EFAULT;
}
if (max_count <= 0 || initial_count > max_count || initial_count < 0)
{
@ -66,8 +69,6 @@ s32 sys_semaphore_destroy(u32 sem_id)
{
sys_semaphore.Warning("sys_semaphore_destroy(sem_id=%d)", sem_id);
LV2_LOCK(0);
std::shared_ptr<Semaphore> sem;
if (!Emu.GetIdManager().GetIDData(sem_id, sem))
{

View file

@ -442,18 +442,17 @@ s32 sys_spu_thread_group_terminate(u32 id, int value)
std::shared_ptr<SpuGroupInfo> spu_thread_group_create(const std::string& name, u32 num, s32 prio, s32 type, u32 container)
{
LV2_LOCK(0);
if (type)
{
sys_spu.Todo("Unsupported SPU Thread Group type (0x%x)", type);
}
std::shared_ptr<SpuGroupInfo> group(new SpuGroupInfo(name, num, prio, type, container));
const u32 _id = sys_spu.GetNewId(group);
group->m_id = _id;
sys_spu.Notice("*** SPU Thread Group created [%s] (num=%d, prio=%d, type=0x%x, container=%d): id=%d",
name.c_str(), num, prio, type, container, _id);
sys_spu.Notice("*** SPU Thread Group created [%s] (num=%d, prio=%d, type=0x%x, container=%d): id=%d", name.c_str(), num, prio, type, container, _id);
return group;
}