From 3dd4c071e1ecdf15a30aa37187283f0b974dc825 Mon Sep 17 00:00:00 2001 From: MegaMech Date: Sun, 14 Apr 2024 17:15:41 -0600 Subject: [PATCH] Update osEeprom Read and Write (#608) --- include/PR/os_cont.h | 2 +- src/os/contramread.c | 2 +- src/os/contramwrite.c | 2 +- src/os/controller.h | 2 +- src/os/osContInit.c | 8 +- src/os/osContStartReadData.c | 6 +- src/os/osEepromLongRead.c | 8 +- src/os/osEepromLongWrite.c | 10 +- src/os/osEepromProbe.c | 25 ++--- src/os/osEepromRead.c | 122 +++++++++++----------- src/os/osEepromWrite.c | 193 +++++++++++++++++------------------ src/os/osPfsInit.c | 2 +- src/os/osPfsIsPlug.c | 8 +- 13 files changed, 192 insertions(+), 198 deletions(-) diff --git a/include/PR/os_cont.h b/include/PR/os_cont.h index 2754f2504..2b989a5ab 100644 --- a/include/PR/os_cont.h +++ b/include/PR/os_cont.h @@ -53,7 +53,7 @@ extern "C" { typedef struct { u16 type; /* Controller Type */ u8 status; /* Controller status */ - u8 errno; + u8 errnum; }OSContStatus; typedef struct { diff --git a/src/os/contramread.c b/src/os/contramread.c index f78507fc6..5f3b6e68d 100644 --- a/src/os/contramread.c +++ b/src/os/contramread.c @@ -15,7 +15,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); diff --git a/src/os/contramwrite.c b/src/os/contramwrite.c index a4db11e17..ebb8d77c5 100644 --- a/src/os/contramwrite.c +++ b/src/os/contramwrite.c @@ -19,7 +19,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); diff --git a/src/os/controller.h b/src/os/controller.h index 518b113ee..541fafdc6 100644 --- a/src/os/controller.h +++ b/src/os/controller.h @@ -169,7 +169,7 @@ 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 OSMesgQueue __osEepromTimerQ; diff --git a/src/os/osContInit.c b/src/os/osContInit.c index 6a20606df..c4c72127e 100644 --- a/src/os/osContInit.c +++ b/src/os/osContInit.c @@ -9,7 +9,7 @@ u32 _osContInitialized = 0; extern u64 osClockRate; // these probably belong in EEPROMlongread or something -u8 _osLastSentSiCmd; +u8 __osContLastCmd; u8 _osContNumControllers; OSTimer D_80196548; OSMesgQueue _osContMesgQueue; @@ -39,7 +39,7 @@ s32 osContInit(OSMesgQueue *mq, u8 *bitpattern, OSContStatus *status) { ret = __osSiRawStartDma(OS_READ, _osContCmdBuf); osRecvMesg(mq, &mesg, OS_MESG_BLOCK); __osContGetInitData(bitpattern, status); - _osLastSentSiCmd = 0; + __osContLastCmd = 0; __osSiCreateAccessQueue(); osCreateMesgQueue(&_osContMesgQueue, _osContMesgBuff, 1); return ret; @@ -54,8 +54,8 @@ void __osContGetInitData(u8 *bitpattern, OSContStatus *status) { cmdBufPtr = &(_osContCmdBuf[0].request); for (i = 0; i < _osContNumControllers; i++, cmdBufPtr++, status++) { response = *(OSContPackedRequest *) cmdBufPtr; - status->errno = (response.rxLen & 0xc0) >> 4; - if (status->errno == 0) { + status->errnum = (response.rxLen & 0xc0) >> 4; + if (status->errnum == 0) { status->type = response.data2 << 8 | response.data1; status->status = response.data3; diff --git a/src/os/osContStartReadData.c b/src/os/osContStartReadData.c index ca1e4da9e..3fb5c48b7 100644 --- a/src/os/osContStartReadData.c +++ b/src/os/osContStartReadData.c @@ -11,7 +11,7 @@ u32 _osContPifCtrl; ALIGNED8 OSContPackedStruct _osContCmdBuf[8]; #endif -extern u8 _osLastSentSiCmd; +extern u8 __osContLastCmd; extern u8 _osContNumControllers; void __osPackReadData(void); @@ -19,7 +19,7 @@ s32 osContStartReadData(OSMesgQueue *mesg) { s32 ret = 0; s32 i; __osSiGetAccess(); - if (_osLastSentSiCmd != 1) { + if (__osContLastCmd != 1) { __osPackReadData(); ret = __osSiRawStartDma(OS_WRITE, _osContCmdBuf); osRecvMesg(mesg, NULL, OS_MESG_BLOCK); @@ -30,7 +30,7 @@ s32 osContStartReadData(OSMesgQueue *mesg) { _osContPifCtrl = 0; ret = __osSiRawStartDma(OS_READ, _osContCmdBuf); - _osLastSentSiCmd = 1; + __osContLastCmd = 1; __osSiRelAccess(); return ret; } diff --git a/src/os/osEepromLongRead.c b/src/os/osEepromLongRead.c index 548e93a0f..55b4f4a61 100644 --- a/src/os/osEepromLongRead.c +++ b/src/os/osEepromLongRead.c @@ -7,7 +7,7 @@ extern OSTimer D_80196548; // 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; @@ -19,9 +19,9 @@ s32 osEepromLongRead(OSMesgQueue *mq, u8 address, u8 *buffer, int nbytes) { return status; } - nbytes -= 8; - address += 1; - buffer += 8; + nbytes -= EEPROM_BLOCK_SIZE; + address++; + buffer += EEPROM_BLOCK_SIZE; osSetTimer(&D_80196548, 12000 * osClockRate / 1000000, 0, &_osContMesgQueue, _osContMesgBuff); osRecvMesg(&_osContMesgQueue, NULL, OS_MESG_BLOCK); } diff --git a/src/os/osEepromLongWrite.c b/src/os/osEepromLongWrite.c index 506b1b8ab..8a7f72e60 100644 --- a/src/os/osEepromLongWrite.c +++ b/src/os/osEepromLongWrite.c @@ -6,9 +6,9 @@ extern u8 _osContNumControllers; extern OSTimer D_80196548; extern OSMesgQueue _osContMesgQueue; extern OSMesg _osContMesgBuff[4]; -// exactly the same as osEepromLongRead except for osEepromWrite call -s32 osEepromLongWrite(OSMesgQueue *mq, u8 address, u8 *buffer, int nbytes) { +// exactly the same as osEepromLongRead except for osEepromWrite call +s32 osEepromLongWrite(OSMesgQueue *mq, u8 address, u8 *buffer, s32 nbytes) { s32 result = 0; if (address > 0x40) { return -1; @@ -20,9 +20,9 @@ s32 osEepromLongWrite(OSMesgQueue *mq, u8 address, u8 *buffer, int nbytes) { return result; } - nbytes -= 8; - address += 1; - buffer += 8; + nbytes -= EEPROM_BLOCK_SIZE; + address++; + buffer += EEPROM_BLOCK_SIZE; osSetTimer(&D_80196548, 12000 * osClockRate / 1000000, 0, &_osContMesgQueue, _osContMesgBuff); osRecvMesg(&_osContMesgQueue, NULL, OS_MESG_BLOCK); } diff --git a/src/os/osEepromProbe.c b/src/os/osEepromProbe.c index 475af4469..7908c212d 100644 --- a/src/os/osEepromProbe.c +++ b/src/os/osEepromProbe.c @@ -1,24 +1,15 @@ +#include "macros.h" #include "libultra_internal.h" +#include "controller.h" -//! @todo merge with osEepromWrite -typedef struct { - u16 unk00; - u8 unk02; - u8 unk03; -} unkStruct; - -s32 __osEepStatus(OSMesgQueue *, unkStruct *); +s32 __osEepStatus(OSMesgQueue *, OSContStatus *); s32 osEepromProbe(OSMesgQueue *mq) { - s32 status = 0; - unkStruct sp18; + s32 ret = 0; + OSContStatus status; __osSiGetAccess(); - status = __osEepStatus(mq, &sp18); - if (status == 0 && (sp18.unk00 & 0x8000) != 0) { - status = 1; - } else { - status = 0; - } + ret = __osEepStatus(mq, &status); + ret = (ret == 0 && (status.type & CONT_EEPROM) != 0) ? EEPROM_TYPE_4K : 0; __osSiRelAccess(); - return status; + return ret; } diff --git a/src/os/osEepromRead.c b/src/os/osEepromRead.c index 561ad2056..a3fc3a4b3 100644 --- a/src/os/osEepromRead.c +++ b/src/os/osEepromRead.c @@ -1,15 +1,11 @@ #include "libultra_internal.h" +#include "controller.h" +#include "macros.h" -extern u8 _osLastSentSiCmd; +extern u8 __osContLastCmd; -extern u32 __osEepPifRam[15]; -extern u32 D_8019769C; +extern OSPifRam __osEepPifRam; -typedef struct { - u16 unk00; - u8 unk02; - u8 unk03; -} unkStruct; typedef struct { u8 unk00; u8 unk01; @@ -29,74 +25,84 @@ typedef struct { unkStruct3 unk04; } unkStruct2; -s32 __osEepStatus(OSMesgQueue *, unkStruct *); -s32 __osPackEepReadData(u8); +s32 __osEepStatus(OSMesgQueue *, OSContStatus *); +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 *) &__osEepPifRam; - 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, &__osEepPifRam); + + ret = __osSiRawStartDma(OS_WRITE, &__osEepPifRam); osRecvMesg(mq, NULL, OS_MESG_BLOCK); - for (sp30 = 0; sp30 < 0x10; sp30++) { - __osEepPifRam[sp30] = 255; + + for (i = 0; i < ARRAY_COUNT(__osEepPifRam.ramarray) + 1; i++) { + __osEepPifRam.ramarray[i] = CONT_CMD_NOP; } - D_8019769C = 0; - sp34 = __osSiRawStartDma(OS_READ, __osEepPifRam); - _osLastSentSiCmd = 4; + __osEepPifRam.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 *) &__osEepPifRam; - for (sp4 = 0; sp4 < 0x10; sp4++) { - __osEepPifRam[sp4] = 255; +void __osPackEepReadData(u8 address) { + u8 *ptr = (u8 *) &__osEepPifRam.ramarray; + __OSContEepromFormat eepromformat; + s32 i; + + for (i = 0; i < ARRAY_COUNT(__osEepPifRam.ramarray) + 1; i++) { + __osEepPifRam.ramarray[i] = CONT_CMD_NOP; } - D_8019769C = 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.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; + + *(__OSContEepromFormat *) ptr = eepromformat; + ptr += sizeof(__OSContEepromFormat); + *ptr = CONT_CMD_END; } diff --git a/src/os/osEepromWrite.c b/src/os/osEepromWrite.c index eba200510..845432502 100644 --- a/src/os/osEepromWrite.c +++ b/src/os/osEepromWrite.c @@ -1,16 +1,12 @@ #include "libultra_internal.h" #include "osContInternal.h" +#include "controller.h" +#include "macros.h" -ALIGNED8 u32 __osEepPifRam[15]; -u32 D_8019769C; +OSPifRam __osEepPifRam; -extern u8 _osLastSentSiCmd; +extern u8 __osContLastCmd; -typedef struct { - u16 unk00; - u8 unk02; - u8 unk03; -} unkStruct; typedef struct { u8 unk00; u8 unk01; @@ -30,133 +26,134 @@ typedef struct { unkStruct3 unk04; } unkStruct2; -s32 __osEepStatus(OSMesgQueue *, unkStruct *); -s32 __osPackEepWriteData(u8, u8 *); +s32 __osEepStatus(OSMesgQueue *, OSContStatus *); +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 *) &__osEepPifRam; + 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, &__osEepPifRam); + ret = __osSiRawStartDma(OS_WRITE, &__osEepPifRam); osRecvMesg(mq, NULL, OS_MESG_BLOCK); - for (sp30 = 0; sp30 < 0x10; sp30++) { - (__osEepPifRam)[sp30] = 255; + for (i = 0; i < ARRAY_COUNT(__osEepPifRam.ramarray) + 1; i++) { + __osEepPifRam.ramarray[i] = CONT_CMD_NOP; } - D_8019769C = 0; - sp34 = __osSiRawStartDma(OS_READ, __osEepPifRam); - _osLastSentSiCmd = 5; + __osEepPifRam.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 *) &__osEepPifRam; - for (sp4 = 0; sp4 < 0x10; sp4++) { - __osEepPifRam[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) + 1; i++) { + __osEepPifRam.ramarray[i] = CONT_CMD_NOP; } - D_8019769C = 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.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; + *(__OSContEepromFormat *) ptr = eepromformat; + ptr += sizeof(__OSContEepromFormat); + *ptr = CONT_CMD_END; } -s32 __osEepStatus(OSMesgQueue *a0, unkStruct *a1) { - u32 sp2c = 0; - s32 sp28; - u8 *sp24 = (u8 *) __osEepPifRam; - 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++) { - __osEepPifRam[sp28] = 0; + for (i = 0; i < ARRAY_COUNT(__osEepPifRam.ramarray) + 1; i++) { + __osEepPifRam.ramarray[i] = 0; + } + __osEepPifRam.pifstatus = CONT_CMD_EXE; + + ptr = (u8 *) __osEepPifRam.ramarray; + for (i = 0; i < 4; i++) { + *ptr++ = 0; } - D_8019769C = 1; - sp24 = (u8 *) __osEepPifRam; - 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, __osEepPifRam); - osRecvMesg(a0, NULL, OS_MESG_BLOCK); - - _osLastSentSiCmd = 5; - - sp2c = __osSiRawStartDma(OS_READ, __osEepPifRam); - 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 *) __osEepPifRam; - 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; } diff --git a/src/os/osPfsInit.c b/src/os/osPfsInit.c index fd5fe147c..9a91ba456 100644 --- a/src/os/osPfsInit.c +++ b/src/os/osPfsInit.c @@ -41,7 +41,7 @@ s32 __osPfsGetStatus(OSMesgQueue *queue, int channel) if (((data[channel].status & CONT_CARD_ON) != 0) && ((data[channel].status & CONT_CARD_PULL) != 0)) return PFS_ERR_NEW_PACK; - if ((data[channel].errno != 0) || ((data[channel].status & CONT_CARD_ON) == 0)) + if ((data[channel].errnum != 0) || ((data[channel].status & CONT_CARD_ON) == 0)) return PFS_ERR_NOPACK; if ((data[channel].status & CONT_ADDR_CRC_ER) != 0) return PFS_ERR_CONTRFAIL; diff --git a/src/os/osPfsIsPlug.c b/src/os/osPfsIsPlug.c index 2f2d8249e..11580732b 100644 --- a/src/os/osPfsIsPlug.c +++ b/src/os/osPfsIsPlug.c @@ -35,7 +35,7 @@ s32 osPfsIsPlug(OSMesgQueue *queue, u8 *pattern) { } if (crc_error_cnt < 1) { for (channel = 0; channel < _osContNumControllers; channel++) { - if (data[channel].errno == 0 && (data[channel].status & CONT_CARD_ON) != 0) { + if (data[channel].errnum == 0 && (data[channel].status & CONT_CARD_ON) != 0) { bits |= 1 << channel; } } @@ -51,7 +51,7 @@ void __osPfsRequestData(u8 cmd) { __OSContRequesFormat requestformat; int i; - _osLastSentSiCmd = cmd; + __osContLastCmd = cmd; for (i = 0; i < ARRLEN(__osPfsPifRam.ramarray) + 1; i++) { // also clear pifstatus __osPfsPifRam.ramarray[i] = 0; @@ -84,8 +84,8 @@ void __osPfsGetInitData(u8 *pattern, OSContStatus *data) { ptr = (u8 *)&__osPfsPifRam; for (i = 0; i < _osContNumControllers; i++, ptr += sizeof(__OSContRequesFormat)) { requestformat = *(__OSContRequesFormat *)ptr; - data->errno = CHNL_ERR(requestformat); - if (data->errno == 0) { + data->errnum = CHNL_ERR(requestformat); + if (data->errnum == 0) { data->type = (requestformat.typel << 8) | (requestformat.typeh); data->status = requestformat.status; bits |= 1 << i;