RetroArch
Classes | Macros | Typedefs | Functions | Variables
card.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#include <time.h>
#include <gcutil.h>
#include "asm.h"
#include "processor.h"
#include "system.h"
#include "ogcsys.h"
#include "cache.h"
#include "dsp.h"
#include "lwp.h"
#include "exi.h"
#include "card.h"
Include dependency graph for card.c:

Classes

struct  card_header
 
struct  card_direntry
 
struct  card_dat
 
struct  card_dircntrl
 
struct  card_bat
 
struct  _card_block
 

Macros

#define CARD_SYSAREA   5
 
#define CARD_SYSDIR   0x2000
 
#define CARD_SYSDIR_BACK   0x4000
 
#define CARD_SYSBAT   0x6000
 
#define CARD_SYSBAT_BACK   0x8000
 
#define _SHIFTL(v, s, w)   ((u32) (((u32)(v) & ((0x01 << (w)) - 1)) << (s)))
 
#define _SHIFTR(v, s, w)   ((u32)(((u32)(v) >> (s)) & ((0x01 << (w)) - 1)))
 
#define _ROTL(v, s)   (((u32)v<<s)|((u32)v>>(0x20-s)))
 
#define CARD_STATUS_UNLOCKED   0x40
 

Typedefs

typedef struct _card_block card_block
 

Functions

static void __card_mountcallback (s32 chn, s32 result)
 
static void __erase_callback (s32 chn, s32 result)
 
static s32 __dounlock (s32 chn, u32 *key)
 
static s32 __card_readsegment (s32 chn, cardcallback callback)
 
static s32 __card_read (s32 chn, u32 address, u32 block_len, void *buffer, cardcallback callback)
 
static s32 __card_updatefat (s32 chn, struct card_bat *fatblock, cardcallback callback)
 
static s32 __card_updatedir (s32 chn, cardcallback callback)
 
static s32 __card_write (s32 chn, u32 address, u32 block_len, void *buffer, cardcallback callback)
 
static s32 __card_writepage (s32 chn, cardcallback callback)
 
static s32 __card_sectorerase (s32 chn, u32 sector, cardcallback callback)
 
static s32 __card_onreset (s32 final)
 
unsigned long gettick ()
 
long long gettime ()
 
syssram__SYS_LockSram ()
 
syssramex__SYS_LockSramEx ()
 
u32 __SYS_UnlockSram (u32 write)
 
u32 __SYS_UnlockSramEx (u32 write)
 
static void __card_checksum (u16 *buff, u32 len, u16 *cs1, u16 *cs2)
 
static s32 __card_putcntrlblock (card_block *card, s32 result)
 
static s32 __card_getcntrlblock (s32 chn, card_block **card)
 
static __inline__ struct card_dat__card_getdirblock (card_block *card)
 
static __inline__ struct card_bat__card_getbatblock (card_block *card)
 
static s32 __card_sync (s32 chn)
 
static void __card_synccallback (s32 chn, s32 result)
 
static void __card_updateiconoffsets (struct card_direntry *entry, card_stat *stats)
 
static s32 __card_getstatusex (s32 chn, s32 fileno, struct card_direntry *entry)
 
static s32 __card_setstatusexasync (s32 chn, s32 fileno, struct card_direntry *entry, cardcallback callback)
 
static s32 __card_getfilenum (card_block *card, const char *filename, const char *gamecode, const char *company, s32 *fileno)
 
static s32 __card_seek (card_file *file, s32 len, s32 offset, card_block **rcard)
 
static u32 __card_checkdir (card_block *card, u32 *currdir)
 
static u32 __card_checkfat (card_block *card, u32 *currfat)
 
static s32 __card_verify (card_block *card)
 
static u32 __card_iscard (u32 id)
 
static s32 __card_allocblock (s32 chn, u32 blocksneed, cardcallback callback)
 
static s32 __card_freeblock (s32 chn, u16 block, cardcallback callback)
 
