Adds TODO comments to remove implementation defined pointer manipulation.

This commit is contained in:
Kenix3 2020-06-06 18:43:10 -04:00
parent cb8b9a2020
commit 2d191e301a
4 changed files with 4 additions and 2 deletions

View File

@ -4,6 +4,8 @@
#define ARRAY_COUNT(arr) (s32)(sizeof(arr) / sizeof(arr[0]))
#define ARRAY_COUNTU(arr) (u32)(sizeof(arr) / sizeof(arr[0]))
// UB: u32 casts here should be uintptr_t casts.
// TODO: After uintptr_t cast change should have an AVOID_UB target that just toggles the KSEG0 bit in the address rather than add/sub 0x80000000
#define PHYSICAL_TO_VIRTUAL(addr) ((u32)(addr) + 0x80000000)
#define PHYSICAL_TO_VIRTUAL2(addr) ((u32)(addr) - 0x80000000)
#define SEGMENTED_TO_VIRTUAL(addr) (void*)(PHYSICAL_TO_VIRTUAL(gRspSegmentPhysAddrs[SEGMENT_NUMBER(addr)]) + SEGMENT_OFFSET(addr))

View File

@ -4109,7 +4109,7 @@ extern UNK_TYPE1 D_801F80F8; // D_801F80F8
extern u64 lastRenderFrameTimestamp; // D_801F8150
extern OSMesgQueue siEventCallbackQueue; // D_801F8160
extern OSMesg siEventCallbackBuffer[1]; // D_801F8178
extern u32 gRspSegmentPhysAddrs[NUM_SEGMENTS]; // D_801F8180
extern u32 gRspSegmentPhysAddrs[NUM_SEGMENTS]; // D_801F8180 // u32 type should be uintptr_t
extern SchedThreadStruct schedContext; // D_801F81C0
extern OSMesgQueueListNode mainIrqmgrCallbackNode; // D_801F84F8
extern OSMesgQueue mainIrqmgrCallbackQueue; // D_801F8500

View File

@ -145,7 +145,6 @@ void* func_8012F73C(SceneContext* sceneCtxt, s32 iParm2, s16 id) {
vromSize = fileTableEntry->vromEnd - fileTableEntry->vromStart;
// TODO: UB to cast void to u32
addr = ((u32)sceneCtxt->objects[iParm2].vramAddr) + vromSize;
// TODO: This is ALIGN16 macro from OOT. Seems to be aligning an address to DMA
addr = ALIGN16(addr);
// UB to cast u32 to pointer
return (void*)addr;

View File

@ -2,6 +2,7 @@
#include <osint.h>
u32 osVirtualToPhysical(void* virtualAddress) {
// UB: u32 casts here should be uintptr_t casts.
if (((u32)virtualAddress >= 0x80000000) && ((u32)virtualAddress < 0xA0000000)) {
return (u32)virtualAddress & 0x1FFFFFFF;
} else if (((u32)virtualAddress >= 0xA0000000) && ((u32)virtualAddress < 0xC0000000)) {