00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef _KOS_H
00033 #define _KOS_H
00034
00035
00036
00037 typedef unsigned int U32;
00038 typedef int S32;
00039 typedef unsigned short U16;
00040 typedef short S16;
00041 typedef unsigned char U8,*P_U8;
00042 typedef char S8;
00043 typedef char BYTE;
00044 typedef char *P_BYTE;
00045 typedef int BOOL;
00046 typedef void *P_VOID;
00047
00048 #ifndef size_t
00049 #define size_t unsigned int
00050 #endif
00051
00052 #ifndef SIZE_T
00053 #define SIZE_T size_t
00054 #endif
00055
00056
00057
00058 #ifndef NULL
00059 #define NULL 0
00060 #endif
00061
00062
00063 #define TIME_T unsigned int
00064
00065 typedef U32 (*FUNC_PTR)();
00066 typedef U32 (*FUNC0PTR)();
00067 typedef U32 (*FUNC1PTR)(U32);
00068 typedef U32 (*FUNC2PTR)(U32,U32);
00069 typedef U32 (*FUNC3PTR)(U32,U32,U32);
00070
00071
00072
00073 #ifndef FALSE
00074 #define FALSE 0
00075 #define TRUE (! FALSE)
00076 #endif
00077
00078
00079
00080
00082 typedef struct
00083 {
00084 U16 year;
00085 U8 month;
00086 U8 day;
00087 }
00088 KDATE;
00089
00091 typedef struct
00092 {
00093 U8 hours;
00094 U8 minutes;
00095 U8 seconds;
00096 U8 unknown1;
00097 U32 unknown2;
00098 } KTIME;
00099
00100
00101 typedef struct
00102 {
00103 KDATE date;
00104 KTIME time;
00105 }
00106 KDATETIME, *P_KDATETIME;
00107
00108
00109
00110
00111
00112 #define KOS_MEM_FREE 0x0000
00113
00114 #define KOS_MEM_GLOBAL 0x1000
00115
00116 #define KOS_MEM_LOCAL 0x2000
00117
00118 #define KOS_MEM_HEAP0 0x0100
00119
00120
00121 #define KOS_MODULE_FILESYSTEM 1
00122
00123 #define KOS_FUNC_FOPEN 0
00124 #define KOS_FUNC_FREAD 1
00125 #define KOS_FUNC_FWRITE 2
00126 #define KOS_FUNC_FCLOSE 3
00127 #define KOS_FUNC_FSEEK 4
00128 #define KOS_FUNC_FDELETE 5
00129
00130 #define KOS_FUNC_FRENAME 6
00131 #define KOS_FUNC_CHDIR 7
00132 #define KOS_FUNC_GETFILEINFO 8
00133 #define KOS_FUNC_GETFIRSTDIR 9
00134 #define KOS_FUNC_GETNEXTDIR 10
00135 #define KOS_FUNC_GETPREVDIR 11
00136 #define KOS_FUNC_GETFIRSTFILE 12
00137 #define KOS_FUNC_GETNEXTFILE 13
00138 #define KOS_FUNC_GETPREVFILE 14
00139 #define KOS_FUNC_FATTR 15
00140 #define KOS_FUNC_GETSIZE 16
00141 #define KOS_FUNC_CHECKINSERT 17
00142 #define KOS_FUNC_CHECKPROTECT 18
00143
00144
00145
00146 #define KOS_READMODE 1
00147 #define KOS_WRITEMODE 2
00148
00149
00150
00151
00152
00153
00154 #define FAT32_SUPPORT 1
00155
00156
00157 #define NEW_FILE_NAME
00158
00159
00161 typedef struct
00162
00163 {
00164 KDATETIME last_modifier;
00165 KDATETIME create_date;
00166 KDATE last_access_date;
00167 #ifdef NEW_FILE_NAME
00168 BYTE file_name[13];
00169 #else
00170 BYTE extension[4];
00171 BYTE name[9];
00172 #endif
00173
00191 U8 attribute;
00192 U16 ext_attr;
00193 U32 size;
00194 }
00195 FILE_INFO, DIR_INFO, *P_FILE_INFO, *P_DIR_INFO;
00196
00197
00198
00199 typedef S32 H_FILE;
00200
00201
00202
00204 #define KOS_READONLY_ATTRIBUTE (1)
00206 #define KOS_HIDDEN_ATTRIBUTE (1<<1)
00208 #define KOS_SYSTEM_ATTRIBUTE (1<<2)
00210 #define KOS_ARCHIVE_ATTRIBUTE (1<<5)
00211
00212 #define FILE_READONLY 0x00000001 //mode parameter in kos_fopen
00213 #define FILE_READWRITE 0x00000002
00214 #define FILE_APPEND 0x00000003
00215
00216 #define FS_SEEK_SET 0
00217 #define FS_SEEK_CUR 1
00218 #define FS_SEEK_END 2
00219
00220 #define ERR_FS_INVALID_NAME -1
00221 #define ERR_FS_FILE_OPENED -2
00222 #define ERR_FS_INVALID_HANDLE -3
00223 #define ERR_FS_INVALID_INDEX -4
00224 #define ERR_FS_INVALID_MODE -5
00225 #define ERR_FS_DISK_FULL -6
00226 #define ERR_FS_DISK_ERROR -7
00227 #define ERR_FS_DISK_CHANGE -8
00228 #define ERR_FS_NO_SDCARD -9
00229 #define ERR_FS_NO_MEMORY -10
00230 #define ERR_FS_NOT_SUPPORT -11
00231 #define ERR_FS_PROTECT -13
00232 #define ERR_FS_NOTFIND -14
00233 #define ERR_FS_DISK_REMOVE -15
00234 #define ERR_FS_FILE_NOTEXIST -16
00235 #define ERR_FS_UNKNOWN -100
00236
00237
00238
00239
00240
00241 #define SUCCESS 0
00242 #define EOF -1
00243 #define KOS_ERR_INVALIDPTR -200 // FIXME: random guess
00244
00245
00246
00247 FUNC_PTR kos_GetFuncEntry(U32 module, U32 index);
00248
00249
00250
00251 H_FILE kos_fopen(P_BYTE fname, U8 mode);
00252 SIZE_T kos_fread(H_FILE fd, P_BYTE buf, U32 length);
00253 SIZE_T kos_fwrite(H_FILE fd, P_BYTE buf, U32 length);
00254 S32 kos_fseek(H_FILE fd, S32 offset, U32 mode);
00255 S32 kos_fclose(H_FILE fd);
00256 S32 kos_fdelete(P_BYTE fname);
00257
00258
00259
00260 #define fdelete(a) kos_fdelete(a);
00261
00262
00263
00264
00265
00266
00267
00268
00270
00273 S32 kos_frename(P_BYTE oldname, P_BYTE newname);
00274
00276
00286 S32 kos_chdir(P_BYTE pDir);
00287
00289 S32 kos_GetSpecialFileInfo(P_BYTE fname, P_FILE_INFO pInfo);
00290
00292
00297 S32 kos_GetFirstDirInfo(P_DIR_INFO pInfo);
00298
00300
00309 S32 kos_GetNextDirInfo(P_DIR_INFO pInfo, U32 index);
00310
00312
00321 S32 kos_GetPrevDirInfo(P_DIR_INFO pInfo, U32 index);
00322
00324
00367 S32 kos_GetFirstFileInfo(P_FILE_INFO pInfo);
00368
00370
00379 S32 kos_GetNextFileInfo(P_FILE_INFO pInfo, U32 index);
00380
00382
00391 S32 kos_GetPrevFileInfo(P_FILE_INFO pInfo, U32 index);
00392
00394
00397 S32 kos_fattr(P_BYTE fname, U8 attr);
00398
00399
00401
00405 S32 kos_GetDiskFreeSize(void);
00406
00408
00412 S32 kos_CheckDiskInsert(void);
00413
00415
00419 S32 kos_CheckDiskProtect(void);
00420
00421
00423
00429 void kos_ResetSD(void);
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440 void *kos_malloc(SIZE_T size);
00441 S32 kos_free(void *pMemory);
00442
00443
00444
00445
00446 void kos_ClearLcd(void);
00447 U32 kos_PutString(U32 dx, U32 dy, P_VOID ptr);
00448 void kos_PutHexNumber(U32 dx, U32 dy, U32 value);
00449 void kos_PutDecNumber(U32 dx, U32 dy, U32 value, U32 bit);
00450
00451 U32 kos_LCDGetContrast(void);
00452 void kos_LCDSetContrast(U32 contrast);
00453
00454
00455
00456 P_BYTE kos_getSerialNumber(void);
00457 void kos_Reset(void);
00458 S32 kos_beep(U32 freq, TIME_T time, U32 override);
00459
00460
00461
00462 U32 kos_GetSysTickTime();
00463
00464
00465
00466 #endif