summaryrefslogtreecommitdiff
path: root/src/libultra_code_O2/pfsinitpak.c
diff options
context:
space:
mode:
authorTharo <17233964+Thar0@users.noreply.github.com>2021-12-01 00:08:57 +0000
committerGitHub <noreply@github.com>2021-11-30 19:08:57 -0500
commitf1d183d6feac23275306bfa2dee939d123702765 (patch)
treec20585c17dea94561f7c4cfcff572e39bc033a3e /src/libultra_code_O2/pfsinitpak.c
parenteabc91881761a82856cca3fab9a4749c60ea1fe7 (diff)
libultra files and directories restructure (#1038)
* Restructure files, begin header restructure * Format * us2dex * Fix parallel spelling Co-authored-by: JoshDuMan <40190173+JoshDuMan@users.noreply.github.com> * Use OS_K0_TO_PHYSICAL in place of VIRTUAL_TO_PHYSICAL in osAiSetNextBuffer * Uppercase hex, exception vector address defines * Interrupt flags 1 Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com> * Interrupt flags 2 Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com> Co-authored-by: JoshDuMan <40190173+JoshDuMan@users.noreply.github.com> Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>
Diffstat (limited to 'src/libultra_code_O2/pfsinitpak.c')
-rw-r--r--src/libultra_code_O2/pfsinitpak.c107
1 files changed, 0 insertions, 107 deletions
diff --git a/src/libultra_code_O2/pfsinitpak.c b/src/libultra_code_O2/pfsinitpak.c
deleted file mode 100644
index 59fb8eda9..000000000
--- a/src/libultra_code_O2/pfsinitpak.c
+++ /dev/null
@@ -1,107 +0,0 @@
-#include "ultra64.h"
-#include "global.h"
-
-s32 osPfsInitPak(OSMesgQueue* queue, OSPfs* pfs, s32 channel) {
- s32 ret;
- u16 sum;
- u16 isum;
- u8 temp[BLOCKSIZE];
- __OSPackId* id;
- __OSPackId newid;
-
- __osSiGetAccess();
-
- ret = __osPfsGetStatus(queue, channel);
-
- __osSiRelAccess();
-
- if (ret != 0) {
- return ret;
- }
-
- pfs->queue = queue;
- pfs->channel = channel;
- pfs->status = 0;
-
- if ((ret = __osPfsCheckRamArea(pfs)) != 0) {
- return ret;
- }
- if ((ret = __osPfsSelectBank(pfs, 0)) != 0) {
- return ret;
- }
- if ((ret = __osContRamRead(pfs->queue, pfs->channel, PFS_ID_0AREA, temp)) != 0) {
- return (ret);
- }
-
- __osIdCheckSum((u16*)temp, &sum, &isum);
- id = (__OSPackId*)temp;
- if ((id->checksum != sum) || (id->invertedChecksum != isum)) {
- if ((ret = __osCheckPackId(pfs, id)) != 0) {
- pfs->status |= PFS_ID_BROKEN;
- return ret;
- }
- }
-
- if ((id->deviceid & 0x01) == 0) {
- ret = __osRepairPackId(pfs, id, &newid);
- if (ret) {
- if (ret == PFS_ERR_ID_FATAL) {
- pfs->status |= PFS_ID_BROKEN;
- }
- return ret;
- }
- id = &newid;
- if ((id->deviceid & 0x01) == 0) {
- return PFS_ERR_DEVICE;
- }
- }
-
- bcopy(id, pfs->id, BLOCKSIZE);
-
- if (1) {}
-
- pfs->version = id->version;
- pfs->banks = id->banks;
- pfs->inodeStartPage = 1 + DEF_DIR_PAGES + (2 * pfs->banks);
- pfs->dir_size = DEF_DIR_PAGES * PFS_ONE_PAGE;
- pfs->inode_table = 1 * PFS_ONE_PAGE;
- pfs->minode_table = (1 + pfs->banks) * PFS_ONE_PAGE;
- pfs->dir_table = pfs->minode_table + (pfs->banks * PFS_ONE_PAGE);
-
- if ((ret = __osContRamRead(pfs->queue, pfs->channel, PFS_LABEL_AREA, pfs->label)) != 0) {
- return ret;
- }
-
- ret = osPfsChecker(pfs);
- pfs->status |= PFS_INITIALIZED;
-
- return ret;
-}
-
-s32 __osPfsCheckRamArea(OSPfs* pfs) {
- s32 i = 0;
- s32 ret = 0;
- u8 temp1[BLOCKSIZE];
- u8 temp2[BLOCKSIZE];
- u8 saveReg[BLOCKSIZE];
-
- if ((ret = __osPfsSelectBank(pfs, PFS_ID_BANK_256K)) != 0) {
- return ret;
- }
- if ((ret = __osContRamRead(pfs->queue, pfs->channel, 0, saveReg)) != 0) {
- return ret;
- }
- for (i = 0; i < BLOCKSIZE; i++) {
- temp1[i] = i;
- }
- if ((ret = __osContRamWrite(pfs->queue, pfs->channel, 0, temp1, 0)) != 0) {
- return ret;
- }
- if ((ret = __osContRamRead(pfs->queue, pfs->channel, 0, temp2)) != 0) {
- return ret;
- }
- if (bcmp(temp1, temp2, BLOCKSIZE) != 0) {
- return PFS_ERR_DEVICE;
- }
- return __osContRamWrite(pfs->queue, pfs->channel, 0, saveReg, 0);
-}