mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-21 03:55:32 +00:00
Some fixes
This commit is contained in:
parent
259b57c64a
commit
125359e30e
15 changed files with 94 additions and 90 deletions
|
@ -310,7 +310,7 @@ class SPUThread : public PPCThread
|
|||
public:
|
||||
SPU_GPR_hdr GPR[128]; //General-Purpose Register
|
||||
SPU_SPR_hdr SPR[128]; //Special-Purpose Registers
|
||||
// FPSCR fpscr; //Unused
|
||||
FPSCR FPSCR;
|
||||
SPU_SNRConfig_hdr cfg; //Signal Notification Registers Configuration (OR-mode enabled: 0x1 for SNR1, 0x2 for SNR2)
|
||||
|
||||
EventPort SPUPs[64]; // SPU Thread Event Ports
|
||||
|
|
|
@ -32,11 +32,14 @@ u64 vfsStreamMemory::Write(const void* src, u64 size)
|
|||
size = GetSize() - Tell();
|
||||
}
|
||||
|
||||
if(!size || !Memory.IsGoodAddr(m_addr + Tell(), size)) return 0;
|
||||
|
||||
Memory.CopyFromReal(m_addr + Tell(), (void*)src, size);
|
||||
|
||||
return vfsStream::Write(src, size);
|
||||
if (!Memory.CopyFromReal(m_addr + Tell(), (void*)src, size))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return vfsStream::Write(src, size);
|
||||
}
|
||||
}
|
||||
|
||||
u64 vfsStreamMemory::Read(void* dst, u64 size)
|
||||
|
@ -46,9 +49,12 @@ u64 vfsStreamMemory::Read(void* dst, u64 size)
|
|||
size = GetSize() - Tell();
|
||||
}
|
||||
|
||||
if(!size || !Memory.IsGoodAddr(m_addr + Tell(), size)) return 0;
|
||||
|
||||
Memory.CopyToReal(dst, m_addr + Tell(), size);
|
||||
|
||||
return vfsStream::Read(dst, size);
|
||||
if (!Memory.CopyToReal(dst, m_addr + Tell(), size))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return vfsStream::Read(dst, size);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,14 +104,14 @@ bool MemoryBlock::GetMemFromAddr(void* dst, const u64 addr, const u32 size)
|
|||
{
|
||||
if(!IsMyAddress(addr) || FixAddr(addr) + size > GetSize()) return false;
|
||||
|
||||
return Memory.CopyToReal(dst, (u32)addr, size);
|
||||
return Memory.CopyToReal(dst, addr, size);
|
||||
}
|
||||
|
||||
bool MemoryBlock::SetMemFromAddr(void* src, const u64 addr, const u32 size)
|
||||
{
|
||||
if(!IsMyAddress(addr) || FixAddr(addr) + size > GetSize()) return false;
|
||||
|
||||
return Memory.CopyFromReal((u32)addr, src, size);
|
||||
return Memory.CopyFromReal(addr, src, size);
|
||||
}
|
||||
|
||||
bool MemoryBlock::GetMemFFromAddr(void* dst, const u64 addr)
|
||||
|
|
|
@ -318,51 +318,31 @@ public:
|
|||
u64 Read64(const u64 addr);
|
||||
u128 Read128(const u64 addr);
|
||||
|
||||
bool CopyToReal(void* real, u32 from, u32 count)
|
||||
bool CopyToReal(void* real, u64 from, u32 count)
|
||||
{
|
||||
if (!count) return true;
|
||||
if (!IsGoodAddr(from, count)) return false;
|
||||
|
||||
memcpy(real, GetMemFromAddr(from), count);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CopyFromReal(u32 to, const void* real, u32 count)
|
||||
bool CopyFromReal(u64 to, const void* real, u32 count)
|
||||
{
|
||||
if (!count) return true;
|
||||
if (!IsGoodAddr(to, count)) return false;
|
||||
|
||||
memcpy(GetMemFromAddr(to), real, count);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Copy(u32 to, u32 from, u32 count)
|
||||
bool Copy(u64 to, u64 from, u32 count)
|
||||
{
|
||||
if (u8* buf = (u8*)malloc(count))
|
||||
{
|
||||
if (CopyToReal(buf, from, count))
|
||||
{
|
||||
if (CopyFromReal(to, buf, count))
|
||||
{
|
||||
free(buf);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
free(buf);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
free(buf);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!IsGoodAddr(to, count) || !IsGoodAddr(from, count)) return false;
|
||||
|
||||
memmove(GetMemFromAddr(to), GetMemFromAddr(from), count);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ReadLeft(u8* dst, const u64 addr, const u32 size)
|
||||
|
@ -797,7 +777,7 @@ public:
|
|||
|
||||
u32 AppendRawBytes(const u8 *bytes, size_t count)
|
||||
{
|
||||
Memory.CopyFromReal(this->m_addr, bytes, count);
|
||||
memmove(Memory + this->m_addr, bytes, count);
|
||||
this->m_addr += count;
|
||||
return this->m_addr;
|
||||
}
|
||||
|
|
|
@ -724,33 +724,11 @@ int cellAdecGetPcm(u32 handle, u32 outBuffer_addr)
|
|||
|
||||
if (!af.data) // fake: empty data
|
||||
{
|
||||
/*u8* buf = (u8*)malloc(4096);
|
||||
memset(buf, 0, 4096);
|
||||
Memory.CopyFromReal(outBuffer_addr, buf, 4096);
|
||||
free(buf);*/
|
||||
return result;
|
||||
}
|
||||
|
||||
// copy data
|
||||
SwrContext* swr = nullptr;
|
||||
|
||||
/*swr = swr_alloc_set_opts(NULL, AV_CH_LAYOUT_STEREO, AV_SAMPLE_FMT_FLT, 48000,
|
||||
frame->channel_layout, (AVSampleFormat)frame->format, frame->sample_rate, 0, NULL);
|
||||
|
||||
if (!swr)
|
||||
{
|
||||
LOG_ERROR(HLE, "cellAdecGetPcm(%d): swr_alloc_set_opts() failed", handle);
|
||||
Emu.Pause();
|
||||
free(out);
|
||||
if (af.data)
|
||||
{
|
||||
av_frame_unref(af.data);
|
||||
av_frame_free(&af.data);
|
||||
}
|
||||
return result;
|
||||
}*/
|
||||
u8* out = (u8*)malloc(af.size);
|
||||
// something is wrong
|
||||
//swr_convert(swr, &out, frame->nb_samples, (const u8**)frame->extended_data, frame->nb_samples);
|
||||
|
||||
// reverse byte order, extract data:
|
||||
float* in_f[2];
|
||||
|
@ -770,7 +748,6 @@ int cellAdecGetPcm(u32 handle, u32 outBuffer_addr)
|
|||
}
|
||||
|
||||
free(out);
|
||||
if (swr) swr_free(&swr);
|
||||
|
||||
if (af.data)
|
||||
{
|
||||
|
|
|
@ -494,7 +494,12 @@ int cellGcmSetPrepareFlip(mem_ptr_t<CellGcmContextData> ctxt, u32 id)
|
|||
|
||||
const s32 res = ctxt->current - ctxt->begin - ctrl.put;
|
||||
|
||||
if(res > 0) Memory.Copy(ctxt->begin, ctxt->current - res, res);
|
||||
if (res > 0 && !Memory.Copy(ctxt->begin, ctxt->current - res, res))
|
||||
{
|
||||
cellGcmSys->Error("cellGcmSetPrepareFlip(): Memory.Copy(0x%x, 0x%x, 0x%x) failed", (u32)ctxt->begin, (u32)ctxt->current - res, res);
|
||||
Emu.Pause();
|
||||
return CELL_EFAULT;
|
||||
}
|
||||
ctxt->current = ctxt->begin + res;
|
||||
|
||||
//InterlockedExchange64((volatile long long*)((u8*)&ctrl + offsetof(CellGcmControl, put)), (u64)(u32)re(res));
|
||||
|
@ -1160,7 +1165,12 @@ int cellGcmCallback(u32 context_addr, u32 count)
|
|||
|
||||
const s32 res = ctx.current - ctx.begin - ctrl.put;
|
||||
|
||||
if(res > 0) Memory.Copy(ctx.begin, ctx.current - res, res);
|
||||
if (res > 0 && !Memory.Copy(ctx.begin, ctx.current - res, res))
|
||||
{
|
||||
cellGcmSys->Error("cellGcmCallback(): Memory.Copy(0x%x, 0x%x, 0x%x) failed", (u32)ctx.begin, (u32)ctx.current - res, res);
|
||||
Emu.Pause();
|
||||
return CELL_EFAULT;
|
||||
}
|
||||
|
||||
ctx.current = ctx.begin + res;
|
||||
|
||||
|
|
|
@ -182,7 +182,11 @@ int cellGifDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const m
|
|||
switch((u32)current_outParam.outputColorSpace)
|
||||
{
|
||||
case CELL_GIFDEC_RGBA:
|
||||
Memory.CopyFromReal(data.GetAddr(), image.get(), image_size);
|
||||
if (!Memory.CopyFromReal(data.GetAddr(), image.get(), image_size))
|
||||
{
|
||||
cellGifDec->Error("cellGifDecDecodeData() failed (dataa_addr=0x%x)", data.GetAddr());
|
||||
return CELL_EFAULT;
|
||||
}
|
||||
break;
|
||||
|
||||
case CELL_GIFDEC_ARGB:
|
||||
|
|
|
@ -164,7 +164,11 @@ int cellJpgDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const m
|
|||
case CELL_JPG_RGBA:
|
||||
case CELL_JPG_RGB:
|
||||
image_size *= current_outParam.outputColorSpace == CELL_JPG_RGBA ? 4 : 3;
|
||||
Memory.CopyFromReal(data.GetAddr(), image.get(), image_size);
|
||||
if (!Memory.CopyFromReal(data.GetAddr(), image.get(), image_size))
|
||||
{
|
||||
cellJpgDec->Error("cellJpgDecDecodeData() failed (data_addr=0x%x)", data.GetAddr());
|
||||
return CELL_EFAULT;
|
||||
}
|
||||
break;
|
||||
|
||||
case CELL_JPG_ARGB:
|
||||
|
|
|
@ -148,7 +148,11 @@ int cellPngDecReadHeader(u32 mainHandle, u32 subHandle, mem_ptr_t<CellPngDecInfo
|
|||
switch(subHandle_data->src.srcSelect.ToBE())
|
||||
{
|
||||
case se32(CELL_PNGDEC_BUFFER):
|
||||
Memory.Copy(buffer.GetAddr(), subHandle_data->src.streamPtr.ToLE(), buffer.GetSize());
|
||||
if (!Memory.Copy(buffer.GetAddr(), subHandle_data->src.streamPtr.ToLE(), buffer.GetSize()))
|
||||
{
|
||||
cellPngDec->Error("cellPngDecReadHeader() failed ()");
|
||||
return CELL_EFAULT;
|
||||
}
|
||||
break;
|
||||
case se32(CELL_PNGDEC_FILE):
|
||||
cellFsLseek(fd, 0, CELL_SEEK_SET, pos.GetAddr());
|
||||
|
@ -213,7 +217,11 @@ int cellPngDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const m
|
|||
switch(subHandle_data->src.srcSelect.ToLE())
|
||||
{
|
||||
case CELL_PNGDEC_BUFFER:
|
||||
Memory.Copy(png.GetAddr(), subHandle_data->src.streamPtr.ToLE(), png.GetSize());
|
||||
if (!Memory.Copy(png.GetAddr(), subHandle_data->src.streamPtr.ToLE(), png.GetSize()))
|
||||
{
|
||||
cellPngDec->Error("cellPngDecDecodeData() failed (I)");
|
||||
return CELL_EFAULT;
|
||||
}
|
||||
break;
|
||||
case CELL_PNGDEC_FILE:
|
||||
cellFsLseek(fd, 0, CELL_SEEK_SET, pos.GetAddr());
|
||||
|
@ -249,12 +257,20 @@ int cellPngDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const m
|
|||
{
|
||||
const int dstOffset = i * bytesPerLine;
|
||||
const int srcOffset = width * nComponents * (flip ? height - i - 1 : i);
|
||||
Memory.CopyFromReal(data.GetAddr() + dstOffset, &image.get()[srcOffset], linesize);
|
||||
if (!Memory.CopyFromReal(data.GetAddr() + dstOffset, &image.get()[srcOffset], linesize))
|
||||
{
|
||||
cellPngDec->Error("cellPngDecDecodeData() failed (II)");
|
||||
return CELL_EFAULT;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Memory.CopyFromReal(data.GetAddr(), image.get(), image_size);
|
||||
if (!Memory.CopyFromReal(data.GetAddr(), image.get(), image_size))
|
||||
{
|
||||
cellPngDec->Error("cellPngDecDecodeData() failed (III)");
|
||||
return CELL_EFAULT;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -279,7 +295,11 @@ int cellPngDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const m
|
|||
output[j + 2] = image.get()[srcOffset + j + 1];
|
||||
output[j + 3] = image.get()[srcOffset + j + 2];
|
||||
}
|
||||
Memory.CopyFromReal(data.GetAddr() + dstOffset, output, linesize);
|
||||
if (!Memory.CopyFromReal(data.GetAddr() + dstOffset, output, linesize))
|
||||
{
|
||||
cellPngDec->Error("cellPngDecDecodeData() failed (IV)");
|
||||
return CELL_EFAULT;
|
||||
}
|
||||
}
|
||||
free(output);
|
||||
}
|
||||
|
|
|
@ -168,9 +168,12 @@ 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());
|
||||
|
||||
Memory.Copy(RAW_SPU_BASE_ADDR + RAW_SPU_OFFSET * id, (u32)img->segs_addr, 256 * 1024);
|
||||
Memory.Write32(RAW_SPU_BASE_ADDR + RAW_SPU_OFFSET * id + RAW_SPU_PROB_OFFSET + SPU_NPC_offs,
|
||||
(u32)img->entry_point);
|
||||
if (!Memory.Copy(RAW_SPU_BASE_ADDR + RAW_SPU_OFFSET * id, (u32)img->segs_addr, 256 * 1024))
|
||||
{
|
||||
sysPrxForUser->Error("sys_raw_spu_image_load() failed");
|
||||
return CELL_EFAULT;
|
||||
}
|
||||
Memory.Write32(RAW_SPU_BASE_ADDR + RAW_SPU_OFFSET * id + RAW_SPU_PROB_OFFSET + SPU_NPC_offs, (u32)img->entry_point);
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ enum cellFsStStatus
|
|||
};
|
||||
|
||||
|
||||
#pragma pack(4)
|
||||
#pragma pack(push, 4)
|
||||
|
||||
struct CellFsStat
|
||||
{
|
||||
|
@ -98,7 +98,7 @@ struct CellFsDirent
|
|||
char d_name[CELL_MAX_FS_FILE_NAME_LENGTH + 1];
|
||||
};
|
||||
|
||||
#pragma pack()
|
||||
#pragma pack(pop)
|
||||
|
||||
struct CellFsAio
|
||||
{
|
||||
|
|
|
@ -14,8 +14,6 @@ struct sys_rwlock_attribute_t
|
|||
};
|
||||
};
|
||||
|
||||
#pragma pack()
|
||||
|
||||
struct RWLock
|
||||
{
|
||||
std::mutex m_lock; // internal lock
|
||||
|
|
|
@ -136,10 +136,14 @@ s32 sys_spu_thread_initialize(mem32_t thread, u32 group, u32 spu_num, mem_ptr_t<
|
|||
u64 a3 = arg->arg3;
|
||||
u64 a4 = arg->arg4;
|
||||
|
||||
CPUThread& new_thread = Emu.GetCPU().AddThread(CPU_THREAD_SPU);
|
||||
//copy SPU image:
|
||||
u32 spu_offset = Memory.MainMem.AllocAlign(256 * 1024);
|
||||
Memory.CopyToReal(Memory + spu_offset, (u32)img->segs_addr, 256 * 1024);
|
||||
auto spu_offset = Memory.MainMem.AllocAlign(256 * 1024);
|
||||
if (!Memory.Copy(spu_offset, (u32)img->segs_addr, 256 * 1024))
|
||||
{
|
||||
return CELL_EFAULT;
|
||||
}
|
||||
|
||||
CPUThread& new_thread = Emu.GetCPU().AddThread(CPU_THREAD_SPU);
|
||||
//initialize from new place:
|
||||
new_thread.SetOffset(spu_offset);
|
||||
new_thread.SetEntry(spu_ep);
|
||||
|
|
|
@ -20,8 +20,6 @@ struct timer
|
|||
sys_timer_information_t timer_information_t;
|
||||
};
|
||||
|
||||
#pragma pack()
|
||||
|
||||
s32 sys_timer_create(mem32_t timer_id);
|
||||
s32 sys_timer_destroy(u32 timer_id);
|
||||
s32 sys_timer_get_information(u32 timer_id, mem_ptr_t<sys_timer_information_t> info);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#pragma pack
|
||||
#pragma once
|
||||
|
||||
#define SYS_VM_TEST_INVALID 0x0000ULL
|
||||
#define SYS_VM_TEST_UNUSED 0x0001ULL
|
||||
|
|
Loading…
Add table
Reference in a new issue