summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/common/disk_cache.c2
-rw-r--r--firmware/drivers/ata.c3
-rw-r--r--firmware/export/fat.h8
-rw-r--r--firmware/include/disk_cache.h23
-rw-r--r--firmware/include/file_internal.h43
-rw-r--r--firmware/include/fs_defines.h108
-rw-r--r--firmware/target/arm/as3525/sd-as3525.c2
-rw-r--r--firmware/target/arm/as3525/sd-as3525v2.c2
-rw-r--r--firmware/target/arm/ata-nand-telechips.c3
-rw-r--r--firmware/target/arm/imx233/nand-imx233.c2
-rw-r--r--firmware/target/arm/imx233/sdmmc-imx233.c1
-rw-r--r--firmware/target/arm/pnx0101/iriver-ifp7xx/usb-ifp7xx.c1
-rw-r--r--firmware/target/arm/pp/ata-sd-pp.c2
-rw-r--r--firmware/target/arm/tms320dm320/sdmmc-dm320.c2
-rw-r--r--firmware/usb.c1
-rw-r--r--firmware/usbstack/usb_storage.c6
16 files changed, 117 insertions, 92 deletions
diff --git a/firmware/common/disk_cache.c b/firmware/common/disk_cache.c
index 0e842e7796..9e4dee6a91 100644
--- a/firmware/common/disk_cache.c
+++ b/firmware/common/disk_cache.c
@@ -23,7 +23,7 @@
23#include "system.h" 23#include "system.h"
24#include "linked_list.h" 24#include "linked_list.h"
25#include "disk_cache.h" 25#include "disk_cache.h"
26#include "fat.h" /* for SECTOR_SIZE */ 26#include "fs_defines.h"
27#include "bitarray.h" 27#include "bitarray.h"
28 28
29/* Cache: LRU cache with separately-chained hashtable 29/* Cache: LRU cache with separately-chained hashtable
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c
index b98567e8bf..b574117620 100644
--- a/firmware/drivers/ata.c
+++ b/firmware/drivers/ata.c
@@ -34,10 +34,9 @@
34#include "ata_idle_notify.h" 34#include "ata_idle_notify.h"
35#include "ata-driver.h" 35#include "ata-driver.h"
36#include "ata-defines.h" 36#include "ata-defines.h"
37#include "fs_defines.h"
37#include "storage.h" 38#include "storage.h"
38 39
39#define SECTOR_SIZE 512
40
41#define SELECT_DEVICE1 0x10 40#define SELECT_DEVICE1 0x10
42#define SELECT_LBA 0x40 41#define SELECT_LBA 0x40
43 42
diff --git a/firmware/export/fat.h b/firmware/export/fat.h
index 963c1fe767..b8092290e6 100644
--- a/firmware/export/fat.h
+++ b/firmware/export/fat.h
@@ -48,14 +48,6 @@
48#define FAT_MAX_TRANSFER_SIZE 256 48#define FAT_MAX_TRANSFER_SIZE 256
49#endif 49#endif
50 50
51/* still experimental? */
52/* increasing this will increase the total memory used by the cache; the
53 cache, as noted in disk_cache.h, has other minimum requirements that may
54 prevent reducing its number of entries in order to compensate */
55#ifndef SECTOR_SIZE
56#define SECTOR_SIZE 512
57#endif
58
59/** 51/**
60 ****************************************************************************/ 52 ****************************************************************************/
61 53
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 */
diff --git a/firmware/target/arm/as3525/sd-as3525.c b/firmware/target/arm/as3525/sd-as3525.c
index 4530d5d763..e65a7525b6 100644
--- a/firmware/target/arm/as3525/sd-as3525.c
+++ b/firmware/target/arm/as3525/sd-as3525.c
@@ -23,7 +23,7 @@
23/* Driver for the ARM PL180 SD/MMC controller inside AS3525 SoC */ 23/* Driver for the ARM PL180 SD/MMC controller inside AS3525 SoC */
24 24
25#include "config.h" /* for HAVE_MULTIDRIVE & AMS_OF_SIZE */ 25#include "config.h" /* for HAVE_MULTIDRIVE & AMS_OF_SIZE */
26#include "fat.h" 26#include "fs_defines.h"
27#include "thread.h" 27#include "thread.h"
28#include "led.h" 28#include "led.h"
29#include "sdmmc.h" 29#include "sdmmc.h"
diff --git a/firmware/target/arm/as3525/sd-as3525v2.c b/firmware/target/arm/as3525/sd-as3525v2.c
index dec36a520d..3f39629e0b 100644
--- a/firmware/target/arm/as3525/sd-as3525v2.c
+++ b/firmware/target/arm/as3525/sd-as3525v2.c
@@ -21,7 +21,7 @@
21 ****************************************************************************/ 21 ****************************************************************************/
22 22
23#include "config.h" /* for HAVE_MULTIVOLUME */ 23#include "config.h" /* for HAVE_MULTIVOLUME */
24#include "fat.h" 24#include "fs_defines.h"
25#include "thread.h" 25#include "thread.h"
26#include "gcc_extensions.h" 26#include "gcc_extensions.h"
27#include "led.h" 27#include "led.h"
diff --git a/firmware/target/arm/ata-nand-telechips.c b/firmware/target/arm/ata-nand-telechips.c
index b8e572068c..869a53c1ef 100644
--- a/firmware/target/arm/ata-nand-telechips.c
+++ b/firmware/target/arm/ata-nand-telechips.c
@@ -28,8 +28,7 @@
28#include "panic.h" 28#include "panic.h"
29#include "nand_id.h" 29#include "nand_id.h"
30#include "storage.h" 30#include "storage.h"
31 31#include "fs_defines.h"
32#define SECTOR_SIZE 512
33 32
34/* ECC on read is implemented on the assumption that MLC-style 4-bit correction 33/* ECC on read is implemented on the assumption that MLC-style 4-bit correction
35 is always used regardless of NAND chip type. This assumption is true for at 34 is always used regardless of NAND chip type. This assumption is true for at
diff --git a/firmware/target/arm/imx233/nand-imx233.c b/firmware/target/arm/imx233/nand-imx233.c
index 22c4fc2748..a7afba7d43 100644
--- a/firmware/target/arm/imx233/nand-imx233.c
+++ b/firmware/target/arm/imx233/nand-imx233.c
@@ -23,7 +23,7 @@
23#include "gpmi-imx233.h" 23#include "gpmi-imx233.h"
24#include "pinctrl-imx233.h" 24#include "pinctrl-imx233.h"
25#include "button-target.h" 25#include "button-target.h"
26#include "fat.h" 26#include "fs_defines.h"
27#include "disk.h" 27#include "disk.h"
28#include "usb.h" 28#include "usb.h"
29#include "debug.h" 29#include "debug.h"
diff --git a/firmware/target/arm/imx233/sdmmc-imx233.c b/firmware/target/arm/imx233/sdmmc-imx233.c
index 28310fbfd1..d3dabafecb 100644
--- a/firmware/target/arm/imx233/sdmmc-imx233.c
+++ b/firmware/target/arm/imx233/sdmmc-imx233.c
@@ -27,7 +27,6 @@
27#include "pinctrl-imx233.h" 27#include "pinctrl-imx233.h"
28#include "partitions-imx233.h" 28#include "partitions-imx233.h"
29#include "button-target.h" 29#include "button-target.h"
30#include "fat.h"
31#include "disk.h" 30#include "disk.h"
32#include "usb.h" 31#include "usb.h"
33#include "debug.h" 32#include "debug.h"
diff --git a/firmware/target/arm/pnx0101/iriver-ifp7xx/usb-ifp7xx.c b/firmware/target/arm/pnx0101/iriver-ifp7xx/usb-ifp7xx.c
index 2f3c4189e5..0bfcdf3b1a 100644
--- a/firmware/target/arm/pnx0101/iriver-ifp7xx/usb-ifp7xx.c
+++ b/firmware/target/arm/pnx0101/iriver-ifp7xx/usb-ifp7xx.c
@@ -25,7 +25,6 @@
25#include "system.h" 25#include "system.h"
26#include "debug.h" 26#include "debug.h"
27#include "ata.h" 27#include "ata.h"
28#include "fat.h"
29#include "disk.h" 28#include "disk.h"
30#include "panic.h" 29#include "panic.h"
31#include "lcd.h" 30#include "lcd.h"
diff --git a/firmware/target/arm/pp/ata-sd-pp.c b/firmware/target/arm/pp/ata-sd-pp.c
index 2a11b40fee..edb806ab96 100644
--- a/firmware/target/arm/pp/ata-sd-pp.c
+++ b/firmware/target/arm/pp/ata-sd-pp.c
@@ -35,8 +35,8 @@
35#include "usb.h" 35#include "usb.h"
36#include "sd.h" 36#include "sd.h"
37#include "storage.h" 37#include "storage.h"
38#include "fs_defines.h"
38 39
39#define SECTOR_SIZE 512
40#define BLOCKS_PER_BANK 0x7a7800 40#define BLOCKS_PER_BANK 0x7a7800
41 41
42/* Comparing documentations of various MMC/SD controllers revealed, */ 42/* Comparing documentations of various MMC/SD controllers revealed, */
diff --git a/firmware/target/arm/tms320dm320/sdmmc-dm320.c b/firmware/target/arm/tms320dm320/sdmmc-dm320.c
index d46dbf5e40..a6e261bcfa 100644
--- a/firmware/target/arm/tms320dm320/sdmmc-dm320.c
+++ b/firmware/target/arm/tms320dm320/sdmmc-dm320.c
@@ -43,7 +43,6 @@
43#endif 43#endif
44#include "sdmmc.h" 44#include "sdmmc.h"
45#include "disk.h" 45#include "disk.h"
46#include "fat.h"
47#include "system-target.h" 46#include "system-target.h"
48 47
49/* The configuration method is not very flexible. */ 48/* The configuration method is not very flexible. */
@@ -72,7 +71,6 @@
72#define UNALIGNED_NUM_SECTORS 10 71#define UNALIGNED_NUM_SECTORS 10
73#define MAX_TRANSFER_ERRORS 10 72#define MAX_TRANSFER_ERRORS 10
74 73
75#define SECTOR_SIZE 512
76#define BLOCKS_PER_BANK 0x7A7800 74#define BLOCKS_PER_BANK 0x7A7800
77 75
78/* command flags for send_cmd */ 76/* command flags for send_cmd */
diff --git a/firmware/usb.c b/firmware/usb.c
index ee6ed2c12c..5e3795dd48 100644
--- a/firmware/usb.c
+++ b/firmware/usb.c
@@ -30,7 +30,6 @@
30#include "system.h" 30#include "system.h"
31#include "debug.h" 31#include "debug.h"
32#include "storage.h" 32#include "storage.h"
33#include "fat.h"
34#include "disk.h" 33#include "disk.h"
35#include "panic.h" 34#include "panic.h"
36#include "lcd.h" 35#include "lcd.h"
diff --git a/firmware/usbstack/usb_storage.c b/firmware/usbstack/usb_storage.c
index 59ec191b4b..70587dfed4 100644
--- a/firmware/usbstack/usb_storage.c
+++ b/firmware/usbstack/usb_storage.c
@@ -27,7 +27,7 @@
27#include "logf.h" 27#include "logf.h"
28#include "storage.h" 28#include "storage.h"
29#include "disk.h" 29#include "disk.h"
30#include "fat.h" 30#include "fs_defines.h"
31/* Needed to get at the audio buffer */ 31/* Needed to get at the audio buffer */
32#include "audio.h" 32#include "audio.h"
33#include "usb_storage.h" 33#include "usb_storage.h"
@@ -41,10 +41,6 @@
41#define RAMDISK_SIZE 2048 41#define RAMDISK_SIZE 2048
42#endif 42#endif
43 43
44#ifndef SECTOR_SIZE
45#define SECTOR_SIZE 512
46#endif
47
48/* These defaults allow the operation */ 44/* These defaults allow the operation */
49#ifndef USBSTOR_READ_SECTORS_FILTER 45#ifndef USBSTOR_READ_SECTORS_FILTER
50#define USBSTOR_READ_SECTORS_FILTER() ({ 0; }) 46#define USBSTOR_READ_SECTORS_FILTER() ({ 0; })