mirror of
https://github.com/izzy2lost/ppsspp.git
synced 2026-03-10 12:43:04 -07:00
Split GetPointer into two versions, to help with const correctness
This commit is contained in:
@@ -493,7 +493,7 @@ int ElfReader::LoadInto(u32 loadAddress, bool fromTop)
|
||||
u32 writeAddr = segmentVAddr[i];
|
||||
|
||||
const u8 *src = GetSegmentPtr(i);
|
||||
u8 *dst = Memory::GetPointer(writeAddr);
|
||||
u8 *dst = Memory::GetPointerWrite(writeAddr);
|
||||
u32 srcSize = p->p_filesz;
|
||||
u32 dstSize = p->p_memsz;
|
||||
|
||||
|
||||
@@ -407,7 +407,7 @@ int ISOFileSystem::Ioctl(u32 handle, u32 cmd, u32 indataPtr, u32 inlen, u32 outd
|
||||
}
|
||||
|
||||
INFO_LOG(SCEIO, "sceIoIoctl: reading ISO9660 volume descriptor read");
|
||||
blockDevice->ReadBlock(16, Memory::GetPointer(outdataPtr));
|
||||
blockDevice->ReadBlock(16, Memory::GetPointerWriteUnchecked(outdataPtr));
|
||||
return 0;
|
||||
|
||||
// Get ISO9660 path table (from open ISO9660 file.)
|
||||
@@ -424,7 +424,7 @@ int ISOFileSystem::Ioctl(u32 handle, u32 cmd, u32 indataPtr, u32 inlen, u32 outd
|
||||
} else {
|
||||
int block = (u16)desc.firstLETableSector;
|
||||
u32 size = Memory::ValidSize(outdataPtr, (u32)desc.pathTableLength);
|
||||
u8 *out = Memory::GetPointer(outdataPtr);
|
||||
u8 *out = Memory::GetPointerWrite(outdataPtr);
|
||||
|
||||
int blocks = size / blockDevice->GetBlockSize();
|
||||
blockDevice->ReadBlocks(block, blocks, out);
|
||||
|
||||
@@ -106,7 +106,7 @@ template<u32 func()> void WrapU_V() {
|
||||
}
|
||||
|
||||
template<u32 func(int, void *, int)> void WrapU_IVI() {
|
||||
u32 retval = func(PARAM(0), Memory::GetPointer(PARAM(1)), PARAM(2));
|
||||
u32 retval = func(PARAM(0), Memory::GetPointerWrite(PARAM(1)), PARAM(2));
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ template<int func(const char *, int, int, u32)> void WrapI_CIIU() {
|
||||
}
|
||||
|
||||
template<int func(int, const char *, u32, void *, void *, u32, int)> void WrapI_ICUVVUI() {
|
||||
u32 retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), Memory::GetPointer(PARAM(3)),Memory::GetPointer(PARAM(4)), PARAM(5), PARAM(6) );
|
||||
u32 retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), Memory::GetPointerWrite(PARAM(3)),Memory::GetPointerWrite(PARAM(4)), PARAM(5), PARAM(6) );
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
@@ -147,13 +147,13 @@ template<int func(int, int, int, int, int, int, u32)> void WrapI_IIIIIIU() {
|
||||
|
||||
// Hm, do so many params get passed in registers?
|
||||
template<int func(int, int, int, int, int, int, int, int, u32)> void WrapI_IIIIIIIIU() {
|
||||
u32 param8 = *(const u32_le *)Memory::GetPointer(currentMIPS->r[29]); //Fixed 9th parameter, thanks to Kingcom
|
||||
u32 param8 = *(const u32_le *)Memory::GetPointerWrite(currentMIPS->r[29]); //Fixed 9th parameter, thanks to Kingcom
|
||||
u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5), PARAM(6), PARAM(7), param8);
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
template<u32 func(int, void *)> void WrapU_IV() {
|
||||
u32 retval = func(PARAM(0), Memory::GetPointer(PARAM(1)));
|
||||
u32 retval = func(PARAM(0), Memory::GetPointerWrite(PARAM(1)));
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
@@ -796,16 +796,16 @@ template <int func(int, const char *, int)> void WrapI_ICI() {
|
||||
}
|
||||
|
||||
template<int func(int, void *, void *, void *, void *, u32, int)> void WrapI_IVVVVUI(){
|
||||
u32 retval = func(PARAM(0), Memory::GetPointer(PARAM(1)), Memory::GetPointer(PARAM(2)), Memory::GetPointer(PARAM(3)), Memory::GetPointer(PARAM(4)), PARAM(5), PARAM(6) );
|
||||
u32 retval = func(PARAM(0), Memory::GetPointerWrite(PARAM(1)), Memory::GetPointerWrite(PARAM(2)), Memory::GetPointerWrite(PARAM(3)), Memory::GetPointerWrite(PARAM(4)), PARAM(5), PARAM(6) );
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
template<int func(int, const char *, u32, void *, int, int, int)> void WrapI_ICUVIII(){
|
||||
u32 retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), Memory::GetPointer(PARAM(3)), PARAM(4), PARAM(5), PARAM(6));
|
||||
u32 retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), Memory::GetPointerWrite(PARAM(3)), PARAM(4), PARAM(5), PARAM(6));
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
template<int func(void *, u32, int)> void WrapI_VUI(){
|
||||
u32 retval = func(Memory::GetPointer(PARAM(0)), PARAM(1), PARAM(2));
|
||||
u32 retval = func(Memory::GetPointerWrite(PARAM(0)), PARAM(1), PARAM(2));
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ static int Replace_memcpy() {
|
||||
}
|
||||
}
|
||||
if (!skip && bytes != 0) {
|
||||
u8 *dst = Memory::GetPointer(destPtr);
|
||||
u8 *dst = Memory::GetPointerWrite(destPtr);
|
||||
const u8 *src = Memory::GetPointer(srcPtr);
|
||||
|
||||
if (!dst || !src) {
|
||||
@@ -190,7 +190,7 @@ static int Replace_memcpy_jak() {
|
||||
}
|
||||
}
|
||||
if (!skip && bytes != 0) {
|
||||
u8 *dst = Memory::GetPointer(destPtr);
|
||||
u8 *dst = Memory::GetPointerWrite(destPtr);
|
||||
const u8 *src = Memory::GetPointer(srcPtr);
|
||||
|
||||
if (!dst || !src) {
|
||||
@@ -240,7 +240,7 @@ static int Replace_memcpy16() {
|
||||
}
|
||||
}
|
||||
if (!skip && bytes != 0) {
|
||||
u8 *dst = Memory::GetPointer(destPtr);
|
||||
u8 *dst = Memory::GetPointerWrite(destPtr);
|
||||
const u8 *src = Memory::GetPointer(srcPtr);
|
||||
if (dst && src) {
|
||||
memmove(dst, src, bytes);
|
||||
@@ -267,7 +267,7 @@ static int Replace_memcpy_swizzled() {
|
||||
gpu->PerformMemoryDownload(srcPtr, pitch * h);
|
||||
}
|
||||
}
|
||||
u8 *dstp = Memory::GetPointer(destPtr);
|
||||
u8 *dstp = Memory::GetPointerWrite(destPtr);
|
||||
const u8 *srcp = Memory::GetPointer(srcPtr);
|
||||
|
||||
if (dstp && srcp) {
|
||||
@@ -312,7 +312,7 @@ static int Replace_memmove() {
|
||||
}
|
||||
}
|
||||
if (!skip && bytes != 0) {
|
||||
u8 *dst = Memory::GetPointer(destPtr);
|
||||
u8 *dst = Memory::GetPointerWrite(destPtr);
|
||||
const u8 *src = Memory::GetPointer(srcPtr);
|
||||
if (dst && src) {
|
||||
memmove(dst, src, bytes);
|
||||
@@ -338,7 +338,7 @@ static int Replace_memset() {
|
||||
skip = gpu->PerformMemorySet(destPtr, value, bytes);
|
||||
}
|
||||
if (!skip && bytes != 0) {
|
||||
u8 *dst = Memory::GetPointer(destPtr);
|
||||
u8 *dst = Memory::GetPointerWrite(destPtr);
|
||||
if (dst) {
|
||||
memset(dst, value, bytes);
|
||||
}
|
||||
@@ -365,7 +365,7 @@ static int Replace_memset_jak() {
|
||||
skip = gpu->PerformMemorySet(destPtr, value, bytes);
|
||||
}
|
||||
if (!skip && bytes != 0) {
|
||||
u8 *dst = Memory::GetPointer(destPtr);
|
||||
u8 *dst = Memory::GetPointerWrite(destPtr);
|
||||
if (dst) {
|
||||
memset(dst, value, bytes);
|
||||
}
|
||||
|
||||
@@ -1263,7 +1263,7 @@ void notifyMatchingHandler(SceNetAdhocMatchingContext * context, ThreadMessage *
|
||||
MatchingArgs argsNew = { 0 };
|
||||
u32_le dataBufLen = msg->optlen + 8; //max(bufLen, msg->optlen + 8);
|
||||
u32_le dataBufAddr = userMemory.Alloc(dataBufLen); // We will free this memory after returning from mipscall. FIXME: Are these buffers supposed to be taken/pre-allocated from the memory pool during sceNetAdhocMatchingInit?
|
||||
uint8_t * dataPtr = Memory::GetPointer(dataBufAddr);
|
||||
uint8_t * dataPtr = Memory::GetPointerWrite(dataBufAddr);
|
||||
if (dataPtr) {
|
||||
memcpy(dataPtr, &msg->mac, sizeof(msg->mac));
|
||||
if (msg->optlen > 0)
|
||||
|
||||
@@ -33,7 +33,7 @@ static u32 sceAdler32(u32 adler, u32 data, u32 datalen) {
|
||||
}
|
||||
INFO_LOG(SCEMISC, "sceAdler32(adler=%08x, data=%08x, datalen=%08x)", adler, data, datalen);
|
||||
|
||||
u8 *buf = Memory::GetPointerUnchecked(data);
|
||||
u8 *buf = Memory::GetPointerWriteUnchecked(data);
|
||||
u32 ret = adler32(adler, buf, datalen);
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -480,7 +480,7 @@ struct Atrac {
|
||||
}
|
||||
|
||||
u8 *BufferStart() {
|
||||
return ignoreDataBuf_ ? Memory::GetPointer(first_.addr) : dataBuf_;
|
||||
return ignoreDataBuf_ ? Memory::GetPointerWrite(first_.addr) : dataBuf_;
|
||||
}
|
||||
|
||||
void SeekToSample(int sample) {
|
||||
@@ -1345,7 +1345,7 @@ static u32 sceAtracDecodeData(int atracID, u32 outAddr, u32 numSamplesAddr, u32
|
||||
u32 numSamples = 0;
|
||||
u32 finish = 0;
|
||||
int remains = 0;
|
||||
int ret = _AtracDecodeData(atracID, Memory::GetPointer(outAddr), outAddr, &numSamples, &finish, &remains);
|
||||
int ret = _AtracDecodeData(atracID, Memory::GetPointerWrite(outAddr), outAddr, &numSamples, &finish, &remains);
|
||||
if (ret != (int)ATRAC_ERROR_BAD_ATRACID && ret != (int)ATRAC_ERROR_NO_DATA) {
|
||||
if (Memory::IsValidAddress(numSamplesAddr))
|
||||
Memory::Write_U32(numSamples, numSamplesAddr);
|
||||
|
||||
@@ -116,7 +116,7 @@ static int sceAudiocodecDecode(u32 ctxPtr, int codec) {
|
||||
|
||||
if (decoder != NULL) {
|
||||
// Decode audio
|
||||
decoder->Decode(Memory::GetPointer(ctx->inDataPtr), ctx->inDataSize, Memory::GetPointer(ctx->outDataPtr), &outbytes);
|
||||
decoder->Decode(Memory::GetPointer(ctx->inDataPtr), ctx->inDataSize, Memory::GetPointerWrite(ctx->outDataPtr), &outbytes);
|
||||
}
|
||||
DEBUG_LOG(ME, "sceAudiocodecDec(%08x, %i (%s))", ctxPtr, codec, GetCodecName(codec));
|
||||
return 0;
|
||||
|
||||
@@ -218,7 +218,7 @@ static int sceSdGetLastIndex(u32 addressCtx, u32 addressHash, u32 addressKey)
|
||||
{
|
||||
pspChnnlsvContext1 ctx;
|
||||
Memory::ReadStruct(addressCtx, &ctx);
|
||||
int res = sceSdGetLastIndex_(ctx, Memory::GetPointer(addressHash), Memory::GetPointer(addressKey));
|
||||
int res = sceSdGetLastIndex_(ctx, Memory::GetPointerWrite(addressHash), Memory::GetPointerWrite(addressKey));
|
||||
Memory::WriteStruct(addressCtx, &ctx);
|
||||
return res;
|
||||
}
|
||||
@@ -348,7 +348,7 @@ static int sceSdRemoveValue(u32 addressCtx, u32 addressData, int length)
|
||||
{
|
||||
pspChnnlsvContext1 ctx;
|
||||
Memory::ReadStruct(addressCtx, &ctx);
|
||||
int res = sceSdRemoveValue_(ctx, Memory::GetPointer(addressData), length);
|
||||
int res = sceSdRemoveValue_(ctx, Memory::GetPointerWrite(addressData), length);
|
||||
Memory::WriteStruct(addressCtx, &ctx);
|
||||
|
||||
return res;
|
||||
@@ -400,8 +400,8 @@ static int sceSdCreateList(u32 ctx2Addr, int mode, int unkwn, u32 dataAddr, u32
|
||||
{
|
||||
pspChnnlsvContext2 ctx2;
|
||||
Memory::ReadStruct(ctx2Addr, &ctx2);
|
||||
u8* data = Memory::GetPointer(dataAddr);
|
||||
u8* cryptkey = Memory::GetPointer(cryptkeyAddr);
|
||||
u8* data = Memory::GetPointerWrite(dataAddr);
|
||||
u8* cryptkey = Memory::GetPointerWrite(cryptkeyAddr);
|
||||
|
||||
int res = sceSdCreateList_(ctx2, mode, unkwn, data, cryptkey);
|
||||
|
||||
@@ -468,7 +468,7 @@ static int sceSdSetMember(u32 ctxAddr, u32 dataAddr, int alignedLen)
|
||||
{
|
||||
pspChnnlsvContext2 ctx;
|
||||
Memory::ReadStruct(ctxAddr, &ctx);
|
||||
u8* data = Memory::GetPointer(dataAddr);
|
||||
u8* data = Memory::GetPointerWrite(dataAddr);
|
||||
|
||||
int res = sceSdSetMember_(ctx, data, alignedLen);
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ static int CommonDecompress(int windowBits, u32 OutBuffer, int OutBufferLength,
|
||||
}
|
||||
|
||||
z_stream stream{};
|
||||
u8 *outBufferPtr = Memory::GetPointer(OutBuffer);
|
||||
u8 *outBufferPtr = Memory::GetPointerWrite(OutBuffer);
|
||||
stream.next_in = (Bytef*)Memory::GetPointer(InBuffer);
|
||||
// We don't know the available length, just let it use as much as it wants.
|
||||
stream.avail_in = (uInt)Memory::ValidSize(InBuffer, Memory::g_MemorySize);
|
||||
|
||||
@@ -133,7 +133,7 @@ static u32 convertARGBtoABGR(u32 argb) {
|
||||
}
|
||||
|
||||
static int __DecodeJpeg(u32 jpegAddr, int jpegSize, u32 imageAddr) {
|
||||
u8 *buf = Memory::GetPointer(jpegAddr);
|
||||
const u8 *buf = Memory::GetPointer(jpegAddr);
|
||||
int width, height, actual_components;
|
||||
unsigned char *jpegBuf = jpgd::decompress_jpeg_image_from_memory(buf, jpegSize, &width, &height, &actual_components, 3);
|
||||
|
||||
@@ -219,7 +219,7 @@ static int getYCbCrBufferSize(int w, int h) {
|
||||
}
|
||||
|
||||
static int __JpegGetOutputInfo(u32 jpegAddr, int jpegSize, u32 colourInfoAddr) {
|
||||
u8 *buf = Memory::GetPointer(jpegAddr);
|
||||
const u8 *buf = Memory::GetPointer(jpegAddr);
|
||||
int width, height, actual_components;
|
||||
unsigned char *jpegBuf = jpgd::decompress_jpeg_image_from_memory(buf, jpegSize, &width, &height, &actual_components, 3);
|
||||
|
||||
@@ -325,7 +325,7 @@ static int __JpegConvertRGBToYCbCr (const void *data, u32 bufferOutputAddr, int
|
||||
}
|
||||
|
||||
static int __JpegDecodeMJpegYCbCr(u32 jpegAddr, int jpegSize, u32 yCbCrAddr) {
|
||||
u8 *buf = Memory::GetPointer(jpegAddr);
|
||||
const u8 *buf = Memory::GetPointer(jpegAddr);
|
||||
int width, height, actual_components;
|
||||
unsigned char *jpegBuf = jpgd::decompress_jpeg_image_from_memory(buf, jpegSize, &width, &height, &actual_components, 3);
|
||||
|
||||
|
||||
@@ -634,8 +634,8 @@ static u32 sceKernelMemcpy(u32 dst, u32 src, u32 size)
|
||||
// Technically should crash if these are invalid and size > 0...
|
||||
if (!skip && Memory::IsValidAddress(dst) && Memory::IsValidAddress(src) && Memory::IsValidAddress(dst + size - 1) && Memory::IsValidAddress(src + size - 1))
|
||||
{
|
||||
u8 *dstp = Memory::GetPointerUnchecked(dst);
|
||||
u8 *srcp = Memory::GetPointerUnchecked(src);
|
||||
u8 *dstp = Memory::GetPointerWriteUnchecked(dst);
|
||||
const u8 *srcp = Memory::GetPointerUnchecked(src);
|
||||
|
||||
// If it's non-overlapping, just do it in one go.
|
||||
if (dst + size < src || src + size < dst)
|
||||
@@ -688,7 +688,7 @@ const HLEFunction Kernel_Library[] =
|
||||
|
||||
static u32 sysclib_memcpy(u32 dst, u32 src, u32 size) {
|
||||
if (Memory::IsValidRange(dst, size) && Memory::IsValidRange(src, size)) {
|
||||
memcpy(Memory::GetPointer(dst), Memory::GetPointer(src), size);
|
||||
memcpy(Memory::GetPointerWriteUnchecked(dst), Memory::GetPointerUnchecked(src), size);
|
||||
}
|
||||
if (MemBlockInfoDetailed(size)) {
|
||||
const std::string tag = "KernelMemcpy/" + GetMemWriteTagAt(src, size);
|
||||
@@ -701,7 +701,7 @@ static u32 sysclib_memcpy(u32 dst, u32 src, u32 size) {
|
||||
static u32 sysclib_strcat(u32 dst, u32 src) {
|
||||
ERROR_LOG(SCEKERNEL, "Untested sysclib_strcat(dest=%08x, src=%08x)", dst, src);
|
||||
if (Memory::IsValidAddress(dst) && Memory::IsValidAddress(src)) {
|
||||
strcat((char *)Memory::GetPointer(dst), (char *)Memory::GetPointer(src));
|
||||
strcat((char *)Memory::GetPointerWriteUnchecked(dst), (const char *)Memory::GetPointerUnchecked(src));
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
@@ -709,7 +709,7 @@ static u32 sysclib_strcat(u32 dst, u32 src) {
|
||||
static int sysclib_strcmp(u32 dst, u32 src) {
|
||||
ERROR_LOG(SCEKERNEL, "Untested sysclib_strcmp(dest=%08x, src=%08x)", dst, src);
|
||||
if (Memory::IsValidAddress(dst) && Memory::IsValidAddress(src)) {
|
||||
return strcmp((char *)Memory::GetPointer(dst), (char *)Memory::GetPointer(src));
|
||||
return strcmp((const char *)Memory::GetPointerUnchecked(dst), (const char *)Memory::GetPointerUnchecked(src));
|
||||
} else {
|
||||
// What to do? Crash, probably.
|
||||
return 0;
|
||||
@@ -719,7 +719,7 @@ static int sysclib_strcmp(u32 dst, u32 src) {
|
||||
static u32 sysclib_strcpy(u32 dst, u32 src) {
|
||||
ERROR_LOG(SCEKERNEL, "Untested sysclib_strcpy(dest=%08x, src=%08x)", dst, src);
|
||||
if (Memory::IsValidAddress(dst) && Memory::IsValidAddress(src)) {
|
||||
strcpy((char *)Memory::GetPointer(dst), (char *)Memory::GetPointer(src));
|
||||
strcpy((char *)Memory::GetPointerWriteUnchecked(dst), (const char *)Memory::GetPointerUnchecked(src));
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
@@ -758,7 +758,7 @@ static int sysclib_sprintf(u32 dst, u32 fmt) {
|
||||
static u32 sysclib_memset(u32 destAddr, int data, int size) {
|
||||
ERROR_LOG(SCEKERNEL, "Untested sysclib_memset(dest=%08x, data=%d ,size=%d)", destAddr, data, size);
|
||||
if (Memory::IsValidRange(destAddr, size)) {
|
||||
memset(Memory::GetPointer(destAddr), data, size);
|
||||
memset(Memory::GetPointerWriteUnchecked(destAddr), data, size);
|
||||
}
|
||||
NotifyMemInfo(MemBlockFlags::WRITE, destAddr, size, "KernelMemset");
|
||||
return 0;
|
||||
@@ -791,7 +791,7 @@ static int sysclib_strncmp(u32 s1, u32 s2, u32 size) {
|
||||
static u32 sysclib_memmove(u32 dst, u32 src, u32 size) {
|
||||
ERROR_LOG(SCEKERNEL, "Untested sysclib_memmove(%08x, %08x, %08x)", dst, src, size);
|
||||
if (Memory::IsValidRange(dst, size) && Memory::IsValidRange(src, size)) {
|
||||
memmove(Memory::GetPointer(dst), Memory::GetPointer(src), size);
|
||||
memmove(Memory::GetPointerWriteUnchecked(dst), Memory::GetPointerUnchecked(src), size);
|
||||
}
|
||||
if (MemBlockInfoDetailed(size)) {
|
||||
const std::string tag = "KernelMemmove/" + GetMemWriteTagAt(src, size);
|
||||
@@ -810,7 +810,7 @@ static u32 sysclib_strncpy(u32 dest, u32 src, u32 size) {
|
||||
u32 i = 0;
|
||||
u32 srcSize = Memory::ValidSize(src, size);
|
||||
const u8 *srcp = Memory::GetPointer(src);
|
||||
u8 *destp = Memory::GetPointer(dest);
|
||||
u8 *destp = Memory::GetPointerWrite(dest);
|
||||
for (i = 0; i < srcSize; ++i) {
|
||||
u8 c = *srcp++;
|
||||
if (c == 0)
|
||||
|
||||
@@ -432,7 +432,7 @@ void __KernelMemoryInit()
|
||||
MemBlockInfoInit();
|
||||
kernelMemory.Init(PSP_GetKernelMemoryBase(), PSP_GetKernelMemoryEnd() - PSP_GetKernelMemoryBase(), false);
|
||||
userMemory.Init(PSP_GetUserMemoryBase(), PSP_GetUserMemoryEnd() - PSP_GetUserMemoryBase(), false);
|
||||
ParallelMemset(&g_threadManager, Memory::GetPointer(PSP_GetKernelMemoryBase()), 0, PSP_GetUserMemoryEnd() - PSP_GetKernelMemoryBase());
|
||||
ParallelMemset(&g_threadManager, Memory::GetPointerWrite(PSP_GetKernelMemoryBase()), 0, PSP_GetUserMemoryEnd() - PSP_GetKernelMemoryBase());
|
||||
NotifyMemInfo(MemBlockFlags::WRITE, PSP_GetKernelMemoryBase(), PSP_GetUserMemoryEnd() - PSP_GetKernelMemoryBase(), "MemInit");
|
||||
INFO_LOG(SCEKERNEL, "Kernel and user memory pools initialized");
|
||||
|
||||
|
||||
@@ -218,7 +218,7 @@ struct MsgPipe : public KernelObject
|
||||
// Receive as much as possible, even if it's not enough to wake up.
|
||||
u32 bytesToSend = std::min(thread->freeSize, GetUsedSize());
|
||||
|
||||
u8* ptr = Memory::GetPointer(buffer);
|
||||
u8* ptr = Memory::GetPointerWrite(buffer);
|
||||
thread->WriteBuffer(buffer, bytesToSend);
|
||||
// Put the unused data at the start of the buffer.
|
||||
nmp.freeSize += bytesToSend;
|
||||
@@ -494,7 +494,7 @@ static int __KernelReceiveMsgPipe(MsgPipe *m, u32 receiveBufAddr, u32 receiveSiz
|
||||
{
|
||||
Memory::Memcpy(curReceiveAddr, m->buffer, bytesToReceive, "MsgPipeReceive");
|
||||
m->nmp.freeSize += bytesToReceive;
|
||||
memmove(Memory::GetPointer(m->buffer), Memory::GetPointer(m->buffer) + bytesToReceive, m->GetUsedSize());
|
||||
memmove(Memory::GetPointerWrite(m->buffer), Memory::GetPointer(m->buffer) + bytesToReceive, m->GetUsedSize());
|
||||
curReceiveAddr += bytesToReceive;
|
||||
receiveSize -= bytesToReceive;
|
||||
|
||||
|
||||
@@ -466,8 +466,8 @@ int sceKernelPollSema(SceUID id, int wantedCount)
|
||||
|
||||
static u32 sceUtilsBufferCopyWithRange(u32 outAddr, int outSize, u32 inAddr, int inSize, int cmd)
|
||||
{
|
||||
u8 *outAddress = Memory::IsValidRange(outAddr, outSize) ? Memory::GetPointer(outAddr) : nullptr;
|
||||
const u8 *inAddress = Memory::IsValidRange(inAddr, inSize) ? Memory::GetPointer(inAddr) : nullptr;
|
||||
u8 *outAddress = Memory::IsValidRange(outAddr, outSize) ? Memory::GetPointerWriteUnchecked(outAddr) : nullptr;
|
||||
const u8 *inAddress = Memory::IsValidRange(inAddr, inSize) ? Memory::GetPointerUnchecked(inAddr) : nullptr;
|
||||
int temp = kirk_sceUtilsBufferCopyWithRange(outAddress, outSize, inAddress, inSize, cmd);
|
||||
if (temp != 0) {
|
||||
ERROR_LOG(SCEKERNEL, "hleUtilsBufferCopyWithRange: Failed with %d", temp);
|
||||
@@ -478,8 +478,8 @@ static u32 sceUtilsBufferCopyWithRange(u32 outAddr, int outSize, u32 inAddr, int
|
||||
// Note sure what difference there is between this and sceUtilsBufferCopyWithRange.
|
||||
static int sceUtilsBufferCopyByPollingWithRange(u32 outAddr, int outSize, u32 inAddr, int inSize, int cmd)
|
||||
{
|
||||
u8 *outAddress = Memory::IsValidRange(outAddr, outSize) ? Memory::GetPointer(outAddr) : nullptr;
|
||||
const u8 *inAddress = Memory::IsValidRange(inAddr, inSize) ? Memory::GetPointer(inAddr) : nullptr;
|
||||
u8 *outAddress = Memory::IsValidRange(outAddr, outSize) ? Memory::GetPointerWriteUnchecked(outAddr) : nullptr;
|
||||
const u8 *inAddress = Memory::IsValidRange(inAddr, inSize) ? Memory::GetPointerUnchecked(inAddr) : nullptr;
|
||||
return kirk_sceUtilsBufferCopyWithRange(outAddress, outSize, inAddress, inSize, cmd);
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ u32 sceKernelUtilsMt19937Init(u32 ctx, u32 seed) {
|
||||
DEBUG_LOG(HLE, "sceKernelUtilsMt19937Init(%08x, %08x)", ctx, seed);
|
||||
if (!Memory::IsValidAddress(ctx))
|
||||
return -1;
|
||||
void *ptr = Memory::GetPointer(ctx);
|
||||
void *ptr = Memory::GetPointerWrite(ctx);
|
||||
// This is made to match the memory layout of a PSP MT structure exactly.
|
||||
// Let's just construct it in place with placement new. Elite C++ hackery FTW.
|
||||
new (ptr) MersenneTwister(seed);
|
||||
@@ -43,7 +43,7 @@ u32 sceKernelUtilsMt19937UInt(u32 ctx) {
|
||||
VERBOSE_LOG(HLE, "sceKernelUtilsMt19937UInt(%08x)", ctx);
|
||||
if (!Memory::IsValidAddress(ctx))
|
||||
return -1;
|
||||
MersenneTwister *mt = (MersenneTwister *)Memory::GetPointer(ctx);
|
||||
MersenneTwister *mt = (MersenneTwister *)Memory::GetPointerUnchecked(ctx);
|
||||
return mt->R32();
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ static int sceMd5Digest(u32 dataAddr, u32 len, u32 digestAddr) {
|
||||
if (!Memory::IsValidAddress(dataAddr) || !Memory::IsValidAddress(digestAddr))
|
||||
return -1;
|
||||
|
||||
md5(Memory::GetPointer(dataAddr), (int)len, Memory::GetPointer(digestAddr));
|
||||
md5(Memory::GetPointerWriteUnchecked(dataAddr), (int)len, Memory::GetPointerWriteUnchecked(digestAddr));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ static int sceMd5BlockUpdate(u32 ctxAddr, u32 dataPtr, u32 len) {
|
||||
if (!Memory::IsValidAddress(ctxAddr) || !Memory::IsValidAddress(dataPtr))
|
||||
return -1;
|
||||
|
||||
md5_update(&md5_ctx, Memory::GetPointer(dataPtr), (int)len);
|
||||
md5_update(&md5_ctx, Memory::GetPointerWriteUnchecked(dataPtr), (int)len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ static int sceMd5BlockResult(u32 ctxAddr, u32 digestAddr) {
|
||||
if (!Memory::IsValidAddress(ctxAddr) || !Memory::IsValidAddress(digestAddr))
|
||||
return -1;
|
||||
|
||||
md5_finish(&md5_ctx, Memory::GetPointer(digestAddr));
|
||||
md5_finish(&md5_ctx, Memory::GetPointerWriteUnchecked(digestAddr));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ int sceKernelUtilsMd5Digest(u32 dataAddr, int len, u32 digestAddr) {
|
||||
if (!Memory::IsValidAddress(dataAddr) || !Memory::IsValidAddress(digestAddr))
|
||||
return -1;
|
||||
|
||||
md5(Memory::GetPointer(dataAddr), (int)len, Memory::GetPointer(digestAddr));
|
||||
md5(Memory::GetPointerWriteUnchecked(dataAddr), (int)len, Memory::GetPointerWriteUnchecked(digestAddr));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ int sceKernelUtilsMd5BlockUpdate(u32 ctxAddr, u32 dataPtr, int len) {
|
||||
if (!Memory::IsValidAddress(ctxAddr) || !Memory::IsValidAddress(dataPtr))
|
||||
return -1;
|
||||
|
||||
md5_update(&md5_ctx, Memory::GetPointer(dataPtr), (int)len);
|
||||
md5_update(&md5_ctx, Memory::GetPointerWriteUnchecked(dataPtr), (int)len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ int sceKernelUtilsMd5BlockResult(u32 ctxAddr, u32 digestAddr) {
|
||||
if (!Memory::IsValidAddress(ctxAddr) || !Memory::IsValidAddress(digestAddr))
|
||||
return -1;
|
||||
|
||||
md5_finish(&md5_ctx, Memory::GetPointer(digestAddr));
|
||||
md5_finish(&md5_ctx, Memory::GetPointerWriteUnchecked(digestAddr));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ int sceKernelUtilsSha1Digest(u32 dataAddr, int len, u32 digestAddr) {
|
||||
if (!Memory::IsValidAddress(dataAddr) || !Memory::IsValidAddress(digestAddr))
|
||||
return -1;
|
||||
|
||||
sha1(Memory::GetPointer(dataAddr), (int)len, Memory::GetPointer(digestAddr));
|
||||
sha1(Memory::GetPointerWriteUnchecked(dataAddr), (int)len, Memory::GetPointerWriteUnchecked(digestAddr));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ int sceKernelUtilsSha1BlockUpdate(u32 ctxAddr, u32 dataAddr, int len) {
|
||||
if (!Memory::IsValidAddress(ctxAddr) || !Memory::IsValidAddress(dataAddr))
|
||||
return -1;
|
||||
|
||||
sha1_update(&sha1_ctx, Memory::GetPointer(dataAddr), (int)len);
|
||||
sha1_update(&sha1_ctx, Memory::GetPointerWriteUnchecked(dataAddr), (int)len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ int sceKernelUtilsSha1BlockResult(u32 ctxAddr, u32 digestAddr) {
|
||||
if (!Memory::IsValidAddress(ctxAddr) || !Memory::IsValidAddress(digestAddr))
|
||||
return -1;
|
||||
|
||||
sha1_finish(&sha1_ctx, Memory::GetPointer(digestAddr));
|
||||
sha1_finish(&sha1_ctx, Memory::GetPointerWriteUnchecked(digestAddr));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -364,7 +364,7 @@ static int CalculateMp3SamplesPerFrame(int versionBits, int layerBits) {
|
||||
static int FindMp3Header(AuCtx *ctx, int &header, int end) {
|
||||
u32 addr = ctx->AuBuf + ctx->AuStreamWorkareaSize();
|
||||
if (Memory::IsValidRange(addr, end)) {
|
||||
u8 *ptr = Memory::GetPointerUnchecked(addr);
|
||||
const u8 *ptr = Memory::GetPointerUnchecked(addr);
|
||||
for (int offset = 0; offset < end; ++offset) {
|
||||
// If we hit valid sync bits, then we've found a header.
|
||||
if (ptr[offset] == 0xFF && (ptr[offset + 1] & 0xC0) == 0xC0) {
|
||||
@@ -689,11 +689,11 @@ static u32 sceMp3LowLevelDecode(u32 mp3, u32 sourceAddr, u32 sourceBytesConsumed
|
||||
return -1;
|
||||
}
|
||||
|
||||
auto inbuff = Memory::GetPointer(sourceAddr);
|
||||
auto outbuff = Memory::GetPointer(samplesAddr);
|
||||
auto inbuff = Memory::GetPointerWriteUnchecked(sourceAddr);
|
||||
auto outbuff = Memory::GetPointerWriteUnchecked(samplesAddr);
|
||||
|
||||
int outpcmbytes = 0;
|
||||
ctx->decoder->Decode((void*)inbuff, 4096, outbuff, &outpcmbytes);
|
||||
ctx->decoder->Decode(inbuff, 4096, outbuff, &outpcmbytes);
|
||||
NotifyMemInfo(MemBlockFlags::WRITE, samplesAddr, outpcmbytes, "Mp3LowLevelDecode");
|
||||
|
||||
Memory::Write_U32(ctx->decoder->GetSourcePos(), sourceBytesConsumedAddr);
|
||||
|
||||
@@ -628,7 +628,7 @@ static int sceMpegQueryStreamOffset(u32 mpeg, u32 bufferAddr, u32 offsetAddr)
|
||||
DEBUG_LOG(ME, "sceMpegQueryStreamOffset(%08x, %08x, %08x)", mpeg, bufferAddr, offsetAddr);
|
||||
|
||||
// Kinda destructive, no?
|
||||
AnalyzeMpeg(Memory::GetPointer(bufferAddr), Memory::ValidSize(bufferAddr, 32768), ctx);
|
||||
AnalyzeMpeg(Memory::GetPointerWriteUnchecked(bufferAddr), Memory::ValidSize(bufferAddr, 32768), ctx);
|
||||
|
||||
if (ctx->mpegMagic != PSMF_MAGIC) {
|
||||
ERROR_LOG(ME, "sceMpegQueryStreamOffset: Bad PSMF magic");
|
||||
@@ -660,7 +660,7 @@ static u32 sceMpegQueryStreamSize(u32 bufferAddr, u32 sizeAddr)
|
||||
MpegContext ctx;
|
||||
ctx.mediaengine = 0;
|
||||
|
||||
AnalyzeMpeg(Memory::GetPointer(bufferAddr), Memory::ValidSize(bufferAddr, 32768), &ctx);
|
||||
AnalyzeMpeg(Memory::GetPointerWriteUnchecked(bufferAddr), Memory::ValidSize(bufferAddr, 32768), &ctx);
|
||||
|
||||
if (ctx.mpegMagic != PSMF_MAGIC) {
|
||||
ERROR_LOG(ME, "sceMpegQueryStreamSize: Bad PSMF magic");
|
||||
@@ -965,7 +965,7 @@ static bool decodePmpVideo(PSPPointer<SceMpegRingBuffer> ringbuffer, u32 pmpctxA
|
||||
for (int i = 0; i < pmp_nBlocks; i++){
|
||||
auto lli = PSPPointer<SceMpegLLI>::Create(pmp_videoSource);
|
||||
// add source block into pmpframes
|
||||
pmpframes->add(Memory::GetPointer(lli->pSrc), lli->iSize);
|
||||
pmpframes->add(Memory::GetPointerWrite(lli->pSrc), lli->iSize);
|
||||
// get next block
|
||||
pmp_videoSource += sizeof(SceMpegLLI);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ static u32 sceMt19937Init(u32 mt19937Addr, u32 seed)
|
||||
{
|
||||
if (!Memory::IsValidAddress(mt19937Addr))
|
||||
return hleLogError(HLE, -1);
|
||||
void *ptr = Memory::GetPointer(mt19937Addr);
|
||||
void *ptr = Memory::GetPointerWriteUnchecked(mt19937Addr);
|
||||
// This is made to match the memory layout of a PSP MT structure exactly.
|
||||
// Let's just construct it in place with placement new. Elite C++ hackery FTW.
|
||||
new (ptr) MersenneTwister(seed);
|
||||
|
||||
@@ -684,7 +684,7 @@ static u32 sceWlanGetEtherAddr(u32 addrAddr) {
|
||||
return hleLogError(SCENET, SCE_KERNEL_ERROR_ILLEGAL_ADDR, "illegal address");
|
||||
}
|
||||
|
||||
u8 *addr = Memory::GetPointer(addrAddr);
|
||||
u8 *addr = Memory::GetPointerWriteUnchecked(addrAddr);
|
||||
if (PPSSPP_ID > 1) {
|
||||
Memory::Memset(addrAddr, PPSSPP_ID, 6);
|
||||
// Making sure the 1st 2-bits on the 1st byte of OUI are zero to prevent issue with some games (ie. Gran Turismo)
|
||||
@@ -722,8 +722,8 @@ static void sceNetEtherNtostr(u32 macPtr, u32 bufferPtr) {
|
||||
DEBUG_LOG(SCENET, "sceNetEtherNtostr(%08x, %08x) at %08x", macPtr, bufferPtr, currentMIPS->pc);
|
||||
|
||||
if (Memory::IsValidAddress(bufferPtr) && Memory::IsValidAddress(macPtr)) {
|
||||
char *buffer = (char *)Memory::GetPointer(bufferPtr);
|
||||
const u8 *mac = Memory::GetPointer(macPtr);
|
||||
char *buffer = (char *)Memory::GetPointerWriteUnchecked(bufferPtr);
|
||||
const u8 *mac = Memory::GetPointerUnchecked(macPtr);
|
||||
|
||||
// MAC address is always 6 bytes / 48 bits.
|
||||
sprintf(buffer, "%02x:%02x:%02x:%02x:%02x:%02x",
|
||||
@@ -748,8 +748,8 @@ static void sceNetEtherStrton(u32 bufferPtr, u32 macPtr) {
|
||||
DEBUG_LOG(SCENET, "sceNetEtherStrton(%08x, %08x)", bufferPtr, macPtr);
|
||||
|
||||
if (Memory::IsValidAddress(bufferPtr) && Memory::IsValidAddress(macPtr)) {
|
||||
const char *buffer = (char *)Memory::GetPointer(bufferPtr);
|
||||
u8 *mac = Memory::GetPointer(macPtr);
|
||||
const char *buffer = (const char *)Memory::GetPointerUnchecked(bufferPtr);
|
||||
u8 *mac = Memory::GetPointerWrite(macPtr);
|
||||
|
||||
// MAC address is always 6 pairs of hex digits.
|
||||
// TODO: Funny stuff happens if it's too short.
|
||||
@@ -896,7 +896,7 @@ static int sceNetApctlGetInfo(int code, u32 pInfoAddr) {
|
||||
if (!Memory::IsValidAddress(pInfoAddr))
|
||||
return hleLogError(SCENET, -1, "apctl invalid arg");
|
||||
|
||||
u8* info = Memory::GetPointer(pInfoAddr); // FIXME: Points to a union instead of a struct thus each field have the same address
|
||||
u8* info = Memory::GetPointerWrite(pInfoAddr); // FIXME: Points to a union instead of a struct thus each field have the same address
|
||||
|
||||
switch (code) {
|
||||
case PSP_NET_APCTL_INFO_PROFILE_NAME:
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user