Skip to content

Commit

Permalink
debug: factorize all static asserts about fat sector size
Browse files Browse the repository at this point in the history
  • Loading branch information
rasky committed Feb 12, 2023
1 parent 2187f4e commit 827b7ec
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 21 deletions.
4 changes: 4 additions & 0 deletions src/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ DSTATUS disk_status(BYTE pdrv)

DRESULT disk_read(BYTE pdrv, BYTE* buff, LBA_t sector, UINT count)
{
_Static_assert(FF_MIN_SS == 512, "this function assumes sector size == 512");
_Static_assert(FF_MAX_SS == 512, "this function assumes sector size == 512");
if (fat_disks[pdrv].disk_read && PhysicalAddr(buff) < 0x00800000)
return fat_disks[pdrv].disk_read(buff, sector, count);
if (fat_disks[pdrv].disk_read_sdram && io_accessible(PhysicalAddr(buff)))
Expand All @@ -173,6 +175,8 @@ DRESULT disk_read(BYTE pdrv, BYTE* buff, LBA_t sector, UINT count)

DRESULT disk_write(BYTE pdrv, const BYTE* buff, LBA_t sector, UINT count)
{
_Static_assert(FF_MIN_SS == 512, "this function assumes sector size == 512");
_Static_assert(FF_MAX_SS == 512, "this function assumes sector size == 512");
if (fat_disks[pdrv].disk_write)
return fat_disks[pdrv].disk_write(buff, sector, count);
return RES_PARERR;
Expand Down
9 changes: 0 additions & 9 deletions src/debug_sdfs_64drive.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ static void sd_abort_64drive(void)

static DRESULT fat_disk_read_sdram_64drive(BYTE* buff, LBA_t sector, UINT count)
{
_Static_assert(FF_MIN_SS == 512, "this function assumes sector size == 512");
_Static_assert(FF_MAX_SS == 512, "this function assumes sector size == 512");

usb_64drive_wait();
io_write(D64_CIBASE_ADDRESS + D64_REGISTER_LBA, sector);
usb_64drive_wait();
Expand All @@ -61,9 +58,6 @@ static DRESULT fat_disk_read_sdram_64drive(BYTE* buff, LBA_t sector, UINT count)

static DRESULT fat_disk_read_64drive(BYTE* buff, LBA_t sector, UINT count)
{
_Static_assert(FF_MIN_SS == 512, "this function assumes sector size == 512");
_Static_assert(FF_MAX_SS == 512, "this function assumes sector size == 512");

usb_64drive_wait();
io_write(D64_CIBASE_ADDRESS + D64_REGISTER_LENGTH, 1);
for (int i=0;i<count;i++)
Expand All @@ -88,9 +82,6 @@ static DRESULT fat_disk_read_64drive(BYTE* buff, LBA_t sector, UINT count)

static DRESULT fat_disk_write_64drive(const BYTE* buff, LBA_t sector, UINT count)
{
_Static_assert(FF_MIN_SS == 512, "this function assumes sector size == 512");
_Static_assert(FF_MAX_SS == 512, "this function assumes sector size == 512");

usb_64drive_wait();
io_write(D64_CIBASE_ADDRESS + D64_REGISTER_LENGTH, 1);
for (int i=0;i<count;i++)
Expand Down
6 changes: 0 additions & 6 deletions src/debug_sdfs_ed64.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,9 +441,6 @@ static DSTATUS fat_disk_initialize_everdrive(void) {

static DRESULT fat_disk_read_everdrive(BYTE* buff, LBA_t sector, UINT count)
{
_Static_assert(FF_MIN_SS == 512, "this function assumes sector size == 512");
_Static_assert(FF_MAX_SS == 512, "this function assumes sector size == 512");

uint8_t crc[8];
DRESULT ret_val = RES_OK;

Expand Down Expand Up @@ -505,9 +502,6 @@ static DRESULT fat_disk_read_everdrive(BYTE* buff, LBA_t sector, UINT count)
}

static DRESULT fat_disk_write_everdrive(const BYTE* buff, LBA_t sector, UINT count) {
_Static_assert(FF_MIN_SS == 512, "this function assumes sector size == 512");
_Static_assert(FF_MAX_SS == 512, "this function assumes sector size == 512");

uint8_t result;
DRESULT ret_val = RES_OK;

Expand Down
6 changes: 0 additions & 6 deletions src/debug_sdfs_sc64.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ static DSTATUS fat_disk_initialize_sc64(void)

static DRESULT fat_disk_read_sc64(BYTE* buff, LBA_t sector, UINT count)
{
_Static_assert(FF_MIN_SS == 512, "this function assumes sector size == 512");
_Static_assert(FF_MAX_SS == 512, "this function assumes sector size == 512");
while (count > 0)
{
UINT sectors_to_process = MIN(count, SC64_BUFFER_SIZE/512);
Expand All @@ -69,17 +67,13 @@ static DRESULT fat_disk_read_sc64(BYTE* buff, LBA_t sector, UINT count)

static DRESULT fat_disk_read_sdram_sc64(BYTE* buff, LBA_t sector, UINT count)
{
_Static_assert(FF_MIN_SS == 512, "this function assumes sector size == 512");
_Static_assert(FF_MAX_SS == 512, "this function assumes sector size == 512");
if (sc64_sd_read_sectors((uint32_t)buff, sector, count))
return FR_DISK_ERR;
return RES_OK;
}

static DRESULT fat_disk_write_sc64(const BYTE* buff, LBA_t sector, UINT count)
{
_Static_assert(FF_MIN_SS == 512, "this function assumes sector size == 512");
_Static_assert(FF_MAX_SS == 512, "this function assumes sector size == 512");
while (count > 0)
{
UINT sectors_to_process = MIN(count, SC64_BUFFER_SIZE/512);
Expand Down

0 comments on commit 827b7ec

Please sign in to comment.