PS2SDK
PS2 Homebrew Libraries
Loading...
Searching...
No Matches
libmc.h File Reference
#include <libmc-common.h>
+ Include dependency graph for libmc.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  mcIcon
 
struct  _sceMcTblGetDir
 
struct  mcTable
 
struct  mcTable._create
 
struct  mcTable._modify
 

Macros

#define MC_WAIT   0
 
#define MC_NOWAIT   1
 
#define MC_TYPE_PSX   sceMcTypePS1
 
#define MC_TYPE_PS2   sceMcTypePS2
 
#define MC_TYPE_POCKET   sceMcTypePDA
 
#define MC_TYPE_NONE   sceMcTypeNoCard
 
#define MC_FORMATTED   1
 
#define MC_UNFORMATTED   0
 
#define MC_ATTR_READABLE   sceMcFileAttrReadable
 
#define MC_ATTR_WRITEABLE   sceMcFileAttrWriteable
 
#define MC_ATTR_EXECUTABLE   sceMcFileAttrExecutable
 
#define MC_ATTR_PROTECTED   sceMcFileAttrDupProhibit
 
#define MC_ATTR_FILE   sceMcFileAttrFile
 
#define MC_ATTR_SUBDIR   sceMcFileAttrSubdir
 
#define MC_ATTR_OBJECT   (sceMcFileAttrFile|sceMcFileAttrSubdir)
 
#define MC_ATTR_CLOSED   sceMcFileAttrClosed
 
#define MC_ATTR_PDAEXEC   sceMcFileAttrPDAExec
 
#define MC_ATTR_PSX   sceMcFileAttrPS1
 
#define MC_ATTR_HIDDEN   sceMcFileAttrHidden
 
#define MC_TYPE_MC   0
 
#define MC_TYPE_XMC   1
 

Typedefs

typedef int iconIVECTOR[4]
 
typedef float iconFVECTOR[4]
 

Enumerations

enum  MC_FUNC_NUMBERS {
  MC_FUNC_NONE = 0x00 , MC_FUNC_GET_INFO , MC_FUNC_OPEN , MC_FUNC_CLOSE ,
  MC_FUNC_SEEK , MC_FUNC_READ , MC_FUNC_WRITE , MC_FUNC_FLUSH = 0x0A ,
  MC_FUNC_MK_DIR , MC_FUNC_CH_DIR , MC_FUNC_GET_DIR , MC_FUNC_SET_INFO ,
  MC_FUNC_DELETE , MC_FUNC_FORMAT , MC_FUNC_UNFORMAT , MC_FUNC_GET_ENT ,
  MC_FUNC_RENAME , MC_FUNC_CHG_PRITY , MC_FUNC_ERASE_BLOCK = 0x5A , MC_FUNC_READ_PAGE ,
  MC_FUNC_WRITE_PAGE
}
 
enum  MCICON_TYPES {
  MCICON_TYPE_SAVED_DATA = 0 , MCICON_TYPE_SOFTWARE_PS2 , MCICON_TYPE_SOFTWARE_PKT , MCICON_TYPE_SETTINGS_DATA ,
  MCICON_TYPE_SYSTEM_DRIVER
}
 

Functions

struct _sceMcTblGetDir __attribute__ ((aligned(64)))
 
 aligned (64)))
 
int mcInit (int type)
 
int mcGetInfo (int port, int slot, int *type, int *free, int *format)
 
int mcOpen (int port, int slot, const char *name, int mode)
 
int mcClose (int fd)
 
int mcSeek (int fd, int offset, int origin)
 
int mcRead (int fd, void *buffer, int size)
 
int mcWrite (int fd, const void *buffer, int size)
 
int mcFlush (int fd)
 
int mcMkDir (int port, int slot, const char *name)
 
int mcChdir (int port, int slot, const char *newDir, char *currentDir)
 
int mcGetDir (int port, int slot, const char *name, unsigned mode, int maxent, sceMcTblGetDir *table)
 
