diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2017-03-12 22:05:44 -0400 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2017-03-12 22:05:44 -0400 |
commit | 6db80020b45ae22b19524b01f60d0653d70ac7ca (patch) | |
tree | 924a9944abe38e094cdbc4b70d0489ed6bc162ce /firmware/include | |
parent | 70c929179b80e0657e31558e34d2bc62e1176564 (diff) | |
download | rockbox-6db80020b45ae22b19524b01f60d0653d70ac7ca.tar.gz rockbox-6db80020b45ae22b19524b01f60d0653d70ac7ca.zip |
Do some housekeeping with fat.h and SECTOR_SIZE
Many includes of fat.h are pointless. Some includes are just for
SECTOR_SIZE. Add a file 'firmware/include/fs_defines.h' for that
and to define tuneable values that were scattered amongst various
headers.
Remove some local definitions of SECTOR_SIZE since they have to be
in agreement with the rest of the fs code anyway.
(We'll see what's in fact pointless in a moment ;)
Change-Id: I9ba183bf58bd87f5c45eba7bd675c7e2c1c18ed5
Diffstat (limited to 'firmware/include')
-rw-r--r-- | firmware/include/disk_cache.h | 23 | ||||
-rw-r--r-- | firmware/include/file_internal.h | 43 | ||||
-rw-r--r-- | firmware/include/fs_defines.h | 108 |
3 files changed, 109 insertions, 65 deletions
diff --git a/firmware/include/disk_cache.h b/firmware/include/disk_cache.h index 725b3778cc..79b2ccf2c6 100644 --- a/firmware/include/disk_cache.h +++ b/firmware/include/disk_cache.h | |||
@@ -21,29 +21,6 @@ | |||
21 | #ifndef DISK_CACHE_H | 21 | #ifndef DISK_CACHE_H |
22 | #define DISK_CACHE_H | 22 | #define DISK_CACHE_H |
23 | 23 | ||
24 | /* This needs enough for all file handles to have a buffer in the worst case | ||
25 | * plus at least one reserved exclusively for the cache client and a couple | ||
26 | * for other file system code. The buffers are put to use by the cache if not | ||
27 | * taken for another purpose (meaning nothing is wasted sitting fallow). | ||
28 | * | ||
29 | * One map per volume is maintained in order to avoid collisions between | ||
30 | * volumes that would slow cache probing. DC_MAP_NUM_ENTRIES is the number | ||
31 | * for each map per volume. The buffers themselves are shared. | ||
32 | */ | ||
33 | #if MEMORYSIZE < 8 | ||
34 | #define DC_NUM_ENTRIES 32 | ||
35 | #define DC_MAP_NUM_ENTRIES 128 | ||
36 | #elif MEMORYSIZE <= 32 | ||
37 | #define DC_NUM_ENTRIES 48 | ||
38 | #define DC_MAP_NUM_ENTRIES 128 | ||
39 | #else /* MEMORYSIZE > 32 */ | ||
40 | #define DC_NUM_ENTRIES 64 | ||
41 | #define DC_MAP_NUM_ENTRIES 256 | ||
42 | #endif /* MEMORYSIZE */ | ||
43 | |||
44 | /* this _could_ be larger than a sector if that would ever be useful */ | ||
45 | #define DC_CACHE_BUFSIZE SECTOR_SIZE | ||
46 | |||
47 | #include "mutex.h" | 24 | #include "mutex.h" |
48 | #include "mv.h" | 25 | #include "mv.h" |
49 | 26 | ||
diff --git a/firmware/include/file_internal.h b/firmware/include/file_internal.h index 5893737833..d62b5a8541 100644 --- a/firmware/include/file_internal.h +++ b/firmware/include/file_internal.h | |||
@@ -28,55 +28,14 @@ | |||
28 | #include "mutex.h" | 28 | #include "mutex.h" |
29 | #include "mrsw_lock.h" | 29 | #include "mrsw_lock.h" |
30 | #include "fs_attr.h" | 30 | #include "fs_attr.h" |
31 | #include "fs_defines.h" | ||
31 | #include "fat.h" | 32 | #include "fat.h" |
32 | #ifdef HAVE_DIRCACHE | 33 | #ifdef HAVE_DIRCACHE |
33 | #include "dircache.h" | 34 | #include "dircache.h" |
34 | #endif | 35 | #endif |
35 | 36 | ||
36 | /** Tuneable parameters **/ | ||
37 | |||
38 | /* limits for number of open descriptors - if you increase these values, make | ||
39 | certain that the disk cache has enough available buffers */ | ||
40 | #define MAX_OPEN_FILES 11 | ||
41 | #define MAX_OPEN_DIRS 12 | ||
42 | #define MAX_OPEN_HANDLES (MAX_OPEN_FILES+MAX_OPEN_DIRS) | 37 | #define MAX_OPEN_HANDLES (MAX_OPEN_FILES+MAX_OPEN_DIRS) |
43 | 38 | ||
44 | /* internal functions open streams as well; make sure they don't fail if all | ||
45 | user descs are busy; this needs to be at least the greatest quantity needed | ||
46 | at once by all internal functions */ | ||
47 | #ifdef HAVE_DIRCACHE | ||
48 | #define AUX_FILEOBJS 3 | ||
49 | #else | ||
50 | #define AUX_FILEOBJS 2 | ||
51 | #endif | ||
52 | |||
53 | /* number of components statically allocated to handle the vast majority | ||
54 | of path depths; should maybe be tuned for >= 90th percentile but for now, | ||
55 | imma just guessing based on something like: | ||
56 | root + 'Music' + 'Artist' + 'Album' + 'Disc N' + filename */ | ||
57 | #define STATIC_PATHCOMP_NUM 6 | ||
58 | |||
59 | #define MAX_COMPNAME 260 | ||
60 | |||
61 | /* unsigned value that will also hold the off_t range we need without | ||
62 | overflow */ | ||
63 | #define file_size_t uint32_t | ||
64 | |||
65 | #ifdef __USE_FILE_OFFSET64 | ||
66 | /* if we want, we can deal with files up to 2^32-1 bytes-- the full FAT16/32 | ||
67 | range */ | ||
68 | #define FILE_SIZE_MAX (0xffffffffu) | ||
69 | #else | ||
70 | /* file contents and size will be preserved by the APIs so long as ftruncate() | ||
71 | isn't used; bytes passed 2^31-1 will not accessible nor will writes succeed | ||
72 | that would extend the file beyond the max for a 32-bit off_t */ | ||
73 | #define FILE_SIZE_MAX (0x7fffffffu) | ||
74 | #endif | ||
75 | |||
76 | /* if file is "large(ish)", then get rid of the contents now rather than | ||
77 | lazily when the file is synced or closed in order to free-up space */ | ||
78 | #define O_TRUNC_THRESH 65536 | ||
79 | |||
80 | /* default attributes when creating new files and directories */ | 39 | /* default attributes when creating new files and directories */ |
81 | #define ATTR_NEW_FILE (ATTR_ARCHIVE) | 40 | #define ATTR_NEW_FILE (ATTR_ARCHIVE) |
82 | #define ATTR_NEW_DIRECTORY (ATTR_DIRECTORY) | 41 | #define ATTR_NEW_DIRECTORY (ATTR_DIRECTORY) |
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 */ | ||