mirror of
https://github.com/AloUltraExt/sm64ex-alo.git
synced 2025-01-22 07:32:15 -05:00
Post r15: Significantly more Libultra Cleanup
This commit is contained in:
parent
87ad88f77b
commit
2e6ef9cb94
43 changed files with 661 additions and 827 deletions
|
@ -114,65 +114,71 @@ index 7f3a0292..15dc1f06 100644
|
|||
@@ -1,4 +1,5 @@
|
||||
#include "libultra_internal.h"
|
||||
+#include <PR/console_type.h>
|
||||
#include "controller.h"
|
||||
#include "macros.h"
|
||||
|
||||
extern u8 _osLastSentSiCmd;
|
||||
|
||||
@@ -42,33 +43,44 @@ s32 osEepromRead(OSMesgQueue *mq, u8 address, u8 *buffer) {
|
||||
@@ -8,37 +9,48 @@ s32 osEepromRead(OSMesgQueue *mq, u8 address, u8 *buffer) {
|
||||
return -1;
|
||||
}
|
||||
__osSiGetAccess();
|
||||
- sp34 = __osEepStatus(mq, &sp28);
|
||||
- if (sp34 != 0 || sp28.unk00 != 0x8000) {
|
||||
- ret = __osEepStatus(mq, &sdata);
|
||||
- if (ret != 0 || sdata.type != CONT_EEPROM) {
|
||||
+ if (gConsoleType == CONSOLE_N64) {
|
||||
+ sp34 = __osEepStatus(mq, &sp28);
|
||||
+ if (sp34 != 0 || sp28.unk00 != 0x8000) {
|
||||
+ ret = __osEepStatus(mq, &sdata);
|
||||
+ if (ret != 0 || sdata.type != CONT_EEPROM) {
|
||||
|
||||
- return 8;
|
||||
- return CONT_NO_RESPONSE_ERROR;
|
||||
- }
|
||||
- while (sp28.unk02 & 0x80) {
|
||||
- __osEepStatus(mq, &sp28);
|
||||
- while (sdata.status & CONT_EEPROM_BUSY) {
|
||||
- __osEepStatus(mq, &sdata);
|
||||
- }
|
||||
- __osPackEepReadData(address);
|
||||
- sp34 = __osSiRawStartDma(OS_WRITE, &D_80365E00);
|
||||
-
|
||||
- ret = __osSiRawStartDma(OS_WRITE, &__osEepPifRam);
|
||||
- osRecvMesg(mq, NULL, OS_MESG_BLOCK);
|
||||
- for (sp30 = 0; sp30 < 0x10; sp30++) {
|
||||
- (D_80365E00)[sp30] = 255;
|
||||
-
|
||||
- for (i = 0; i < ARRAY_COUNT(__osEepPifRam.ramarray); i++) {
|
||||
- __osEepPifRam.ramarray[i] = CONT_CMD_NOP;
|
||||
- }
|
||||
- D_80365E3C = 0;
|
||||
- sp34 = __osSiRawStartDma(OS_READ, D_80365E00);
|
||||
- _osLastSentSiCmd = 4;
|
||||
- __osEepPifRam.s.pifstatus = 0;
|
||||
-
|
||||
- ret = __osSiRawStartDma(OS_READ, __osEepPifRam);
|
||||
- __osContLastCmd = CONT_CMD_READ_EEPROM;
|
||||
- osRecvMesg(mq, NULL, OS_MESG_BLOCK);
|
||||
- for (sp30 = 0; sp30 < 4; sp30++) {
|
||||
- sp2c++;
|
||||
-
|
||||
- for (i = 0; i < 4; i++) {
|
||||
- ptr++;
|
||||
- }
|
||||
- sp20 = *(unkStruct2 *) sp2c;
|
||||
- sp34 = (sp20.unk01 & 0xc0) >> 4;
|
||||
- if (sp34 == 0) {
|
||||
- for (sp30 = 0; sp30 < 8; sp30++) {
|
||||
- *buffer++ = ((u8 *) &sp20.unk04)[sp30];
|
||||
+ return 8;
|
||||
-
|
||||
- eepromformat = *(__OSContEepromFormat *) ptr;
|
||||
- ret = CHNL_ERR(eepromformat);
|
||||
- if (ret == 0) {
|
||||
- for (i = 0; i < 8; i++) {
|
||||
- *buffer++ = eepromformat.data[i];
|
||||
+ return CONT_NO_RESPONSE_ERROR;
|
||||
+ }
|
||||
+ while (sp28.unk02 & 0x80) {
|
||||
+ __osEepStatus(mq, &sp28);
|
||||
+ while (sdata.status & CONT_EEPROM_BUSY) {
|
||||
+ __osEepStatus(mq, &sdata);
|
||||
+ }
|
||||
+ __osPackEepReadData(address);
|
||||
+ sp34 = __osSiRawStartDma(OS_WRITE, &D_80365E00);
|
||||
+ ret = __osSiRawStartDma(OS_WRITE, &__osEepPifRam);
|
||||
+ osRecvMesg(mq, NULL, OS_MESG_BLOCK);
|
||||
+ for (sp30 = 0; sp30 < 0x10; sp30++) {
|
||||
+ (D_80365E00)[sp30] = 255;
|
||||
+ for (i = 0; i < 0x10; i++) {
|
||||
+ __osEepPifRam.ramarray[i] = CONT_CMD_NOP;
|
||||
}
|
||||
+ D_80365E3C = 0;
|
||||
+ sp34 = __osSiRawStartDma(OS_READ, D_80365E00);
|
||||
+ _osLastSentSiCmd = 4;
|
||||
+ __osEepPifRam.s.pifstatus = 0;
|
||||
+ ret = __osSiRawStartDma(OS_READ, __osEepPifRam);
|
||||
+ __osContLastCmd = CONT_CMD_READ_EEPROM;
|
||||
+ osRecvMesg(mq, NULL, OS_MESG_BLOCK);
|
||||
+ for (sp30 = 0; sp30 < 4; sp30++) {
|
||||
+ sp2c++;
|
||||
+ for (i = 0; i < 4; i++) {
|
||||
+ ptr++;
|
||||
+ }
|
||||
+ sp20 = *(unkStruct2 *) sp2c;
|
||||
+ sp34 = (sp20.unk01 & 0xc0) >> 4;
|
||||
+ if (sp34 == 0) {
|
||||
+ for (sp30 = 0; sp30 < 8; sp30++) {
|
||||
+ *buffer++ = ((u8 *) &sp20.unk04)[sp30];
|
||||
+ eepromformat = *(__OSContEepromFormat *) ptr;
|
||||
+ ret = CHNL_ERR(eepromformat);
|
||||
+ if (ret == 0) {
|
||||
+ for (i = 0; i < 8; i++) {
|
||||
+ *buffer++ = ((u8 *) &eepromformat.unk04)[i];
|
||||
+ }
|
||||
+ }
|
||||
+ } else if (gConsoleType == CONSOLE_IQUE) {
|
||||
|
@ -183,10 +189,10 @@ index 7f3a0292..15dc1f06 100644
|
|||
+ buffer[i] = __osBbEepromAddress[(address << 3) + i];
|
||||
+ }
|
||||
+
|
||||
+ sp34 = 0;
|
||||
+ ret = 0;
|
||||
}
|
||||
__osSiRelAccess();
|
||||
return sp34;
|
||||
return ret;
|
||||
diff --git a/lib/src/osEepromWrite.c b/lib/src/osEepromWrite.c
|
||||
index 67c42a59..f2c029cc 100644
|
||||
--- a/lib/src/osEepromWrite.c
|
||||
|
@ -194,79 +200,79 @@ index 67c42a59..f2c029cc 100644
|
|||
@@ -1,5 +1,6 @@
|
||||
#include "libultra_internal.h"
|
||||
#include "osContInternal.h"
|
||||
#include "controller.h"
|
||||
+#include <PR/console_type.h>
|
||||
|
||||
#ifndef AVOID_UB
|
||||
ALIGNED8 u32 D_80365E00[15];
|
||||
@@ -52,36 +53,47 @@ s32 osEepromWrite(OSMesgQueue *mq, u8 address, u8 *buffer) {
|
||||
OSPifRam __osEepPifRam;
|
||||
@@ -19,36 +20,47 @@ s32 osEepromWrite(OSMesgQueue *mq, u8 address, u8 *buffer) {
|
||||
}
|
||||
|
||||
__osSiGetAccess();
|
||||
- sp34 = __osEepStatus(mq, &sp1c);
|
||||
- ret = __osEepStatus(mq, &sdata);
|
||||
+ if (gConsoleType == CONSOLE_N64) {
|
||||
+ sp34 = __osEepStatus(mq, &sp1c);
|
||||
+ ret = __osEepStatus(mq, &sdata);
|
||||
|
||||
- if (sp34 != 0 || sp1c.unk00 != 0x8000) {
|
||||
- return 8;
|
||||
- if (ret != 0 || sdata.type != CONT_EEPROM) {
|
||||
- return CONT_NO_RESPONSE_ERROR;
|
||||
- }
|
||||
+ if (sp34 != 0 || sp1c.unk00 != 0x8000) {
|
||||
+ if (ret != 0 || sdata.type != CONT_EEPROM) {
|
||||
+ return 8;
|
||||
+ }
|
||||
|
||||
- while (sp1c.unk02 & 0x80) {
|
||||
- __osEepStatus(mq, &sp1c);
|
||||
- while (sdata.status & CONT_EEPROM_BUSY) {
|
||||
- __osEepStatus(mq, &sdata);
|
||||
- }
|
||||
+ while (sp1c.unk02 & 0x80) {
|
||||
+ __osEepStatus(mq, &sp1c);
|
||||
+ while (sdata.status & CONT_EEPROM_BUSY) {
|
||||
+ __osEepStatus(mq, &sdata);
|
||||
+ }
|
||||
|
||||
- __osPackEepWriteData(address, buffer);
|
||||
+ __osPackEepWriteData(address, buffer);
|
||||
|
||||
- sp34 = __osSiRawStartDma(OS_WRITE, &D_80365E00);
|
||||
- ret = __osSiRawStartDma(OS_WRITE, &__osEepPifRam);
|
||||
- osRecvMesg(mq, NULL, OS_MESG_BLOCK);
|
||||
+ sp34 = __osSiRawStartDma(OS_WRITE, &D_80365E00);
|
||||
+ ret = __osSiRawStartDma(OS_WRITE, &__osEepPifRam);
|
||||
+ osRecvMesg(mq, NULL, OS_MESG_BLOCK);
|
||||
|
||||
- for (sp30 = 0; sp30 < 0x10; sp30++) {
|
||||
- (D_80365E00)[sp30] = 255;
|
||||
- for (i = 0; i < ARRAY_COUNT(__osEepPifRam.ramarray); i++) {
|
||||
- __osEepPifRam.ramarray[i] = CONT_CMD_NOP;
|
||||
- }
|
||||
+ for (sp30 = 0; sp30 < 0x10; sp30++) {
|
||||
+ (D_80365E00)[sp30] = 255;
|
||||
+ for (i = 0; i < ARRAY_COUNT(__osEepPifRam.ramarray); i++) {
|
||||
+ __osEepPifRam.ramarray[i] = CONT_CMD_NOP;
|
||||
+ }
|
||||
|
||||
- D_80365E3C = 0;
|
||||
- sp34 = __osSiRawStartDma(OS_READ, D_80365E00);
|
||||
- _osLastSentSiCmd = 5;
|
||||
- __osEepPifRam.s.pifstatus = 0;
|
||||
- ret = __osSiRawStartDma(OS_READ, &__osEepPifRam);
|
||||
- __osContLastCmd = CONT_CMD_WRITE_EEPROM;
|
||||
- osRecvMesg(mq, NULL, OS_MESG_BLOCK);
|
||||
+ D_80365E3C = 0;
|
||||
+ sp34 = __osSiRawStartDma(OS_READ, D_80365E00);
|
||||
+ _osLastSentSiCmd = 5;
|
||||
+ __osEepPifRam.s.pifstatus = 0;
|
||||
+ ret = __osSiRawStartDma(OS_READ, &__osEepPifRam);
|
||||
+ __osContLastCmd = CONT_CMD_WRITE_EEPROM;
|
||||
+ osRecvMesg(mq, NULL, OS_MESG_BLOCK);
|
||||
|
||||
- for (sp30 = 0; sp30 < 4; sp30++) {
|
||||
- sp2c++;
|
||||
- for (i = 0; i < 4; i++) {
|
||||
- ptr++;
|
||||
- }
|
||||
+ for (sp30 = 0; sp30 < 4; sp30++) {
|
||||
+ sp2c++;
|
||||
+ for (i = 0; i < 4; i++) {
|
||||
+ ptr++;
|
||||
+ }
|
||||
+
|
||||
+ sp20 = *(unkStruct2 *) sp2c;
|
||||
+ sp34 = (sp20.unk01 & 0xc0) >> 4;
|
||||
+ eepromformat = *(__OSContEepromFormat *) ptr;
|
||||
+ ret = CHNL_ERR(eepromformat);
|
||||
+ } else if (gConsoleType == CONSOLE_IQUE) {
|
||||
+ u8 *__osBbEepromAddress = * (u8**) 0x8000035C;
|
||||
+ s32 i;
|
||||
+
|
||||
|
||||
- sp20 = *(unkStruct2 *) sp2c;
|
||||
- sp34 = (sp20.unk01 & 0xc0) >> 4;
|
||||
- eepromformat = *(__OSContEepromFormat *) ptr;
|
||||
- ret = CHNL_ERR(eepromformat);
|
||||
+ for (i = 0; i < 8; i++) {
|
||||
+ __osBbEepromAddress[(address << 3) + i] = buffer[i];
|
||||
+ }
|
||||
+
|
||||
+ sp34 = 0;
|
||||
+ ret = 0;
|
||||
+ }
|
||||
__osSiRelAccess();
|
||||
return sp34;
|
||||
return ret;
|
||||
}
|
||||
diff --git a/lib/src/osInitialize.c b/lib/src/osInitialize.c
|
||||
index ba73024b..6deaf407 100644
|
||||
|
@ -284,7 +290,7 @@ index ba73024b..6deaf407 100644
|
|||
u32 status;
|
||||
#endif
|
||||
|
||||
UNUSED u32 sp2c;
|
||||
UNUSED u32 ptr;
|
||||
|
||||
+ gConsoleType = get_console_type();
|
||||
__osFinalrom = TRUE;
|
||||
|
@ -296,7 +302,7 @@ index da9bc4dd..9c1cebba 100755
|
|||
+++ b/sm64.ld
|
||||
@@ -310,6 +310,8 @@ SECTIONS
|
||||
#if ENABLE_RUMBLE
|
||||
BUILD_DIR/libultra.a:unk_shindou_file_3.o(.text);
|
||||
BUILD_DIR/libultra.a:pfsgetstatus.o(.text);
|
||||
#endif
|
||||
+ BUILD_DIR/libultra.a:consoleType.o(.text);
|
||||
+ BUILD_DIR/libultra.a:skGetId.o(.text);
|
||||
|
@ -305,7 +311,7 @@ index da9bc4dd..9c1cebba 100755
|
|||
BUILD_DIR/src/game*.o(.text);
|
||||
@@ -432,6 +434,8 @@ SECTIONS
|
||||
#if ENABLE_RUMBLE
|
||||
BUILD_DIR/libultra.a:unk_shindou_file_3.o(.text);
|
||||
BUILD_DIR/libultra.a:pfsgetstatus.o(.text);
|
||||
#endif
|
||||
+ BUILD_DIR/libultra.a:consoleType.o(.text);
|
||||
+ BUILD_DIR/libultra.a:skGetId.o(.text);
|
||||
|
|
|
@ -53,7 +53,7 @@ extern "C" {
|
|||
typedef struct {
|
||||
u16 type; /* Controller Type */
|
||||
u8 status; /* Controller status */
|
||||
u8 errnum;
|
||||
u8 errnum;
|
||||
}OSContStatus;
|
||||
|
||||
typedef struct {
|
||||
|
@ -62,15 +62,15 @@ typedef struct {
|
|||
s8 stick_y; /* -80 <= stick_y <= 80 */
|
||||
s8 ext_stick_x;
|
||||
s8 ext_stick_y;
|
||||
u8 errnum;
|
||||
u8 errnum;
|
||||
} OSContPad;
|
||||
|
||||
typedef struct {
|
||||
void *address; /* Ram pad Address: 11 bits */
|
||||
u8 databuffer[32]; /* address of the data buffer */
|
||||
u8 addressCrc; /* CRC code for address */
|
||||
u8 addressCrc; /* CRC code for address */
|
||||
u8 dataCrc; /* CRC code for data */
|
||||
u8 errnum;
|
||||
u8 errnum;
|
||||
} OSContRamIo;
|
||||
|
||||
|
||||
|
|
94
include/PR/rdb.h
Normal file
94
include/PR/rdb.h
Normal file
|
@ -0,0 +1,94 @@
|
|||
|
||||
/**************************************************************************
|
||||
*
|
||||
* $Revision: 1.6 $
|
||||
* $Date: 1997/02/11 08:29:31 $
|
||||
* $Source: /disk6/Master/cvsmdev2/PR/include/rdb.h,v $
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef _RDB_H
|
||||
#define _RDB_H
|
||||
|
||||
/* U64 side address */
|
||||
#define RDB_BASE_REG 0xc0000000
|
||||
#define RDB_WRITE_INTR_REG (RDB_BASE_REG + 0x8)
|
||||
#define RDB_READ_INTR_REG (RDB_BASE_REG + 0xc)
|
||||
#define RDB_BASE_VIRTUAL_ADDR 0x80000000
|
||||
|
||||
/* packet type Have six bits, so can have up to 63 types */
|
||||
#define RDB_TYPE_INVALID 0
|
||||
#define RDB_TYPE_GtoH_PRINT 1
|
||||
#define RDB_TYPE_GtoH_FAULT 2
|
||||
#define RDB_TYPE_GtoH_LOG_CT 3
|
||||
#define RDB_TYPE_GtoH_LOG 4
|
||||
#define RDB_TYPE_GtoH_READY_FOR_DATA 5
|
||||
#define RDB_TYPE_GtoH_DATA_CT 6
|
||||
#define RDB_TYPE_GtoH_DATA 7
|
||||
#define RDB_TYPE_GtoH_DEBUG 8
|
||||
#define RDB_TYPE_GtoH_RAMROM 9
|
||||
#define RDB_TYPE_GtoH_DEBUG_DONE 10
|
||||
#define RDB_TYPE_GtoH_DEBUG_READY 11
|
||||
#define RDB_TYPE_GtoH_KDEBUG 12
|
||||
#define RDB_TYPE_GtoH_PROF_DATA 22
|
||||
|
||||
|
||||
#define RDB_TYPE_HtoG_LOG_DONE 13
|
||||
#define RDB_TYPE_HtoG_DEBUG 14
|
||||
#define RDB_TYPE_HtoG_DEBUG_CT 15
|
||||
#define RDB_TYPE_HtoG_DATA 16
|
||||
#define RDB_TYPE_HtoG_DATA_DONE 17
|
||||
#define RDB_TYPE_HtoG_REQ_RAMROM 18
|
||||
#define RDB_TYPE_HtoG_FREE_RAMROM 19
|
||||
#define RDB_TYPE_HtoG_KDEBUG 20
|
||||
#define RDB_TYPE_HtoG_PROF_SIGNAL 21
|
||||
|
||||
|
||||
#define RDB_PROF_ACK_SIG 1
|
||||
#define RDB_PROF_FLUSH_SIG 2
|
||||
#define PROF_BLOCK_SIZE 2048
|
||||
|
||||
#define RDB_LOG_MAX_BLOCK_SIZE 0x8000
|
||||
#define RDB_DATA_MAX_BLOCK_SIZE 0x8000
|
||||
|
||||
|
||||
/* GIO side address */
|
||||
#define GIO_RDB_BASE_REG 0xbf480000
|
||||
#define GIO_RDB_WRITE_INTR_REG (GIO_RDB_BASE_REG + 0x8)
|
||||
#define GIO_RDB_READ_INTR_REG (GIO_RDB_BASE_REG + 0xc)
|
||||
|
||||
/* minor device number */
|
||||
#define GIO_RDB_PRINT_MINOR 1
|
||||
#define GIO_RDB_DEBUG_MINOR 2
|
||||
|
||||
/* interrupt bit */
|
||||
#define GIO_RDB_WRITE_INTR_BIT 0x80000000
|
||||
#define GIO_RDB_READ_INTR_BIT 0x40000000
|
||||
|
||||
/* debug command */
|
||||
#define DEBUG_COMMAND_NULL 0
|
||||
#define DEBUG_COMMAND_MEMORY 1
|
||||
#define DEBUG_COMMAND_REGISTER 2
|
||||
#define DEBUG_COMMAND_INVALID 255
|
||||
|
||||
/* debug state */
|
||||
#define DEBUG_STATE_NULL 0
|
||||
#define DEBUG_STATE_RECEIVE 1
|
||||
#define DEBUG_STATE_INVALID 255
|
||||
|
||||
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
|
||||
|
||||
/* Structure for debug port */
|
||||
typedef struct {
|
||||
unsigned type : 2; /* 0: invalid, 1: print, 2: debug */
|
||||
unsigned pad : 4; // CHANGED FROM THE ORIGINAL LIBULTRA HEADER
|
||||
unsigned length : 2; /* 1, 2, or 3 */
|
||||
unsigned char buf[3]; /* character buffer */
|
||||
} rdbPacket;
|
||||
|
||||
extern unsigned int __osRdbWriteOK;
|
||||
extern unsigned int __osRdbSendMessage;
|
||||
|
||||
#endif /* _LANGUAGE_C */
|
||||
|
||||
#endif /* !_RDB_H */
|
|
@ -17,8 +17,8 @@ glabel __osExceptionPreamble
|
|||
nop
|
||||
|
||||
glabel __osException
|
||||
lui $k0, %hi(gInterruptedThread)
|
||||
addiu $k0, %lo(gInterruptedThread)
|
||||
lui $k0, %hi(__osThreadSave)
|
||||
addiu $k0, %lo(__osThreadSave)
|
||||
sd $at, 0x20($k0)
|
||||
mfc0 $k1, $12
|
||||
sw $k1, 0x118($k0)
|
||||
|
@ -217,20 +217,20 @@ glabel __osException
|
|||
nop
|
||||
lui $t2, %hi(D_C000000C)
|
||||
sw $zero, %lo(D_C000000C)($t2)
|
||||
lui $t1, %hi(D_80334A40)
|
||||
lw $t1, %lo(D_80334A40)($t1)
|
||||
lui $t1, %hi(__osRdbSendMessage)
|
||||
lw $t1, %lo(__osRdbSendMessage)($t1)
|
||||
addiu $t2, %lo(D_C000000C)
|
||||
beqz $t1, .L803268E8
|
||||
nop
|
||||
jal send_mesg
|
||||
li $a0, 120
|
||||
.L803268E8:
|
||||
lui $t1, %hi(D_80334A44)
|
||||
lw $t1, %lo(D_80334A44)($t1)
|
||||
lui $at, %hi(D_80334A44)
|
||||
lui $t1, %hi(__osRdbWriteOK)
|
||||
lw $t1, %lo(__osRdbWriteOK)($t1)
|
||||
lui $at, %hi(__osRdbWriteOK)
|
||||
addi $t1, $t1, 1
|
||||
b .L80326E08
|
||||
sw $t1, %lo(D_80334A44)($at)
|
||||
sw $t1, %lo(__osRdbWriteOK)($at)
|
||||
.L80326900:
|
||||
#endif
|
||||
andi $t1, $t0, 0x7c
|
||||
|
|
|
@ -1,148 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "piint.h"
|
||||
#include "PR/rcp.h"
|
||||
#include "new_func.h"
|
||||
#include "macros.h"
|
||||
|
||||
#if defined(VERSION_EU)
|
||||
s32 __osLeoInterrupt(void) {
|
||||
u32 sp3c;
|
||||
u32 sp38;
|
||||
u32 sp34;
|
||||
__OSTranxInfo *sp30;
|
||||
__OSBlockInfo *sp2c;
|
||||
u32 sp28;
|
||||
UNUSED __OSBlockInfo *sp24;
|
||||
if (!osDDActive) {
|
||||
return 0;
|
||||
}
|
||||
sp30 = &__osDiskHandle->transferInfo;
|
||||
sp2c = &sp30->block[sp30->blockNum];
|
||||
sp38 = IO_READ(PI_STATUS_REG);
|
||||
if (sp38 & PI_STATUS_DMA_BUSY) {
|
||||
IO_WRITE(PI_STATUS_REG, PI_STATUS_RESET | PI_STATUS_CLR_INTR);
|
||||
WAIT_ON_LEO_IO_BUSY(sp38);
|
||||
sp3c = IO_READ(LEO_STATUS);
|
||||
if (sp3c & LEO_STATUS_MECHANIC_INTERRUPT) {
|
||||
WAIT_ON_LEO_IO_BUSY(sp38);
|
||||
IO_WRITE(LEO_BM_CTL, sp30->bmCtlShadow | LEO_BM_CTL_CLR_MECHANIC_INTR);
|
||||
}
|
||||
sp30->errStatus = 75;
|
||||
func_802F4A20();
|
||||
return 1;
|
||||
}
|
||||
WAIT_ON_LEO_IO_BUSY(sp38);
|
||||
sp3c = IO_READ(LEO_STATUS);
|
||||
if (sp3c & LEO_STATUS_MECHANIC_INTERRUPT) {
|
||||
WAIT_ON_LEO_IO_BUSY(sp38);
|
||||
IO_WRITE(LEO_BM_CTL, sp30->bmCtlShadow | LEO_BM_CTL_CLR_MECHANIC_INTR);
|
||||
sp30->errStatus = 0;
|
||||
return 0;
|
||||
}
|
||||
if (sp3c & LEO_STATUS_BUFFER_MANAGER_ERROR) {
|
||||
sp30->errStatus = 3;
|
||||
func_802F4A20();
|
||||
return 1;
|
||||
}
|
||||
if (sp30->cmdType == 1) {
|
||||
if ((sp3c & LEO_STATUS_DATA_REQUEST) == 0) {
|
||||
if (sp30->sectorNum + 1 != sp30->transferMode * 85) {
|
||||
sp30->errStatus = 6;
|
||||
func_802F4A20();
|
||||
return 1;
|
||||
}
|
||||
IO_WRITE(PI_STATUS_REG, PI_STATUS_CLR_INTR);
|
||||
__OSGlobalIntMask |= 0x00100401;
|
||||
sp30->errStatus = 0;
|
||||
func_802F4B08();
|
||||
return 1;
|
||||
}
|
||||
sp2c->dramAddr = (void *) ((u32) sp2c->dramAddr + sp2c->sectorSize);
|
||||
sp30->sectorNum++;
|
||||
osEPiRawStartDma(__osDiskHandle, 1, 0x05000400, sp2c->dramAddr, sp2c->sectorSize);
|
||||
return 1;
|
||||
}
|
||||
if (sp30->cmdType == 0) {
|
||||
if (sp30->transferMode == 3) {
|
||||
if ((s32)(sp2c->C1ErrNum + 17) < sp30->sectorNum) {
|
||||
sp30->errStatus = 0;
|
||||
func_802F4A20();
|
||||
return 1;
|
||||
}
|
||||
if ((sp3c & LEO_STATUS_DATA_REQUEST) == 0) {
|
||||
sp30->errStatus = 17;
|
||||
func_802F4A20();
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
sp2c->dramAddr = (void *) ((u32) sp2c->dramAddr + sp2c->sectorSize);
|
||||
}
|
||||
sp34 = IO_READ(LEO_BM_STATUS);
|
||||
if (((LEO_BM_STATUS_C1SINGLE & sp34) && (LEO_BM_STATUS_C1DOUBLE & sp34)) || (sp34 & LEO_BM_STATUS_MICRO)) {
|
||||
if (sp2c->C1ErrNum > 3) {
|
||||
if (sp30->transferMode != 3 || sp30->sectorNum > 0x52) {
|
||||
sp30->errStatus = 17;
|
||||
func_802F4A20();
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
sp28 = sp2c->C1ErrNum;
|
||||
sp2c->C1ErrSector[sp28] = sp30->sectorNum + 1;
|
||||
}
|
||||
sp2c->C1ErrNum++;
|
||||
}
|
||||
if (sp3c & LEO_STATUS_C2_TRANSFER) {
|
||||
if (sp30->sectorNum != 87) {
|
||||
sp30->errStatus = 6;
|
||||
func_802F4A20();
|
||||
}
|
||||
if (sp30->transferMode == 2 && sp30->blockNum == 0) {
|
||||
sp30->blockNum = 1;
|
||||
sp30->sectorNum = -1;
|
||||
sp30->block[1].dramAddr =
|
||||
(void *) ((u32) sp30->block[1].dramAddr - sp30->block[1].sectorSize);
|
||||
} else {
|
||||
IO_WRITE(PI_STATUS_REG, PI_STATUS_CLR_INTR);
|
||||
__OSGlobalIntMask |= 0x00100401;
|
||||
}
|
||||
osEPiRawStartDma(__osDiskHandle, 0, 0x5000000, sp2c->C2Addr, sp2c->sectorSize * 4);
|
||||
sp30->errStatus = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (sp30->sectorNum == -1 && sp30->transferMode == 2 && sp30->blockNum == 1) {
|
||||
sp24 = &sp30->block[0];
|
||||
if (sp30->block[0].C1ErrNum == 0) {
|
||||
if (((u32 *) sp30->block[0].C2Addr)[0] | ((u32 *) sp30->block[0].C2Addr)[1]
|
||||
| ((u32 *) sp30->block[0].C2Addr)[2] | ((u32 *) sp30->block[0].C2Addr)[3]) {
|
||||
sp30->errStatus = 6;
|
||||
func_802F4A20();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
sp30->errStatus = 0;
|
||||
func_802F4B08();
|
||||
}
|
||||
sp30->sectorNum++;
|
||||
if (sp3c & LEO_STATUS_DATA_REQUEST) {
|
||||
if (sp30->sectorNum > 0x54) {
|
||||
sp30->errStatus = 6;
|
||||
func_802F4A20();
|
||||
return 1;
|
||||
}
|
||||
osEPiRawStartDma(__osDiskHandle, 0, 0x05000400, sp2c->dramAddr, sp2c->sectorSize);
|
||||
sp30->errStatus = 0;
|
||||
return 1;
|
||||
}
|
||||
if (sp30->sectorNum <= 0x54) {
|
||||
sp30->errStatus = 6;
|
||||
func_802F4A20();
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
sp30->errStatus = 75;
|
||||
func_802F4A20();
|
||||
return 1;
|
||||
}
|
||||
#endif
|
|
@ -9,7 +9,7 @@
|
|||
static s16 _Ldunscale(s16 *, printf_struct *);
|
||||
static void _Genld(printf_struct *, u8, u8 *, s16, s16);
|
||||
|
||||
const double D_80338670[] = { 10e0L, 10e1L, 10e3L, 10e7L, 10e15L, 10e31L, 10e63L, 10e127L, 10e255L };
|
||||
const double pows[] = { 10e0L, 10e1L, 10e3L, 10e7L, 10e15L, 10e31L, 10e63L, 10e127L, 10e255L };
|
||||
|
||||
/* float properties */
|
||||
#define _D0 0
|
||||
|
@ -92,7 +92,7 @@ void _Ldtob(printf_struct *args, u8 type) {
|
|||
exp = -n;
|
||||
for (i = 0; n > 0; n >>= 1, i++) {
|
||||
if ((n & 1) != 0) {
|
||||
val *= D_80338670[i];
|
||||
val *= pows[i];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -101,7 +101,7 @@ void _Ldtob(printf_struct *args, u8 type) {
|
|||
exp &= ~3;
|
||||
for (n = exp, i = 0; n > 0; n >>= 1, i++) {
|
||||
if ((n & 1) != 0) {
|
||||
factor *= D_80338670[i];
|
||||
factor *= pows[i];
|
||||
}
|
||||
}
|
||||
val /= factor;
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
|
||||
#define BUFF_LEN 0x18
|
||||
|
||||
static u8 D_80334960[] = "0123456789abcdef";
|
||||
static u8 D_80334974[] = "0123456789ABCDEF";
|
||||
static u8 ldigs[] = "0123456789abcdef";
|
||||
static u8 udigs[] = "0123456789ABCDEF";
|
||||
|
||||
void _Litob(printf_struct *args, u8 type) {
|
||||
u8 buff[BUFF_LEN];
|
||||
|
@ -17,9 +17,9 @@ void _Litob(printf_struct *args, u8 type) {
|
|||
lldiv_t quotrem;
|
||||
|
||||
if (type == 'X') {
|
||||
num_map = D_80334974;
|
||||
num_map = udigs;
|
||||
} else {
|
||||
num_map = D_80334960;
|
||||
num_map = ldigs;
|
||||
}
|
||||
|
||||
base = (type == 'o') ? 8 : ((type != 'x' && type != 'X') ? 10 : 16);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "macros.h"
|
||||
#include "PR/os.h"
|
||||
|
||||
#if defined(VERSION_EU) || defined(VERSION_SH)
|
||||
#include "new_func.h"
|
||||
|
@ -44,19 +45,19 @@ void __osDevMgrMain(void *args) {
|
|||
sp2c = 0;
|
||||
}
|
||||
osRecvMesg(sp34->accessQueue, &dummy, OS_MESG_BLOCK);
|
||||
__osResetGlobalIntMask(0x00100401); // remove magic constant!
|
||||
__osEPiRawWriteIo(mb->piHandle, 0x05000510, (sp24->bmCtlShadow | 0x80000000));
|
||||
__osResetGlobalIntMask(OS_IM_PI);
|
||||
osEPiRawWriteIo(mb->piHandle, 0x05000510, (sp24->bmCtlShadow | 0x80000000));
|
||||
while (TRUE) {
|
||||
osRecvMesg(sp34->eventQueue, &em, OS_MESG_BLOCK);
|
||||
#ifdef VERSION_SH
|
||||
sp24 = &mb->piHandle->transferInfo;
|
||||
sp28 = &sp24->block[sp24->blockNum];
|
||||
if (sp28->errStatus == 0x1D) {
|
||||
__osEPiRawWriteIo(mb->piHandle, 0x5000510, sp24->bmCtlShadow | 0x10000000);
|
||||
__osEPiRawWriteIo(mb->piHandle, 0x5000510, sp24->bmCtlShadow);
|
||||
__osEPiRawReadIo(mb->piHandle, 0x5000508, &tmp);
|
||||
osEPiRawWriteIo(mb->piHandle, 0x5000510, sp24->bmCtlShadow | 0x10000000);
|
||||
osEPiRawWriteIo(mb->piHandle, 0x5000510, sp24->bmCtlShadow);
|
||||
osEPiRawReadIo(mb->piHandle, 0x5000508, &tmp);
|
||||
if ((tmp & 0x2000000) != 0) {
|
||||
__osEPiRawWriteIo(mb->piHandle, 0x5000510, sp24->bmCtlShadow | 0x1000000);
|
||||
osEPiRawWriteIo(mb->piHandle, 0x5000510, sp24->bmCtlShadow | 0x1000000);
|
||||
}
|
||||
sp28->errStatus = 4;
|
||||
IO_WRITE(PI_STATUS_REG, PI_STATUS_CLR_INTR);
|
||||
|
@ -76,7 +77,7 @@ void __osDevMgrMain(void *args) {
|
|||
}
|
||||
osSendMesg(sp34->accessQueue, NULL, OS_MESG_NOBLOCK);
|
||||
if (mb->piHandle->transferInfo.blockNum == 1) {
|
||||
func_802F71F0();
|
||||
osYieldThread();
|
||||
}
|
||||
} else {
|
||||
switch (mb->hdr.type) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "new_func.h"
|
||||
#include "PR/os.h"
|
||||
|
||||
void __osResetGlobalIntMask(u32 mask) {
|
||||
register u32 prev;
|
||||
|
|
|
@ -1,38 +1,33 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "PR/rdb.h"
|
||||
#include "PR/R4300.h"
|
||||
|
||||
typedef struct {
|
||||
u8 unk00 : 2;
|
||||
u8 pad : 4;
|
||||
u8 unk01 : 2;
|
||||
u8 unk2[3];
|
||||
} unkStruct;
|
||||
u32 __osRdbSendMessage = 0;
|
||||
u32 __osRdbWriteOK = 1;
|
||||
|
||||
u32 D_80334A40 = 0;
|
||||
u32 D_80334A44 = 1;
|
||||
void __osSyncPutChars(s32 type, s32 length, u8 *buf) {
|
||||
rdbPacket packet;
|
||||
s32 i;
|
||||
u32 mask;
|
||||
packet.type = type;
|
||||
packet.length = length;
|
||||
|
||||
void __osSyncPutChars(s32 a0, s32 a1, u8 *a2) {
|
||||
unkStruct sp24;
|
||||
s32 sp20;
|
||||
u32 sp1c;
|
||||
sp24.unk00 = a0;
|
||||
sp24.unk01 = a1;
|
||||
|
||||
for (sp20 = 0; sp20 < a1; sp20++) {
|
||||
sp24.unk2[sp20] = a2[sp20];
|
||||
for (i = 0; i < length; i++) {
|
||||
packet.buf[i] = buf[i];
|
||||
}
|
||||
|
||||
while (!__osAtomicDec(&D_80334A44)) {
|
||||
while (!__osAtomicDec(&__osRdbWriteOK)) {
|
||||
;
|
||||
}
|
||||
|
||||
sp1c = __osDisableInt();
|
||||
mask = __osDisableInt();
|
||||
|
||||
*(u32 *) 0xC0000000 = *(u32 *) &sp24;
|
||||
while (!(__osGetCause() & 0x2000)) {
|
||||
*(u32 *) RDB_BASE_REG = *(u32 *) &packet;
|
||||
while (!(__osGetCause() & CAUSE_IP6)) {
|
||||
;
|
||||
}
|
||||
*(u32 *) 0xC000000C = 0;
|
||||
D_80334A44++;
|
||||
*(u32 *) RDB_READ_INTR_REG = 0;
|
||||
__osRdbWriteOK++;
|
||||
|
||||
__osRestoreInt(sp1c);
|
||||
__osRestoreInt(mask);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include "controller.h"
|
||||
#include "macros.h"
|
||||
|
||||
extern s32 func_8030A5C0(OSMesgQueue *, s32);
|
||||
extern s32 __osPfsGetStatus(OSMesgQueue *, s32);
|
||||
void __osPackRamReadData(int channel, u16 address);
|
||||
|
||||
s32 __osContRamRead(OSMesgQueue *mq, int channel, u16 address, u8 *buffer) {
|
||||
|
@ -16,7 +16,7 @@ s32 __osContRamRead(OSMesgQueue *mq, int channel, u16 address, u8 *buffer) {
|
|||
ptr = (u8 *)&__osPfsPifRam;
|
||||
retry = 2;
|
||||
__osSiGetAccess();
|
||||
_osLastSentSiCmd = CONT_CMD_READ_MEMPACK;
|
||||
__osContLastCmd = CONT_CMD_READ_MEMPACK;
|
||||
__osPackRamReadData(channel, address);
|
||||
ret = __osSiRawStartDma(OS_WRITE, &__osPfsPifRam);
|
||||
osRecvMesg(mq, NULL, OS_MESG_BLOCK);
|
||||
|
@ -35,7 +35,7 @@ s32 __osContRamRead(OSMesgQueue *mq, int channel, u16 address, u8 *buffer) {
|
|||
u8 c;
|
||||
c = __osContDataCrc((u8*)&ramreadformat.data);
|
||||
if (c != ramreadformat.datacrc) {
|
||||
ret = func_8030A5C0(mq, channel);
|
||||
ret = __osPfsGetStatus(mq, channel);
|
||||
if (ret != 0) {
|
||||
__osSiRelAccess();
|
||||
return ret;
|
||||
|
@ -64,11 +64,11 @@ void __osPackRamReadData(int channel, u16 address) {
|
|||
|
||||
ptr = (u8 *)__osPfsPifRam.ramarray;
|
||||
|
||||
for (i = 0; i < ARRAY_COUNT(__osPfsPifRam.ramarray) + 1; i++) { // also clear pifstatus
|
||||
for (i = 0; i < ARRAY_COUNT(__osPfsPifRam.ramarray); i++) {
|
||||
__osPfsPifRam.ramarray[i] = 0;
|
||||
}
|
||||
|
||||
__osPfsPifRam.pifstatus = CONT_CMD_EXE;
|
||||
__osPfsPifRam.s.pifstatus = CONT_CMD_EXE;
|
||||
ramreadformat.dummy = CONT_CMD_NOP;
|
||||
ramreadformat.txsize = CONT_CMD_READ_MEMPACK_TX;
|
||||
ramreadformat.rxsize = CONT_CMD_READ_MEMPACK_RX;
|
||||
|
|
|
@ -3,15 +3,15 @@
|
|||
#include "controller.h"
|
||||
#include "macros.h"
|
||||
|
||||
extern s32 func_8030A5C0(OSMesgQueue *, s32);
|
||||
void __osPackRamWriteData(int channel, u16 address, u8 *buffer);
|
||||
extern s32 __osPfsGetStatus(OSMesgQueue *, s32);
|
||||
void __osPackRamWriteData(s32 channel, u16 address, u8 *buffer);
|
||||
|
||||
s32 __osContRamWrite(OSMesgQueue *mq, int channel, u16 address, u8 *buffer, int force) {
|
||||
s32 __osContRamWrite(OSMesgQueue *mq, s32 channel, u16 address, u8 *buffer, s32 force) {
|
||||
s32 ret;
|
||||
int i;
|
||||
s32 i;
|
||||
u8 *ptr;
|
||||
__OSContRamReadFormat ramreadformat;
|
||||
int retry;
|
||||
s32 retry;
|
||||
|
||||
ret = 0;
|
||||
ptr = (u8 *)&__osPfsPifRam;
|
||||
|
@ -20,7 +20,7 @@ s32 __osContRamWrite(OSMesgQueue *mq, int channel, u16 address, u8 *buffer, int
|
|||
return 0;
|
||||
}
|
||||
__osSiGetAccess();
|
||||
_osLastSentSiCmd = CONT_CMD_WRITE_MEMPACK;
|
||||
__osContLastCmd = CONT_CMD_WRITE_MEMPACK;
|
||||
__osPackRamWriteData(channel, address, buffer);
|
||||
ret = __osSiRawStartDma(OS_WRITE, &__osPfsPifRam);
|
||||
osRecvMesg(mq, NULL, OS_MESG_BLOCK);
|
||||
|
@ -39,7 +39,7 @@ s32 __osContRamWrite(OSMesgQueue *mq, int channel, u16 address, u8 *buffer, int
|
|||
ret = CHNL_ERR(ramreadformat);
|
||||
if (ret == 0) {
|
||||
if (__osContDataCrc(buffer) != ramreadformat.datacrc) {
|
||||
ret = func_8030A5C0(mq, channel);
|
||||
ret = __osPfsGetStatus(mq, channel);
|
||||
if (ret != 0) {
|
||||
__osSiRelAccess();
|
||||
return ret;
|
||||
|
@ -64,11 +64,11 @@ void __osPackRamWriteData(int channel, u16 address, u8 *buffer) {
|
|||
|
||||
ptr = (u8 *)__osPfsPifRam.ramarray;
|
||||
|
||||
for (i = 0; i < ARRAY_COUNT(__osPfsPifRam.ramarray) + 1; i++) { // also clear pifstatus
|
||||
for (i = 0; i < ARRAY_COUNT(__osPfsPifRam.ramarray); i++) {
|
||||
__osPfsPifRam.ramarray[i] = 0;
|
||||
}
|
||||
|
||||
__osPfsPifRam.pifstatus = CONT_CMD_EXE;
|
||||
__osPfsPifRam.s.pifstatus = CONT_CMD_EXE;
|
||||
ramreadformat.dummy = CONT_CMD_NOP;
|
||||
ramreadformat.txsize = CONT_CMD_WRITE_MEMPACK_TX;
|
||||
ramreadformat.rxsize = CONT_CMD_WRITE_MEMPACK_RX;
|
||||
|
|
|
@ -7,14 +7,18 @@
|
|||
//should go somewhere else but
|
||||
#define CHNL_ERR(format) ((format.rxsize & CHNL_ERR_MASK) >> 4)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/* 0x0 */ u32 ramarray[15];
|
||||
/* 0x3C */ u32 pifstatus;
|
||||
|
||||
// Although this is not the technical struct used, unionizing this removes UB.
|
||||
// pifstatus is often referenced as ramarray[16].
|
||||
typedef union{
|
||||
struct s {
|
||||
/* 0x0 */ u32 ramarray[15];
|
||||
/* 0x3C */ u32 pifstatus;
|
||||
} s;
|
||||
u32 ramarray[16];
|
||||
} OSPifRam;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
/* 0x0 */ u8 dummy;
|
||||
/* 0x1 */ u8 txsize;
|
||||
/* 0x2 */ u8 rxsize;
|
||||
|
@ -24,8 +28,7 @@ typedef struct
|
|||
/* 0x7 */ s8 stick_y;
|
||||
} __OSContReadFormat;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
/* 0x0 */ u8 dummy;
|
||||
/* 0x1 */ u8 txsize;
|
||||
/* 0x2 */ u8 rxsize;
|
||||
|
@ -36,8 +39,7 @@ typedef struct
|
|||
/* 0x7 */ u8 dummy1;
|
||||
} __OSContRequesFormat;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
/* 0x0 */ u8 txsize;
|
||||
/* 0x1 */ u8 rxsize;
|
||||
/* 0x2 */ u8 cmd;
|
||||
|
@ -46,8 +48,7 @@ typedef struct
|
|||
/* 0x5 */ u8 status;
|
||||
} __OSContRequesFormatShort;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
/* 0x0 */ u8 dummy;
|
||||
/* 0x1 */ u8 txsize;
|
||||
/* 0x2 */ u8 rxsize;
|
||||
|
@ -66,8 +67,7 @@ typedef union {
|
|||
/* 0x0 */ u16 ipage;
|
||||
} __OSInodeUnit;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
/* 0x0 */ u32 game_code;
|
||||
/* 0x4 */ u16 company_code;
|
||||
/* 0x6 */ __OSInodeUnit start_page;
|
||||
|
@ -78,13 +78,11 @@ typedef struct
|
|||
/* 0x10 */ u8 game_name[PFS_FILE_NAME_LEN];
|
||||
} __OSDir;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
/* 0x0 */ __OSInodeUnit inode_page[128];
|
||||
} __OSInode;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
/* 0x0 */ u32 repaired;
|
||||
/* 0x4 */ u32 random;
|
||||
/* 0x8 */ u64 serial_mid;
|
||||
|
@ -96,8 +94,7 @@ typedef struct
|
|||
/* 0x1E */ u16 inverted_checksum;
|
||||
} __OSPackId;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
/* 0x0 */ u8 txsize;
|
||||
/* 0x1 */ u8 rxsize;
|
||||
/* 0x2 */ u8 cmd;
|
||||
|
@ -159,7 +156,7 @@ s32 __osPfsDeclearPage(OSPfs *pfs, __OSInode *inode, int file_size_in_pages, int
|
|||
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);
|
||||
s32 __osContRamWrite(OSMesgQueue *mq, s32 channel, u16 address, u8 *buffer, s32 force);
|
||||
void __osContGetInitData(u8 *pattern, OSContStatus *data);
|
||||
void __osPackRequestData(u8 cmd);
|
||||
void __osPfsRequestData(u8 cmd);
|
||||
|
@ -168,14 +165,14 @@ u8 __osContAddressCrc(u16 addr);
|
|||
u8 __osContDataCrc(u8 *data);
|
||||
s32 __osPfsGetStatus(OSMesgQueue *queue, int channel);
|
||||
|
||||
extern u8 _osLastSentSiCmd;
|
||||
extern u8 __osContLastCmd;
|
||||
extern OSTimer __osEepromTimer;
|
||||
extern OSMesg __osEepromTimerMsg;
|
||||
extern OSMesg __osEepromTimerMsg[4];
|
||||
extern OSMesgQueue __osEepromTimerQ;
|
||||
extern OSPifRam __osEepPifRam;
|
||||
extern OSPifRam __osContPifRam;
|
||||
extern OSPifRam __osPfsPifRam;
|
||||
extern u8 _osContNumControllers;
|
||||
extern u8 __osMaxControllers;
|
||||
|
||||
//some version of this almost certainly existed since there's plenty of times where it's used right before a return 0
|
||||
#define ERRCK(fn) \
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
#include "PR/rcp.h"
|
||||
#include "piint.h"
|
||||
#include "new_func.h"
|
||||
|
||||
void func_802F4A20(void) {
|
||||
__OSTranxInfo *sp1c;
|
||||
volatile u32 sp18;
|
||||
sp1c = &__osDiskHandle->transferInfo;
|
||||
WAIT_ON_LEO_IO_BUSY(sp18);
|
||||
IO_WRITE(LEO_BM_CTL, (LEO_BM_CTL_RESET | sp1c->bmCtlShadow));
|
||||
WAIT_ON_LEO_IO_BUSY(sp18);
|
||||
IO_WRITE(LEO_BM_CTL, sp1c->bmCtlShadow);
|
||||
func_802F4B08();
|
||||
IO_WRITE(PI_STATUS_REG, PI_STATUS_CLR_INTR);
|
||||
__OSGlobalIntMask |= 0x00100401; // TODO: fix magic numbers
|
||||
}
|
||||
|
||||
typedef struct OSEventMessageStruct_0_s {
|
||||
OSMesgQueue *queue;
|
||||
OSMesg msg;
|
||||
} OSEventMessageStruct_0;
|
||||
|
||||
extern OSEventMessageStruct_0 __osEventStateTab[16]; // should be OS_NUM_EVENTS + 1 I think
|
||||
|
||||
void func_802F4B08(void) {
|
||||
OSEventMessageStruct_0 *sp2c;
|
||||
OSMesgQueue *sp28;
|
||||
u32 sp24;
|
||||
register OSThread *s0;
|
||||
sp2c = &__osEventStateTab[OS_EVENT_PI];
|
||||
sp28 = sp2c->queue;
|
||||
if (!sp28 || sp28->validCount >= sp28->msgCount) {
|
||||
return;
|
||||
}
|
||||
sp24 = (sp28->first + sp28->validCount) % sp28->msgCount;
|
||||
sp28->msg[sp24] = sp2c->msg;
|
||||
sp28->validCount++;
|
||||
if (sp28->mtqueue->next != NULL) {
|
||||
s0 = __osPopThread(&sp28->mtqueue);
|
||||
__osEnqueueThread(&__osRunQueue, s0);
|
||||
}
|
||||
}
|
|
@ -7,11 +7,11 @@ void guRotateF(float m[4][4], float a, float x, float y, float z) {
|
|||
float sp28;
|
||||
float sp24;
|
||||
float xx, yy, zz;
|
||||
static float D_80365D70 = GU_PI / 180;
|
||||
static float dtor = GU_PI / 180;
|
||||
|
||||
guNormalize(&x, &y, &z);
|
||||
|
||||
a = a * D_80365D70;
|
||||
a = a * dtor;
|
||||
|
||||
sin_a = sinf(a);
|
||||
cos_a = cosf(a);
|
||||
|
|
|
@ -1,21 +1,13 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "PR/rdb.h"
|
||||
|
||||
typedef struct {
|
||||
u8 unk00 : 2;
|
||||
u8 pad : 4;
|
||||
u8 unk01 : 2;
|
||||
u8 unk2[3];
|
||||
} unkStruct;
|
||||
static s32 debugState = 0;
|
||||
static s32 numChars = 0;
|
||||
static s32 numCharsToReceive = 0;
|
||||
|
||||
extern u32 D_80334A44;
|
||||
extern u8 debugBuffer[0x100];
|
||||
|
||||
u32 D_80334A30 = 0;
|
||||
u32 D_80334A34 = 0;
|
||||
s32 D_80334A38 = 0;
|
||||
|
||||
extern u8 D_80365E40[0x100];
|
||||
|
||||
OSThread gInterruptedThread;
|
||||
OSThread __osThreadSave;
|
||||
|
||||
void u32_to_string(u32 i, u8 *str) {
|
||||
str[0] = (i >> 0x18) & 0xff;
|
||||
|
@ -34,29 +26,29 @@ u32 string_to_u32(u8 *str) {
|
|||
}
|
||||
|
||||
void send_packet(u8 *a0, s32 a1) {
|
||||
unkStruct sp1c;
|
||||
rdbPacket pkt;
|
||||
s32 i;
|
||||
sp1c.unk00 = 2;
|
||||
for (sp1c.unk01 = a1, i = 0; i < a1; i++) {
|
||||
sp1c.unk2[i] = a0[i];
|
||||
pkt.type = 2;
|
||||
for (pkt.length = a1, i = 0; i < a1; i++) {
|
||||
pkt.buf[i] = a0[i];
|
||||
}
|
||||
*(volatile u32 *) 0xc0000000 = *(u32 *) &sp1c;
|
||||
*(volatile u32 *) RDB_BASE_REG = *(u32 *) &pkt;
|
||||
while (!(__osGetCause() & 0x2000)) {
|
||||
;
|
||||
}
|
||||
*(volatile u32 *) 0xc000000c = 0;
|
||||
*(volatile u32 *) RDB_READ_INTR_REG = 0;
|
||||
}
|
||||
|
||||
void send(u8 *buff, s32 len) {
|
||||
s32 i;
|
||||
s32 end;
|
||||
s32 rem;
|
||||
if (!D_80334A44) {
|
||||
if (!__osRdbWriteOK) {
|
||||
while (!(__osGetCause() & 0x2000)) {
|
||||
;
|
||||
}
|
||||
*(volatile u32 *) 0xc000000c = 0;
|
||||
D_80334A44 = 1;
|
||||
*(volatile u32 *) RDB_READ_INTR_REG = 0;
|
||||
__osRdbWriteOK = 1;
|
||||
}
|
||||
i = 0;
|
||||
rem = len % 3;
|
||||
|
@ -72,62 +64,62 @@ void send(u8 *buff, s32 len) {
|
|||
void process_command_memory(void) {
|
||||
u32 sp1c;
|
||||
u32 sp18;
|
||||
sp1c = string_to_u32(&D_80365E40[1]);
|
||||
sp18 = string_to_u32(&D_80365E40[5]);
|
||||
sp1c = string_to_u32(&debugBuffer[1]);
|
||||
sp18 = string_to_u32(&debugBuffer[5]);
|
||||
send((u8 *) (uintptr_t) sp1c, sp18);
|
||||
}
|
||||
|
||||
void process_command_register(void) {
|
||||
send((u8 *) &gInterruptedThread.context, sizeof(__OSThreadContext));
|
||||
send((u8 *) &__osThreadSave.context, sizeof(__OSThreadContext));
|
||||
}
|
||||
|
||||
void kdebugserver(u32 a0) {
|
||||
u32 sp2c;
|
||||
unkStruct sp28;
|
||||
*(u32 *) &sp28 = a0;
|
||||
for (sp2c = 0; sp2c < sp28.unk01; sp2c++) {
|
||||
D_80365E40[D_80334A34] = sp28.unk2[sp2c];
|
||||
D_80334A34++;
|
||||
rdbPacket pkt;
|
||||
*(u32 *) &pkt = a0;
|
||||
for (sp2c = 0; sp2c < pkt.length; sp2c++) {
|
||||
debugBuffer[numChars] = pkt.buf[sp2c];
|
||||
numChars++;
|
||||
}
|
||||
D_80334A38 -= sp28.unk01;
|
||||
switch (D_80334A30) {
|
||||
numCharsToReceive -= pkt.length;
|
||||
switch (debugState) {
|
||||
case 0:
|
||||
switch (sp28.unk2[0]) {
|
||||
switch (pkt.buf[0]) {
|
||||
case 1:
|
||||
D_80334A30 = 1;
|
||||
D_80334A38 = 9 - sp28.unk01;
|
||||
debugState = 1;
|
||||
numCharsToReceive = 9 - pkt.length;
|
||||
break;
|
||||
case 2:
|
||||
process_command_register();
|
||||
D_80334A30 = 0;
|
||||
D_80334A34 = 0;
|
||||
D_80334A38 = 0;
|
||||
debugState = 0;
|
||||
numChars = 0;
|
||||
numCharsToReceive = 0;
|
||||
break;
|
||||
default:
|
||||
D_80334A30 = 0;
|
||||
D_80334A34 = 0;
|
||||
D_80334A38 = 0;
|
||||
debugState = 0;
|
||||
numChars = 0;
|
||||
numCharsToReceive = 0;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (D_80334A38 <= 0) {
|
||||
if (D_80365E40[0] == 1) {
|
||||
if (numCharsToReceive <= 0) {
|
||||
if (debugBuffer[0] == 1) {
|
||||
process_command_memory();
|
||||
D_80334A30 = 0;
|
||||
D_80334A34 = 0;
|
||||
D_80334A38 = 0;
|
||||
debugState = 0;
|
||||
numChars = 0;
|
||||
numCharsToReceive = 0;
|
||||
} else {
|
||||
D_80334A30 = 0;
|
||||
D_80334A34 = 0;
|
||||
D_80334A38 = 0;
|
||||
debugState = 0;
|
||||
numChars = 0;
|
||||
numCharsToReceive = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
D_80334A30 = 0;
|
||||
D_80334A34 = 0;
|
||||
D_80334A38 = 0;
|
||||
debugState = 0;
|
||||
numChars = 0;
|
||||
numCharsToReceive = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "libultra_internal.h"
|
||||
|
||||
#if defined(VERSION_JP) || defined(VERSION_US)
|
||||
u8 D_80365E40[0x100];
|
||||
u8 debugBuffer[0x100];
|
||||
#endif
|
||||
|
|
|
@ -1,31 +1,54 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "PR/rcp.h"
|
||||
#include "bstring.h"
|
||||
#include "new_func.h"
|
||||
#include "macros.h"
|
||||
#include "piint.h"
|
||||
#include "osint.h"
|
||||
|
||||
u8 leoDiskStack[OS_PIM_STACKSIZE]; // technically should have a OS_LEO_STACKSIZE or something..
|
||||
|
||||
#ifdef VERSION_SH
|
||||
|
||||
// TODO: so many magic constants :'(
|
||||
static void __osLeoResume(void);
|
||||
static void __osLeoAbnormalResume(void);
|
||||
|
||||
s32 __osLeoInterrupt() {
|
||||
s32 __osLeoInterrupt(void) {
|
||||
u32 stat;
|
||||
#ifdef VERSION_EU
|
||||
u32 pi_stat;
|
||||
#else // VERSION_SH
|
||||
volatile u32 pi_stat;
|
||||
#endif
|
||||
u32 bm_stat;
|
||||
__OSTranxInfo *info;
|
||||
__OSBlockInfo *blockInfo;
|
||||
|
||||
#ifdef VERSION_EU
|
||||
if (!osDDActive) {
|
||||
return 0;
|
||||
}
|
||||
#else // VERSION_SH
|
||||
stat = 0;
|
||||
#endif
|
||||
|
||||
info = &__osDiskHandle->transferInfo;
|
||||
blockInfo = &info->block[info->blockNum];
|
||||
pi_stat = IO_READ(PI_STATUS_REG);
|
||||
if (pi_stat & PI_STATUS_DMA_BUSY) {
|
||||
#ifdef VERSION_EU
|
||||
IO_WRITE(PI_STATUS_REG, PI_STATUS_RESET | PI_STATUS_CLR_INTR);
|
||||
WAIT_ON_LEO_IO_BUSY(pi_stat);
|
||||
stat = IO_READ(LEO_STATUS);
|
||||
if (stat & LEO_STATUS_MECHANIC_INTERRUPT) {
|
||||
WAIT_ON_LEO_IO_BUSY(pi_stat);
|
||||
IO_WRITE(LEO_BM_CTL, info->bmCtlShadow | LEO_BM_CTL_CLR_MECHANIC_INTR);
|
||||
}
|
||||
info->errStatus = LEO_ERROR_75;
|
||||
__osLeoAbnormalResume();
|
||||
#else // VERSION_SH
|
||||
__OSGlobalIntMask = __OSGlobalIntMask & ~SR_IBIT4; //cartridge interrupt
|
||||
blockInfo->errStatus = LEO_ERROR_29;
|
||||
__osLeoResume();
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
WAIT_ON_LEO_IO_BUSY(pi_stat);
|
||||
|
@ -33,35 +56,57 @@ s32 __osLeoInterrupt() {
|
|||
if (stat & LEO_STATUS_MECHANIC_INTERRUPT) {
|
||||
WAIT_ON_LEO_IO_BUSY(pi_stat);
|
||||
IO_WRITE(LEO_BM_CTL, info->bmCtlShadow | LEO_BM_CTL_CLR_MECHANIC_INTR);
|
||||
#ifdef VERSION_EU
|
||||
info->errStatus = LEO_ERROR_GOOD;
|
||||
#else // VERSION_SH
|
||||
blockInfo->errStatus = LEO_ERROR_GOOD;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef VERSION_SH
|
||||
if (info->cmdType == LEO_CMD_TYPE_2) {
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (stat & LEO_STATUS_BUFFER_MANAGER_ERROR) {
|
||||
#ifdef VERSION_EU
|
||||
info->errStatus = LEO_ERROR_3;
|
||||
__osLeoAbnormalResume();
|
||||
#else //VERSION_SH
|
||||
WAIT_ON_LEO_IO_BUSY(pi_stat);
|
||||
stat = IO_READ(LEO_STATUS);
|
||||
blockInfo->errStatus = LEO_ERROR_22;
|
||||
__osLeoResume();
|
||||
IO_WRITE(PI_STATUS_REG, PI_STATUS_CLR_INTR);
|
||||
__OSGlobalIntMask |= OS_IM_PI;
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (info->cmdType == LEO_CMD_TYPE_1) {
|
||||
if ((stat & LEO_STATUS_DATA_REQUEST) == 0) {
|
||||
if (info->sectorNum + 1 != info->transferMode * 85) {
|
||||
#ifdef VERSION_EU
|
||||
info->errStatus = LEO_ERROR_6;
|
||||
#else // VERSION_SH
|
||||
blockInfo->errStatus = LEO_ERROR_24;
|
||||
#endif
|
||||
__osLeoAbnormalResume();
|
||||
return 1;
|
||||
}
|
||||
IO_WRITE(PI_STATUS_REG, PI_STATUS_CLR_INTR);
|
||||
__OSGlobalIntMask |= OS_IM_PI;
|
||||
#ifdef VERSION_EU
|
||||
info->errStatus = LEO_ERROR_GOOD;
|
||||
#else // VERSION_SH
|
||||
blockInfo->errStatus = LEO_ERROR_GOOD;
|
||||
#endif
|
||||
__osLeoResume();
|
||||
return 1;
|
||||
}
|
||||
blockInfo->dramAddr = (void *)((u32)blockInfo->dramAddr + blockInfo->sectorSize);
|
||||
blockInfo->dramAddr = (void *) ((u32)blockInfo->dramAddr + blockInfo->sectorSize);
|
||||
info->sectorNum++;
|
||||
osEPiRawStartDma(__osDiskHandle, OS_WRITE, LEO_SECTOR_BUFF, blockInfo->dramAddr, blockInfo->sectorSize);
|
||||
return 1;
|
||||
|
@ -69,12 +114,20 @@ s32 __osLeoInterrupt() {
|
|||
if (info->cmdType == LEO_CMD_TYPE_0) {
|
||||
if (info->transferMode == LEO_SECTOR_MODE) {
|
||||
if ((s32)blockInfo->C1ErrNum + 17 < info->sectorNum) {
|
||||
#ifdef VERSION_EU
|
||||
info->errStatus = LEO_ERROR_GOOD;
|
||||
#else // VERSION_SH
|
||||
blockInfo->errStatus = LEO_ERROR_GOOD;
|
||||
#endif
|
||||
__osLeoAbnormalResume();
|
||||
return 1;
|
||||
}
|
||||
if ((stat & LEO_STATUS_DATA_REQUEST) == 0) {
|
||||
#ifdef VERSION_EU
|
||||
info->errStatus = LEO_ERROR_17;
|
||||
#else // VERSION_SH
|
||||
blockInfo->errStatus = LEO_ERROR_23;
|
||||
#endif
|
||||
__osLeoAbnormalResume();
|
||||
return 1;
|
||||
}
|
||||
|
@ -85,68 +138,107 @@ s32 __osLeoInterrupt() {
|
|||
if ((bm_stat & LEO_BM_STATUS_C1SINGLE && bm_stat & LEO_BM_STATUS_C1DOUBLE) || bm_stat & LEO_BM_STATUS_MICRO) {
|
||||
if (blockInfo->C1ErrNum > 3) {
|
||||
if (info->transferMode != LEO_SECTOR_MODE || info->sectorNum > 0x52) {
|
||||
blockInfo->errStatus = LEO_ERROR_23;
|
||||
#ifdef VERSION_EU
|
||||
info->errStatus = LEO_ERROR_17;
|
||||
#else // VERSION_SH
|
||||
blockInfo->errStatus = LEO_ERROR_23;
|
||||
#endif
|
||||
__osLeoAbnormalResume();
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
int errNum = blockInfo->C1ErrNum;
|
||||
s32 errNum = blockInfo->C1ErrNum;
|
||||
blockInfo->C1ErrSector[errNum] = info->sectorNum + 1;
|
||||
}
|
||||
blockInfo->C1ErrNum++;
|
||||
}
|
||||
|
||||
if (stat & LEO_STATUS_C2_TRANSFER) {
|
||||
if (info->sectorNum != 87) {
|
||||
#ifdef VERSION_EU
|
||||
info->errStatus = LEO_ERROR_6;
|
||||
#else // VERSION_SH
|
||||
blockInfo->errStatus = LEO_ERROR_24;
|
||||
#endif
|
||||
__osLeoAbnormalResume();
|
||||
}
|
||||
if (info->transferMode == LEO_TRACK_MODE && info->blockNum == 0) {
|
||||
info->blockNum = 1;
|
||||
info->sectorNum = -1;
|
||||
info->block[1].dramAddr = (void *)((u32)info->block[1].dramAddr - info->block[1].sectorSize);
|
||||
|
||||
#ifdef VERSION_SH
|
||||
blockInfo->errStatus = LEO_ERROR_22;
|
||||
#endif
|
||||
} else {
|
||||
IO_WRITE(PI_STATUS_REG, PI_STATUS_CLR_INTR);
|
||||
__OSGlobalIntMask |= OS_IM_PI;
|
||||
#ifdef VERSION_SH
|
||||
info->cmdType = LEO_CMD_TYPE_2;
|
||||
blockInfo->errStatus = LEO_ERROR_GOOD;
|
||||
#endif
|
||||
}
|
||||
osEPiRawStartDma(__osDiskHandle, OS_READ, LEO_C2_BUFF, blockInfo->C2Addr, blockInfo->sectorSize * 4);
|
||||
#ifdef VERSION_EU
|
||||
info->errStatus = LEO_ERROR_GOOD;
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (info->sectorNum == -1 && info->transferMode == LEO_TRACK_MODE && info->blockNum == 1) {
|
||||
__OSBlockInfo *bptr = &info->block[0];
|
||||
if (bptr->C1ErrNum == 0) {
|
||||
if (((u32 *)bptr->C2Addr)[0] | ((u32 *)bptr->C2Addr)[1] | ((u32 *)bptr->C2Addr)[2] | ((u32 *)bptr->C2Addr)[3]) {
|
||||
bptr->errStatus = LEO_ERROR_24;
|
||||
#ifdef VERSION_EU
|
||||
info->errStatus = LEO_ERROR_6;
|
||||
#else // VERSION_SH
|
||||
bptr->errStatus = LEO_ERROR_24;
|
||||
#endif
|
||||
__osLeoAbnormalResume();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
bptr->errStatus = 0;
|
||||
#ifdef VERSION_EU
|
||||
info->errStatus = LEO_ERROR_GOOD;
|
||||
#else // VERSION_SH
|
||||
bptr->errStatus = LEO_ERROR_GOOD;
|
||||
#endif
|
||||
__osLeoResume();
|
||||
}
|
||||
info->sectorNum++;
|
||||
if (stat & LEO_STATUS_DATA_REQUEST) {
|
||||
if (info->sectorNum > 0x54) {
|
||||
#ifdef VERSION_EU
|
||||
info->errStatus = LEO_ERROR_6;
|
||||
#else // VERSION_SH
|
||||
blockInfo->errStatus = LEO_ERROR_24;
|
||||
#endif
|
||||
__osLeoAbnormalResume();
|
||||
return 1;
|
||||
}
|
||||
osEPiRawStartDma(__osDiskHandle, 0, LEO_SECTOR_BUFF, blockInfo->dramAddr, blockInfo->sectorSize);
|
||||
blockInfo->errStatus = LEO_ERROR_GOOD;
|
||||
#ifdef VERSION_EU
|
||||
info->errStatus = LEO_ERROR_GOOD;
|
||||
#else // VERSION_SH
|
||||
blockInfo->errStatus = LEO_ERROR_GOOD;
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
if (info->sectorNum <= 0x54) {
|
||||
#ifdef VERSION_EU
|
||||
info->errStatus = LEO_ERROR_6;
|
||||
#else // VERSION_SH
|
||||
blockInfo->errStatus = LEO_ERROR_24;
|
||||
#endif
|
||||
__osLeoAbnormalResume();
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
#ifdef VERSION_EU
|
||||
info->errStatus = LEO_ERROR_75;
|
||||
#else // VERSION_SH
|
||||
blockInfo->errStatus = LEO_ERROR_4;
|
||||
#endif
|
||||
|
||||
__osLeoAbnormalResume();
|
||||
return 1;
|
||||
}
|
||||
|
@ -180,5 +272,3 @@ static void __osLeoResume(void) {
|
|||
__osEnqueueThread(&__osRunQueue, __osPopThread(&mq->mtqueue));
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -27,12 +27,6 @@ extern OSThread_ListHead __osThreadTail_fix;
|
|||
#define __osRunQueue __osThreadTail_fix.queue
|
||||
#define __osActiveQueue __osThreadTail_fix.tlnext
|
||||
#define __osRunningThread __osThreadTail_fix.unk10
|
||||
|
||||
// Fix for the EEPROM array.
|
||||
extern u32 D_80365E00[16];
|
||||
|
||||
// alias the last array element correctly
|
||||
#define D_80365E3C D_80365E00[15]
|
||||
#else
|
||||
// Original OSThread_ListHead definitions
|
||||
extern OSThread *__osThreadTail;
|
||||
|
@ -40,10 +34,6 @@ extern u32 D_80334894;
|
|||
extern OSThread *__osRunQueue;
|
||||
extern OSThread *__osActiveQueue;
|
||||
extern OSThread *__osRunningThread;
|
||||
|
||||
// Original EEPROM definitions
|
||||
extern u32 D_80365E00[15];
|
||||
extern u32 D_80365E3C;
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -23,7 +23,7 @@ s32 osMotorStop(OSPfs *pfs) {
|
|||
}
|
||||
__osSiGetAccess();
|
||||
|
||||
_osLastSentSiCmd = CONT_CMD_WRITE_MEMPACK;
|
||||
__osContLastCmd = CONT_CMD_WRITE_MEMPACK;
|
||||
__osSiRawStartDma(OS_WRITE, &_MotorStopData[pfs->channel]);
|
||||
osRecvMesg(pfs->queue, NULL, OS_MESG_BLOCK);
|
||||
ret = __osSiRawStartDma(OS_READ, &__osPfsPifRam);
|
||||
|
@ -59,7 +59,7 @@ s32 osMotorStart(OSPfs *pfs) {
|
|||
|
||||
__osSiGetAccess();
|
||||
|
||||
_osLastSentSiCmd = CONT_CMD_WRITE_MEMPACK;
|
||||
__osContLastCmd = CONT_CMD_WRITE_MEMPACK;
|
||||
__osSiRawStartDma(OS_WRITE, &_MotorStartData[pfs->channel]);
|
||||
osRecvMesg(pfs->queue, NULL, OS_MESG_BLOCK);
|
||||
ret = __osSiRawStartDma(OS_READ, &__osPfsPifRam);
|
||||
|
@ -86,11 +86,11 @@ void _MakeMotorData(int channel, u16 address, u8 *buffer, OSPifRam *mdata) {
|
|||
__OSContRamReadFormat ramreadformat;
|
||||
int i;
|
||||
|
||||
ptr = (u8 *) mdata->ramarray;
|
||||
for (i = 0; i < ARRAY_COUNT(mdata->ramarray); i++) {
|
||||
mdata->ramarray[i] = 0;
|
||||
ptr = (u8 *) mdata->s.ramarray;
|
||||
for (i = 0; i < ARRAY_COUNT(mdata->s.ramarray); i++) {
|
||||
mdata->s.ramarray[i] = 0;
|
||||
}
|
||||
mdata->pifstatus = CONT_CMD_EXE;
|
||||
mdata->s.pifstatus = CONT_CMD_EXE;
|
||||
ramreadformat.dummy = CONT_CMD_NOP;
|
||||
ramreadformat.txsize = CONT_CMD_WRITE_MEMPACK_TX;
|
||||
ramreadformat.rxsize = CONT_CMD_WRITE_MEMPACK_RX;
|
||||
|
|
|
@ -5,18 +5,10 @@
|
|||
|
||||
extern u32 osDDActive;
|
||||
|
||||
extern OSPiHandle *__osDiskHandle; //possibly __osPiTable
|
||||
|
||||
extern /*volatile*/ u32 __OSGlobalIntMask;
|
||||
s32 osEPiRawStartDma(OSPiHandle *arg0, s32 dir, u32 cart_addr, void *dram_addr, u32 size);
|
||||
void func_802F4B08(void);
|
||||
void func_802F4A20(void);
|
||||
void __osResetGlobalIntMask(u32 mask);
|
||||
void __osEPiRawWriteIo(OSPiHandle*, u32, u32);
|
||||
void func_802F71F0(void);
|
||||
void osYieldThread(void);
|
||||
#ifdef VERSION_SH
|
||||
void __osSetGlobalIntMask(s32 arg0);
|
||||
s32 __osEPiRawReadIo(OSPiHandle *arg0, u32 devAddr, u32 *arg2);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "osContInternal.h"
|
||||
#include "PR/os.h"
|
||||
#include "controller.h"
|
||||
|
||||
void __osPackRequestData(u8);
|
||||
void __osContGetInitData(u8 *, OSContStatus *);
|
||||
|
||||
u32 _osContInitialized = 0; // probably initialized
|
||||
|
||||
extern u64 osClockRate;
|
||||
|
||||
// these probably belong in EEPROMlongread or something
|
||||
u8 _osLastSentSiCmd;
|
||||
u8 _osContNumControllers;
|
||||
OSTimer D_80365D28;
|
||||
OSMesgQueue _osContMesgQueue;
|
||||
OSMesg _osContMesgBuff[4];
|
||||
u8 __osContLastCmd;
|
||||
u8 __osMaxControllers;
|
||||
OSTimer __osEepromTimer;
|
||||
OSMesgQueue __osEepromTimerQ;
|
||||
OSMesg __osEepromTimerMsg[4];
|
||||
s32 osContInit(OSMesgQueue *mq, u8 *bitpattern, OSContStatus *status) {
|
||||
OSMesg mesg;
|
||||
u32 ret = 0;
|
||||
|
@ -31,7 +31,7 @@ s32 osContInit(OSMesgQueue *mq, u8 *bitpattern, OSContStatus *status) {
|
|||
osSetTimer(&timer, 500000 * osClockRate / 1000000 - currentTime, 0, &timerMesgQueue, &mesg);
|
||||
osRecvMesg(&timerMesgQueue, &mesg, OS_MESG_BLOCK);
|
||||
}
|
||||
_osContNumControllers = 4; // TODO: figure out what it means
|
||||
__osMaxControllers = MAXCONTROLLERS;
|
||||
#if defined(VERSION_EU) || defined(VERSION_SH)
|
||||
__osPackRequestData(0);
|
||||
#else
|
||||
|
@ -43,12 +43,12 @@ s32 osContInit(OSMesgQueue *mq, u8 *bitpattern, OSContStatus *status) {
|
|||
osRecvMesg(mq, &mesg, OS_MESG_BLOCK);
|
||||
__osContGetInitData(bitpattern, status);
|
||||
#if defined(VERSION_EU) || defined(VERSION_SH)
|
||||
_osLastSentSiCmd = 0;
|
||||
__osContLastCmd = CONT_CMD_REQUEST_STATUS;
|
||||
#else
|
||||
_osLastSentSiCmd = 255;
|
||||
__osContLastCmd = CONT_CMD_RESET;
|
||||
#endif
|
||||
__osSiCreateAccessQueue();
|
||||
osCreateMesgQueue(&_osContMesgQueue, _osContMesgBuff, 1);
|
||||
osCreateMesgQueue(&__osEepromTimerQ, __osEepromTimerMsg, 1);
|
||||
return ret;
|
||||
}
|
||||
void __osContGetInitData(u8 *bitpattern, OSContStatus *status) {
|
||||
|
@ -59,7 +59,7 @@ void __osContGetInitData(u8 *bitpattern, OSContStatus *status) {
|
|||
|
||||
sp7 = 0;
|
||||
cmdBufPtr = &(_osContCmdBuf[0].request);
|
||||
for (i = 0; i < _osContNumControllers; i++, cmdBufPtr++, status++) {
|
||||
for (i = 0; i < __osMaxControllers; i++, cmdBufPtr++, status++) {
|
||||
response = *(OSContPackedRequest *) cmdBufPtr;
|
||||
status->errnum = (response.rxLen & 0xc0) >> 4;
|
||||
if (status->errnum == 0) {
|
||||
|
@ -92,7 +92,7 @@ void __osPackRequestData(u8 command) {
|
|||
request.data3 = 255;
|
||||
request.data4 = 255;
|
||||
|
||||
for (i = 0; i < _osContNumControllers; i++) {
|
||||
for (i = 0; i < __osMaxControllers; i++) {
|
||||
*cmdBufPtr++ = request;
|
||||
}
|
||||
cmdBufPtr->padOrEnd = 254;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "osContInternal.h"
|
||||
#include <macros.h>
|
||||
#include "controller.h"
|
||||
|
||||
#ifndef AVOID_UB
|
||||
ALIGNED8 OSContPackedStruct _osContCmdBuf[7];
|
||||
|
@ -11,15 +12,15 @@ u32 _osContPifCtrl;
|
|||
ALIGNED8 OSContPackedStruct _osContCmdBuf[8];
|
||||
#endif
|
||||
|
||||
extern u8 _osLastSentSiCmd;
|
||||
extern u8 _osContNumControllers;
|
||||
extern u8 __osContLastCmd;
|
||||
extern u8 __osMaxControllers;
|
||||
|
||||
void __osPackReadData(void);
|
||||
s32 osContStartReadData(OSMesgQueue *mesg) {
|
||||
s32 ret = 0;
|
||||
s32 i;
|
||||
__osSiGetAccess();
|
||||
if (_osLastSentSiCmd != 1) {
|
||||
if (__osContLastCmd != CONT_CMD_READ_BUTTON) {
|
||||
__osPackReadData();
|
||||
ret = __osSiRawStartDma(OS_WRITE, _osContCmdBuf);
|
||||
osRecvMesg(mesg, NULL, OS_MESG_BLOCK);
|
||||
|
@ -30,7 +31,7 @@ s32 osContStartReadData(OSMesgQueue *mesg) {
|
|||
|
||||
_osContPifCtrl = 0;
|
||||
ret = __osSiRawStartDma(OS_READ, _osContCmdBuf);
|
||||
_osLastSentSiCmd = 1;
|
||||
__osContLastCmd = CONT_CMD_READ_BUTTON;
|
||||
__osSiRelAccess();
|
||||
return ret;
|
||||
}
|
||||
|
@ -39,7 +40,7 @@ void osContGetReadData(OSContPad *pad) {
|
|||
OSContPackedRead response;
|
||||
s32 i;
|
||||
cmdBufPtr = &_osContCmdBuf[0].read;
|
||||
for (i = 0; i < _osContNumControllers; i++, cmdBufPtr++, pad++) {
|
||||
for (i = 0; i < __osMaxControllers; i++, cmdBufPtr++, pad++) {
|
||||
response = *cmdBufPtr;
|
||||
pad->errnum = (response.rxLen & 0xc0) >> 4;
|
||||
if (pad->errnum == 0) {
|
||||
|
@ -66,7 +67,7 @@ void __osPackReadData() {
|
|||
request.button = 65535;
|
||||
request.rawStickX = -1;
|
||||
request.rawStickY = -1;
|
||||
for (i = 0; i < _osContNumControllers; i++) {
|
||||
for (i = 0; i < __osMaxControllers; i++) {
|
||||
*cmdBufPtr++ = request;
|
||||
}
|
||||
cmdBufPtr->padOrEnd = 254;
|
||||
|
|
|
@ -1,23 +1,20 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "PR/os.h"
|
||||
#include "piint.h"
|
||||
|
||||
#define OS_PI_MGR_MESG_BUFF_SIZE 1
|
||||
|
||||
#ifdef VERSION_SH // TODO: In libreultra this is in an include
|
||||
extern OSPiHandle *CartRomHandle;
|
||||
extern OSPiHandle *LeoDiskHandle;
|
||||
#endif
|
||||
|
||||
OSMgrArgs __osPiDevMgr = { 0 };
|
||||
OSDevMgr __osPiDevMgr = { 0 };
|
||||
#if defined(VERSION_EU) || defined(VERSION_SH)
|
||||
OSPiHandle *__osPiTable = NULL;
|
||||
#endif
|
||||
#ifdef VERSION_SH
|
||||
OSPiHandle **__osCurrentHandle[2] = { &CartRomHandle, &LeoDiskHandle };
|
||||
OSPiHandle *__osCurrentHandle[2] = { &CartRomHandle, &LeoDiskHandle };
|
||||
#endif
|
||||
OSThread piMgrThread;
|
||||
u32 piMgrStack[0x400]; // stack bottom
|
||||
OSMesgQueue __osPiMesgQueue;
|
||||
OSMesg piMgrMesgBuff[OS_PI_MGR_MESG_BUFF_SIZE + 1];
|
||||
OSMesgQueue piEventQueue;
|
||||
OSMesg piEventBuf[OS_PI_MGR_MESG_BUFF_SIZE + 1];
|
||||
|
||||
extern u32 gOsPiAccessQueueCreated;
|
||||
extern OSMesgQueue gOsPiMessageQueue;
|
||||
|
@ -28,13 +25,13 @@ void osCreatePiManager(OSPri pri, OSMesgQueue *cmdQ, OSMesg *cmdBuf, s32 cmdMsgC
|
|||
OSPri newPri;
|
||||
OSPri currentPri;
|
||||
|
||||
if (!__osPiDevMgr.initialized) {
|
||||
if (!__osPiDevMgr.active) {
|
||||
osCreateMesgQueue(cmdQ, cmdBuf, cmdMsgCnt);
|
||||
osCreateMesgQueue(&__osPiMesgQueue, &piMgrMesgBuff[0], OS_PI_MGR_MESG_BUFF_SIZE);
|
||||
osCreateMesgQueue(&piEventQueue, &piEventBuf[0], OS_PI_MGR_MESG_BUFF_SIZE);
|
||||
if (!gOsPiAccessQueueCreated) {
|
||||
__osPiCreateAccessQueue();
|
||||
} // what is this constant geez
|
||||
osSetEventMesg(OS_EVENT_PI, &__osPiMesgQueue, (void *) 0x22222222);
|
||||
osSetEventMesg(OS_EVENT_PI, &piEventQueue, (void *) 0x22222222);
|
||||
newPri = -1;
|
||||
currentPri = osGetThreadPri(NULL);
|
||||
if (currentPri < pri) {
|
||||
|
@ -42,14 +39,14 @@ void osCreatePiManager(OSPri pri, OSMesgQueue *cmdQ, OSMesg *cmdBuf, s32 cmdMsgC
|
|||
osSetThreadPri(NULL, pri);
|
||||
}
|
||||
int_disabled = __osDisableInt();
|
||||
__osPiDevMgr.initialized = TRUE;
|
||||
__osPiDevMgr.mgrThread = &piMgrThread;
|
||||
__osPiDevMgr.active = TRUE;
|
||||
__osPiDevMgr.thread = &piMgrThread;
|
||||
__osPiDevMgr.cmdQueue = cmdQ;
|
||||
__osPiDevMgr.eventQueue = &__osPiMesgQueue;
|
||||
__osPiDevMgr.accessQueue = &gOsPiMessageQueue;
|
||||
__osPiDevMgr.dma_func = osPiRawStartDma;
|
||||
__osPiDevMgr.evtQueue = &piEventQueue;
|
||||
__osPiDevMgr.acsQueue = &gOsPiMessageQueue;
|
||||
__osPiDevMgr.dma = osPiRawStartDma;
|
||||
#if defined(VERSION_EU) || defined(VERSION_SH)
|
||||
__osPiDevMgr.edma_func = osEPiRawStartDma;
|
||||
__osPiDevMgr.edma = osEPiRawStartDma;
|
||||
#endif
|
||||
osCreateThread(&piMgrThread, 0, __osDevMgrMain, (void *) &__osPiDevMgr, &piMgrStack[0x400], pri);
|
||||
osStartThread(&piMgrThread);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "PR/rcp.h"
|
||||
#include "piint.h"
|
||||
|
||||
s32 __osEPiRawReadIo(OSPiHandle *pihandle, u32 devAddr, u32 *data) {
|
||||
s32 osEPiRawReadIo(OSPiHandle *pihandle, u32 devAddr, u32 *data) {
|
||||
register s32 stat;
|
||||
|
||||
WAIT_ON_IO_BUSY(stat);
|
|
@ -2,7 +2,7 @@
|
|||
#include "PR/rcp.h"
|
||||
#include "piint.h"
|
||||
|
||||
s32 __osEPiRawWriteIo(OSPiHandle *pihandle, u32 devAddr, u32 data) {
|
||||
s32 osEPiRawWriteIo(OSPiHandle *pihandle, u32 devAddr, u32 data) {
|
||||
register u32 stat;
|
||||
|
||||
WAIT_ON_IO_BUSY(stat);
|
|
@ -1,13 +1,7 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "controller.h"
|
||||
|
||||
extern u64 osClockRate;
|
||||
extern u8 D_80365D20;
|
||||
extern u8 _osContNumControllers;
|
||||
extern OSTimer D_80365D28; // not sure what this is yet
|
||||
extern OSMesgQueue _osContMesgQueue;
|
||||
extern OSMesg _osContMesgBuff[4];
|
||||
|
||||
s32 osEepromLongRead(OSMesgQueue *mq, u8 address, u8 *buffer, int nbytes) {
|
||||
s32 osEepromLongRead(OSMesgQueue *mq, u8 address, u8 *buffer, s32 nbytes) {
|
||||
s32 status = 0;
|
||||
if (address > 0x40) {
|
||||
return -1;
|
||||
|
@ -22,8 +16,8 @@ s32 osEepromLongRead(OSMesgQueue *mq, u8 address, u8 *buffer, int nbytes) {
|
|||
nbytes -= EEPROM_BLOCK_SIZE;
|
||||
address++;
|
||||
buffer += EEPROM_BLOCK_SIZE;
|
||||
osSetTimer(&D_80365D28, 12000 * osClockRate / 1000000, 0, &_osContMesgQueue, _osContMesgBuff);
|
||||
osRecvMesg(&_osContMesgQueue, NULL, OS_MESG_BLOCK);
|
||||
osSetTimer(&__osEepromTimer, 12000 * osClockRate / 1000000, 0, &__osEepromTimerQ, __osEepromTimerMsg);
|
||||
osRecvMesg(&__osEepromTimerQ, NULL, OS_MESG_BLOCK);
|
||||
}
|
||||
|
||||
return status;
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
#include "libultra_internal.h"
|
||||
|
||||
extern u64 osClockRate;
|
||||
extern u8 D_80365D20;
|
||||
extern u8 _osContNumControllers;
|
||||
extern OSTimer D_80365D28;
|
||||
extern OSMesgQueue _osContMesgQueue;
|
||||
extern OSMesg _osContMesgBuff[4];
|
||||
// exactly the same as osEepromLongRead except for osEepromWrite call
|
||||
#include "controller.h"
|
||||
|
||||
s32 osEepromLongWrite(OSMesgQueue *mq, u8 address, u8 *buffer, int nbytes) {
|
||||
s32 result = 0;
|
||||
|
@ -23,8 +16,8 @@ s32 osEepromLongWrite(OSMesgQueue *mq, u8 address, u8 *buffer, int nbytes) {
|
|||
nbytes -= EEPROM_BLOCK_SIZE;
|
||||
address++;
|
||||
buffer += EEPROM_BLOCK_SIZE;
|
||||
osSetTimer(&D_80365D28, 12000 * osClockRate / 1000000, 0, &_osContMesgQueue, _osContMesgBuff);
|
||||
osRecvMesg(&_osContMesgQueue, NULL, OS_MESG_BLOCK);
|
||||
osSetTimer(&__osEepromTimer, 12000 * osClockRate / 1000000, 0, &__osEepromTimerQ, __osEepromTimerMsg);
|
||||
osRecvMesg(&__osEepromTimerQ, NULL, OS_MESG_BLOCK);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
@ -1,102 +1,84 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "controller.h"
|
||||
#include "macros.h"
|
||||
|
||||
extern u8 _osLastSentSiCmd;
|
||||
|
||||
typedef struct {
|
||||
u16 unk00;
|
||||
u8 unk02;
|
||||
u8 unk03;
|
||||
} unkStruct;
|
||||
typedef struct {
|
||||
u8 unk00;
|
||||
u8 unk01;
|
||||
u8 unk02;
|
||||
u8 unk03;
|
||||
u8 unk04;
|
||||
u8 unk05;
|
||||
u8 unk06;
|
||||
u8 unk07;
|
||||
} unkStruct3;
|
||||
|
||||
typedef struct {
|
||||
u8 unk00;
|
||||
u8 unk01;
|
||||
u8 unk02;
|
||||
u8 unk03;
|
||||
unkStruct3 unk04;
|
||||
} unkStruct2;
|
||||
|
||||
s32 __osEepStatus(OSMesgQueue *, unkStruct *);
|
||||
s32 __osPackEepReadData(u8);
|
||||
void __osPackEepReadData(u8);
|
||||
|
||||
s32 osEepromRead(OSMesgQueue *mq, u8 address, u8 *buffer) {
|
||||
s32 sp34;
|
||||
s32 sp30;
|
||||
u8 *sp2c;
|
||||
unkStruct sp28;
|
||||
unkStruct2 sp20;
|
||||
sp34 = 0;
|
||||
sp30 = 0;
|
||||
sp2c = (u8 *) &D_80365E00;
|
||||
if (address > 0x40) {
|
||||
s32 ret= 0;
|
||||
s32 i = 0;
|
||||
u8 *ptr = (u8 *) &__osEepPifRam.ramarray;
|
||||
OSContStatus sdata;
|
||||
__OSContEepromFormat eepromformat;
|
||||
|
||||
if (address > EEPROM_MAXBLOCKS) {
|
||||
return -1;
|
||||
}
|
||||
__osSiGetAccess();
|
||||
sp34 = __osEepStatus(mq, &sp28);
|
||||
if (sp34 != 0 || sp28.unk00 != 0x8000) {
|
||||
|
||||
return 8;
|
||||
__osSiGetAccess();
|
||||
ret = __osEepStatus(mq, &sdata);
|
||||
if (ret != 0 || sdata.type != CONT_EEPROM) {
|
||||
|
||||
return CONT_NO_RESPONSE_ERROR;
|
||||
}
|
||||
while (sp28.unk02 & 0x80) {
|
||||
__osEepStatus(mq, &sp28);
|
||||
|
||||
while (sdata.status & CONT_EEPROM_BUSY) {
|
||||
__osEepStatus(mq, &sdata);
|
||||
}
|
||||
__osPackEepReadData(address);
|
||||
sp34 = __osSiRawStartDma(OS_WRITE, &D_80365E00);
|
||||
|
||||
ret = __osSiRawStartDma(OS_WRITE, &__osEepPifRam);
|
||||
osRecvMesg(mq, NULL, OS_MESG_BLOCK);
|
||||
for (sp30 = 0; sp30 < 0x10; sp30++) {
|
||||
(D_80365E00)[sp30] = 255;
|
||||
|
||||
for (i = 0; i < ARRAY_COUNT(__osEepPifRam.ramarray); i++) {
|
||||
__osEepPifRam.ramarray[i] = CONT_CMD_NOP;
|
||||
}
|
||||
D_80365E3C = 0;
|
||||
sp34 = __osSiRawStartDma(OS_READ, D_80365E00);
|
||||
_osLastSentSiCmd = 4;
|
||||
__osEepPifRam.s.pifstatus = 0;
|
||||
|
||||
ret = __osSiRawStartDma(OS_READ, &__osEepPifRam);
|
||||
__osContLastCmd = CONT_CMD_READ_EEPROM;
|
||||
osRecvMesg(mq, NULL, OS_MESG_BLOCK);
|
||||
for (sp30 = 0; sp30 < 4; sp30++) {
|
||||
sp2c++;
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
ptr++;
|
||||
}
|
||||
sp20 = *(unkStruct2 *) sp2c;
|
||||
sp34 = (sp20.unk01 & 0xc0) >> 4;
|
||||
if (sp34 == 0) {
|
||||
for (sp30 = 0; sp30 < 8; sp30++) {
|
||||
*buffer++ = ((u8 *) &sp20.unk04)[sp30];
|
||||
|
||||
eepromformat = *(__OSContEepromFormat *) ptr;
|
||||
ret = CHNL_ERR(eepromformat);
|
||||
|
||||
if (ret == 0) {
|
||||
for (i = 0; i < 8; i++) {
|
||||
*buffer++ = eepromformat.data[i];
|
||||
}
|
||||
}
|
||||
|
||||
__osSiRelAccess();
|
||||
return sp34;
|
||||
return ret;
|
||||
}
|
||||
|
||||
s32 __osPackEepReadData(u8 address) {
|
||||
u8 *sp14;
|
||||
unkStruct2 sp8;
|
||||
s32 sp4;
|
||||
sp14 = (u8 *) &D_80365E00;
|
||||
for (sp4 = 0; sp4 < 0x10; sp4++) {
|
||||
D_80365E00[sp4] = 255;
|
||||
void __osPackEepReadData(u8 address) {
|
||||
u8 *ptr = (u8 *) &__osEepPifRam.ramarray;
|
||||
__OSContEepromFormat eepromformat;
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < ARRAY_COUNT(__osEepPifRam.ramarray); i++) {
|
||||
__osEepPifRam.ramarray[i] = CONT_CMD_NOP;
|
||||
}
|
||||
D_80365E3C = 1;
|
||||
sp8.unk00 = 2;
|
||||
sp8.unk01 = 8;
|
||||
sp8.unk02 = 4;
|
||||
sp8.unk03 = address;
|
||||
for (sp4 = 0; sp4 < 8; sp4++) {
|
||||
((u8 *) &sp8.unk04)[sp4] = 0;
|
||||
__osEepPifRam.s.pifstatus = CONT_CMD_EXE;
|
||||
|
||||
eepromformat.txsize = CONT_CMD_READ_EEPROM_TX;
|
||||
eepromformat.rxsize = CONT_CMD_READ_EEPROM_RX;
|
||||
eepromformat.cmd = CONT_CMD_READ_EEPROM;
|
||||
eepromformat.address = address;
|
||||
for (i = 0; i < ARRAY_COUNT(eepromformat.data); i++) {
|
||||
eepromformat.data[i] = 0;
|
||||
}
|
||||
for (sp4 = 0; sp4 < 4; sp4++) {
|
||||
*sp14++ = 0;
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
*ptr++ = 0;
|
||||
}
|
||||
*(unkStruct2 *) sp14 = sp8;
|
||||
sp14 += 0xc;
|
||||
*sp14 = 254;
|
||||
#ifdef AVOID_UB
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
*(__OSContEepromFormat *) ptr = eepromformat;
|
||||
ptr += sizeof(__OSContEepromFormat);
|
||||
*ptr = CONT_CMD_END;
|
||||
}
|
||||
|
|
|
@ -1,170 +1,136 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "osContInternal.h"
|
||||
#include "controller.h"
|
||||
|
||||
#ifndef AVOID_UB
|
||||
ALIGNED8 u32 D_80365E00[15];
|
||||
u32 D_80365E3C;
|
||||
#else
|
||||
// Certain code accesses the 16th element (D_80365E3C) in this array, making a seperate
|
||||
// definition UB when gcc rearranges those.
|
||||
ALIGNED8 u32 D_80365E00[16];
|
||||
#endif
|
||||
extern u8 _osLastSentSiCmd;
|
||||
OSPifRam __osEepPifRam;
|
||||
|
||||
typedef struct {
|
||||
u16 unk00;
|
||||
u8 unk02;
|
||||
u8 unk03;
|
||||
} unkStruct;
|
||||
typedef struct {
|
||||
u8 unk00;
|
||||
u8 unk01;
|
||||
u8 unk02;
|
||||
u8 unk03;
|
||||
u8 unk04;
|
||||
u8 unk05;
|
||||
u8 unk06;
|
||||
u8 unk07;
|
||||
} unkStruct3;
|
||||
|
||||
typedef struct {
|
||||
u8 unk00;
|
||||
u8 unk01;
|
||||
u8 unk02;
|
||||
u8 unk03;
|
||||
unkStruct3 unk04;
|
||||
} unkStruct2;
|
||||
|
||||
s32 __osEepStatus(OSMesgQueue *, unkStruct *);
|
||||
s32 __osPackEepWriteData(u8, u8 *);
|
||||
void __osPackEepWriteData(u8, u8 *);
|
||||
|
||||
s32 osEepromWrite(OSMesgQueue *mq, u8 address, u8 *buffer) {
|
||||
s32 sp34;
|
||||
s32 sp30;
|
||||
u8 *sp2c;
|
||||
unkStruct2 sp20;
|
||||
unkStruct sp1c;
|
||||
sp34 = 0;
|
||||
sp2c = (u8 *) &D_80365E00;
|
||||
s32 ret = 0;
|
||||
s32 i;
|
||||
u8 *ptr = (u8 *) &__osEepPifRam.ramarray;
|
||||
__OSContEepromFormat eepromformat;
|
||||
OSContStatus sdata;
|
||||
|
||||
if (address > 0x40) {
|
||||
if (address > EEPROM_MAXBLOCKS) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
__osSiGetAccess();
|
||||
sp34 = __osEepStatus(mq, &sp1c);
|
||||
ret = __osEepStatus(mq, &sdata);
|
||||
|
||||
if (sp34 != 0 || sp1c.unk00 != 0x8000) {
|
||||
return 8;
|
||||
if (ret != 0 || sdata.type != CONT_EEPROM) {
|
||||
return CONT_NO_RESPONSE_ERROR;
|
||||
}
|
||||
|
||||
while (sp1c.unk02 & 0x80) {
|
||||
__osEepStatus(mq, &sp1c);
|
||||
while (sdata.status & CONT_EEPROM_BUSY) {
|
||||
__osEepStatus(mq, &sdata);
|
||||
}
|
||||
|
||||
__osPackEepWriteData(address, buffer);
|
||||
|
||||
sp34 = __osSiRawStartDma(OS_WRITE, &D_80365E00);
|
||||
ret = __osSiRawStartDma(OS_WRITE, &__osEepPifRam);
|
||||
osRecvMesg(mq, NULL, OS_MESG_BLOCK);
|
||||
|
||||
for (sp30 = 0; sp30 < 0x10; sp30++) {
|
||||
(D_80365E00)[sp30] = 255;
|
||||
for (i = 0; i < ARRAY_COUNT(__osEepPifRam.ramarray); i++) {
|
||||
__osEepPifRam.ramarray[i] = CONT_CMD_NOP;
|
||||
}
|
||||
|
||||
D_80365E3C = 0;
|
||||
sp34 = __osSiRawStartDma(OS_READ, D_80365E00);
|
||||
_osLastSentSiCmd = 5;
|
||||
__osEepPifRam.s.pifstatus = 0;
|
||||
ret = __osSiRawStartDma(OS_READ, &__osEepPifRam);
|
||||
__osContLastCmd = CONT_CMD_WRITE_EEPROM;
|
||||
osRecvMesg(mq, NULL, OS_MESG_BLOCK);
|
||||
|
||||
for (sp30 = 0; sp30 < 4; sp30++) {
|
||||
sp2c++;
|
||||
for (i = 0; i < 4; i++) {
|
||||
ptr++;
|
||||
}
|
||||
|
||||
sp20 = *(unkStruct2 *) sp2c;
|
||||
sp34 = (sp20.unk01 & 0xc0) >> 4;
|
||||
eepromformat = *(__OSContEepromFormat *) ptr;
|
||||
ret = CHNL_ERR(eepromformat);
|
||||
__osSiRelAccess();
|
||||
return sp34;
|
||||
return ret;
|
||||
}
|
||||
|
||||
s32 __osPackEepWriteData(u8 address, u8 *buffer) {
|
||||
u8 *sp14;
|
||||
unkStruct2 sp8;
|
||||
s32 sp4;
|
||||
sp14 = (u8 *) &D_80365E00;
|
||||
for (sp4 = 0; sp4 < 0x10; sp4++) {
|
||||
D_80365E00[sp4] = 255;
|
||||
void __osPackEepWriteData(u8 address, u8 *buffer) {
|
||||
u8 *ptr = (u8 *) &__osEepPifRam.ramarray;
|
||||
__OSContEepromFormat eepromformat;
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < ARRAY_COUNT(__osEepPifRam.ramarray); i++) {
|
||||
__osEepPifRam.ramarray[i] = CONT_CMD_NOP;
|
||||
}
|
||||
D_80365E3C = 1;
|
||||
sp8.unk00 = 10;
|
||||
sp8.unk01 = 1;
|
||||
sp8.unk02 = 5;
|
||||
sp8.unk03 = address;
|
||||
for (sp4 = 0; sp4 < 8; sp4++) {
|
||||
((u8 *) &sp8.unk04)[sp4] = *buffer++;
|
||||
__osEepPifRam.s.pifstatus = CONT_CMD_EXE;
|
||||
|
||||
eepromformat.txsize = CONT_CMD_WRITE_EEPROM_TX;
|
||||
eepromformat.rxsize = CONT_CMD_WRITE_EEPROM_RX;
|
||||
eepromformat.cmd = CONT_CMD_WRITE_EEPROM;
|
||||
eepromformat.address = address;
|
||||
|
||||
for (i = 0; i < ARRAY_COUNT(eepromformat.data); i++) {
|
||||
eepromformat.data[i] = *buffer++;
|
||||
}
|
||||
for (sp4 = 0; sp4 < 4; sp4++) {
|
||||
*sp14++ = 0;
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
*ptr++ = 0;
|
||||
}
|
||||
*(unkStruct2 *) sp14 = sp8;
|
||||
sp14 += 0xc;
|
||||
*sp14 = 254;
|
||||
#ifdef AVOID_UB
|
||||
return 0;
|
||||
#endif
|
||||
*(__OSContEepromFormat *) ptr = eepromformat;
|
||||
ptr += sizeof(__OSContEepromFormat);
|
||||
*ptr = CONT_CMD_END;
|
||||
}
|
||||
|
||||
s32 __osEepStatus(OSMesgQueue *a0, unkStruct *a1) {
|
||||
u32 sp2c = 0;
|
||||
s32 sp28;
|
||||
u8 *sp24 = (u8 *) D_80365E00;
|
||||
unkStruct3 sp1c;
|
||||
s32 __osEepStatus(OSMesgQueue *mq, OSContStatus *data) {
|
||||
u32 ret = 0;
|
||||
s32 i;
|
||||
u8 *ptr = (u8 *) __osEepPifRam.ramarray;
|
||||
__OSContRequesFormat requestformat;
|
||||
|
||||
for (sp28 = 0; sp28 < 0x10; sp28++) {
|
||||
D_80365E00[sp28] = 0;
|
||||
for (i = 0; i < ARRAY_COUNT(__osEepPifRam.ramarray); i++) {
|
||||
__osEepPifRam.ramarray[i] = 0;
|
||||
}
|
||||
__osEepPifRam.s.pifstatus = CONT_CMD_EXE;
|
||||
|
||||
ptr = (u8 *) __osEepPifRam.ramarray;
|
||||
for (i = 0; i < 4; i++) {
|
||||
*ptr++ = 0;
|
||||
}
|
||||
|
||||
D_80365E3C = 1;
|
||||
sp24 = (u8 *) D_80365E00;
|
||||
for (sp28 = 0; sp28 < 4; sp28++) {
|
||||
*sp24++ = 0;
|
||||
requestformat.dummy = CONT_CMD_NOP;
|
||||
requestformat.txsize = CONT_CMD_REQUEST_STATUS_TX;
|
||||
requestformat.rxsize = CONT_CMD_REQUEST_STATUS_RX;
|
||||
requestformat.cmd = CONT_CMD_REQUEST_STATUS;
|
||||
requestformat.typeh = CONT_CMD_NOP;
|
||||
requestformat.typel = CONT_CMD_NOP;
|
||||
requestformat.status = CONT_CMD_NOP;
|
||||
requestformat.dummy1 = CONT_CMD_NOP;
|
||||
*(__OSContRequesFormat *) ptr = requestformat;
|
||||
|
||||
ptr += sizeof(__OSContRequesFormat);
|
||||
*ptr = CONT_CMD_END;
|
||||
|
||||
ret = __osSiRawStartDma(OS_WRITE, &__osEepPifRam);
|
||||
osRecvMesg(mq, NULL, OS_MESG_BLOCK);
|
||||
|
||||
__osContLastCmd = CONT_CMD_WRITE_EEPROM;
|
||||
|
||||
ret = __osSiRawStartDma(OS_READ, &__osEepPifRam);
|
||||
osRecvMesg(mq, NULL, OS_MESG_BLOCK);
|
||||
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
sp1c.unk00 = 255;
|
||||
sp1c.unk01 = 1;
|
||||
sp1c.unk02 = 3;
|
||||
sp1c.unk03 = 0;
|
||||
sp1c.unk04 = 255;
|
||||
sp1c.unk05 = 255;
|
||||
sp1c.unk06 = 255;
|
||||
sp1c.unk07 = 255;
|
||||
*(unkStruct3 *) sp24 = sp1c;
|
||||
|
||||
sp24 += 8;
|
||||
sp24[0] = 254;
|
||||
|
||||
sp2c = __osSiRawStartDma(OS_WRITE, D_80365E00);
|
||||
osRecvMesg(a0, NULL, OS_MESG_BLOCK);
|
||||
|
||||
_osLastSentSiCmd = 5;
|
||||
|
||||
sp2c = __osSiRawStartDma(OS_READ, D_80365E00);
|
||||
osRecvMesg(a0, NULL, OS_MESG_BLOCK);
|
||||
|
||||
if (sp2c != 0) {
|
||||
return sp2c;
|
||||
ptr = (u8 *) __osEepPifRam.ramarray;
|
||||
for (i = 0; i < 4; i++) {
|
||||
*ptr++ = 0;
|
||||
}
|
||||
|
||||
sp24 = (u8 *) D_80365E00;
|
||||
for (sp28 = 0; sp28 < 4; sp28++) {
|
||||
*sp24++ = 0;
|
||||
}
|
||||
|
||||
sp1c = *(unkStruct3 *) sp24;
|
||||
a1->unk03 = (sp1c.unk02 & 0xc0) >> 4;
|
||||
a1->unk00 = (sp1c.unk05 << 8) | sp1c.unk04;
|
||||
a1->unk02 = sp1c.unk06;
|
||||
if (a1->unk03 != 0) {
|
||||
return a1->unk03;
|
||||
requestformat = *(__OSContRequesFormat *) ptr;
|
||||
data->errnum = CHNL_ERR(requestformat);
|
||||
data->type = (requestformat.typel << 8) | requestformat.typeh;
|
||||
data->status = requestformat.status;
|
||||
if (data->errnum != 0) {
|
||||
return data->errnum;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ void osInitialize(void) {
|
|||
u32 status;
|
||||
#endif
|
||||
|
||||
UNUSED u32 sp2c;
|
||||
UNUSED u32 ptr;
|
||||
|
||||
__osFinalrom = TRUE;
|
||||
__osSetSR(__osGetSR() | SR_CU1);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
s32 osJamMesg(OSMesgQueue *mq, OSMesg msg, s32 flag) {
|
||||
register s32 int_disabled;
|
||||
int_disabled = __osDisableInt();
|
||||
while (mq->validCount >= mq->msgCount) {
|
||||
while (MQ_IS_FULL(mq)) {
|
||||
if (flag == OS_MESG_BLOCK) {
|
||||
__osRunningThread->state = OS_STATE_WAITING;
|
||||
__osEnqueueAndYield(&mq->fullqueue);
|
||||
|
|
|
@ -24,17 +24,17 @@ s32 osPfsIsPlug(OSMesgQueue *queue, u8 *pattern) {
|
|||
ret = __osSiRawStartDma(OS_READ, &__osPfsPifRam);
|
||||
osRecvMesg(queue, &dummy, OS_MESG_BLOCK);
|
||||
__osPfsGetInitData(&bitpattern, data);
|
||||
for (channel = 0; channel < _osContNumControllers; channel++) {
|
||||
for (channel = 0; channel < __osMaxControllers; channel++) {
|
||||
if ((data[channel].status & CONT_ADDR_CRC_ER) == 0) {
|
||||
crc_error_cnt--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (_osContNumControllers == channel) {
|
||||
if (__osMaxControllers == channel) {
|
||||
crc_error_cnt = 0;
|
||||
}
|
||||
if (crc_error_cnt < 1) {
|
||||
for (channel = 0; channel < _osContNumControllers; channel++) {
|
||||
for (channel = 0; channel < __osMaxControllers; channel++) {
|
||||
if (data[channel].errnum == 0 && (data[channel].status & CONT_CARD_ON) != 0) {
|
||||
bits |= 1 << channel;
|
||||
}
|
||||
|
@ -51,13 +51,13 @@ void __osPfsRequestData(u8 cmd) {
|
|||
__OSContRequesFormat requestformat;
|
||||
int i;
|
||||
|
||||
_osLastSentSiCmd = cmd;
|
||||
__osContLastCmd = cmd;
|
||||
|
||||
for (i = 0; i < ARRAY_COUNT(__osPfsPifRam.ramarray) + 1; i++) { // also clear pifstatus
|
||||
for (i = 0; i < ARRAY_COUNT(__osPfsPifRam.ramarray); i++) { // also clear pifstatus
|
||||
__osPfsPifRam.ramarray[i] = 0;
|
||||
}
|
||||
|
||||
__osPfsPifRam.pifstatus = CONT_CMD_EXE;
|
||||
__osPfsPifRam.s.pifstatus = CONT_CMD_EXE;
|
||||
|
||||
ptr = (u8 *)&__osPfsPifRam;
|
||||
requestformat.dummy = CONT_CMD_NOP;
|
||||
|
@ -68,7 +68,7 @@ void __osPfsRequestData(u8 cmd) {
|
|||
requestformat.typel = CONT_CMD_NOP;
|
||||
requestformat.status = CONT_CMD_NOP;
|
||||
requestformat.dummy1 = CONT_CMD_NOP;
|
||||
for (i = 0; i < _osContNumControllers; i++) {
|
||||
for (i = 0; i < __osMaxControllers; i++) {
|
||||
*(__OSContRequesFormat *)ptr = requestformat;
|
||||
ptr += sizeof(__OSContRequesFormat);
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ void __osPfsGetInitData(u8 *pattern, OSContStatus *data) {
|
|||
u8 bits;
|
||||
bits = 0;
|
||||
ptr = (u8 *)&__osPfsPifRam;
|
||||
for (i = 0; i < _osContNumControllers; i++, ptr += sizeof(__OSContRequesFormat)) {
|
||||
for (i = 0; i < __osMaxControllers; i++, ptr += sizeof(__OSContRequesFormat)) {
|
||||
requestformat = *(__OSContRequesFormat *)ptr;
|
||||
data->errnum = CHNL_ERR(requestformat);
|
||||
if (data->errnum == 0) {
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
#include "libultra_internal.h"
|
||||
|
||||
extern OSMgrArgs __osPiDevMgr;
|
||||
#include "piint.h"
|
||||
|
||||
OSMesgQueue *osPiGetCmdQueue(void) {
|
||||
if (!__osPiDevMgr.initialized) {
|
||||
if (!__osPiDevMgr.active) {
|
||||
return NULL;
|
||||
}
|
||||
return __osPiDevMgr.cmdQueue;
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
#include "libultra_internal.h"
|
||||
|
||||
extern OSMgrArgs __osPiDevMgr;
|
||||
#include "piint.h"
|
||||
|
||||
s32 osPiStartDma(OSIoMesg *mb, s32 priority, s32 direction, uintptr_t devAddr, void *vAddr,
|
||||
size_t nbytes, OSMesgQueue *mq) {
|
||||
register s32 result;
|
||||
register OSMesgQueue *cmdQueue;
|
||||
if (!__osPiDevMgr.initialized) {
|
||||
if (!__osPiDevMgr.active) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ s32 osSendMesg(OSMesgQueue *mq, OSMesg msg, s32 flag) {
|
|||
register OSThread *s2;
|
||||
int_disabled = __osDisableInt();
|
||||
|
||||
while (mq->validCount >= mq->msgCount) {
|
||||
while (MQ_IS_FULL(mq)) {
|
||||
if (flag == OS_MESG_BLOCK) {
|
||||
__osRunningThread->state = 8;
|
||||
__osEnqueueAndYield(&mq->fullqueue);
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
ptr = (void *) osVirtualToPhysical(ptr); \
|
||||
}
|
||||
|
||||
OSTask D_803638B0;
|
||||
static OSTask tmpTask;
|
||||
OSTask *_VirtualToPhysicalTask(OSTask *task) {
|
||||
OSTask *physicalTask;
|
||||
physicalTask = &D_803638B0;
|
||||
physicalTask = &tmpTask;
|
||||
bcopy(task, physicalTask, sizeof(OSTask));
|
||||
_osVirtualToPhysical(physicalTask->t.ucode);
|
||||
_osVirtualToPhysical(physicalTask->t.ucode_data);
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "PR/R4300.h"
|
||||
|
||||
uintptr_t osVirtualToPhysical(void *addr) {
|
||||
if ((uintptr_t) addr >= 0x80000000 && (uintptr_t) addr < 0xa0000000) {
|
||||
return ((uintptr_t) addr & 0x1fffffff);
|
||||
} else if ((uintptr_t) addr >= 0xa0000000 && (uintptr_t) addr < 0xc0000000) {
|
||||
return ((uintptr_t) addr & 0x1fffffff);
|
||||
if (IS_KSEG0(addr)) {
|
||||
return K0_TO_PHYS(addr);
|
||||
} else if (IS_KSEG1(addr)) {
|
||||
return (K1_TO_PHYS(addr));
|
||||
} else {
|
||||
return __osProbeTLB(addr);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include "libultra_internal.h"
|
||||
|
||||
void func_802F71F0(void) {
|
||||
register u32 s0 = __osDisableInt();
|
||||
void osYieldThread(void) {
|
||||
register u32 saveMask = __osDisableInt();
|
||||
__osRunningThread->state = OS_STATE_RUNNABLE;
|
||||
__osEnqueueAndYield(&__osRunQueue);
|
||||
__osRestoreInt(s0);
|
||||
__osRestoreInt(saveMask);
|
||||
}
|
|
@ -1,68 +1,26 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "controller.h"
|
||||
|
||||
void __osPfsRequestOneChannel(int channel);
|
||||
void __osPfsGetOneChannelData(int channel, OSContStatus *data);
|
||||
|
||||
s32 __osPfsGetStatus(OSMesgQueue *queue, int channel) {
|
||||
s32 ret;
|
||||
s32 __osPfsGetStatus(OSMesgQueue *queue, s32 channel) {
|
||||
s32 ret = 0;
|
||||
OSMesg dummy;
|
||||
OSContStatus data;
|
||||
ret = 0;
|
||||
__osPfsRequestOneChannel(channel);
|
||||
u8 pattern;
|
||||
OSContStatus data[4];
|
||||
|
||||
__osPfsRequestData(CONT_CMD_REQUEST_STATUS);
|
||||
ret = __osSiRawStartDma(OS_WRITE, &__osPfsPifRam);
|
||||
osRecvMesg(queue, &dummy, OS_MESG_BLOCK);
|
||||
ret = __osSiRawStartDma(OS_READ, &__osPfsPifRam);
|
||||
osRecvMesg(queue, &dummy, OS_MESG_BLOCK);
|
||||
__osPfsGetOneChannelData(channel, &data);
|
||||
if (((data.status & CONT_CARD_ON) != 0) && ((data.status & CONT_CARD_PULL) != 0)) {
|
||||
__osPfsGetInitData(&pattern, data);
|
||||
if (data[channel].status & CONT_CARD_ON && data[channel].status & CONT_CARD_PULL) {
|
||||
return PFS_ERR_NEW_PACK;
|
||||
}
|
||||
if ((data.errnum != 0) || ((data.status & CONT_CARD_ON) == 0)) {
|
||||
if (data[channel].errnum || !(data[channel].status & CONT_CARD_ON)) {
|
||||
return PFS_ERR_NOPACK;
|
||||
}
|
||||
if ((data.status & CONT_ADDR_CRC_ER) != 0) {
|
||||
if (data[channel].status & CONT_ADDR_CRC_ER) {
|
||||
return PFS_ERR_CONTRFAIL;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void __osPfsRequestOneChannel(int channel) {
|
||||
u8 *ptr;
|
||||
__OSContRequesFormatShort requestformat;
|
||||
int i;
|
||||
|
||||
_osLastSentSiCmd = CONT_CMD_REQUEST_STATUS;
|
||||
__osPfsPifRam.pifstatus = CONT_CMD_EXE;
|
||||
ptr = (u8 *)&__osPfsPifRam;
|
||||
|
||||
requestformat.txsize = CONT_CMD_REQUEST_STATUS_TX;
|
||||
requestformat.rxsize = CONT_CMD_REQUEST_STATUS_RX;
|
||||
requestformat.cmd = CONT_CMD_REQUEST_STATUS;
|
||||
requestformat.typeh = CONT_CMD_NOP;
|
||||
requestformat.typel = CONT_CMD_NOP;
|
||||
requestformat.status = CONT_CMD_NOP;
|
||||
for (i = 0; i < channel; i++) {
|
||||
*ptr++ = 0;
|
||||
}
|
||||
|
||||
*(__OSContRequesFormatShort *)ptr = requestformat;
|
||||
ptr += sizeof(__OSContRequesFormatShort);
|
||||
*ptr = CONT_CMD_END;
|
||||
}
|
||||
|
||||
void __osPfsGetOneChannelData(int channel, OSContStatus *data) {
|
||||
u8 *ptr;
|
||||
__OSContRequesFormatShort requestformat;
|
||||
int i;
|
||||
ptr = (u8*)&__osPfsPifRam;
|
||||
for (i = 0; i < channel; i++) {
|
||||
ptr++;
|
||||
}
|
||||
requestformat = *(__OSContRequesFormatShort *)ptr;
|
||||
data->errnum = CHNL_ERR(requestformat);
|
||||
if (data->errnum == 0) {
|
||||
data->type = (requestformat.typel << 8) | (requestformat.typeh);
|
||||
data->status = requestformat.status;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,11 +88,15 @@
|
|||
#define LEO_CMD_TYPE_2 2 //TODO: name
|
||||
|
||||
#define LEO_ERROR_GOOD 0
|
||||
#define LEO_ERROR_3 3 //
|
||||
#define LEO_ERROR_4 4 //maybe busy?
|
||||
#define LEO_ERROR_6 6 //
|
||||
#define LEO_ERROR_17 17 //
|
||||
#define LEO_ERROR_22 22 //
|
||||
#define LEO_ERROR_23 23 //unrecovered read error?
|
||||
#define LEO_ERROR_24 24 //no reference position found?
|
||||
#define LEO_ERROR_29 29 //
|
||||
#define LEO_ERROR_75 75 //
|
||||
|
||||
extern OSDevMgr __osPiDevMgr;
|
||||
extern OSPiHandle *__osCurrentHandle[2];
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "controller.h"
|
||||
|
||||
s32 func_8030A5C0(OSMesgQueue *arg0, s32 arg1) { // TODO: This is almost certainly __osPfsGetStatus.
|
||||
s32 sp34 = 0;
|
||||
OSMesg sp30;
|
||||
u8 sp2f;
|
||||
OSContStatus sp1c[4];
|
||||
__osPfsRequestData(0);
|
||||
sp34 = __osSiRawStartDma(1, &__osPfsPifRam);
|
||||
osRecvMesg(arg0, &sp30, 1);
|
||||
sp34 = __osSiRawStartDma(0, &__osPfsPifRam);
|
||||
osRecvMesg(arg0, &sp30, 1);
|
||||
__osPfsGetInitData(&sp2f, sp1c);
|
||||
if (sp1c[arg1].status & CONT_CARD_ON && sp1c[arg1].status & CONT_CARD_PULL) {
|
||||
return 2;
|
||||
}
|
||||
if (sp1c[arg1].errnum || !(sp1c[arg1].status & CONT_CARD_ON)) {
|
||||
return 1;
|
||||
}
|
||||
if (sp1c[arg1].status & CONT_ADDR_CRC_ER) {
|
||||
return 4;
|
||||
}
|
||||
return sp34;
|
||||
|
||||
}
|
13
sm64.ld
13
sm64.ld
|
@ -273,9 +273,8 @@ SECTIONS
|
|||
BUILD_DIR/libultra.a:osPiRawReadIo.o(.text);
|
||||
BUILD_DIR/libultra.a:__osSetHWintrRoutine.o(.text);
|
||||
#ifdef VERSION_EU
|
||||
BUILD_DIR/libultra.a:D_802F4380.o(.text);
|
||||
BUILD_DIR/libultra.a:leointerrupt.o(.text);
|
||||
#endif
|
||||
BUILD_DIR/libultra.a:func_802F4A20.o(.text);
|
||||
BUILD_DIR/libultra.a:osTimer.o(.text);
|
||||
#ifdef VERSION_EU
|
||||
BUILD_DIR/libultra.a:__osDisableInt.o(.text);
|
||||
|
@ -330,14 +329,14 @@ SECTIONS
|
|||
BUILD_DIR/libultra.a:__osDequeueThread.o(.text);
|
||||
BUILD_DIR/libultra.a:__osProbeTLB.o(.text);
|
||||
BUILD_DIR/libultra.a:__osResetGlobalIntMask.o(.text);
|
||||
BUILD_DIR/libultra.a:__osEPiRawWriteIo.o(.text);
|
||||
BUILD_DIR/libultra.a:osEPiRawWriteIo.o(.text);
|
||||
#ifdef VERSION_SH
|
||||
BUILD_DIR/libultra.a:__osEPiRawReadIo.o(.text);
|
||||
BUILD_DIR/libultra.a:osEPiRawReadIo.o(.text);
|
||||
BUILD_DIR/libultra.a:__osSetGlobalIntMask.o(.text);
|
||||
#endif
|
||||
BUILD_DIR/libultra.a:func_802F71F0.o(.text);
|
||||
BUILD_DIR/libultra.a:osYieldThread.o(.text);
|
||||
#ifdef RUMBLE_FEEDBACK
|
||||
BUILD_DIR/libultra.a:unk_shindou_file_3.o(.text);
|
||||
BUILD_DIR/libultra.a:pfsgetstatus.o(.text);
|
||||
#endif
|
||||
BUILD_DIR/lib/rsp.o(.text);
|
||||
#else
|
||||
|
@ -458,7 +457,7 @@ SECTIONS
|
|||
BUILD_DIR/libultra.a:__osAtomicDec.o(.text);
|
||||
BUILD_DIR/libultra.a:guLookAtRef.o(.text); /* Fast3DEX2 only */
|
||||
#ifdef RUMBLE_FEEDBACK
|
||||
BUILD_DIR/libultra.a:unk_shindou_file_3.o(.text);
|
||||
BUILD_DIR/libultra.a:pfsgetstatus.o(.text);
|
||||
#endif
|
||||
BUILD_DIR/lib/rsp.o(.text);
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue