mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-22 11:32:41 -05:00
Sansa AMS : use the aligned buffer in bss for all DMA transfers
This was only used for data transfers, now use it also for card data transfers in sd_select_bank, to save runtime alignement and stack usage. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21564 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
eaa9df37e0
commit
ed75cc09f1
1 changed files with 11 additions and 16 deletions
|
|
@ -122,6 +122,10 @@ static bool sd_enabled = false;
|
||||||
static struct wakeup transfer_completion_signal;
|
static struct wakeup transfer_completion_signal;
|
||||||
static volatile bool retry;
|
static volatile bool retry;
|
||||||
|
|
||||||
|
#define UNALIGNED_NUM_SECTORS 10
|
||||||
|
static unsigned char aligned_buffer[UNALIGNED_NUM_SECTORS* SECTOR_SIZE] __attribute__((aligned(32))); /* align on cache line size */
|
||||||
|
static unsigned char *uncached_buffer = UNCACHED_ADDR(&aligned_buffer[0]);
|
||||||
|
|
||||||
static inline void mci_delay(void) { int i = 0xffff; while(i--) ; }
|
static inline void mci_delay(void) { int i = 0xffff; while(i--) ; }
|
||||||
|
|
||||||
#ifdef HAVE_HOTSWAP
|
#ifdef HAVE_HOTSWAP
|
||||||
|
|
@ -571,11 +575,6 @@ static int sd_wait_for_state(const int drive, unsigned int state)
|
||||||
|
|
||||||
static int sd_select_bank(signed char bank)
|
static int sd_select_bank(signed char bank)
|
||||||
{
|
{
|
||||||
/* allocate card data buffer on the stack */
|
|
||||||
unsigned char card_data[512 + 31];
|
|
||||||
/* align it on cache line size */
|
|
||||||
unsigned char *aligned_card_data = (void*)(((int)&card_data[0] + 31) & ~31);
|
|
||||||
unsigned char *uncached_card_data = UNCACHED_ADDR(aligned_card_data);
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
|
@ -596,20 +595,20 @@ static int sd_select_bank(signed char bank)
|
||||||
|
|
||||||
mci_delay();
|
mci_delay();
|
||||||
|
|
||||||
memset(uncached_card_data, 0, 512);
|
memset(uncached_buffer, 0, 512);
|
||||||
if(bank == -1)
|
if(bank == -1)
|
||||||
{ /* enable bank switching */
|
{ /* enable bank switching */
|
||||||
uncached_card_data[0] = 16;
|
uncached_buffer[0] = 16;
|
||||||
uncached_card_data[1] = 1;
|
uncached_buffer[1] = 1;
|
||||||
uncached_card_data[2] = 10;
|
uncached_buffer[2] = 10;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
uncached_card_data[0] = bank;
|
uncached_buffer[0] = bank;
|
||||||
|
|
||||||
dma_retain();
|
dma_retain();
|
||||||
/* we don't use the uncached card data for DMA, because we need the
|
/* we don't use the uncached buffer here, because we need the
|
||||||
* physical memory address for DMA transfers */
|
* physical memory address for DMA transfers */
|
||||||
dma_enable_channel(0, aligned_card_data, MCI_FIFO(INTERNAL_AS3525),
|
dma_enable_channel(0, aligned_buffer, MCI_FIFO(INTERNAL_AS3525),
|
||||||
DMA_PERI_SD, DMAC_FLOWCTRL_PERI_MEM_TO_PERI, true, false, 0, DMA_S8,
|
DMA_PERI_SD, DMAC_FLOWCTRL_PERI_MEM_TO_PERI, true, false, 0, DMA_S8,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
|
@ -636,10 +635,6 @@ static int sd_select_bank(signed char bank)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define UNALIGNED_NUM_SECTORS 10
|
|
||||||
static unsigned char aligned_buffer[UNALIGNED_NUM_SECTORS* SECTOR_SIZE] __attribute__((aligned(32))); /* align on cache line size */
|
|
||||||
static unsigned char *uncached_buffer = UNCACHED_ADDR(&aligned_buffer[0]);
|
|
||||||
|
|
||||||
static int sd_transfer_sectors(IF_MV2(int drive,) unsigned long start,
|
static int sd_transfer_sectors(IF_MV2(int drive,) unsigned long start,
|
||||||
int count, void* buf, const bool write)
|
int count, void* buf, const bool write)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue