mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-17 08:11:51 +00:00
Small fixes
This commit is contained in:
parent
cbeadcf872
commit
f4952bee18
@ -90,7 +90,6 @@ static const g_module_list[] =
|
||||
{0x0050, "cellSpursJq"},
|
||||
{0x0052, "cellPngEnc"},
|
||||
{0x0053, "cellMusicDecode2"},
|
||||
{0x0054, "cellSync"},
|
||||
{0x0055, "cellSync2"},
|
||||
{0x0056, "cellNpUtil"},
|
||||
{0x0057, "cellRudp"},
|
||||
|
@ -186,7 +186,8 @@ struct PamfHeader
|
||||
be_t<u32> mux_rate_max; //== 0x01D470 (400 bps per unit, == 48000000 bps)
|
||||
be_t<u32> mux_rate_min; //== 0x0107AC (?????)
|
||||
u16 reserved2; // ?????
|
||||
be_t<u16> stream_count; //total stream count
|
||||
u8 reserved3;
|
||||
u8 stream_count; //total stream count (reduced to 1 byte)
|
||||
be_t<u16> unk1; //== 1 (?????)
|
||||
be_t<u32> table_data_size; //== table_size - 0x20 == 0x14 + (0x30 * total_stream_num) (?????)
|
||||
//TODO: check relative offset of stream structs (could be from 0x0c to 0x14, currently 0x14)
|
||||
@ -245,7 +246,8 @@ int cellPamfGetStreamOffsetAndSize(mem_ptr_t<PamfHeader> pAddr, u64 fileSize, me
|
||||
cellPamf.Warning("cellPamfGetStreamOffsetAndSize(pAddr=0x%x, fileSize=%d, pOffset_addr=0x%x, pSize_addr=0x%x)",
|
||||
pAddr.GetAddr(), fileSize, pOffset.GetAddr(), pSize.GetAddr());
|
||||
|
||||
pOffset = (u64)pAddr->data_offset << 11;
|
||||
const u64 size = (u64)pAddr->data_offset << 11;
|
||||
pOffset = size;
|
||||
pSize = (u64)pAddr->data_size << 11;
|
||||
return CELL_OK;
|
||||
}
|
||||
@ -327,6 +329,9 @@ int cellPamfReaderGetNumberOfSpecificStreams(mem_ptr_t<CellPamfReader> pSelf, u8
|
||||
|
||||
int counts[6] = {0, 0, 0, 0, 0, 0};
|
||||
|
||||
/*if (!pAddr->magic)
|
||||
return 1; /*hack*/
|
||||
|
||||
for (int i = 0; i < pAddr->stream_count; i++)
|
||||
{
|
||||
switch (pAddr->stream_headers[i].type)
|
||||
@ -338,6 +343,7 @@ int cellPamfReaderGetNumberOfSpecificStreams(mem_ptr_t<CellPamfReader> pSelf, u8
|
||||
default:
|
||||
cellPamf.Error("cellPamfReaderGetNumberOfSpecificStreams: unsupported stream type found(0x%x)",
|
||||
pAddr->stream_headers[i].type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -356,7 +362,7 @@ int cellPamfReaderGetNumberOfSpecificStreams(mem_ptr_t<CellPamfReader> pSelf, u8
|
||||
return counts[CELL_PAMF_STREAM_TYPE_ATRAC3PLUS] +
|
||||
counts[CELL_PAMF_STREAM_TYPE_PAMF_LPCM] + counts[CELL_PAMF_STREAM_TYPE_AC3];
|
||||
default:
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -394,6 +400,9 @@ int cellPamfReaderSetStreamWithTypeAndIndex(mem_ptr_t<CellPamfReader> pSelf, u8
|
||||
|
||||
u32 found = 0;
|
||||
|
||||
/*if (!pAddr->magic)
|
||||
return 0; /*hack*/
|
||||
|
||||
for (int i = 0; i < pAddr->stream_count; i++)
|
||||
{
|
||||
switch (pAddr->stream_headers[i].type)
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include "Emu/SysCalls/SC_FUNC.h"
|
||||
|
||||
void cellSync_init();
|
||||
Module cellSync(0x0054, cellSync_init);
|
||||
Module cellSync("cellSync", cellSync_init);
|
||||
|
||||
// Return Codes
|
||||
enum
|
||||
@ -24,6 +24,7 @@ enum
|
||||
|
||||
int cellSyncMutexInitialize(mem32_t mutex)
|
||||
{
|
||||
cellSync.Log("cellSyncMutexInitialize(mutex=0x%x)", mutex.GetAddr());
|
||||
const u32 mutex_addr = mutex.GetAddr();
|
||||
if (!mutex_addr)
|
||||
{
|
||||
@ -34,11 +35,13 @@ int cellSyncMutexInitialize(mem32_t mutex)
|
||||
return CELL_SYNC_ERROR_ALIGN;
|
||||
}
|
||||
mutex = 0;
|
||||
_mm_sfence();
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
int cellSyncMutexLock(mem32_t mutex)
|
||||
{
|
||||
cellSync.Log("cellSyncMutexLock(mutex=0x%x)", mutex.GetAddr());
|
||||
const u32 mutex_addr = mutex.GetAddr();
|
||||
if (!mutex_addr)
|
||||
{
|
||||
@ -48,7 +51,7 @@ int cellSyncMutexLock(mem32_t mutex)
|
||||
{
|
||||
return CELL_SYNC_ERROR_ALIGN;
|
||||
}
|
||||
while (_InterlockedExchange((volatile long*)Memory.VirtualToRealAddr(mutex_addr), 1 << 24));
|
||||
while (_InterlockedExchange((volatile long*)(Memory + mutex_addr), 1 << 24));
|
||||
//need to check how does SPU work with these mutexes, also obtainment order is not guaranteed
|
||||
_mm_lfence();
|
||||
return CELL_OK;
|
||||
@ -56,6 +59,7 @@ int cellSyncMutexLock(mem32_t mutex)
|
||||
|
||||
int cellSyncMutexTryLock(mem32_t mutex)
|
||||
{
|
||||
cellSync.Log("cellSyncMutexTryLock(mutex=0x%x)", mutex.GetAddr());
|
||||
const u32 mutex_addr = mutex.GetAddr();
|
||||
if (!mutex_addr)
|
||||
{
|
||||
@ -66,7 +70,7 @@ int cellSyncMutexTryLock(mem32_t mutex)
|
||||
return CELL_SYNC_ERROR_ALIGN;
|
||||
}
|
||||
//check cellSyncMutexLock
|
||||
if (_InterlockedExchange((volatile long*)Memory.VirtualToRealAddr(mutex_addr), 1 << 24))
|
||||
if (_InterlockedExchange((volatile long*)(Memory + mutex_addr), 1 << 24))
|
||||
{
|
||||
return CELL_SYNC_ERROR_BUSY;
|
||||
}
|
||||
@ -76,6 +80,7 @@ int cellSyncMutexTryLock(mem32_t mutex)
|
||||
|
||||
int cellSyncMutexUnlock(mem32_t mutex)
|
||||
{
|
||||
cellSync.Log("cellSyncMutexUnlock(mutex=0x%x)", mutex.GetAddr());
|
||||
const u32 mutex_addr = mutex.GetAddr();
|
||||
if (!mutex_addr)
|
||||
{
|
||||
@ -87,7 +92,7 @@ int cellSyncMutexUnlock(mem32_t mutex)
|
||||
}
|
||||
//check cellSyncMutexLock
|
||||
_mm_sfence();
|
||||
_InterlockedExchange((volatile long*)Memory.VirtualToRealAddr(mutex_addr), 0);
|
||||
_InterlockedExchange((volatile long*)(Memory + mutex_addr), 0);
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
|
@ -81,11 +81,12 @@ int sys_spu_image_import(mem_ptr_t<sys_spu_image> img, u32 src, u32 type)
|
||||
}
|
||||
|
||||
vfsStreamMemory f(src);
|
||||
u32 entry = LoadSpuImage(f);
|
||||
u32 entry;
|
||||
u32 offset = LoadSpuImage(f, entry);
|
||||
|
||||
img->type = 1;
|
||||
img->type = type;
|
||||
img->entry_point = entry;
|
||||
img->segs_addr = 0x0;
|
||||
img->segs_addr = offset;
|
||||
img->nsegs = 0;
|
||||
|
||||
return CELL_OK;
|
||||
@ -119,15 +120,13 @@ int sys_raw_spu_load(int id, u32 path_addr, mem32_t entry)
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
extern u64 g_last_spu_offset;
|
||||
|
||||
int sys_raw_spu_image_load(int id, mem_ptr_t<sys_spu_image> img)
|
||||
{
|
||||
sysPrxForUser.Warning("sys_raw_spu_image_load(id=0x%x, img_addr=0x%x)", id, img.GetAddr());
|
||||
|
||||
memcpy(Memory + RAW_SPU_BASE_ADDR + RAW_SPU_OFFSET * id, Memory + g_last_spu_offset, 256 * 1024);
|
||||
memcpy(Memory + RAW_SPU_BASE_ADDR + RAW_SPU_OFFSET * id, Memory + (u32)img->segs_addr, 256 * 1024);
|
||||
Memory.Write32(RAW_SPU_BASE_ADDR + RAW_SPU_OFFSET * id + RAW_SPU_PROB_OFFSET + SPU_NPC_offs,
|
||||
img->entry_point - g_last_spu_offset);
|
||||
(u32)img->entry_point);
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
@ -390,14 +390,12 @@ std::atomic<u32> g_FsAioReadID = 0;
|
||||
|
||||
int cellFsAioRead(mem_ptr_t<CellFsAio> aio, mem32_t aio_id, u32 func_addr)
|
||||
{
|
||||
sys_fs.Warning("cellFsAioRead(aio_addr: 0x%x, id_addr: 0x%x, func_addr: 0x%x)", aio.GetAddr(), aio_id.GetAddr(), func_addr);
|
||||
|
||||
ID id;
|
||||
u32 fd = (u32)aio->fd;
|
||||
if(!sys_fs.CheckId(fd, id)) return CELL_ESRCH;
|
||||
vfsFileBase& orig_file = *(vfsFileBase*)id.m_data;
|
||||
//open the file again (to prevent access conflicts roughly)
|
||||
vfsStream file = *Emu.GetVFS().Open(orig_file.GetPath(), vfsRead);
|
||||
vfsStream& file = vfsLocalFile(orig_file.GetPath().AfterFirst('/'), vfsRead);
|
||||
|
||||
u64 nbytes = (u64)aio->size;
|
||||
const u32 buf_addr = (u32)aio->buf_addr;
|
||||
@ -416,8 +414,11 @@ int cellFsAioRead(mem_ptr_t<CellFsAio> aio, mem32_t aio_id, u32 func_addr)
|
||||
const u32 xid = g_FsAioReadID++;
|
||||
aio_id = xid;
|
||||
|
||||
sys_fs.Warning("cellFsAioRead(aio_addr: 0x%x[%s], id_addr: 0x%x, func_addr: 0x%x[res=%d, addr=0x%x])", aio.GetAddr(),
|
||||
orig_file.GetPath().c_str(), aio_id.GetAddr(), func_addr, res, (u32)aio->buf_addr);
|
||||
|
||||
//TODO: init the callback
|
||||
/*CPUThread& new_thread = Emu.GetCPU().AddThread(CPU_THREAD_PPU);
|
||||
CPUThread& new_thread = Emu.GetCPU().AddThread(CPU_THREAD_PPU);
|
||||
new_thread.SetEntry(func_addr);
|
||||
new_thread.SetPrio(1001);
|
||||
new_thread.SetStackSize(0x10000);
|
||||
@ -427,7 +428,7 @@ int cellFsAioRead(mem_ptr_t<CellFsAio> aio, mem32_t aio_id, u32 func_addr)
|
||||
new_thread.SetArg(2, xid); //xid (unique id)
|
||||
new_thread.SetArg(3, res); //size (bytes read)
|
||||
new_thread.Run();
|
||||
new_thread.Exec();*/
|
||||
new_thread.Exec();
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
@ -23,17 +23,15 @@ struct SpuGroupInfo
|
||||
}
|
||||
};
|
||||
|
||||
u64 g_last_spu_offset = 0;
|
||||
|
||||
u32 LoadSpuImage(vfsStream& stream)
|
||||
u32 LoadSpuImage(vfsStream& stream, u32& spu_ep)
|
||||
{
|
||||
ELFLoader l(stream);
|
||||
l.LoadInfo();
|
||||
u32 alloc_size = 0xFFFFED - stream.GetSize();
|
||||
g_last_spu_offset = Memory.MainMem.Alloc(alloc_size);
|
||||
l.LoadData(g_last_spu_offset);
|
||||
|
||||
return g_last_spu_offset + l.GetEntry();
|
||||
const u32 alloc_size = 256 * 1024 /*0x1000000 - stream.GetSize()*/;
|
||||
u32 spu_offset = Memory.MainMem.Alloc(alloc_size);
|
||||
l.LoadData(spu_offset);
|
||||
spu_ep = l.GetEntry();
|
||||
return spu_offset;
|
||||
}
|
||||
|
||||
//156
|
||||
@ -54,11 +52,12 @@ int sys_spu_image_open(mem_ptr_t<sys_spu_image> img, u32 path_addr)
|
||||
return CELL_ENOENT;
|
||||
}
|
||||
|
||||
u32 entry = LoadSpuImage(f);
|
||||
u32 entry;
|
||||
u32 offset = LoadSpuImage(f, entry);
|
||||
|
||||
img->type = 1;
|
||||
img->entry_point = entry;
|
||||
img->segs_addr = 0x0;
|
||||
img->segs_addr = offset;
|
||||
img->nsegs = 0;
|
||||
|
||||
return CELL_OK;
|
||||
@ -97,7 +96,7 @@ int sys_spu_thread_initialize(mem32_t thread, u32 group, u32 spu_num, mem_ptr_t<
|
||||
return CELL_EBUSY;
|
||||
}
|
||||
|
||||
u32 ls_entry = img->entry_point - g_last_spu_offset;
|
||||
u32 spu_ep = (u32)img->entry_point;
|
||||
std::string name = Memory.ReadString(attr->name_addr, attr->name_len).mb_str();
|
||||
u64 a1 = arg->arg1;
|
||||
u64 a2 = arg->arg2;
|
||||
@ -107,10 +106,10 @@ int sys_spu_thread_initialize(mem32_t thread, u32 group, u32 spu_num, mem_ptr_t<
|
||||
CPUThread& new_thread = Emu.GetCPU().AddThread(CPU_THREAD_SPU);
|
||||
//copy SPU image:
|
||||
u32 spu_offset = Memory.MainMem.Alloc(256 * 1024);
|
||||
memcpy(Memory + spu_offset, Memory + g_last_spu_offset, 256 * 1024);
|
||||
memcpy(Memory + spu_offset, Memory + (u32)img->segs_addr, 256 * 1024);
|
||||
//initialize from new place:
|
||||
new_thread.SetOffset(spu_offset);
|
||||
new_thread.SetEntry(ls_entry);
|
||||
new_thread.SetEntry(spu_ep);
|
||||
new_thread.SetName(name);
|
||||
new_thread.SetArg(0, a1);
|
||||
new_thread.SetArg(1, a2);
|
||||
@ -123,7 +122,8 @@ int sys_spu_thread_initialize(mem32_t thread, u32 group, u32 spu_num, mem_ptr_t<
|
||||
group_info.threads[spu_num] = &new_thread;
|
||||
|
||||
ConLog.Write("New SPU Thread:");
|
||||
ConLog.Write("ls_entry = 0x%x", ls_entry);
|
||||
ConLog.Write("SPU img offset = 0x%x", (u32)img->segs_addr);
|
||||
ConLog.Write("entry_point = 0x%x", spu_ep);
|
||||
ConLog.Write("name = %s", name.c_str());
|
||||
ConLog.Write("a1 = 0x%x", a1);
|
||||
ConLog.Write("a2 = 0x%x", a2);
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
u32 LoadSpuImage(vfsStream& stream);
|
||||
u32 LoadSpuImage(vfsStream& stream, u32& spu_ep);
|
||||
|
||||
enum
|
||||
{
|
||||
@ -9,6 +9,13 @@ enum
|
||||
SYS_SPU_THREAD_GROUP_JOIN_TERMINATED = 0x0004
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
SYS_SPU_SEGMENT_TYPE_COPY = 0x0001,
|
||||
SYS_SPU_SEGMENT_TYPE_FILL = 0x0002,
|
||||
SYS_SPU_SEGMENT_TYPE_INFO = 0x0004,
|
||||
};
|
||||
|
||||
struct sys_spu_thread_group_attribute
|
||||
{
|
||||
be_t<u32> name_len;
|
||||
@ -35,8 +42,8 @@ struct sys_spu_thread_argument
|
||||
struct sys_spu_image
|
||||
{
|
||||
be_t<u32> type;
|
||||
be_t<u32> entry_point;
|
||||
be_t<u32> segs_addr;
|
||||
be_t<u32> entry_point;
|
||||
be_t<u32> segs_addr; //temporarily used as offset of LS image after elf loading
|
||||
be_t<int> nsegs;
|
||||
};
|
||||
|
||||
|
@ -119,8 +119,8 @@ bool ELF32Loader::LoadShdrInfo()
|
||||
|
||||
if(ehdr.e_shstrndx >= shdr_arr.GetCount())
|
||||
{
|
||||
ConLog.Error("LoadShdr32 error: shstrndx too big!");
|
||||
return false;
|
||||
ConLog.Warning("LoadShdr32 error: shstrndx too big!");
|
||||
return true;
|
||||
}
|
||||
|
||||
for(u32 i=0; i<shdr_arr.GetCount(); ++i)
|
||||
|
Loading…
Reference in New Issue
Block a user