diff options
| author | petrie911 <69443847+petrie911@users.noreply.github.com> | 2022-10-04 15:46:32 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-04 21:46:32 +0100 |
| commit | 2006a65ba62e7e848823cd1de009c9e16d6421eb (patch) | |
| tree | 90748c833b1620d1be9b9cbf1c19b18037626acf /src/code/z_lib.c | |
| parent | 8cd48db087ed7527d376195736eb9d4714bdf862 (diff) | |
z_overlay and z_fbdemo_dlftbls (Transition overlay handling), clean up a lot of u32s used to store pointers (#1073)
* overlay matches
* prototypes
* fbdemo too
* virtual to physical
* names, cleanup, etc
* bss reordering
* uintptr stuff
* fixed now?
* one fix
* headers and such
* fixes'n'stuff
* XXX action
* docs of a sort
* useless error codes
* n
* format
* header? I barely know her!
Co-authored-by: petrie911 <petrie911@users.noreply.github.com>
Diffstat (limited to 'src/code/z_lib.c')
| -rw-r--r-- | src/code/z_lib.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/code/z_lib.c b/src/code/z_lib.c index 03e6c395c..6466b337c 100644 --- a/src/code/z_lib.c +++ b/src/code/z_lib.c @@ -704,20 +704,30 @@ void* Lib_SegmentedToVirtual(void* ptr) { void* Lib_SegmentedToVirtualNull(void* ptr) { if (((uintptr_t)ptr >> 28) == 0) { return ptr; + } else { + return SEGMENTED_TO_VIRTUAL(ptr); } - - return SEGMENTED_TO_VIRTUAL(ptr); } -void* Lib_PhysicalToVirtual(void* ptr) { +/* + * Converts a 32-bit virtual address (0x80XXXXXX) to a 24-bit physical address (0xXXXXXX). The NULL case accounts for + * the NULL virtual address being 0x00000000 and not 0x80000000. Used by transition overlays, which store their + * addresses in 24-bit fields. + */ +void* Lib_VirtualToPhysical(void* ptr) { if (ptr == NULL) { return NULL; } else { - return (void*)PHYSICAL_TO_VIRTUAL(ptr); + return (void*)VIRTUAL_TO_PHYSICAL(ptr); } } -void* Lib_PhysicalToVirtualNull(void* ptr) { +/* + * Converts a 24-bit physical address (0xXXXXXX) to a 32-bit virtual address (0x80XXXXXX). The NULL case accounts for + * the NULL virtual address being 0x00000000 and not 0x80000000. Used by transition overlays, which store their + * addresses in 24-bit fields. + */ +void* Lib_PhysicalToVirtual(void* ptr) { if (ptr == NULL) { return NULL; } else { |