int mcSetFileInfo (int port, int slot, const char *name, const sceMcTblGetDir *info, unsigned flags)
 
int mcDelete (int port, int slot, const char *name)
 
int mcFormat (int port, int slot)
 
int mcUnformat (int port, int slot)
 
int mcGetEntSpace (int port, int slot, const char *path)
 
int mcRename (int port, int slot, const char *oldName, const char *newName)
 
int mcEraseBlock (int port, int slot, int block, int mode)
 
int mcReadPage (int port, int slot, unsigned int page, void *buffer)
 
int mcWritePage (int port, int slot, int page, const void *buffer)
 
int mcChangeThreadPriority (int level)
 
int mcSync (int mode, int *cmd, int *result)
 
int mcReset (void)
 

Variables

sceMcStDateTime _Create
 
sceMcStDateTime _Modify
 
u32 FileSizeByte
 
u16 AttrFile
 
u16 Reserve1
 
u32 Reserve2
 
u32 PdaAplNo
 
unsigned char EntryName [32]
 

Detailed Description

Macros, structures & function prototypes for mclib.

Definition in file libmc.h.


Data Structure Documentation

◆ mcIcon

struct mcIcon

Definition at line 106 of file libmc.h.

Data Fields
unsigned char head[4]

header = "PS2D"

unsigned short type

filetype, used to be "unknown1" (see MCICON_TYPE_* above)

unsigned short nlOffset

new line pos within title name

unsigned unknown2

unknown

unsigned trans

transparency

iconIVECTOR bgCol[4]

background color for each of the four points

iconFVECTOR lightDir[3]

directions of three light sources

iconFVECTOR lightCol[3]

colors of each of these sources

iconFVECTOR lightAmbient

ambient light

unsigned short title[34]

application title - NOTE: stored in sjis, NOT normal ascii

unsigned char view[64]

list icon filename

unsigned char copy[64]

copy icon filename

unsigned char del[64]

delete icon filename

unsigned char unknown3[512]

unknown

◆ _sceMcTblGetDir

struct _sceMcTblGetDir

Definition at line 138 of file libmc.h.

+ Collaboration diagram for _sceMcTblGetDir:
Data Fields
sceMcStDateTime _Create
sceMcStDateTime _Modify
u32 FileSizeByte
u16 AttrFile
u16 Reserve1
u32 Reserve2
u32 PdaAplNo
unsigned char EntryName[32]
char EntryName[32]

◆ mcTable

struct mcTable

Definition at line 149 of file libmc.h.

+ Collaboration diagram for mcTable:
Data Fields
struct mcTable._createstruct mcTable _create
struct mcTable._modify _modify
unsigned fileSizeByte

File size (bytes). For a directory entry: 0

unsigned short attrFile

File attribute

unsigned short unknown3
unsigned unknown4[2]
unsigned char name[32]

Entry name

◆ mcTable._create

struct mcTable._create

Definition at line 151 of file libmc.h.

Data Fields
unsigned char unknown1
unsigned char sec

Entry creation date/time (second)

unsigned char min

Entry creation date/time (minute)

unsigned char hour

Entry creation date/time (hour)

unsigned char day

Entry creation date/time (day)

unsigned char month

Entry creation date/time (month)

unsigned short year

Entry creation date/time (year)

◆ mcTable._modify

struct mcTable._modify

Definition at line 168 of file libmc.h.

Data Fields
unsigned char unknown2
unsigned char sec

Entry modification date/time (second)

unsigned char min

Entry modification date/time (minute)

unsigned char hour

Entry modification date/time (hour)

unsigned char day

Entry modification date/time (day)

unsigned char month

Entry modification date/time (month)

unsigned short year

Entry modification date/time (year)

Macro Definition Documentation

◆ MC_WAIT

#define MC_WAIT   0

Definition at line 38 of file libmc.h.

◆ MC_NOWAIT

#define MC_NOWAIT   1

Definition at line 39 of file libmc.h.

◆ MC_TYPE_PSX

#define MC_TYPE_PSX   sceMcTypePS1

