A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd

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

+118 -105
+1 -1
apps/debug_menu.c
··· 63 63 #include "usb.h" 64 64 #include "rtc.h" 65 65 #include "storage.h" 66 - #include "fat.h" 66 + #include "fs_defines.h" 67 67 #include "eeprom_24cxx.h" 68 68 #if (CONFIG_STORAGE & STORAGE_MMC) || (CONFIG_STORAGE & STORAGE_SD) 69 69 #include "sdmmc.h"
-1
bootloader/gigabeat.c
··· 29 29 #include "lcd.h" 30 30 #include "../kernel-internal.h" 31 31 #include "storage.h" 32 - #include "fat.h" 33 32 #include "file_internal.h" 34 33 #include "disk.h" 35 34 #include "font.h"
-1
bootloader/ipod.c
··· 32 32 #include "lcd.h" 33 33 #include "../kernel-internal.h" 34 34 #include "ata.h" 35 - #include "fat.h" 36 35 #include "file_internal.h" 37 36 #include "disk.h" 38 37 #include "font.h"
-1
bootloader/ipod6g.c
··· 32 32 #include "../kernel-internal.h" 33 33 #include "file_internal.h" 34 34 #include "storage.h" 35 - #include "fat.h" 36 35 #include "disk.h" 37 36 #include "font.h" 38 37 #include "backlight.h"
-1
bootloader/ipodnano2g.c
··· 34 34 #include "../kernel-internal.h" 35 35 #include "file_internal.h" 36 36 #include "storage.h" 37 - #include "fat.h" 38 37 #include "disk.h" 39 38 #include "font.h" 40 39 #include "backlight.h"
-1
bootloader/meizu_m3.c
··· 32 32 #include "lcd.h" 33 33 #include "../kernel-internal.h" 34 34 #include "storage.h" 35 - #include "fat.h" 36 35 #include "disk.h" 37 36 #include "font.h" 38 37 #include "backlight.h"
-1
bootloader/meizu_m6sl.c
··· 30 30 #include "kernel.h" 31 31 #include "thread.h" 32 32 #include "storage.h" 33 - #include "fat.h" 34 33 #include "disk.h" 35 34 #include "font.h" 36 35 #include "adc.h"
-1
bootloader/meizu_m6sp.c
··· 30 30 #include "kernel.h" 31 31 #include "thread.h" 32 32 #include "storage.h" 33 - #include "fat.h" 34 33 #include "disk.h" 35 34 #include "font.h" 36 35 #include "button.h"
-1
bootloader/mini2440.c
··· 30 30 #include "../kernel-internal.h" 31 31 #include "storage.h" 32 32 #include "file_internal.h" 33 - #include "fat.h" 34 33 #include "disk.h" 35 34 #include "font.h" 36 35 #include "backlight.h"
-1
bootloader/mrobe500.c
··· 27 27 #include "../kernel-internal.h" 28 28 #include "storage.h" 29 29 #include "file_internal.h" 30 - #include "fat.h" 31 30 #include "disk.h" 32 31 #include "font.h" 33 32 #include "adc.h"
-1
bootloader/sansaview.c
··· 35 35 #include "lcd.h" 36 36 #include "../kernel-internal.h" 37 37 #include "storage.h" 38 - #include "fat.h" 39 38 #include "disk.h" 40 39 #include "font.h" 41 40 #include "backlight.h"
-1
bootloader/telechips.c
··· 31 31 #include "../kernel-internal.h" 32 32 #include "storage.h" 33 33 #include "file_internal.h" 34 - #include "fat.h" 35 34 #include "disk.h" 36 35 #include "font.h" 37 36 #include "button.h"
-1
bootloader/tpj1022.c
··· 32 32 #include "thread.h" 33 33 #include "storage.h" 34 34 #include "file_internal.h" 35 - #include "fat.h" 36 35 #include "disk.h" 37 36 #include "font.h" 38 37 #include "panic.h"
+1 -1
firmware/common/disk_cache.c
··· 23 23 #include "system.h" 24 24 #include "linked_list.h" 25 25 #include "disk_cache.h" 26 - #include "fat.h" /* for SECTOR_SIZE */ 26 + #include "fs_defines.h" 27 27 #include "bitarray.h" 28 28 29 29 /* Cache: LRU cache with separately-chained hashtable
+1 -2
firmware/drivers/ata.c
··· 34 34 #include "ata_idle_notify.h" 35 35 #include "ata-driver.h" 36 36 #include "ata-defines.h" 37 + #include "fs_defines.h" 37 38 #include "storage.h" 38 - 39 - #define SECTOR_SIZE 512 40 39 41 40 #define SELECT_DEVICE1 0x10 42 41 #define SELECT_LBA 0x40
-8
firmware/export/fat.h
··· 48 48 #define FAT_MAX_TRANSFER_SIZE 256 49 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
-23
firmware/include/disk_cache.h
··· 21 21 #ifndef DISK_CACHE_H 22 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 24 #include "mutex.h" 48 25 #include "mv.h" 49 26
+1 -42
firmware/include/file_internal.h
··· 28 28 #include "mutex.h" 29 29 #include "mrsw_lock.h" 30 30 #include "fs_attr.h" 31 + #include "fs_defines.h" 31 32 #include "fat.h" 32 33 #ifdef HAVE_DIRCACHE 33 34 #include "dircache.h" 34 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 37 #define MAX_OPEN_HANDLES (MAX_OPEN_FILES+MAX_OPEN_DIRS) 43 - 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 38 80 39 /* default attributes when creating new files and directories */ 81 40 #define ATTR_NEW_FILE (ATTR_ARCHIVE)
+108
firmware/include/fs_defines.h
··· 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 */
+1 -1
firmware/target/arm/as3525/sd-as3525.c
··· 23 23 /* Driver for the ARM PL180 SD/MMC controller inside AS3525 SoC */ 24 24 25 25 #include "config.h" /* for HAVE_MULTIDRIVE & AMS_OF_SIZE */ 26 - #include "fat.h" 26 + #include "fs_defines.h" 27 27 #include "thread.h" 28 28 #include "led.h" 29 29 #include "sdmmc.h"
+1 -1
firmware/target/arm/as3525/sd-as3525v2.c
··· 21 21 ****************************************************************************/ 22 22 23 23 #include "config.h" /* for HAVE_MULTIVOLUME */ 24 - #include "fat.h" 24 + #include "fs_defines.h" 25 25 #include "thread.h" 26 26 #include "gcc_extensions.h" 27 27 #include "led.h"
+1 -2
firmware/target/arm/ata-nand-telechips.c
··· 28 28 #include "panic.h" 29 29 #include "nand_id.h" 30 30 #include "storage.h" 31 - 32 - #define SECTOR_SIZE 512 31 + #include "fs_defines.h" 33 32 34 33 /* ECC on read is implemented on the assumption that MLC-style 4-bit correction 35 34 is always used regardless of NAND chip type. This assumption is true for at
+1 -1
firmware/target/arm/imx233/nand-imx233.c
··· 23 23 #include "gpmi-imx233.h" 24 24 #include "pinctrl-imx233.h" 25 25 #include "button-target.h" 26 - #include "fat.h" 26 + #include "fs_defines.h" 27 27 #include "disk.h" 28 28 #include "usb.h" 29 29 #include "debug.h"
-1
firmware/target/arm/imx233/sdmmc-imx233.c
··· 27 27 #include "pinctrl-imx233.h" 28 28 #include "partitions-imx233.h" 29 29 #include "button-target.h" 30 - #include "fat.h" 31 30 #include "disk.h" 32 31 #include "usb.h" 33 32 #include "debug.h"
-1
firmware/target/arm/pnx0101/iriver-ifp7xx/usb-ifp7xx.c
··· 25 25 #include "system.h" 26 26 #include "debug.h" 27 27 #include "ata.h" 28 - #include "fat.h" 29 28 #include "disk.h" 30 29 #include "panic.h" 31 30 #include "lcd.h"
+1 -1
firmware/target/arm/pp/ata-sd-pp.c
··· 35 35 #include "usb.h" 36 36 #include "sd.h" 37 37 #include "storage.h" 38 + #include "fs_defines.h" 38 39 39 - #define SECTOR_SIZE 512 40 40 #define BLOCKS_PER_BANK 0x7a7800 41 41 42 42 /* Comparing documentations of various MMC/SD controllers revealed, */
-2
firmware/target/arm/tms320dm320/sdmmc-dm320.c
··· 43 43 #endif 44 44 #include "sdmmc.h" 45 45 #include "disk.h" 46 - #include "fat.h" 47 46 #include "system-target.h" 48 47 49 48 /* The configuration method is not very flexible. */ ··· 72 71 #define UNALIGNED_NUM_SECTORS 10 73 72 #define MAX_TRANSFER_ERRORS 10 74 73 75 - #define SECTOR_SIZE 512 76 74 #define BLOCKS_PER_BANK 0x7A7800 77 75 78 76 /* command flags for send_cmd */
-1
firmware/usb.c
··· 30 30 #include "system.h" 31 31 #include "debug.h" 32 32 #include "storage.h" 33 - #include "fat.h" 34 33 #include "disk.h" 35 34 #include "panic.h" 36 35 #include "lcd.h"
+1 -5
firmware/usbstack/usb_storage.c
··· 27 27 #include "logf.h" 28 28 #include "storage.h" 29 29 #include "disk.h" 30 - #include "fat.h" 30 + #include "fs_defines.h" 31 31 /* Needed to get at the audio buffer */ 32 32 #include "audio.h" 33 33 #include "usb_storage.h" ··· 39 39 40 40 #ifdef USB_USE_RAMDISK 41 41 #define RAMDISK_SIZE 2048 42 - #endif 43 - 44 - #ifndef SECTOR_SIZE 45 - #define SECTOR_SIZE 512 46 42 #endif 47 43 48 44 /* These defaults allow the operation */