Compare commits
1 Commits
cleanup/se
...
agent/w092
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
147b055274 |
@@ -53,9 +53,9 @@ Progress
|
||||
<!-- progress:start -->
|
||||
| Decompiled | Matched | Linked | Data |
|
||||
|:---:|:---:|:---:|:---:|
|
||||
| 92.68% | 81.49% | 57.21% | 88.99% |
|
||||
| 93.26% | 82.01% | 57.21% | 89.10% |
|
||||
|
||||
units 768/1027 complete, functions 11732/12563 matched.
|
||||
units 768/1027 complete, functions 11877/12563 matched.
|
||||
|
||||
decompiled = code with a C/C++ implementation (objdiff fuzzy), matched = byte-exact code, linked = code actually linked into the DOL, data = byte-exact data
|
||||
<!-- progress:end -->
|
||||
|
||||
39
libs/RVL_SDK/include/private/fa/pf_kernel.h
Normal file
39
libs/RVL_SDK/include/private/fa/pf_kernel.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#ifndef FA_PF_KERNEL_H
|
||||
#define FA_PF_KERNEL_H
|
||||
|
||||
#include <revolution/os.h>
|
||||
|
||||
typedef struct PFK_TASK_CONFIG {
|
||||
void* (*entry)(void*);
|
||||
void* argument;
|
||||
u32 stack_size;
|
||||
void* stack;
|
||||
s32 priority;
|
||||
OSThread* thread;
|
||||
} PFK_TASK_CONFIG;
|
||||
|
||||
typedef struct PFK_MAILBOX_CONFIG {
|
||||
OSMessageQueue* queue;
|
||||
OSMessage* messages;
|
||||
s32 count;
|
||||
} PFK_MAILBOX_CONFIG;
|
||||
|
||||
typedef struct PFK_SEMAPHORE_CONFIG {
|
||||
u32 initial_count;
|
||||
u32 maximum_count;
|
||||
OSSemaphore* semaphore;
|
||||
} PFK_SEMAPHORE_CONFIG;
|
||||
|
||||
s32 pfk_create_task(PFK_TASK_CONFIG* config);
|
||||
s32 pfk_start_task(s32 task_id);
|
||||
s32 pfk_get_task_id(s32* task_id);
|
||||
s32 pfk_set_task_priority(s32 task_id, s32 priority);
|
||||
s32 pfk_create_mailbox(PFK_MAILBOX_CONFIG* config);
|
||||
s32 pfk_receive_message(s32 mailbox, OSMessage* message);
|
||||
s32 pfk_send_message(s32 mailbox, OSMessage message);
|
||||
s32 pfk_create_semaphore(PFK_SEMAPHORE_CONFIG* config);
|
||||
s32 pfk_delete_semaphore(s32 semaphore);
|
||||
s32 pfk_get_semaphore(s32 semaphore);
|
||||
s32 pfk_release_semaphore(s32 semaphore);
|
||||
|
||||
#endif
|
||||
59
libs/RVL_SDK/include/private/fa/puh_msc.h
Normal file
59
libs/RVL_SDK/include/private/fa/puh_msc.h
Normal file
@@ -0,0 +1,59 @@
|
||||
#ifndef FA_PUH_MSC_H
|
||||
#define FA_PUH_MSC_H
|
||||
|
||||
#include <revolution/fa/types.h>
|
||||
|
||||
typedef struct UHF_MSC_DEVICE {
|
||||
FADisk* disk;
|
||||
u32 device_id;
|
||||
u32 interface_id;
|
||||
u32 endpoint_in;
|
||||
u32 endpoint_out;
|
||||
u32 total_blocks;
|
||||
u32 block_size;
|
||||
u32 tag;
|
||||
u32 lun;
|
||||
u32 flags;
|
||||
u32 status;
|
||||
u32 event;
|
||||
} UHF_MSC_DEVICE;
|
||||
|
||||
typedef struct UHF_MSC_PARAMETERS {
|
||||
UHF_MSC_DEVICE* device;
|
||||
void* sense;
|
||||
u32 timeout;
|
||||
void* buffer;
|
||||
u32 length;
|
||||
u32 sector;
|
||||
u16 transfer_flags;
|
||||
u16 block_count;
|
||||
u32 options;
|
||||
u32 result_size;
|
||||
FADisk* disk;
|
||||
} UHF_MSC_PARAMETERS;
|
||||
|
||||
typedef struct UHF_MSC_MESSAGE {
|
||||
u32 command;
|
||||
s32 semaphore;
|
||||
s32* result;
|
||||
UHF_MSC_PARAMETERS parameters;
|
||||
void (*callback)(void*);
|
||||
void* context;
|
||||
} UHF_MSC_MESSAGE;
|
||||
|
||||
extern UHF_MSC_DEVICE uhg_msc_blk_device_tbl[8];
|
||||
extern s32 uhg_msc_memid_8169971C;
|
||||
s32 uhf_ker_set_priority(s32 task_id, s32 priority);
|
||||
void* uhf_ker_get_memory_block(s32 pool, u32 size, u32 alignment);
|
||||
s32 uhf_ker_release_memory_block(s32 pool, void* block);
|
||||
s32 uhf_ker_create_sem(u32 initial_count, u32 maximum_count);
|
||||
s32 uhf_ker_delete_sem(s32 semaphore);
|
||||
s32 uhf_ker_get_sem(s32 semaphore);
|
||||
s32 uhf_ker_send_message(s32 mailbox, void* message, u32 flags);
|
||||
s32 uhf_ker_check_cacheable(void* buffer);
|
||||
s32 usbh_msc_read10(UHF_MSC_DEVICE* device, u32 sector, u16 count, void* buffer, void* sense);
|
||||
s32 usbh_msc_write10(UHF_MSC_DEVICE* device, u32 sector, u16 count, void* buffer, void* sense);
|
||||
s32 uhf_msc_get_message_id(void);
|
||||
s32 __uhf_msc_cmd_check_sense(const void* sense);
|
||||
|
||||
#endif
|
||||
33
libs/RVL_SDK/include/revolution/fa/pf_stub.h
Normal file
33
libs/RVL_SDK/include/revolution/fa/pf_stub.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#ifndef FA_PF_STUB_H
|
||||
#define FA_PF_STUB_H
|
||||
|
||||
#include <revolution/fa.h>
|
||||
|
||||
typedef union PF_STUB_RESULT {
|
||||
s32 status;
|
||||
u32 count;
|
||||
void* stream;
|
||||
} PF_STUB_RESULT;
|
||||
|
||||
typedef struct PF_STUB_MESSAGE {
|
||||
s32 task_id;
|
||||
s32 operation;
|
||||
s8 drive;
|
||||
u32 value;
|
||||
u32 count;
|
||||
const void* object;
|
||||
const void* data;
|
||||
void* context;
|
||||
u32 options;
|
||||
s32 semaphore;
|
||||
PF_STUB_RESULT* result_address;
|
||||
FADisk* disk;
|
||||
FAPartition* partition;
|
||||
void (*callback)(s32, void*);
|
||||
void* callback_context;
|
||||
PF_STUB_RESULT result;
|
||||
} PF_STUB_MESSAGE;
|
||||
|
||||
extern s32 pfstub_com_massage(PF_STUB_MESSAGE* message);
|
||||
|
||||
#endif
|
||||
100
libs/RVL_SDK/src/fa/api/FAAttach.c
Normal file
100
libs/RVL_SDK/src/fa/api/FAAttach.c
Normal file
@@ -0,0 +1,100 @@
|
||||
#include <revolution/fa/types.h>
|
||||
#include <string.h>
|
||||
|
||||
typedef struct FA_NAND_ATTACH {
|
||||
char path[80];
|
||||
u32 size;
|
||||
} FA_NAND_ATTACH;
|
||||
|
||||
typedef struct FA_ATTACH_REQUEST {
|
||||
FADrvTbl* table;
|
||||
u32 count;
|
||||
} FA_ATTACH_REQUEST;
|
||||
|
||||
FADisk* gOpenDisk[26];
|
||||
FAPartition* gOpenPartition[26];
|
||||
typedef struct FA_DISK_INIT {
|
||||
s32 (*initialize)(FADiskTbl*, u32);
|
||||
u32 extension;
|
||||
} FA_DISK_INIT;
|
||||
|
||||
extern s32 pfd_sddrv_init_drv_tbl(FADiskTbl* table, u32 extension);
|
||||
extern s32 usbh_msc_blk_init_drv_tbl(FADiskTbl* table, u32 extension);
|
||||
extern s32 fa_nanddrv_init_drv_tbl(FADiskTbl* table, u32 extension);
|
||||
|
||||
static FA_DISK_INIT diskInitTbl[] = {
|
||||
{pfd_sddrv_init_drv_tbl, 0},
|
||||
{usbh_msc_blk_init_drv_tbl, 0},
|
||||
{fa_nanddrv_init_drv_tbl, 0},
|
||||
};
|
||||
|
||||
static struct {
|
||||
FA_DISK_INIT* entries;
|
||||
u32 count;
|
||||
} drvInitFunc = {diskInitTbl, 3};
|
||||
extern s32 pdm_open_disk(FA_DISK_INIT* table, FADisk** disk);
|
||||
extern s32 pdm_open_partition(FADisk* disk, u32 index, FAPartition** partition);
|
||||
extern s32 pfstub_attach(FA_ATTACH_REQUEST* request, FA_NAND_ATTACH* nand);
|
||||
extern s32 pfd_sddrv_is_media_insert(void);
|
||||
extern s32 pfd_mscdrv_is_media_insert(void);
|
||||
|
||||
FAError FAAttach(u32 device, char* nand_path, u32 nand_size, FADrvTbl* table) {
|
||||
FADisk* disk;
|
||||
FA_ATTACH_REQUEST request;
|
||||
FA_NAND_ATTACH nand;
|
||||
s32 error;
|
||||
s32 index;
|
||||
|
||||
if (device >= 4) {
|
||||
return -2;
|
||||
}
|
||||
if (table == NULL) {
|
||||
return -2;
|
||||
}
|
||||
if (device == 2 && nand_path == NULL) {
|
||||
return -2;
|
||||
}
|
||||
if (device == 3 && table->pPart == NULL) {
|
||||
return -2;
|
||||
}
|
||||
if (device <= 2) {
|
||||
if (pdm_open_disk(&drvInitFunc.entries[(u8)device], &disk) != 0) {
|
||||
return -1;
|
||||
}
|
||||
if (pdm_open_partition(disk, 0, &table->pPart) != 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
request.table = table;
|
||||
request.count = 0;
|
||||
if (device == 2) {
|
||||
memcpy(nand.path, nand_path, 78);
|
||||
nand.size = nand_size;
|
||||
}
|
||||
if (device == 2) {
|
||||
error = pfstub_attach(&request, &nand);
|
||||
} else {
|
||||
error = pfstub_attach(&request, NULL);
|
||||
}
|
||||
if (error != 0) {
|
||||
return -1;
|
||||
}
|
||||
index = table->drive - 'A';
|
||||
if (device <= 2) {
|
||||
gOpenDisk[index] = disk;
|
||||
gOpenPartition[index] = table->pPart;
|
||||
if (device == 0) {
|
||||
if (pfd_sddrv_is_media_insert()) {
|
||||
request.table->stat |= 0x10;
|
||||
}
|
||||
} else if (device == 1) {
|
||||
if (pfd_mscdrv_is_media_insert()) {
|
||||
request.table->stat |= 0x10;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
gOpenDisk[index] = NULL;
|
||||
gOpenPartition[index] = NULL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
8
libs/RVL_SDK/src/fa/api/FABuffering.c
Normal file
8
libs/RVL_SDK/src/fa/api/FABuffering.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
extern s32 pfstub_buffering(s8 drive, s32 mode);
|
||||
|
||||
FAError FABuffering(s8 drive, s32 mode) {
|
||||
s32 error = pfstub_buffering(drive, mode);
|
||||
return (-error | error) >> 31;
|
||||
}
|
||||
11
libs/RVL_SDK/src/fa/api/FACreate.c
Normal file
11
libs/RVL_SDK/src/fa/api/FACreate.c
Normal file
@@ -0,0 +1,11 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
extern FAFILE* pfstub_create(const char* fileName, int mode);
|
||||
|
||||
FAFILE* FACreate(const char* fileName, int mode) {
|
||||
FAFILE* result = pfstub_create(fileName, mode);
|
||||
if (result == NULL) {
|
||||
result = NULL;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
8
libs/RVL_SDK/src/fa/api/FACreatedir.c
Normal file
8
libs/RVL_SDK/src/fa/api/FACreatedir.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
extern s32 pfstub_createdir(const char* dirName, s32 mode, FADta* dta);
|
||||
|
||||
s32 FACreatedir(const char* dirName, s32 mode, FADta* dta) {
|
||||
s32 result = pfstub_createdir(dirName, mode, dta);
|
||||
return (-result | result) >> 31;
|
||||
}
|
||||
24
libs/RVL_SDK/src/fa/api/FADetach.c
Normal file
24
libs/RVL_SDK/src/fa/api/FADetach.c
Normal file
@@ -0,0 +1,24 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
extern FADisk* gOpenDisk[26];
|
||||
extern FAPartition* gOpenPartition[26];
|
||||
extern s32 pfstub_detach(s8 drive);
|
||||
extern s32 pdm_close_partition(FAPartition* partition);
|
||||
extern s32 pdm_close_disk(FADisk* disk);
|
||||
|
||||
FAError FADetach(s8 drive) {
|
||||
FADisk* disk = gOpenDisk[drive - 'A'];
|
||||
FAPartition* partition = gOpenPartition[drive - 'A'];
|
||||
if (pfstub_detach(drive) != 0) {
|
||||
return -1;
|
||||
}
|
||||
if (disk != NULL && partition != NULL) {
|
||||
if (pdm_close_partition(partition) != 0) {
|
||||
return -1;
|
||||
}
|
||||
if (pdm_close_disk(disk) != 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
11
libs/RVL_SDK/src/fa/api/FAErrnum.c
Normal file
11
libs/RVL_SDK/src/fa/api/FAErrnum.c
Normal file
@@ -0,0 +1,11 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
extern s32 pfstub_errnum(void);
|
||||
|
||||
FAError FAErrnum(void) {
|
||||
s32 error = pfstub_errnum();
|
||||
if (error == 5) {
|
||||
return 5;
|
||||
}
|
||||
return error == 0 ? 0 : error;
|
||||
}
|
||||
11
libs/RVL_SDK/src/fa/api/FAFopen.c
Normal file
11
libs/RVL_SDK/src/fa/api/FAFopen.c
Normal file
@@ -0,0 +1,11 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
extern FAFILE* pfstub_fopen(const char* fileName, const char* mode);
|
||||
|
||||
FAFILE* FAFopen(const char* fileName, const char* mode) {
|
||||
FAFILE* result = pfstub_fopen(fileName, mode);
|
||||
if (result == NULL) {
|
||||
result = NULL;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
8
libs/RVL_SDK/src/fa/api/FAFormat.c
Normal file
8
libs/RVL_SDK/src/fa/api/FAFormat.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
extern s32 pfstub_format(s8 drive, u32 mode);
|
||||
|
||||
FAError FAFormat(s8 drive, u32 mode) {
|
||||
s32 error = pfstub_format(drive, mode);
|
||||
return (-error | error) >> 31;
|
||||
}
|
||||
8
libs/RVL_SDK/src/fa/api/FAFseek.c
Normal file
8
libs/RVL_SDK/src/fa/api/FAFseek.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
extern s32 pfstub_fseek(FAFILE* stream, s32 offset, int origin);
|
||||
|
||||
FAError FAFseek(FAFILE* stream, s32 offset, int origin) {
|
||||
s32 error = pfstub_fseek(stream, offset, origin);
|
||||
return (-error | error) >> 31;
|
||||
}
|
||||
8
libs/RVL_SDK/src/fa/api/FAFsfirst.c
Normal file
8
libs/RVL_SDK/src/fa/api/FAFsfirst.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
extern s32 pfstub_fsfirst(const char* dirName, u8 attr, FADta* dta);
|
||||
|
||||
FAError FAFsfirst(const char* dirName, u8 attr, FADta* dta) {
|
||||
s32 error = pfstub_fsfirst(dirName, attr, dta);
|
||||
return (-error | error) >> 31;
|
||||
}
|
||||
8
libs/RVL_SDK/src/fa/api/FAFsnext.c
Normal file
8
libs/RVL_SDK/src/fa/api/FAFsnext.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
extern s32 pfstub_fsnext(FADta* dta);
|
||||
|
||||
FAError FAFsnext(FADta* dta) {
|
||||
s32 error = pfstub_fsnext(dta);
|
||||
return (-error | error) >> 31;
|
||||
}
|
||||
8
libs/RVL_SDK/src/fa/api/FAFstat.c
Normal file
8
libs/RVL_SDK/src/fa/api/FAFstat.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
extern s32 pfstub_fstat(const char* fileName, FAFileStat* stat);
|
||||
|
||||
FAError FAFstat(const char* fileName, FAFileStat* stat) {
|
||||
s32 error = pfstub_fstat(fileName, stat);
|
||||
return (-error | error) >> 31;
|
||||
}
|
||||
8
libs/RVL_SDK/src/fa/api/FAGetdev.c
Normal file
8
libs/RVL_SDK/src/fa/api/FAGetdev.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
extern s32 pfstub_devinf(s8 drive, FADevInf* data);
|
||||
|
||||
FAError FAGetdev(s8 drive, FADevInf* data) {
|
||||
s32 error = pfstub_devinf(drive, data);
|
||||
return (-error | error) >> 31;
|
||||
}
|
||||
36
libs/RVL_SDK/src/fa/api/FAInit.c
Normal file
36
libs/RVL_SDK/src/fa/api/FAInit.c
Normal file
@@ -0,0 +1,36 @@
|
||||
#include <revolution/fa.h>
|
||||
#include <revolution/os.h>
|
||||
|
||||
char* __FAVersion = "<< RVL_SDK - FA \trelease build: Apr 20 2010 11:20:14 (0x4199_60831) >>";
|
||||
s32 FAFileSysInitialized;
|
||||
s32 FAInInitializing;
|
||||
extern s32 FADiskInitialized;
|
||||
extern s32 pdm_init_diskmanager(s32 config, void* parameter);
|
||||
extern s32 pfstub_init_prfile2(s32 config, void* parameter);
|
||||
|
||||
FAError FAInit(int flag) {
|
||||
s32 error;
|
||||
if (FAInInitializing == 1) {
|
||||
return -1;
|
||||
}
|
||||
FAInInitializing = 1;
|
||||
if (!FADiskInitialized) {
|
||||
error = pdm_init_diskmanager(0, NULL);
|
||||
FADiskInitialized = error == 0;
|
||||
if (error != 0) {
|
||||
FAInInitializing = 0;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (!FAFileSysInitialized) {
|
||||
error = pfstub_init_prfile2(flag, NULL);
|
||||
FAFileSysInitialized = error == 0;
|
||||
if (error == -1) {
|
||||
FAInInitializing = 0;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
FAInInitializing = 0;
|
||||
OSRegisterVersion(__FAVersion);
|
||||
return 0;
|
||||
}
|
||||
8
libs/RVL_SDK/src/fa/api/FAMount.c
Normal file
8
libs/RVL_SDK/src/fa/api/FAMount.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
extern s32 pfstub_mount(s8 drive);
|
||||
|
||||
FAError FAMount(s8 drive) {
|
||||
s32 error = pfstub_mount(drive);
|
||||
return (-error | error) >> 31;
|
||||
}
|
||||
63
libs/RVL_SDK/src/fa/api/FARegistCB.c
Normal file
63
libs/RVL_SDK/src/fa/api/FARegistCB.c
Normal file
@@ -0,0 +1,63 @@
|
||||
#include <revolution/fa/types.h>
|
||||
|
||||
typedef struct FA_MEDIA_CALLBACKS {
|
||||
FAInsertCallback sd_insert;
|
||||
FAEjectCallback sd_eject;
|
||||
FAInsertCallback usb_insert;
|
||||
FAEjectCallback usb_eject;
|
||||
u32 flags;
|
||||
} FA_MEDIA_CALLBACKS;
|
||||
|
||||
FA_MEDIA_CALLBACKS gMediaInOutCallback;
|
||||
extern s32 pfd_sddrv_registar_callback(FAInsertCallback insert, FAEjectCallback eject);
|
||||
extern s32 pfd_mscdrv_registar_callback(FAInsertCallback insert, FAEjectCallback eject);
|
||||
void FANotifySDInsert(s8 drive);
|
||||
void FANotifySDEject(s8 drive);
|
||||
void FANotifyUSBInsert(s8 drive);
|
||||
void FANotifyUSBEject(s8 drive);
|
||||
|
||||
FAError FARegistCB(s32 device, FAInsertCallback insert, FAEjectCallback eject) {
|
||||
s32 error;
|
||||
switch (device) {
|
||||
case 0:
|
||||
gMediaInOutCallback.sd_insert = insert;
|
||||
gMediaInOutCallback.sd_eject = eject;
|
||||
error = pfd_sddrv_registar_callback(FANotifySDInsert, FANotifySDEject);
|
||||
break;
|
||||
case 1:
|
||||
gMediaInOutCallback.usb_insert = insert;
|
||||
gMediaInOutCallback.usb_eject = eject;
|
||||
error = pfd_mscdrv_registar_callback(FANotifyUSBInsert, FANotifyUSBEject);
|
||||
break;
|
||||
default:
|
||||
return -2;
|
||||
}
|
||||
if (error != 0) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void FANotifySDInsert(s8 drive) {
|
||||
if (gMediaInOutCallback.sd_insert) {
|
||||
gMediaInOutCallback.sd_insert(drive);
|
||||
}
|
||||
}
|
||||
|
||||
void FANotifySDEject(s8 drive) {
|
||||
if (gMediaInOutCallback.sd_eject) {
|
||||
gMediaInOutCallback.sd_eject(drive);
|
||||
}
|
||||
}
|
||||
|
||||
void FANotifyUSBInsert(s8 drive) {
|
||||
if (gMediaInOutCallback.usb_insert) {
|
||||
gMediaInOutCallback.usb_insert(drive);
|
||||
}
|
||||
}
|
||||
|
||||
void FANotifyUSBEject(s8 drive) {
|
||||
if (gMediaInOutCallback.usb_eject) {
|
||||
gMediaInOutCallback.usb_eject(drive);
|
||||
}
|
||||
}
|
||||
8
libs/RVL_SDK/src/fa/api/FARemove.c
Normal file
8
libs/RVL_SDK/src/fa/api/FARemove.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
extern s32 pfstub_remove(const char* fileName);
|
||||
|
||||
FAError FARemove(const char* fileName) {
|
||||
s32 error = pfstub_remove(fileName);
|
||||
return (-error | error) >> 31;
|
||||
}
|
||||
13
libs/RVL_SDK/src/fa/api/FASetThreadPriority.c
Normal file
13
libs/RVL_SDK/src/fa/api/FASetThreadPriority.c
Normal file
@@ -0,0 +1,13 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
extern s32 pfstub_set_stub_priority(s32 priority);
|
||||
extern s32 usbh_msc_set_thread_priority(s32 priority);
|
||||
|
||||
FAError FASetThreadPriority(s32 priority) {
|
||||
s32 error = pfstub_set_stub_priority(priority);
|
||||
if (error != 0) {
|
||||
return error == -2 ? -2 : -1;
|
||||
}
|
||||
error = usbh_msc_set_thread_priority(priority);
|
||||
return (-error | error) >> 31;
|
||||
}
|
||||
17
libs/RVL_SDK/src/fa/api/FAUnmount.c
Normal file
17
libs/RVL_SDK/src/fa/api/FAUnmount.c
Normal file
@@ -0,0 +1,17 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
extern s32 pfstub_unmount(s8 drive, u32 force);
|
||||
|
||||
FAError FAUnmount(s8 drive, u32 force) {
|
||||
s32 error = pfstub_unmount(drive, force);
|
||||
if (error == -1) {
|
||||
error = -1;
|
||||
} else if (error == 1) {
|
||||
error = 1;
|
||||
} else if (error == 0) {
|
||||
error = 0;
|
||||
} else {
|
||||
error = -1;
|
||||
}
|
||||
return error;
|
||||
}
|
||||
16
libs/RVL_SDK/src/fa/driver/msc_drv.c
Normal file
16
libs/RVL_SDK/src/fa/driver/msc_drv.c
Normal file
@@ -0,0 +1,16 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
static FAInsertCallback g_attach_func;
|
||||
static FAEjectCallback g_detach_func;
|
||||
|
||||
extern s32 uhf_msc_is_media_insert(void);
|
||||
|
||||
s32 pfd_mscdrv_registar_callback(FAInsertCallback insert, FAEjectCallback eject) {
|
||||
g_attach_func = insert;
|
||||
g_detach_func = eject;
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 pfd_mscdrv_is_media_insert(void) {
|
||||
return uhf_msc_is_media_insert();
|
||||
}
|
||||
39
libs/RVL_SDK/src/fa/driver/pfd_cmn.c
Normal file
39
libs/RVL_SDK/src/fa/driver/pfd_cmn.c
Normal file
@@ -0,0 +1,39 @@
|
||||
#include <private/fa/pdm.h>
|
||||
#include <private/fa/pf_volume.h>
|
||||
|
||||
extern PF_VOLUME_SET pf_vol_set;
|
||||
extern pf_s32 pdm_part_is_attached_partition(PDM_PARTITION* partition);
|
||||
|
||||
pf_u8 pfd_get_media_drv_char(PDM_DISK* disk, pf_s8* drives, pf_u32 capacity) {
|
||||
pf_u32 partition_index;
|
||||
PDM_PARTITION* partition;
|
||||
PF_VOLUME* volume;
|
||||
pf_u8 count;
|
||||
pf_s8* next_drive;
|
||||
pf_u32 volume_index;
|
||||
if (drives == NULL || capacity == 0) {
|
||||
return 0;
|
||||
}
|
||||
next_drive = drives;
|
||||
count = 0;
|
||||
partition = pdm_disk_set.partition;
|
||||
for (partition_index = 0; partition_index < 26; partition_index++, partition++) {
|
||||
if (pdm_part_is_attached_partition(partition) && partition->p_disk == disk) {
|
||||
volume = pf_vol_set.volumes;
|
||||
for (volume_index = 0; volume_index < 26; volume++) {
|
||||
volume_index++;
|
||||
if (volume->p_part == partition) {
|
||||
count++;
|
||||
*next_drive++ = volume->drv_char;
|
||||
if (count == capacity) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count == capacity) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
@@ -1030,13 +1030,13 @@ s32 pfd_sddrv_build_mbr_bpb(u32 total_sectors) {
|
||||
}
|
||||
|
||||
s32 pfd_sddrv_calc_fat32_mbr_bpb(PFD_SDDRV_FORMAT_DATA* format_data) {
|
||||
PFD_SDDRV_SIZE_SETTINGS settings;
|
||||
const PFD_SDDRV_SIZE_DEPEND* size_entry;
|
||||
u32 entry_index;
|
||||
u32 cluster_count;
|
||||
u32 fat_sectors;
|
||||
u32 fat_sector_count;
|
||||
u32 available_sectors;
|
||||
u32 fat_sector_count;
|
||||
u32 fat_sectors;
|
||||
u32 cluster_count;
|
||||
u32 entry_index;
|
||||
const PFD_SDDRV_SIZE_DEPEND* size_entry;
|
||||
PFD_SDDRV_SIZE_SETTINGS settings;
|
||||
u32 reserved_sectors = 0;
|
||||
u32 data_start_sector;
|
||||
u32 calculated_fat_sectors;
|
||||
@@ -1153,7 +1153,7 @@ s32 pfd_sddrv_store_fat32_mbr_buf(PFD_SDDRV_FORMAT_DATA* format_data, u8* sector
|
||||
}
|
||||
pf_memset(&settings, 0, 0x10);
|
||||
size_entry = sddrv_size_depend_tbl;
|
||||
for (entry_index = 0; entry_index < 14; entry_index++, size_entry++) {
|
||||
for (entry_index = 0; entry_index < 14; size_entry++, entry_index++) {
|
||||
if (size_entry->min_sectors < format_data->total_sectors && format_data->total_sectors <= size_entry->max_sectors) {
|
||||
settings.reserved_sectors = sddrv_size_depend_tbl[entry_index].reserved_sectors;
|
||||
settings.fat_copies = sddrv_size_depend_tbl[entry_index].fat_copies;
|
||||
@@ -1430,11 +1430,10 @@ s32 pfd_sddrv_build_fat32_mbr_bpb(u32 total_sectors) {
|
||||
}
|
||||
|
||||
s32 pfd_sddrv_full_format(void) {
|
||||
s32 result;
|
||||
u32 retry_count;
|
||||
u16 bytes_per_sector;
|
||||
u32 total_sectors;
|
||||
FADiskInfo geometry;
|
||||
u32 status;
|
||||
u32 retry_count;
|
||||
s32 result;
|
||||
|
||||
retry_count = 0;
|
||||
do {
|
||||
@@ -1466,21 +1465,21 @@ s32 pfd_sddrv_full_format(void) {
|
||||
if (g_pfd_sddrv_info.media_ejected != 0) {
|
||||
return -33;
|
||||
}
|
||||
result = pfd_sddrv_get_total_sectors(&total_sectors, &bytes_per_sector);
|
||||
result = pfd_sddrv_get_total_sectors(&geometry.totalSectors, &geometry.bytesPerSector);
|
||||
if (result != 0) {
|
||||
OSReport("ERR Failed to get total sectors. pfd_sddrv_get_total_sectors()\n");
|
||||
return result;
|
||||
}
|
||||
if ((status & 0x10000) != 0 && (status & 0x100000) == 0) {
|
||||
if (total_sectors > 0x400000) {
|
||||
if (geometry.totalSectors > 0x400000) {
|
||||
return -34;
|
||||
}
|
||||
result = pfd_sddrv_build_mbr_bpb(total_sectors);
|
||||
result = pfd_sddrv_build_mbr_bpb(geometry.totalSectors);
|
||||
} else if ((status & 0x10000) != 0 && (status & 0x100000) != 0) {
|
||||
if (total_sectors > 0x4000000) {
|
||||
if (geometry.totalSectors > 0x4000000) {
|
||||
return -34;
|
||||
}
|
||||
result = pfd_sddrv_build_fat32_mbr_bpb(total_sectors);
|
||||
result = pfd_sddrv_build_fat32_mbr_bpb(geometry.totalSectors);
|
||||
} else {
|
||||
return -31;
|
||||
}
|
||||
|
||||
121
libs/RVL_SDK/src/fa/kernel/pfk_api.c
Normal file
121
libs/RVL_SDK/src/fa/kernel/pfk_api.c
Normal file
@@ -0,0 +1,121 @@
|
||||
#include <private/fa/pf_kernel.h>
|
||||
|
||||
s32 pfk_create_task(PFK_TASK_CONFIG* config) {
|
||||
if (config == NULL) {
|
||||
OSReport("prfile2:ERR pfk_create_task() invalid param\n");
|
||||
return 0;
|
||||
}
|
||||
if (!OSCreateThread(config->thread, config->entry, config->argument,
|
||||
(u8*)config->stack + config->stack_size, config->stack_size,
|
||||
config->priority, 0)) {
|
||||
OSReport("prfile2:ERR pfk_create_task() failed to create thread\n");
|
||||
return 0;
|
||||
}
|
||||
return (s32)config->thread;
|
||||
}
|
||||
|
||||
s32 pfk_start_task(s32 task_id) {
|
||||
if (task_id == 0) {
|
||||
OSReport("prfile2:ERR pfk_start_task() invalid tsk_id\n");
|
||||
return -2;
|
||||
}
|
||||
if (OSIsThreadSuspended((OSThread*)task_id) == TRUE) {
|
||||
OSResumeThread((OSThread*)task_id);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 pfk_get_task_id(s32* task_id) {
|
||||
OSThread* thread;
|
||||
if (task_id == NULL) {
|
||||
OSReport("prfile2:ERR pfk_get_task_id() invalid param\n");
|
||||
return -2;
|
||||
}
|
||||
thread = OSGetCurrentThread();
|
||||
if (thread == NULL) {
|
||||
OSReport("INFO failed to OSGetCurrentThread\n");
|
||||
*task_id = 0;
|
||||
return -3;
|
||||
}
|
||||
*task_id = (s32)thread;
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 pfk_set_task_priority(s32 task_id, s32 priority) {
|
||||
if (priority < 0 || priority > 31) {
|
||||
return -2;
|
||||
}
|
||||
return OSSetThreadPriority((OSThread*)task_id, priority) == TRUE ? 0 : -3;
|
||||
}
|
||||
|
||||
s32 pfk_create_mailbox(PFK_MAILBOX_CONFIG* config) {
|
||||
if (config == NULL || config->queue == NULL || config->messages == NULL) {
|
||||
OSReport("prfile2:ERR pfk_create_mailbox() Invalid Param\n");
|
||||
return 0;
|
||||
}
|
||||
OSInitMessageQueue(config->queue, config->messages, config->count);
|
||||
return (s32)config->queue;
|
||||
}
|
||||
|
||||
s32 pfk_receive_message(s32 mailbox, OSMessage* message) {
|
||||
if (mailbox == 0) {
|
||||
OSReport("prfile2:ERR pfk_receive_message() Invalid Param\n");
|
||||
return -2;
|
||||
}
|
||||
if (!OSReceiveMessage((OSMessageQueue*)mailbox, message, OS_MESSAGE_BLOCK)) {
|
||||
OSReport("prfile2:ERR pfk_receive_message() Faile to OSReceiveMessage()\n");
|
||||
return -3;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 pfk_send_message(s32 mailbox, OSMessage message) {
|
||||
if (mailbox == 0 || message == NULL) {
|
||||
OSReport("prfile2:ERR pfk_send_message() Invalid Param\n");
|
||||
return -2;
|
||||
}
|
||||
if (!OSSendMessage((OSMessageQueue*)mailbox, message, 0)) {
|
||||
OSReport("prfile2:ERR pfk_send_message() Failed to pfk_send_message()\n");
|
||||
return -3;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 pfk_create_semaphore(PFK_SEMAPHORE_CONFIG* config) {
|
||||
u32 count;
|
||||
if (config == NULL || config->semaphore == NULL || config->initial_count > config->maximum_count) {
|
||||
OSReport("prfile2:ERR pfk_create_semaphore() Invalid Param\n");
|
||||
return 0;
|
||||
}
|
||||
OSInitSemaphore(config->semaphore, config->maximum_count);
|
||||
for (count = config->maximum_count - config->initial_count; count != 0; count--) {
|
||||
OSWaitSemaphore(config->semaphore);
|
||||
}
|
||||
return (s32)config->semaphore;
|
||||
}
|
||||
|
||||
s32 pfk_delete_semaphore(s32 semaphore) {
|
||||
if (semaphore == 0) {
|
||||
OSReport("prfile2:ERR pfk_delete_semaphore() Invalid Param\n");
|
||||
return -2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 pfk_get_semaphore(s32 semaphore) {
|
||||
if (semaphore == 0) {
|
||||
OSReport("prfile2:ERR pfk_get_semaphore() Invalid Param\n");
|
||||
return -2;
|
||||
}
|
||||
OSWaitSemaphore((OSSemaphore*)semaphore);
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 pfk_release_semaphore(s32 semaphore) {
|
||||
if (semaphore == 0) {
|
||||
OSReport("prfile2:ERR pfk_release_semaphore() Invalid Param\n");
|
||||
return -2;
|
||||
}
|
||||
OSSignalSemaphore((OSSemaphore*)semaphore);
|
||||
return 0;
|
||||
}
|
||||
80
libs/RVL_SDK/src/fa/msc/puh_msc.c
Normal file
80
libs/RVL_SDK/src/fa/msc/puh_msc.c
Normal file
@@ -0,0 +1,80 @@
|
||||
#include <private/fa/puh_msc.h>
|
||||
|
||||
static s32 st_uhs_msc_status;
|
||||
static s32 st_uhs_msc_msgid;
|
||||
static s32 st_uhs_msc_tskid;
|
||||
s32 uhg_msc_memid_8169971C;
|
||||
static s32 _uhf_msc_api_send_message(UHF_MSC_PARAMETERS* parameters, u32 command);
|
||||
|
||||
s32 usbh_msc_read10(UHF_MSC_DEVICE* device, u32 sector, u16 count, void* buffer, void* sense) {
|
||||
UHF_MSC_PARAMETERS parameters = {0};
|
||||
if (st_uhs_msc_status != 1) {
|
||||
return -3;
|
||||
}
|
||||
parameters.device = device;
|
||||
parameters.sector = sector;
|
||||
parameters.block_count = count;
|
||||
parameters.buffer = buffer;
|
||||
parameters.sense = sense;
|
||||
return _uhf_msc_api_send_message(¶meters, 0x1010a00);
|
||||
}
|
||||
|
||||
s32 usbh_msc_write10(UHF_MSC_DEVICE* device, u32 sector, u16 count, void* buffer, void* sense) {
|
||||
UHF_MSC_PARAMETERS parameters = {0};
|
||||
if (st_uhs_msc_status != 1) {
|
||||
return -3;
|
||||
}
|
||||
parameters.device = device;
|
||||
parameters.sector = sector;
|
||||
parameters.block_count = count;
|
||||
parameters.buffer = buffer;
|
||||
parameters.sense = sense;
|
||||
return _uhf_msc_api_send_message(¶meters, 0x1010b00);
|
||||
}
|
||||
|
||||
s32 usbh_msc_set_thread_priority(s32 priority) {
|
||||
s32 error;
|
||||
if (st_uhs_msc_tskid != 0) {
|
||||
error = uhf_ker_set_priority(st_uhs_msc_tskid, priority);
|
||||
if (error != 0) {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static s32 _uhf_msc_api_send_message(UHF_MSC_PARAMETERS* parameters, u32 command) {
|
||||
s32 result = 0;
|
||||
s32 semaphore;
|
||||
UHF_MSC_MESSAGE* message;
|
||||
message = uhf_ker_get_memory_block(uhg_msc_memid_8169971C, sizeof(UHF_MSC_MESSAGE), 4);
|
||||
if (message == NULL) {
|
||||
return -12;
|
||||
}
|
||||
semaphore = uhf_ker_create_sem(0, 0);
|
||||
if (semaphore <= 0) {
|
||||
uhf_ker_release_memory_block(uhg_msc_memid_8169971C, message);
|
||||
return -12;
|
||||
}
|
||||
message->command = command;
|
||||
message->semaphore = semaphore;
|
||||
message->result = &result;
|
||||
message->parameters = *parameters;
|
||||
if (uhf_ker_send_message(st_uhs_msc_msgid, message, 0) != 0) {
|
||||
uhf_ker_release_memory_block(uhg_msc_memid_8169971C, message);
|
||||
uhf_ker_delete_sem(semaphore);
|
||||
return -12;
|
||||
}
|
||||
if (uhf_ker_get_sem(semaphore) != 0) {
|
||||
uhf_ker_delete_sem(semaphore);
|
||||
return -12;
|
||||
}
|
||||
if (uhf_ker_delete_sem(semaphore) != 0) {
|
||||
return -12;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
s32 uhf_msc_get_message_id(void) {
|
||||
return st_uhs_msc_msgid;
|
||||
}
|
||||
318
libs/RVL_SDK/src/fa/msc/puh_msc_blk.c
Normal file
318
libs/RVL_SDK/src/fa/msc/puh_msc_blk.c
Normal file
@@ -0,0 +1,318 @@
|
||||
#include <private/fa/puh_msc.h>
|
||||
#include <string.h>
|
||||
|
||||
UHF_MSC_DEVICE uhg_msc_blk_device_tbl[8];
|
||||
static u8* st_uhs_msc_blk_buf;
|
||||
extern void pdm_disk_notify_media_insert(FADisk* disk);
|
||||
s32 uhf_msc_blk_init(FADisk* disk);
|
||||
s32 uhf_msc_blk_finalize(FADisk* disk);
|
||||
s32 uhf_msc_blk_mount(FADisk* disk);
|
||||
s32 uhf_msc_blk_unmount(FADisk* disk);
|
||||
s32 uhf_msc_blk_format(FADisk* disk, u8* format);
|
||||
s32 uhf_msc_blk_pread(FADisk* disk, u8* buffer, u32 sector, u32 blocks, u32* completed);
|
||||
s32 uhf_msc_blk_pwrite(FADisk* disk, u8* buffer, u32 sector, u32 blocks, u32* completed);
|
||||
s32 uhf_msc_blk_get_disk_info(FADisk* disk, FADiskInfo* info);
|
||||
s32 _uhf_msc_blk_send_message(UHF_MSC_PARAMETERS* parameters, u32 command);
|
||||
|
||||
FAFuncTbl st_uhs_msc_blk_func = {
|
||||
uhf_msc_blk_init,
|
||||
uhf_msc_blk_finalize,
|
||||
uhf_msc_blk_mount,
|
||||
uhf_msc_blk_unmount,
|
||||
uhf_msc_blk_format,
|
||||
uhf_msc_blk_pread,
|
||||
uhf_msc_blk_pwrite,
|
||||
uhf_msc_blk_get_disk_info,
|
||||
};
|
||||
|
||||
static inline UHF_MSC_DEVICE* uhf_msc_blk_find_device(FADisk* disk) {
|
||||
UHF_MSC_DEVICE* entry = uhg_msc_blk_device_tbl;
|
||||
UHF_MSC_DEVICE* device = NULL;
|
||||
u32 index;
|
||||
for (index = 0; index < 8; entry++, index++) {
|
||||
if (entry->disk == disk) {
|
||||
device = &uhg_msc_blk_device_tbl[index];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return device;
|
||||
}
|
||||
|
||||
s32 usbh_msc_blk_init_drv_tbl(FADiskTbl* table, u32 extension) {
|
||||
if (table == NULL) {
|
||||
return -1;
|
||||
}
|
||||
table->uiExt = extension;
|
||||
table->pFunc = (FAFuncTbl*)&st_uhs_msc_blk_func;
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 uhf_msc_blk_init(FADisk* disk) {
|
||||
UHF_MSC_PARAMETERS parameters = {0};
|
||||
parameters.disk = disk;
|
||||
return _uhf_msc_blk_send_message(¶meters, 0x1010005);
|
||||
}
|
||||
|
||||
s32 uhf_msc_blk_get_disk_info(FADisk* disk, FADiskInfo* info) {
|
||||
UHF_MSC_DEVICE* device;
|
||||
if (disk == NULL || info == NULL) {
|
||||
return -1;
|
||||
}
|
||||
device = uhf_msc_blk_find_device(disk);
|
||||
if (device == NULL) {
|
||||
return -1;
|
||||
}
|
||||
info->totalSectors = device->total_blocks;
|
||||
info->cylinders = 0;
|
||||
info->heads = 0;
|
||||
info->sectorsPerTrack = 0;
|
||||
info->bytesPerSector = device->block_size;
|
||||
info->mediaAttr = 0;
|
||||
if (device->flags & 0x1000) {
|
||||
info->mediaAttr |= 1;
|
||||
}
|
||||
info->formatParam = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 uhf_msc_blk_mount(FADisk* disk) {
|
||||
UHF_MSC_DEVICE* device;
|
||||
if (disk == NULL) {
|
||||
return -1;
|
||||
}
|
||||
device = uhf_msc_blk_find_device(disk);
|
||||
if (device == NULL) {
|
||||
return -1;
|
||||
}
|
||||
return ((device->flags >> 2) & 1) - 1;
|
||||
}
|
||||
|
||||
s32 uhf_msc_blk_pread(FADisk* disk, u8* buffer, u32 sector, u32 blocks, u32* completed) {
|
||||
u16 transfer_blocks;
|
||||
UHF_MSC_DEVICE* device;
|
||||
s32 error;
|
||||
u32 block_size;
|
||||
u8* transfer_buffer;
|
||||
u32 transfer_limit;
|
||||
s32 cacheable;
|
||||
u8 sense[3] = {0};
|
||||
|
||||
*completed = 0;
|
||||
if (disk == NULL || buffer == NULL) {
|
||||
return -1;
|
||||
}
|
||||
if (blocks == 0) {
|
||||
return 0;
|
||||
}
|
||||
device = uhf_msc_blk_find_device(disk);
|
||||
if (device == NULL) {
|
||||
return -1;
|
||||
}
|
||||
if (!(device->flags & 4)) {
|
||||
return -1;
|
||||
}
|
||||
block_size = device->block_size;
|
||||
if (block_size == 0) {
|
||||
return -1;
|
||||
}
|
||||
if (uhf_ker_check_cacheable(buffer) == 0) {
|
||||
transfer_limit = 512 / block_size;
|
||||
if (transfer_limit == 0) {
|
||||
return -1;
|
||||
}
|
||||
memset(st_uhs_msc_blk_buf, 0, 512);
|
||||
cacheable = 0;
|
||||
transfer_buffer = st_uhs_msc_blk_buf;
|
||||
} else {
|
||||
transfer_limit = 65536 / block_size;
|
||||
cacheable = 1;
|
||||
transfer_buffer = buffer;
|
||||
}
|
||||
do {
|
||||
transfer_blocks = transfer_limit;
|
||||
if (blocks <= transfer_limit) {
|
||||
transfer_blocks = blocks;
|
||||
}
|
||||
error = usbh_msc_read10(device, sector, transfer_blocks, transfer_buffer, sense);
|
||||
if (error == 0) {
|
||||
if (!cacheable) {
|
||||
memcpy(buffer, transfer_buffer, transfer_blocks * block_size);
|
||||
buffer += transfer_blocks * block_size;
|
||||
} else {
|
||||
transfer_buffer += transfer_blocks * block_size;
|
||||
}
|
||||
blocks -= transfer_blocks;
|
||||
sector += transfer_blocks;
|
||||
*completed += transfer_blocks;
|
||||
if (blocks == 0) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (error == -15) {
|
||||
switch (__uhf_msc_cmd_check_sense(sense)) {
|
||||
case 11:
|
||||
break;
|
||||
case 34:
|
||||
if (device->disk != NULL) {
|
||||
pdm_disk_notify_media_insert(device->disk);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
error = -1;
|
||||
break;
|
||||
} else {
|
||||
error = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while (1);
|
||||
return error;
|
||||
}
|
||||
|
||||
s32 uhf_msc_blk_pwrite(FADisk* disk, u8* buffer, u32 sector, u32 blocks, u32* completed) {
|
||||
u16 transfer_blocks;
|
||||
UHF_MSC_DEVICE* device;
|
||||
u32 block_size;
|
||||
s32 error;
|
||||
u8* transfer_buffer;
|
||||
u32 transfer_limit;
|
||||
s32 cacheable;
|
||||
u8 sense[3] = {0};
|
||||
|
||||
*completed = 0;
|
||||
if (disk == NULL || buffer == NULL) {
|
||||
return -1;
|
||||
}
|
||||
if (blocks == 0) {
|
||||
return 0;
|
||||
}
|
||||
device = uhf_msc_blk_find_device(disk);
|
||||
if (device == NULL) {
|
||||
return -1;
|
||||
}
|
||||
if (!(device->flags & 4)) {
|
||||
return -1;
|
||||
}
|
||||
block_size = device->block_size;
|
||||
if (block_size == 0) {
|
||||
return -1;
|
||||
}
|
||||
if (uhf_ker_check_cacheable(buffer) == 0) {
|
||||
transfer_limit = 512 / block_size;
|
||||
if (transfer_limit == 0) {
|
||||
return -1;
|
||||
}
|
||||
cacheable = 0;
|
||||
transfer_buffer = st_uhs_msc_blk_buf;
|
||||
} else {
|
||||
transfer_limit = 65536 / block_size;
|
||||
cacheable = 1;
|
||||
transfer_buffer = buffer;
|
||||
}
|
||||
do {
|
||||
transfer_blocks = transfer_limit;
|
||||
if (blocks <= transfer_limit) {
|
||||
transfer_blocks = blocks;
|
||||
}
|
||||
if (!cacheable) {
|
||||
memcpy(transfer_buffer, buffer, transfer_blocks * block_size);
|
||||
}
|
||||
error = usbh_msc_write10(device, sector, transfer_blocks, transfer_buffer, sense);
|
||||
if (error == 0) {
|
||||
if (!cacheable) {
|
||||
buffer += transfer_blocks * block_size;
|
||||
}
|
||||
if (cacheable) {
|
||||
transfer_buffer += transfer_blocks * block_size;
|
||||
}
|
||||
blocks -= transfer_blocks;
|
||||
sector += transfer_blocks;
|
||||
*completed += transfer_blocks;
|
||||
if (blocks == 0) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (error == -15) {
|
||||
switch (__uhf_msc_cmd_check_sense(sense)) {
|
||||
case 11:
|
||||
case 37:
|
||||
break;
|
||||
case 34:
|
||||
if (device->disk != NULL) {
|
||||
pdm_disk_notify_media_insert(device->disk);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
error = -1;
|
||||
break;
|
||||
} else {
|
||||
error = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while (1);
|
||||
return error;
|
||||
}
|
||||
|
||||
s32 uhf_msc_blk_format(FADisk* disk, u8* format) {
|
||||
return disk == NULL ? -1 : 0;
|
||||
}
|
||||
|
||||
s32 uhf_msc_blk_finalize(FADisk* disk) {
|
||||
UHF_MSC_PARAMETERS parameters = {0};
|
||||
parameters.disk = disk;
|
||||
return _uhf_msc_blk_send_message(¶meters, 0x1010006);
|
||||
}
|
||||
|
||||
s32 uhf_msc_blk_unmount(FADisk* disk) {
|
||||
return disk == NULL ? -1 : 0;
|
||||
}
|
||||
|
||||
s32 uhf_msc_is_media_insert(FADisk* disk) {
|
||||
UHF_MSC_DEVICE* device = uhf_msc_blk_find_device(disk);
|
||||
if (device == NULL) {
|
||||
return 0;
|
||||
}
|
||||
if (!(device->flags & 4)) {
|
||||
return 0;
|
||||
}
|
||||
pdm_disk_notify_media_insert(disk);
|
||||
return 1;
|
||||
}
|
||||
|
||||
s32 _uhf_msc_blk_send_message(UHF_MSC_PARAMETERS* parameters, u32 command) {
|
||||
s32 result = 0;
|
||||
s32 semaphore;
|
||||
UHF_MSC_MESSAGE* message;
|
||||
s32 mailbox = uhf_msc_get_message_id();
|
||||
message = uhf_ker_get_memory_block(uhg_msc_memid_8169971C, sizeof(UHF_MSC_MESSAGE), 4);
|
||||
if (message == NULL) {
|
||||
return -1;
|
||||
}
|
||||
semaphore = uhf_ker_create_sem(0, 0);
|
||||
if (semaphore <= 0) {
|
||||
uhf_ker_release_memory_block(uhg_msc_memid_8169971C, message);
|
||||
return -1;
|
||||
}
|
||||
message->command = command;
|
||||
message->semaphore = semaphore;
|
||||
message->result = &result;
|
||||
message->parameters = *parameters;
|
||||
if (uhf_ker_send_message(mailbox, message, 0) != 0) {
|
||||
uhf_ker_release_memory_block(uhg_msc_memid_8169971C, message);
|
||||
uhf_ker_delete_sem(semaphore);
|
||||
return -1;
|
||||
}
|
||||
if (uhf_ker_get_sem(semaphore) != 0) {
|
||||
uhf_ker_delete_sem(semaphore);
|
||||
return -1;
|
||||
}
|
||||
if (uhf_ker_delete_sem(semaphore) != 0) {
|
||||
return -1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
94
libs/RVL_SDK/src/fa/msc/puh_msc_cmd.c
Normal file
94
libs/RVL_SDK/src/fa/msc/puh_msc_cmd.c
Normal file
@@ -0,0 +1,94 @@
|
||||
#include <revolution/types.h>
|
||||
|
||||
typedef struct UHF_MSC_SENSE {
|
||||
u8 key;
|
||||
u8 code;
|
||||
u8 qualifier;
|
||||
} UHF_MSC_SENSE;
|
||||
|
||||
s32 __uhf_msc_cmd_check_sense(const UHF_MSC_SENSE* sense) {
|
||||
s32 code = (sense->key << 16) | (sense->code << 8) | sense->qualifier;
|
||||
switch (code) {
|
||||
case 0x0:
|
||||
return 0;
|
||||
case 0x11701:
|
||||
return 1;
|
||||
case 0x11800:
|
||||
return 2;
|
||||
case 0x20401:
|
||||
return 3;
|
||||
case 0x20402:
|
||||
return 4;
|
||||
case 0x20404:
|
||||
return 5;
|
||||
case 0x204ff:
|
||||
return 6;
|
||||
case 0x20600:
|
||||
return 7;
|
||||
case 0x20800:
|
||||
return 8;
|
||||
case 0x20801:
|
||||
return 9;
|
||||
case 0x20880:
|
||||
return 10;
|
||||
case 0x23a00:
|
||||
return 11;
|
||||
case 0x25400:
|
||||
return 12;
|
||||
case 0x28000:
|
||||
return 13;
|
||||
case 0x2ffff:
|
||||
return 14;
|
||||
case 0x30200:
|
||||
return 15;
|
||||
case 0x30300:
|
||||
return 16;
|
||||
case 0x31000:
|
||||
return 17;
|
||||
case 0x31100:
|
||||
return 18;
|
||||
case 0x31200:
|
||||
return 19;
|
||||
case 0x31300:
|
||||
return 20;
|
||||
case 0x31400:
|
||||
return 21;
|
||||
case 0x33001:
|
||||
return 22;
|
||||
case 0x33101:
|
||||
return 23;
|
||||
case 0x51a00:
|
||||
return 25;
|
||||
case 0x52000:
|
||||
return 26;
|
||||
case 0x52100:
|
||||
return 27;
|
||||
case 0x52400:
|
||||
return 28;
|
||||
case 0x52500:
|
||||
return 29;
|
||||
case 0x52600:
|
||||
return 30;
|
||||
case 0x52601:
|
||||
return 31;
|
||||
case 0x52602:
|
||||
return 32;
|
||||
case 0x53900:
|
||||
return 33;
|
||||
case 0x62800:
|
||||
return 34;
|
||||
case 0x62900:
|
||||
return 35;
|
||||
case 0x62f00:
|
||||
return 36;
|
||||
case 0x72700:
|
||||
return 37;
|
||||
case 0xb4e00:
|
||||
return 38;
|
||||
default:
|
||||
if ((u32)((sense->key << 8) | sense->code) == 0x0440) {
|
||||
return 24;
|
||||
}
|
||||
return 39;
|
||||
}
|
||||
}
|
||||
34
libs/RVL_SDK/src/fa/pdm_api.c
Normal file
34
libs/RVL_SDK/src/fa/pdm_api.c
Normal file
@@ -0,0 +1,34 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
extern s32 pdm_disk_init_disk_manager(s32 config, void* parameter);
|
||||
extern s32 pdm_disk_add_disk(FADiskTbl* table, FADisk** disk);
|
||||
extern s32 pdm_disk_del_disk(FADisk* disk);
|
||||
extern s32 pdm_part_get_partition(FADisk* disk, u16 index, FAPartition** partition);
|
||||
extern s32 pdm_part_release_partition(FAPartition* partition);
|
||||
|
||||
s32 pdm_init_diskmanager(s32 config, void* parameter) {
|
||||
return pdm_disk_init_disk_manager(config, parameter);
|
||||
}
|
||||
|
||||
s32 pdm_open_disk(FADiskTbl* table, FADisk** disk) {
|
||||
s32 error;
|
||||
*disk = NULL;
|
||||
error = pdm_disk_add_disk(table, disk);
|
||||
return error != 0 ? error : 0;
|
||||
}
|
||||
|
||||
s32 pdm_close_disk(FADisk* disk) {
|
||||
return pdm_disk_del_disk(disk);
|
||||
}
|
||||
|
||||
s32 pdm_open_partition(FADisk* disk, u16 index, FAPartition** partition) {
|
||||
s32 error;
|
||||
*partition = NULL;
|
||||
error = pdm_part_get_partition(disk, index, partition);
|
||||
return error != 0 ? error : 0;
|
||||
}
|
||||
|
||||
s32 pdm_close_partition(FAPartition* partition) {
|
||||
s32 error = pdm_part_release_partition(partition);
|
||||
return error != 0 ? error : 0;
|
||||
}
|
||||
8
libs/RVL_SDK/src/fa/pf_buffering.c
Normal file
8
libs/RVL_SDK/src/fa/pf_buffering.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
extern s32 PFVOL_buffering(s8 drive, u8 mode);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
s32 pf2_buffering(s32 drive, u32 mode) {
|
||||
return PFAPI_convertReturnValue(PFVOL_buffering(drive, mode));
|
||||
}
|
||||
33
libs/RVL_SDK/src/fa/pf_cdelete.c
Normal file
33
libs/RVL_SDK/src/fa/pf_cdelete.c
Normal file
@@ -0,0 +1,33 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
typedef struct PF_API_STRING {
|
||||
const s8* head;
|
||||
const s8* tail;
|
||||
const s8* current;
|
||||
u32 code_mode;
|
||||
} PF_API_STRING;
|
||||
|
||||
typedef struct PF_API_VOLUME_SET {
|
||||
u8 reserved[0x40];
|
||||
s32 last_error;
|
||||
} PF_API_VOLUME_SET;
|
||||
|
||||
extern PF_API_VOLUME_SET pf_vol_set;
|
||||
extern s32 PFSTR_InitStr(PF_API_STRING* string, const s8* text, u32 mode);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
extern s32 PFFILE_cdelete(PF_API_STRING* path, u32 position, u32 count, u32* completed);
|
||||
|
||||
u32 pf2_cdelete(const char* path, u32 position, u32 count) {
|
||||
PF_API_STRING path_string;
|
||||
u32 completed = 0;
|
||||
s32 error;
|
||||
|
||||
error = PFSTR_InitStr(&path_string, (const s8*)path, 1);
|
||||
if (error == 0) {
|
||||
error = PFFILE_cdelete(&path_string, position, count, &completed);
|
||||
} else {
|
||||
pf_vol_set.last_error = error;
|
||||
}
|
||||
return completed;
|
||||
}
|
||||
32
libs/RVL_SDK/src/fa/pf_chdmod.c
Normal file
32
libs/RVL_SDK/src/fa/pf_chdmod.c
Normal file
@@ -0,0 +1,32 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
typedef struct PF_API_STRING {
|
||||
const s8* head;
|
||||
const s8* tail;
|
||||
const s8* current;
|
||||
u32 code_mode;
|
||||
} PF_API_STRING;
|
||||
|
||||
typedef struct PF_API_VOLUME_SET {
|
||||
u8 reserved[0x40];
|
||||
s32 last_error;
|
||||
} PF_API_VOLUME_SET;
|
||||
|
||||
extern PF_API_VOLUME_SET pf_vol_set;
|
||||
extern s32 PFSTR_InitStr(PF_API_STRING* string, const s8* text, u32 mode);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
extern s32 PFDIR_chdmod(PF_API_STRING* path, u8 attributes);
|
||||
|
||||
s32 pf2_chdmod(const char* path, u32 attributes) {
|
||||
PF_API_STRING path_string;
|
||||
s32 error;
|
||||
|
||||
error = PFSTR_InitStr(&path_string, (const s8*)path, 1);
|
||||
if (error == 0) {
|
||||
error = PFDIR_chdmod(&path_string, attributes);
|
||||
} else {
|
||||
pf_vol_set.last_error = error;
|
||||
}
|
||||
return PFAPI_convertReturnValue(error);
|
||||
}
|
||||
32
libs/RVL_SDK/src/fa/pf_chmod.c
Normal file
32
libs/RVL_SDK/src/fa/pf_chmod.c
Normal file
@@ -0,0 +1,32 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
typedef struct PF_API_STRING {
|
||||
const s8* head;
|
||||
const s8* tail;
|
||||
const s8* current;
|
||||
u32 code_mode;
|
||||
} PF_API_STRING;
|
||||
|
||||
typedef struct PF_API_VOLUME_SET {
|
||||
u8 reserved[0x40];
|
||||
s32 last_error;
|
||||
} PF_API_VOLUME_SET;
|
||||
|
||||
extern PF_API_VOLUME_SET pf_vol_set;
|
||||
extern s32 PFSTR_InitStr(PF_API_STRING* string, const s8* text, u32 mode);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
extern s32 PFDIR_chmod(PF_API_STRING* path, u8 attributes);
|
||||
|
||||
s32 pf2_chmod(const char* path, u32 attributes) {
|
||||
PF_API_STRING path_string;
|
||||
s32 error;
|
||||
|
||||
error = PFSTR_InitStr(&path_string, (const s8*)path, 1);
|
||||
if (error == 0) {
|
||||
error = PFDIR_chmod(&path_string, attributes);
|
||||
} else {
|
||||
pf_vol_set.last_error = error;
|
||||
}
|
||||
return PFAPI_convertReturnValue(error);
|
||||
}
|
||||
33
libs/RVL_SDK/src/fa/pf_cinsert.c
Normal file
33
libs/RVL_SDK/src/fa/pf_cinsert.c
Normal file
@@ -0,0 +1,33 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
typedef struct PF_API_STRING {
|
||||
const s8* head;
|
||||
const s8* tail;
|
||||
const s8* current;
|
||||
u32 code_mode;
|
||||
} PF_API_STRING;
|
||||
|
||||
typedef struct PF_API_VOLUME_SET {
|
||||
u8 reserved[0x40];
|
||||
s32 last_error;
|
||||
} PF_API_VOLUME_SET;
|
||||
|
||||
extern PF_API_VOLUME_SET pf_vol_set;
|
||||
extern s32 PFSTR_InitStr(PF_API_STRING* string, const s8* text, u32 mode);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
extern s32 PFFILE_cinsert(PF_API_STRING* path, u32 position, u32 count, u32* completed);
|
||||
|
||||
u32 pf2_cinsert(const char* path, u32 position, u32 count) {
|
||||
PF_API_STRING path_string;
|
||||
u32 completed = 0;
|
||||
s32 error;
|
||||
|
||||
error = PFSTR_InitStr(&path_string, (const s8*)path, 1);
|
||||
if (error == 0) {
|
||||
error = PFFILE_cinsert(&path_string, position, count, &completed);
|
||||
} else {
|
||||
pf_vol_set.last_error = error;
|
||||
}
|
||||
return completed;
|
||||
}
|
||||
34
libs/RVL_SDK/src/fa/pf_combine.c
Normal file
34
libs/RVL_SDK/src/fa/pf_combine.c
Normal file
@@ -0,0 +1,34 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
typedef struct PF_API_STRING {
|
||||
const s8* head;
|
||||
const s8* tail;
|
||||
const s8* current;
|
||||
u32 code_mode;
|
||||
} PF_API_STRING;
|
||||
|
||||
typedef struct PF_API_VOLUME_SET {
|
||||
u8 reserved[0x40];
|
||||
s32 last_error;
|
||||
} PF_API_VOLUME_SET;
|
||||
|
||||
extern PF_API_VOLUME_SET pf_vol_set;
|
||||
extern s32 PFSTR_InitStr(PF_API_STRING* string, const s8* text, u32 mode);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
extern s32 PFFILE_combine(PF_API_STRING* source, PF_API_STRING* destination);
|
||||
|
||||
s32 pf2_combine(const char* source, const char* destination) {
|
||||
PF_API_STRING source_string;
|
||||
PF_API_STRING destination_string;
|
||||
s32 error;
|
||||
|
||||
error = PFSTR_InitStr(&source_string, (const s8*)source, 1);
|
||||
error |= PFSTR_InitStr(&destination_string, (const s8*)destination, 1);
|
||||
if (error == 0) {
|
||||
error = PFFILE_combine(&source_string, &destination_string);
|
||||
} else {
|
||||
pf_vol_set.last_error = error;
|
||||
}
|
||||
return PFAPI_convertReturnValue(error);
|
||||
}
|
||||
32
libs/RVL_SDK/src/fa/pf_createdir.c
Normal file
32
libs/RVL_SDK/src/fa/pf_createdir.c
Normal file
@@ -0,0 +1,32 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
typedef struct PF_API_STRING {
|
||||
const s8* head;
|
||||
const s8* tail;
|
||||
const s8* current;
|
||||
u32 code_mode;
|
||||
} PF_API_STRING;
|
||||
|
||||
typedef struct PF_API_VOLUME_SET {
|
||||
u8 reserved[0x40];
|
||||
s32 last_error;
|
||||
} PF_API_VOLUME_SET;
|
||||
|
||||
extern PF_API_VOLUME_SET pf_vol_set;
|
||||
extern s32 PFSTR_InitStr(PF_API_STRING* string, const s8* text, u32 mode);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
extern s32 PFDIR_createdir(PF_API_STRING* path, s32 mode, FADta* data);
|
||||
|
||||
s32 pf2_createdir(const char* path, s32 mode, FADta* data) {
|
||||
PF_API_STRING path_string;
|
||||
s32 error;
|
||||
|
||||
error = PFSTR_InitStr(&path_string, (const s8*)path, 1);
|
||||
if (error == 0) {
|
||||
error = PFDIR_createdir(&path_string, mode, data);
|
||||
} else {
|
||||
pf_vol_set.last_error = error;
|
||||
}
|
||||
return PFAPI_convertReturnValue(error);
|
||||
}
|
||||
36
libs/RVL_SDK/src/fa/pf_cut.c
Normal file
36
libs/RVL_SDK/src/fa/pf_cut.c
Normal file
@@ -0,0 +1,36 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
typedef struct PF_API_STRING {
|
||||
const s8* head;
|
||||
const s8* tail;
|
||||
const s8* current;
|
||||
u32 code_mode;
|
||||
} PF_API_STRING;
|
||||
|
||||
typedef struct PF_API_VOLUME_SET {
|
||||
u8 reserved[0x40];
|
||||
s32 last_error;
|
||||
} PF_API_VOLUME_SET;
|
||||
|
||||
extern PF_API_VOLUME_SET pf_vol_set;
|
||||
extern s32 PFSTR_InitStr(PF_API_STRING* string, const s8* text, u32 mode);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
extern s32 PFFILE_cdelete(PF_API_STRING* path, u32 position, u32 count, u32* completed);
|
||||
|
||||
s32 pf2_cut(const char* path, u32 position) {
|
||||
PF_API_STRING path_string;
|
||||
u32 completed;
|
||||
s32 error;
|
||||
|
||||
error = PFSTR_InitStr(&path_string, (const s8*)path, 1);
|
||||
if (error == 0) {
|
||||
PFFILE_cdelete(&path_string, position, 1, &completed);
|
||||
if (completed != 1) {
|
||||
error = -1;
|
||||
}
|
||||
} else {
|
||||
pf_vol_set.last_error = error;
|
||||
}
|
||||
return PFAPI_convertReturnValue(error);
|
||||
}
|
||||
8
libs/RVL_SDK/src/fa/pf_derrnum.c
Normal file
8
libs/RVL_SDK/src/fa/pf_derrnum.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
extern s32 PFVOL_derrnum(s8 drive);
|
||||
extern s32 PFAPI_convertDriverError(s32 error);
|
||||
|
||||
s32 pf2_derrnum(s8 drive) {
|
||||
return PFAPI_convertDriverError(PFVOL_derrnum(drive));
|
||||
}
|
||||
34
libs/RVL_SDK/src/fa/pf_divide.c
Normal file
34
libs/RVL_SDK/src/fa/pf_divide.c
Normal file
@@ -0,0 +1,34 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
typedef struct PF_API_STRING {
|
||||
const s8* head;
|
||||
const s8* tail;
|
||||
const s8* current;
|
||||
u32 code_mode;
|
||||
} PF_API_STRING;
|
||||
|
||||
typedef struct PF_API_VOLUME_SET {
|
||||
u8 reserved[0x40];
|
||||
s32 last_error;
|
||||
} PF_API_VOLUME_SET;
|
||||
|
||||
extern PF_API_VOLUME_SET pf_vol_set;
|
||||
extern s32 PFSTR_InitStr(PF_API_STRING* string, const s8* text, u32 mode);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
extern s32 PFFILE_divide(PF_API_STRING* source, PF_API_STRING* destination, u32 offset);
|
||||
|
||||
s32 pf2_divide(const char* source, const char* destination, u32 offset) {
|
||||
PF_API_STRING source_string;
|
||||
PF_API_STRING destination_string;
|
||||
s32 error;
|
||||
|
||||
error = PFSTR_InitStr(&source_string, (const s8*)source, 1);
|
||||
error |= PFSTR_InitStr(&destination_string, (const s8*)destination, 1);
|
||||
if (error == 0) {
|
||||
error = PFFILE_divide(&source_string, &destination_string, offset);
|
||||
} else {
|
||||
pf_vol_set.last_error = error;
|
||||
}
|
||||
return PFAPI_convertReturnValue(error);
|
||||
}
|
||||
8
libs/RVL_SDK/src/fa/pf_fadjust.c
Normal file
8
libs/RVL_SDK/src/fa/pf_fadjust.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
extern s32 PFFILE_fadjust(FAFILE* file);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
s32 pf2_fadjust(FAFILE* file) {
|
||||
return PFAPI_convertReturnValue(PFFILE_fadjust(file));
|
||||
}
|
||||
9
libs/RVL_SDK/src/fa/pf_fappend.c
Normal file
9
libs/RVL_SDK/src/fa/pf_fappend.c
Normal file
@@ -0,0 +1,9 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
extern s32 PFFILE_fappend(FAFILE* file, u32 size, u32* appended_size);
|
||||
|
||||
u32 pf2_fappend(FAFILE* file, u32 size) {
|
||||
u32 appended_size;
|
||||
PFFILE_fappend(file, size, &appended_size);
|
||||
return appended_size;
|
||||
}
|
||||
8
libs/RVL_SDK/src/fa/pf_fchdir.c
Normal file
8
libs/RVL_SDK/src/fa/pf_fchdir.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
extern s32 PFDIR_fchdir(FADIR* directory);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
s32 pf2_fchdir(FADIR* directory) {
|
||||
return PFAPI_convertReturnValue(PFDIR_fchdir(directory));
|
||||
}
|
||||
34
libs/RVL_SDK/src/fa/pf_fconcat.c
Normal file
34
libs/RVL_SDK/src/fa/pf_fconcat.c
Normal file
@@ -0,0 +1,34 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
typedef struct PF_API_STRING {
|
||||
const s8* head;
|
||||
const s8* tail;
|
||||
const s8* current;
|
||||
u32 code_mode;
|
||||
} PF_API_STRING;
|
||||
|
||||
typedef struct PF_API_VOLUME_SET {
|
||||
u8 reserved[0x40];
|
||||
s32 last_error;
|
||||
} PF_API_VOLUME_SET;
|
||||
|
||||
extern PF_API_VOLUME_SET pf_vol_set;
|
||||
extern s32 PFSTR_InitStr(PF_API_STRING* string, const s8* text, u32 mode);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
extern s32 PFFILE_combine(PF_API_STRING* source, PF_API_STRING* destination);
|
||||
|
||||
s32 pf2_fconcat(const char* source, const char* destination) {
|
||||
PF_API_STRING source_string;
|
||||
PF_API_STRING destination_string;
|
||||
s32 error;
|
||||
|
||||
error = PFSTR_InitStr(&source_string, (const s8*)source, 1);
|
||||
error |= PFSTR_InitStr(&destination_string, (const s8*)destination, 1);
|
||||
if (error == 0) {
|
||||
error = PFFILE_combine(&source_string, &destination_string);
|
||||
} else {
|
||||
pf_vol_set.last_error = error;
|
||||
}
|
||||
return PFAPI_convertReturnValue(error);
|
||||
}
|
||||
8
libs/RVL_SDK/src/fa/pf_fsetclstlink.c
Normal file
8
libs/RVL_SDK/src/fa/pf_fsetclstlink.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
extern s32 PFFILE_fsetclstlink(FAFILE* file, u32 mode, void* setting);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
s32 pf2_fsetclstlink(FAFILE* file, u32 mode, void* setting) {
|
||||
return PFAPI_convertReturnValue(PFFILE_fsetclstlink(file, mode, setting));
|
||||
}
|
||||
8
libs/RVL_SDK/src/fa/pf_fsexec.c
Normal file
8
libs/RVL_SDK/src/fa/pf_fsexec.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
extern s32 PFDIR_fsexec(FADta* data, u32 flags, u32 mode);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
s32 pf2_fsexec(FADta* data, u32 flags, u32 mode) {
|
||||
return PFAPI_convertReturnValue(PFDIR_fsexec(data, flags, mode));
|
||||
}
|
||||
8
libs/RVL_SDK/src/fa/pf_getvol.c
Normal file
8
libs/RVL_SDK/src/fa/pf_getvol.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
extern s32 PFVOL_getvol(s8 drive, void* volume_info);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
s32 pf2_getvol(s8 drive, void* volume_info) {
|
||||
return PFAPI_convertReturnValue(PFVOL_getvol(drive, volume_info));
|
||||
}
|
||||
8
libs/RVL_SDK/src/fa/pf_getvolcfg.c
Normal file
8
libs/RVL_SDK/src/fa/pf_getvolcfg.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
extern s32 PFVOL_getvolcfg(s8 drive, u32* config);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
s32 pf2_getvolcfg(s8 drive, u32* config) {
|
||||
return PFAPI_convertReturnValue(PFVOL_getvolcfg(drive, config));
|
||||
}
|
||||
42
libs/RVL_SDK/src/fa/pf_insert.c
Normal file
42
libs/RVL_SDK/src/fa/pf_insert.c
Normal file
@@ -0,0 +1,42 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
typedef struct PF_API_STRING {
|
||||
const s8* head;
|
||||
const s8* tail;
|
||||
const s8* current;
|
||||
u32 code_mode;
|
||||
} PF_API_STRING;
|
||||
|
||||
typedef struct PF_API_VOLUME_SET {
|
||||
u8 reserved[0x40];
|
||||
s32 last_error;
|
||||
} PF_API_VOLUME_SET;
|
||||
|
||||
extern PF_API_VOLUME_SET pf_vol_set;
|
||||
extern s32 PFSTR_InitStr(PF_API_STRING* string, const s8* text, u32 mode);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
extern s32 PFFILE_cinsert(PF_API_STRING* path, u32 position, u32 count, u32* completed);
|
||||
extern s32 PFFILE_cdelete(PF_API_STRING* path, u32 position, u32 count, u32* completed);
|
||||
|
||||
s32 pf2_insert(const char* path, u32 count) {
|
||||
PF_API_STRING path_string;
|
||||
u32 inserted;
|
||||
u32 deleted;
|
||||
s32 error;
|
||||
|
||||
error = PFSTR_InitStr(&path_string, (const s8*)path, 1);
|
||||
if (error == 0) {
|
||||
PFFILE_cinsert(&path_string, 0, count, &inserted);
|
||||
if (count != inserted || count == 0) {
|
||||
if (inserted != 0) {
|
||||
PFSTR_InitStr(&path_string, (const s8*)path, 1);
|
||||
PFFILE_cdelete(&path_string, 0, inserted, &deleted);
|
||||
}
|
||||
error = -1;
|
||||
}
|
||||
} else {
|
||||
pf_vol_set.last_error = error;
|
||||
}
|
||||
return PFAPI_convertReturnValue(error);
|
||||
}
|
||||
13
libs/RVL_SDK/src/fa/pf_iswriteprotected.c
Normal file
13
libs/RVL_SDK/src/fa/pf_iswriteprotected.c
Normal file
@@ -0,0 +1,13 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
extern s32 PFVOL_iswriteprotected(s8 drive, u32* protected_status);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
s32 pf2_iswriteprotected(s8 drive) {
|
||||
u32 protected_status = 0;
|
||||
s32 error = PFVOL_iswriteprotected(drive, &protected_status);
|
||||
if (error == 0) {
|
||||
return protected_status;
|
||||
}
|
||||
return PFAPI_convertReturnValue(error);
|
||||
}
|
||||
34
libs/RVL_SDK/src/fa/pf_move.c
Normal file
34
libs/RVL_SDK/src/fa/pf_move.c
Normal file
@@ -0,0 +1,34 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
typedef struct PF_API_STRING {
|
||||
const s8* head;
|
||||
const s8* tail;
|
||||
const s8* current;
|
||||
u32 code_mode;
|
||||
} PF_API_STRING;
|
||||
|
||||
typedef struct PF_API_VOLUME_SET {
|
||||
u8 reserved[0x40];
|
||||
s32 last_error;
|
||||
} PF_API_VOLUME_SET;
|
||||
|
||||
extern PF_API_VOLUME_SET pf_vol_set;
|
||||
extern s32 PFSTR_InitStr(PF_API_STRING* string, const s8* text, u32 mode);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
extern s32 PFDIR_move(PF_API_STRING* source, PF_API_STRING* destination);
|
||||
|
||||
s32 pf2_move(const char* source, const char* destination) {
|
||||
PF_API_STRING source_string;
|
||||
PF_API_STRING destination_string;
|
||||
s32 error;
|
||||
|
||||
error = PFSTR_InitStr(&source_string, (const s8*)source, 1);
|
||||
error |= PFSTR_InitStr(&destination_string, (const s8*)destination, 1);
|
||||
if (error == 0) {
|
||||
error = PFDIR_move(&source_string, &destination_string);
|
||||
} else {
|
||||
pf_vol_set.last_error = error;
|
||||
}
|
||||
return PFAPI_convertReturnValue(error);
|
||||
}
|
||||
34
libs/RVL_SDK/src/fa/pf_opendir.c
Normal file
34
libs/RVL_SDK/src/fa/pf_opendir.c
Normal file
@@ -0,0 +1,34 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
typedef struct PF_API_STRING {
|
||||
const s8* head;
|
||||
const s8* tail;
|
||||
const s8* current;
|
||||
u32 code_mode;
|
||||
} PF_API_STRING;
|
||||
|
||||
typedef struct PF_API_VOLUME_SET {
|
||||
u8 reserved[0x40];
|
||||
s32 last_error;
|
||||
} PF_API_VOLUME_SET;
|
||||
|
||||
extern PF_API_VOLUME_SET pf_vol_set;
|
||||
extern s32 PFSTR_InitStr(PF_API_STRING* string, const s8* text, u32 mode);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
extern s32 PFDIR_opendir(PF_API_STRING* path, FADIR** directory);
|
||||
extern void* PFAPI_convertReturnValue2NULL(s32 error, void* stream);
|
||||
|
||||
FADIR* pf2_opendir(const char* path) {
|
||||
PF_API_STRING path_string;
|
||||
FADIR* directory;
|
||||
s32 error;
|
||||
|
||||
error = PFSTR_InitStr(&path_string, (const s8*)path, 1);
|
||||
if (error == 0) {
|
||||
error = PFDIR_opendir(&path_string, &directory);
|
||||
} else {
|
||||
pf_vol_set.last_error = error;
|
||||
}
|
||||
return PFAPI_convertReturnValue2NULL(error, directory);
|
||||
}
|
||||
8
libs/RVL_SDK/src/fa/pf_readdir.c
Normal file
8
libs/RVL_SDK/src/fa/pf_readdir.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
extern s32 PFDIR_readdir(FADIR* directory, void* result);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
s32 pf2_readdir(FADIR* directory, void* result) {
|
||||
return PFAPI_convertReturnValue(PFDIR_readdir(directory, result));
|
||||
}
|
||||
8
libs/RVL_SDK/src/fa/pf_regctx.c
Normal file
8
libs/RVL_SDK/src/fa/pf_regctx.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
extern s32 PFVOL_regctx(void);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
s32 pf2_regctx(void) {
|
||||
return PFAPI_convertReturnValue(PFVOL_regctx());
|
||||
}
|
||||
8
libs/RVL_SDK/src/fa/pf_rewinddir.c
Normal file
8
libs/RVL_SDK/src/fa/pf_rewinddir.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
extern s32 PFDIR_seekdir(FADIR* directory, u32 position);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
s32 pf2_rewinddir(FADIR* directory) {
|
||||
return PFAPI_convertReturnValue(PFDIR_seekdir(directory, 0));
|
||||
}
|
||||
8
libs/RVL_SDK/src/fa/pf_rmvvol.c
Normal file
8
libs/RVL_SDK/src/fa/pf_rmvvol.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
extern s32 PFVOL_rmvvol(s8 drive);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
s32 pf2_rmvvol(s8 drive) {
|
||||
return PFAPI_convertReturnValue(PFVOL_rmvvol(drive));
|
||||
}
|
||||
8
libs/RVL_SDK/src/fa/pf_seekdir.c
Normal file
8
libs/RVL_SDK/src/fa/pf_seekdir.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
extern s32 PFDIR_seekdir(FADIR* directory, u32 position);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
s32 pf2_seekdir(FADIR* directory, u32 position) {
|
||||
return PFAPI_convertReturnValue(PFDIR_seekdir(directory, position));
|
||||
}
|
||||
8
libs/RVL_SDK/src/fa/pf_setclstlink.c
Normal file
8
libs/RVL_SDK/src/fa/pf_setclstlink.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
extern s32 PFVOL_setclstlink(s8 drive, s32 mode, void* setting);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
s32 pf2_setclstlink(s8 drive, s32 mode, void* setting) {
|
||||
return PFAPI_convertReturnValue(PFVOL_setclstlink(drive, mode, setting));
|
||||
}
|
||||
8
libs/RVL_SDK/src/fa/pf_setcode.c
Normal file
8
libs/RVL_SDK/src/fa/pf_setcode.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
extern s32 PFVOL_setcode(const void* code_set);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
s32 pf2_setcode(const void* code_set) {
|
||||
return PFAPI_convertReturnValue(PFVOL_setcode(code_set));
|
||||
}
|
||||
8
libs/RVL_SDK/src/fa/pf_setencode.c
Normal file
8
libs/RVL_SDK/src/fa/pf_setencode.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
extern s32 PFVOL_setencode(u32 mode);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
s32 pf2_setencode(u32 mode) {
|
||||
return PFAPI_convertReturnValue(PFVOL_setencode(mode));
|
||||
}
|
||||
8
libs/RVL_SDK/src/fa/pf_settailbuf.c
Normal file
8
libs/RVL_SDK/src/fa/pf_settailbuf.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
extern s32 PFVOL_settailbuf(s8 drive, u32 count, void* buffer);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
s32 pf2_settailbuf(s8 drive, u32 count, void* buffer) {
|
||||
return PFAPI_convertReturnValue(PFVOL_settailbuf(drive, count, buffer));
|
||||
}
|
||||
8
libs/RVL_SDK/src/fa/pf_setupfsi.c
Normal file
8
libs/RVL_SDK/src/fa/pf_setupfsi.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
extern s32 PFVOL_setupfsi(s8 drive, u16 mode);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
s32 pf2_setupfsi(s32 drive, u32 mode) {
|
||||
return PFAPI_convertReturnValue(PFVOL_setupfsi(drive, mode));
|
||||
}
|
||||
30
libs/RVL_SDK/src/fa/pf_setvol.c
Normal file
30
libs/RVL_SDK/src/fa/pf_setvol.c
Normal file
@@ -0,0 +1,30 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
typedef struct PF_API_STRING {
|
||||
const s8* head;
|
||||
const s8* tail;
|
||||
const s8* current;
|
||||
u32 code_mode;
|
||||
} PF_API_STRING;
|
||||
|
||||
typedef struct PF_API_VOLUME_SET {
|
||||
u8 reserved[0x40];
|
||||
s32 last_error;
|
||||
} PF_API_VOLUME_SET;
|
||||
|
||||
extern PF_API_VOLUME_SET pf_vol_set;
|
||||
extern s32 PFSTR_InitStr(PF_API_STRING* string, const s8* text, u32 mode);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
extern s32 PFVOL_setvol(s8 drive, PF_API_STRING* label);
|
||||
|
||||
s32 pf2_setvol(s8 drive, const char* label) {
|
||||
PF_API_STRING label_string;
|
||||
s32 error = PFSTR_InitStr(&label_string, (const s8*)label, 1);
|
||||
if (error == 0) {
|
||||
error = PFVOL_setvol(drive, &label_string);
|
||||
} else {
|
||||
pf_vol_set.last_error = error;
|
||||
}
|
||||
return PFAPI_convertReturnValue(error);
|
||||
}
|
||||
8
libs/RVL_SDK/src/fa/pf_setvolcfg.c
Normal file
8
libs/RVL_SDK/src/fa/pf_setvolcfg.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
extern s32 PFVOL_setvolcfg(s8 drive, u32* config);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
s32 pf2_setvolcfg(s8 drive, u32* config) {
|
||||
return PFAPI_convertReturnValue(PFVOL_setvolcfg(drive, config));
|
||||
}
|
||||
152
libs/RVL_SDK/src/fa/pf_stub.c
Normal file
152
libs/RVL_SDK/src/fa/pf_stub.c
Normal file
@@ -0,0 +1,152 @@
|
||||
#include <revolution/fa/pf_stub.h>
|
||||
#include <private/fa/pf_system.h>
|
||||
#include <private/fa/pf_kernel.h>
|
||||
|
||||
typedef struct PF_STUB_VOLUME_CONTEXT {
|
||||
u8 volume_state[0x64];
|
||||
s32 context_id;
|
||||
} PF_STUB_VOLUME_CONTEXT;
|
||||
|
||||
extern PF_STUB_VOLUME_CONTEXT pf_vol_set;
|
||||
extern FADisk* gOpenDisk[26];
|
||||
extern FAPartition* gOpenPartition[26];
|
||||
extern s32 pfd_sddrv_is_media_insert(void);
|
||||
extern s32 pfd_mscdrv_is_media_insert(FADisk* disk);
|
||||
extern void pfstub_call_function_standard(PF_STUB_MESSAGE* message);
|
||||
extern void pfstub_call_function_unicode(PF_STUB_MESSAGE* message);
|
||||
void* pfstub_entry(void* argument);
|
||||
s32 pfstub_store_result(PF_STUB_MESSAGE* message);
|
||||
|
||||
void pfstub_init_stub(void) {
|
||||
PFK_MAILBOX_CONFIG mailbox;
|
||||
PFK_TASK_CONFIG task;
|
||||
if (pf_sys_set.initialized == 0) {
|
||||
mailbox.queue = &pf_sys_set.mailbox;
|
||||
mailbox.messages = pf_sys_set.messages;
|
||||
mailbox.count = 20;
|
||||
pf_sys_set.mailbox_id = pfk_create_mailbox(&mailbox);
|
||||
task.entry = pfstub_entry;
|
||||
task.argument = NULL;
|
||||
task.priority = 16;
|
||||
task.stack_size = sizeof(pf_sys_set.task_stack);
|
||||
task.stack = pf_sys_set.task_stack;
|
||||
task.thread = &pf_sys_set.task;
|
||||
pf_sys_set.task_id = pfk_create_task(&task);
|
||||
pfk_start_task(pf_sys_set.task_id);
|
||||
pf_sys_set.initialized = 1;
|
||||
}
|
||||
}
|
||||
|
||||
s32 pfstub_set_stub_priority(s32 priority) {
|
||||
if (pf_sys_set.initialized != 1) {
|
||||
return -1;
|
||||
}
|
||||
return pfk_set_task_priority(pf_sys_set.task_id, priority);
|
||||
}
|
||||
|
||||
void* pfstub_entry(void* argument) {
|
||||
PF_STUB_MESSAGE* received = NULL;
|
||||
PF_STUB_MESSAGE* message;
|
||||
for (;;) {
|
||||
if (pfk_receive_message(pf_sys_set.mailbox_id, (OSMessage*)&received) != 0) {
|
||||
continue;
|
||||
}
|
||||
message = received;
|
||||
if (message == NULL) {
|
||||
continue;
|
||||
}
|
||||
pf_vol_set.context_id = message->task_id;
|
||||
if (message->operation >= 0 && message->operation < 100) {
|
||||
pfstub_call_function_standard(message);
|
||||
} else if (received->operation >= 100 && received->operation < 200) {
|
||||
pfstub_call_function_unicode(message);
|
||||
} else {
|
||||
message->result.status = -1;
|
||||
}
|
||||
if (message->callback == NULL) {
|
||||
pfk_release_semaphore(message->semaphore);
|
||||
} else {
|
||||
if (message->operation == 27) {
|
||||
FADrvTbl* table = message->context;
|
||||
s32 index = table->drive - 'A';
|
||||
gOpenDisk[index] = message->disk;
|
||||
gOpenPartition[index] = message->partition;
|
||||
if (message->value == 0) {
|
||||
if (pfd_sddrv_is_media_insert()) {
|
||||
((FADrvTbl*)message->context)->stat |= 0x10;
|
||||
}
|
||||
} else if ((s32)message->value == 1) {
|
||||
if (pfd_mscdrv_is_media_insert(message->disk)) {
|
||||
((FADrvTbl*)message->context)->stat |= 0x10;
|
||||
}
|
||||
}
|
||||
}
|
||||
message->callback(pfstub_store_result(message), message->callback_context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
s32 pfstub_com_massage(PF_STUB_MESSAGE* message) {
|
||||
s32 task_id;
|
||||
PFK_SEMAPHORE_CONFIG config;
|
||||
OSSemaphore semaphore;
|
||||
s32 error;
|
||||
if (message->callback == NULL) {
|
||||
config.initial_count = 0;
|
||||
config.maximum_count = 1;
|
||||
config.semaphore = &semaphore;
|
||||
message->semaphore = pfk_create_semaphore(&config);
|
||||
} else {
|
||||
message->semaphore = 0;
|
||||
}
|
||||
if (pfk_get_task_id(&task_id) != 0) {
|
||||
return -1;
|
||||
}
|
||||
message->task_id = task_id;
|
||||
if (pfk_send_message(pf_sys_set.mailbox_id, message) != 0) {
|
||||
return -1;
|
||||
}
|
||||
if (message->callback == NULL) {
|
||||
error = pfk_get_semaphore(message->semaphore);
|
||||
pfk_delete_semaphore(message->semaphore);
|
||||
if (error != 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 pfstub_store_result(PF_STUB_MESSAGE* message) {
|
||||
s32 error = 0;
|
||||
if (message->result_address != NULL) {
|
||||
*message->result_address = message->result;
|
||||
switch (message->operation) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 54:
|
||||
case 100:
|
||||
case 101:
|
||||
case 122:
|
||||
if (message->result.stream == NULL) {
|
||||
error = -1;
|
||||
}
|
||||
break;
|
||||
case 35:
|
||||
if (message->result.status != (s32)message->value) {
|
||||
error = -1;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
if (message->result.status != (s32)message->count) {
|
||||
error = -1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
error = message->result.status;
|
||||
}
|
||||
return error;
|
||||
}
|
||||
272
libs/RVL_SDK/src/fa/pf_stub_standard.c
Normal file
272
libs/RVL_SDK/src/fa/pf_stub_standard.c
Normal file
@@ -0,0 +1,272 @@
|
||||
#include <revolution/fa/pf_stub.h>
|
||||
|
||||
extern void* pf2_create(const void*, u32);
|
||||
extern void* pf2_fopen(const void*, const void*);
|
||||
extern s32 pf2_fclose(const void*);
|
||||
extern s32 pf2_fread(const void*, u32, u32, const void*);
|
||||
extern s32 pf2_fwrite(const void*, u32, u32, const void*);
|
||||
extern s32 pf2_fseek(const void*, u32, u32);
|
||||
extern s32 pf2_remove(const void*);
|
||||
extern s32 pf2_rename(const void*, const void*);
|
||||
extern s32 pf2_mkdir(const void*);
|
||||
extern s32 pf2_rmdir(const void*);
|
||||
extern s32 pf2_chdir(const void*);
|
||||
extern s32 pf2_fstat(const void*, const void*);
|
||||
extern s32 pf2_chmod(const void*, u32);
|
||||
extern s32 pf2_mount(s8);
|
||||
extern s32 pf2_format(s8, const void*);
|
||||
extern s32 pf2_buffering(s8, u32);
|
||||
extern s32 pf2_ferror(const void*);
|
||||
extern s32 pf2_feof(const void*);
|
||||
extern s32 pf2_errnum(void);
|
||||
extern s32 pf2_devinf(s8, const void*);
|
||||
extern s32 pf2_setvol(s8, const void*);
|
||||
extern s32 pf2_getvol(s8, const void*);
|
||||
extern s32 pf2_rmvvol(s8);
|
||||
extern s32 pf2_chdmod(const void*, u32);
|
||||
extern s32 pf2_fconcat(const void*, const void*);
|
||||
extern s32 pf2_attach(const void*, const void*);
|
||||
extern s32 pf2_fsfirst(const void*, u32, const void*);
|
||||
extern s32 pf2_fsnext(const void*);
|
||||
extern s32 pf2_setupfsi(s8, u32);
|
||||
extern s32 pf2_setclstlink(s8, u32, const void*);
|
||||
extern s32 pf2_fsetclstlink(const void*, u32, const void*);
|
||||
extern s32 pf2_sync(s8, u32);
|
||||
extern s32 pf2_fsync(const void*);
|
||||
extern s32 pf2_fappend(const void*, u32);
|
||||
extern s32 pf2_settailbuf(s8, u32, const void*);
|
||||
extern s32 pf2_derrnum(s8);
|
||||
extern s32 pf2_fsexec(const void*, u32, s32);
|
||||
extern s32 pf2_unmount(s8, u32);
|
||||
extern s32 pf2_combine(const void*, const void*);
|
||||
extern s32 pf2_detach(s8);
|
||||
extern s32 pf2_divide(const void*, const void*, u32);
|
||||
extern s32 pf2_xdivide(const void*, const void*, u32);
|
||||
extern s32 pf2_fadjust(const void*);
|
||||
extern s32 pf2_finfo(const void*, const void*);
|
||||
extern s32 pf2_move(const void*, const void*);
|
||||
extern s32 pf2_cinsert(const void*, u32, u32);
|
||||
extern s32 pf2_insert(const void*, u32);
|
||||
extern s32 pf2_cdelete(const void*, u32, u32);
|
||||
extern s32 pf2_cut(const void*, u32);
|
||||
extern s32 pf2_setvolcfg(s8, const void*);
|
||||
extern s32 pf2_getvolcfg(s8, const void*);
|
||||
extern s32 pf2_setcode(const void*);
|
||||
extern void* pf2_opendir(const void*);
|
||||
extern s32 pf2_closedir(const void*);
|
||||
extern s32 pf2_readdir(const void*, const void*);
|
||||
extern s32 pf2_telldir(const void*, const void*);
|
||||
extern s32 pf2_seekdir(const void*, u32);
|
||||
extern s32 pf2_rewinddir(const void*);
|
||||
extern s32 pf2_fchdir(const void*);
|
||||
extern s32 pf2_regctx(void);
|
||||
extern s32 pf2_unregctx(void);
|
||||
extern s32 pf2_flock(const void*, u32);
|
||||
extern s32 pf2_setencode(u32);
|
||||
extern s32 pf2_createdir(const void*, u32, const void*);
|
||||
extern s32 pf2_iswriteprotected(s8);
|
||||
|
||||
void pfstub_call_function_standard(PF_STUB_MESSAGE* message) {
|
||||
switch (message->operation) {
|
||||
case 0:
|
||||
message->result.stream = pf2_create(message->object,message->value);
|
||||
break;
|
||||
case 1:
|
||||
message->result.stream = pf2_fopen(message->object,message->data);
|
||||
break;
|
||||
case 2:
|
||||
message->result.status = pf2_fclose(message->object);
|
||||
break;
|
||||
case 3:
|
||||
message->result.status = pf2_fread(message->object,message->value, message->count,message->data);
|
||||
break;
|
||||
case 4:
|
||||
message->result.status = pf2_fwrite(message->object,message->value, message->count,message->data);
|
||||
break;
|
||||
case 5:
|
||||
message->result.status = pf2_fseek(message->object,message->value, message->count);
|
||||
break;
|
||||
case 7:
|
||||
message->result.status = pf2_remove(message->object);
|
||||
break;
|
||||
case 8:
|
||||
message->result.status = pf2_rename(message->object,message->data);
|
||||
break;
|
||||
case 0x2e:
|
||||
message->result.status = pf2_move(message->object,message->data);
|
||||
break;
|
||||
case 9:
|
||||
message->result.status = pf2_mkdir(message->object);
|
||||
break;
|
||||
case 0x41:
|
||||
message->result.status = pf2_createdir(message->object,message->value, message->data);
|
||||
break;
|
||||
case 10:
|
||||
message->result.status = pf2_rmdir(message->object);
|
||||
break;
|
||||
case 0xb:
|
||||
message->result.status = pf2_chdir(message->object);
|
||||
break;
|
||||
case 0xc:
|
||||
message->result.status = pf2_fstat(message->object,message->data);
|
||||
break;
|
||||
case 0xd:
|
||||
message->result.status = pf2_chmod(message->object,message->value);
|
||||
break;
|
||||
case 0xe:
|
||||
message->result.status = pf2_mount(message->drive);
|
||||
break;
|
||||
case 0x27:
|
||||
message->result.status = pf2_unmount(message->drive,message->value);
|
||||
break;
|
||||
case 0xf:
|
||||
message->result.status = pf2_format(message->drive,message->object);
|
||||
break;
|
||||
case 0x10:
|
||||
message->result.status = pf2_buffering(message->drive,message->value);
|
||||
break;
|
||||
case 0x11:
|
||||
message->result.status = pf2_ferror(message->object);
|
||||
break;
|
||||
case 0x12:
|
||||
message->result.status = pf2_feof(message->object);
|
||||
break;
|
||||
case 0x13:
|
||||
message->result.status = pf2_errnum();
|
||||
break;
|
||||
case 0x14:
|
||||
message->result.status = pf2_devinf(message->drive,message->object);
|
||||
break;
|
||||
case 0x15:
|
||||
message->result.status = pf2_setvol(message->drive,message->object);
|
||||
break;
|
||||
case 0x16:
|
||||
message->result.status = pf2_getvol(message->drive,message->object);
|
||||
break;
|
||||
case 0x17:
|
||||
message->result.status = pf2_rmvvol(message->drive);
|
||||
break;
|
||||
case 0x18:
|
||||
message->result.status = pf2_chdmod(message->object,message->value);
|
||||
break;
|
||||
case 0x19:
|
||||
message->result.status = pf2_fconcat(message->object,message->data);
|
||||
break;
|
||||
case 0x1b:
|
||||
message->result.status = pf2_attach(message->object,message->data);
|
||||
break;
|
||||
case 0x29:
|
||||
message->result.status = pf2_detach(message->drive);
|
||||
break;
|
||||
case 0x1c:
|
||||
message->result.status = pf2_fsfirst(message->object,(u8)message->value, message->data);
|
||||
break;
|
||||
case 0x1d:
|
||||
message->result.status = pf2_fsnext(message->object);
|
||||
break;
|
||||
case 0x26:
|
||||
message->result.status = pf2_fsexec(message->object,message->value, (u8)message->drive);
|
||||
break;
|
||||
case 0x1e:
|
||||
message->result.status = pf2_setupfsi(message->drive,(s16)message->value);
|
||||
break;
|
||||
case 0x1f:
|
||||
message->result.status = pf2_setclstlink(message->drive,message->value, message->object);
|
||||
break;
|
||||
case 0x20:
|
||||
message->result.status = pf2_fsetclstlink(message->object,message->value, message->data);
|
||||
break;
|
||||
case 0x21:
|
||||
message->result.status = pf2_sync(message->drive,message->value);
|
||||
break;
|
||||
case 0x22:
|
||||
message->result.status = pf2_fsync(message->object);
|
||||
break;
|
||||
case 0x23:
|
||||
message->result.status = pf2_fappend(message->object,message->value);
|
||||
break;
|
||||
case 0x2c:
|
||||
message->result.status = pf2_fadjust(message->object);
|
||||
break;
|
||||
case 0x2d:
|
||||
message->result.status = pf2_finfo(message->object,message->data);
|
||||
break;
|
||||
case 0x24:
|
||||
message->result.status = pf2_settailbuf(message->drive,message->value, message->object);
|
||||
break;
|
||||
case 0x25:
|
||||
message->result.status = pf2_derrnum(message->drive);
|
||||
break;
|
||||
case 0x28:
|
||||
message->result.status = pf2_combine(message->object,message->data);
|
||||
break;
|
||||
case 0x2a:
|
||||
message->result.status = pf2_divide(message->object,message->data, message->value);
|
||||
break;
|
||||
case 0x2b:
|
||||
message->result.status = pf2_xdivide(message->object,message->data, message->value);
|
||||
break;
|
||||
case 0x2f:
|
||||
message->result.status = pf2_cinsert(message->object,message->value, message->count);
|
||||
break;
|
||||
case 0x30:
|
||||
message->result.status = pf2_insert(message->object,message->value);
|
||||
break;
|
||||
case 0x31:
|
||||
message->result.status = pf2_cdelete(message->object,message->value, message->count);
|
||||
break;
|
||||
case 0x32:
|
||||
message->result.status = pf2_cut(message->object,message->value);
|
||||
break;
|
||||
case 0x33:
|
||||
message->result.status = pf2_setvolcfg(message->drive,message->object);
|
||||
break;
|
||||
case 0x34:
|
||||
message->result.status = pf2_getvolcfg(message->drive,message->object);
|
||||
break;
|
||||
case 0x35:
|
||||
message->result.status = pf2_setcode(message->object);
|
||||
break;
|
||||
case 0x36:
|
||||
message->result.stream = pf2_opendir(message->object);
|
||||
break;
|
||||
case 0x37:
|
||||
message->result.status = pf2_closedir(message->object);
|
||||
break;
|
||||
case 0x38:
|
||||
message->result.status = pf2_readdir(message->object,message->data);
|
||||
break;
|
||||
case 0x39:
|
||||
message->result.status = pf2_telldir(message->object,message->data);
|
||||
break;
|
||||
case 0x3a:
|
||||
message->result.status = pf2_seekdir(message->object,message->value);
|
||||
break;
|
||||
case 0x3b:
|
||||
message->result.status = pf2_rewinddir(message->object);
|
||||
break;
|
||||
case 0x3c:
|
||||
message->result.status = pf2_fchdir(message->object);
|
||||
break;
|
||||
case 0x3d:
|
||||
message->result.status = pf2_regctx();
|
||||
break;
|
||||
case 0x3e:
|
||||
message->result.status = pf2_unregctx();
|
||||
break;
|
||||
case 0x3f:
|
||||
message->result.status = pf2_flock(message->object,message->value);
|
||||
break;
|
||||
case 0x40:
|
||||
message->result.status = pf2_setencode(message->value);
|
||||
break;
|
||||
case 0x50:
|
||||
message->result.status = pf2_iswriteprotected(message->drive);
|
||||
break;
|
||||
case 6:
|
||||
break;
|
||||
default:
|
||||
message->result.status = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
106
libs/RVL_SDK/src/fa/pf_stub_unicode.c
Normal file
106
libs/RVL_SDK/src/fa/pf_stub_unicode.c
Normal file
@@ -0,0 +1,106 @@
|
||||
#include <revolution/fa/pf_stub.h>
|
||||
|
||||
extern void* pf2_w_create(const void*, u32);
|
||||
extern void* pf2_w_fopen(const void*, const void*);
|
||||
extern s32 pf2_w_remove(const void*);
|
||||
extern s32 pf2_w_rename(const void*, const void*);
|
||||
extern s32 pf2_w_mkdir(const void*);
|
||||
extern s32 pf2_w_rmdir(const void*);
|
||||
extern s32 pf2_w_chdir(const void*);
|
||||
extern s32 pf2_w_fstat(const void*, const void*);
|
||||
extern s32 pf2_w_chmod(const void*, u32);
|
||||
extern s32 pf2_w_chdmod(const void*, u32);
|
||||
extern s32 pf2_w_fconcat(const void*, const void*);
|
||||
extern s32 pf2_w_fsfirst(const void*, u32, const void*);
|
||||
extern s32 pf2_w_fsnext(const void*);
|
||||
extern s32 pf2_w_fsexec(const void*, u32, s32);
|
||||
extern s32 pf2_w_combine(const void*, const void*);
|
||||
extern s32 pf2_w_divide(const void*, const void*, u32);
|
||||
extern s32 pf2_w_xdivide(const void*, const void*, u32);
|
||||
extern s32 pf2_w_move(const void*, const void*);
|
||||
extern s32 pf2_w_cinsert(const void*, u32, u32);
|
||||
extern s32 pf2_w_insert(const void*, u32);
|
||||
extern s32 pf2_w_cdelete(const void*, u32, u32);
|
||||
extern s32 pf2_w_cut(const void*, u32);
|
||||
extern void* pf2_w_opendir(const void*);
|
||||
extern s32 pf2_w_createdir(const void*, u32, const void*);
|
||||
|
||||
void pfstub_call_function_unicode(PF_STUB_MESSAGE* message) {
|
||||
switch (message->operation) {
|
||||
case 100:
|
||||
message->result.stream = pf2_w_create(message->object,message->value);
|
||||
break;
|
||||
case 0x65:
|
||||
message->result.stream = pf2_w_fopen(message->object,message->data);
|
||||
break;
|
||||
case 0x66:
|
||||
message->result.status = pf2_w_remove(message->object);
|
||||
break;
|
||||
case 0x67:
|
||||
message->result.status = pf2_w_rename(message->object,message->data);
|
||||
break;
|
||||
case 0x75:
|
||||
message->result.status = pf2_w_move(message->object,message->data);
|
||||
break;
|
||||
case 0x68:
|
||||
message->result.status = pf2_w_mkdir(message->object);
|
||||
break;
|
||||
case 0x7b:
|
||||
message->result.status = pf2_w_createdir(message->object,message->value, message->data);
|
||||
break;
|
||||
case 0x69:
|
||||
message->result.status = pf2_w_rmdir(message->object);
|
||||
break;
|
||||
case 0x6a:
|
||||
message->result.status = pf2_w_chdir(message->object);
|
||||
break;
|
||||
case 0x6b:
|
||||
message->result.status = pf2_w_fstat(message->object,message->data);
|
||||
break;
|
||||
case 0x6c:
|
||||
message->result.status = pf2_w_chmod(message->object,message->value);
|
||||
break;
|
||||
case 0x6d:
|
||||
message->result.status = pf2_w_chdmod(message->object,message->value);
|
||||
break;
|
||||
case 0x6e:
|
||||
message->result.status = pf2_w_fconcat(message->object,message->data);
|
||||
break;
|
||||
case 0x6f:
|
||||
message->result.status = pf2_w_fsfirst(message->object,(u8)message->value, message->data);
|
||||
break;
|
||||
case 0x70:
|
||||
message->result.status = pf2_w_fsnext(message->object);
|
||||
break;
|
||||
case 0x71:
|
||||
message->result.status = pf2_w_fsexec(message->object,message->value, (u8)message->drive);
|
||||
break;
|
||||
case 0x72:
|
||||
message->result.status = pf2_w_combine(message->object,message->data);
|
||||
break;
|
||||
case 0x73:
|
||||
message->result.status = pf2_w_divide(message->object,message->data, message->value);
|
||||
break;
|
||||
case 0x74:
|
||||
message->result.status = pf2_w_xdivide(message->object,message->data, message->value);
|
||||
break;
|
||||
case 0x76:
|
||||
message->result.status = pf2_w_cinsert(message->object,message->value, message->count);
|
||||
break;
|
||||
case 0x77:
|
||||
message->result.status = pf2_w_insert(message->object,message->value);
|
||||
break;
|
||||
case 0x78:
|
||||
message->result.status = pf2_w_cdelete(message->object,message->value, message->count);
|
||||
break;
|
||||
case 0x79:
|
||||
message->result.status = pf2_w_cut(message->object,message->value);
|
||||
break;
|
||||
case 0x7a:
|
||||
message->result.stream = pf2_w_opendir(message->object);
|
||||
break;
|
||||
default:
|
||||
message->result.status = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
8
libs/RVL_SDK/src/fa/pf_telldir.c
Normal file
8
libs/RVL_SDK/src/fa/pf_telldir.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
extern s32 PFDIR_telldir(FADIR* directory, u32* position);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
s32 pf2_telldir(FADIR* directory, u32* position) {
|
||||
return PFAPI_convertReturnValue(PFDIR_telldir(directory, position));
|
||||
}
|
||||
8
libs/RVL_SDK/src/fa/pf_unregctx.c
Normal file
8
libs/RVL_SDK/src/fa/pf_unregctx.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
extern s32 PFVOL_unregctx(void);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
s32 pf2_unregctx(void) {
|
||||
return PFAPI_convertReturnValue(PFVOL_unregctx());
|
||||
}
|
||||
241
libs/RVL_SDK/src/fa/pf_volume_apiadd.c
Normal file
241
libs/RVL_SDK/src/fa/pf_volume_apiadd.c
Normal file
@@ -0,0 +1,241 @@
|
||||
#include <revolution/types.h>
|
||||
|
||||
typedef struct PFVOL_VOLUME PFVOL_VOLUME;
|
||||
|
||||
typedef struct PFVOL_BPB {
|
||||
u16 bytes_per_sector;
|
||||
u16 num_reserved_sectors;
|
||||
u16 num_root_dir_entries;
|
||||
u8 sectors_per_cluster;
|
||||
u8 num_FATs;
|
||||
u32 total_sectors;
|
||||
u32 sectors_per_FAT;
|
||||
u32 root_dir_cluster;
|
||||
u16 fs_info_sector;
|
||||
u16 backup_boot_sector;
|
||||
u16 ext_flags;
|
||||
u8 media;
|
||||
u8 pad_1b;
|
||||
s32 fat_type;
|
||||
u8 log2_bytes_per_sector;
|
||||
u8 log2_sectors_per_cluster;
|
||||
u8 num_active_FATs;
|
||||
u8 pad_23;
|
||||
u16 num_root_dir_sectors;
|
||||
u16 pad_26;
|
||||
u32 active_FAT_sector;
|
||||
u32 first_root_dir_sector;
|
||||
u32 first_data_sector;
|
||||
u32 num_clusters;
|
||||
} PFVOL_BPB;
|
||||
|
||||
typedef struct PFVOL_DIR_ENTRY {
|
||||
u16 long_name[261];
|
||||
u8 num_entry_LFNs;
|
||||
u8 ordinal;
|
||||
u8 check_sum;
|
||||
u8 pad_20d;
|
||||
s8 short_name[13];
|
||||
u8 small_letter_flag;
|
||||
u8 attr;
|
||||
u8 create_time_ms;
|
||||
u16 create_time;
|
||||
u16 create_date;
|
||||
u16 access_date;
|
||||
u16 modify_time;
|
||||
u16 modify_date;
|
||||
u32 file_size;
|
||||
PFVOL_VOLUME* volume;
|
||||
u32 path_len;
|
||||
u32 start_cluster;
|
||||
u32 entry_sector;
|
||||
u16 entry_offset;
|
||||
} PFVOL_DIR_ENTRY;
|
||||
|
||||
typedef struct PFVOL_FAT_HINT {
|
||||
u32 chain_index;
|
||||
u32 cluster;
|
||||
u32 previous_cluster;
|
||||
u32 reserved;
|
||||
} PFVOL_FAT_HINT;
|
||||
|
||||
typedef struct PFVOL_LAST_CLUSTER {
|
||||
u32 num_last_cluster;
|
||||
u32 max_chain_index;
|
||||
} PFVOL_LAST_CLUSTER;
|
||||
|
||||
typedef struct PFVOL_FAT_LAST_ACCESS {
|
||||
u32 chain_index;
|
||||
u32 cluster;
|
||||
} PFVOL_FAT_LAST_ACCESS;
|
||||
|
||||
typedef struct PFVOL_CLUSTER_LINK {
|
||||
u32* buffer;
|
||||
u16 interval;
|
||||
u16 interval_offset;
|
||||
u32 position;
|
||||
u32 max_count;
|
||||
u32 save_index;
|
||||
} PFVOL_CLUSTER_LINK;
|
||||
|
||||
typedef struct PFVOL_FFD {
|
||||
u32 start_cluster;
|
||||
u32 flags;
|
||||
u32* p_start_cluster;
|
||||
PFVOL_LAST_CLUSTER last_cluster;
|
||||
PFVOL_FAT_LAST_ACCESS last_access;
|
||||
PFVOL_CLUSTER_LINK cluster_link;
|
||||
PFVOL_FAT_HINT* hint;
|
||||
PFVOL_VOLUME* volume;
|
||||
} PFVOL_FFD;
|
||||
|
||||
typedef struct PFVOL_STR {
|
||||
const char* head;
|
||||
const char* tail;
|
||||
const char* current;
|
||||
u32 code_mode;
|
||||
} PFVOL_STR;
|
||||
|
||||
typedef struct PFVOL_CURRENT_DIR {
|
||||
u32 stat;
|
||||
s32 context_id;
|
||||
PFVOL_DIR_ENTRY directory;
|
||||
} PFVOL_CURRENT_DIR;
|
||||
|
||||
typedef struct PFVOL_CURRENT_VOLUME {
|
||||
u32 stat;
|
||||
s32 context_id;
|
||||
PFVOL_VOLUME* volume;
|
||||
} PFVOL_CURRENT_VOLUME;
|
||||
|
||||
typedef struct PFVOL_CONTEXT {
|
||||
u32 stat;
|
||||
s32 context_id;
|
||||
} PFVOL_CONTEXT;
|
||||
|
||||
typedef struct PFVOL_VOLUME_INFO {
|
||||
s8 label[12];
|
||||
u8 attr;
|
||||
u8 reserved_0d[3];
|
||||
u32 time;
|
||||
u32 date;
|
||||
} PFVOL_VOLUME_INFO;
|
||||
|
||||
typedef struct PFVOL_CHARCODE {
|
||||
s32 (*oem2unicode)(const s8*, u16*);
|
||||
s32 (*unicode2oem)(const u16*, s8*);
|
||||
s32 (*oem_char_width)(const s8*);
|
||||
s32 (*is_oem_mb_char)(s8, s32);
|
||||
s32 (*unicode_char_width)(const u16*);
|
||||
s32 (*is_unicode_mb_char)(u16, s32);
|
||||
} PFVOL_CHARCODE;
|
||||
|
||||
typedef struct PFVOL_CACHE_SETTING {
|
||||
void* pages;
|
||||
void* buffers;
|
||||
u16 num_fat_pages;
|
||||
u16 num_data_pages;
|
||||
u32 num_fat_buf_size;
|
||||
u32 num_data_buf_size;
|
||||
} PFVOL_CACHE_SETTING;
|
||||
|
||||
typedef struct PFVOL_DRIVER {
|
||||
void* partition;
|
||||
PFVOL_CACHE_SETTING* cache;
|
||||
s8 drive;
|
||||
u8 stat;
|
||||
u8 pad_0a[2];
|
||||
} PFVOL_DRIVER;
|
||||
|
||||
typedef struct PFVOL_OPEN_SFD {
|
||||
u8 gap_0000[0x3C];
|
||||
PFVOL_DIR_ENTRY directory_entry;
|
||||
} PFVOL_OPEN_SFD;
|
||||
|
||||
typedef struct PFVOL_OPEN_FILE {
|
||||
u32 stat;
|
||||
u32 reserved;
|
||||
PFVOL_OPEN_SFD* stream;
|
||||
u8 gap_000C[0x24];
|
||||
} PFVOL_OPEN_FILE;
|
||||
|
||||
typedef struct PFVOL_CLUSTER_SETTING {
|
||||
u32* buffer;
|
||||
u32 max_count;
|
||||
u16 interval;
|
||||
u16 reserved;
|
||||
} PFVOL_CLUSTER_SETTING;
|
||||
|
||||
struct PFVOL_VOLUME {
|
||||
PFVOL_BPB bpb;
|
||||
u32 num_free_clusters;
|
||||
u32 last_free_cluster;
|
||||
u8 gap_0040[0xD0C];
|
||||
PFVOL_OPEN_FILE files[5];
|
||||
u8 gap_0E3C[0x7E0];
|
||||
u32 num_open_files;
|
||||
u32 num_open_dirs;
|
||||
u32 cache_flags;
|
||||
u16 num_fat_pages;
|
||||
u16 num_data_pages;
|
||||
u8 gap_162C[0x10];
|
||||
u32 num_fat_buf_size;
|
||||
u32 num_data_buf_size;
|
||||
u8 gap_1644[4];
|
||||
s8 label[12];
|
||||
PFVOL_CURRENT_DIR current_dir[4];
|
||||
u32 file_buffer_count;
|
||||
void* file_buffers;
|
||||
void* current_file_buffer;
|
||||
u32 last_error;
|
||||
u32 last_driver_error;
|
||||
u32 reserved_1f88;
|
||||
u16 flags;
|
||||
s8 drv_char;
|
||||
u8 drive_state;
|
||||
u16 fsi_flag;
|
||||
u16 reserved_1f92;
|
||||
u16 cluster_link_flags;
|
||||
u16 cluster_link_interval;
|
||||
u32* cluster_link_buffer;
|
||||
u32 cluster_link_capacity;
|
||||
void* driver_partition;
|
||||
u8 gap_1fa4[4];
|
||||
const u8* format_options;
|
||||
};
|
||||
|
||||
typedef struct PFVOL_SET {
|
||||
u32 flags;
|
||||
u32 reserved_004;
|
||||
PFVOL_VOLUME* current_volume;
|
||||
PFVOL_CURRENT_VOLUME context_volume[3];
|
||||
s32 num_attached_drives;
|
||||
s32 num_mounted_volumes;
|
||||
u32 config;
|
||||
void* user_data;
|
||||
s32 last_error;
|
||||
s32 last_driver_error;
|
||||
PFVOL_CHARCODE codeset;
|
||||
u32 setting;
|
||||
u8 gap_0064[0x0C];
|
||||
PFVOL_CONTEXT context[3];
|
||||
PFVOL_VOLUME volumes[26];
|
||||
} PFVOL_SET;
|
||||
|
||||
extern PFVOL_SET pf_vol_set;
|
||||
extern PFVOL_VOLUME* PFVOL_GetVolumeFromDrvChar(s8 drive);
|
||||
|
||||
s32 PFVOL_iswriteprotected(s8 drive, u32* protected_status) {
|
||||
PFVOL_VOLUME* volume = PFVOL_GetVolumeFromDrvChar(drive);
|
||||
if (!(volume->flags & 8)) {
|
||||
pf_vol_set.last_error = 9;
|
||||
volume->last_error = 9;
|
||||
return 9;
|
||||
}
|
||||
if (volume->flags & 2) {
|
||||
*protected_status = 1;
|
||||
} else {
|
||||
*protected_status = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
33
libs/RVL_SDK/src/fa/pf_w_cdelete.c
Normal file
33
libs/RVL_SDK/src/fa/pf_w_cdelete.c
Normal file
@@ -0,0 +1,33 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
typedef struct PF_API_STRING {
|
||||
const s8* head;
|
||||
const s8* tail;
|
||||
const s8* current;
|
||||
u32 code_mode;
|
||||
} PF_API_STRING;
|
||||
|
||||
typedef struct PF_API_VOLUME_SET {
|
||||
u8 reserved[0x40];
|
||||
s32 last_error;
|
||||
} PF_API_VOLUME_SET;
|
||||
|
||||
extern PF_API_VOLUME_SET pf_vol_set;
|
||||
extern s32 PFSTR_InitStr(PF_API_STRING* string, const s8* text, u32 mode);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
extern s32 PFFILE_cdelete(PF_API_STRING* path, u32 position, u32 count, u32* completed);
|
||||
|
||||
u32 pf2_w_cdelete(const u16* path, u32 position, u32 count) {
|
||||
PF_API_STRING path_string;
|
||||
u32 completed = 0;
|
||||
s32 error;
|
||||
|
||||
error = PFSTR_InitStr(&path_string, (const s8*)path, 2);
|
||||
if (error == 0) {
|
||||
error = PFFILE_cdelete(&path_string, position, count, &completed);
|
||||
} else {
|
||||
pf_vol_set.last_error = error;
|
||||
}
|
||||
return completed;
|
||||
}
|
||||
32
libs/RVL_SDK/src/fa/pf_w_chdir.c
Normal file
32
libs/RVL_SDK/src/fa/pf_w_chdir.c
Normal file
@@ -0,0 +1,32 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
typedef struct PF_API_STRING {
|
||||
const s8* head;
|
||||
const s8* tail;
|
||||
const s8* current;
|
||||
u32 code_mode;
|
||||
} PF_API_STRING;
|
||||
|
||||
typedef struct PF_API_VOLUME_SET {
|
||||
u8 reserved[0x40];
|
||||
s32 last_error;
|
||||
} PF_API_VOLUME_SET;
|
||||
|
||||
extern PF_API_VOLUME_SET pf_vol_set;
|
||||
extern s32 PFSTR_InitStr(PF_API_STRING* string, const s8* text, u32 mode);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
extern s32 PFDIR_chdir(PF_API_STRING* path);
|
||||
|
||||
s32 pf2_w_chdir(const u16* path) {
|
||||
PF_API_STRING path_string;
|
||||
s32 error;
|
||||
|
||||
error = PFSTR_InitStr(&path_string, (const s8*)path, 2);
|
||||
if (error == 0) {
|
||||
error = PFDIR_chdir(&path_string);
|
||||
} else {
|
||||
pf_vol_set.last_error = error;
|
||||
}
|
||||
return PFAPI_convertReturnValue(error);
|
||||
}
|
||||
32
libs/RVL_SDK/src/fa/pf_w_chdmod.c
Normal file
32
libs/RVL_SDK/src/fa/pf_w_chdmod.c
Normal file
@@ -0,0 +1,32 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
typedef struct PF_API_STRING {
|
||||
const s8* head;
|
||||
const s8* tail;
|
||||
const s8* current;
|
||||
u32 code_mode;
|
||||
} PF_API_STRING;
|
||||
|
||||
typedef struct PF_API_VOLUME_SET {
|
||||
u8 reserved[0x40];
|
||||
s32 last_error;
|
||||
} PF_API_VOLUME_SET;
|
||||
|
||||
extern PF_API_VOLUME_SET pf_vol_set;
|
||||
extern s32 PFSTR_InitStr(PF_API_STRING* string, const s8* text, u32 mode);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
extern s32 PFDIR_chdmod(PF_API_STRING* path, u8 attributes);
|
||||
|
||||
s32 pf2_w_chdmod(const u16* path, u32 attributes) {
|
||||
PF_API_STRING path_string;
|
||||
s32 error;
|
||||
|
||||
error = PFSTR_InitStr(&path_string, (const s8*)path, 2);
|
||||
if (error == 0) {
|
||||
error = PFDIR_chdmod(&path_string, attributes);
|
||||
} else {
|
||||
pf_vol_set.last_error = error;
|
||||
}
|
||||
return PFAPI_convertReturnValue(error);
|
||||
}
|
||||
32
libs/RVL_SDK/src/fa/pf_w_chmod.c
Normal file
32
libs/RVL_SDK/src/fa/pf_w_chmod.c
Normal file
@@ -0,0 +1,32 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
typedef struct PF_API_STRING {
|
||||
const s8* head;
|
||||
const s8* tail;
|
||||
const s8* current;
|
||||
u32 code_mode;
|
||||
} PF_API_STRING;
|
||||
|
||||
typedef struct PF_API_VOLUME_SET {
|
||||
u8 reserved[0x40];
|
||||
s32 last_error;
|
||||
} PF_API_VOLUME_SET;
|
||||
|
||||
extern PF_API_VOLUME_SET pf_vol_set;
|
||||
extern s32 PFSTR_InitStr(PF_API_STRING* string, const s8* text, u32 mode);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
extern s32 PFDIR_chmod(PF_API_STRING* path, u8 attributes);
|
||||
|
||||
s32 pf2_w_chmod(const u16* path, u32 attributes) {
|
||||
PF_API_STRING path_string;
|
||||
s32 error;
|
||||
|
||||
error = PFSTR_InitStr(&path_string, (const s8*)path, 2);
|
||||
if (error == 0) {
|
||||
error = PFDIR_chmod(&path_string, attributes);
|
||||
} else {
|
||||
pf_vol_set.last_error = error;
|
||||
}
|
||||
return PFAPI_convertReturnValue(error);
|
||||
}
|
||||
33
libs/RVL_SDK/src/fa/pf_w_cinsert.c
Normal file
33
libs/RVL_SDK/src/fa/pf_w_cinsert.c
Normal file
@@ -0,0 +1,33 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
typedef struct PF_API_STRING {
|
||||
const s8* head;
|
||||
const s8* tail;
|
||||
const s8* current;
|
||||
u32 code_mode;
|
||||
} PF_API_STRING;
|
||||
|
||||
typedef struct PF_API_VOLUME_SET {
|
||||
u8 reserved[0x40];
|
||||
s32 last_error;
|
||||
} PF_API_VOLUME_SET;
|
||||
|
||||
extern PF_API_VOLUME_SET pf_vol_set;
|
||||
extern s32 PFSTR_InitStr(PF_API_STRING* string, const s8* text, u32 mode);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
extern s32 PFFILE_cinsert(PF_API_STRING* path, u32 position, u32 count, u32* completed);
|
||||
|
||||
u32 pf2_w_cinsert(const u16* path, u32 position, u32 count) {
|
||||
PF_API_STRING path_string;
|
||||
u32 completed = 0;
|
||||
s32 error;
|
||||
|
||||
error = PFSTR_InitStr(&path_string, (const s8*)path, 2);
|
||||
if (error == 0) {
|
||||
error = PFFILE_cinsert(&path_string, position, count, &completed);
|
||||
} else {
|
||||
pf_vol_set.last_error = error;
|
||||
}
|
||||
return completed;
|
||||
}
|
||||
34
libs/RVL_SDK/src/fa/pf_w_combine.c
Normal file
34
libs/RVL_SDK/src/fa/pf_w_combine.c
Normal file
@@ -0,0 +1,34 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
typedef struct PF_API_STRING {
|
||||
const s8* head;
|
||||
const s8* tail;
|
||||
const s8* current;
|
||||
u32 code_mode;
|
||||
} PF_API_STRING;
|
||||
|
||||
typedef struct PF_API_VOLUME_SET {
|
||||
u8 reserved[0x40];
|
||||
s32 last_error;
|
||||
} PF_API_VOLUME_SET;
|
||||
|
||||
extern PF_API_VOLUME_SET pf_vol_set;
|
||||
extern s32 PFSTR_InitStr(PF_API_STRING* string, const s8* text, u32 mode);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
extern s32 PFFILE_combine(PF_API_STRING* source, PF_API_STRING* destination);
|
||||
|
||||
s32 pf2_w_combine(const u16* source, const u16* destination) {
|
||||
PF_API_STRING source_string;
|
||||
PF_API_STRING destination_string;
|
||||
s32 error;
|
||||
|
||||
error = PFSTR_InitStr(&source_string, (const s8*)source, 2);
|
||||
error |= PFSTR_InitStr(&destination_string, (const s8*)destination, 2);
|
||||
if (error == 0) {
|
||||
error = PFFILE_combine(&source_string, &destination_string);
|
||||
} else {
|
||||
pf_vol_set.last_error = error;
|
||||
}
|
||||
return PFAPI_convertReturnValue(error);
|
||||
}
|
||||
34
libs/RVL_SDK/src/fa/pf_w_create.c
Normal file
34
libs/RVL_SDK/src/fa/pf_w_create.c
Normal file
@@ -0,0 +1,34 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
typedef struct PF_API_STRING {
|
||||
const s8* head;
|
||||
const s8* tail;
|
||||
const s8* current;
|
||||
u32 code_mode;
|
||||
} PF_API_STRING;
|
||||
|
||||
typedef struct PF_API_VOLUME_SET {
|
||||
u8 reserved[0x40];
|
||||
s32 last_error;
|
||||
} PF_API_VOLUME_SET;
|
||||
|
||||
extern PF_API_VOLUME_SET pf_vol_set;
|
||||
extern s32 PFSTR_InitStr(PF_API_STRING* string, const s8* text, u32 mode);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
extern s32 PFFILE_fopen(PF_API_STRING* path, s32 mode, FAFILE** file);
|
||||
extern void* PFAPI_convertReturnValue2NULL(s32 error, void* stream);
|
||||
|
||||
FAFILE* pf2_w_create(const u16* path) {
|
||||
PF_API_STRING path_string;
|
||||
FAFILE* file;
|
||||
s32 error;
|
||||
|
||||
error = PFSTR_InitStr(&path_string, (const s8*)path, 2);
|
||||
if (error == 0) {
|
||||
error = PFFILE_fopen(&path_string, 25, &file);
|
||||
} else {
|
||||
pf_vol_set.last_error = error;
|
||||
}
|
||||
return PFAPI_convertReturnValue2NULL(error, file);
|
||||
}
|
||||
32
libs/RVL_SDK/src/fa/pf_w_createdir.c
Normal file
32
libs/RVL_SDK/src/fa/pf_w_createdir.c
Normal file
@@ -0,0 +1,32 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
typedef struct PF_API_STRING {
|
||||
const s8* head;
|
||||
const s8* tail;
|
||||
const s8* current;
|
||||
u32 code_mode;
|
||||
} PF_API_STRING;
|
||||
|
||||
typedef struct PF_API_VOLUME_SET {
|
||||
u8 reserved[0x40];
|
||||
s32 last_error;
|
||||
} PF_API_VOLUME_SET;
|
||||
|
||||
extern PF_API_VOLUME_SET pf_vol_set;
|
||||
extern s32 PFSTR_InitStr(PF_API_STRING* string, const s8* text, u32 mode);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
extern s32 PFDIR_createdir(PF_API_STRING* path, s32 mode, FADta* data);
|
||||
|
||||
s32 pf2_w_createdir(const u16* path, s32 mode, FADta* data) {
|
||||
PF_API_STRING path_string;
|
||||
s32 error;
|
||||
|
||||
error = PFSTR_InitStr(&path_string, (const s8*)path, 2);
|
||||
if (error == 0) {
|
||||
error = PFDIR_createdir(&path_string, mode, data);
|
||||
} else {
|
||||
pf_vol_set.last_error = error;
|
||||
}
|
||||
return PFAPI_convertReturnValue(error);
|
||||
}
|
||||
36
libs/RVL_SDK/src/fa/pf_w_cut.c
Normal file
36
libs/RVL_SDK/src/fa/pf_w_cut.c
Normal file
@@ -0,0 +1,36 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
typedef struct PF_API_STRING {
|
||||
const s8* head;
|
||||
const s8* tail;
|
||||
const s8* current;
|
||||
u32 code_mode;
|
||||
} PF_API_STRING;
|
||||
|
||||
typedef struct PF_API_VOLUME_SET {
|
||||
u8 reserved[0x40];
|
||||
s32 last_error;
|
||||
} PF_API_VOLUME_SET;
|
||||
|
||||
extern PF_API_VOLUME_SET pf_vol_set;
|
||||
extern s32 PFSTR_InitStr(PF_API_STRING* string, const s8* text, u32 mode);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
extern s32 PFFILE_cdelete(PF_API_STRING* path, u32 position, u32 count, u32* completed);
|
||||
|
||||
s32 pf2_w_cut(const u16* path, u32 position) {
|
||||
PF_API_STRING path_string;
|
||||
u32 completed;
|
||||
s32 error;
|
||||
|
||||
error = PFSTR_InitStr(&path_string, (const s8*)path, 2);
|
||||
if (error == 0) {
|
||||
PFFILE_cdelete(&path_string, position, 1, &completed);
|
||||
if (completed != 1) {
|
||||
error = -1;
|
||||
}
|
||||
} else {
|
||||
pf_vol_set.last_error = error;
|
||||
}
|
||||
return PFAPI_convertReturnValue(error);
|
||||
}
|
||||
34
libs/RVL_SDK/src/fa/pf_w_divide.c
Normal file
34
libs/RVL_SDK/src/fa/pf_w_divide.c
Normal file
@@ -0,0 +1,34 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
typedef struct PF_API_STRING {
|
||||
const s8* head;
|
||||
const s8* tail;
|
||||
const s8* current;
|
||||
u32 code_mode;
|
||||
} PF_API_STRING;
|
||||
|
||||
typedef struct PF_API_VOLUME_SET {
|
||||
u8 reserved[0x40];
|
||||
s32 last_error;
|
||||
} PF_API_VOLUME_SET;
|
||||
|
||||
extern PF_API_VOLUME_SET pf_vol_set;
|
||||
extern s32 PFSTR_InitStr(PF_API_STRING* string, const s8* text, u32 mode);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
extern s32 PFFILE_divide(PF_API_STRING* source, PF_API_STRING* destination, u32 offset);
|
||||
|
||||
s32 pf2_w_divide(const u16* source, const u16* destination, u32 offset) {
|
||||
PF_API_STRING source_string;
|
||||
PF_API_STRING destination_string;
|
||||
s32 error;
|
||||
|
||||
error = PFSTR_InitStr(&source_string, (const s8*)source, 2);
|
||||
error |= PFSTR_InitStr(&destination_string, (const s8*)destination, 2);
|
||||
if (error == 0) {
|
||||
error = PFFILE_divide(&source_string, &destination_string, offset);
|
||||
} else {
|
||||
pf_vol_set.last_error = error;
|
||||
}
|
||||
return PFAPI_convertReturnValue(error);
|
||||
}
|
||||
34
libs/RVL_SDK/src/fa/pf_w_fconcat.c
Normal file
34
libs/RVL_SDK/src/fa/pf_w_fconcat.c
Normal file
@@ -0,0 +1,34 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
typedef struct PF_API_STRING {
|
||||
const s8* head;
|
||||
const s8* tail;
|
||||
const s8* current;
|
||||
u32 code_mode;
|
||||
} PF_API_STRING;
|
||||
|
||||
typedef struct PF_API_VOLUME_SET {
|
||||
u8 reserved[0x40];
|
||||
s32 last_error;
|
||||
} PF_API_VOLUME_SET;
|
||||
|
||||
extern PF_API_VOLUME_SET pf_vol_set;
|
||||
extern s32 PFSTR_InitStr(PF_API_STRING* string, const s8* text, u32 mode);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
extern s32 PFFILE_combine(PF_API_STRING* source, PF_API_STRING* destination);
|
||||
|
||||
s32 pf2_w_fconcat(const u16* source, const u16* destination) {
|
||||
PF_API_STRING source_string;
|
||||
PF_API_STRING destination_string;
|
||||
s32 error;
|
||||
|
||||
error = PFSTR_InitStr(&source_string, (const s8*)source, 2);
|
||||
error |= PFSTR_InitStr(&destination_string, (const s8*)destination, 2);
|
||||
if (error == 0) {
|
||||
error = PFFILE_combine(&source_string, &destination_string);
|
||||
} else {
|
||||
pf_vol_set.last_error = error;
|
||||
}
|
||||
return PFAPI_convertReturnValue(error);
|
||||
}
|
||||
41
libs/RVL_SDK/src/fa/pf_w_fopen.c
Normal file
41
libs/RVL_SDK/src/fa/pf_w_fopen.c
Normal file
@@ -0,0 +1,41 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
typedef struct PFF2_STR {
|
||||
const s8* p_head;
|
||||
const s8* p_tail;
|
||||
const s8* p_current;
|
||||
u32 code_mode;
|
||||
} PFF2_STR;
|
||||
|
||||
typedef struct PFF2_VOL_SET {
|
||||
u8 reserved[0x40];
|
||||
s32 last_error;
|
||||
} PFF2_VOL_SET;
|
||||
|
||||
extern PFF2_VOL_SET pf_vol_set;
|
||||
extern s32 PFWAPI_ParseOpenModeString(const u16* mode_str);
|
||||
extern s32 PFSTR_InitStr(PFF2_STR* path, const s8* text, u32 code_mode);
|
||||
extern s32 PFFILE_fopen(PFF2_STR* path, s32 mode, FAFILE** result);
|
||||
extern FAFILE* PFAPI_convertReturnValue2NULL(s32 err, FAFILE* p_stream);
|
||||
|
||||
FAFILE* pf2_w_fopen(const u16* path, const u16* mode) {
|
||||
u32 open_mode;
|
||||
FAFILE* p_file;
|
||||
PFF2_STR path_str;
|
||||
s32 err;
|
||||
|
||||
open_mode = PFWAPI_ParseOpenModeString(mode);
|
||||
if (open_mode == 0) {
|
||||
pf_vol_set.last_error = 10;
|
||||
p_file = NULL;
|
||||
} else {
|
||||
err = PFSTR_InitStr(&path_str, (const s8*)path, 2);
|
||||
if (err == 0) {
|
||||
err = PFFILE_fopen(&path_str, open_mode, &p_file);
|
||||
} else {
|
||||
pf_vol_set.last_error = err;
|
||||
}
|
||||
p_file = PFAPI_convertReturnValue2NULL(err, p_file);
|
||||
}
|
||||
return p_file;
|
||||
}
|
||||
8
libs/RVL_SDK/src/fa/pf_w_fsexec.c
Normal file
8
libs/RVL_SDK/src/fa/pf_w_fsexec.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
extern s32 PFDIR_fsexec(FADta* data, u32 flags, u32 mode);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
s32 pf2_w_fsexec(FADta* data, u32 flags, u32 mode) {
|
||||
return PFAPI_convertReturnValue(PFDIR_fsexec(data, flags, mode));
|
||||
}
|
||||
32
libs/RVL_SDK/src/fa/pf_w_fsfirst.c
Normal file
32
libs/RVL_SDK/src/fa/pf_w_fsfirst.c
Normal file
@@ -0,0 +1,32 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
typedef struct PF_API_STRING {
|
||||
const s8* head;
|
||||
const s8* tail;
|
||||
const s8* current;
|
||||
u32 code_mode;
|
||||
} PF_API_STRING;
|
||||
|
||||
typedef struct PF_API_VOLUME_SET {
|
||||
u8 reserved[0x40];
|
||||
s32 last_error;
|
||||
} PF_API_VOLUME_SET;
|
||||
|
||||
extern PF_API_VOLUME_SET pf_vol_set;
|
||||
extern s32 PFSTR_InitStr(PF_API_STRING* string, const s8* text, u32 mode);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
extern s32 PFDIR_fsfirst(PF_API_STRING* path, u8 attributes, FADta* data);
|
||||
|
||||
s32 pf2_w_fsfirst(const u16* path, u8 attributes, FADta* data) {
|
||||
PF_API_STRING path_string;
|
||||
s32 error;
|
||||
|
||||
error = PFSTR_InitStr(&path_string, (const s8*)path, 2);
|
||||
if (error == 0) {
|
||||
error = PFDIR_fsfirst(&path_string, attributes, data);
|
||||
} else {
|
||||
pf_vol_set.last_error = error;
|
||||
}
|
||||
return PFAPI_convertReturnValue(error);
|
||||
}
|
||||
8
libs/RVL_SDK/src/fa/pf_w_fsnext.c
Normal file
8
libs/RVL_SDK/src/fa/pf_w_fsnext.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
extern s32 PFDIR_fsnext(FADta* data);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
s32 pf2_w_fsnext(FADta* data) {
|
||||
return PFAPI_convertReturnValue(PFDIR_fsnext(data));
|
||||
}
|
||||
32
libs/RVL_SDK/src/fa/pf_w_fstat.c
Normal file
32
libs/RVL_SDK/src/fa/pf_w_fstat.c
Normal file
@@ -0,0 +1,32 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
typedef struct PF_API_STRING {
|
||||
const s8* head;
|
||||
const s8* tail;
|
||||
const s8* current;
|
||||
u32 code_mode;
|
||||
} PF_API_STRING;
|
||||
|
||||
typedef struct PF_API_VOLUME_SET {
|
||||
u8 reserved[0x40];
|
||||
s32 last_error;
|
||||
} PF_API_VOLUME_SET;
|
||||
|
||||
extern PF_API_VOLUME_SET pf_vol_set;
|
||||
extern s32 PFSTR_InitStr(PF_API_STRING* string, const s8* text, u32 mode);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
extern s32 PFDIR_fstat(PF_API_STRING* path, FAFileStat* stat);
|
||||
|
||||
s32 pf2_w_fstat(const u16* path, FAFileStat* stat) {
|
||||
PF_API_STRING path_string;
|
||||
s32 error;
|
||||
|
||||
error = PFSTR_InitStr(&path_string, (const s8*)path, 2);
|
||||
if (error == 0) {
|
||||
error = PFDIR_fstat(&path_string, stat);
|
||||
} else {
|
||||
pf_vol_set.last_error = error;
|
||||
}
|
||||
return PFAPI_convertReturnValue(error);
|
||||
}
|
||||
42
libs/RVL_SDK/src/fa/pf_w_insert.c
Normal file
42
libs/RVL_SDK/src/fa/pf_w_insert.c
Normal file
@@ -0,0 +1,42 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
typedef struct PF_API_STRING {
|
||||
const s8* head;
|
||||
const s8* tail;
|
||||
const s8* current;
|
||||
u32 code_mode;
|
||||
} PF_API_STRING;
|
||||
|
||||
typedef struct PF_API_VOLUME_SET {
|
||||
u8 reserved[0x40];
|
||||
s32 last_error;
|
||||
} PF_API_VOLUME_SET;
|
||||
|
||||
extern PF_API_VOLUME_SET pf_vol_set;
|
||||
extern s32 PFSTR_InitStr(PF_API_STRING* string, const s8* text, u32 mode);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
extern s32 PFFILE_cinsert(PF_API_STRING* path, u32 position, u32 count, u32* completed);
|
||||
extern s32 PFFILE_cdelete(PF_API_STRING* path, u32 position, u32 count, u32* completed);
|
||||
|
||||
s32 pf2_w_insert(const u16* path, u32 count) {
|
||||
PF_API_STRING path_string;
|
||||
u32 inserted;
|
||||
u32 deleted;
|
||||
s32 error;
|
||||
|
||||
error = PFSTR_InitStr(&path_string, (const s8*)path, 2);
|
||||
if (error == 0) {
|
||||
PFFILE_cinsert(&path_string, 0, count, &inserted);
|
||||
if (count != inserted || count == 0) {
|
||||
if (inserted != 0) {
|
||||
PFSTR_InitStr(&path_string, (const s8*)path, 2);
|
||||
PFFILE_cdelete(&path_string, 0, inserted, &deleted);
|
||||
}
|
||||
error = -1;
|
||||
}
|
||||
} else {
|
||||
pf_vol_set.last_error = error;
|
||||
}
|
||||
return PFAPI_convertReturnValue(error);
|
||||
}
|
||||
32
libs/RVL_SDK/src/fa/pf_w_mkdir.c
Normal file
32
libs/RVL_SDK/src/fa/pf_w_mkdir.c
Normal file
@@ -0,0 +1,32 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
typedef struct PF_API_STRING {
|
||||
const s8* head;
|
||||
const s8* tail;
|
||||
const s8* current;
|
||||
u32 code_mode;
|
||||
} PF_API_STRING;
|
||||
|
||||
typedef struct PF_API_VOLUME_SET {
|
||||
u8 reserved[0x40];
|
||||
s32 last_error;
|
||||
} PF_API_VOLUME_SET;
|
||||
|
||||
extern PF_API_VOLUME_SET pf_vol_set;
|
||||
extern s32 PFSTR_InitStr(PF_API_STRING* string, const s8* text, u32 mode);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
extern s32 PFDIR_mkdir(PF_API_STRING* path);
|
||||
|
||||
s32 pf2_w_mkdir(const u16* path) {
|
||||
PF_API_STRING path_string;
|
||||
s32 error;
|
||||
|
||||
error = PFSTR_InitStr(&path_string, (const s8*)path, 2);
|
||||
if (error == 0) {
|
||||
error = PFDIR_mkdir(&path_string);
|
||||
} else {
|
||||
pf_vol_set.last_error = error;
|
||||
}
|
||||
return PFAPI_convertReturnValue(error);
|
||||
}
|
||||
34
libs/RVL_SDK/src/fa/pf_w_move.c
Normal file
34
libs/RVL_SDK/src/fa/pf_w_move.c
Normal file
@@ -0,0 +1,34 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
typedef struct PF_API_STRING {
|
||||
const s8* head;
|
||||
const s8* tail;
|
||||
const s8* current;
|
||||
u32 code_mode;
|
||||
} PF_API_STRING;
|
||||
|
||||
typedef struct PF_API_VOLUME_SET {
|
||||
u8 reserved[0x40];
|
||||
s32 last_error;
|
||||
} PF_API_VOLUME_SET;
|
||||
|
||||
extern PF_API_VOLUME_SET pf_vol_set;
|
||||
extern s32 PFSTR_InitStr(PF_API_STRING* string, const s8* text, u32 mode);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
extern s32 PFDIR_move(PF_API_STRING* source, PF_API_STRING* destination);
|
||||
|
||||
s32 pf2_w_move(const u16* source, const u16* destination) {
|
||||
PF_API_STRING source_string;
|
||||
PF_API_STRING destination_string;
|
||||
s32 error;
|
||||
|
||||
error = PFSTR_InitStr(&source_string, (const s8*)source, 2);
|
||||
error |= PFSTR_InitStr(&destination_string, (const s8*)destination, 2);
|
||||
if (error == 0) {
|
||||
error = PFDIR_move(&source_string, &destination_string);
|
||||
} else {
|
||||
pf_vol_set.last_error = error;
|
||||
}
|
||||
return PFAPI_convertReturnValue(error);
|
||||
}
|
||||
34
libs/RVL_SDK/src/fa/pf_w_opendir.c
Normal file
34
libs/RVL_SDK/src/fa/pf_w_opendir.c
Normal file
@@ -0,0 +1,34 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
typedef struct PF_API_STRING {
|
||||
const s8* head;
|
||||
const s8* tail;
|
||||
const s8* current;
|
||||
u32 code_mode;
|
||||
} PF_API_STRING;
|
||||
|
||||
typedef struct PF_API_VOLUME_SET {
|
||||
u8 reserved[0x40];
|
||||
s32 last_error;
|
||||
} PF_API_VOLUME_SET;
|
||||
|
||||
extern PF_API_VOLUME_SET pf_vol_set;
|
||||
extern s32 PFSTR_InitStr(PF_API_STRING* string, const s8* text, u32 mode);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
extern s32 PFDIR_opendir(PF_API_STRING* path, FADIR** directory);
|
||||
extern void* PFAPI_convertReturnValue2NULL(s32 error, void* stream);
|
||||
|
||||
FADIR* pf2_w_opendir(const u16* path) {
|
||||
PF_API_STRING path_string;
|
||||
FADIR* directory;
|
||||
s32 error;
|
||||
|
||||
error = PFSTR_InitStr(&path_string, (const s8*)path, 2);
|
||||
if (error == 0) {
|
||||
error = PFDIR_opendir(&path_string, &directory);
|
||||
} else {
|
||||
pf_vol_set.last_error = error;
|
||||
}
|
||||
return PFAPI_convertReturnValue2NULL(error, directory);
|
||||
}
|
||||
32
libs/RVL_SDK/src/fa/pf_w_remove.c
Normal file
32
libs/RVL_SDK/src/fa/pf_w_remove.c
Normal file
@@ -0,0 +1,32 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
typedef struct PF_API_STRING {
|
||||
const s8* head;
|
||||
const s8* tail;
|
||||
const s8* current;
|
||||
u32 code_mode;
|
||||
} PF_API_STRING;
|
||||
|
||||
typedef struct PF_API_VOLUME_SET {
|
||||
u8 reserved[0x40];
|
||||
s32 last_error;
|
||||
} PF_API_VOLUME_SET;
|
||||
|
||||
extern PF_API_VOLUME_SET pf_vol_set;
|
||||
extern s32 PFSTR_InitStr(PF_API_STRING* string, const s8* text, u32 mode);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
extern s32 PFFILE_remove(PF_API_STRING* path);
|
||||
|
||||
s32 pf2_w_remove(const u16* path) {
|
||||
PF_API_STRING path_string;
|
||||
s32 error;
|
||||
|
||||
error = PFSTR_InitStr(&path_string, (const s8*)path, 2);
|
||||
if (error == 0) {
|
||||
error = PFFILE_remove(&path_string);
|
||||
} else {
|
||||
pf_vol_set.last_error = error;
|
||||
}
|
||||
return PFAPI_convertReturnValue(error);
|
||||
}
|
||||
34
libs/RVL_SDK/src/fa/pf_w_rename.c
Normal file
34
libs/RVL_SDK/src/fa/pf_w_rename.c
Normal file
@@ -0,0 +1,34 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
typedef struct PF_API_STRING {
|
||||
const s8* head;
|
||||
const s8* tail;
|
||||
const s8* current;
|
||||
u32 code_mode;
|
||||
} PF_API_STRING;
|
||||
|
||||
typedef struct PF_API_VOLUME_SET {
|
||||
u8 reserved[0x40];
|
||||
s32 last_error;
|
||||
} PF_API_VOLUME_SET;
|
||||
|
||||
extern PF_API_VOLUME_SET pf_vol_set;
|
||||
extern s32 PFSTR_InitStr(PF_API_STRING* string, const s8* text, u32 mode);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
extern s32 PFDIR_rename(PF_API_STRING* source, PF_API_STRING* destination);
|
||||
|
||||
s32 pf2_w_rename(const u16* source, const u16* destination) {
|
||||
PF_API_STRING source_string;
|
||||
PF_API_STRING destination_string;
|
||||
s32 error;
|
||||
|
||||
error = PFSTR_InitStr(&source_string, (const s8*)source, 2);
|
||||
error |= PFSTR_InitStr(&destination_string, (const s8*)destination, 2);
|
||||
if (error == 0) {
|
||||
error = PFDIR_rename(&source_string, &destination_string);
|
||||
} else {
|
||||
pf_vol_set.last_error = error;
|
||||
}
|
||||
return PFAPI_convertReturnValue(error);
|
||||
}
|
||||
32
libs/RVL_SDK/src/fa/pf_w_rmdir.c
Normal file
32
libs/RVL_SDK/src/fa/pf_w_rmdir.c
Normal file
@@ -0,0 +1,32 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
typedef struct PF_API_STRING {
|
||||
const s8* head;
|
||||
const s8* tail;
|
||||
const s8* current;
|
||||
u32 code_mode;
|
||||
} PF_API_STRING;
|
||||
|
||||
typedef struct PF_API_VOLUME_SET {
|
||||
u8 reserved[0x40];
|
||||
s32 last_error;
|
||||
} PF_API_VOLUME_SET;
|
||||
|
||||
extern PF_API_VOLUME_SET pf_vol_set;
|
||||
extern s32 PFSTR_InitStr(PF_API_STRING* string, const s8* text, u32 mode);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
extern s32 PFDIR_rmdir(PF_API_STRING* path);
|
||||
|
||||
s32 pf2_w_rmdir(const u16* path) {
|
||||
PF_API_STRING path_string;
|
||||
s32 error;
|
||||
|
||||
error = PFSTR_InitStr(&path_string, (const s8*)path, 2);
|
||||
if (error == 0) {
|
||||
error = PFDIR_rmdir(&path_string);
|
||||
} else {
|
||||
pf_vol_set.last_error = error;
|
||||
}
|
||||
return PFAPI_convertReturnValue(error);
|
||||
}
|
||||
34
libs/RVL_SDK/src/fa/pf_w_xdivide.c
Normal file
34
libs/RVL_SDK/src/fa/pf_w_xdivide.c
Normal file
@@ -0,0 +1,34 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
typedef struct PF_API_STRING {
|
||||
const s8* head;
|
||||
const s8* tail;
|
||||
const s8* current;
|
||||
u32 code_mode;
|
||||
} PF_API_STRING;
|
||||
|
||||
typedef struct PF_API_VOLUME_SET {
|
||||
u8 reserved[0x40];
|
||||
s32 last_error;
|
||||
} PF_API_VOLUME_SET;
|
||||
|
||||
extern PF_API_VOLUME_SET pf_vol_set;
|
||||
extern s32 PFSTR_InitStr(PF_API_STRING* string, const s8* text, u32 mode);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
extern s32 PFFILE_divide(PF_API_STRING* source, PF_API_STRING* destination, u32 offset);
|
||||
|
||||
s32 pf2_w_xdivide(const u16* source, const u16* destination, u32 offset) {
|
||||
PF_API_STRING source_string;
|
||||
PF_API_STRING destination_string;
|
||||
s32 error;
|
||||
|
||||
error = PFSTR_InitStr(&source_string, (const s8*)source, 2);
|
||||
error |= PFSTR_InitStr(&destination_string, (const s8*)destination, 2);
|
||||
if (error == 0) {
|
||||
error = PFFILE_divide(&source_string, &destination_string, offset);
|
||||
} else {
|
||||
pf_vol_set.last_error = error;
|
||||
}
|
||||
return PFAPI_convertReturnValue(error);
|
||||
}
|
||||
34
libs/RVL_SDK/src/fa/pf_xdivide.c
Normal file
34
libs/RVL_SDK/src/fa/pf_xdivide.c
Normal file
@@ -0,0 +1,34 @@
|
||||
#include <revolution/fa.h>
|
||||
|
||||
typedef struct PF_API_STRING {
|
||||
const s8* head;
|
||||
const s8* tail;
|
||||
const s8* current;
|
||||
u32 code_mode;
|
||||
} PF_API_STRING;
|
||||
|
||||
typedef struct PF_API_VOLUME_SET {
|
||||
u8 reserved[0x40];
|
||||
s32 last_error;
|
||||
} PF_API_VOLUME_SET;
|
||||
|
||||
extern PF_API_VOLUME_SET pf_vol_set;
|
||||
extern s32 PFSTR_InitStr(PF_API_STRING* string, const s8* text, u32 mode);
|
||||
extern s32 PFAPI_convertReturnValue(s32 error);
|
||||
|
||||
extern s32 PFFILE_divide(PF_API_STRING* source, PF_API_STRING* destination, u32 offset);
|
||||
|
||||
s32 pf2_xdivide(const char* source, const char* destination, u32 offset) {
|
||||
PF_API_STRING source_string;
|
||||
PF_API_STRING destination_string;
|
||||
s32 error;
|
||||
|
||||
error = PFSTR_InitStr(&source_string, (const s8*)source, 1);
|
||||
error |= PFSTR_InitStr(&destination_string, (const s8*)destination, 1);
|
||||
if (error == 0) {
|
||||
error = PFFILE_divide(&source_string, &destination_string, offset);
|
||||
} else {
|
||||
pf_vol_set.last_error = error;
|
||||
}
|
||||
return PFAPI_convertReturnValue(error);
|
||||
}
|
||||
14
libs/RVL_SDK/src/fa/pfs_attach.c
Normal file
14
libs/RVL_SDK/src/fa/pfs_attach.c
Normal file
@@ -0,0 +1,14 @@
|
||||
#include <revolution/fa/pf_stub.h>
|
||||
|
||||
s32 pfstub_attach(FADrvTbl* drives, u32 mode) {
|
||||
PF_STUB_MESSAGE message;
|
||||
|
||||
message.operation = 27;
|
||||
message.object = drives;
|
||||
message.callback = NULL;
|
||||
message.data = (void*)mode;
|
||||
if (pfstub_com_massage(&message) == -1) {
|
||||
return -1;
|
||||
}
|
||||
return message.result.status;
|
||||
}
|
||||
14
libs/RVL_SDK/src/fa/pfs_buffering.c
Normal file
14
libs/RVL_SDK/src/fa/pfs_buffering.c
Normal file
@@ -0,0 +1,14 @@
|
||||
#include <revolution/fa/pf_stub.h>
|
||||
|
||||
s32 pfstub_buffering(s8 drive, u32 mode) {
|
||||
PF_STUB_MESSAGE message;
|
||||
|
||||
message.operation = 16;
|
||||
message.drive = drive;
|
||||
message.value = mode;
|
||||
message.callback = NULL;
|
||||
if (pfstub_com_massage(&message) == -1) {
|
||||
return -1;
|
||||
}
|
||||
return message.result.status;
|
||||
}
|
||||
14
libs/RVL_SDK/src/fa/pfs_create.c
Normal file
14
libs/RVL_SDK/src/fa/pfs_create.c
Normal file
@@ -0,0 +1,14 @@
|
||||
#include <revolution/fa/pf_stub.h>
|
||||
|
||||
FAFILE* pfstub_create(const char* path, int mode) {
|
||||
PF_STUB_MESSAGE message;
|
||||
|
||||
message.operation = 0;
|
||||
message.object = path;
|
||||
message.value = mode;
|
||||
message.callback = NULL;
|
||||
if (pfstub_com_massage(&message) == -1) {
|
||||
return NULL;
|
||||
}
|
||||
return message.result.stream;
|
||||
}
|
||||
15
libs/RVL_SDK/src/fa/pfs_createdir.c
Normal file
15
libs/RVL_SDK/src/fa/pfs_createdir.c
Normal file
@@ -0,0 +1,15 @@
|
||||
#include <revolution/fa/pf_stub.h>
|
||||
|
||||
s32 pfstub_createdir(const char* path, s32 mode, FADta* data) {
|
||||
PF_STUB_MESSAGE message;
|
||||
|
||||
message.operation = 65;
|
||||
message.object = path;
|
||||
message.value = mode;
|
||||
message.data = data;
|
||||
message.callback = NULL;
|
||||
if (pfstub_com_massage(&message) == -1) {
|
||||
return -1;
|
||||
}
|
||||
return message.result.status;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user