summaryrefslogtreecommitdiff
path: root/firmware/include/fs_defines.h
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/include/fs_defines.h')
-rw-r--r--firmware/include/fs_defines.h108
1 files changed, 108 insertions, 0 deletions
diff --git a/firmware/include/fs_defines.h b/firmware/include/fs_defines.h
new file mode 100644
index 0000000000..538c4b36cd
--- /dev/null
+++ b/firmware/include/fs_defines.h
@@ -0,0 +1,108 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2017 by Michael Sevakis
11 *
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.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#ifndef FS_DEFINES_H
22#define FS_DEFINES_H
23
24/** Tuneable parameters **/
25
26#if 0
27/* Define this just in case you're doing something that may crash a lot and
28 want less write caching */
29#define FS_MIN_WRITECACHING
30#endif
31
32#ifndef MAX_PATH
33#define MAX_PATH 260
34#endif
35
36#define MAX_COMPNAME 260
37
38/* still experimental? */
39/* increasing this will increase the total memory used by the cache; the
40 cache, as noted in disk_cache.h, has other minimum requirements that may
41 prevent reducing its number of entries in order to compensate */
42#ifndef SECTOR_SIZE
43#define SECTOR_SIZE 512
44#endif
45
46/* limits for number of open descriptors - if you increase these values, make
47 certain that the disk cache has enough available buffers */
48#define MAX_OPEN_FILES 11
49#define MAX_OPEN_DIRS 12
50
51/* internal functions open streams as well; make sure they don't fail if all
52 user descs are busy; this needs to be at least the greatest quantity needed
53 at once by all internal functions */
54#ifdef HAVE_DIRCACHE
55#define AUX_FILEOBJS 3
56#else
57#define AUX_FILEOBJS 2
58#endif
59
60/* number of components statically allocated to handle the vast majority
61 of path depths; should maybe be tuned for >= 90th percentile but for now,
62 imma just guessing based on something like:
63 root + 'Music' + 'Artist' + 'Album' + 'Disc N' + filename */
64#define STATIC_PATHCOMP_NUM 6
65
66/* unsigned value that will also hold the off_t range we need without
67 overflow */
68#define file_size_t uint32_t
69
70#ifdef __USE_FILE_OFFSET64
71/* if we want, we can deal with files up to 2^32-1 bytes-- the full FAT16/32
72 range */
73#define FILE_SIZE_MAX (0xffffffffu)
74#else
75/* file contents and size will be preserved by the APIs so long as ftruncate()
76 isn't used; bytes passed 2^31-1 will not accessible nor will writes succeed
77 that would extend the file beyond the max for a 32-bit off_t */
78#define FILE_SIZE_MAX (0x7fffffffu)
79#endif
80
81/* if file is "large(ish)", then get rid of the contents now rather than
82 lazily when the file is synced or closed in order to free-up space */
83#define O_TRUNC_THRESH 65536
84
85/* This needs enough for all file handles to have a buffer in the worst case
86 * plus at least one reserved exclusively for the cache client and a couple
87 * for other file system code. The buffers are put to use by the cache if not
88 * taken for another purpose (meaning nothing is wasted sitting fallow).
89 *
90 * One map per volume is maintained in order to avoid collisions between
91 * volumes that would slow cache probing. IOC_MAP_NUM_ENTRIES is the number
92 * for each map per volume. The buffers themselves are shared.
93 */
94#if MEMORYSIZE < 8
95#define DC_NUM_ENTRIES 32
96#define DC_MAP_NUM_ENTRIES 128
97#elif MEMORYSIZE <= 32
98#define DC_NUM_ENTRIES 48
99#define DC_MAP_NUM_ENTRIES 128
100#else /* MEMORYSIZE > 32 */
101#define DC_NUM_ENTRIES 64
102#define DC_MAP_NUM_ENTRIES 256
103#endif /* MEMORYSIZE */
104
105/* this _could_ be larger than a sector if that would ever be useful */
106#define DC_CACHE_BUFSIZE SECTOR_SIZE
107
108#endif /* FS_DEFINES_H */