Small cleanup

This commit is contained in:
Nekotekina 2015-03-13 04:09:53 +03:00
parent 5c31037c04
commit c88e0a0eb9
9 changed files with 46 additions and 48 deletions

View File

@ -193,8 +193,8 @@ class squeue_t
public: public:
squeue_t() squeue_t()
: m_sync({})
{ {
m_sync.write_relaxed({});
} }
u32 get_max_size() const u32 get_max_size() const
@ -202,9 +202,9 @@ public:
return sq_size; return sq_size;
} }
bool is_full() const bool is_full() const volatile
{ {
return m_sync.read_relaxed().count == sq_size; return m_sync.data.count == sq_size;
} }
bool push(const T& data, const std::function<bool()>& test_exit) bool push(const T& data, const std::function<bool()>& test_exit)

View File

@ -78,29 +78,29 @@ void SPUThread::InitRegs()
ch_mfc_args = {}; ch_mfc_args = {};
mfc_queue.clear(); mfc_queue.clear();
ch_tag_mask = 0; ch_tag_mask = {};
ch_tag_stat.data = {}; ch_tag_stat = {};
ch_stall_stat.data = {}; ch_stall_stat = {};
ch_atomic_stat.data = {}; ch_atomic_stat = {};
ch_in_mbox.clear(); ch_in_mbox.clear();
ch_out_mbox.data = {}; ch_out_mbox = {};
ch_out_intr_mbox.data = {}; ch_out_intr_mbox = {};
snr_config = 0; snr_config = {};
ch_snr1.data = {}; ch_snr1 = {};
ch_snr2.data = {}; ch_snr2 = {};
ch_event_mask = 0; ch_event_mask = {};
ch_event_stat.write_relaxed(0); ch_event_stat = {};
ch_dec_start_timestamp = get_time(); // ??? ch_dec_start_timestamp = get_time(); // ???
ch_dec_value = 0; ch_dec_value = {};
run_ctrl.write_relaxed(0); run_ctrl = {};
status.write_relaxed(0); status = {};
int0.clear(); int0.clear();
int2.clear(); int2.clear();

View File

@ -139,10 +139,7 @@ union spu_channel_t
atomic_t<sync_var_t> sync_var; // atomic variable atomic_t<sync_var_t> sync_var; // atomic variable
sync_var_t data; // unsafe direct access
public: public:
bool push(u32 value) bool push(u32 value)
{ {
bool out_result; bool out_result;
@ -205,14 +202,14 @@ public:
sync_var.write_relaxed({ count, value }); sync_var.write_relaxed({ count, value });
} }
u32 get_value() u32 get_value() volatile
{ {
return sync_var.read_relaxed().value; return sync_var.data.value;
} }
u32 get_count() u32 get_count() volatile
{ {
return sync_var.read_relaxed().count; return sync_var.data.count;
} }
}; };
@ -232,8 +229,8 @@ struct spu_channel_4_t
public: public:
void clear() void clear()
{ {
sync_var.write_relaxed({}); sync_var = {};
value3.write_relaxed({}); value3 = {};
} }
void push_uncond(u32 value) void push_uncond(u32 value)
@ -275,9 +272,9 @@ public:
return out_result; return out_result;
} }
u32 get_count() u32 get_count() volatile
{ {
return sync_var.read_relaxed().count; return sync_var.data.count;
} }
}; };
@ -311,10 +308,10 @@ public:
void clear() void clear()
{ {
mask.write_relaxed(0); mask = {};
stat.write_relaxed(0); stat = {};
assigned.write_relaxed(-1); assigned = { -1 };
} }
}; };

View File

