libogc
v2.9.0
|
Memory card subsystem. More...
#include <gctypes.h>
Data Structures | |
struct | _card_dir |
struct | _card_direntry |
struct | _card_file |
struct | _card_stat |
Macros | |
#define | CARD_ANIM_BOUNCE 0x04 |
#define | CARD_ANIM_LOOP 0x00 |
#define | CARD_ANIM_MASK 0x04 |
#define | CARD_ATTRIB_NOCOPY 0x08 |
#define | CARD_ATTRIB_NOMOVE 0x10 |
#define | CARD_ATTRIB_PUBLIC 0x04 |
#define | CARD_BANNER_CI 0x01 |
#define | CARD_BANNER_H 32 |
#define | CARD_BANNER_MASK 0x03 |
#define | CARD_BANNER_NONE 0x00 |
#define | CARD_BANNER_RGB 0x02 |
#define | CARD_BANNER_W 96 |
#define | CARD_ERROR_BROKEN -6 |
#define | CARD_ERROR_BUSY -1 |
#define | CARD_ERROR_CANCELED -14 |
#define | CARD_ERROR_ENCODING -13 |
#define | CARD_ERROR_EXIST -7 |
#define | CARD_ERROR_FATAL_ERROR -128 |
#define | CARD_ERROR_INSSPACE -9 |
#define | CARD_ERROR_IOERROR -5 |
#define | CARD_ERROR_LIMIT -11 |
#define | CARD_ERROR_NAMETOOLONG -12 |
#define | CARD_ERROR_NOCARD -3 |
#define | CARD_ERROR_NOENT -8 |
#define | CARD_ERROR_NOFILE -4 |
#define | CARD_ERROR_NOPERM -10 |
#define | CARD_ERROR_READY 0 |
#define | CARD_ERROR_UNLOCKED 1 |
#define | CARD_ERROR_WRONGDEVICE -2 |
#define | CARD_FILENAMELEN 32 |
#define | CARD_GetBannerFmt(stat) (((stat)->banner_fmt)&CARD_BANNER_MASK) |
#define | CARD_GetIconFmt(stat, n) (((stat)->icon_fmt>>(2*(n)))&CARD_ICON_MASK) |
#define | CARD_GetIconSpeed(stat, n) (((stat)->icon_speed>>(2*(n)))&~CARD_SPEED_MASK); |
#define | CARD_ICON_CI 0x01 |
#define | CARD_ICON_H 32 |
#define | CARD_ICON_MASK 0x03 |
#define | CARD_ICON_NONE 0x00 |
#define | CARD_ICON_RGB 0x02 |
#define | CARD_ICON_W 32 |
#define | CARD_MAXFILES 127 |
#define | CARD_MAXICONS 8 |
#define | CARD_READSIZE 512 |
#define | CARD_SetBannerFmt(stat, fmt) ((stat)->banner_fmt = (u8)(((stat)->banner_fmt&~CARD_BANNER_MASK)|(fmt))) |
#define | CARD_SetCommentAddr(stat, addr) ((stat)->comment_addr = (u32)(addr)) |
#define | CARD_SetIconAddr(stat, addr) ((stat)->icon_addr = (u32)(addr)) |
#define | CARD_SetIconFmt(stat, n, fmt) ((stat)->icon_fmt = (u16)(((stat)->icon_fmt&~(CARD_ICON_MASK<<(2*(n))))|((fmt)<<(2*(n))))) |
#define | CARD_SetIconSpeed(stat, n, speed) ((stat)->icon_speed = (u16)(((stat)->icon_fmt&~(CARD_SPEED_MASK<<(2*(n))))|((speed)<<(2*(n))))) |
#define | CARD_SLOTA 0 |
#define | CARD_SLOTB 1 |
#define | CARD_SPEED_END 0x00 |
#define | CARD_SPEED_FAST 0x01 |
#define | CARD_SPEED_MASK 0x03 |
#define | CARD_SPEED_MIDDLE 0x02 |
#define | CARD_SPEED_SLOW 0x03 |
#define | CARD_WORKAREA_SIZE (5*8*1024) |
Typedefs | |
typedef struct _card_dir | card_dir |
structure to hold the information of a directory entry More... | |
typedef struct _card_direntry | card_direntry |
structure to hold the information of the save file entry ( aka GCI ) More... | |
typedef struct _card_file | card_file |
structure to hold the fileinformations upon open and for later use. More... | |
typedef struct _card_stat | card_stat |
structure to hold the additional statistical informations. More... | |
typedef void(* | cardcallback) (s32 chan, s32 result) |
function pointer typedef for the user's operation callback More... | |
Functions | |
s32 | CARD_Close (card_file *file) |
Closes the file with the given card_file structure and releases the handle. More... | |
s32 | CARD_Create (s32 chn, const char *filename, u32 size, card_file *file) |
Creates a new file with the given filename and fills in the fileinformations. Synchronous version. More... | |
s32 | CARD_CreateAsync (s32 chn, const char *filename, u32 size, card_file *file, cardcallback callback) |
Creates a new file with the given filename and fills in the fileinformations. This function returns immediately. Asynchronous version. More... | |
s32 | CARD_CreateEntry (s32 chn, card_dir *direntry, card_file *file) |
Creates a new file with the given filename and fills in the fileinformations. Synchronous version. More... | |
s32 | CARD_CreateEntryAsync (s32 chn, card_dir *direntry, card_file *file, cardcallback callback) |
Creates a new file with the given filename and fills in the fileinformations. This function returns immediately. Asynchronous version. More... | |
s32 | CARD_Delete (s32 chn, const char *filename) |
Deletes a file with the given filename. Synchronous version. More... | |
s32 | CARD_DeleteAsync (s32 chn, const char *filename, cardcallback callback) |
Deletes a file with the given filename. This function returns immediately. Asynchronous version. More... | |
s32 | CARD_DeleteEntry (s32 chn, card_dir *dir_entry) |
Deletes a file with the given directory entry informations. More... | |
s32 | CARD_DeleteEntryAsync (s32 chn, card_dir *dir_entry, cardcallback callback) |
Deletes a file with the given directory entry informations. This function returns immediately. Asynchronous version. More... | |
s32 | CARD_FindFirst (s32 chn, card_dir *dir, bool showall) |
Start to iterate thru the memory card's directory structure and returns the first directory entry. More... | |
s32 | CARD_FindNext (card_dir *dir) |
Returns the next directory entry from the memory cards directory structure. More... | |
s32 | CARD_Format (s32 chn) |
s32 | CARD_FormatAsync (s32 chn, cardcallback callback) |
s32 | CARD_GetAttributes (s32 chn, s32 fileno, u8 *attr) |
Get additional file attributes. Synchronous version. More... | |
s32 | CARD_GetBlockCount (s32 chn, u32 *block_count) |
Returns the next directory entry from the memory cards directory structure. More... | |
s32 | CARD_GetDirectory (s32 chn, card_dir *dir_entries, s32 *count, bool showall) |
Returns the directory entries. size of entries is max. 128. More... | |
s32 | CARD_GetErrorCode (s32 chn) |
Returns the result code from the last operation. More... | |
s32 | CARD_GetFreeBlocks (s32 chn, u16 *freeblocks) |
Get the free blocks in memory card. More... | |
s32 | CARD_GetSectorSize (s32 chn, u32 *sector_size) |
Returns the next directory entry from the memory cards directory structure. More... | |
s32 | CARD_GetSerialNo (s32 chn, u32 *serial1, u32 *serial2) |
Get the encrypted serial numbers of the memory card. More... | |
s32 | CARD_GetStatus (s32 chn, s32 fileno, card_stat *stats) |
Get additional file statistic informations. More... | |
s32 | CARD_GetStatusEx (s32 chn, s32 fileno, card_direntry *entry) |
Get the directory entry (GCI header) More... | |
s32 | CARD_Init (const char *gamecode, const char *company) |
Performs the initialization of the memory card subsystem. More... | |
s32 | CARD_Mount (s32 chn, void *workarea, cardcallback detach_cb) |
Mounts the memory card in the slot CHN. Synchronous version. More... | |
s32 | CARD_MountAsync (s32 chn, void *workarea, cardcallback detach_cb, cardcallback attach_cb) |
Mounts the memory card in the slot CHN. This function returns immediately. Asynchronous version. More... | |
s32 | CARD_Open (s32 chn, const char *filename, card_file *file) |
Opens the file with the given filename and fills in the fileinformations. More... | |
s32 | CARD_OpenEntry (s32 chn, card_dir *entry, card_file *file) |
Opens the file with the given filename and fills in the fileinformations. More... | |
s32 | CARD_Probe (s32 chn) |
Performs a check against the desired EXI channel if a device is inserted. More... | |
s32 | CARD_ProbeEx (s32 chn, s32 *mem_size, s32 *sect_size) |
Performs a check against the desired EXI channel if a memory card is inserted or mounted. More... | |
s32 | CARD_Read (card_file *file, void *buffer, u32 len, u32 offset) |
Reads the data from the file into the buffer from the given offset with the given length. Synchronous version. More... | |
s32 | CARD_ReadAsync (card_file *file, void *buffer, u32 len, u32 offset, cardcallback callback) |
Reads the data from the file into the buffer from the given offset with the given length. This function returns immediately. Asynchronous version. More... | |
s32 | CARD_SetAttributes (s32 chn, s32 fileno, u8 attr) |
Set additional file attributes. Synchronous version. More... | |
s32 | CARD_SetAttributesAsync (s32 chn, s32 fileno, u8 attr, cardcallback callback) |
Set additional file attributes. This function returns immediately. Asynchronous version. More... | |
s32 | CARD_SetCompany (const char *company) |
Set additional file attributes. This function returns immediately. Asynchronous version. More... | |
s32 | CARD_SetGamecode (const char *gamecode) |
Set additional file attributes. This function returns immediately. Asynchronous version. More... | |
s32 | CARD_SetStatus (s32 chn, s32 fileno, card_stat *stats) |
Set additional file statistic informations. Synchronous version. More... | |
s32 | CARD_SetStatusAsync (s32 chn, s32 fileno, card_stat *stats, cardcallback callback) |
Set additional file statistic informations. This function returns immediately. Asynchronous version. More... | |
s32 | CARD_SetStatusEx (s32 chn, s32 fileno, card_direntry *entry) |
Set the directory entry (preferably from a GCI header), except block index and lenght. More... | |
s32 | CARD_Unmount (s32 chn) |
Unmounts the memory card in the slot CHN and releases the EXI bus. More... | |
s32 | CARD_Write (card_file *file, void *buffer, u32 len, u32 offset) |
Writes the data to the file from the buffer to the given offset with the given length. Synchronous version. More... | |
s32 | CARD_WriteAsync (card_file *file, void *buffer, u32 len, u32 offset, cardcallback callback) |
Writes the data to the file from the buffer to the given offset with the given length. This function returns immediately. Asynchronous version. More... | |
Memory card subsystem.
#define CARD_FILENAMELEN 32 |
maximum filename length
#define CARD_MAXFILES 127 |
maximum number of files on the memory card
#define CARD_READSIZE 512 |
minimum size of block to read from memory card
#define CARD_WORKAREA_SIZE (5*8*1024) |
minimum size of the workarea passed to Mount[Async]()
struct card_dir |
structure to hold the information of a directory entry
chn | CARD slot. |
fileno | file index in the card directory structure. |
filelen | length of file. |
filename[CARD_FILENAMELEN] | name of the file on card. |
gamecode[4] | string identifier <=4. |
company[2] | string identifier <=2. |
showall | boolean flag whether to showall entries or ony those identified by card_gamecode and card_company, previously set within the call to CARD_Init() |
struct card_direntry |
structure to hold the information of the save file entry ( aka GCI )
gamecode[4] | string identifier <=4. |
company[2] | string identifier <=2. |
padding | always 0xFF. |
banner_fmt | format of banner. |
filename[CARD_FILENAMELEN] | name of the file on card. |
last_modified | last time it was modified,in seconds since 1970 in seconds. |
icon_addr | icon image address in file. |
icon_fmt | icon image format. |
icon_speed | speed of an animated icon. |
permission | permissions of the save file. |
copy_times | how many times the save file has been copied. |
block | starting block of the save file. |
length | size of the save file.. |
padding | always 0xFFFF. |
comment_addr | address in file of the comment block. |
struct _card_file card_file |
structure to hold the fileinformations upon open and for later use.
chn | CARD slot. |
filenum | file index in the card directory structure. |
offset | offset into the file. |
len | length of file. |
iblock | block index on memory card. |
struct card_stat |
structure to hold the additional statistical informations.
filename[CARD_FILENAMELEN] | name of the file on card. |
len | length of file. |
gamecode[4] | string identifier <=4. |
company[2] | string identifier <=2. |
banner_fmt | format of banner. |
icon_addr | icon image address in file. |
icon_fmt | icon image format. |
icon_speed | speed of an animated icon. |
comment_addr | address in file of the comment block. |
offset_banner | offset in file to the banner's image data. |
offset_banner_tlut | offset in file to the banner's texture lookup table. |
offset_icon[CARD_MAXICONS] | array of offsets in file to the icon's image data <CARD_MAXICONS. |
offset_icon_tlut | offset in file to the icons's texture lookup table. |
offset_data | offset to additional data. |
function pointer typedef for the user's operation callback
chan | CARD slot |
result | result of operation upon call of callback. |
Closes the file with the given card_file structure and releases the handle.
[in] | file | pointer to the card_file structure to close. |
Creates a new file with the given filename and fills in the fileinformations. Synchronous version.
[in] | chn | CARD slot |
[in] | filename | name of the file to create. |
[in] | size | size of the newly created file. This must be a multiple of the memory card's sector size. |
[out] | file | pointer to the card_file structure. It receives the fileinformations for later usage. |
s32 CARD_CreateAsync | ( | s32 | chn, |
const char * | filename, | ||
u32 | size, | ||
card_file * | file, | ||
cardcallback | callback | ||
) |
Creates a new file with the given filename and fills in the fileinformations. This function returns immediately. Asynchronous version.
[in] | chn | CARD slot |
[in] | filename | name of the file to create. |
[in] | size | size of the newly created file. This must be a multiple of the memory card's sector size. |
[out] | file | pointer to the card_file structure. It receives the fileinformations for later usage. |
[in] | callback | pointer to a callback function. This callback will be called when the create process has finished. |
Creates a new file with the given filename and fills in the fileinformations. Synchronous version.
[in] | chn | CARD slot |
[in] | entry | pointer to the directory entry to create. |
[out] | file | pointer to the card_file structure. It receives the fileinformations for later usage. |
s32 CARD_CreateEntryAsync | ( | s32 | chn, |
card_dir * | entry, | ||
card_file * | file, | ||
cardcallback | callback | ||
) |
Creates a new file with the given filename and fills in the fileinformations. This function returns immediately. Asynchronous version.
[in] | chn | CARD slot |
[in] | entry | pointer to the directory entry to create |
[out] | file | pointer to the card_file structure. It receives the fileinformations for later usage. |
[in] | callback | pointer to a callback function. This callback will be called when the create process has finished. |
Deletes a file with the given filename. Synchronous version.
[in] | chn | CARD slot |
[in] | filename | name of the file to delete. |
s32 CARD_DeleteAsync | ( | s32 | chn, |
const char * | filename, | ||
cardcallback | callback | ||
) |
Deletes a file with the given filename. This function returns immediately. Asynchronous version.
[in] | chn | CARD slot |
[in] | filename | name of the file to delete. |
[in] | callback | pointer to a callback function. This callback will be called when the delete process has finished. |
Deletes a file with the given directory entry informations.
[in] | chn | CARD slot |
[in] | dir_entry | pointer to the card_dir structure which holds the informations for the delete operation. |
s32 CARD_DeleteEntryAsync | ( | s32 | chn, |
card_dir * | dir_entry, | ||
cardcallback | callback | ||
) |
Deletes a file with the given directory entry informations. This function returns immediately. Asynchronous version.
[in] | chn | CARD slot |
[in] | dir_entry | pointer to the card_dir structure which holds the informations for the delete operation. |
[in] | callback | pointer to a callback function. This callback will be called when the delete process has finished. |
Start to iterate thru the memory card's directory structure and returns the first directory entry.
[in] | chn | CARD slot |
[out] | dir | pointer to card_dir structure to receive the result set. |
[in] | showall | Whether to show all files of the memory card or only those which are identified by the company and gamecode string. |
Returns the next directory entry from the memory cards directory structure.
[out] | dir | pointer to card_dir structure to receive the result set. |
s32 CARD_FormatAsync | ( | s32 | chn, |
cardcallback | callback | ||
) |
Not finished function
Get additional file attributes. Synchronous version.
[in] | chn | CARD slot. |
[in] | fileno | file index. returned by a previous call to CARD_Open(). |
[out] | attr | pointer to receive attribute value. |
Returns the next directory entry from the memory cards directory structure.
[in] | chn | CARD slot. |
[out] | sector_size | pointer to receive the result. |
Returns the directory entries. size of entries is max. 128.
[in] | chn | CARD slot |
[out] | dir_entries | pointer to card_dir structure to receive the result set. |
[out] | count | pointer to an integer to receive the counted entries. |
[in] | showall | Whether to show all files of the memory card or only those which are identified by the company and gamecode string. |
Returns the result code from the last operation.
[in] | chn | CARD slot |
Get the free blocks in memory card.
[in] | chn | CARD slot. |
[in] | freeblocks | pointer to receive freeblocks value. |
Returns the next directory entry from the memory cards directory structure.
[in] | chn | CARD slot. |
[out] | sector_size | pointer to receive the result. |
Get the encrypted serial numbers of the memory card.
[in] | chn | CARD slot. |
[in] | serial1 | & serial2 CARD slot. |
Get additional file statistic informations.
[in] | chn | CARD slot. |
[in] | fileno | file index. returned by a previous call to CARD_Open(). |
[out] | stats | pointer to receive the result set. |
s32 CARD_GetStatusEx | ( | s32 | chn, |
s32 | fileno, | ||
card_direntry * | entry | ||
) |
Get the directory entry (GCI header)
[in] | chn | CARD slot. |
[in] | fileno | file index. returned by a previous call to CARD_Open(). |
[out] | entry | pointer to receive the directory entry. |
s32 CARD_Init | ( | const char * | gamecode, |
const char * | company | ||
) |
Performs the initialization of the memory card subsystem.
[in] | gamecode | pointer to a 4byte long string to specify the vendors game code. May be NULL |
[in] | company | pointer to a 2byte long string to specify the vendors company code. May be NULL |
s32 CARD_Mount | ( | s32 | chn, |
void * | workarea, | ||
cardcallback | detach_cb | ||
) |
Mounts the memory card in the slot CHN. Synchronous version.
[in] | chn | CARD slot |
[in] | workarea | pointer to memory area to hold the cards system area. The startaddress of the workdarea should be aligned on a 32byte boundery |
[in] | detach_cb | pointer to a callback function. This callback function will be called when the card is removed from the slot. |
s32 CARD_MountAsync | ( | s32 | chn, |
void * | workarea, | ||
cardcallback | detach_cb, | ||
cardcallback | attach_cb | ||
) |
Mounts the memory card in the slot CHN. This function returns immediately. Asynchronous version.
[in] | chn | CARD slot |
[in] | workarea | pointer to memory area to hold the cards system area. The startaddress of the workdarea should be aligned on a 32byte boundery |
[in] | detach_cb | pointer to a callback function. This callback function will be called when the card is removed from the slot. |
[in] | attach_cb | pointer to a callback function. This callback function will be called when the mount process has finished. |
Opens the file with the given filename and fills in the fileinformations.
[in] | chn | CARD slot |
[in] | filename | name of the file to open. |
[out] | file | pointer to the card_file structure. It receives the fileinformations for later usage. |
Opens the file with the given filename and fills in the fileinformations.
[in] | chn | CARD slot |
[in] | entry | pointer to the directory entry to open. |
[out] | file | pointer to the card_file structure. It receives the fileinformations for later usage. |
Performs a check against the desired EXI channel if a device is inserted.
[in] | chn | CARD slot |
Performs a check against the desired EXI channel if a memory card is inserted or mounted.
[in] | chn | CARD slot |
[out] | mem_size | pointer to a integer variable, ready to take the resulting value (this param is optional and can be NULL) |
[out] | sect_size | pointer to a integer variable, ready to take the resulting value (this param is optional and can be NULL) |
Reads the data from the file into the buffer from the given offset with the given length. Synchronous version.
[in] | file | pointer to the card_file structure. It holds the fileinformations to read from. |
[out] | buffer | pointer to memory area read-in the data. The startaddress of the buffer should be aligned to a 32byte boundery. |
[in] | len | length of data to read. |
[in] | offset | offset into the file to read from. |
s32 CARD_ReadAsync | ( | card_file * | file, |
void * | buffer, | ||
u32 | len, | ||
u32 | offset, | ||
cardcallback | callback | ||
) |
Reads the data from the file into the buffer from the given offset with the given length. This function returns immediately. Asynchronous version.
[in] | file | pointer to the card_file structure. It holds the fileinformations to read from. |
[out] | buffer | pointer to memory area read-in the data. The startaddress of the buffer should be aligned to a 32byte boundery. |
[in] | len | length of data to read. |
[in] | offset | offset into the file to read from. |
[in] | callback | pointer to a callback function. This callback will be called when the read process has finished. |
Set additional file attributes. Synchronous version.
[in] | chn | CARD slot. |
[in] | fileno | file index. returned by a previous call to CARD_Open(). |
[in] | attr | attribute value to set. |
s32 CARD_SetAttributesAsync | ( | s32 | chn, |
s32 | fileno, | ||
u8 | attr, | ||
cardcallback | callback | ||
) |
Set additional file attributes. This function returns immediately. Asynchronous version.
[in] | chn | CARD slot. |
[in] | fileno | file index. returned by a previous call to CARD_Open(). |
[in] | attr | attribute value to set. |
[in] | callback | pointer to a callback function. This callback will be called when the setattributes process has finished. |
s32 CARD_SetCompany | ( | const char * | company | ) |
Set additional file attributes. This function returns immediately. Asynchronous version.
[in] | chn | CARD slot. |
s32 CARD_SetGamecode | ( | const char * | gamecode | ) |
Set additional file attributes. This function returns immediately. Asynchronous version.
[in] | chn | CARD slot. |
Set additional file statistic informations. Synchronous version.
[in] | chn | CARD slot. |
[in] | fileno | file index. returned by a previous call to CARD_Open(). |
[out] | stats | pointer which holds the informations to set. |
s32 CARD_SetStatusAsync | ( | s32 | chn, |
s32 | fileno, | ||
card_stat * | stats, | ||
cardcallback | callback | ||
) |
Set additional file statistic informations. This function returns immediately. Asynchronous version.
[in] | chn | CARD slot. |
[in] | fileno | file index. returned by a previous call to CARD_Open(). |
[out] | stats | pointer which holds the informations to set. |
[in] | callback | pointer to a callback function. This callback will be called when the setstatus process has finished. |
s32 CARD_SetStatusEx | ( | s32 | chn, |
s32 | fileno, | ||
card_direntry * | entry | ||
) |
Set the directory entry (preferably from a GCI header), except block index and lenght.
[in] | chn | CARD slot. |
[in] | fileno | file index. returned by a previous call to CARD_Open(). |
[out] | entry | pointer to a directory entry structure (or GCI header). |
Unmounts the memory card in the slot CHN and releases the EXI bus.
[in] | chn | CARD slot |
Writes the data to the file from the buffer to the given offset with the given length. Synchronous version.
[in] | file | pointer to the card_file structure which holds the fileinformations. |
[in] | buffer | pointer to the memory area to read from. The startaddress of the buffer should be aligned on a 32byte boundery. |
[in] | len | length of data to write. |
[in] | offset | starting point in the file to start writing. |
s32 CARD_WriteAsync | ( | card_file * | file, |
void * | buffer, | ||
u32 | len, | ||
u32 | offset, | ||
cardcallback | callback | ||
) |
Writes the data to the file from the buffer to the given offset with the given length. This function returns immediately. Asynchronous version.
[in] | file | pointer to the card_file structure which holds the fileinformations. |
[in] | buffer | pointer to the memory area to read from. The startaddress of the buffer should be aligned on a 32byte boundery. |
[in] | len | length of data to write. |
[in] | offset | starting point in the file to start writing. |
[in] | callback | pointer to a callback function. This callback will be called when the write process has finished. |