|
#include "diskio.h"
|
|
|
|
#include "stdio.h"
|
|
|
|
FILE * disk_image;
|
|
|
|
/*-----------------------------------------------------------------------*/
|
|
/* Initialize Disk Drive */
|
|
/*-----------------------------------------------------------------------*/
|
|
|
|
DSTATUS disk_initialize (void)
|
|
{
|
|
DSTATUS stat;
|
|
|
|
disk_image = fopen("sd.image","rb");
|
|
|
|
stat = RES_OK;
|
|
|
|
return stat;
|
|
}
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------*/
|
|
/* Read Partial Sector */
|
|
/*-----------------------------------------------------------------------*/
|
|
|
|
DRESULT disk_readp (
|
|
BYTE* dest, /* Pointer to the destination object */
|
|
DWORD sector, /* Sector number (LBA) */
|
|
WORD sofs, /* Offset in the sector */
|
|
WORD count /* Byte count (bit15:destination) */
|
|
)
|
|
{
|
|
DRESULT res;
|
|
|
|
fseek(disk_image,sector*512+sofs,SEEK_SET);
|
|
fread(dest,count,1,disk_image);
|
|
|
|
res = RES_OK;
|
|
|
|
return res;
|
|
}
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------*/
|
|
/* Write Partial Sector */
|
|
/*-----------------------------------------------------------------------*/
|
|
|
|
DRESULT disk_writep (const BYTE* buff, DWORD sc)
|
|
{
|
|
DRESULT res;
|
|
|
|
|
|
if (!buff) {
|
|
if (sc) {
|
|
|
|
// Initiate write process
|
|
|
|
} else {
|
|
|
|
// Finalize write process
|
|
|
|
}
|
|
} else {
|
|
|
|
// Send data to the disk
|
|
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|