@ -882,28 +882,28 @@ void syncLFQueueInit(vm::ptr<CellSyncLFQueue> queue, vm::ptr<u8> buffer, u32 siz
if (direction == CELL_SYNC_QUEUE_ANY2ANY) if (direction == CELL_SYNC_QUEUE_ANY2ANY)
{ {
queue->pop1.write_relaxed({}); queue->pop1 = {};
queue->push1.write_relaxed({}); queue->push1 = {};
queue->m_buffer.set(queue->m_buffer.addr() | 1); queue->m_buffer.set(queue->m_buffer.addr() | 1);
queue->m_bs[0] = -1; queue->m_bs[0] = -1;
queue->m_bs[1] = -1; queue->m_bs[1] = -1;
//m_bs[2] //m_bs[2]
//m_bs[3] //m_bs[3]
queue->m_v1 = -1; queue->m_v1 = -1;
queue->push2.write_relaxed({ be_t<u16>::make(-1) }); queue->push2 = { { be_t<u16>::make(-1) } };
queue->pop2.write_relaxed({ be_t<u16>::make(-1) }); queue->pop2 = { { be_t<u16>::make(-1) } };
} }
else else
{ {
queue->pop1.write_relaxed({ be_t<u16>::make(0), be_t<u16>::make(0), queue->pop1.read_relaxed().m_h3, be_t<u16>::make(0) }); queue->pop1 = { { be_t<u16>::make(0), be_t<u16>::make(0), queue->pop1.read_relaxed().m_h3, be_t<u16>::make(0) } };
queue->push1.write_relaxed({ be_t<u16>::make(0), be_t<u16>::make(0), queue->push1.read_relaxed().m_h7, be_t<u16>::make(0) }); queue->push1 = { { be_t<u16>::make(0), be_t<u16>::make(0), queue->push1.read_relaxed().m_h7, be_t<u16>::make(0) } };
queue->m_bs[0] = -1; // written as u32 queue->m_bs[0] = -1; // written as u32
queue->m_bs[1] = -1; queue->m_bs[1] = -1;
queue->m_bs[2] = -1; queue->m_bs[2] = -1;
queue->m_bs[3] = -1; queue->m_bs[3] = -1;
queue->m_v1 = 0; queue->m_v1 = 0;
queue->push2.write_relaxed({}); queue->push2 = {};
queue->pop2.write_relaxed({}); queue->pop2 = {};
} }
queue->m_v2 = 0; queue->m_v2 = 0;

View File

@ -114,7 +114,7 @@ s32 sys_lwmutex_create(vm::ptr<sys_lwmutex_t> lwmutex, vm::ptr<sys_lwmutex_attri
std::shared_ptr<lwmutex_t> lw(new lwmutex_t(protocol, attr->name_u64)); std::shared_ptr<lwmutex_t> lw(new lwmutex_t(protocol, attr->name_u64));
lwmutex->lock_var.write_relaxed({ lwmutex::free, lwmutex::zero }); lwmutex->lock_var = { { lwmutex::free, lwmutex::zero } };
lwmutex->attribute = attr->recursive | attr->protocol; lwmutex->attribute = attr->recursive | attr->protocol;
lwmutex->recursive_count = 0; lwmutex->recursive_count = 0;
lwmutex->sleep_queue = Emu.GetIdManager().GetNewID(lw); lwmutex->sleep_queue = Emu.GetIdManager().GetNewID(lw);
@ -575,7 +575,7 @@ s32 sys_lwcond_wait(PPUThread& CPU, vm::ptr<sys_lwcond_t> lwcond, u64 timeout)
const be_t<u32> recursive_value = lwmutex->recursive_count; const be_t<u32> recursive_value = lwmutex->recursive_count;
// set special value // set special value
lwmutex->owner.write_relaxed(lwmutex::reserved); lwmutex->owner = { lwmutex::reserved };
lwmutex->recursive_count = 0; lwmutex->recursive_count = 0;
// call the syscall // call the syscall

View File

@ -20,7 +20,7 @@
SysCallBase sys_fs("sys_fs"); SysCallBase sys_fs("sys_fs");
s32 sys_fs_open(vm::ptr<const char> path, s32 flags, vm::ptr<u32> fd, u64 mode, vm::ptr<const void> arg, u64 size) s32 sys_fs_open(vm::ptr<const char> path, s32 flags, vm::ptr<u32> fd, u32 mode, vm::ptr<const void> arg, u64 size)
{ {
sys_fs.Warning("sys_fs_open(path=*0x%x, flags=0x%x, fd=*0x%x, arg=*0x%x, size=0x%llx)", path, flags, fd, arg, size); sys_fs.Warning("sys_fs_open(path=*0x%x, flags=0x%x, fd=*0x%x, arg=*0x%x, size=0x%llx)", path, flags, fd, arg, size);
sys_fs.Warning("*** path = '%s'", path.get_ptr()); sys_fs.Warning("*** path = '%s'", path.get_ptr());

View File

@ -89,7 +89,7 @@ enum : s32
enum CellFsMode : s32 enum CellFsMode : s32
{ {
CELL_FS_S_IFMT = 0170000, CELL_FS_S_IFMT = 0170000,
CELL_FS_S_IFDIR = 0040000, // directory CELL_FS_S_IFDIR = 0040000, // directory
CELL_FS_S_IFREG = 0100000, // regular CELL_FS_S_IFREG = 0100000, // regular
CELL_FS_S_IFLNK = 0120000, // symbolic link CELL_FS_S_IFLNK = 0120000, // symbolic link
@ -126,7 +126,7 @@ struct CellFsDirent
struct CellFsStat struct CellFsStat
{ {
be_t<u32> mode; be_t<s32> mode;
be_t<s32> uid; be_t<s32> uid;
be_t<s32> gid; be_t<s32> gid;
be_t<s64> atime; be_t<s64> atime;
@ -145,7 +145,7 @@ struct CellFsUtimbuf
#pragma pack(pop) #pragma pack(pop)
// SysCalls // SysCalls
s32 sys_fs_open(vm::ptr<const char> path, s32 flags, vm::ptr<u32> fd, u64 mode, vm::ptr<const void> arg, u64 size); s32 sys_fs_open(vm::ptr<const char> path, s32 flags, vm::ptr<u32> fd, u32 mode, vm::ptr<const void> arg, u64 size);
s32 sys_fs_read(u32 fd, vm::ptr<void> buf, u64 nbytes, vm::ptr<u64> nread); s32 sys_fs_read(u32 fd, vm::ptr<void> buf, u64 nbytes, vm::ptr<u64> nread);
s32 sys_fs_write(u32 fd, vm::ptr<const void> buf, u64 nbytes, vm::ptr<u64> nwrite); s32 sys_fs_write(u32 fd, vm::ptr<const void> buf, u64 nbytes, vm::ptr<u64> nwrite);
s32 sys_fs_close(u32 fd); s32 sys_fs_close(u32 fd);

View File

@ -16,7 +16,7 @@ void lwmutex_create(sys_lwmutex_t& lwmutex, bool recursive, u32 protocol, u64 na
{ {
std::shared_ptr<lwmutex_t> mutex(new lwmutex_t(protocol, name)); std::shared_ptr<lwmutex_t> mutex(new lwmutex_t(protocol, name));
lwmutex.lock_var.write_relaxed({ lwmutex::free, lwmutex::zero }); lwmutex.lock_var = { { lwmutex::free, lwmutex::zero } };
lwmutex.attribute = protocol | (recursive ? SYS_SYNC_RECURSIVE : SYS_SYNC_NOT_RECURSIVE); lwmutex.attribute = protocol | (recursive ? SYS_SYNC_RECURSIVE : SYS_SYNC_NOT_RECURSIVE);
lwmutex.recursive_count = 0; lwmutex.recursive_count = 0;
lwmutex.sleep_queue = Emu.GetIdManager().GetNewID(mutex, TYPE_LWMUTEX); lwmutex.sleep_queue = Emu.GetIdManager().GetNewID(mutex, TYPE_LWMUTEX);

View File

@ -315,11 +315,12 @@ s32 sys_spu_thread_group_start(u32 id)
spu.SetEntry(image->entry_point); spu.SetEntry(image->entry_point);
spu.Run(); spu.Run();
spu.status.write_relaxed(SPU_STATUS_RUNNING);
spu.GPR[3] = u128::from64(0, args.arg1); spu.GPR[3] = u128::from64(0, args.arg1);
spu.GPR[4] = u128::from64(0, args.arg2); spu.GPR[4] = u128::from64(0, args.arg2);
spu.GPR[5] = u128::from64(0, args.arg3); spu.GPR[5] = u128::from64(0, args.arg3);
spu.GPR[6] = u128::from64(0, args.arg4); spu.GPR[6] = u128::from64(0, args.arg4);
spu.status.exchange(SPU_STATUS_RUNNING);
} }
} }
@ -518,7 +519,7 @@ s32 sys_spu_thread_group_terminate(u32 id, s32 value)
{ {
auto& spu = static_cast<SPUThread&>(*t); auto& spu = static_cast<SPUThread&>(*t);
spu.status.write_relaxed(SPU_STATUS_STOPPED); spu.status.exchange(SPU_STATUS_STOPPED);
spu.FastStop(); spu.FastStop();
} }
} }