summaryrefslogtreecommitdiff
path: root/libs/JSystem/JKernel
diff options
context:
space:
mode:
authorTakaRikka <38417346+TakaRikka@users.noreply.github.com>2022-12-19 11:06:32 -0800
committerGitHub <noreply@github.com>2022-12-19 12:06:32 -0700
commitca71275bbecc7db9a4eeca3a6ac4215b66de4318 (patch)
treec2851f8cec211216fe0cb6a31a0260a62fc3bf53 /libs/JSystem/JKernel
parent1114b13da81ab0b52fd4bb56a32f32331a21e581 (diff)
big d_a_alink pass (#214)
* d_a_alink pass1 wip * more d_a_alink work * remove asm * more daalink work * 20% dol code decompiled * fixed some nonmatchings for building * a few daalink functions and labeling some HIO data
Diffstat (limited to 'libs/JSystem/JKernel')
-rw-r--r--libs/JSystem/JKernel/JKRAram.cpp13
-rw-r--r--libs/JSystem/JKernel/JKRAramHeap.cpp2
-rw-r--r--libs/JSystem/JKernel/JKRAramStream.cpp15
-rw-r--r--libs/JSystem/JKernel/JKRDecomp.cpp1
-rw-r--r--libs/JSystem/JKernel/JKRDvdArchive.cpp4
-rw-r--r--libs/JSystem/JKernel/JKRFileCache.cpp2
-rw-r--r--libs/JSystem/JKernel/JKRFileLoader.cpp22
-rw-r--r--libs/JSystem/JKernel/JKRHeap.cpp2
-rw-r--r--libs/JSystem/JKernel/JKRMemArchive.cpp8
-rw-r--r--libs/JSystem/JKernel/JKRSolidHeap.cpp2
10 files changed, 31 insertions, 40 deletions
diff --git a/libs/JSystem/JKernel/JKRAram.cpp b/libs/JSystem/JKernel/JKRAram.cpp
index fad1d82be9..119155979c 100644
--- a/libs/JSystem/JKernel/JKRAram.cpp
+++ b/libs/JSystem/JKernel/JKRAram.cpp
@@ -10,6 +10,7 @@
#include "JSystem/JKernel/JKRAramStream.h"
#include "JSystem/JKernel/JKRExpHeap.h"
#include "JSystem/JUtility/JUTException.h"
+#include "MSL_C/string.h"
#include "dol2asm.h"
#include "dolphin/ar/ar.h"
#include "global.h"
@@ -28,7 +29,9 @@ extern "C" void mainRamToAram__7JKRAramFPUcUlUl15JKRExpandSwitchUlP7JKRHeapiPUl(
extern "C" void aramToMainRam__7JKRAramFUlPUcUl15JKRExpandSwitchUlP7JKRHeapiPUl();
extern "C" static void JKRDecompressFromAramToMainRam__FUlPvUlUlUlPUl();
extern "C" static void decompSZS_subroutine__FPUcPUc();
+static int decompSZS_subroutine(u8* param_0, u8* param_1);
extern "C" static void firstSrcData__Fv();
+static u8* firstSrcData(void);
extern "C" static void nextSrcData__FPUc();
extern "C" void __sinit_JKRAram_cpp();
extern "C" void func_802D2DF0(void* _this);
@@ -43,7 +46,6 @@ extern "C" u8 sAramObject__7JKRAram[4];
// External References:
//
-SECTION_INIT void memcpy();
extern "C" void alloc__7JKRHeapFUliP7JKRHeap();
extern "C" void alloc__7JKRHeapFUli();
extern "C" void free__7JKRHeapFPvP7JKRHeap();
@@ -281,7 +283,7 @@ static u32 readCount;
static u32 maxDest;
/* 804513FC-80451400 0008FC 0004+00 1/1 0/0 0/0 .sbss None */
-static u8 data_804513FC[4];
+static bool data_804513FC;
/* 80451400-80451404 000900 0004+00 2/2 0/0 0/0 .sbss tsPtr */
static u32* tsPtr;
@@ -297,8 +299,7 @@ static u32 tsArea;
// doesn't use r13
void JKRDecompressFromAramToMainRam(u32 src, void* dst, u32 srcLength, u32 dstLength, u32 offset,
u32* resourceSize) {
-#define s_is_decompress_mutex_initialized lbl_804513FC
-#define decompMutex lbl_804343C0
+#define s_is_decompress_mutex_initialized data_804513FC
// STATIC BEGIN
// This code is probably generated by the compiler for a static variable
@@ -311,7 +312,7 @@ void JKRDecompressFromAramToMainRam(u32 src, void* dst, u32 srcLength, u32 dstLe
// STATIC END
OSLockMutex(&decompMutex);
- u32 szpSize = getSZSBufferSize();
+ u32 szpSize = JKRAram::getSZSBufferSize();
szpBuf = (u8*)JKRAllocFromSysHeap(szpSize, 0x20);
ASSERT(szpBuf != 0);
szpEnd = szpBuf + szpSize;
@@ -431,7 +432,7 @@ static u8* nextSrcData(u8* current) {
transLeft -= transSize;
if (transLeft == 0) {
- srcLimit = (u32)(dest + left) + transSize;
+ srcLimit = (dest + left) + transSize;
}
return dest;
diff --git a/libs/JSystem/JKernel/JKRAramHeap.cpp b/libs/JSystem/JKernel/JKRAramHeap.cpp
index a3d800e690..0e04176dc3 100644
--- a/libs/JSystem/JKernel/JKRAramHeap.cpp
+++ b/libs/JSystem/JKernel/JKRAramHeap.cpp
@@ -78,7 +78,7 @@ JKRAramHeap::JKRAramHeap(u32 startAddress, u32 size) {
// close match, regalloc problem in the beginning of the while loop
#ifdef NONMATCHING
JKRAramHeap::~JKRAramHeap() {
- JSUList<JKRAramBlock>* list = &lbl_8043430C;
+ JSUList<JKRAramBlock>* list = &sAramList;
JSUListIterator<JKRAramBlock> iterator = list;
while (iterator != list->getEnd()) {
diff --git a/libs/JSystem/JKernel/JKRAramStream.cpp b/libs/JSystem/JKernel/JKRAramStream.cpp
index 7f770f9f0a..90b754a50f 100644
--- a/libs/JSystem/JKernel/JKRAramStream.cpp
+++ b/libs/JSystem/JKernel/JKRAramStream.cpp
@@ -7,6 +7,8 @@
#include "JSystem/JKernel/JKRAramPiece.h"
#include "JSystem/JKernel/JKRHeap.h"
#include "JSystem/JSupport/JSUFileStream.h"
+#include "JSystem/JSupport/JSURandomInputStream.h"
+#include "JSystem/JUtility/JUTException.h"
#include "dol2asm.h"
#include "global.h"
@@ -125,10 +127,10 @@ s32 JKRAramStream::readFromAram(void) {
#ifdef NONMATCHING
s32 JKRAramStream::writeToAram(JKRAramStreamCommand* command) {
u32 size;
- u32 dstSize = command->mDstLength;
+ u32 dstSize = command->mSize;
u32 offset = command->mOffset;
u32 writtenLength = 0;
- u32 destination = command->mDst;
+ u32 destination = command->mAddress;
u8* buffer = command->mTransferBuffer;
u32 bufferSize = command->mTransferBufferSize;
JKRHeap* heap = command->mHeap;
@@ -167,13 +169,11 @@ s32 JKRAramStream::writeToAram(JKRAramStreamCommand* command) {
heap->dump();
}
- panic_f__12JUTExceptionFPCciPCce("JKRAramStream.cpp", 0xac, "%s",
- ":::Cannot alloc memory\n");
+ JUTException::panic_f("JKRAramStream.cpp", 0xac, "%s", ":::Cannot alloc memory\n");
}
if (buffer) {
- seek__20JSURandomInputStreamFl17JSUStreamSeekFrom((JSURandomInputStream*)command->mStream,
- offset, 0);
+ ((JSURandomInputStream*)command->mStream)->seek(offset, JSUStreamSeekFrom_SET);
while (dstSize != 0) {
u32 length;
if (dstSize > size) {
@@ -182,8 +182,7 @@ s32 JKRAramStream::writeToAram(JKRAramStreamCommand* command) {
length = dstSize;
}
- s32 readLength =
- read__14JSUInputStreamFPvl((JSUInputStream*)command->mStream, buffer, length);
+ s32 readLength = ((JSURandomInputStream*)command->mStream)->read(buffer, length);
if (readLength == 0) {
writtenLength = 0;
break;
diff --git a/libs/JSystem/JKernel/JKRDecomp.cpp b/libs/JSystem/JKernel/JKRDecomp.cpp
index 1ea61165ed..f1f2a1799b 100644
--- a/libs/JSystem/JKernel/JKRDecomp.cpp
+++ b/libs/JSystem/JKernel/JKRDecomp.cpp
@@ -6,6 +6,7 @@
#include "JSystem/JKernel/JKRDecomp.h"
#include "JSystem/JKernel/JKRAramPiece.h"
#include "JSystem/JKernel/JKRHeap.h"
+#include "JSystem/JKernel/JKRArchive.h"
#include "dol2asm.h"
#include "dolphin/types.h"
diff --git a/libs/JSystem/JKernel/JKRDvdArchive.cpp b/libs/JSystem/JKernel/JKRDvdArchive.cpp
index 1e2ee8eb91..70597f9992 100644
--- a/libs/JSystem/JKernel/JKRDvdArchive.cpp
+++ b/libs/JSystem/JKernel/JKRDvdArchive.cpp
@@ -8,6 +8,8 @@
#include "JSystem/JKernel/JKRDvdRipper.h"
#include "JSystem/JKernel/JKRExpHeap.h"
#include "JSystem/JUtility/JUTException.h"
+#include "MSL_C/math.h"
+#include "MSL_C/string.h"
#include "dol2asm.h"
#include "global.h"
@@ -29,7 +31,6 @@ extern "C" extern char const* const JKRDvdArchive__stringBase0;
// External References:
//
-SECTION_INIT void memset();
extern "C" void alloc__7JKRHeapFUliP7JKRHeap();
extern "C" void alloc__7JKRHeapFUli();
extern "C" void free__7JKRHeapFPvP7JKRHeap();
@@ -70,7 +71,6 @@ extern "C" void _restgpr_26();
extern "C" void _restgpr_27();
extern "C" void _restgpr_28();
extern "C" void _restgpr_29();
-extern "C" void abs();
extern "C" u8 sVolumeList__13JKRFileLoader[12];
extern "C" u8 sSystemHeap__7JKRHeap[4];
diff --git a/libs/JSystem/JKernel/JKRFileCache.cpp b/libs/JSystem/JKernel/JKRFileCache.cpp
index 33f231947c..e480f0bc2c 100644
--- a/libs/JSystem/JKernel/JKRFileCache.cpp
+++ b/libs/JSystem/JKernel/JKRFileCache.cpp
@@ -319,7 +319,7 @@ void JKRFileCache::removeResourceAll(void) {
iterator = mCacheBlockList.getFirst();
while (iterator != mCacheBlockList.getEnd()) {
JKRFreeToHeap(mParentHeap, iterator->mMemoryPtr);
- mCacheBlockList.remove(&iterator->mLink);
+ mCacheBlockList.remove(iterator.mLink);
JSUListIterator<CCacheBlock> next = iterator++;
CCacheBlock* cacheBlock = next.getObject();
delete cacheBlock;
diff --git a/libs/JSystem/JKernel/JKRFileLoader.cpp b/libs/JSystem/JKernel/JKRFileLoader.cpp
index 88e153fef8..7570bec016 100644
--- a/libs/JSystem/JKernel/JKRFileLoader.cpp
+++ b/libs/JSystem/JKernel/JKRFileLoader.cpp
@@ -177,17 +177,7 @@ SECTION_DEAD static char const* const pad_8039D152 = "\0\0\0\0\0";
#pragma pop
/* 804508C0-804508C8 000340 0002+06 1/1 0/0 0/0 .sdata rootPath$2498 */
-SECTION_SDATA static u8 rootPath[2 + 6 /* padding */] = {
- 0x2F,
- 0x00,
- /* padding */
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
-};
+SECTION_SDATA static char rootPath[2] = "/";
/* 802D44C4-802D45A0 2CEE04 00DC+00 1/1 0/0 0/0 .text fetchVolumeName__13JKRFileLoaderFPclPCc */
// matches, but lbl_804508C0 is accessed through r13
@@ -198,9 +188,9 @@ const char* JKRFileLoader::fetchVolumeName(char* buffer, long bufferSize, const
// lbl_804508C0 = JKernel::rootPath$2498 "/"
// lbl_803D2D18 = MSL_C::__lower_map
- if (strcmp(path, lbl_8039D150) == 0) {
- strcpy(buffer, lbl_804508C0);
- return lbl_804508C0;
+ if (strcmp(path, "/") == 0) {
+ strcpy(buffer, rootPath);
+ return rootPath;
}
path++;
@@ -211,7 +201,7 @@ const char* JKRFileLoader::fetchVolumeName(char* buffer, long bufferSize, const
if (ch == -1) {
lower_char = -1;
} else {
- lower_char = lbl_803D2D18[ch & 0xFF];
+ lower_char = __lower_map[ch & 0xFF];
}
*buffer = lower_char;
@@ -223,7 +213,7 @@ const char* JKRFileLoader::fetchVolumeName(char* buffer, long bufferSize, const
*buffer = '\0';
if (*path == '\0') {
- path = lbl_804508C0;
+ path = rootPath;
}
return path;
diff --git a/libs/JSystem/JKernel/JKRHeap.cpp b/libs/JSystem/JKernel/JKRHeap.cpp
index 09ee11deeb..1087bc1eda 100644
--- a/libs/JSystem/JKernel/JKRHeap.cpp
+++ b/libs/JSystem/JKernel/JKRHeap.cpp
@@ -359,7 +359,7 @@ s32 JKRHeap::changeGroupID(u8 param_1) {
*/
// "not/nor" instruction in the wrong place
#ifdef NONMATCHING
-s32 JKRHeap::getMaxAllocatableSize(int alignment) {
+u32 JKRHeap::getMaxAllocatableSize(int alignment) {
u32 maxFreeBlock = (u32)getMaxFreeBlock();
s32 freeSize = getFreeSize();
diff --git a/libs/JSystem/JKernel/JKRMemArchive.cpp b/libs/JSystem/JKernel/JKRMemArchive.cpp
index 5f53043543..4d834d4dba 100644
--- a/libs/JSystem/JKernel/JKRMemArchive.cpp
+++ b/libs/JSystem/JKernel/JKRMemArchive.cpp
@@ -206,10 +206,10 @@ bool JKRMemArchive::open(long entryNum, JKRArchive::EMountDirection mountDirecti
mIsOpen = false;
mMountDirection = mountDirection;
- if (mMountDirection == JKRArchive::HEAD) {
+ if (mMountDirection == JKRArchive::MOUNT_DIRECTION_HEAD) {
u32 loadedSize;
mArcHeader = (SArcHeader*)JKRDvdRipper::loadToMainRAM(
- entryNum, NULL, EXPAND_SWITCH_UNKNOWN1, 0, mHeap, JKRDvdRipper::FORWARD, 0,
+ entryNum, NULL, EXPAND_SWITCH_UNKNOWN1, 0, mHeap, JKRDvdRipper::ALLOC_DIRECTION_FORWARD, 0,
&mCompression, &loadedSize);
if (mArcHeader) {
DCInvalidateRange(mArcHeader, loadedSize);
@@ -217,7 +217,7 @@ bool JKRMemArchive::open(long entryNum, JKRArchive::EMountDirection mountDirecti
} else {
u32 loadedSize;
mArcHeader = (SArcHeader*)JKRDvdRipper::loadToMainRAM(
- entryNum, NULL, EXPAND_SWITCH_UNKNOWN1, 0, mHeap, JKRDvdRipper::BACKWARD, 0,
+ entryNum, NULL, EXPAND_SWITCH_UNKNOWN1, 0, mHeap, JKRDvdRipper::ALLOC_DIRECTION_BACKWARD, 0,
&mCompression, &loadedSize);
if (mArcHeader) {
DCInvalidateRange(mArcHeader, loadedSize);
@@ -269,7 +269,7 @@ bool JKRMemArchive::open(void* buffer, u32 bufferSize, JKRMemBreakFlag flag) {
(u8*)(mArcHeader->file_data_offset + mArcHeader->header_length + (u32)mArcHeader);
mIsOpen = (flag == JKRMEMBREAK_FLAG_UNKNOWN1);
mHeap = JKRHeap::findFromRoot(buffer);
- mCompression = JKRDecomp::NONE;
+ mCompression = COMPRESSION_NONE;
return true;
}
#else
diff --git a/libs/JSystem/JKernel/JKRSolidHeap.cpp b/libs/JSystem/JKernel/JKRSolidHeap.cpp
index 79d79d5f6b..ab4185671a 100644
--- a/libs/JSystem/JKernel/JKRSolidHeap.cpp
+++ b/libs/JSystem/JKernel/JKRSolidHeap.cpp
@@ -323,7 +323,7 @@ void JKRSolidHeap::state_register(JKRHeap::TState* p, u32 id) const {
getState_(p);
setState_u32ID_(p, id);
- setState_uUsedSize_(p, getUsedSize());
+ setState_uUsedSize_(p, getUsedSize((JKRSolidHeap*)this));
setState_u32CheckCode_(p, (u32)mSolidHead + (u32)mSolidTail * 3);
}
#else