Merge branch 'master' of git@github.com:optixx/snesram
Conflicts: tools/ffsample/linux/diskio.c
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
static volatile
|
||||
DSTATUS Stat = STA_NOINIT; /* Disk status */
|
||||
|
||||
<<<<<<< HEAD:tools/ffsample/linux/diskio.c
|
||||
/*
|
||||
|
||||
sudo losetup /dev/loop0 disk00.vfat
|
||||
@@ -50,28 +51,24 @@ Signature: 0xAA55
|
||||
3: 00 0 0 0 - 0 0 0 [ 0 - 0] unused
|
||||
4: 00 0 0 0 - 0 0 0 [ 0 - 0] unused
|
||||
*/
|
||||
=======
|
||||
>>>>>>> 660767c464c3d78d36436123eb2e717c3c85f6bc:tools/ffsample/linux/diskio.c
|
||||
|
||||
/* 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
|
||||
|
||||
|
||||
*/
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
@@ -85,18 +82,16 @@ return 1 byte
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define IMAGE_NAME "disk00.vfat"
|
||||
|
||||
int *image_addr;
|
||||
char *image_addr;
|
||||
|
||||
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) {
|
||||
@@ -104,19 +99,17 @@ 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,fd,)
|
||||
image_addr = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||
if (image_addr == MAP_FAILED) {
|
||||
close(fd);
|
||||
perror("Error mmapping the file");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
Stat &= ~STA_NOINIT; /* When device goes ready, clear STA_NOINIT */
|
||||
return Stat;
|
||||
}
|
||||
@@ -147,13 +140,10 @@ DRESULT disk_read (
|
||||
if (drv || !count) return RES_PARERR;
|
||||
if (Stat & STA_NOINIT) return RES_NOTRDY;
|
||||
|
||||
DWORD offset = sector * 512;
|
||||
DWORD offset = sector * 512;
|
||||
int size = count * 512;
|
||||
|
||||
printf("disk_read: sector=%li count=%i addr=%p size=%i\n",sector,count,image_addr + offset,size);
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -169,23 +159,14 @@ 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;
|
||||
|
||||
/* Issue Write Setor(s) command */
|
||||
/*
|
||||
write_ata(REG_COUNT, count);
|
||||
write_ata(REG_SECTOR, (BYTE)sector);
|
||||
write_ata(REG_CYLL, (BYTE)(sector >> 8));
|
||||
write_ata(REG_CYLH, (BYTE)(sector >> 16));
|
||||
write_ata(REG_DEV, ((BYTE)(sector >> 24) & 0x0F) | LBA);
|
||||
write_ata(REG_COMMAND, CMD_WRITE);
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
#endif /* _READONLY */
|
||||
@@ -223,38 +204,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 */
|
||||
|
||||
Reference in New Issue
Block a user