o add snes fatfs dummy
o add fatfs custom chip to bsnes o finishes fatfs linux backend smaple
This commit is contained in:
@@ -5,63 +5,22 @@
|
||||
static volatile
|
||||
DSTATUS Stat = STA_NOINIT; /* Disk status */
|
||||
|
||||
/*
|
||||
|
||||
sudo losetup /dev/loop0 disk00.vfat
|
||||
sudo mkfs.vfat -f 2 -F 16 -v /dev/loop0
|
||||
mkfs.vfat 2.11 (12 Mar 2005)
|
||||
Loop device does not match a floppy size, using default hd params
|
||||
/dev/loop0 has 64 heads and 32 sectors per track,
|
||||
logical sector size is 512,
|
||||
using 0xf8 media descriptor, with 524288 sectors;
|
||||
file system has 2 16-bit FATs and 8 sectors per cluster.
|
||||
FAT size is 256 sectors, and provides 65467 clusters.
|
||||
Root directory contains 512 slots.
|
||||
Volume ID is 4a1aab3d, no volume label.
|
||||
|
||||
|
||||
FAT type = 2
|
||||
Bytes/Cluster = 4096
|
||||
Number of FATs = 2
|
||||
Root DIR entries = 512
|
||||
Sectors/FAT = 256
|
||||
Number of clusters = 65467
|
||||
FAT start (lba) = 1
|
||||
DIR start (lba,clustor) = 513
|
||||
Data start (lba) = 545
|
||||
Ok
|
||||
disk_read: sector=513 count=1 addr=0xa8009800 size=512
|
||||
scan_files ret
|
||||
0 files, 0 bytes.
|
||||
0 folders.
|
||||
261868 KB total disk space.
|
||||
147456 KB available.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
/* Interface
|
||||
|
||||
** Scratch Buffer
|
||||
|
||||
addr 3 byte
|
||||
size 1 byte
|
||||
|
||||
** Call Interface
|
||||
|
||||
cmd 1 byte
|
||||
sector 4 bytes
|
||||
count 1 byte
|
||||
return 1 byte
|
||||
|
||||
** Commands
|
||||
|
||||
* disk_init
|
||||
* disk_read
|
||||
* disk_write
|
||||
|
||||
|
||||
*/
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
@@ -77,7 +36,6 @@ return 1 byte
|
||||
#include <sys/mman.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#define IMAGE_NAME "disk00.vfat"
|
||||
|
||||
char *image_addr;
|
||||
@@ -86,8 +44,6 @@ DSTATUS disk_initialize (BYTE drv) {
|
||||
if (drv) return STA_NOINIT; /* Supports only single drive */
|
||||
|
||||
Stat |= STA_NOINIT;
|
||||
/* map image */
|
||||
|
||||
|
||||
int fd = open(IMAGE_NAME, O_RDWR);
|
||||
if (fd == -1) {
|
||||
@@ -95,11 +51,9 @@ DSTATUS disk_initialize (BYTE drv) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
int size = lseek(fd,0,SEEK_END);
|
||||
lseek(fd,0,SEEK_SET);
|
||||
printf("Open Image (size %i)\n",size);
|
||||
|
||||
|
||||
image_addr = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||
if (image_addr == MAP_FAILED) {
|
||||
@@ -140,11 +94,8 @@ DRESULT disk_read (
|
||||
|
||||
DWORD offset = sector * 512;
|
||||
int size = count * 512;
|
||||
|
||||
printf("disk_read: sector=%li count=%i addr=%p off=%li size=%i\n",sector,count,image_addr + offset,offset,size);
|
||||
memcpy(buff,image_addr + offset,size);
|
||||
//printf("%x %x %x %x\n",buff[0],buff[1],buff[2],buff[3]);
|
||||
|
||||
return RES_OK;
|
||||
}
|
||||
|
||||
@@ -160,16 +111,12 @@ DRESULT disk_write (
|
||||
BYTE count /* Sector count (1..255) */
|
||||
)
|
||||
{
|
||||
BYTE s, c, iowr_l, iowr_h;
|
||||
|
||||
|
||||
|
||||
if (drv || !count) return RES_PARERR;
|
||||
if (Stat & STA_NOINIT) return RES_NOTRDY;
|
||||
|
||||
DWORD offset = sector * 512;
|
||||
int size = count * 512;
|
||||
|
||||
printf("disk_write: sector=%li count=%i addr=%p off=%li size=%i\n",sector,count,image_addr + offset,offset,size);
|
||||
memcpy(image_addr + offset,buff,size);
|
||||
return RES_OK;
|
||||
@@ -209,38 +156,9 @@ DRESULT disk_ioctl (
|
||||
*(DWORD*)buff = 32;
|
||||
return RES_OK;
|
||||
|
||||
case CTRL_SYNC : /* Nothing to do */
|
||||
printf("disk_ioctl: CTRL_SIZE\n");
|
||||
return RES_OK;
|
||||
|
||||
case ATA_GET_REV : /* Get firmware revision (8 chars) */
|
||||
printf("disk_ioctl: ATAL_GET_REV\n");
|
||||
ofs = 23; w = 4; n = 4;
|
||||
break;
|
||||
|
||||
case ATA_GET_MODEL : /* Get model name (40 chars) */
|
||||
printf("disk_ioctl: ATAL_GET_MODEL\n");
|
||||
ofs = 27; w = 20; n = 20;
|
||||
break;
|
||||
|
||||
case ATA_GET_SN : /* Get serial number (20 chars) */
|
||||
printf("disk_ioctl: ATAL_GET_SN\n");
|
||||
ofs = 10; w = 10; n = 10;
|
||||
break;
|
||||
|
||||
default:
|
||||
return RES_PARERR;
|
||||
}
|
||||
|
||||
/*
|
||||
write_ata(REG_COMMAND, CMD_IDENTIFY);
|
||||
if (!wait_data()) return RES_ERROR;
|
||||
read_part(ptr, ofs, w);
|
||||
while (n--) {
|
||||
dl = *ptr; dh = *(ptr+1);
|
||||
*ptr++ = dh; *ptr++ = dl;
|
||||
}
|
||||
*/
|
||||
return RES_OK;
|
||||
}
|
||||
#endif /* _USE_IOCTL != 0 */
|
||||
|
||||
@@ -2,6 +2,11 @@
|
||||
/ Low level disk interface modlue include file R0.05 (C)ChaN, 2007
|
||||
/-----------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef _DISKIO
|
||||
|
||||
#define _READONLY 0 /* 1: Read-only mode */
|
||||
@@ -56,26 +61,11 @@ void disk_timerproc (void);
|
||||
#define CTRL_POWER 4
|
||||
#define CTRL_LOCK 5
|
||||
#define CTRL_EJECT 6
|
||||
/* MMC/SDC command */
|
||||
#define MMC_GET_TYPE 10
|
||||
#define MMC_GET_CSD 11
|
||||
#define MMC_GET_CID 12
|
||||
#define MMC_GET_OCR 13
|
||||
#define MMC_GET_SDSTAT 14
|
||||
/* ATA/CF command */
|
||||
#define ATA_GET_REV 20
|
||||
#define ATA_GET_MODEL 21
|
||||
#define ATA_GET_SN 22
|
||||
|
||||
|
||||
|
||||
/* Card type flags (CardType) */
|
||||
#define CT_MMC 0x01
|
||||
#define CT_SD1 0x02
|
||||
#define CT_SD2 0x04
|
||||
#define CT_SDC (CT_SD1|CT_SD2)
|
||||
#define CT_BLOCK 0x08
|
||||
|
||||
|
||||
#define _DISKIO
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -81,13 +81,13 @@
|
||||
/* 512 for memroy card and hard disk, 1024 for floppy disk, 2048 for MO disk */
|
||||
|
||||
|
||||
#define _MULTI_PARTITION 1
|
||||
#define _MULTI_PARTITION 0
|
||||
/* When _MULTI_PARTITION is set to 0, each volume is bound to the same physical
|
||||
/ drive number and can mount only first primaly partition. When it is set to 1,
|
||||
/ each volume is tied to the partitions listed in Drives[]. */
|
||||
|
||||
|
||||
#define _CODE_PAGE 850
|
||||
#define _CODE_PAGE 437
|
||||
/* The _CODE_PAGE specifies the OEM code page to be used on the target system.
|
||||
/ When it is non LFN configuration, there is no difference between SBCS code
|
||||
/ pages. When LFN is enabled, the code page must always be set correctly.
|
||||
|
||||
Binary file not shown.
@@ -241,22 +241,6 @@ int main (void)
|
||||
{ printf("Sector size: %u\n", w1); }
|
||||
if (disk_ioctl((BYTE)p1, GET_BLOCK_SIZE, &p2) == RES_OK)
|
||||
{ printf("Erase block size: %lu sectors\n", p2); }
|
||||
if (disk_ioctl((BYTE)p1, MMC_GET_TYPE, &b1) == RES_OK)
|
||||
{ printf("Card type: %u\n", b1); }
|
||||
if (disk_ioctl((BYTE)p1, MMC_GET_CSD, Buff) == RES_OK)
|
||||
{ printf("CSD:\n"); put_dump(Buff, 0, 16); }
|
||||
if (disk_ioctl((BYTE)p1, MMC_GET_CID, Buff) == RES_OK)
|
||||
{ printf("CID:\n"); put_dump(Buff, 0, 16); }
|
||||
if (disk_ioctl((BYTE)p1, MMC_GET_OCR, Buff) == RES_OK)
|
||||
{ printf("OCR:\n"); put_dump(Buff, 0, 4); }
|
||||
if (disk_ioctl((BYTE)p1, MMC_GET_SDSTAT, Buff) == RES_OK) {
|
||||
printf("SD Status:\n");
|
||||
for (s1 = 0; s1 < 64; s1 += 16) put_dump(Buff+s1, s1, 16);
|
||||
}
|
||||
if (disk_ioctl((BYTE)p1, ATA_GET_MODEL, line) == RES_OK)
|
||||
{ line[40] = '\0'; printf("Model: %s\n", line); }
|
||||
if (disk_ioctl((BYTE)p1, ATA_GET_SN, line) == RES_OK)
|
||||
{ line[20] = '\0'; printf("S/N: %s\n", line); }
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user