ps2sdk  1.1
A collection of Open Source libraries used for developing applications on Sony's PlayStation 2® (PS2).
libmc.h
Go to the documentation of this file.
1 /*
2 # _____ ___ ____ ___ ____
3 # ____| | ____| | | |____|
4 # | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5 #-----------------------------------------------------------------------
6 # Copyright 2001-2004, ps2dev - http://www.ps2dev.org
7 # Licenced under Academic Free License version 2.0
8 # Review ps2sdk README & LICENSE files for further details.
9 */
10 
16 /*
17  NOTE: These functions will work with the MCMAN/MCSERV or XMCMAN/XMCSERV
18  modules stored in rom0. To determine which one you are using, send the
19  appropriate arg to the mcInit() function (MC_TYPE_MC or MC_TYPE_XMC)
20 
21  NOTE: These functions seem to work for both psx and ps2 memcards
22 
23  to use memcards:
24  1) first load modules (sio2man then mcman/mcserv)
25  2) call mcInit(MC_TYPE)
26  3) use mcGetInfo() to see if memcards are connected
27  4) use mcSync to check that the function has finished
28 
29  all mc* functions except mcInit() are asynchronous and require mcSync()
30  usage to test when they are done
31 */
32 
33 #ifndef __LIBMC_H__
34 #define __LIBMC_H__
35 
36 #include <libmc-common.h>
37 
38 #define MC_WAIT 0
39 #define MC_NOWAIT 1
40 
41 #define MC_TYPE_PSX sceMcTypePS1
42 #define MC_TYPE_PS2 sceMcTypePS2
43 #define MC_TYPE_POCKET sceMcTypePDA
44 #define MC_TYPE_NONE sceMcTypeNoCard
45 
46 #define MC_FORMATTED 1
47 #define MC_UNFORMATTED 0
48 
49 // Valid bits in memcard file attributes (mctable.AttrFile)
50 #define MC_ATTR_READABLE sceMcFileAttrReadable
51 #define MC_ATTR_WRITEABLE sceMcFileAttrWriteable
52 #define MC_ATTR_EXECUTABLE sceMcFileAttrExecutable
53 #define MC_ATTR_PROTECTED sceMcFileAttrDupProhibit
54 #define MC_ATTR_FILE sceMcFileAttrFile
55 #define MC_ATTR_SUBDIR sceMcFileAttrSubdir
57 #define MC_ATTR_OBJECT (sceMcFileAttrFile|sceMcFileAttrSubdir)
58 #define MC_ATTR_CLOSED sceMcFileAttrClosed
59 #define MC_ATTR_PDAEXEC sceMcFileAttrPDAExec
60 #define MC_ATTR_PSX sceMcFileAttrPS1
62 #define MC_ATTR_HIDDEN sceMcFileAttrHidden
63 
66  MC_FUNC_NONE = 0x00,
73  MC_FUNC_FLUSH = 0x0A,
87 };
88 
96  MCICON_TYPE_SAVED_DATA = 0, // "Saved Data (PlayStation(r)2)"
97  MCICON_TYPE_SOFTWARE_PS2, // "Software (PlayStation(r)2)"
98  MCICON_TYPE_SOFTWARE_PKT, // "Software (PocketStation(r))"
99  MCICON_TYPE_SETTINGS_DATA // "Settings File (PlayStation(r)2)"
100 };
101 
102 typedef int iconIVECTOR[4];
103 typedef float iconFVECTOR[4];
104 
105 typedef struct
106 {
108  unsigned char head[4];
110  unsigned short type;
112  unsigned short nlOffset;
114  unsigned unknown2;
116  unsigned trans;
118  iconIVECTOR bgCol[4];
120  iconFVECTOR lightDir[3];
122  iconFVECTOR lightCol[3];
126  unsigned short title[34];
128  unsigned char view[64];
130  unsigned char copy[64];
132  unsigned char del[64];
134  unsigned char unknown3[512];
135 } mcIcon;
136 
137 typedef struct _sceMcTblGetDir { // size = 64
141  u16 AttrFile; // 20
142  u16 Reserve1; // 22
143  u32 Reserve2; // 24
144  u32 PdaAplNo; // 28
145  unsigned char EntryName[32]; // 32
146 } sceMcTblGetDir __attribute__((aligned(64)));
147 
148 typedef struct
149 {
150  struct
151  {
152  unsigned char unknown1;
154  unsigned char sec;
156  unsigned char min;
158  unsigned char hour;
160  unsigned char day;
162  unsigned char month;
164  unsigned short year;
165  } _create;
166 
167  struct
168  {
169  unsigned char unknown2;
171  unsigned char sec;
173  unsigned char min;
175  unsigned char hour;
177  unsigned char day;
179  unsigned char month;
181  unsigned short year;
182  } _modify;
183 
185  unsigned fileSizeByte;
187  unsigned short attrFile;
188  unsigned short unknown3;
189  unsigned unknown4[2];
191  unsigned char name[32];
192 } mcTable __attribute__((deprecated, aligned (64)));
193 
194 // values to send to mcInit() to use either mcserv or xmcserv
195 #define MC_TYPE_MC 0
196 #define MC_TYPE_XMC 1
197 
198 #ifdef __cplusplus
199 extern "C" {
200 #endif
201 
207 int mcInit(int type);
208 
222 int mcGetInfo(int port, int slot, int* type, int* free, int* format);
223 
234 int mcOpen(int port, int slot, const char *name, int mode);
235 
243 int mcClose(int fd);
244 
254 int mcSeek(int fd, int offset, int origin);
255 
256 
266 int mcRead(int fd, void *buffer, int size);
267 
277 int mcWrite(int fd, const void *buffer, int size);
278 
286 int mcFlush(int fd);
287 
297 int mcMkDir(int port, int slot, const char* name);
298 
310 int mcChdir(int port, int slot, const char* newDir, char* currentDir);
311 
325 int mcGetDir(int port, int slot, const char *name, unsigned mode, int maxent, sceMcTblGetDir* table);
326 
338 int mcSetFileInfo(int port, int slot, const char* name, const sceMcTblGetDir* info, unsigned flags);
339 
349 int mcDelete(int port, int slot, const char *name);
350 
359 int mcFormat(int port, int slot);
360 
369 int mcUnformat(int port, int slot);
370 
380 int mcGetEntSpace(int port, int slot, const char* path);
381 
393 int mcRename(int port, int slot, const char* oldName, const char* newName);
394 
406 int mcEraseBlock(int port, int slot, int block, int mode);
407 
419 int mcReadPage(int port, int slot, unsigned int page, void *buffer);
420 
432 int mcWritePage(int port, int slot, int page, const void *buffer);
433 
443 int mcChangeThreadPriority(int level);
444 
452 int mcSync(int mode, int *cmd, int *result);
453 
458 int mcReset(void);
459 
460 #ifdef __cplusplus
461 }
462 #endif
463 
464 #endif /* __LIBMC_H__ */
jpgData * info
Definition: camera-test.c:14
int mcReset(void)
Definition: libmc.c:905
int mcGetEntSpace(int port, int slot, const char *path)
Definition: libmc.c:693
int mcUnformat(int port, int slot)
Definition: libmc.c:671
int mcSeek(int fd, int offset, int origin)
Definition: libmc.c:424
int mcRead(int fd, void *buffer, int size)
Definition: libmc.c:447
int mcMkDir(int port, int slot, const char *name)
Definition: libmc.c:532
int mcWritePage(int port, int slot, int page, const void *buffer)
Definition: libmc.c:814
int mcEraseBlock(int port, int slot, int block, int mode)
Definition: libmc.c:746
int mcOpen(int port, int slot, const char *name, int mode)
Definition: libmc.c:378
int mcRename(int port, int slot, const char *oldName, const char *newName)
Definition: libmc.c:717
int mcChdir(int port, int slot, const char *newDir, char *currentDir)
Definition: libmc.c:541
int mcSetFileInfo(int port, int slot, const char *name, const sceMcTblGetDir *info, unsigned flags)
Definition: libmc.c:595
int mcReadPage(int port, int slot, unsigned int page, void *buffer)
Definition: libmc.c:789
MCICON_TYPES
Definition: libmc.h:95
@ MCICON_TYPE_SOFTWARE_PS2
Definition: libmc.h:97
@ MCICON_TYPE_SETTINGS_DATA
Definition: libmc.h:99
@ MCICON_TYPE_SAVED_DATA
Definition: libmc.h:96
@ MCICON_TYPE_SOFTWARE_PKT
Definition: libmc.h:98
float iconFVECTOR[4]
Definition: libmc.h:103
int mcGetDir(int port, int slot, const char *name, unsigned mode, int maxent, sceMcTblGetDir *table)
Definition: libmc.c:567
int mcClose(int fd)
Definition: libmc.c:403
int iconIVECTOR[4]
Definition: libmc.h:102
int mcGetInfo(int port, int slot, int *type, int *free, int *format)
Definition: libmc.c:336
int mcInit(int type)
Definition: libmc.c:230
MC_FUNC_NUMBERS
Definition: libmc.h:65
@ MC_FUNC_GET_ENT
Definition: libmc.h:81
@ MC_FUNC_DELETE
Definition: libmc.h:78
@ MC_FUNC_WRITE_PAGE
Definition: libmc.h:86
@ MC_FUNC_UNFORMAT
Definition: libmc.h:80
@ MC_FUNC_FORMAT
Definition: libmc.h:79
@ MC_FUNC_GET_INFO
Definition: libmc.h:67
@ MC_FUNC_MK_DIR
Definition: libmc.h:74
@ MC_FUNC_CLOSE
Definition: libmc.h:69
@ MC_FUNC_GET_DIR
Definition: libmc.h:76
@ MC_FUNC_WRITE
Definition: libmc.h:72
@ MC_FUNC_SET_INFO
Definition: libmc.h:77
@ MC_FUNC_CH_DIR
Definition: libmc.h:75
@ MC_FUNC_READ_PAGE
Definition: libmc.h:85
@ MC_FUNC_NONE
Definition: libmc.h:66
@ MC_FUNC_SEEK
Definition: libmc.h:70
@ MC_FUNC_RENAME
Definition: libmc.h:82
@ MC_FUNC_CHG_PRITY
Definition: libmc.h:83
@ MC_FUNC_FLUSH
Definition: libmc.h:73
@ MC_FUNC_ERASE_BLOCK
Definition: libmc.h:84
@ MC_FUNC_OPEN
Definition: libmc.h:68
@ MC_FUNC_READ
Definition: libmc.h:71
int mcDelete(int port, int slot, const char *name)
Definition: libmc.c:624
int mcFormat(int port, int slot)
Definition: libmc.c:649
int mcWrite(int fd, const void *buffer, int size)
Definition: libmc.c:473
int mcChangeThreadPriority(int level)
Definition: libmc.c:843
int mcSync(int mode, int *cmd, int *result)
Definition: libmc.c:864
int mcFlush(int fd)
Definition: libmc.c:511
s32 slot
Definition: libpad.c:176
s32 port
Definition: libpad.c:176
s32 mode
Definition: rpc_client.c:15
u8 buffer[128]
Definition: rpc_client.c:19
s32 result
Definition: rpc_client.c:23
#define min(a, b)
Definition: standard.h:54
Definition: libmc.h:106
unsigned unknown2
Definition: libmc.h:114
unsigned short type
Definition: libmc.h:110
iconFVECTOR lightAmbient
Definition: libmc.h:124
unsigned short nlOffset
Definition: libmc.h:112
unsigned trans
Definition: libmc.h:116
Definition: libmc.h:149
unsigned char unknown1
Definition: libmc.h:152
unsigned char min
Definition: libmc.h:156
unsigned char day
Definition: libmc.h:160
unsigned char unknown2
Definition: libmc.h:169
unsigned char hour
Definition: libmc.h:158
unsigned char month
Definition: libmc.h:162
unsigned short year
Definition: libmc.h:164
unsigned char sec
Definition: libmc.h:154
unsigned fileSizeByte
Definition: libmc.h:185
unsigned short unknown3
Definition: libmc.h:188
unsigned short attrFile
Definition: libmc.h:187
sceMcStDateTime _Create
Definition: libmc.h:138
u16 AttrFile
Definition: libmc.h:141
sceMcStDateTime _Modify
Definition: libmc.h:139
u32 FileSizeByte
Definition: libmc.h:140
u16 Reserve1
Definition: libmc.h:142
u32 PdaAplNo
Definition: libmc.h:144
u32 Reserve2
Definition: libmc.h:143
unsigned int u32
Definition: tamtypes.h:30
unsigned short u16
Definition: tamtypes.h:24