RetroArch
card.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------
2 
3 card.h -- Memory card subsystem
4 
5 Copyright (C) 2004
6 Michael Wiedenbauer (shagkur)
7 Dave Murphy (WinterMute)
8 
9 This software is provided 'as-is', without any express or implied
10 warranty. In no event will the authors be held liable for any
11 damages arising from the use of this software.
12 
13 Permission is granted to anyone to use this software for any
14 purpose, including commercial applications, and to alter it and
15 redistribute it freely, subject to the following restrictions:
16 
17 1. The origin of this software must not be misrepresented; you
18 must not claim that you wrote the original software. If you use
19 this software in a product, an acknowledgment in the product
20 documentation would be appreciated but is not required.
21 
22 2. Altered source versions must be plainly marked as such, and
23 must not be misrepresented as being the original software.
24 
25 3. This notice may not be removed or altered from any source
26 distribution.
27 
28 -------------------------------------------------------------*/
29 
30 
31 #ifndef __CARD_H__
32 #define __CARD_H__
33 
41 #include <gctypes.h>
42 
47 #define CARD_SLOTA 0
48 #define CARD_SLOTB 1
53 #define CARD_WORKAREA (5*8*1024)
54 #define CARD_READSIZE 512
55 #define CARD_FILENAMELEN 32
56 #define CARD_MAXFILES 128
62 #define CARD_ERROR_UNLOCKED 1
63 #define CARD_ERROR_READY 0
64 #define CARD_ERROR_BUSY -1
65 #define CARD_ERROR_WRONGDEVICE -2
66 #define CARD_ERROR_NOCARD -3
67 #define CARD_ERROR_NOFILE -4
68 #define CARD_ERROR_IOERROR -5
69 #define CARD_ERROR_BROKEN -6
70 #define CARD_ERROR_EXIST -7
71 #define CARD_ERROR_NOENT -8
72 #define CARD_ERROR_INSSPACE -9
73 #define CARD_ERROR_NOPERM -10
74 #define CARD_ERROR_LIMIT -11
75 #define CARD_ERROR_NAMETOOLONG -12
76 #define CARD_ERROR_ENCODING -13
77 #define CARD_ERROR_CANCELED -14
78 #define CARD_ERROR_FATAL_ERROR -128
83 /* File attribute defines */
84 #define CARD_ATTRIB_PUBLIC 0x04
85 #define CARD_ATTRIB_NOCOPY 0x08
86 #define CARD_ATTRIB_NOMOVE 0x10
87 
88 /* Banner & Icon Attributes */
89 #define CARD_BANNER_W 96
90 #define CARD_BANNER_H 32
91 
92 #define CARD_BANNER_NONE 0x00
93 #define CARD_BANNER_CI 0x01
94 #define CARD_BANNER_RGB 0x02
95 #define CARD_BANNER_MASK 0x03
96 
97 #define CARD_MAXICONS 8
98 #define CARD_ICON_W 32
99 #define CARD_ICON_H 32
100 
101 #define CARD_ICON_NONE 0x00
102 #define CARD_ICON_CI 0x01
103 #define CARD_ICON_RGB 0x02
104 #define CARD_ICON_MASK 0x03
105 
106 #define CARD_ANIM_LOOP 0x00
107 #define CARD_ANIM_BOUNCE 0x04
108 #define CARD_ANIM_MASK 0x04
109 
110 #define CARD_SPEED_END 0x00
111 #define CARD_SPEED_FAST 0x01
112 #define CARD_SPEED_MIDDLE 0x02
113 #define CARD_SPEED_SLOW 0x03
114 #define CARD_SPEED_MASK 0x03
115 
116 #ifdef __cplusplus
117  extern "C" {
118 #endif /* __cplusplus */
119 
120 
129 typedef struct _card_file {
135 } card_file;
136 
137 
148 typedef struct _card_dir {
156  bool showall;
157 } card_dir;
158 
159 
176 typedef struct _card_stat {
179  u32 time; //time since 1970 in seconds
194 } card_stat;
195 
196 #define CARD_GetBannerFmt(stat) (((stat)->banner_fmt)&CARD_BANNER_MASK)
197 #define CARD_SetBannerFmt(stat,fmt) ((stat)->banner_fmt = (u8)(((stat)->banner_fmt&~CARD_BANNER_MASK)|(fmt)))
198 #define CARD_GetIconFmt(stat,n) (((stat)->icon_fmt>>(2*(n)))&CARD_ICON_MASK)
199 #define CARD_SetIconFmt(stat,n,fmt) ((stat)->icon_fmt = (u16)(((stat)->icon_fmt&~(CARD_ICON_MASK<<(2*(n))))|((fmt)<<(2*(n)))))
200 #define CARD_GetIconSpeed(stat,n) (((stat)->icon_speed>>(2*(n)))&~CARD_SPEED_MASK);
201 #define CARD_SetIconSpeed(stat,n,speed) ((stat)->icon_speed = (u16)(((stat)->icon_fmt&~(CARD_SPEED_MASK<<(2*(n))))|((speed)<<(2*(n)))))
202 #define CARD_SetIconAddr(stat,addr) ((stat)->icon_addr = (u32)(addr))
203 #define CARD_SetCommentAddr(stat,addr) ((stat)->comment_addr = (u32)(addr))
204 
210 typedef void (*cardcallback)(s32 chan,s32 result);
211 
212 
220 s32 CARD_Init(const char *gamecode,const char *company);
221 
222 
229 s32 CARD_Probe(s32 chn);
230 
231 
240 s32 CARD_ProbeEx(s32 chn,s32 *mem_size,s32 *sect_size);
241 
242 
251 s32 CARD_Mount(s32 chn,void *workarea,cardcallback detach_cb);
252 
253 
263 s32 CARD_MountAsync(s32 chn,void *workarea,cardcallback detach_cb,cardcallback attach_cb);
264 
265 
272 s32 CARD_Unmount(s32 chn);
273 
274 
285 
286 
298 
299 
308 s32 CARD_Open(s32 chn,const char *filename,card_file *file);
309 
310 
320 
321 
329 
330 
340 s32 CARD_Create(s32 chn,const char *filename,u32 size,card_file *file);
341 
342 
353 s32 CARD_CreateAsync(s32 chn,const char *filename,u32 size,card_file *file,cardcallback callback);
354 
355 
365 
366 
377 
378 
386 s32 CARD_Delete(s32 chn,const char *filename);
387 
388 
397 s32 CARD_DeleteAsync(s32 chn,const char *filename,cardcallback callback);
398 
399 
407 s32 CARD_DeleteEntry(s32 chn,card_dir *dir_entry);
408 
409 
419 
420 
431 
432 
444 
445 
453 
454 
463 s32 CARD_FindFirst(s32 chn, card_dir *dir, bool showall);
464 
465 
473 
474 
484 s32 CARD_GetDirectory(s32 chn, card_dir *dir_entries, s32 *count, bool showall);
485 
486 
494 s32 CARD_GetSectorSize(s32 chn,u32 *sector_size);
495 
496 
504 s32 CARD_GetBlockCount(s32 chn,u32 *block_count);
505 
506 
515 s32 CARD_GetStatus(s32 chn,s32 fileno,card_stat *stats);
516 
517 
526 s32 CARD_SetStatus(s32 chn,s32 fileno,card_stat *stats);
527 
528 
539 
540 
549 s32 CARD_GetAttributes(s32 chn,s32 fileno,u8 *attr);
550 
551 
560 s32 CARD_SetAttributes(s32 chn,s32 fileno,u8 attr);
561 
562 
573 
577 s32 CARD_Format(s32 chn);
582 
583 
590 s32 CARD_SetCompany(const char *company);
591 
592 
599 s32 CARD_SetGamecode(const char *gamecode);
600 
601 #ifdef __cplusplus
602  }
603 #endif /* __cplusplus */
604 
605 #endif
s32 CARD_Unmount(s32 chn)
Unmounts the memory card in the slot CHN and releases the EXI bus.
Definition: card.c:2332
u8 filename[CARD_FILENAMELEN]
Definition: card.h:153
u32 offset_icon_tlut[CARD_MAXICONS]
Definition: card.h:192
int32_t s32
32bit signed integer
Definition: gctypes.h:24
u8 company[2]
Definition: card.h:181
u16 icon_fmt
Definition: card.h:184
s32 CARD_SetStatus(s32 chn, s32 fileno, card_stat *stats)
Set additional file statistic informations. Synchronous version.
Definition: card.c:2912
u32 offset_banner_tlut
Definition: card.h:190
s32 CARD_SetStatusAsync(s32 chn, s32 fileno, card_stat *stats, cardcallback callback)
Set additional file statistic informations. This function returns immediately. Asynchronous version.
Definition: card.c:2879
s32 filenum
Definition: card.h:131
Data type definitions.
u8 company[2]
Definition: card.h:155
u16 iblock
Definition: card.h:134
struct _card_dir card_dir
structure to hold the information of a directory entry
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 i...
Definition: card.c:2483
s32 CARD_DeleteEntry(s32 chn, card_dir *dir_entry)
Deletes a file with the given directory entry informations.
Definition: card.c:2692
u8 gamecode[4]
Definition: card.h:154
s32 CARD_SetCompany(const char *company)
Set additional file attributes. This function returns immediately. Asynchronous version.
Definition: card.c:2955
GLenum GLsizei len
Definition: glext.h:7389
#define CARD_MAXICONS
Definition: card.h:97
s32 CARD_Probe(s32 chn)
Performs a check against the desired EXI channel if a device is inserted.
Definition: card.c:2216
u8 filename[CARD_FILENAMELEN]
Definition: card.h:177
GLsizeiptr size
Definition: glext.h:6559
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.
Definition: card.c:2765
u32 fileno
Definition: card.h:150
s32 CARD_Mount(s32 chn, void *workarea, cardcallback detach_cb)
Mounts the memory card in the slot CHN. Synchronous version.
Definition: card.c:2323
s32 CARD_SetGamecode(const char *gamecode)
Set additional file attributes. This function returns immediately. Asynchronous version.
Definition: card.c:2967
u32 comment_addr
Definition: card.h:188
Definition: card.h:129
typedef void(__stdcall *PFN_DESTRUCTION_CALLBACK)(void *pData)
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....
Definition: card.c:2379
u16 iconfmt[CARD_MAXICONS]
Definition: card.h:185
s32 chn
Definition: card.h:130
#define CARD_FILENAMELEN
Definition: card.h:55
GLuint GLuint GLsizei count
Definition: glext.h:6292
void callback(s32 result, dvdcmdblk *block)
Definition: dvd.c:2293
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.
Definition: card.c:2473
Definition: card.h:176
s32 len
Definition: card.h:133
s32 CARD_SetAttributes(s32 chn, s32 fileno, u8 attr)
Set additional file attributes. Synchronous version.
Definition: card.c:2945
uint16_t u16
16bit unsigned integer
Definition: gctypes.h:18
s32 CARD_GetAttributes(s32 chn, s32 fileno, u8 *attr)
Get additional file attributes. Synchronous version.
Definition: card.c:2922
u32 time
Definition: card.h:179
s32 CARD_Open(s32 chn, const char *filename, card_file *file)
Opens the file with the given filename and fills in the fileinformations.
Definition: card.c:2554
s32 CARD_FormatAsync(s32 chn, cardcallback callback)
Definition: card.c:2701
u32 offset_icon[CARD_MAXICONS]
Definition: card.h:191
bool showall
Definition: card.h:156
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....
Definition: card.c:2402
s32 CARD_GetBlockCount(s32 chn, u32 *block_count)
Returns the next directory entry from the memory cards directory structure.
Definition: card.c:2834
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....
Definition: card.c:2345
Definition: card.h:148
u8 banner_fmt
Definition: card.h:182
struct _card_stat card_stat
structure to hold the additional statistical informations.
GLuint64EXT * result
Definition: glext.h:12211
u32 len
Definition: card.h:178
s32 CARD_Close(card_file *file)
Closes the file with the given card_file structure and releases the handle.
Definition: card.c:2614
s32 CARD_SetAttributesAsync(s32 chn, s32 fileno, u8 attr, cardcallback callback)
Set additional file attributes. This function returns immediately. Asynchronous version.
Definition: card.c:2933
s32 CARD_OpenEntry(s32 chn, card_dir *entry, card_file *file)
Opens the file with the given filename and fills in the fileinformations.
Definition: card.c:2583
s32 CARD_GetStatus(s32 chn, s32 fileno, card_stat *stats)
Get additional file statistic informations.
Definition: card.c:2848
u8 permissions
Definition: card.h:152
s32 CARD_Init(const char *gamecode, const char *company)
Performs the initialization of the memory card subsystem.
Definition: card.c:2193
s32 CARD_FindNext(card_dir *dir)
Returns the next directory entry from the memory cards directory structure.
Definition: card.c:2778
u16 iconspeed[CARD_MAXICONS]
Definition: card.h:187
void(* cardcallback)(s32 chan, s32 result)
function pointer typedef for the user's operation callback
Definition: card.h:210
s32 CARD_DeleteAsync(s32 chn, const char *filename, cardcallback callback)
Deletes a file with the given filename. This function returns immediately. Asynchronous version.
Definition: card.c:2628
s32 CARD_Format(s32 chn)
Definition: card.c:2709
s32 CARD_Delete(s32 chn, const char *filename)
Deletes a file with the given filename. Synchronous version.
Definition: card.c:2657
u32 offset_banner
Definition: card.h:189
s32 chn
Definition: card.h:149
u32 offset_data
Definition: card.h:193
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.
Definition: card.c:2544
s32 offset
Definition: card.h:132
struct _card_file card_file
structure to hold the fileinformations upon open and for later use.
s32 CARD_GetDirectory(s32 chn, card_dir *dir_entries, s32 *count, bool showall)
Returns the directory entries. size of entries is max. 128.
Definition: card.c:2785
u8 gamecode[4]
Definition: card.h:180
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 i...
Definition: card.c:2412
u16 icon_speed
Definition: card.h:186
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.
Definition: card.c:2221
s32 CARD_GetErrorCode(s32 chn)
Returns the result code from the last operation.
Definition: card.c:2721
Definition: civetweb.c:1024
Definition: video4linux2.c:51
GLintptr offset
Definition: glext.h:6560
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....
Definition: card.c:2369
u32 filelen
Definition: card.h:151
uint8_t u8
8bit unsigned integer
Definition: gctypes.h:17
uint32_t u32
32bit unsigned integer
Definition: gctypes.h:19
s32 CARD_GetSectorSize(s32 chn, u32 *sector_size)
Returns the next directory entry from the memory cards directory structure.
Definition: card.c:2820
s32 CARD_DeleteEntryAsync(s32 chn, card_dir *dir_entry, cardcallback callback)
Deletes a file with the given directory entry informations. This function returns immediately....
Definition: card.c:2666
u32 icon_addr
Definition: card.h:183
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.
Definition: card.c:2270