Remove the calls to backlight_lcd_sleep_countdown from target specific code and move...
[kugel-rb.git] / firmware / export / fat.h
blobc99a1a75f843871d0d1f23930212810d6da04fef
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2002 by Linus Nielsen Feltzing
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #ifndef FAT_H
23 #define FAT_H
25 #include <stdbool.h>
26 #include "mv.h" /* for volume definitions */
27 #include "config.h"
29 #define SECTOR_SIZE 512
31 /* Number of bytes reserved for a file name (including the trailing \0).
32 Since names are stored in the entry as UTF-8, we won't be able to
33 store all names allowed by FAT. In FAT, a name can have max 255
34 characters (not bytes!). Since the UTF-8 encoding of a char may take
35 up to 4 bytes, there will be names that we won't be able to store
36 completely. For such names, the short DOS name is used. */
37 #define FAT_FILENAME_BYTES 256
39 struct fat_direntry
41 unsigned char name[FAT_FILENAME_BYTES]; /* UTF-8 encoded name plus \0 */
42 unsigned short attr; /* Attributes */
43 unsigned char crttimetenth; /* Millisecond creation
44 time stamp (0-199) */
45 unsigned short crttime; /* Creation time */
46 unsigned short crtdate; /* Creation date */
47 unsigned short lstaccdate; /* Last access date */
48 unsigned short wrttime; /* Last write time */
49 unsigned short wrtdate; /* Last write date */
50 unsigned long filesize; /* File size in bytes */
51 long firstcluster; /* fstclusterhi<<16 + fstcluslo */
54 #define FAT_ATTR_READ_ONLY 0x01
55 #define FAT_ATTR_HIDDEN 0x02
56 #define FAT_ATTR_SYSTEM 0x04
57 #define FAT_ATTR_VOLUME_ID 0x08
58 #define FAT_ATTR_DIRECTORY 0x10
59 #define FAT_ATTR_ARCHIVE 0x20
60 #define FAT_ATTR_VOLUME 0x40 /* this is a volume, not a real directory */
62 struct fat_file
64 long firstcluster; /* first cluster in file */
65 long lastcluster; /* cluster of last access */
66 long lastsector; /* sector of last access */
67 long clusternum; /* current clusternum */
68 long sectornum; /* sector number in this cluster */
69 unsigned int direntry; /* short dir entry index from start of dir */
70 unsigned int direntries; /* number of dir entries used by this file */
71 long dircluster; /* first cluster of dir */
72 bool eof;
73 #ifdef HAVE_MULTIVOLUME
74 int volume; /* file resides on which volume */
75 #endif
78 struct fat_dir
80 unsigned int entry;
81 unsigned int entrycount;
82 long sector;
83 struct fat_file file;
84 unsigned char sectorcache[3][SECTOR_SIZE];
87 #ifdef HAVE_HOTSWAP
88 extern void fat_lock(void);
89 extern void fat_unlock(void);
90 #endif
92 extern void fat_init(void);
93 extern int fat_mount(IF_MV2(int volume,) IF_MV2(int drive,) long startsector);
94 extern int fat_unmount(int volume, bool flush);
95 extern void fat_size(IF_MV2(int volume,) /* public for info */
96 unsigned long* size,
97 unsigned long* free);
98 extern void fat_recalc_free(IF_MV_NONVOID(int volume)); /* public for debug info screen */
99 extern int fat_create_dir(const char* name,
100 struct fat_dir* newdir,
101 struct fat_dir* dir);
102 extern int fat_open(IF_MV2(int volume,)
103 long cluster,
104 struct fat_file* ent,
105 const struct fat_dir* dir);
106 extern int fat_create_file(const char* name,
107 struct fat_file* ent,
108 struct fat_dir* dir);
109 extern long fat_readwrite(struct fat_file *ent, long sectorcount,
110 void* buf, bool write );
111 extern int fat_closewrite(struct fat_file *ent, long size, int attr);
112 extern int fat_seek(struct fat_file *ent, unsigned long sector );
113 extern int fat_remove(struct fat_file *ent);
114 extern int fat_truncate(const struct fat_file *ent);
115 extern int fat_rename(struct fat_file* file,
116 struct fat_dir* dir,
117 const unsigned char* newname,
118 long size, int attr);
120 extern int fat_opendir(IF_MV2(int volume,)
121 struct fat_dir *ent, unsigned long currdir,
122 const struct fat_dir *parent_dir);
123 extern int fat_getnext(struct fat_dir *ent, struct fat_direntry *entry);
124 extern unsigned int fat_get_cluster_size(IF_MV_NONVOID(int volume)); /* public for debug info screen */
125 extern bool fat_ismounted(int volume);
127 #endif