aboutsummaryrefslogtreecommitdiff
path: root/arch/casiowin/fxlib/include/filebios.h
blob: a7133d133b118acf1114baca55b254e0ab9562be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
/* ****************************************************************************
 * filebios.h -- fxlib's file definitions.
 * Copyright (C) 2017 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr>
 *
 * This file is part of the 'casiowin/fxlib' module,
 * in libcarrot, an experimental modular libc project.
 *
 * This file is free software: you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your option)
 * any later version.
 *
 * This file is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Lesser Public
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this file.  If not, see <http://www.gnu.org/licenses/>.
 * ************************************************************************* */
#include <fxlib/cdefs.h>

__BEGIN_NAMESPACE_FXLIB

typedef unsigned short FONTCHARACTER;
/* ************************************************************************* */
/*  File opening mode                                                        */
/* ************************************************************************* */
/* File opening modes are:
 *
 * `_OPENMODE_READ`:            read only;
 * `_OPENMODE_READ_SHARE`:      read only while sharing (?);
 * `_OPENMODE_WRITE`:           write only;
 * `_OPENMODE_READWRITE`:       read and write;
 * `_OPENMODE_READWRITE_SHARE`: read while sharing (?), and write.
 *
 * TODO: what is sharing? */

enum _OPENMODE {
	_OPENMODE_READ            = 0x01,
	_OPENMODE_READ_SHARE      = 0x80,
	_OPENMODE_WRITE           = 0x02,
	_OPENMODE_READWRITE       = 0x03,
	_OPENMODE_READWRITE_SHARE = 0x83
};
/* ************************************************************************* */
/*  Creating mode                                                            */
/* ************************************************************************* */
/* This mode is for when you're creating files or directories.
 * Known creation modes are:
 *
 * `_CREATEMODE_BINARY`:    create a regular file;
 * `_CREATEMODE_DIRECTORY`: create a directory. */

enum _CREATEMODE {
	_CREATEMODE_BINARY    = 0x01,
	_CREATEMODE_DIRECTORY = 0x05
};
/* ************************************************************************* */
/*  Storage device                                                           */
/* ************************************************************************* */
/* Here are the different storage devices you can interact with.
 * Known devices are:
 *
 * `DEVICE_MAIN_MEMORY`: the main memory (up to 64 KiB, for light data);
 * `DEVICE_STORAGE`:     'fls0', flash memory, generally 1.5 MiB;
 * `DEVICE_SD_CARD`:     'crd0', memory card (fx-9860G SD only). */

enum DEVICE_TYPE {
	DEVICE_MAIN_MEMORY = 0x00,
	DEVICE_STORAGE     = 0x01,
	DEVICE_SD_CARD     = 0x02
};
/* ************************************************************************* */
/*  File information                                                         */
/* ************************************************************************* */
/* This is mainly used for file listing.
 * Here are the entry types:
 *
 * `DT_DIRECTORY`: directory;
 * `DT_FILE`:      regular file;
 * `DT_ADDIN_AP`:  add-in file;
 * `DT_EACT`:      e-activity file;
 * `DT_LANGUAGE`:  language file;
 * `DT_BITMAP`:    bitmap file (?);
 * `DT_MAINMEM`:   main memory archive;
 * `DT_TEMP`:      temporary file;
 * `DT_DOT`:       current directory;
 * `DT_DOTDOT`:    parent directory;
 * `DT_VOLUME`:    volume label. */

#define DT_DIRECTORY  0x0000
#define DT_FILE       0x0001
#define DT_ADDIN_APP  0x0002
#define DT_EACT       0x0003
#define DT_LANGUAGE   0x0004
#define DT_BITMAP     0x0005
#define DT_MAINMEM    0x0006
#define DT_TEMP       0x0007
#define DT_DOT        0x0008
#define DT_DOTDOT     0x0009
#define DT_VOLUME     0x000A

struct tag_FILE_INFO {
	unsigned short id;       /* index in the type index */
	unsigned short type;     /* index number, see the `DT_*` constants */
	unsigned long  fsize;    /* filesize (in bytes) */
	unsigned long  dsize;    /* datasize (without file header) */
	unsigned long  property; /* file not completed, except when
	                          * property is 0 */
	unsigned long  address;
};