Definition at line 41 of file libmc.h.

◆ MC_TYPE_PS2

#define MC_TYPE_PS2   sceMcTypePS2

Definition at line 42 of file libmc.h.

◆ MC_TYPE_POCKET

#define MC_TYPE_POCKET   sceMcTypePDA

Definition at line 43 of file libmc.h.

◆ MC_TYPE_NONE

#define MC_TYPE_NONE   sceMcTypeNoCard

Definition at line 44 of file libmc.h.

◆ MC_FORMATTED

#define MC_FORMATTED   1

Definition at line 46 of file libmc.h.

◆ MC_UNFORMATTED

#define MC_UNFORMATTED   0

Definition at line 47 of file libmc.h.

◆ MC_ATTR_READABLE

#define MC_ATTR_READABLE   sceMcFileAttrReadable

Definition at line 50 of file libmc.h.

◆ MC_ATTR_WRITEABLE

#define MC_ATTR_WRITEABLE   sceMcFileAttrWriteable

Definition at line 51 of file libmc.h.

◆ MC_ATTR_EXECUTABLE

#define MC_ATTR_EXECUTABLE   sceMcFileAttrExecutable

Definition at line 52 of file libmc.h.

◆ MC_ATTR_PROTECTED

#define MC_ATTR_PROTECTED   sceMcFileAttrDupProhibit

Definition at line 53 of file libmc.h.

◆ MC_ATTR_FILE

#define MC_ATTR_FILE   sceMcFileAttrFile

Definition at line 54 of file libmc.h.

◆ MC_ATTR_SUBDIR

#define MC_ATTR_SUBDIR   sceMcFileAttrSubdir

Definition at line 55 of file libmc.h.

◆ MC_ATTR_OBJECT

#define MC_ATTR_OBJECT   (sceMcFileAttrFile|sceMcFileAttrSubdir)

File or directory

Definition at line 57 of file libmc.h.

◆ MC_ATTR_CLOSED

#define MC_ATTR_CLOSED   sceMcFileAttrClosed

Definition at line 58 of file libmc.h.

◆ MC_ATTR_PDAEXEC

#define MC_ATTR_PDAEXEC   sceMcFileAttrPDAExec

Definition at line 59 of file libmc.h.

◆ MC_ATTR_PSX

#define MC_ATTR_PSX   sceMcFileAttrPS1

Definition at line 60 of file libmc.h.

◆ MC_ATTR_HIDDEN

#define MC_ATTR_HIDDEN   sceMcFileAttrHidden

not hidden in osdsys, but it is to games

Definition at line 62 of file libmc.h.

◆ MC_TYPE_MC

#define MC_TYPE_MC   0

Definition at line 196 of file libmc.h.

◆ MC_TYPE_XMC

#define MC_TYPE_XMC   1

Definition at line 197 of file libmc.h.

Typedef Documentation

◆ iconIVECTOR

typedef int iconIVECTOR[4]

Definition at line 103 of file libmc.h.

◆ iconFVECTOR

typedef float iconFVECTOR[4]

Definition at line 104 of file libmc.h.

Enumeration Type Documentation

◆ MC_FUNC_NUMBERS

function numbers returned by mcSync in the 'cmd' pointer

Definition at line 65 of file libmc.h.

◆ MCICON_TYPES

These types show up in the OSD browser when set. If the OSD doesn't know the number it'll display "Unrecognizable Data" or so. AFAIK these have no other effects. Known type IDs for icon.sys file:

Definition at line 95 of file libmc.h.

Function Documentation

◆ mcInit()

int mcInit ( int  type)

init memcard lib

Parameters
typeMC_TYPE_MC = use MCSERV/MCMAN; MC_TYPE_XMC = use XMCSERV/XMCMAN
Returns
0 = successful; < 0 = error

Definition at line 230 of file libmc.c.

References _iop_reboot_count, g_currentCmd, g_mclibInited, g_mcType, mcReset(), and mcRpcCmd.

◆ mcGetInfo()

