|
|
| version 1.19, 2005/03/23 08:07:48 | version 1.20, 2005/04/05 09:12:24 |
|---|---|
| Line 15 | Line 15 |
| // ---- | // ---- |
| static BRESULT nc_reopen(SXSIDEV sxsi) { | |
| (void)sxsi; | |
| return(FAILURE); | |
| } | |
| static REG8 nc_read(SXSIDEV sxsi, long pos, UINT8 *buf, UINT size) { | static REG8 nc_read(SXSIDEV sxsi, long pos, UINT8 *buf, UINT size) { |
| (void)sxsi; | (void)sxsi; |
| Line 40 static REG8 nc_format(SXSIDEV sxsi, long | Line 46 static REG8 nc_format(SXSIDEV sxsi, long |
| return(0x60); | return(0x60); |
| } | } |
| static void sxsi_disconnect(SXSIDEV sxsi) { | static void nc_close(SXSIDEV sxsi) { |
| (void)sxsi; | |
| } | |
| static void nc_destroy(SXSIDEV sxsi) { | |
| FILEH fh; | (void)sxsi; |
| } | |
| static void sxsi_disconnect(SXSIDEV sxsi) { | |
| if (sxsi) { | if (sxsi) { |
| #if defined(SUPPORT_IDEIO) | #if defined(SUPPORT_IDEIO) |
| ideio_notify(sxsi->drv, 0); | ideio_notify(sxsi->drv, 0); |
| #endif | #endif |
| fh = (FILEH)sxsi->fh; | if (sxsi->flag & SXSIFLAG_FILEOPENED) { |
| (*sxsi->close)(sxsi); | |
| } | |
| if (sxsi->flag & SXSIFLAG_READY) { | |
| (*sxsi->destroy)(sxsi); | |
| } | |
| sxsi->flag = 0; | sxsi->flag = 0; |
| sxsi->fh = (INTPTR)FILEH_INVALID; | sxsi->reopen = nc_reopen; |
| sxsi->read = nc_read; | sxsi->read = nc_read; |
| sxsi->write = nc_write; | sxsi->write = nc_write; |
| sxsi->format = nc_format; | sxsi->format = nc_format; |
| if (fh != FILEH_INVALID) { | sxsi->close = nc_close; |
| file_close(fh); | sxsi->destroy = nc_destroy; |
| } | |
| } | } |
| } | } |
| Line 77 void sxsi_initialize(void) { | Line 96 void sxsi_initialize(void) { |
| } | } |
| #endif | #endif |
| for (i=0; i<NELEMENTS(sxsi_dev); i++) { | for (i=0; i<NELEMENTS(sxsi_dev); i++) { |
| sxsi_dev[i].fh = (INTPTR)FILEH_INVALID; | |
| sxsi_disconnect(sxsi_dev + i); | sxsi_disconnect(sxsi_dev + i); |
| } | } |
| } | } |
| Line 86 void sxsi_allflash(void) { | Line 104 void sxsi_allflash(void) { |
| SXSIDEV sxsi; | SXSIDEV sxsi; |
| SXSIDEV sxsiterm; | SXSIDEV sxsiterm; |
| FILEH fh; | |
| sxsi = sxsi_dev; | sxsi = sxsi_dev; |
| sxsiterm = sxsi + NELEMENTS(sxsi_dev); | sxsiterm = sxsi + NELEMENTS(sxsi_dev); |
| while(sxsi < sxsiterm) { | while(sxsi < sxsiterm) { |
| fh = (FILEH)sxsi->fh; | if (sxsi->flag & SXSIFLAG_FILEOPENED) { |
| sxsi->fh = (INTPTR)FILEH_INVALID; | sxsi->flag &= ~SXSIFLAG_FILEOPENED; |
| if (fh != FILEH_INVALID) { | (*sxsi->close)(sxsi); |
| file_close(fh); | |
| } | } |
| sxsi++; | sxsi++; |
| } | } |
| Line 132 BOOL sxsi_isconnect(SXSIDEV sxsi) { | Line 148 BOOL sxsi_isconnect(SXSIDEV sxsi) { |
| BRESULT sxsi_prepare(SXSIDEV sxsi) { | BRESULT sxsi_prepare(SXSIDEV sxsi) { |
| FILEH fh; | |
| if ((sxsi == NULL) || (!(sxsi->flag & SXSIFLAG_READY))) { | if ((sxsi == NULL) || (!(sxsi->flag & SXSIFLAG_READY))) { |
| return(FAILURE); | return(FAILURE); |
| } | } |
| fh = (FILEH)sxsi->fh; | if (!(sxsi->flag & SXSIFLAG_FILEOPENED)) { |
| if (fh == FILEH_INVALID) { | if ((*sxsi->reopen)(sxsi) == SUCCESS) { |
| fh = file_open(sxsi->fname); | sxsi->flag |= SXSIFLAG_FILEOPENED; |
| sxsi->fh = (INTPTR)fh; | } |
| if (fh == FILEH_INVALID) { | else { |
| sxsi->flag = 0; | |
| return(FAILURE); | return(FAILURE); |
| } | } |
| } | } |
| Line 243 BRESULT sxsi_devopen(REG8 drv, const OEM | Line 256 BRESULT sxsi_devopen(REG8 drv, const OEM |
| goto sxsiope_err; | goto sxsiope_err; |
| } | } |
| file_cpyname(sxsi->fname, fname, NELEMENTS(sxsi->fname)); | file_cpyname(sxsi->fname, fname, NELEMENTS(sxsi->fname)); |
| sxsi->flag = SXSIFLAG_READY; | sxsi->flag = SXSIFLAG_READY | SXSIFLAG_FILEOPENED; |
| #if defined(SUPPORT_IDEIO) | #if defined(SUPPORT_IDEIO) |
| ideio_notify(sxsi->drv, 1); | ideio_notify(sxsi->drv, 1); |
| #endif | #endif |