Line 61:
Line 61:
|Print a message to the screen and halts the system
|Print a message to the screen and halts the system
|}
|}
−
−
===Filesystem===
−
{| class="wikitable"
−
!Name
−
!Prototype
−
!Description
−
!Notes
−
|-
−
|FSInit
−
|<code>void FSInit(void);</code>
−
|Initializes the FS library.
−
|Must be called before anything else! Can be called multiple times safely.
−
|-
−
|FSShutdown
−
|<code>void FSShutdown(void);</code>
−
|This is just a "return;".
−
|
−
|-
−
|FSAddClient
−
|<code>int FSAddClient(void *client, int ret_flag);</code>
−
|Registers a new client for use.
−
|Returns 0 if successful. Client size is 0x1700 bytes, should be 0x20 byte padded.
−
|-
−
|FSInitCmdBlock
−
|<code>void FSInitCmdBlock(void *block);</code>
−
|Initializes a command block for use.
−
|Command Block size is 0xA80 bytes, should be 0x20 byte padded.
−
|}
−
−
The FS* functions appear to only be used by regular applications, while the FSA* functions appear to only be used by system rpls.
===Internal===
===Internal===
Line 251:
Line 221:
</syntaxhighlight>
</syntaxhighlight>
|}
|}
+
+
==Filesystem==
+
The FS* functions appear to only be used by regular applications, while the FSA* functions appear to only be used by system rpls.
+
===Initialization===
+
{| class="wikitable"
+
!Name
+
!Prototype
+
!Description
+
!Notes
+
|-
+
|FSInit
+
|<code>void FSInit(void);</code>
+
|Initializes the FS library.
+
|Must be called before anything else! Can be called multiple times safely.
+
|-
+
|FSShutdown
+
|<code>void FSShutdown(void);</code>
+
|This is just a "return;".
+
|
+
|-
+
|FSAddClient
+
|<code>FSStatus FSAddClient(FSClient *client, FSRetflag flag);</code>
+
|Registers a new client for use.
+
|Returns OK or MAX_CLIENTS(-3). Client size is 0x1700 bytes, should be 0x20 byte padded.
+
|-
+
|FSDelClient
+
|<code>FSStatus FSDelClient(FSClient *client, FSRetflag flag);</code>
+
|Unregisters an existing client.
+
|Returns OK. See above for data size.
+
|-
+
|FSGetClientNum
+
|<code>int FSGetClientNum(void);</code>
+
|Gets the number of registered clients.
+
|
+
|}
+
+
===Command Blocks===
+
{| class="wikitable"
+
!Name
+
!Prototype
+
!Description
+
!Notes
+
|-
+
|FSInitCmdBlock
+
|<code>void FSInitCmdBlock(FSCmdBlock *block);</code>
+
|Initializes a command block for use.
+
|Command Block size is 0xA80 bytes, should be 0x20 byte padded.
+
|-
+
|FSCancelCommand
+
|<code>void FSCancelCommand(FSClient *client, FSCmdBlock *block);</code>
+
|Cancels the pending command
+
|Cannot cancel an ongoing command, it has to complete.
+
|-
+
|FSCancelAllCommands
+
|<code>void FSCancelAllCommands(FSClient *client);
+
|Cancels all pending commands for the passed client.
+
|Cannot cancel an ongoing command, it has to complete.
+
|-
+
|FSSetUserData
+
|<code>void FSSetUserData(FSCmdBlock *block, void *user_data);</code>
+
|Sets the user data for the passed command block
+
|
+
|-
+
|FSGetUserData
+
|<code>void* FSGetUserData(FSCmdBlock *block);</code>
+
|Returns pointer to the user data
+
|Can return NULL if invalid, please error check.
+
|-
+
|FSSetCmdPriority
+
|<code>void FSSetCmdPriority(FSCmdBlock *block, uint8_t priority);</code>
+
|Sets the priority for the passed command block
+
|Priority 0 is highest, 31 is lowest, 16 is default.
+
|-
+
|FSGetCmdPriority
+
|<code>int FSGetCmdPriority(FSCmdBlock *block);</code>
+
|Gets the priority for the passed command block
+
|Priority 0 is highest, 31 is lowest, 16 is default.
+
|-
+
|FSGetCurrentCmdBlock
+
|<code>FSCmdBlock* FSGetCurrentCmdBlock(FSClient *client);
+
|Returns a pointer to the command block being processed.
+
|May return NULL if invalid client or if nothing's processed, please error check.
+
|}
+
+
===Defines===
+
<syntaxhighlight lang="C">
+
#define FS_CLIENT_BUFFER_SIZE (5888) /* 0x1700 */
+
#define FS_CMD_BLOCK_SIZE (2688) /* 0xA80 */
+
+
#define FS_STATUS_OK 0 /* Everything looks good */
+
+
#define FS_STATUS_BASE (0)
+
+
#define FS_STATUS_CANCELED (FS_STATUS_BASE - 1)
+
#define FS_STATUS_END (FS_STATUS_BASE - 2)
+
#define FS_STATUS_MAX (FS_STATUS_BASE - 3)
+
+
#define FS_STATUS_ALREADY_OPEN (FS_STATUS_BASE - 4)
+
#define FS_STATUS_EXISTS (FS_STATUS_BASE - 5)
+
#define FS_STATUS_NOT_FOUND (FS_STATUS_BASE - 6)
+
#define FS_STATUS_NOT_FILE (FS_STATUS_BASE - 7)
+
#define FS_STATUS_NOT_DIR (FS_STATUS_BASE - 8)
+
#define FS_STATUS_ACCESS_ERROR (FS_STATUS_BASE - 9)
+
#define FS_STATUS_PERMISSION_ERROR (FS_STATUS_BASE -10)
+
#define FS_STATUS_FILE_TOO_BIG (FS_STATUS_BASE -11)
+
#define FS_STATUS_STORAGE_FULL (FS_STATUS_BASE -12)
+
#define FS_STATUS_JOURNAL_FULL (FS_STATUS_BASE -13)
+
#define FS_STATUS_UNSUPPORTED_CMD (FS_STATUS_BASE -14)
+
+
#define FS_STATUS_MEDIA_NOT_READY (FS_STATUS_BASE -15)
+
#define FS_STATUS_INVALID_MEDIA (FS_STATUS_BASE -16)
+
#define FS_STATUS_MEDIA_ERROR (FS_STATUS_BASE -17)
+
#define FS_STATUS_DATA_CORRUPTED (FS_STATUS_BASE -18)
+
#define FS_STATUS_WRITE_PROTECTED (FS_STATUS_BASE -19)
+
+
#define FS_STATUS_FATAL_ERROR (FS_STATUS_BASE -1024)
+
+
#define FS_RET_NO_ERROR 0x0000
+
#define FS_RET_MAX 0x0001
+
#define FS_RET_ALREADY_OPEN 0x0002
+
#define FS_RET_EXISTS 0x0004
+
#define FS_RET_NOT_FOUND 0x0008
+
#define FS_RET_NOT_FILE 0x0010
+
#define FS_RET_NOT_DIR 0x0020
+
#define FS_RET_ACCESS_ERROR 0x0040
+
#define FS_RET_PERMISSION_ERROR 0x0080
+
#define FS_RET_FILE_TOO_BIG 0x0100
+
#define FS_RET_STORAGE_FULL 0x0200
+
#define FS_RET_UNSUPPORTED_CMD 0x0400
+
#define FS_RET_JOURNAL_FULL 0x0800
+
+
#define FS_ERROR_BASE (-196608) /* 0xFFFD0000 */
+
#define FS_ERROR_LIB_NOT_INIT (FS_ERROR_BASE - 1)
+
#define FS_ERROR_INVALID_CLIENT_HANDLE (FS_ERROR_BASE -37) /* ??? */
+
+
typedef struct {uint8_t buffer[FS_CLIENT_BUFFER_SIZE];} FSClient;
+
typedef struct {uint8_t buffer[FS_CMD_BLOCK_SIZE];} FSCmdBlock;
+
</syntaxhighlight>
== Defines ==
== Defines ==