typedef struct tag_FILE_INFO FILE_INFO;
/* ************************************************************************* */
/*  Errors from the file interface                                           */
/* ************************************************************************* */
/* Here are the errors you can have from the file interface.
 * Known errors are:
 *
 * `IML_FILEERR_NOERROR`:           everything went great;
 * `IML_FILEERR_ENTRYNOTFOUND`:     no such file or directory;
 * `IML_FILEERR_ILLEGALPARAM`:      a parameter was invalid;
 * `IML_FILEERR_ILLEGALPATH`:       path is invalid;
 * `IML_FILEERR_DEVICEFULL`:        device is full;
 * `IML_FILEERR_ILLEGALDEVICE`:     device does not exist;
 * `IML_FILEERR_ILLEGALFILESYS`:    file system does not exist;
 * `IML_FILEERR_ILLEGALSYSTEM`:     system does not exist (?);
 * `IML_FILEERR_ACCESSDENIED`:      access to the file was denied;
 * `IML_FILEERR_ALREADYEXISTENTRY`: entry already exists;
 * `IML_FILEERR_READONLYFILE`:      file is read-only;
 * `IML_FILEERR_ENUMRATEEND`:       no more entries;
 * `IML_FILEERR_ILLEGALSEEKPOS`:    cannot seek to this position.
 *
 * Notice that `IML_FILEERR_NOTRECORDFILE`, `IML_FILEERR_DEVICENOTEXIST`,
 * `IML_FILEERR_ENDOFFILE` and `IML_FILEERR_NOTDUALRECORDFILE`
 * are commented in the original header. */

#define IML_FILEERR_NOERROR            0
#define IML_FILEERR_ENTRYNOTFOUND     -1
#define IML_FILEERR_ILLEGALPARAM      -2
#define IML_FILEERR_ILLEGALPATH       -3
#define IML_FILEERR_DEVICEFULL        -4
#define IML_FILEERR_ILLEGALDEVICE     -5
#define IML_FILEERR_ILLEGALFILESYS    -6
#define IML_FILEERR_ILLEGALSYSTEM     -7
#define IML_FILEERR_ACCESSDENIED      -8
#define IML_FILEERR_ALREADYLOCKED     -9
#define IML_FILEERR_ILLEGALTASKID     -10
#define IML_FILEERR_PERMISSIONERROR   -11
#define IML_FILEERR_ENTRYFULL         -12
#define IML_FILEERR_ALREADYEXISTENTRY -13
#define IML_FILEERR_READONLYFILE      -14
#define IML_FILEERR_ILLEGALFILTER     -15
#define IML_FILEERR_ENUMRATEEND       -16
#define IML_FILEERR_DEVICECHANGED     -17
#define IML_FILEERR_NOTRECORDFILE     -18
#define IML_FILEERR_ILLEGALSEEKPOS    -19
#define IML_FILEERR_ILLEGALBLOCKFILE  -20
#define IML_FILEERR_DEVICENOTEXIST    -21
#define IML_FILEERR_ENDOFFILE         -22
#define IML_FILEERR_NOTMOUNTDEVICE    -23
#define IML_FILEERR_NOTUNMOUNTDEVICE  -24
#define IML_FILEERR_CANNOTLOCKSYSTEM  -25
#define IML_FILEERR_RECORDNOTFOUND    -26
#define IML_FILEERR_NOTDUALRECORDFILE -27
#define IML_FILEERR_NOTALARMSUPPORT   -28
#define IML_FILEERR_CANNOTADDALARM    -29
#define IML_FILEERR_FILEFINDUSED      -30
#define IML_FILEERR_DEVICEERROR       -31
#define IML_FILEERR_SYSTEMNOTLOCKED   -32
#define IML_FILEERR_DEVICENOTFOUND    -33
#define IML_FILEERR_FILETYPEMISMATCH  -34
#define IML_FILEERR_NOTEMPTY          -35
#define IML_FILEERR_BROKENSYSTEMDATA  -36
#define IML_FILEERR_MEDIANOTREADY     -37
#define IML_FILEERR_TOOMANYALARMITEM  -38
#define IML_FILEERR_SAMEALARMEXIST    -39
#define IML_FILEERR_ACCESSWAPAREA     -40
#define IML_FILEERR_MULTIMEDIACARD    -41
#define IML_FILEERR_COPYPROTECTION    -42
#define IML_FILEERR_ILLEGALFILEDATA   -43

/* corrections (from fxlib) */
# define IML_FILEERR_ACCESSDENYED      IML_FILEERR_ACCESSDENIED

__END_NAMESPACE_FXLIB