static s32 __card_unlockedhandler (s32 chn, s32 dev)
 
static s32 __card_readstatus (s32 chn, u8 *pstatus)
 
static s32 __card_clearstatus (s32 chn)
 
static s32 __card_enableinterrupt (s32 chn, u32 enable)
 
static s32 __card_txhandler (s32 chn, s32 dev)
 
static void __timeouthandler (syswd_t alarm, void *cbarg)
 
static void __setuptimeout (card_block *card)
 
static s32 __retry (s32 chn)
 
static void __card_defaultapicallback (s32 chn, s32 result)
 
static s32 __card_exihandler (s32 chn, s32 dev)
 
static s32 __card_exthandler (s32 chn, s32 dev)
 
static void __write_callback (s32 chn, s32 result)
 
static void __read_callback (s32 chn, s32 result)
 
static void __delete_callback (s32 chn, s32 result)
 
static void __format_callback (s32 chn, s32 result)
 
static void __blockwritecallback (s32 chn, s32 result)
 
static void __blockreadcallback (s32 chn, s32 result)
 
static void __unlocked_callback (s32 chn, s32 result)
 
static s32 __card_start (s32 chn, cardcallback tx_cb, cardcallback exi_cb)
 
static void __card_fatwritecallback (s32 chn, s32 result)
 
static void __card_dirwritecallback (s32 chn, s32 result)
 
static s32 __card_formatregion (s32 chn, u32 encode, cardcallback callback)
 
static void __card_faterasecallback (s32 chn, s32 result)
 
static void __card_direrasecallback (s32 chn, s32 result)
 
static void __card_createfatcallback (s32 chn, s32 result)
 
static void __card_dounmount (s32 chn, s32 result)
 
static s32 __card_domount (s32 chn)
 
static __inline__ void __card_srand (u32 val)
 
static __inline__ u32 __card_rand ()
 
static u32 __card_initval ()
 
static u32 __card_dummylen ()
 
static u32 exnor_1st (u32 a, u32 b)
 
static u32 exnor (u32 a, u32 b)
 
static u32 bitrev (u32 val)
 
static s32 __card_readarrayunlock (s32 chn, u32 address, void *buffer, u32 len, u32 flag)
 
static void __dsp_initcallback (dsptask_t *task)
 
static u8 tmp_buffer [64] ATTRIBUTE_ALIGN (32)
 
static void __dsp_donecallback (dsptask_t *task)
 
s32 CARD_Init (const char *gamecode, const char *company)
 Performs the initialization of the memory card subsystem. 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_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_Mount (s32 chn, void *workarea, cardcallback detach_cb)
 Mounts the memory card in the slot CHN. Synchronous version. More...
 
s32 CARD_Unmount (s32 chn)
 Unmounts the memory card in the slot CHN and releases the EXI bus. 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_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_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...
 
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_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_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_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_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_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_Close (card_file *file)
 Closes the file with the given card_file structure and releases the handle. 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_Delete (s32 chn, const char *filename)
 Deletes a file with the given filename. Synchronous version. 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_DeleteEntry (s32 chn, card_dir *dir_entry)
 Deletes a file with the given directory entry informations. More...
 
s32 CARD_FormatAsync (s32 chn, cardcallback callback)
 
s32 CARD_Format (s32 chn)
 
s32 CARD_GetErrorCode (s32 chn)
 Returns the result code from the last operation. More...
 
s32 __card_findnext (card_dir *dir)
 
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_GetDirectory (s32 chn, card_dir *dir_entries, s32 *count, bool showall)
 Returns the directory entries. size of entries is max. 128. More...
 
s32 CARD_GetSectorSize (s32 chn, u32 *sector_size)
 Returns the next directory entry from the memory cards directory structure. More...
 
s32 CARD_GetBlockCount (s32 chn, u32 *block_count)
 Returns the next directory entry from the memory cards directory structure. More...
 
