static uae_u32 REGPARAM2 gayle_wget (uaecptr addr) { struct ide_hdf *ide = NULL; int ide_reg; uae_u32 v; #ifdef NCR if (is_a4000t_scsi() && (addr & (0xffff - 1)) == 0x3000) return 0xffff; // NCR DIP BANK if (isdataflyerscsiplus(addr, &v, 2)) { return v; } if (isa4000t(&addr)) { if (addr >= NCR_OFFSET) { addr &= NCR_MASK; v = (ncr710_io_bget_a4000t(addr) << 8) | ncr710_io_bget_a4000t(addr + 1); } return v; } #endif ide_reg = get_gayle_ide_reg (addr, &ide); if (ide_reg == IDE_DATA) { v = ide_get_data (ide); if (GAYLE_LOG > 4) write_log(_T("IDE_DATA_WORD %08X=%04X PC=%X\n"), addr, v & 0xffff, M68K_GETPC); return v; } v = gayle_bget (addr) << 8; v |= gayle_bget (addr + 1); return v; }
/* * read from the IDE device */ static LONG ide_read(UBYTE cmd,UWORD ifnum,UWORD dev,ULONG sector,UWORD count,UBYTE *buffer,BOOL need_byteswap) { volatile struct IDE *interface = ide_interface + ifnum; struct IFINFO *info = ifinfo + ifnum; UWORD spi; UBYTE status1, status2; LONG rc = 0L; KDEBUG(("ide_read(0x%02x, %u, %u, %lu, %u, 0x%08lx, %d)\n", cmd, ifnum, dev, sector, count, (ULONG)buffer, need_byteswap)); if (ide_select_device(interface,dev) < 0) return EREADF; /* * if READ SECTOR and MULTIPLE MODE, set cmd & spi accordingly */ spi = 1; if ((cmd == IDE_CMD_READ_SECTOR) && (info->dev[dev].options & MULTIPLE_MODE_ACTIVE)) { cmd = IDE_CMD_READ_MULTIPLE; spi = info->dev[dev].spi; KDEBUG(("spi=%u\n", spi)); } ide_rw_start(interface,dev,sector,count,cmd); /* * each iteration of this loop handles one DRQ block */ while (count > 0) { UWORD numsecs; ULONG xferlen; if (wait_for_not_BSY(interface,XFER_TIMEOUT)) return EREADF; status1 = IDE_READ_ALT_STATUS();/* alternate status, ignore */ status1 = IDE_READ_STATUS(); /* status, clear pending interrupt */ numsecs = (count>spi) ? spi : count; xferlen = (ULONG)numsecs * SECTOR_SIZE; rc = E_OK; if (status1 & IDE_STATUS_DRQ) ide_get_data(interface,buffer,xferlen,need_byteswap); else rc = EREADF; if (status1 & (IDE_STATUS_DF | IDE_STATUS_ERR)) rc = EREADF; if (rc) break; buffer += xferlen; count -= numsecs; } status2 = IDE_READ_ALT_STATUS(); /* alternate status, ignore */ status2 = IDE_READ_STATUS(); /* status, clear pending interrupt */ if (status2 & (IDE_STATUS_BSY|IDE_STATUS_DF|IDE_STATUS_DRQ|IDE_STATUS_ERR)) rc = EREADF; return rc; }