feat(radio): static disk cache (#6170)

This commit is contained in:
Raphael Coeffic
2025-05-08 20:44:33 +10:00
committed by GitHub
parent a651f2e297
commit 83feee4d45
5 changed files with 27 additions and 3 deletions
@@ -29,6 +29,13 @@
_stext_iram = LOADADDR(.iram); _stext_iram = LOADADDR(.iram);
/* Disk cache buffers */
.disk_cache (NOLOAD) :
{
. = ALIGN(4);
*(.disk_cache)
} > RAM_D1
/* Extra DMA section */ /* Extra DMA section */
.dram (NOLOAD) : .dram (NOLOAD) :
{ {
@@ -29,6 +29,13 @@
_stext_iram = LOADADDR(.iram); _stext_iram = LOADADDR(.iram);
/* Disk cache buffers */
.disk_cache (NOLOAD) :
{
. = ALIGN(4);
*(.disk_cache)
} > PSRAM
/* Extra DMA section */ /* Extra DMA section */
.dram (NOLOAD) : .dram (NOLOAD) :
{ {
+7 -1
View File
@@ -38,6 +38,10 @@
#define BLOCK_SIZE FF_MAX_SS #define BLOCK_SIZE FF_MAX_SS
#define DISK_CACHE_BLOCK_SIZE (DISK_CACHE_BLOCK_SECTORS * BLOCK_SIZE) #define DISK_CACHE_BLOCK_SIZE (DISK_CACHE_BLOCK_SECTORS * BLOCK_SIZE)
#if !defined(__DISK_CACHE)
#define __DISK_CACHE __SDRAM
#endif
DiskCache diskCache; DiskCache diskCache;
class DiskCacheBlock class DiskCacheBlock
@@ -112,9 +116,11 @@ DiskCache::DiskCache() : lastBlock(0), blocks(nullptr), diskDrv(nullptr)
stats.noWrites = 0; stats.noWrites = 0;
} }
static DiskCacheBlock _cache_blocks[DISK_CACHE_BLOCKS_NUM] __DISK_CACHE;
void DiskCache::initialize(const diskio_driver_t* drv) void DiskCache::initialize(const diskio_driver_t* drv)
{ {
blocks = new DiskCacheBlock[DISK_CACHE_BLOCKS_NUM]; blocks = _cache_blocks;
diskDrv = drv; diskDrv = drv;
} }
+5
View File
@@ -24,8 +24,13 @@
#include "hal/fatfs_diskio.h" #include "hal/fatfs_diskio.h"
// tunable parameters // tunable parameters
#if !defined(DISK_CACHE_BLOCKS_NUM)
#define DISK_CACHE_BLOCKS_NUM 32 // no cache blocks #define DISK_CACHE_BLOCKS_NUM 32 // no cache blocks
#endif
#if !defined(DISK_CACHE_BLOCK_SECTORS)
#define DISK_CACHE_BLOCK_SECTORS 16 // no sectors #define DISK_CACHE_BLOCK_SECTORS 16 // no sectors
#endif
struct DiskCacheStats struct DiskCacheStats
{ {
@@ -27,5 +27,4 @@
#define __IRAM __attribute__((section(".iram"))) #define __IRAM __attribute__((section(".iram")))
#define __SDRAM __attribute__((section(".sdram"), aligned(4))) #define __SDRAM __attribute__((section(".sdram"), aligned(4)))
#define __SDRAMFONTS __attribute__((section(".sdram_fonts"), aligned(4))) #define __SDRAMFONTS __attribute__((section(".sdram_fonts"), aligned(4)))
#define __DISK_CACHE __attribute__((section(".disk_cache"), aligned(4)))