mirror of
https://github.com/opentx/opentx.git
synced 2025-07-24 00:35:18 +03:00
Compilation fix. Massstorage won't use disk cache anymore
This commit is contained in:
parent
67ebadc9e0
commit
4b2315f56b
9 changed files with 60 additions and 66 deletions
|
@ -24,9 +24,6 @@
|
||||||
#if defined(SIMU) && !defined(SIMU_DISKIO)
|
#if defined(SIMU) && !defined(SIMU_DISKIO)
|
||||||
#define __disk_read(...) (RES_OK)
|
#define __disk_read(...) (RES_OK)
|
||||||
#define __disk_write(...) (RES_OK)
|
#define __disk_write(...) (RES_OK)
|
||||||
#else
|
|
||||||
extern DRESULT __disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count);
|
|
||||||
extern DRESULT __disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0 // set to 1 to enable traces
|
#if 0 // set to 1 to enable traces
|
||||||
|
@ -37,8 +34,8 @@
|
||||||
|
|
||||||
DiskCache diskCache;
|
DiskCache diskCache;
|
||||||
|
|
||||||
DiskCacheBlock::DiskCacheBlock()
|
DiskCacheBlock::DiskCacheBlock():
|
||||||
: startSector(0),
|
startSector(0),
|
||||||
endSector(0)
|
endSector(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -79,8 +76,8 @@ bool DiskCacheBlock::empty() const
|
||||||
return (endSector == 0);
|
return (endSector == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
DiskCache::DiskCache()
|
DiskCache::DiskCache():
|
||||||
: lastBlock(0)
|
lastBlock(0)
|
||||||
{
|
{
|
||||||
stats.noHits = 0;
|
stats.noHits = 0;
|
||||||
stats.noMisses = 0;
|
stats.noMisses = 0;
|
||||||
|
@ -102,7 +99,7 @@ DRESULT DiskCache::read(BYTE drv, BYTE * buff, DWORD sector, UINT count)
|
||||||
}
|
}
|
||||||
|
|
||||||
// if block + cache block size is beyond the end of the disk, then read it directly without using cache
|
// if block + cache block size is beyond the end of the disk, then read it directly without using cache
|
||||||
if (sector+DISK_CACHE_BLOCK_SECTORS >= SDCardInfo.CardCapacity / SDCardInfo.CardBlockSize) {
|
if (sector+DISK_CACHE_BLOCK_SECTORS >= sdGetNoSectors()) {
|
||||||
TRACE_DISK_CACHE("\t\t cache would be beyond end of disk(%u)", this, (uint32_t)sector);
|
TRACE_DISK_CACHE("\t\t cache would be beyond end of disk(%u)", this, (uint32_t)sector);
|
||||||
return __disk_read(drv, buff, sector, count);
|
return __disk_read(drv, buff, sector, count);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,4 +13,4 @@ endmacro(add_lua_export_target)
|
||||||
|
|
||||||
add_lua_export_target(taranis -DCPUARM -DPCBTARANIS -DLUA -DVIRTUALINPUTS)
|
add_lua_export_target(taranis -DCPUARM -DPCBTARANIS -DLUA -DVIRTUALINPUTS)
|
||||||
add_lua_export_target(taranis_x9e -DCPUARM -DPCBTARANIS -DPCBX9E -DLUA -DVIRTUALINPUTS)
|
add_lua_export_target(taranis_x9e -DCPUARM -DPCBTARANIS -DPCBX9E -DLUA -DVIRTUALINPUTS)
|
||||||
add_lua_export_target(horus -DCPUARM -DPCBHORUS -DLUA -DVIRTUALINPUTS -I${RADIO_SRC_DIRECTORY}/gui/horus)
|
add_lua_export_target(horus -DCPUARM -DPCBHORUS -DLUA -DVIRTUALINPUTS -I${RADIO_SRC_DIRECTORY}/gui/480x272)
|
||||||
|
|
|
@ -326,7 +326,7 @@ uint32_t sdGetNoSectors()
|
||||||
|
|
||||||
uint32_t sdGetSize()
|
uint32_t sdGetSize()
|
||||||
{
|
{
|
||||||
return (sdGetNoSectors() * 512) / 1000000;
|
return (sdGetNoSectors() * BLOCK_SIZE) / 1000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t sdGetFreeSectors()
|
uint32_t sdGetFreeSectors()
|
||||||
|
|
|
@ -229,7 +229,8 @@ int8_t STORAGE_Read (uint8_t lun,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return (disk_read(0, buf, blk_addr, blk_len) == RES_OK) ? 0 : -1;
|
// read without cache
|
||||||
|
return (__disk_read(0, buf, blk_addr, blk_len) == RES_OK) ? 0 : -1;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief Write data to the medium
|
* @brief Write data to the medium
|
||||||
|
@ -250,8 +251,9 @@ int8_t STORAGE_Write (uint8_t lun,
|
||||||
return (fat12Write(buf, blk_addr, blk_len) == 0) ? 0 : -1;
|
return (fat12Write(buf, blk_addr, blk_len) == 0) ? 0 : -1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return (disk_write(0, buf, blk_addr, blk_len) == RES_OK) ? 0 : -1;
|
// write without cache
|
||||||
|
return (__disk_write(0, buf, blk_addr, blk_len) == RES_OK) ? 0 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -100,24 +100,33 @@ void delay_ms(uint32_t ms);
|
||||||
void getCPUUniqueID(char * s);
|
void getCPUUniqueID(char * s);
|
||||||
|
|
||||||
// SD driver
|
// SD driver
|
||||||
|
#define BLOCK_SIZE 512 /* Block Size in Bytes */
|
||||||
#if !defined(SIMU) || defined(SIMU_DISKIO)
|
#if !defined(SIMU) || defined(SIMU_DISKIO)
|
||||||
uint32_t sdIsHC(void);
|
uint32_t sdIsHC(void);
|
||||||
uint32_t sdGetSpeed(void);
|
uint32_t sdGetSpeed(void);
|
||||||
#define SD_IS_HC() (sdIsHC())
|
#define SD_IS_HC() (sdIsHC())
|
||||||
#define SD_GET_SPEED() (sdGetSpeed())
|
#define SD_GET_SPEED() (sdGetSpeed())
|
||||||
#define SD_GET_FREE_BLOCKNR() (sdGetFreeSectors())
|
#define SD_GET_FREE_BLOCKNR() (sdGetFreeSectors())
|
||||||
#define SD_CARD_PRESENT() (~SD_PRESENT_GPIO->IDR & SD_PRESENT_GPIO_PIN)
|
#define SD_CARD_PRESENT() (~SD_PRESENT_GPIO->IDR & SD_PRESENT_GPIO_PIN)
|
||||||
void sdInit(void);
|
void sdInit(void);
|
||||||
void sdDone(void);
|
void sdDone(void);
|
||||||
#define sdPoll10ms()
|
#define sdPoll10ms()
|
||||||
#define sdMountPoll()
|
#define sdMountPoll()
|
||||||
uint32_t sdMounted(void);
|
uint32_t sdMounted(void);
|
||||||
#else
|
#else
|
||||||
#define SD_IS_HC() (0)
|
#define SD_IS_HC() (0)
|
||||||
#define SD_GET_SPEED() (0)
|
#define SD_GET_SPEED() (0)
|
||||||
#define sdInit()
|
#define sdInit()
|
||||||
#define sdDone()
|
#define sdDone()
|
||||||
#define SD_CARD_PRESENT() true
|
#define SD_CARD_PRESENT() true
|
||||||
|
#endif
|
||||||
|
#if defined(DISK_CACHE)
|
||||||
|
#include "diskio.h"
|
||||||
|
DRESULT __disk_read(BYTE drv, BYTE * buff, DWORD sector, UINT count);
|
||||||
|
DRESULT __disk_write(BYTE drv, const BYTE * buff, DWORD sector, UINT count);
|
||||||
|
#else
|
||||||
|
#define __disk_read disk_read
|
||||||
|
#define __disk_write disk_write
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Flash Write driver
|
// Flash Write driver
|
||||||
|
|
|
@ -110,15 +110,10 @@ uint32_t sdReadRetries = 0;
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
/* Read Sector(s) */
|
/* Read Sector(s) */
|
||||||
|
|
||||||
#if !defined(DISK_CACHE)
|
DRESULT __disk_read(
|
||||||
#define __disk_read disk_read
|
|
||||||
#define __disk_write disk_write
|
|
||||||
#endif
|
|
||||||
|
|
||||||
DRESULT __disk_read (
|
|
||||||
BYTE drv, /* Physical drive nmuber (0..) */
|
BYTE drv, /* Physical drive nmuber (0..) */
|
||||||
BYTE *buff, /* Data buffer to store read data */
|
BYTE * buff, /* Data buffer to store read data */
|
||||||
DWORD sector, /* Sector address (LBA) */
|
DWORD sector, /* Sector address (LBA) */
|
||||||
UINT count /* Number of sectors to read (1..255) */
|
UINT count /* Number of sectors to read (1..255) */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
@ -194,10 +189,10 @@ DRESULT __disk_read (
|
||||||
/* Write Sector(s) */
|
/* Write Sector(s) */
|
||||||
|
|
||||||
#if _READONLY == 0
|
#if _READONLY == 0
|
||||||
DRESULT __disk_write (
|
DRESULT __disk_write(
|
||||||
BYTE drv, /* Physical drive nmuber (0..) */
|
BYTE drv, /* Physical drive nmuber (0..) */
|
||||||
const BYTE *buff, /* Data to be written */
|
const BYTE *buff, /* Data to be written */
|
||||||
DWORD sector, /* Sector address (LBA) */
|
DWORD sector, /* Sector address (LBA) */
|
||||||
UINT count /* Number of sectors to write (1..255) */
|
UINT count /* Number of sectors to write (1..255) */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
@ -250,9 +245,6 @@ DRESULT __disk_write (
|
||||||
}
|
}
|
||||||
#endif /* _READONLY */
|
#endif /* _READONLY */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
/* Miscellaneous Functions */
|
/* Miscellaneous Functions */
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,6 @@
|
||||||
|
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
|
|
||||||
#define BLOCK_SIZE 512 /* Block Size in Bytes */
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1105,11 +1105,6 @@ DSTATUS disk_status (BYTE pdrv)
|
||||||
return (DSTATUS)0;
|
return (DSTATUS)0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(DISK_CACHE)
|
|
||||||
#define __disk_read disk_read
|
|
||||||
#define __disk_write disk_write
|
|
||||||
#endif
|
|
||||||
|
|
||||||
DRESULT __disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count)
|
DRESULT __disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count)
|
||||||
{
|
{
|
||||||
if (diskImage == 0) return RES_NOTRDY;
|
if (diskImage == 0) return RES_NOTRDY;
|
||||||
|
|
|
@ -159,26 +159,27 @@ void getCPUUniqueID(char * s);
|
||||||
// SD driver
|
// SD driver
|
||||||
#define BLOCK_SIZE 512 /* Block Size in Bytes */
|
#define BLOCK_SIZE 512 /* Block Size in Bytes */
|
||||||
#if !defined(SIMU) || defined(SIMU_DISKIO)
|
#if !defined(SIMU) || defined(SIMU_DISKIO)
|
||||||
uint32_t sdIsHC(void);
|
uint32_t sdIsHC(void);
|
||||||
uint32_t sdGetSpeed(void);
|
uint32_t sdGetSpeed(void);
|
||||||
#define SD_IS_HC() (sdIsHC())
|
#define SD_IS_HC() (sdIsHC())
|
||||||
#define SD_GET_SPEED() (sdGetSpeed())
|
#define SD_GET_SPEED() (sdGetSpeed())
|
||||||
#define SD_GET_FREE_BLOCKNR() (sdGetFreeSectors())
|
#define SD_GET_FREE_BLOCKNR() (sdGetFreeSectors())
|
||||||
#else
|
#else
|
||||||
#define SD_IS_HC() (0)
|
#define SD_IS_HC() (0)
|
||||||
#define SD_GET_SPEED() (0)
|
#define SD_GET_SPEED() (0)
|
||||||
#endif
|
#endif
|
||||||
|
#define __disk_read disk_read
|
||||||
|
#define __disk_write disk_write
|
||||||
#if defined(SIMU)
|
#if defined(SIMU)
|
||||||
#define sdInit()
|
#define sdInit()
|
||||||
#define sdDone()
|
#define sdDone()
|
||||||
#else
|
#else
|
||||||
void sdInit(void);
|
void sdInit(void);
|
||||||
void sdDone(void);
|
void sdDone(void);
|
||||||
void sdPoll10ms(void);
|
void sdPoll10ms(void);
|
||||||
#define sdMountPoll()
|
#define sdMountPoll()
|
||||||
uint32_t sdMounted(void);
|
uint32_t sdMounted(void);
|
||||||
#define SD_CARD_PRESENT() (~SD_GPIO_PRESENT->IDR & SD_GPIO_PIN_PRESENT)
|
#define SD_CARD_PRESENT() (~SD_GPIO_PRESENT->IDR & SD_GPIO_PIN_PRESENT)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Flash Write driver
|
// Flash Write driver
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue