syncLFQueueInitialize

This commit is contained in:
Nekotekina 2014-08-09 23:39:56 +04:00
parent 6bd45f9697
commit c7e77730fe
2 changed files with 69 additions and 26 deletions

View File

@ -1091,7 +1091,49 @@ int _cellSyncLFQueueDetachLv2EventQueue()
void syncLFQueueInitialize(mem_ptr_t<CellSyncLFQueue> ea, u32 buffer_addr, u32 size, u32 depth, CellSyncQueueDirection direction, u32 eaSignal_addr)
{
ea->m_h1 = 0;
ea->m_h2 = 0;
ea->m_h4 = 0;
ea->m_h5 = 0;
ea->m_h6 = 0;
ea->m_h8 = 0;
ea->m_size = size;
ea->m_depth = depth;
ea->m_buffer = (u64)buffer_addr;
ea->m_direction = direction;
for (u32 i = 0; i < sizeof(ea->m_hs) / sizeof(u16); i++)
{
ea->m_hs[i] = 0;
}
ea->m_eaSignal = (u64)eaSignal_addr;
if (direction == CELL_SYNC_QUEUE_ANY2ANY)
{
ea->m_h3 = 0;
ea->m_h7 = 0;
ea->m_buffer = (u64)buffer_addr | 1;
ea->m_bs[0] = -1;
ea->m_bs[1] = -1;
//m_bs[2]
//m_bs[3]
ea->m_v1 = -1;
ea->m_hs[0] = -1;
ea->m_hs[16] = -1;
ea->m_v2 = 0;
ea->m_v3 = 0;
}
else
{
//m_h3
//m_h7
ea->m_bs[0] = -1; // written as u32
ea->m_bs[1] = -1;
ea->m_bs[2] = -1;
ea->m_bs[3] = -1;
ea->m_v1 = 0;
ea->m_v2 = 0; // written as u64
ea->m_v3 = 0;
}
}
int cellSyncLFQueueInitialize(mem_ptr_t<CellSyncLFQueue> ea, u32 buffer_addr, u32 size, u32 depth, CellSyncQueueDirection direction, u32 eaSignal_addr)
@ -1139,9 +1181,9 @@ int cellSyncLFQueueInitialize(mem_ptr_t<CellSyncLFQueue> ea, u32 buffer_addr, u3
u32 old_value;
while (true)
{
const u32 old_data = ea->m_data1();
const u32 old_data = ea->m_data();
CellSyncLFQueue new_data;
new_data.m_data1() = old_data;
new_data.m_data() = old_data;
if (old_data)
{
@ -1163,11 +1205,11 @@ int cellSyncLFQueueInitialize(mem_ptr_t<CellSyncLFQueue> ea, u32 buffer_addr, u3
}
}
}
new_data.m_data1() = se32(1);
new_data.m_data() = se32(1);
old_value = se32(1);
}
if (InterlockedCompareExchange(&ea->m_data1(), new_data.m_data1(), old_data) == old_data) break;
if (InterlockedCompareExchange(&ea->m_data(), new_data.m_data(), old_data) == old_data) break;
}
if (old_value == se32(2))
@ -1190,12 +1232,12 @@ int cellSyncLFQueueInitialize(mem_ptr_t<CellSyncLFQueue> ea, u32 buffer_addr, u3
// prx: sync, zeroize u32 at 0x2c offset
InterlockedCompareExchange(&ea->m_data1(), 0, 0);
ea->m_data1() = 0;
InterlockedCompareExchange(&ea->m_data(), 0, 0);
ea->m_data() = 0;
}
// prx: sync
InterlockedCompareExchange(&ea->m_data1(), 0, 0);
InterlockedCompareExchange(&ea->m_data(), 0, 0);
return CELL_OK;
}

View File

@ -97,26 +97,27 @@ enum CellSyncQueueDirection : u32
struct CellSyncLFQueue
{
be_t<u64> m_v1;
be_t<u64> m_v2;
be_t<u32> m_size;
be_t<u32> m_depth;
be_t<u64> m_buffer;
be_t<u32> m_v5;
be_t<CellSyncQueueDirection> m_direction;
be_t<u64> m_v6;
be_t<u64> m_v7;
be_t<u64> m_v8;
be_t<u64> m_v9;
be_t<u64> m_v10;
be_t<u64> m_v11;
be_t<u64> m_v12;
be_t<u64> m_v13;
be_t<u64> m_v14;
be_t<u64> m_eaSignal;
be_t<u64> reserved;
be_t<u16> m_h1; // 0x0
be_t<u16> m_h2; // 0x2
be_t<u16> m_h3; // 0x4
be_t<u16> m_h4; // 0x6
be_t<u16> m_h5; // 0x8
be_t<u16> m_h6; // 0xA
be_t<u16> m_h7; // 0xC
be_t<u16> m_h8; // 0xE
be_t<u32> m_size; // 0x10
be_t<u32> m_depth; // 0x14
be_t<u64> m_buffer; // 0x18
u8 m_bs[4]; // 0x20
be_t<CellSyncQueueDirection> m_direction; // 0x24
be_t<u32> m_v1; // 0x28
be_t<u32> m_sync; // 0x2C
be_t<u16> m_hs[32]; // 0x30
be_t<u64> m_eaSignal;// 0x70
be_t<u32> m_v2; // 0x78
be_t<u32> m_v3; // 0x7C
volatile u32& m_data1()
volatile u32& m_data()
{
return *reinterpret_cast<u32*>((u8*)this + 0x2c);
}