rk27xx: Take advantage of STORAGE_NEEDS_BOUNCE_BUFFER

(And get rid of its custom realignment code)

Change-Id: Iff27d717b870d3db239310421776744ea6863373
This commit is contained in:
Solomon Peachy 2021-03-27 17:17:19 -04:00
parent 961ffa61dd
commit 83fcbedc65
2 changed files with 10 additions and 0 deletions

View file

@ -41,6 +41,7 @@
#include "sysfont.h" #include "sysfont.h"
#define RES_NO (-1) #define RES_NO (-1)
// #define ALIGN_BUF
/* debug stuff */ /* debug stuff */
unsigned long sd_debug_time_rd = 0; unsigned long sd_debug_time_rd = 0;
@ -51,7 +52,9 @@ static tCardInfo card_info;
/* for compatibility */ /* for compatibility */
static long last_disk_activity = -1; static long last_disk_activity = -1;
#ifdef ALIGN_BUF
static unsigned char aligned_buf[512] STORAGE_ALIGN_ATTR; static unsigned char aligned_buf[512] STORAGE_ALIGN_ATTR;
#endif
static struct mutex sd_mtx SHAREDBSS_ATTR; static struct mutex sd_mtx SHAREDBSS_ATTR;
#ifndef BOOTLOADER #ifndef BOOTLOADER
@ -397,8 +400,10 @@ static inline void read_sd_data(unsigned char **dst)
{ {
void *buf = *dst; void *buf = *dst;
#ifdef ALIGN_BUF
if (!IS_ALIGNED(((unsigned long)*dst), CACHEALIGN_SIZE)) if (!IS_ALIGNED(((unsigned long)*dst), CACHEALIGN_SIZE))
buf = aligned_buf; buf = aligned_buf;
#endif
commit_discard_dcache_range((const void *)buf, 512); commit_discard_dcache_range((const void *)buf, 512);
@ -413,8 +418,10 @@ static inline void read_sd_data(unsigned char **dst)
/* wait for DMA engine to finish transfer */ /* wait for DMA engine to finish transfer */
while (A2A_DMA_STS & 1); while (A2A_DMA_STS & 1);
#ifdef ALIGN_BUF
if (buf == aligned_buf) if (buf == aligned_buf)
memcpy(*dst, aligned_buf, 512); memcpy(*dst, aligned_buf, 512);
#endif
*dst += 512; *dst += 512;
} }
@ -423,11 +430,13 @@ static inline void write_sd_data(unsigned char **src)
{ {
void *buf = *src; void *buf = *src;
#ifdef ALIGN_BUF
if (!IS_ALIGNED(((unsigned long)*src), CACHEALIGN_SIZE)) if (!IS_ALIGNED(((unsigned long)*src), CACHEALIGN_SIZE))
{ {
buf = aligned_buf; buf = aligned_buf;
memcpy(aligned_buf, *src, 512); memcpy(aligned_buf, *src, 512);
} }
#endif
commit_discard_dcache_range((const void *)buf, 512); commit_discard_dcache_range((const void *)buf, 512);

View file

@ -53,5 +53,6 @@ void commit_discard_idcache(void);
#define CPUFREQ_MAX 200000000 #define CPUFREQ_MAX 200000000
#define STORAGE_WANTS_ALIGN #define STORAGE_WANTS_ALIGN
#define STORAGE_NEEDS_BOUNCE_BUFFER
#endif /* SYSTEM_TARGET_H */ #endif /* SYSTEM_TARGET_H */