mirror of
https://github.com/CTCaer/hekate.git
synced 2024-12-01 22:12:06 +00:00
sdmmc: Ensure aligned DMA buffers
This commit is contained in:
parent
c24d943122
commit
168de9ddd8
2 changed files with 10 additions and 6 deletions
|
@ -46,7 +46,8 @@ DRESULT disk_read (
|
||||||
UINT count /* Number of sectors to read */
|
UINT count /* Number of sectors to read */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if ((u32)buff >= DRAM_START)
|
// Ensure that buffer resides in DRAM and it's DMA aligned.
|
||||||
|
if (((u32)buff >= DRAM_START) && !((u32)buff % 8))
|
||||||
return sdmmc_storage_read(&sd_storage, sector, count, buff) ? RES_OK : RES_ERROR;
|
return sdmmc_storage_read(&sd_storage, sector, count, buff) ? RES_OK : RES_ERROR;
|
||||||
u8 *buf = (u8 *)SDMMC_UPPER_BUFFER;
|
u8 *buf = (u8 *)SDMMC_UPPER_BUFFER;
|
||||||
if (sdmmc_storage_read(&sd_storage, sector, count, buf))
|
if (sdmmc_storage_read(&sd_storage, sector, count, buf))
|
||||||
|
@ -67,9 +68,10 @@ DRESULT disk_write (
|
||||||
UINT count /* Number of sectors to write */
|
UINT count /* Number of sectors to write */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if ((u32)buff >= DRAM_START)
|
// Ensure that buffer resides in DRAM and it's DMA aligned.
|
||||||
|
if (((u32)buff >= DRAM_START) && !((u32)buff % 8))
|
||||||
return sdmmc_storage_write(&sd_storage, sector, count, (void *)buff) ? RES_OK : RES_ERROR;
|
return sdmmc_storage_write(&sd_storage, sector, count, (void *)buff) ? RES_OK : RES_ERROR;
|
||||||
u8 *buf = (u8 *)SDMMC_UPPER_BUFFER; //TODO: define this somewhere.
|
u8 *buf = (u8 *)SDMMC_UPPER_BUFFER;
|
||||||
memcpy(buf, buff, 512 * count);
|
memcpy(buf, buff, 512 * count);
|
||||||
if (sdmmc_storage_write(&sd_storage, sector, count, buf))
|
if (sdmmc_storage_write(&sd_storage, sector, count, buf))
|
||||||
return RES_OK;
|
return RES_OK;
|
||||||
|
|
|
@ -46,7 +46,8 @@ DRESULT disk_read (
|
||||||
UINT count /* Number of sectors to read */
|
UINT count /* Number of sectors to read */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if ((u32)buff >= DRAM_START)
|
// Ensure that buffer resides in DRAM and it's DMA aligned.
|
||||||
|
if (((u32)buff >= DRAM_START) && !((u32)buff % 8))
|
||||||
return sdmmc_storage_read(&sd_storage, sector, count, buff) ? RES_OK : RES_ERROR;
|
return sdmmc_storage_read(&sd_storage, sector, count, buff) ? RES_OK : RES_ERROR;
|
||||||
u8 *buf = (u8 *)SDMMC_UPPER_BUFFER;
|
u8 *buf = (u8 *)SDMMC_UPPER_BUFFER;
|
||||||
if (sdmmc_storage_read(&sd_storage, sector, count, buf))
|
if (sdmmc_storage_read(&sd_storage, sector, count, buf))
|
||||||
|
@ -67,9 +68,10 @@ DRESULT disk_write (
|
||||||
UINT count /* Number of sectors to write */
|
UINT count /* Number of sectors to write */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if ((u32)buff >= DRAM_START)
|
// Ensure that buffer resides in DRAM and it's DMA aligned.
|
||||||
|
if (((u32)buff >= DRAM_START) && !((u32)buff % 8))
|
||||||
return sdmmc_storage_write(&sd_storage, sector, count, (void *)buff) ? RES_OK : RES_ERROR;
|
return sdmmc_storage_write(&sd_storage, sector, count, (void *)buff) ? RES_OK : RES_ERROR;
|
||||||
u8 *buf = (u8 *)SDMMC_UPPER_BUFFER; //TODO: define this somewhere.
|
u8 *buf = (u8 *)SDMMC_UPPER_BUFFER;
|
||||||
memcpy(buf, buff, 512 * count);
|
memcpy(buf, buff, 512 * count);
|
||||||
if (sdmmc_storage_write(&sd_storage, sector, count, buf))
|
if (sdmmc_storage_write(&sd_storage, sector, count, buf))
|
||||||
return RES_OK;
|
return RES_OK;
|
||||||
|
|
Loading…
Reference in a new issue