mirror of
https://github.com/izzy2lost/Diddy-Kong-Racing.git
synced 2026-06-19 01:16:26 -07:00
Matched __osContRamRead
This commit is contained in:
@@ -100,6 +100,28 @@ typedef struct
|
||||
#define DIR_STATUS_UNKNOWN 1
|
||||
#define DIR_STATUS_OCCUPIED 2
|
||||
|
||||
extern s32 __osEepStatus(OSMesgQueue *, OSContStatus *);
|
||||
u16 __osSumcalc(u8 *ptr, int length);
|
||||
s32 __osIdCheckSum(u16 *ptr, u16 *csum, u16 *icsum);
|
||||
s32 __osRepairPackId(OSPfs *pfs, __OSPackId *badid, __OSPackId *newid);
|
||||
s32 __osCheckPackId(OSPfs *pfs, __OSPackId *temp);
|
||||
s32 __osGetId(OSPfs *pfs);
|
||||
s32 __osCheckId(OSPfs *pfs);
|
||||
s32 __osPfsRWInode(OSPfs *pfs, __OSInode *inode, u8 flag, u8 bank);
|
||||
s32 __osPfsSelectBank(OSPfs *pfs);
|
||||
s32 __osPfsDeclearPage(OSPfs *pfs, __OSInode *inode, int file_size_in_pages, int *first_page, u8 bank, int *decleared, int *last_page);
|
||||
s32 __osPfsReleasePages(OSPfs *pfs, __OSInode *inode, u8 start_page, u16 *sum, u8 bank, __OSInodeUnit *last_page, int flag);
|
||||
s32 __osBlockSum(OSPfs *pfs, u8 page_no, u16 *sum, u8 bank);
|
||||
s32 __osContRamRead(OSMesgQueue *mq, int channel, u16 address, u8 *buffer);
|
||||
s32 __osContRamWrite(OSMesgQueue *mq, int channel, u16 address, u8 *buffer, int force);
|
||||
void __osContGetInitData(u8 *pattern, OSContStatus *data);
|
||||
void __osPackRequestData(u8 cmd);
|
||||
void __osPfsRequestData(u8 cmd);
|
||||
void __osPfsGetInitData(u8* pattern, OSContStatus* data);
|
||||
u8 __osContAddressCrc(u16 addr);
|
||||
u8 __osContDataCrc(u8 *data);
|
||||
s32 __osPfsGetStatus(OSMesgQueue *queue, int channel);
|
||||
|
||||
extern u8 __osContLastCmd;
|
||||
extern OSTimer __osEepromTimer;
|
||||
extern OSMesg __osEepromTimerMsg;
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
/* The comment below is needed for this file to be picked up by generate_ld */
|
||||
/* RAM_POS: 0x800CDCA0 */
|
||||
|
||||
#include "macros.h"
|
||||
#include "libultra_internal.h"
|
||||
#include "controller.h"
|
||||
#include "siint.h"
|
||||
|
||||
#if 0
|
||||
GLOBAL_ASM("lib/asm/non_matchings/unknown_0CE8A0/__osContRamRead.s")
|
||||
GLOBAL_ASM("lib/asm/non_matchings/unknown_0CE8A0/__osPackRamReadData.s")
|
||||
#else
|
||||
extern s32 D_8012CE1C;
|
||||
static void __osPackRamReadData(int channel, u16 address);
|
||||
s32 __osContRamRead(OSMesgQueue *mq, int channel, u16 address, u8 *buffer) {
|
||||
s32 ret;
|
||||
int i;
|
||||
u8 *ptr;
|
||||
__OSContRamReadFormat ramreadformat;
|
||||
int retry;
|
||||
ret = 0;
|
||||
ptr = (u8 *)&__osPfsPifRam;
|
||||
retry = 2;
|
||||
__osSiGetAccess();
|
||||
__osContLastCmd = CONT_CMD_READ_MEMPACK;
|
||||
__osPackRamReadData(channel, address);
|
||||
ret = __osSiRawStartDma(OS_WRITE, &__osPfsPifRam);
|
||||
osRecvMesg(mq, NULL, OS_MESG_BLOCK);
|
||||
do {
|
||||
for (i = 0; i < ARRLEN(__osPfsPifRam.ramarray) + 1; i++) { // also clear pifstatus
|
||||
__osPfsPifRam.ramarray[i] = 0xFFU;
|
||||
}
|
||||
D_8012CE1C = 0;
|
||||
ret = __osSiRawStartDma(OS_READ, &__osPfsPifRam);
|
||||
osRecvMesg(mq, NULL, OS_MESG_BLOCK);
|
||||
ptr = (u8 *)&__osPfsPifRam;
|
||||
if (channel != 0) {
|
||||
for (i = 0; i < channel; i++) {
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
ramreadformat = *(__OSContRamReadFormat *)ptr;
|
||||
ret = CHNL_ERR(ramreadformat);
|
||||
if (ret == 0) {
|
||||
u8 c;
|
||||
c = __osContDataCrc((u8*)&ramreadformat.data);
|
||||
if (c != ramreadformat.datacrc) {
|
||||
ret = __osPfsGetStatus(mq, channel);
|
||||
if (ret != 0) {
|
||||
__osSiRelAccess();
|
||||
return ret;
|
||||
}
|
||||
ret = PFS_ERR_CONTRFAIL;
|
||||
} else {
|
||||
for (i = 0; i < ARRLEN(ramreadformat.data); i++) {
|
||||
*buffer++ = ramreadformat.data[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ret != PFS_ERR_CONTRFAIL)
|
||||
break;
|
||||
} while (retry-- >= 0);
|
||||
__osSiRelAccess();
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void __osPackRamReadData(int channel, u16 address) {
|
||||
u8 *ptr;
|
||||
__OSContRamReadFormat ramreadformat;
|
||||
int i;
|
||||
|
||||
ptr = (u8 *)__osPfsPifRam.ramarray;
|
||||
|
||||
for (i = 0; i < ARRLEN(__osPfsPifRam.ramarray) + 1; i++) { // also clear pifstatus
|
||||
__osPfsPifRam.ramarray[i] = 0;
|
||||
}
|
||||
|
||||
__osPfsPifRam.pifstatus = CONT_CMD_EXE;
|
||||
ramreadformat.dummy = CONT_CMD_NOP;
|
||||
ramreadformat.txsize = CONT_CMD_READ_MEMPACK_TX;
|
||||
ramreadformat.rxsize = CONT_CMD_READ_MEMPACK_RX;
|
||||
ramreadformat.cmd = CONT_CMD_READ_MEMPACK;
|
||||
ramreadformat.address = (address << 0x5) | __osContAddressCrc(address);
|
||||
ramreadformat.datacrc = CONT_CMD_NOP;
|
||||
for (i = 0; i < ARRLEN(ramreadformat.data); i++) {
|
||||
ramreadformat.data[i] = CONT_CMD_NOP;
|
||||
}
|
||||
if (channel != 0) {
|
||||
for (i = 0; i < channel; i++) {
|
||||
*ptr++ = 0;
|
||||
}
|
||||
}
|
||||
*(__OSContRamReadFormat *)ptr = ramreadformat;
|
||||
ptr += sizeof(__OSContRamReadFormat);
|
||||
ptr[0] = CONT_CMD_END;
|
||||
}
|
||||
#endif
|
||||
@@ -1,8 +0,0 @@
|
||||
/* The comment below is needed for this file to be picked up by generate_ld */
|
||||
/* RAM_POS: 0x800CDCA0 */
|
||||
|
||||
#include "types.h"
|
||||
#include "macros.h"
|
||||
|
||||
GLOBAL_ASM("lib/asm/non_matchings/unknown_0CE8A0/__osContRamRead.s")
|
||||
GLOBAL_ASM("lib/asm/non_matchings/unknown_0CE8A0/__osPackRamReadData.s")
|
||||
Reference in New Issue
Block a user