s32 CARD_GetStatus (s32 chn, s32 fileno, card_stat *stats)
 Get additional file statistic informations. 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_SetStatus (s32 chn, s32 fileno, card_stat *stats)
 Set additional file statistic informations. Synchronous version. More...
 
s32 CARD_GetAttributes (s32 chn, s32 fileno, u8 *attr)
 Get 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_SetAttributes (s32 chn, s32 fileno, u8 attr)
 Set additional file attributes. Synchronous 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...
 

Variables

struct card_header ATTRIBUTE_PACKED
 
static u32 card_sector_size []
 
static u32 card_latency []
 
static u32 card_inited = 0
 
static u32 crand_next = 1
 
static u8 card_gamecode [4] = {0xff,0xff,0xff,0xff}
 
static u8 card_company [2] = {0xff,0xff}
 
static card_block cardmap [2]
 
static sys_resetinfo card_resetinfo
 
static vu16 *const _viReg = (u16*)0xCC002000
 

Macro Definition Documentation

◆ _ROTL

#define _ROTL (   v,
  s 
)    (((u32)v<<s)|((u32)v>>(0x20-s)))

◆ _SHIFTL

#define _SHIFTL (   v,
  s,
  w 
)    ((u32) (((u32)(v) & ((0x01 << (w)) - 1)) << (s)))

◆ _SHIFTR

#define _SHIFTR (   v,
  s,
  w 
)    ((u32)(((u32)(v) >> (s)) & ((0x01 << (w)) - 1)))

◆ CARD_STATUS_UNLOCKED

#define CARD_STATUS_UNLOCKED   0x40

◆ CARD_SYSAREA

#define CARD_SYSAREA   5

◆ CARD_SYSBAT

#define CARD_SYSBAT   0x6000

◆ CARD_SYSBAT_BACK

#define CARD_SYSBAT_BACK   0x8000

◆ CARD_SYSDIR

#define CARD_SYSDIR   0x2000

◆ CARD_SYSDIR_BACK

#define CARD_SYSDIR_BACK   0x4000

Typedef Documentation

◆ card_block

typedef struct _card_block card_block

Function Documentation

◆ __blockreadcallback()

