diff --git a/src/cdrom/cdrom.c b/src/cdrom/cdrom.c index 407f3e7..7f3572b 100644 --- a/src/cdrom/cdrom.c +++ b/src/cdrom/cdrom.c @@ -9,7 +9,7 @@ * Implementation of the CD-ROM drive with SCSI(-like) * commands, for both ATAPI and SCSI usage. * - * Version: @(#)cdrom.c 1.0.8 2018/03/20 + * Version: @(#)cdrom.c 1.0.9 2018/03/20 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -197,7 +197,7 @@ const uint8_t cdrom_command_flags[0x100] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, IMPLEMENTED | CHECK_READY, - IMPLEMENTED | CHECK_READY | ALLOW_UA, /* Read TOC - can get through UNIT_ATTENTION, per VIDE-CDD.SYS + IMPLEMENTED | CHECK_READY, /* Read TOC - can get through UNIT_ATTENTION, per VIDE-CDD.SYS NOTE: The ATAPI reference says otherwise, but I think this is a question of interpreting things right - the UNIT ATTENTION condition we have here is a tradition from not ready to ready, by definition the drive @@ -531,11 +531,19 @@ void cdrom_destroy_drives(void) void cdrom_init(int id, int cdb_len_setting) { cdrom_t *dev; + uint8_t *trcbuf; + uint32_t tcap; if (id >= CDROM_NUM) return; dev = cdrom[id]; + tcap = dev->cdrom_capacity; + trcbuf = (uint8_t *) malloc(16); + memcpy(trcbuf, dev->rcbuf, 16); memset(dev, 0x00, sizeof(cdrom_t)); + memcpy(dev->rcbuf, trcbuf, 16); + free(trcbuf); + dev->cdrom_capacity = tcap; dev->requested_blocks = 1; if (cdb_len_setting <= 1) dev->cdb_len_setting = cdb_len_setting; @@ -551,7 +559,6 @@ void cdrom_init(int id, int cdb_len_setting) cdrom_log("CD-ROM %i: Bus type %i, bus mode %i\n", id, cdrom_drives[id].bus_type, cdrom_drives[id].bus_mode); if (cdrom_drives[id].bus_type < CDROM_BUS_SCSI) cdrom_set_signature(id); - cdrom_drives[id].max_blocks_at_once = 85; dev->status = READY_STAT | DSC_STAT; dev->pos = 0; dev->packet_status = 0xff; @@ -1256,29 +1263,29 @@ int cdrom_read_data(uint8_t id, int msf, int type, int flags, uint32_t *len) int last_valid_data_pos = 0; - if (cdrom_drives[id].handler->pass_through) { - cdsize = cdrom_drives[id].handler->size(id); + cdsize = cdrom_drives[id].handler->size(id); + if (dev->sector_pos >= cdsize) { + cdrom_log("CD-ROM %i: Trying to read from beyond the end of disc (%i >= %i)\n", id, dev->sector_pos, cdsize); + cdrom_lba_out_of_range(id); + return 0; + } + + if ((dev->sector_pos + dev->sector_len - 1) >= cdsize) { + cdrom_log("CD-ROM %i: Trying to read to beyond the end of disc (%i >= %i)\n", id, (dev->sector_pos + dev->sector_len - 1), cdsize); + cdrom_lba_out_of_range(id); + return 0; + } + + if (cdrom_drives[id].handler->pass_through) { ret = cdrom_pass_through(id, len, dev->current_cdb, cdbufferb + dev->data_pos); dev->data_pos += *len; if (!ret) return 0; - if (dev->sector_pos > (cdsize - 1)) { - /* cdrom_log("CD-ROM %i: Trying to read beyond the end of disc\n", id); */ - cdrom_lba_out_of_range(id); - return 0; - } - dev->old_len = *len; } else { - if (dev->sector_pos > (cdrom_drives[id].handler->size(id) - 1)) { - /* cdrom_log("CD-ROM %i: Trying to read beyond the end of disc\n", id); */ - cdrom_lba_out_of_range(id); - return 0; - } - dev->old_len = 0; *len = 0; diff --git a/src/cdrom/cdrom.h b/src/cdrom/cdrom.h index f866bf7..5d80039 100644 --- a/src/cdrom/cdrom.h +++ b/src/cdrom/cdrom.h @@ -8,7 +8,7 @@ * * Definitions for the CDROM module.. * - * Version: @(#)cdrom.h 1.0.7 2018/03/20 + * Version: @(#)cdrom.h 1.0.8 2018/03/20 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -197,8 +197,6 @@ typedef struct { } cdrom_t; typedef struct { - int max_blocks_at_once; - CDROM *handler; int host_drive; diff --git a/src/disk/hdc_ide.c b/src/disk/hdc_ide.c index cecbe2c..e3e6474 100644 --- a/src/disk/hdc_ide.c +++ b/src/disk/hdc_ide.c @@ -6,10 +6,9 @@ * * This file is part of the VARCem Project. * - * Implementation of the IDE emulation for hard disks and ATAPI - * CD-ROM devices. + * Emulation of hard disk, CD-ROM and ZIP IDE/ATAPI devices. * - * Version: @(#)hdc_ide.c 1.0.11 2018/03/18 + * Version: @(#)hdc_ide.c 1.0.12 2018/03/20 * * Authors: Miran Grca, * Sarah Walker, @@ -523,11 +522,12 @@ static void ide_atapi_zip_identify(IDE *ide) uint8_t zip_id; int32_t d; + memset(ide->buffer, 0, 512); zip_id = atapi_zip_drives[ide->channel]; /* Using (2<<5) below makes the ASUS P/I-P54TP4XE misdentify the ZIP drive as a LS-120. */ - ide->buffer[0] = 0x8000 | (0<<8) | 0x80 | (1<<5); /* ATAPI device, direct-access device, removable media, accelerated DRQ */ + ide->buffer[0] = 0x8000 | (0<<8) | 0x80 | (1<<5); /* ATAPI device, direct-access device, removable media, interrupt DRQ */ ide_padstr((char *) (ide->buffer + 10), "", 20); /* Serial Number */ if (zip_drives[zip_id].is_250) { ide_padstr((char *) (ide->buffer + 23), "42.S", 8); /* Firmware */ @@ -536,6 +536,8 @@ static void ide_atapi_zip_identify(IDE *ide) ide_padstr((char *) (ide->buffer + 23), "E.08", 8); /* Firmware */ ide_padstr((char *) (ide->buffer + 27), "IOMEGA ZIP 100 ATAPI", 40); /* Model */ } + + ide->buffer[48] = 1; /*Dword transfers supported*/ ide->buffer[49] = 0x200; /* LBA supported */ /* Note by Kotori: Look at this if this is supported by ZIP at all. */ @@ -563,6 +565,7 @@ static void ide_atapi_zip_identify(IDE *ide) ide->buffer[52] = 120; ide->buffer[53] = 2; /*Words 64-70 are valid*/ ide->buffer[63] = 0x0003; /*Multi-word DMA 0 & 1*/ + ide->buffer[88] = 7; ide->buffer[64] = 0x0001; /*PIO Mode 3*/ ide->buffer[65] = 120; ide->buffer[66] = 120; @@ -575,11 +578,12 @@ static void ide_atapi_zip_identify(IDE *ide) d <<= 8; if ((ide->mdma_mode & 0x300) == 0x200) ide->buffer[88] |= d; + else if ((ide->mdma_mode & 0x300) == 0x100) + ide->buffer[63] |= d; else if ((ide->mdma_mode & 0x300) == 0x400) { if ((ide->mdma_mode & 0xff) >= 3) ide->buffer[64] |= d; - } else - ide->buffer[63] |= d; + } ide_log("PIDENTIFY DMA Mode: %04X, %04X\n", ide->buffer[62], ide->buffer[63]); } } @@ -705,7 +709,7 @@ static int ide_set_features(IDE *ide) if (!PCI || !dma || (ide->board >= 2)) max_pio = 0; else - max_pio = 2; + max_pio = 4; } ide_log("Features code %02X\n", features); @@ -883,6 +887,7 @@ void ide_reset(void) ide_log("Found IDE hard disk on channel %i\n", hdd[d].ide_channel); loadhd(&ide_drives[hdd[d].ide_channel], d, hdd[d].fn); ide_drives[hdd[d].ide_channel].sector_buffer = (uint8_t *) malloc(256*512); + memset(ide_drives[hdd[d].ide_channel].sector_buffer, 0, 256*512); if (++c >= (IDE_NUM+XTIDE_NUM)) break; } if ((hdd[d].bus==HDD_BUS_XTIDE) && (hdd[d].xtide_channel < XTIDE_NUM)) @@ -890,6 +895,7 @@ void ide_reset(void) ide_log("Found XT IDE hard disk on channel %i\n", hdd[d].xtide_channel); loadhd(&ide_drives[hdd[d].xtide_channel | 8], d, hdd[d].fn); ide_drives[hdd[d].xtide_channel | 8].sector_buffer = (uint8_t *) malloc(256*512); + memset(ide_drives[hdd[d].ide_channel].sector_buffer, 0, 256*512); if (++c >= (IDE_NUM+XTIDE_NUM)) break; } } @@ -902,8 +908,10 @@ void ide_reset(void) else if (ide_drive_is_cdrom(&ide_drives[d]) && (ide_drives[d].type == IDE_NONE)) ide_drives[d].type = IDE_CDROM; - if (ide_drives[d].type != IDE_NONE) + if (ide_drives[d].type != IDE_NONE) { ide_drives[d].buffer = (uint16_t *) malloc(65536 * sizeof(uint16_t)); + memset(ide_drives[d].buffer, 0, 65536 * sizeof(uint16_t)); + } ide_set_signature(&ide_drives[d]); @@ -929,6 +937,23 @@ void ide_reset(void) } +void ide_set_all_signatures(void) +{ + int d; + + for (d = 0; d < IDE_NUM; d++) + { + ide_set_signature(&ide_drives[d]); + + if (ide_drives[d].sector_buffer) + memset(ide_drives[d].sector_buffer, 0, 256*512); + + if (ide_drives[d].buffer) + memset(ide_drives[d].buffer, 0, 65536 * sizeof(uint16_t)); + } +} + + void ide_reset_hard(void) { int d; @@ -1536,14 +1561,15 @@ void writeide(int ide_board, uint16_t addr, uint8_t val) zip[atapi_zip_drives[ide->channel]].packet_status = ZIP_PHASE_IDLE; zip[atapi_zip_drives[ide->channel]].pos=0; zip[atapi_zip_drives[ide->channel]].phase = 1; - zip[atapi_zip_drives[ide->channel]].status = READY_STAT | DRQ_STAT | (zip[atapi_zip_drives[ide->channel]].status & ERR_STAT); + zip[atapi_zip_drives[ide->channel]].status = READY_STAT | DRQ_STAT; + ide_irq_raise(ide); /* Interrupt IRQ, requires IRQ on any DRQ. */ } else if (ide_drive_is_cdrom(ide)) { cdrom[atapi_cdrom_drives[ide->channel]]->packet_status = CDROM_PHASE_IDLE; cdrom[atapi_cdrom_drives[ide->channel]]->pos=0; cdrom[atapi_cdrom_drives[ide->channel]]->phase = 1; - cdrom[atapi_cdrom_drives[ide->channel]]->status = READY_STAT | DRQ_STAT | (cdrom[atapi_cdrom_drives[ide->channel]]->status & ERR_STAT); + cdrom[atapi_cdrom_drives[ide->channel]]->status = READY_STAT | DRQ_STAT; } else { diff --git a/src/disk/hdc_ide.h b/src/disk/hdc_ide.h index 2141f4f..8f73c0b 100644 --- a/src/disk/hdc_ide.h +++ b/src/disk/hdc_ide.h @@ -8,7 +8,7 @@ * * Definitions for the IDE module. * - * Version: @(#)hdc_ide.h 1.0.2 2018/03/15 + * Version: @(#)hdc_ide.h 1.0.3 2018/03/20 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -106,6 +106,8 @@ extern void ide_init_first(void); extern void ide_reset(void); extern void ide_reset_hard(void); +extern void ide_set_all_signatures(void); + extern void ide_xtide_init(void); extern void ide_pri_enable(void); diff --git a/src/disk/zip.c b/src/disk/zip.c index 46c1ff2..5f04492 100644 --- a/src/disk/zip.c +++ b/src/disk/zip.c @@ -9,7 +9,7 @@ * Implementation of the Iomega ZIP drive with SCSI(-like) * commands, for both ATAPI and SCSI usage. * - * Version: @(#)zip.c 1.0.6 2018/03/18 + * Version: @(#)zip.c 1.0.7 2018/03/20 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -589,7 +589,7 @@ void zip_close(uint8_t id) } } -void build_atapi_zip_map() +void build_atapi_zip_map(void) { uint8_t i = 0; @@ -613,7 +613,7 @@ int find_zip_for_scsi_id(uint8_t scsi_id, uint8_t scsi_lun) return 0xff; } -void build_scsi_zip_map() +void build_scsi_zip_map(void) { uint8_t i = 0; uint8_t j = 0; @@ -673,7 +673,6 @@ void zip_init(int id, int cdb_len_setting) zip_log("ZIP %i: Bus type %i, bus mode %i\n", id, zip_drives[id].bus_type, zip_drives[id].bus_mode); if (zip_drives[id].bus_type < ZIP_BUS_SCSI) zip_set_signature(id); - zip_drives[id].max_blocks_at_once = 85; zip[id].status = READY_STAT | DSC_STAT; zip[id].pos = 0; zip[id].packet_status = 0xff; @@ -1174,9 +1173,18 @@ static void zip_data_phase_error(uint8_t id) #define zipbufferb zip[id].buffer -int zip_data(uint8_t id, uint32_t *len, int out) +int zip_blocks(uint8_t id, uint32_t *len, int first_batch, int out) { - int i = 0; + zip[id].data_pos = 0; + + *len = 0; + + if (!zip[id].sector_len) { + zip_command_complete(id); + return -1; + } + + *len = zip[id].requested_blocks << 9; if (zip[id].sector_pos >= zip_drives[id].medium_size) { zip_log("ZIP %i: Trying to %s beyond the end of disk\n", id, out ? "write" : "read"); @@ -1184,40 +1192,15 @@ int zip_data(uint8_t id, uint32_t *len, int out) return 0; } - *len = 0; + zip_log("%s %i bytes of blocks...\n", out ? "Written" : "Read", *len); + + fseek(zip_drives[id].f, zip_drives[id].base + (zip[id].sector_pos << 9), SEEK_SET); + if (out) + fwrite(zipbufferb, 1, *len, zip_drives[id].f); + else + fread(zipbufferb, 1, *len, zip_drives[id].f); - for (i = 0; i < zip[id].requested_blocks; i++) { - fseek(zip_drives[id].f, zip_drives[id].base + (zip[id].sector_pos << 9) + *len, SEEK_SET); - if (out) - fwrite(zipbufferb + *len, 1, 512, zip_drives[id].f); - else - fread(zipbufferb + *len, 1, 512, zip_drives[id].f); - - *len += 512; - } - - return 1; -} - -int zip_blocks(uint8_t id, uint32_t *len, int first_batch, int out) -{ - int ret = 0; - - zip[id].data_pos = 0; - - if (!zip[id].sector_len) { - zip_command_complete(id); - return -1; - } - - zip_log("%sing %i blocks starting from %i...\n", out ? "Writ" : "Read", zip[id].requested_blocks, zip[id].sector_pos); - - ret = zip_data(id, len, out); - - zip_log("%s %i bytes of blocks...\n", out ? "Written" : "Read", *len); - - if (!ret) - return 0; + zip_log("%s %i bytes of blocks...\n", out ? "Written" : "Read", *len); zip[id].sector_pos += zip[id].requested_blocks; zip[id].sector_len -= zip[id].requested_blocks; @@ -2414,6 +2397,7 @@ void zip_phase_callback(uint8_t id) zip_log("ZIP %i: ZIP_PHASE_ERROR\n", id); zip[id].status = READY_STAT | ERR_STAT; zip[id].phase = 3; + zip[id].packet_status = 0xFF; zip_irq_raise(id); ui_sb_update_icon(SB_ZIP | id, 0); return; diff --git a/src/disk/zip.h b/src/disk/zip.h index 623ee8d..3371a62 100644 --- a/src/disk/zip.h +++ b/src/disk/zip.h @@ -9,7 +9,7 @@ * Implementation of the Iomega ZIP drive with SCSI(-like) * commands, for both ATAPI and SCSI usage. * - * Version: @(#)zip.h 1.0.3 2018/03/18 + * Version: @(#)zip.h 1.0.4 2018/03/20 * * Author: Miran Grca, * @@ -140,8 +140,6 @@ typedef struct { } zip_t; typedef struct { - int max_blocks_at_once; - int host_drive; int prev_host_drive; diff --git a/src/machine/m_at_scat.c b/src/machine/m_at_scat.c index 6ffc6c3..43fe1b6 100644 --- a/src/machine/m_at_scat.c +++ b/src/machine/m_at_scat.c @@ -10,7 +10,7 @@ * * Re-worked version based on the 82C235 datasheet and errata. * - * Version: @(#)m_at_scat.c 1.0.3 2018/03/15 + * Version: @(#)m_at_scat.c 1.0.4 2018/03/20 * * Authors: Fred N. van Kempen, * Original by GreatPsycho for PCem. @@ -42,14 +42,15 @@ #include #include #include "../emu.h" -#include "../device.h" #include "../cpu/cpu.h" #include "../cpu/x86.h" -#include "../floppy/fdd.h" -#include "../floppy/fdc.h" +#include "../nmi.h" #include "../io.h" #include "../mem.h" -#include "../nmi.h" +#include "../device.h" +#include "../keyboard.h" +#include "../floppy/fdd.h" +#include "../floppy/fdc.h" #include "machine.h" @@ -745,7 +746,10 @@ machine_at_scat_init(const machine_t *model) void machine_at_scatsx_init(const machine_t *model) { - machine_at_init(model); + machine_at_common_init(model); + + device_add(&keyboard_at_ami_device); + device_add(&fdc_at_device); scatsx_init(); diff --git a/src/machine/m_ps2_mca.c b/src/machine/m_ps2_mca.c index e31b1ad..fc84b3f 100644 --- a/src/machine/m_ps2_mca.c +++ b/src/machine/m_ps2_mca.c @@ -8,7 +8,7 @@ * * Implementation of MCA-based PS/2 machines. * - * Version: @(#)m_ps2_mca.c 1.0.4 2018/03/19 + * Version: @(#)m_ps2_mca.c 1.0.5 2018/03/20 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -99,7 +99,7 @@ static struct /*The model 70 type 3/4 BIOS performs cache testing. Since we don't have any proper cache emulation, it's faked a bit here. - + Port E2 is used for cache diagnostics. Bit 7 seems to be set on a cache miss, toggling bit 2 seems to clear this. The BIOS performs at least the following tests : @@ -669,7 +669,7 @@ uint8_t ps2_mca_read(uint16_t port, void *p) else temp = 0xff; break; - + default: temp = 0xff; break; @@ -752,13 +752,13 @@ static void ps2_mca_board_common_init() io_sethandler(0x0094, 0x0001, ps2_mca_read, NULL, NULL, ps2_mca_write, NULL, NULL, NULL); io_sethandler(0x0096, 0x0001, ps2_mca_read, NULL, NULL, ps2_mca_write, NULL, NULL, NULL); io_sethandler(0x0100, 0x0008, ps2_mca_read, NULL, NULL, ps2_mca_write, NULL, NULL, NULL); - + port_92_reset(); port_92_add(); ps2.setup = 0xff; - + lpt1_init(0x3bc); } @@ -781,12 +781,12 @@ static void ps2_mem_expansion_write(int port, uint8_t val, void *p) } static void ps2_mca_board_model_50_init() -{ +{ ps2_mca_board_common_init(); mem_remap_top_384k(); mca_init(4); - + ps2.planar_read = model_50_read; ps2.planar_write = model_50_write; @@ -846,9 +846,9 @@ static void ps2_mca_board_model_50_init() } static void ps2_mca_board_model_55sx_init() -{ +{ ps2_mca_board_common_init(); - + mem_mapping_add(&ps2.shadow_mapping, (mem_size+256) * 1024, 128*1024, @@ -862,10 +862,9 @@ static void ps2_mca_board_model_55sx_init() MEM_MAPPING_INTERNAL, NULL); - mem_remap_top_256k(); ps2.option[3] = 0x10; - + memset(ps2.memory_bank, 0xf0, 8); switch (mem_size/1024) { @@ -899,10 +898,10 @@ static void ps2_mca_board_model_55sx_init() ps2.memory_bank[0] = 0x01; ps2.memory_bank[1] = 0x01; break; - } - + } + mca_init(4); - + ps2.planar_read = model_55sx_read; ps2.planar_write = model_55sx_write; @@ -912,9 +911,9 @@ static void ps2_mca_board_model_55sx_init() static void mem_encoding_update() { mem_mapping_disable(&ps2.split_mapping); - + ps2.split_addr = ((uint32_t) (ps2.mem_regs[0] & 0xf)) << 20; - + if (ps2.mem_regs[1] & 2) { mem_set_mem_state(0xe0000, 0x20000, MEM_READ_EXTERNAL | MEM_WRITE_INTERNAL); /* pclog("PS/2 Model 80-111: ROM space enabled\n"); */ @@ -992,14 +991,14 @@ static uint8_t mem_encoding_read_cached(uint16_t addr, void *p) static void mem_encoding_write_cached(uint16_t addr, uint8_t val, void *p) { uint8_t old; - + switch (addr) { - case 0xe0: - ps2.mem_regs[0] = val; - break; - case 0xe1: - ps2.mem_regs[1] = val; + case 0xe0: + ps2.mem_regs[0] = val; + break; + case 0xe1: + ps2.mem_regs[1] = val; break; case 0xe2: old = ps2.mem_regs[2]; @@ -1041,20 +1040,20 @@ static void mem_encoding_write_cached(uint16_t addr, uint8_t val, void *p) } static void ps2_mca_board_model_70_type34_init(int is_type4) -{ +{ ps2_mca_board_common_init(); mem_remap_top_256k(); ps2.split_addr = mem_size * 1024; mca_init(4); - + ps2.planar_read = model_70_type3_read; ps2.planar_write = model_70_type3_write; - + device_add(&ps2_nvr_device); - + io_sethandler(0x00e0, 0x0003, mem_encoding_read_cached, NULL, NULL, mem_encoding_write_cached, NULL, NULL, NULL); - + ps2.mem_regs[1] = 2; switch (mem_size/1024) @@ -1077,17 +1076,31 @@ static void ps2_mca_board_model_70_type34_init(int is_type4) ps2.option[2] = 0x02; break; } - + if (is_type4) ps2.option[2] |= 0x04; /*486 CPU*/ + mem_mapping_add(&ps2.split_mapping, + (mem_size+256) * 1024, + 256*1024, + ps2_read_split_ram, + ps2_read_split_ramw, + ps2_read_split_raml, + ps2_write_split_ram, + ps2_write_split_ramw, + ps2_write_split_raml, + &ram[0xa0000], + MEM_MAPPING_INTERNAL, + NULL); + mem_mapping_disable(&ps2.split_mapping); + mem_mapping_add(&ps2.cache_mapping, - 0, + 0, is_type4 ? (8 * 1024) : (64 * 1024), ps2_read_cache_ram, ps2_read_cache_ramw, ps2_read_cache_raml, - ps2_write_cache_ram, + ps2_write_cache_ram, NULL, NULL, ps2_cache, @@ -1134,24 +1147,24 @@ static void ps2_mca_board_model_70_type34_init(int is_type4) NULL); mem_mapping_disable(&ps2.expansion_mapping); } - - device_add(&ps1vga_device); + + device_add(&ps1vga_device); } static void ps2_mca_board_model_80_type2_init(int is486) -{ +{ ps2_mca_board_common_init(); ps2.split_addr = mem_size * 1024; mca_init(8); - + ps2.planar_read = model_80_read; ps2.planar_write = model_80_write; - + device_add(&ps2_nvr_device); - + io_sethandler(0x00e0, 0x0002, mem_encoding_read, NULL, NULL, mem_encoding_write, NULL, NULL, NULL); - + ps2.mem_regs[1] = 2; /* Note by Kotori: I rewrote this because the original code was using diff --git a/src/pci.c b/src/pci.c index a24bfbb..0bc0377 100644 --- a/src/pci.c +++ b/src/pci.c @@ -8,7 +8,7 @@ * * Implement the PCI bus. * - * Version: @(#)pci.c 1.0.1 2018/02/14 + * Version: @(#)pci.c 1.0.2 2018/03/20 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -54,6 +54,7 @@ #include "cdrom/cdrom.h" #include "disk/hdc.h" #include "disk/hdc_ide.h" +#include "disk/zip.h" static uint64_t pci_irq_hold[16]; @@ -692,14 +693,26 @@ static void trc_reset(uint8_t val) pci_reset_handler.super_io_reset(); } +#if 0 ide_reset(); +#else + ide_set_all_signatures(); +#endif + for (i = 0; i < CDROM_NUM; i++) { - if (!cdrom_drives[i].bus_type) + if ((cdrom_drives[i].bus_type == CDROM_BUS_ATAPI_PIO_ONLY) || (cdrom_drives[i].bus_type == CDROM_BUS_ATAPI_PIO_AND_DMA)) { cdrom_reset(i); } } + for (i = 0; i < ZIP_NUM; i++) + { + if ((zip_drives[i].bus_type == ZIP_BUS_ATAPI_PIO_ONLY) || (zip_drives[i].bus_type == ZIP_BUS_ATAPI_PIO_AND_DMA)) + { + zip_reset(i); + } + } port_92_reset(); keyboard_at_reset(); diff --git a/src/video/vid_ati28800.c b/src/video/vid_ati28800.c index 591479c..f58e64f 100644 --- a/src/video/vid_ati28800.c +++ b/src/video/vid_ati28800.c @@ -8,7 +8,7 @@ * * ATI 28800 emulation (VGA Charger and Korean VGA) * - * Version: @(#)vid_ati28800.c 1.0.8 2018/03/18 + * Version: @(#)vid_ati28800.c 1.0.9 2018/03/20 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -573,17 +573,6 @@ ati28800_force_redraw(void *priv) ati->svga.fullchange = changeframecount; } -void ati28800k_add_status_info(char *s, int max_len, void *p) -{ - ati28800_t *ati28800 = (ati28800_t *)p; - char temps[128]; - - svga_add_status_info(s, max_len, &ati28800->svga); - - sprintf(temps, "Korean SVGA mode enabled : %s\n\n", ati28800->ksc5601_mode_enabled ? "Yes" : "No"); - strncat(s, temps, max_len); -} - static void ati28800_add_status_info(char *s, int max_len, void *priv) { ati28800_t *ati = (ati28800_t *)priv; @@ -591,6 +580,17 @@ static void ati28800_add_status_info(char *s, int max_len, void *priv) svga_add_status_info(s, max_len, &ati->svga); } +void ati28800k_add_status_info(char *s, int max_len, void *p) +{ + char temps[128]; + ati28800_t *ati28800 = (ati28800_t *)p; + + sprintf(temps, "Korean SVGA mode enabled : %s\n\n", ati28800->ksc5601_mode_enabled ? "Yes" : "No"); + strncat(s, temps, max_len); + + ati28800_add_status_info(s, max_len, p); +} + static const device_config_t ati28800_config[] = { diff --git a/src/video/vid_cl54xx.c b/src/video/vid_cl54xx.c index 99e95c0..86d0776 100644 --- a/src/video/vid_cl54xx.c +++ b/src/video/vid_cl54xx.c @@ -9,7 +9,7 @@ * Emulation of select Cirrus Logic cards (CL-GD 5428, * CL-GD 5429, 5430, 5434 and 5436 are supported). * - * Version: @(#)vid_cl54xx.c 1.0.9 2018/03/17 + * Version: @(#)vid_cl54xx.c 1.0.10 2018/03/20 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -59,7 +59,6 @@ #include "vid_cl54xx.h" -#define BIOS_GD5424_PATH L"roms/video/cirruslogic/cl5424.bin" #define BIOS_GD5426_PATH L"roms/video/cirruslogic/diamond speedstar pro vlb v3.04.bin" #define BIOS_GD5428_PATH L"roms/video/cirruslogic/vlbusjapan.bin" #define BIOS_GD5429_PATH L"roms/video/cirruslogic/5429.vbi" @@ -67,14 +66,18 @@ #define BIOS_GD5430_PCI_PATH L"roms/video/cirruslogic/pci.bin" #define BIOS_GD5434_PATH L"roms/video/cirruslogic/gd5434.bin" #define BIOS_GD5436_PATH L"roms/video/cirruslogic/5436.vbi" +#define BIOS_GD5446_PATH L"roms/video/cirruslogic/5446bv.vbi" +#define BIOS_GD5446_STB_PATH L"roms/video/cirruslogic/stb nitro64v.bin" +#define BIOS_GD5480_PATH L"roms/video/cirruslogic/clgd5480.rom" -#define CIRRUS_ID_CLGD5424 0x94 #define CIRRUS_ID_CLGD5426 0x90 #define CIRRUS_ID_CLGD5428 0x98 #define CIRRUS_ID_CLGD5429 0x9c #define CIRRUS_ID_CLGD5430 0xa0 #define CIRRUS_ID_CLGD5434 0xa8 #define CIRRUS_ID_CLGD5436 0xac +#define CIRRUS_ID_CLGD5446 0xb8 +#define CIRRUS_ID_CLGD5480 0xbc /* sequencer 0x07 */ #define CIRRUS_SR7_BPP_VGA 0x00 @@ -609,13 +612,13 @@ gd543x_recalc_mapping(gd54xx_t *gd54xx) } } else if (gd54xx->pci) { base = gd54xx->lfb_base; - if (svga->crtc[0x27] == CIRRUS_ID_CLGD5436) + if (svga->crtc[0x27] >= CIRRUS_ID_CLGD5436) size = 16 * 1024 * 1024; else size = 4 * 1024 * 1024; } else { /*VLB*/ base = 128*1024*1024; - if (svga->crtc[0x27] == CIRRUS_ID_CLGD5436) + if (svga->crtc[0x27] >= CIRRUS_ID_CLGD5436) size = 16 * 1024 * 1024; else size = 4 * 1024 * 1024; @@ -1713,7 +1716,7 @@ gd543x_mmio_write(uint32_t addr, uint8_t val, void *p) else gd54xx->blt.dst_addr &= 0x1fffff; - if ((svga->crtc[0x27] == CIRRUS_ID_CLGD5436) && (gd54xx->blt.status & CIRRUS_BLT_AUTOSTART)) { + if ((svga->crtc[0x27] >= CIRRUS_ID_CLGD5436) && (gd54xx->blt.status & CIRRUS_BLT_AUTOSTART)) { if (gd54xx->blt.mode == CIRRUS_BLTMODE_MEMSYSSRC) { gd54xx->blt.sys_tx = 1; gd54xx->blt.sys_cnt = 0; @@ -1752,7 +1755,7 @@ gd543x_mmio_write(uint32_t addr, uint8_t val, void *p) break; case 0x1b: - if (svga->crtc[0x27] == CIRRUS_ID_CLGD5436) + if (svga->crtc[0x27] >= CIRRUS_ID_CLGD5436) gd54xx->blt.modeext = val; break; @@ -2321,7 +2324,7 @@ gd54xx_init(const device_t *info) { gd54xx_t *gd54xx = malloc(sizeof(gd54xx_t)); svga_t *svga = &gd54xx->svga; - int id = info->local; + int id = info->local & 0xff; wchar_t *romfn = NULL; memset(gd54xx, 0, sizeof(gd54xx_t)); @@ -2355,6 +2358,17 @@ gd54xx_init(const device_t *info) case CIRRUS_ID_CLGD5436: romfn = BIOS_GD5436_PATH; break; + + case CIRRUS_ID_CLGD5446: + if (info->local & 0x100) + romfn = BIOS_GD5446_STB_PATH; + else + romfn = BIOS_GD5446_PATH; + break; + + case CIRRUS_ID_CLGD5480: + romfn = BIOS_GD5480_PATH; + break; } gd54xx->vram_size = device_get_config_int("memory"); @@ -2440,6 +2454,24 @@ gd5436_available(void) return rom_present(BIOS_GD5436_PATH); } +static int +gd5446_available(void) +{ + return rom_present(BIOS_GD5446_PATH); +} + +static int +gd5446_stb_available(void) +{ + return rom_present(BIOS_GD5446_STB_PATH); +} + +static int +gd5480_available(void) +{ + return rom_present(BIOS_GD5480_PATH); +} + void gd54xx_close(void *p) { @@ -2697,3 +2729,48 @@ const device_t gd5436_pci_device = gd54xx_add_status_info, gd5434_config }; + +const device_t gd5446_pci_device = +{ + "Cirrus Logic CL-GD 5446 (PCI)", + DEVICE_PCI, + CIRRUS_ID_CLGD5446, + gd54xx_init, + gd54xx_close, + NULL, + gd5446_available, + gd54xx_speed_changed, + gd54xx_force_redraw, + gd54xx_add_status_info, + gd5434_config +}; + +const device_t gd5446_stb_pci_device = +{ + "STB Nitro 64V (PCI)", + DEVICE_PCI, + CIRRUS_ID_CLGD5446, + gd54xx_init, + gd54xx_close, + NULL, + gd5446_stb_available, + gd54xx_speed_changed, + gd54xx_force_redraw, + gd54xx_add_status_info, + gd5434_config +}; + +const device_t gd5480_pci_device = +{ + "Cirrus Logic CL-GD 5480 (PCI)", + DEVICE_PCI, + CIRRUS_ID_CLGD5480, + gd54xx_init, + gd54xx_close, + NULL, + gd5480_available, + gd54xx_speed_changed, + gd54xx_force_redraw, + gd54xx_add_status_info, + gd5434_config +}; diff --git a/src/video/vid_cl54xx.h b/src/video/vid_cl54xx.h index 8528fad..22743d8 100644 --- a/src/video/vid_cl54xx.h +++ b/src/video/vid_cl54xx.h @@ -8,7 +8,7 @@ * * Definitions for the CLGD5428 driver. * - * Version: @(#)vid_cl54xx.h 1.0.5 2018/03/17 + * Version: @(#)vid_cl54xx.h 1.0.6 2018/03/20 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -51,6 +51,9 @@ extern const device_t gd5434_isa_device; extern const device_t gd5434_vlb_device; extern const device_t gd5434_pci_device; extern const device_t gd5436_pci_device; +extern const device_t gd5446_pci_device; +extern const device_t gd5446_stb_pci_device; +extern const device_t gd5480_pci_device; #endif /*VIDEO_CL54XX_H*/ diff --git a/src/video/vid_table.c b/src/video/vid_table.c index c83c1cd..df27bac 100644 --- a/src/video/vid_table.c +++ b/src/video/vid_table.c @@ -8,7 +8,7 @@ * * Define all known video cards. * - * Version: @(#)vid_table.c 1.0.10 2018/03/17 + * Version: @(#)vid_table.c 1.0.11 2018/03/20 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -145,7 +145,9 @@ video_cards[] = { {"[PCI] Cirrus Logic GD5430", "cl_gd5430_pci", &gd5430_pci_device, VID_CL_GD5430_PCI, VIDEO_FLAG_TYPE_SPECIAL, {VIDEO_BUS, 4, 4, 8, 10, 10, 20}}, {"[PCI] Cirrus Logic GD5434", "cl_gd5434_pci", &gd5434_pci_device, VID_CL_GD5434_PCI, VIDEO_FLAG_TYPE_SPECIAL, {VIDEO_BUS, 4, 4, 8, 10, 10, 20}}, {"[PCI] Cirrus Logic GD5436", "cl_gd5436_pci", &gd5436_pci_device, VID_CL_GD5436_PCI, VIDEO_FLAG_TYPE_SPECIAL, {VIDEO_BUS, 4, 4, 8, 10, 10, 20}}, - #if defined(DEV_BRANCH) && defined(USE_STEALTH32) + {"[PCI] Cirrus Logic GD5446", "cl_gd5446_pci", &gd5446_pci_device, VID_CL_GD5446_PCI, VIDEO_FLAG_TYPE_SPECIAL, {VIDEO_BUS, 4, 4, 8, 10, 10, 20}}, + {"[PCI] Cirrus Logic GD5480", "cl_gd5480_pci", &gd5480_pci_device, VID_CL_GD5480_PCI, VIDEO_FLAG_TYPE_SPECIAL, {VIDEO_BUS, 4, 4, 8, 10, 10, 20}}, +#if defined(DEV_BRANCH) && defined(USE_STEALTH32) {"[PCI] Diamond Stealth 32 (Tseng ET4000/w32p)", "stealth32_pci", &et4000w32p_pci_device, VID_ET4000W32_PCI, VIDEO_FLAG_TYPE_SPECIAL, {VIDEO_BUS, 4, 4, 4, 10, 10, 10}}, #endif {"[PCI] Diamond Stealth 3D 2000 (S3 ViRGE)", "stealth3d_2000_pci", &s3_virge_pci_device, VID_VIRGE_PCI, VIDEO_FLAG_TYPE_SPECIAL, {VIDEO_BUS, 2, 2, 3, 28, 28, 45}}, @@ -158,13 +160,14 @@ video_cards[] = { {"[PCI] Phoenix S3 Trio64", "px_trio64_pci", &s3_phoenix_trio64_pci_device, VID_PHOENIX_TRIO64_PCI, VIDEO_FLAG_TYPE_SPECIAL, {VIDEO_BUS, 3, 2, 4, 25, 25, 40}}, {"[PCI] S3 ViRGE/DX", "virge375_pci", &s3_virge_375_pci_device, VID_VIRGEDX_PCI, VIDEO_FLAG_TYPE_SPECIAL, {VIDEO_BUS, 2, 2, 3, 28, 28, 45}}, {"[PCI] S3 ViRGE/DX (VBE 2.0)", "virge375_vbe20_pci", &s3_virge_375_4_pci_device, VID_VIRGEDX4_PCI, VIDEO_FLAG_TYPE_SPECIAL, {VIDEO_BUS, 2, 2, 3, 28, 28, 45}}, + {"[PCI] STB Nitro 64V (CL-GD5446)", "cl_gd5446_stb_pci", &gd5446_stb_pci_device, VID_CL_GD5446_STB_PCI, VIDEO_FLAG_TYPE_SPECIAL, {VIDEO_BUS, 4, 4, 8, 10, 10, 20}}, {"[PCI] Trident TGUI9440", "tgui9440_pci", &tgui9440_pci_device, VID_TGUI9440_PCI, VIDEO_FLAG_TYPE_SPECIAL, {VIDEO_BUS, 4, 8, 16, 4, 8, 16}}, {"[VLB] ATI Graphics Pro Turbo (Mach64 GX)", "mach64gx_vlb", &mach64gx_vlb_device, VID_MACH64GX_VLB, VIDEO_FLAG_TYPE_SPECIAL, {VIDEO_BUS, 2, 2, 1, 20, 20, 21}}, {"[VLB] Cardex Tseng ET4000/w32p", "et4000w32p_vlb", &et4000w32p_cardex_vlb_device, VID_ET4000W32_CARDEX_VLB, VIDEO_FLAG_TYPE_SPECIAL, {VIDEO_BUS, 4, 4, 4, 10, 10, 10}}, {"[VLB] Cirrus Logic GD5429", "cl_gd5429_vlb", &gd5429_vlb_device, VID_CL_GD5429_VLB, VIDEO_FLAG_TYPE_SPECIAL, {VIDEO_BUS, 4, 4, 8, 10, 10, 20}}, {"[VLB] Cirrus Logic GD5434", "cl_gd5434_vlb", &gd5434_vlb_device, VID_CL_GD5434_VLB, VIDEO_FLAG_TYPE_SPECIAL, {VIDEO_BUS, 4, 4, 8, 10, 10, 20}}, {"[VLB] Diamond SpeedStar PRO (CL-GD5426)", "cl_gd5426_vlb", &gd5426_vlb_device, VID_CL_GD5426_VLB, VIDEO_FLAG_TYPE_SPECIAL, {VIDEO_BUS, 4, 4, 8, 10, 10, 20}}, - {"[VLB] Diamond SpeedStar PRO SE (CL GD5430)", "cl_gd5430_vlb", &gd5430_vlb_device, VID_CL_GD5430_VLB, VIDEO_FLAG_TYPE_SPECIAL, {VIDEO_BUS, 4, 4, 8, 10, 10, 20}}, + {"[VLB] Diamond SpeedStar PRO SE (CL-GD5430)", "cl_gd5430_vlb", &gd5430_vlb_device, VID_CL_GD5430_VLB, VIDEO_FLAG_TYPE_SPECIAL, {VIDEO_BUS, 4, 4, 8, 10, 10, 20}}, #if defined(DEV_BRANCH) && defined(USE_STEALTH32) {"[VLB] Diamond Stealth 32 (Tseng ET4000/w32p)", "stealth32_vlb", &et4000w32p_vlb_device, VID_ET4000W32_VLB, VIDEO_FLAG_TYPE_SPECIAL, {VIDEO_BUS, 4, 4, 4, 10, 10, 10}}, #endif diff --git a/src/video/video.h b/src/video/video.h index edee329..bfcbd74 100644 --- a/src/video/video.h +++ b/src/video/video.h @@ -8,7 +8,7 @@ * * Definitions for the video controller module. * - * Version: @(#)video.h 1.0.9 2018/03/18 + * Version: @(#)video.h 1.0.10 2018/03/20 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -104,7 +104,10 @@ enum { VID_CL_GD5434_ISA, /* Cirrus Logic GD5434 ISA */ VID_CL_GD5434_VLB, /* Cirrus Logic GD5434 VLB */ VID_CL_GD5434_PCI, /* Cirrus Logic GD5434 PCI */ - VID_CL_GD5436_PCI, /* Cirrus Logic CL-GD 5436 PCI */ + VID_CL_GD5436_PCI, /* Cirrus Logic GD5436 PCI */ + VID_CL_GD5446_PCI, /* Cirrus Logic GD5446 PCI */ + VID_CL_GD5446_STB_PCI, /* STB Nitro 64V (Cirrus Logic GD5446) PCI */ + VID_CL_GD5480_PCI, /* Cirrus Logic GD5480 PCI */ VID_OTI037C, /* Oak OTI-037C */ VID_OTI067, /* Oak OTI-067 */ VID_OTI077, /* Oak OTI-077 */ diff --git a/src/win/win_cdrom_ioctl.c b/src/win/win_cdrom_ioctl.c index 8a5b5b6..fa6d778 100644 --- a/src/win/win_cdrom_ioctl.c +++ b/src/win/win_cdrom_ioctl.c @@ -9,7 +9,7 @@ * Implementation of the CD-ROM host drive IOCTL interface for * Windows using SCSI Passthrough Direct. * - * Version: @(#)cdrom_ioctl.c 1.0.6 2018/03/18 + * Version: @(#)cdrom_ioctl.c 1.0.7 2018/03/20 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -1224,6 +1224,7 @@ static uint32_t ioctl_size(uint8_t id) { uint8_t capacity_buffer[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; uint32_t capacity = 0; + ioctl_read_capacity(id, capacity_buffer); capacity = ((uint32_t) capacity_buffer[0]) << 24; capacity |= ((uint32_t) capacity_buffer[1]) << 16; @@ -1281,18 +1282,24 @@ int ioctl_hopen(uint8_t id) return 0; } +#define rcs "Read capacity: %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\n" +#define drb dev->rcbuf + int ioctl_open(uint8_t id, char d) { cdrom_t *dev = cdrom[id]; sprintf(cdrom_ioctl[id].ioctl_path,"\\\\.\\%c:",d); + pclog("IOCTL path: %s\n", cdrom_ioctl[id].ioctl_path); dev->disc_changed = 1; cdrom_ioctl_windows[id].hIOCTL = CreateFile(cdrom_ioctl[id].ioctl_path, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); cdrom_drives[id].handler = &ioctl_cdrom; dev->handler_inited = 1; - cdrom_ioctl[id].capacity_read=0; /* With this two lines, we read the READ CAPACITY command output from the host drive into our cache buffer. */ + cdrom_ioctl[id].capacity_read=0; /* With these two lines, we read the READ CAPACITY command output from the host drive into our cache buffer. */ ioctl_read_capacity(id, NULL); + pclog(rcs, drb[0], drb[1], drb[2], drb[3], drb[4], drb[5], drb[6], drb[7], + drb[8], drb[9], drb[10], drb[11], drb[12], drb[13], drb[14], drb[15]); CloseHandle(cdrom_ioctl_windows[id].hIOCTL); cdrom_ioctl_windows[id].hIOCTL = NULL; return 0; diff --git a/src/win/win_devconf.c b/src/win/win_devconf.c index f066ad6..1ed2081 100644 --- a/src/win/win_devconf.c +++ b/src/win/win_devconf.c @@ -8,7 +8,7 @@ * * Imlementation of the Device Configuration dialog. * - * Version: @(#)win_devconf.c 1.0.5 2018/03/15 + * Version: @(#)win_devconf.c 1.0.6 2018/03/20 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -262,7 +262,7 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) val_int = config->spinner.min; SendMessage(h, WM_GETTEXT, 79, (LPARAM)ws); - wcstombs(s, ws, 79); + wcstombs(s, ws, 79); /*tic*/ sscanf(s, "%i", &c); if (val_int != c) @@ -351,7 +351,8 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) break; case CONFIG_SPINNER: - SendMessage(h, WM_GETTEXT, 79, (LPARAM)s); + SendMessage(h, WM_GETTEXT, 79, (LPARAM)ws); + wcstombs(s, ws, 79); sscanf(s, "%i", &c); if (c > config->spinner.max) c = config->spinner.max;