altos: Add SDCARD and FAT16 filesystem support
[fw/altos] / src / drivers / ao_fat.h
1 /*
2  * Copyright © 2013 Keith Packard <keithp@keithp.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; version 2 of the License.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  * General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License along
14  * with this program; if not, write to the Free Software Foundation, Inc.,
15  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
16  */
17
18 #ifndef _AO_FAT_H_
19 #define _AO_FAT_H_
20
21 void
22 ao_fat_init(void);
23
24 #define AO_FAT_FILE_READ_ONLY           0x01
25 #define AO_FAT_FILE_HIDDEN              0x02
26 #define AO_FAT_FILE_SYSTEM              0x04
27 #define AO_FAT_FILE_VOLUME_LABEL        0x08
28 #define AO_FAT_FILE_DIRECTORY           0x10
29 #define AO_FAT_FILE_ARCHIVE             0x20
30
31 #define AO_FAT_DENT_EMPTY               0xe5
32 #define AO_FAT_DENT_END                 0x00
33
34 uint8_t
35 ao_fat_open(char name[11]);
36
37 uint8_t
38 ao_fat_creat(char name[11]);
39
40 void
41 ao_fat_close(void);
42
43 int
44 ao_fat_read(uint8_t *dest, int len);
45
46 int
47 ao_fat_write(uint8_t *buf, int len);
48
49 #define AO_FAT_SEEK_SET 0
50 #define AO_FAT_SEEK_CUR 1
51 #define AO_FAT_SEEK_END 2
52
53 uint32_t
54 bao_fat_seek(int32_t pos, uint8_t whence);
55
56 uint8_t
57 ao_fat_unlink(char name[11]);
58
59 uint8_t
60 ao_fat_rename(char old[11], char new[11]);
61
62 struct ao_fat_dirent {
63         char            name[11];
64         uint8_t         attr;
65         uint32_t        size;
66         uint16_t        cluster;
67         uint16_t        entry;
68 };
69
70 uint8_t
71 ao_fat_readdir(uint16_t *entry, struct ao_fat_dirent *dirent);
72
73 #endif /* _AO_FAT_H_ */