static void __blockreadcallback ( s32  chn,
s32  result 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __blockwritecallback()

static void __blockwritecallback ( s32  chn,
s32  result 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __card_allocblock()

static s32 __card_allocblock ( s32  chn,
u32  blocksneed,
cardcallback  callback 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __card_checkdir()

static u32 __card_checkdir ( card_block card,
u32 currdir 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __card_checkfat()

static u32 __card_checkfat ( card_block card,
u32 currfat 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __card_checksum()

static void __card_checksum ( u16 buff,
u32  len,
u16 cs1,
u16 cs2 
)
static
Here is the caller graph for this function:

◆ __card_clearstatus()

static s32 __card_clearstatus ( s32  chn)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __card_createfatcallback()

static void __card_createfatcallback ( s32  chn,
s32  result 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __card_defaultapicallback()

static void __card_defaultapicallback ( s32  chn,
s32  result 
)
static
Here is the caller graph for this function:

◆ __card_direrasecallback()

static void __card_direrasecallback ( s32  chn,
s32  result 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __card_dirwritecallback()

static void __card_dirwritecallback ( s32  chn,
s32  result 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __card_domount()

static s32 __card_domount ( s32  chn)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __card_dounmount()

static void __card_dounmount ( s32  chn,
s32  result 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __card_dummylen()

static u32 __card_dummylen ( )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __card_enableinterrupt()

static s32 __card_enableinterrupt ( s32  chn,
u32  enable 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __card_exihandler()

static s32 __card_exihandler ( s32  chn,
s32  dev 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __card_exthandler()

static s32 __card_exthandler ( s32  chn,
s32  dev 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __card_faterasecallback()

static void __card_faterasecallback ( s32  chn,
s32  result 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __card_fatwritecallback()

static void __card_fatwritecallback ( s32  chn,
s32  result 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __card_findnext()

s32 __card_findnext ( card_dir dir)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __card_formatregion()

static s32 __card_formatregion ( s32  chn,
u32  encode,
cardcallback  callback 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __card_freeblock()

static s32 __card_freeblock ( s32  chn,
u16  block,
cardcallback  callback 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __card_getbatblock()

static __inline__ struct card_bat* __card_getbatblock ( card_block card)
static
Here is the caller graph for this function:

◆ __card_getcntrlblock()

static s32 __card_getcntrlblock ( s32  chn,
card_block **  card 
)
static
Here is the caller graph for this function:

◆ __card_getdirblock()

static __inline__ struct card_dat* __card_getdirblock ( card_block card)
static
Here is the caller graph for this function:

◆ __card_getfilenum()

static s32 __card_getfilenum ( card_block card,
const char *  filename,
const char *  gamecode,
const char *  company,
s32 fileno 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __card_getstatusex()

static s32 __card_getstatusex ( s32  chn,
s32  fileno,
struct card_direntry entry 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __card_initval()

static u32 __card_initval ( )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __card_iscard()

static u32 __card_iscard ( u32  id)
static
Here is the caller graph for this function:

◆ __card_mountcallback()

static void __card_mountcallback ( s32  chn,
s32  result 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __card_onreset()

static s32 __card_onreset ( s32  final)
static
Here is the call graph for this function:

◆ __card_putcntrlblock()

static s32 __card_putcntrlblock ( card_block card,
s32  result 
)
static
Here is the caller graph for this function:

◆ __card_rand()

static __inline__ u32 __card_rand ( )
static
Here is the caller graph for this function:

◆ __card_read()

static s32 __card_read ( s32  chn,
u32  address,
u32  block_len,
void buffer,
cardcallback  callback 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __card_readarrayunlock()

static s32 __card_readarrayunlock ( s32  chn,
u32  address,
void buffer,
u32  len,
u32  flag 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __card_readsegment()

static s32 __card_readsegment ( s32  chn,
cardcallback  callback 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __card_readstatus()

static s32 __card_readstatus ( s32  chn,
u8 pstatus 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __card_sectorerase()

static s32 __card_sectorerase ( s32  chn,
u32  sector,
cardcallback  callback 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __card_seek()

static s32 __card_seek ( card_file file,
s32  len,
s32  offset,
card_block **  rcard 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __card_setstatusexasync()

static s32 __card_setstatusexasync ( s32  chn,
s32  fileno,
struct card_direntry entry,
cardcallback  callback 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __card_srand()

static __inline__ void __card_srand ( u32  val)
static
Here is the caller graph for this function:

◆ __card_start()

static s32 __card_start ( s32  chn,
cardcallback  tx_cb,
cardcallback  exi_cb 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __card_sync()

static s32 __card_sync ( s32  chn)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __card_synccallback()

static void __card_synccallback ( s32  chn,
s32  result 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __card_txhandler()

static s32 __card_txhandler ( s32  chn,
s32  dev 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __card_unlockedhandler()

static s32 __card_unlockedhandler ( s32  chn,
s32  dev 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __card_updatedir()

static s32 __card_updatedir ( s32  chn,
cardcallback  callback 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __card_updatefat()

static s32 __card_updatefat ( s32  chn,
struct card_bat fatblock,
cardcallback  callback 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __card_updateiconoffsets()

static void __card_updateiconoffsets ( struct card_direntry entry,
card_stat stats 
)
static
Here is the caller graph for this function:

◆ __card_verify()

static s32 __card_verify ( card_block card)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __card_write()

static s32 __card_write ( s32  chn,
u32  address,
u32  block_len,
void buffer,
cardcallback  callback 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __card_writepage()

static s32 __card_writepage ( s32  chn,
cardcallback  callback 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __delete_callback()

static void __delete_callback ( s32  chn,
s32  result 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __dounlock()

static s32 __dounlock ( s32  chn,
u32 key 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __dsp_donecallback()

static void __dsp_donecallback ( dsptask_t task)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __dsp_initcallback()

static void __dsp_initcallback ( dsptask_t task)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __erase_callback()

static void __erase_callback ( s32  chn,
s32  result 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __format_callback()

static void __format_callback ( s32  chn,
s32  result 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __read_callback()

static void __read_callback ( s32  chn,
s32  result 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __retry()

static s32 __retry ( s32  chn)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __setuptimeout()

static void __setuptimeout ( card_block card)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __SYS_LockSram()

syssram* __SYS_LockSram ( )
Here is the caller graph for this function:

◆ __SYS_LockSramEx()

syssramex* __SYS_LockSramEx ( )
Here is the caller graph for this function:

◆ __SYS_UnlockSram()

u32 __SYS_UnlockSram ( u32  write)
Here is the caller graph for this function:

◆ __SYS_UnlockSramEx()

u32 __SYS_UnlockSramEx ( u32  write)
Here is the caller graph for this function:

◆ __timeouthandler()

static void __timeouthandler ( syswd_t  alarm,
void cbarg 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __unlocked_callback()

static void __unlocked_callback ( s32  chn,
s32  result 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __write_callback()

static void __write_callback ( s32  chn,
s32  result 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ATTRIBUTE_ALIGN()

static u8 tmp_buffer [64] ATTRIBUTE_ALIGN ( 32  )
static

◆ bitrev()

static u32 bitrev ( u32  val)
static
Here is the caller graph for this function:

◆ CARD_Close()

s32 CARD_Close ( card_file file)

Closes the file with the given card_file structure and releases the handle.

Parameters
[in]filepointer to the card_file structure to close.
Returns
card error codes
Here is the call graph for this function:

◆ CARD_Create()

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.

Parameters
[in]chnCARD slot
[in]filenamename of the file to create.
[in]sizesize of the newly created file. This must be a multiple of the memory card's sector size.
[out]filepointer to the card_file structure. It receives the fileinformations for later usage.
Returns
card error codes
Here is the call graph for this function:

◆ CARD_CreateAsync()

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.

Parameters
[in]chnCARD slot
[in]filenamename of the file to create.
[in]sizesize of the newly created file. This must be a multiple of the memory card's sector size.
[out]filepointer to the card_file structure. It receives the fileinformations for later usage.
[in]callbackpointer to a callback function. This callback will be called when the create process has finished.
Returns
card error codes
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CARD_CreateEntry()

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.

Parameters
[in]chnCARD slot
[in]entrypointer to the directory entry to create.
[out]filepointer to the card_file structure. It receives the fileinformations for later usage.
Returns
card error codes
Here is the call graph for this function:

◆ CARD_CreateEntryAsync()

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.

Parameters
[in]chnCARD slot
[in]entrypointer to the directory entry to create
[out]filepointer to the card_file structure. It receives the fileinformations for later usage.
[in]callbackpointer to a callback function. This callback will be called when the create process has finished.
Returns
card error codes
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CARD_Delete()

s32 CARD_Delete ( s32  chn,
const char *  filename 
)

Deletes a file with the given filename. Synchronous version.

Parameters
[in]chnCARD slot
[in]filenamename of the file to delete.
Returns
card error codes
Here is the call graph for this function:

◆ CARD_DeleteAsync()

s32 CARD_DeleteAsync ( s32  chn,
const char *  filename,
cardcallback  callback 
)

Deletes a file with the given filename. This function returns immediately. Asynchronous version.

Parameters
[in]chnCARD slot
[in]filenamename of the file to delete.
[in]callbackpointer to a callback function. This callback will be called when the delete process has finished.
Returns
card error codes
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CARD_DeleteEntry()

s32 CARD_DeleteEntry ( s32  chn,
card_dir dir_entry 
)

Deletes a file with the given directory entry informations.

Parameters
[in]chnCARD slot
[in]dir_entrypointer to the card_dir structure which holds the informations for the delete operation.
Returns
card error codes
Here is the call graph for this function:

◆ CARD_DeleteEntryAsync()

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.

Parameters
[in]chnCARD slot
[in]dir_entrypointer to the card_dir structure which holds the informations for the delete operation.
[in]callbackpointer to a callback function. This callback will be called when the delete process has finished.
Returns
card error codes
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CARD_FindFirst()

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.

Parameters
[in]chnCARD slot
[out]dirpointer to card_dir structure to receive the result set.
[in]showallWhether to show all files of the memory card or only those which are identified by the company and gamecode string.
Returns
card error codes
Here is the call graph for this function:

◆ CARD_FindNext()

s32 CARD_FindNext ( card_dir dir)

Returns the next directory entry from the memory cards directory structure.

Parameters
[out]dirpointer to card_dir structure to receive the result set.
Returns
card error codes
Here is the call graph for this function:

◆ CARD_Format()

s32 CARD_Format ( s32  chn)

Not finished function

Here is the call graph for this function:

◆ CARD_FormatAsync()

s32 CARD_FormatAsync ( s32  chn,
cardcallback  callback 
)

Not finished function

Here is the call graph for this function:

◆ CARD_GetAttributes()

s32 CARD_GetAttributes ( s32  chn,
s32  fileno,
u8 attr 
)

Get additional file attributes. Synchronous version.

Parameters
[in]chnCARD slot.
[in]filenofile index. returned by a previous call to CARD_Open().
[out]attrpointer to receive attribute value.
Returns
card error codes
Here is the call graph for this function:

◆ CARD_GetBlockCount()

s32 CARD_GetBlockCount ( s32  chn,
u32 block_count 
)

Returns the next directory entry from the memory cards directory structure.

Parameters
[in]chnCARD slot.
[out]sector_sizepointer to receive the result.
Returns
card error codes
Here is the call graph for this function:

◆ CARD_GetDirectory()

s32 CARD_GetDirectory ( s32  chn,
card_dir dir_entries,
s32 count,
bool  showall 
)

Returns the directory entries. size of entries is max. 128.

Parameters
[in]chnCARD slot
[out]dir_entriespointer to card_dir structure to receive the result set.
[out]countpointer to an integer to receive the counted entries.
[in]showallWhether to show all files of the memory card or only those which are identified by the company and gamecode string.
Returns
card error codes
Here is the call graph for this function:

◆ CARD_GetErrorCode()

s32 CARD_GetErrorCode ( s32  chn)

Returns the result code from the last operation.

Parameters
[in]chnCARD slot
Returns
card error codes of last operation
Here is the caller graph for this function:

◆ CARD_GetSectorSize()

s32 CARD_GetSectorSize ( s32  chn,
u32 sector_size 
)

Returns the next directory entry from the memory cards directory structure.

Parameters
[in]chnCARD slot.
[out]sector_sizepointer to receive the result.
Returns
card error codes
Here is the call graph for this function:

◆ CARD_GetStatus()

s32 CARD_GetStatus ( s32  chn,
s32  fileno,
card_stat stats 
)

Get additional file statistic informations.

Parameters
[in]chnCARD slot.
[in]filenofile index. returned by a previous call to CARD_Open().
[out]statspointer to receive the result set.
Returns
card error codes
Here is the call graph for this function:

◆ CARD_Init()

s32 CARD_Init ( const char *  gamecode,
const char *  company 
)

Performs the initialization of the memory card subsystem.

Parameters
[in]gamecodepointer to a 4byte long string to specify the vendors game code. May be NULL
[in]companypointer to a 2byte long string to specify the vendors company code. May be NULL
Returns
card error codes
Here is the call graph for this function:

◆ CARD_Mount()

s32 CARD_Mount ( s32  chn,
void workarea,
cardcallback  detach_cb 
)

Mounts the memory card in the slot CHN. Synchronous version.

Parameters
[in]chnCARD slot
[in]workareapointer to memory area to hold the cards system area. The startaddress of the workdarea should be aligned on a 32byte boundery
[in]detach_cbpointer to a callback function. This callback function will be called when the card is removed from the slot.
Returns
card error codes
Here is the call graph for this function:

◆ CARD_MountAsync()

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.

Parameters
[in]chnCARD slot
[in]workareapointer to memory area to hold the cards system area. The startaddress of the workdarea should be aligned on a 32byte boundery
[in]detach_cbpointer to a callback function. This callback function will be called when the card is removed from the slot.
[in]attach_cbpointer to a callback function. This callback function will be called when the mount process has finished.
Returns
card error codes
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CARD_Open()

s32 CARD_Open ( s32  chn,
const char *  filename,
card_file file 
)

Opens the file with the given filename and fills in the fileinformations.

Parameters
[in]chnCARD slot
[in]filenamename of the file to open.
[out]filepointer to the card_file structure. It receives the fileinformations for later usage.
Returns
card error codes
Here is the call graph for this function:

◆ CARD_OpenEntry()

s32 CARD_OpenEntry ( s32  chn,
card_dir entry,
card_file file 
)

Opens the file with the given filename and fills in the fileinformations.

Parameters
[in]chnCARD slot
[in]entrypointer to the directory entry to open.
[out]filepointer to the card_file structure. It receives the fileinformations for later usage.
Returns
card error codes
Here is the call graph for this function:

◆ CARD_Probe()

s32 CARD_Probe ( s32  chn)

Performs a check against the desired EXI channel if a device is inserted.

Parameters
[in]chnCARD slot
Returns
card error codes
Here is the call graph for this function:

◆ CARD_ProbeEx()

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.

Parameters
[in]chnCARD slot
[out]mem_sizepointer to a integer variable, ready to take the resulting value (this param is optional and can be NULL)
[out]sect_sizepointer to a integer variable, ready to take the resulting value (this param is optional and can be NULL)
Returns
card error codes
Here is the call graph for this function:

◆ CARD_Read()

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.

Parameters
[in]filepointer to the card_file structure. It holds the fileinformations to read from.
[out]bufferpointer to memory area read-in the data. The startaddress of the buffer should be aligned to a 32byte boundery.
[in]lenlength of data to read.
[in]offsetoffset into the file to read from.
Returns
card error codes
Here is the call graph for this function:

◆ CARD_ReadAsync()

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.

Parameters
[in]filepointer to the card_file structure. It holds the fileinformations to read from.
[out]bufferpointer to memory area read-in the data. The startaddress of the buffer should be aligned to a 32byte boundery.
[in]lenlength of data to read.
[in]offsetoffset into the file to read from.
[in]callbackpointer to a callback function. This callback will be called when the read process has finished.
Returns
card error codes
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CARD_SetAttributes()

s32 CARD_SetAttributes ( s32  chn,
s32  fileno,
u8  attr 
)

Set additional file attributes. Synchronous version.

Parameters
[in]chnCARD slot.
[in]filenofile index. returned by a previous call to CARD_Open().
[in]attrattribute value to set.
Returns
card error codes
Here is the call graph for this function:

◆ CARD_SetAttributesAsync()

s32 CARD_SetAttributesAsync ( s32  chn,
s32  fileno,
u8  attr,
cardcallback  callback 
)

Set additional file attributes. This function returns immediately. Asynchronous version.

Parameters
[in]chnCARD slot.
[in]filenofile index. returned by a previous call to CARD_Open().
[in]attrattribute value to set.
[in]callbackpointer to a callback function. This callback will be called when the setattributes process has finished.
Returns
card error codes
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CARD_SetCompany()

s32 CARD_SetCompany ( const char *  company)

Set additional file attributes. This function returns immediately. Asynchronous version.

Parameters
[in]chnCARD slot.
Returns
card error codes
Here is the call graph for this function:

◆ CARD_SetGamecode()

s32 CARD_SetGamecode ( const char *  gamecode)

Set additional file attributes. This function returns immediately. Asynchronous version.

Parameters
[in]chnCARD slot.
Returns
card error codes
Here is the call graph for this function:

◆ CARD_SetStatus()

s32 CARD_SetStatus ( s32  chn,
s32  fileno,
card_stat stats 
)

Set additional file statistic informations. Synchronous version.

Parameters
[in]chnCARD slot.
[in]filenofile index. returned by a previous call to CARD_Open().
[out]statspointer which holds the informations to set.
Returns
card error codes
Here is the call graph for this function:

◆ CARD_SetStatusAsync()

s32 CARD_SetStatusAsync ( s32  chn,
s32  fileno,
card_stat stats,
cardcallback  callback 
)

Set additional file statistic informations. This function returns immediately. Asynchronous version.

Parameters
[in]chnCARD slot.
[in]filenofile index. returned by a previous call to CARD_Open().
[out]statspointer which holds the informations to set.
[in]callbackpointer to a callback function. This callback will be called when the setstatus process has finished.
Returns
card error codes
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CARD_Unmount()

s32 CARD_Unmount ( s32  chn)

Unmounts the memory card in the slot CHN and releases the EXI bus.

Parameters
[in]chnCARD slot
Returns
card error codes
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CARD_Write()

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.

Parameters
[in]filepointer to the card_file structure which holds the fileinformations.
[in]bufferpointer to the memory area to read from. The startaddress of the buffer should be aligned on a 32byte boundery.
[in]lenlength of data to write.
[in]offsetstarting point in the file to start writing.
Returns
card error codes
Here is the call graph for this function:

◆ CARD_WriteAsync()

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.

Parameters
[in]filepointer to the card_file structure which holds the fileinformations.
[in]bufferpointer to the memory area to read from. The startaddress of the buffer should be aligned on a 32byte boundery.
[in]lenlength of data to write.
[in]offsetstarting point in the file to start writing.
[in]callbackpointer to a callback function. This callback will be called when the write process has finished.
Returns
card error codes
Here is the call graph for this function:
Here is the caller graph for this function:

◆ exnor()

static u32 exnor ( u32  a,
u32  b 
)
static
Here is the caller graph for this function:

◆ exnor_1st()

static u32 exnor_1st ( u32  a,
u32  b 
)
static
Here is the caller graph for this function:

◆ gettick()

unsigned long gettick ( )
Here is the caller graph for this function:

◆ gettime()

long long gettime ( )
Here is the caller graph for this function:

Variable Documentation

◆ _viReg

vu16* const _viReg = (u16*)0xCC002000
static

◆ ATTRIBUTE_PACKED

struct card_bat ATTRIBUTE_PACKED

◆ card_company

u8 card_company[2] = {0xff,0xff}
static

◆ card_gamecode

u8 card_gamecode[4] = {0xff,0xff,0xff,0xff}
static

◆ card_inited

u32 card_inited = 0
static

◆ card_latency

u32 card_latency[]
static
Initial value:
=
{
0x00000004,
0x00000008,
0x00000010,
0x00000020,
0x00000030,
0x00000080,
0x00000100,
0x00000200
}

◆ card_resetinfo

sys_resetinfo card_resetinfo
static
Initial value:
= {
{},
127
}
static s32 __card_onreset(s32 final)
Definition: card.c:264

◆ card_sector_size

u32 card_sector_size[]
static
Initial value:
=
{
0x0002000,
0x0004000,
0x0008000,
0x0010000,
0x0020000,
0x0040000,
0x0000000,
0x0000000
}

◆ cardmap

card_block cardmap[2]
static

◆ crand_next

u32 crand_next = 1
static