add fatfs through vfs for EVB plus
1. see board\TencentOS_tiny_EVB_MX_Plus\KEIL\fatfs_through_vfs
This commit is contained in:
@@ -29,7 +29,7 @@ static uint8_t sdio_aligned_buffer[512] __ALIGNED__(4);
|
||||
static ssize_t sd_read(vfs_inode_t *dev, void *buf, size_t start_sector, unsigned int nsectors)
|
||||
{
|
||||
TOS_CPU_CPSR_ALLOC();
|
||||
int ret = 0;
|
||||
int rc = 0;
|
||||
uint32_t i;
|
||||
uint8_t *buff = (uint8_t *)buf;
|
||||
uint64_t sector_addr = start_sector << 9;
|
||||
@@ -37,44 +37,42 @@ static ssize_t sd_read(vfs_inode_t *dev, void *buf, size_t start_sector, unsigne
|
||||
TOS_CPU_INT_DISABLE();
|
||||
if ((cpu_addr_t)buff % 4 != 0) {
|
||||
for (i = 0; i < nsectors; ++i) {
|
||||
ret = tos_hal_sd_read(&sd, sdio_aligned_buffer, sector_addr + 512 * i, 1, 2000);
|
||||
rc = tos_hal_sd_read(&sd, sdio_aligned_buffer, sector_addr + 512 * i, 1, 2000);
|
||||
memcpy(buff, sdio_aligned_buffer, 512);
|
||||
buff += 512;
|
||||
}
|
||||
} else {
|
||||
ret = tos_hal_sd_read(&sd, buff, sector_addr, nsectors, 2000);
|
||||
rc = tos_hal_sd_read(&sd, buff, sector_addr, nsectors, 2000);
|
||||
}
|
||||
TOS_CPU_INT_ENABLE();
|
||||
return ret;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static ssize_t sd_write(vfs_inode_t *dev, const unsigned char *buf, size_t start_sector, unsigned int nsectors)
|
||||
{
|
||||
TOS_CPU_CPSR_ALLOC();
|
||||
int ret = 0;
|
||||
int rc = 0;
|
||||
uint32_t i;
|
||||
uint8_t *buff = (uint8_t *)buf;
|
||||
uint64_t sector_addr = start_sector << 9;
|
||||
|
||||
TOS_CPU_INT_DISABLE();
|
||||
if ((cpu_addr_t)buff % 4 !=0) {
|
||||
if ((cpu_addr_t)buff % 4 != 0) {
|
||||
for (i = 0; i < nsectors; ++i) {
|
||||
memcpy(sdio_aligned_buffer, buff, 512);
|
||||
ret = tos_hal_sd_write(&sd, sdio_aligned_buffer, sector_addr + 512 * i, 1, 2000);
|
||||
rc = tos_hal_sd_write(&sd, sdio_aligned_buffer, sector_addr + 512 * i, 1, 2000);
|
||||
buff += 512;
|
||||
}
|
||||
} else {
|
||||
ret = tos_hal_sd_write(&sd, buff, sector_addr, nsectors, 2000);
|
||||
rc = tos_hal_sd_write(&sd, buff, sector_addr, nsectors, 2000);
|
||||
}
|
||||
TOS_CPU_INT_ENABLE();
|
||||
return ret;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int sd_ioctl(vfs_inode_t *dev, int cmd, unsigned long arg)
|
||||
{
|
||||
int ret = 0;
|
||||
int rc = 0;
|
||||
void *buff = (void *)arg;
|
||||
|
||||
if (cmd != CTRL_SYNC && !buff) {
|
||||
@@ -98,11 +96,11 @@ static int sd_ioctl(vfs_inode_t *dev, int cmd, unsigned long arg)
|
||||
break;
|
||||
|
||||
default:
|
||||
ret = -1;
|
||||
rc = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int sd_geometry(vfs_inode_t *dev, vfs_blkdev_geo_t *geo)
|
||||
|
Reference in New Issue
Block a user