diff options
author | Arisotura <thetotalworm@gmail.com> | 2021-10-28 18:47:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-28 18:47:13 +0200 |
commit | ff3f661bb54dcb31e2533967aa231d827d2be4b7 (patch) | |
tree | f6b9d4ea0fc42f234bb1dd4f1dc6b0db9069333e /src/fatfs/diskio.c | |
parent | a8613af2bd3ba0cc9d52b6a5d63899cda7ca2864 (diff) |
DLDI/SD folder-sync apparatus (#1251)
guess we can finally have DLDI that isn't obtuse
Diffstat (limited to 'src/fatfs/diskio.c')
-rw-r--r-- | src/fatfs/diskio.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/fatfs/diskio.c b/src/fatfs/diskio.c index 225d9bf..9ed4a76 100644 --- a/src/fatfs/diskio.c +++ b/src/fatfs/diskio.c @@ -13,15 +13,17 @@ static ff_disk_read_cb ReadCb; static ff_disk_write_cb WriteCb; +static LBA_t SectorCount; static DSTATUS Status = STA_NOINIT | STA_NODISK; -void ff_disk_open(ff_disk_read_cb readcb, ff_disk_write_cb writecb) +void ff_disk_open(ff_disk_read_cb readcb, ff_disk_write_cb writecb, LBA_t seccnt) { if (!readcb) return; ReadCb = readcb; WriteCb = writecb; + SectorCount = seccnt; Status &= ~STA_NODISK; if (!writecb) Status |= STA_PROTECT; @@ -32,6 +34,7 @@ void ff_disk_close() { ReadCb = (void*)0; WriteCb = (void*)0; + SectorCount = 0; Status &= ~STA_PROTECT; Status |= STA_NODISK; @@ -123,12 +126,28 @@ DRESULT disk_ioctl ( { switch (cmd) { - case 0: // sync + case CTRL_SYNC: // TODO: fflush? return RES_OK; + + case GET_SECTOR_COUNT: + *(LBA_t*)buff = SectorCount; + return RES_OK; + + case GET_SECTOR_SIZE: + *(WORD*)buff = 0x200; + return RES_OK; + + case GET_BLOCK_SIZE: + *(DWORD*)buff = 1; + return RES_OK; + + case CTRL_TRIM: + // TODO?? + return RES_OK; } - //printf("disk_ioctl(%02X, %02X, %p)\n", pdrv, cmd, buff); + //printf("FatFS: unknown disk_ioctl(%02X, %02X, %p)\n", pdrv, cmd, buff); return RES_PARERR; } |