From c8afff5630d97d983a098266e7eecc07b210c748 Mon Sep 17 00:00:00 2001 From: David Voswinkel Date: Sat, 23 May 2009 21:06:15 +0200 Subject: [PATCH] start implment lowlevel io --- snes/irqtest/irqtest.asm | 2 ++ tools/ffsample/linux/diskio.c | 57 +++++++++++++++++++++++++++++++++- tools/ffsample/linux/fftest | Bin 35863 -> 35967 bytes tools/ffsample/linux/main.c | 16 +++++++++- 4 files changed, 73 insertions(+), 2 deletions(-) mode change 100644 => 100755 tools/ffsample/linux/fftest diff --git a/snes/irqtest/irqtest.asm b/snes/irqtest/irqtest.asm index 3b28a9a..235d3ec 100644 --- a/snes/irqtest/irqtest.asm +++ b/snes/irqtest/irqtest.asm @@ -69,6 +69,8 @@ Infinity: ;---------------------------------------------------------------------------- ; Out: None ;---------------------------------------------------------------------------- + + SetupVideo: php diff --git a/tools/ffsample/linux/diskio.c b/tools/ffsample/linux/diskio.c index 47a423f..8c2824b 100644 --- a/tools/ffsample/linux/diskio.c +++ b/tools/ffsample/linux/diskio.c @@ -14,18 +14,57 @@ using 0xf8 media descriptor, with 8192 sectors; file system has 2 32-bit FATs and 1 sector per cluster. FAT size is 63 sectors, and provides 8034 clusters. Volume ID is 4a1424ec, no volume label. + +filesize 4194304 + */ +/* 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 + + +*/ + /*-----------------------------------------------------------------------*/ /* Initialize Disk Drive */ /*-----------------------------------------------------------------------*/ +#define IMAGE_NAME "disk00.vfat" + +int 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,); + int size = fseek(END); + fseek(0); + + image_addr = mmap(0,fd,) + + Stat &= ~STA_NOINIT; /* When device goes ready, clear STA_NOINIT */ return Stat; } @@ -55,7 +94,15 @@ DRESULT disk_read ( BYTE c, iord_l, iord_h; if (drv || !count) return RES_PARERR; if (Stat & STA_NOINIT) return RES_NOTRDY; + + printf("disk_read: sector=%i count=%i\n",sector,count); + DWORD offset = sector * 512; + DWORD size = count * 512; + + printf("disk_read: addr=%p offset=%i size=%i\n",image_addr,offset,size); + memcpy(buff,image_addr + offset,size); + /* Issue Read Setor(s) command */ /* write_ata(REG_COUNT, count); @@ -82,7 +129,8 @@ DRESULT disk_write ( ) { BYTE s, c, iowr_l, iowr_h; - + + if (drv || !count) return RES_PARERR; if (Stat & STA_NOINIT) return RES_NOTRDY; @@ -120,29 +168,36 @@ DRESULT disk_ioctl ( switch (ctrl) { case GET_SECTOR_COUNT : /* Get number of sectors on the disk (DWORD) */ + printf("disk_ioctl: GET_SECTOR_COUNT\n"); ofs = 60; w = 2; n = 0; break; case GET_SECTOR_SIZE : /* Get sectors on the disk (WORD) */ + printf("disk_ioctl: GET_SECTOR_SIZE\n"); *(WORD*)buff = 512; return RES_OK; case GET_BLOCK_SIZE : /* Get erase block size in sectors (DWORD) */ + printf("disk_ioctl: GET_BLOCK_SIZE\n"); *(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; diff --git a/tools/ffsample/linux/fftest b/tools/ffsample/linux/fftest old mode 100644 new mode 100755 index c207c988d535bdcd04da5d2ee022c4b713b9f603..bd06933cbc785b426f22c9c2fe8d6e7519e6a3a0 GIT binary patch delta 906 zcmb7B&1(};5TAM3mn>3jYYQ6u+BC*$sk@}xBnB)}g!Z6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!*(|_y5B59&3C=)cCBM9ESSUR8}Io~UH8Dk diff --git a/tools/ffsample/linux/main.c b/tools/ffsample/linux/main.c index f3ebe88..61ceb52 100644 --- a/tools/ffsample/linux/main.c +++ b/tools/ffsample/linux/main.c @@ -137,7 +137,7 @@ FRESULT scan_files (char* path) static -void put_rc (FRESULT rc) +void _put_rc (FRESULT rc) { const char* str[] = { "OK", @@ -160,7 +160,21 @@ void put_rc (FRESULT rc) printf("rc=%u FR_%s\n", (WORD)rc, str[rc]); } +static +void put_rc (FRESULT rc) +{ + const char *p; + static const char str[] = + "OK\0" "NOT_READY\0" "NO_FILE\0" "FR_NO_PATH\0" "INVALID_NAME\0" "INVALID_DRIVE\0" + "DENIED\0" "EXIST\0" "RW_ERROR\0" "WRITE_PROTECTED\0" "NOT_ENABLED\0" + "NO_FILESYSTEM\0" "INVALID_OBJECT\0" "MKFS_ABORTED\0"; + FRESULT i; + for (p = str, i = 0; i != rc && *p; i++) { + while(*p++); + } + xprintf("rc=%u FR_%s\n", (WORD)rc, p); +} static