int mcGetInfo ( int  port,
int  slot,
int *  type,
int *  free,
int *  format 
)

get memcard state mcSync result: 0 = same card as last getInfo call -1 = formatted card inserted since last getInfo call -2 = unformatted card inserted since last getInfo call < -2 = memcard access error (could be due to accessing psx memcard)

Parameters
portport number
slotslot number
typepointer to get memcard type
freepointer to get number of free clusters
formatpointer to get whether or not the card is formatted (Note: Originally, sceMcGetInfo didn't have a 5th argument for returning the format status. As this is emulated based on the return value of sceMcSync() when rom0:MCSERV is used, please keep track of the return value from sceMcSync instead!)
Returns
0 = successful; < 0 = error

Definition at line 336 of file libmc.c.

References g_currentCmd, g_mclibInited, g_mcType, mcGetInfoApdx(), mcRpcCmd, and SIF_RPC_M_NOWAIT.

◆ mcOpen()

int mcOpen ( int  port,
int  slot,
const char *  name,
int  mode 
)

open a file on memcard mcSync returns: 0 or more = file descriptor (success) < 0 = error

Parameters
portport number
slotslot number
namefilename to open
modeopen file mode (O_RDWR, O_CREAT, etc)
Returns
0 = successful; < 0 = error

Definition at line 378 of file libmc.c.

References g_currentCmd, g_mclibInited, g_mcType, mcRpcCmd, and SIF_RPC_M_NOWAIT.

Referenced by mcMkDir().

◆ mcClose()

int mcClose ( int  fd)

close an open file on memcard mcSync returns: 0 if closed successfully < 0 = error

Parameters
fdfile descriptor of open file
Returns
0 successful; < 0 = error

Definition at line 403 of file libmc.c.

References g_currentCmd, g_mclibInited, g_mcType, mcRpcCmd, and SIF_RPC_M_NOWAIT.

◆ mcSeek()

int mcSeek ( int  fd,
int  offset,
int  origin 
)

move memcard file pointer mcSync returns: 0 or more = offset of file pointer from start of file < 0 = error

Parameters
fdfile descriptor
offsetnumber of bytes from origin
origininitial position for offset
Returns
0 = successful; < 0 = error

Definition at line 424 of file libmc.c.

References g_currentCmd, g_mclibInited, g_mcType, mcRpcCmd, and SIF_RPC_M_NOWAIT.

◆ mcRead()

int mcRead ( int  fd,
void *  buffer,
int  size 
)

read from file on memcard mcSync returns: 0 or more = number of bytes read from memcard < 0 = error

Parameters
fdfile descriptor
bufferbuffer to read to
sizenumber of bytes to read
Returns
0 = successful; < 0 = error

Definition at line 447 of file libmc.c.

References g_currentCmd, g_mclibInited, g_mcType, mcReadFixAlign(), mcRpcCmd, and SIF_RPC_M_NOWAIT.

◆ mcWrite()

int mcWrite ( int  fd,
const void *  buffer,
int  size 
)

write to file on memcard mcSync returns: 0 or more = number of bytes written to memcard < 0 = error

Parameters
fdfile descriptor
bufferto write from write
sizenumber of bytes to read
Returns
0 = successful; < 0 = error

Definition at line 473 of file libmc.c.

References g_currentCmd, g_mclibInited, g_mcType, mcRpcCmd, and SIF_RPC_M_NOWAIT.

◆ mcFlush()

int mcFlush ( int  fd)

flush file cache to memcard mcSync returns: 0 if ok < 0 if error

Parameters
fdfile descriptor
Returns
0 = successful; < 0 = error

Definition at line 511 of file libmc.c.

References g_currentCmd, g_mclibInited, g_mcType, mcRpcCmd, and SIF_RPC_M_NOWAIT.

◆ mcMkDir()

int mcMkDir ( int  port,
int  slot,
const char *  name 
)

create a dir mcSync returns: 0 if ok < 0 if error

Parameters
portport number
slotslot number
namedirectory name
Returns
0 = successful; < 0 = error

Definition at line 532 of file libmc.c.

References g_currentCmd, and mcOpen().

◆ mcChdir()

int mcChdir ( int  port,
int  slot,
const char *  newDir,
char *  currentDir 
)

change current dir (can also get current dir) mcSync returns: 0 if ok < 0 if error

Parameters
portport number
slotslot number
newDirnew dir to change to
currentDirbuffer to get current dir (use 0 if not needed)
Returns
0 = successful; < 0 = error

Definition at line 541 of file libmc.c.

References g_currentCmd, g_mclibInited, g_mcType, mcRpcCmd, mcStoreDir(), and SIF_RPC_M_NOWAIT.

◆ mcGetDir()

int mcGetDir ( int  port,
int  slot,
const char *  name,
unsigned  mode,
int  maxent,
sceMcTblGetDir table 
)

get memcard filelist mcSync result: 0 or more = number of file entries obtained (success) -2 = unformatted card -4 = dirname error

Parameters
portport number of memcard
slotslot number of memcard
namefilename to search for (can use wildcard and relative dirs)
modemode: 0 = first call, otherwise = followup call
maxextmaximum number of entries to be written to filetable in 1 call
tablemc table array
Returns
0 = successful; < 0 = error

Definition at line 567 of file libmc.c.

References g_currentCmd, g_mclibInited, g_mcType, mcRpcCmd, and SIF_RPC_M_NOWAIT.

◆ mcSetFileInfo()

int mcSetFileInfo ( int  port,
int  slot,
const char *  name,
const sceMcTblGetDir info,
unsigned  flags 
)

change file information mcSync returns: 0 if ok < 0 if error

Parameters
portport number
slotslot number
namefilename to access
infodata to be changed
flagsflags to show which data is valid
Returns
0 = successful; < 0 = error

Definition at line 595 of file libmc.c.

References g_currentCmd, g_mclibInited, g_mcType, mcRpcCmd, and SIF_RPC_M_NOWAIT.

◆ mcDelete()

int mcDelete ( int  port,
int  slot,
const char *  name 
)

delete file mcSync returns: 0 if deleted successfully < 0 if error

Parameters
portport number to delete from
slotslot number to delete from
namefilename to delete
Returns
0 = successful; < 0 = error

Definition at line 624 of file libmc.c.

References g_currentCmd, g_mclibInited, g_mcType, mcRpcCmd, and SIF_RPC_M_NOWAIT.

◆ mcFormat()

int mcFormat ( int  port,
int  slot 
)

format memory card mcSync returns: 0 if ok < 0 if error

Parameters
portport number
slotslot number
Returns
0 = success; -1 = error

Definition at line 649 of file libmc.c.

References g_currentCmd, g_mclibInited, g_mcType, mcRpcCmd, and SIF_RPC_M_NOWAIT.

◆ mcUnformat()

int mcUnformat ( int  port,
int  slot 
)

unformat memory card mcSync returns: 0 if ok < 0 if error

Parameters
portport number
slotslot number
Returns
0 = success; -1 = error

Definition at line 671 of file libmc.c.

References g_currentCmd, g_mclibInited, g_mcType, mcRpcCmd, and SIF_RPC_M_NOWAIT.

◆ mcGetEntSpace()

int mcGetEntSpace ( int  port,
int  slot,
const char *  path 
)

get free space info mcSync returns: 0 or more = number of free entries (success) < 0 if error

Parameters
portport number
slotslot number
pathpath to be checked
Returns
0 or more = number of empty entries; -1 = error

Definition at line 693 of file libmc.c.

References g_currentCmd, g_mclibInited, g_mcType, mcRpcCmd, and SIF_RPC_M_NOWAIT.

◆ mcRename()

int mcRename ( int  port,
int  slot,
const char *  oldName,
const char *  newName 
)

rename file or dir on memcard Note: rom0:MCSERV does not support this. mcSync returns: 0 if ok < 0 if error

Parameters
portport number
slotslot number
oldNamename of file/dir to rename
newNamenew name to give to file/dir
Returns
1 = success; < 0 = error

Definition at line 717 of file libmc.c.

References g_currentCmd, g_mclibInited, g_mcType, mcRpcCmd, and SIF_RPC_M_NOWAIT.

◆ mcEraseBlock()

int mcEraseBlock ( int  port,
int  slot,
int  block,
int  mode 
)

Erases a block on the memory card. Note: rom0:XMCSERV does not support this. mcSync returns: 0 if ok < 0 if error

Parameters
portport number
slotslot number
blockBlock number of the block to be erased.
modeMode: -1 to inhibit ECC recalculation of the erased block's pages (useful if sceMcWritePage is used to fill in its contents later on), 0 for normal operation.
Returns
0 = success; -1 = error

Definition at line 746 of file libmc.c.

References g_currentCmd, g_mclibInited, g_mcType, mcRpcCmd, and SIF_RPC_M_NOWAIT.

◆ mcReadPage()

int mcReadPage ( int  port,
int  slot,
unsigned int  page,
void *  buffer 
)

Reads a page from the memory card. Note: rom0:XMCSERV does not support this. mcSync returns: 0 if ok < 0 if error

Parameters
portport number
slotslot number
pagePage number of the page to be read.
bufferPointer to buffer that will contain the read data.
Returns
0 = success; -1 = error

Definition at line 789 of file libmc.c.

References g_currentCmd, g_mclibInited, g_mcType, mcRpcCmd, and SIF_RPC_M_NOWAIT.

◆ mcWritePage()

int mcWritePage ( int  port,
int  slot,
int  page,
const void *  buffer 
)

Writes a page to the memory card. (The block which the page resides on must be erased first!) Note: rom0:XMCSERV does not support this. mcSync returns: 0 if ok < 0 if error

Parameters
portport number
slotslot number
pagePage number of the page to be written.
bufferPointer to buffer containing data to be written.
Returns
0 = success; -1 = error

Definition at line 814 of file libmc.c.

References g_currentCmd, g_mclibInited, g_mcType, mcRpcCmd, and SIF_RPC_M_NOWAIT.

◆ mcChangeThreadPriority()

int mcChangeThreadPriority ( int  level)

change mcserv thread priority (I don't think this is implemented properly) Note: rom0:MCSERV does not support this. mcSync returns: 0 if ok < 0 if error

Parameters
levelthread priority
Returns
0 = success; -1 = error

Definition at line 843 of file libmc.c.

References g_currentCmd, g_mclibInited, g_mcType, mcRpcCmd, and SIF_RPC_M_NOWAIT.

◆ mcSync()

int mcSync ( int  mode,
int *  cmd,
int *  result 
)

wait for mc functions to finish or check if they have finished yet

Parameters
modemode 0=wait till function finishes, 1=check function status
cmdpointer for storing the number of the currenlty processing function
resultpointer for storing result of function if it finishes
Returns
0 = function is still executing (mode=1); 1 = function has finished executing; -1 = no function registered

Definition at line 866 of file libmc.c.

References g_currentCmd.

◆ mcReset()

int mcReset ( void  )

Reset (force deinit) of library

Returns
0 = success

Definition at line 908 of file libmc.c.

References g_mclibInited.

Referenced by mcInit().

Variable Documentation

◆ _Create

sceMcStDateTime _Create

Definition at line 0 of file libmc.h.

◆ _Modify

sceMcStDateTime _Modify

Definition at line 1 of file libmc.h.

◆ FileSizeByte

u32 FileSizeByte

Definition at line 2 of file libmc.h.

◆ AttrFile

u16 AttrFile

Definition at line 3 of file libmc.h.

◆ Reserve1

u16 Reserve1

Definition at line 4 of file libmc.h.

◆ Reserve2

u32 Reserve2

Definition at line 5 of file libmc.h.

◆ PdaAplNo

u32 PdaAplNo

Definition at line 6 of file libmc.h.

◆ EntryName

unsigned char EntryName[32]

Definition at line 7 of file libmc.h.