diff --git a/src/Makefile.am b/src/Makefile.am index 993e6c0..3a83dae 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -32,7 +32,7 @@ codegen_ops_mmx_logic.c codegen_ops_mmx_pack.c codegen_ops_mmx_shift.c codegen_o codegen_ops_logic.c codegen_ops_shift.c codegen_ops_misc.c codegen_ops_mov.c codegen_ops_stack.c codegen_reg.c \ codegen_timing_486.c codegen_timing_686.c codegen_timing_common.c codegen_timing_k6.c codegen_timing_pentium.c \ codegen_timing_winchip.c codegen_timing_winchip2.c compaq.c config.c cpu.c cpu_tables.c dells200.c device.c disc.c \ -disc_fdi.c disc_img.c disc_sector.c dma.c esdi_at.c fdc.c fdc37c665.c fdd.c fdi2raw.c gameport.c hdd.c hdd_esdi.c \ +disc_fdi.c disc_img.c disc_sector.c dma.c esdi_at.c fdc.c fdc37c665.c fdc37c93x.c fdd.c fdi2raw.c gameport.c hdd.c hdd_esdi.c \ hdd_file.c headland.c i430lx.c i430fx.c i430hx.c i430vx.c ide.c ide_atapi.c ide_sff8038i.c intel.c intel_flash.c io.c \ jim.c joystick_ch_flightstick_pro.c joystick_standard.c joystick_sw_pad.c joystick_tm_fcs.c keyboard.c \ keyboard_amstrad.c keyboard_at.c keyboard_olim24.c keyboard_pcjr.c keyboard_xt.c laserxt.c lpt.c lpt_dac.c lpt_dss.c \ diff --git a/src/Makefile.mingw-wx-sdl2 b/src/Makefile.mingw-wx-sdl2 index 63ba36c..3f8ce14 100644 --- a/src/Makefile.mingw-wx-sdl2 +++ b/src/Makefile.mingw-wx-sdl2 @@ -17,7 +17,7 @@ OBJ = 386.o 386_common.o 386_dynarec.o 386_dynarec_ops.o 808x.o 82091aa.o acc203 codegen_ops_mov.o codegen_ops_shift.o codegen_ops_stack.o codegen_reg.o codegen_timing_486.o \ codegen_timing_686.o codegen_timing_common.o codegen_timing_k6.o codegen_timing_pentium.o \ codegen_timing_winchip.o codegen_timing_winchip2.o compaq.o config.o cpu.o cpu_tables.o device.o \ - dells200.o disc.o disc_fdi.o disc_img.o disc_sector.o dma.o esdi_at.o fdc.o fdc37c665.o fdd.o \ + dells200.o disc.o disc_fdi.o disc_img.o disc_sector.o dma.o esdi_at.o fdc.o fdc37c665.o fdc37c93x.o fdd.o \ fdi2raw.o gameport.o hdd.o hdd_esdi.o hdd_file.o headland.o i430hx.o i430lx.o i430fx.o i430vx.o ide.o \ ide_atapi.o ide_sff8038i.o intel.o intel_flash.o io.o jim.o joystick_ch_flightstick_pro.o \ joystick_standard.o joystick_sw_pad.o joystick_tm_fcs.o keyboard.o keyboard_amstrad.o keyboard_at.o \ diff --git a/src/Makefile.mingw-wx-sdl2-network b/src/Makefile.mingw-wx-sdl2-network index b0e5509..a0e2415 100644 --- a/src/Makefile.mingw-wx-sdl2-network +++ b/src/Makefile.mingw-wx-sdl2-network @@ -17,7 +17,7 @@ OBJ = 386.o 386_common.o 386_dynarec.o 386_dynarec_ops.o 808x.o 82091aa.o acc203 codegen_ops_mov.o codegen_ops_shift.o codegen_ops_stack.o codegen_reg.o codegen_timing_486.o \ codegen_timing_686.o codegen_timing_common.o codegen_timing_k6.o codegen_timing_pentium.o \ codegen_timing_winchip.o codegen_timing_winchip2.o compaq.o config.o cpu.o cpu_tables.o device.o \ - dells200.o disc.o disc_fdi.o disc_img.o disc_sector.o dma.o esdi_at.o fdc.o fdc37c665.o fdd.o \ + dells200.o disc.o disc_fdi.o disc_img.o disc_sector.o dma.o esdi_at.o fdc.o fdc37c665.o fdc37c93x.o fdd.o \ fdi2raw.o gameport.o hdd.o hdd_esdi.o hdd_file.o headland.o i430hx.o i430lx.o i430fx.o i430vx.o ide.o \ ide_atapi.o ide_sff8038i.o intel.o intel_flash.o io.o jim.o joystick_ch_flightstick_pro.o \ joystick_standard.o joystick_sw_pad.o joystick_tm_fcs.o keyboard.o keyboard_amstrad.o keyboard_at.o \ diff --git a/src/fdc37c93x.c b/src/fdc37c93x.c new file mode 100644 index 0000000..890d95d --- /dev/null +++ b/src/fdc37c93x.c @@ -0,0 +1,253 @@ +#include "ibm.h" + +#include "fdc.h" +#include "fdd.h" +#include "io.h" +#include "lpt.h" +#include "serial.h" +#include "fdc37c93x.h" + +typedef struct fdc37c93x_t +{ + int index; + + uint8_t global_regs[0x30]; + uint8_t fdc_regs[0x100]; + uint8_t ide1_regs[0x100]; + uint8_t ide2_regs[0x100]; + uint8_t lpt_regs[0x100]; + uint8_t com1_regs[0x100]; + uint8_t com2_regs[0x100]; + uint8_t rtc_regs[0x100]; + uint8_t kbd_regs[0x100]; + uint8_t auxio_regs[0x100]; + uint8_t accessbus_regs[0x100]; + + uint8_t lock[2]; +} fdc37c93x_t; + +static fdc37c93x_t fdc37c93x_global; + +static void write_lock(fdc37c93x_t *fdc37c93x, uint8_t val) +{ + if (val == 0x55 && fdc37c93x->lock[1] == 0x55) + fdc_3f1_enable(0); + if (fdc37c93x->lock[0] == 0x55 && fdc37c93x->lock[1] == 0x55 && val != 0x55) + fdc_3f1_enable(1); + + fdc37c93x->lock[0] = fdc37c93x->lock[1]; + fdc37c93x->lock[1] = val; +} + +void fdc37c93x_write(uint16_t port, uint8_t val, void *p) +{ + fdc37c93x_t *fdc37c93x = (fdc37c93x_t *)p; + +// pclog("Write SuperIO %04x %02x\n", port, val); + if (fdc37c93x->lock[0] == 0x55 && fdc37c93x->lock[1] == 0x55) + { + if (port == 0x3f0) + { + if (val == 0xaa) + write_lock(fdc37c93x, val); + else + fdc37c93x->index = val; + } + else + { + uint16_t addr; + int irq; + +// pclog("fdc37c93x_write: index=%02x dev=%i val=%02x\n", fdc37c93x->index, fdc37c93x->global_regs[7], val); + if (fdc37c93x->index < 0x30) + { + if (fdc37c93x->index != 0x20 && fdc37c93x->index != 0x21) + fdc37c93x->global_regs[fdc37c93x->index] = val; + } + else switch (fdc37c93x->global_regs[7]) + { + case 0: + fdc37c93x->fdc_regs[fdc37c93x->index] = val; + break; + case 1: + fdc37c93x->ide1_regs[fdc37c93x->index] = val; + break; + case 2: + fdc37c93x->ide2_regs[fdc37c93x->index] = val; + break; + case 3: + fdc37c93x->lpt_regs[fdc37c93x->index] = val; + break; + case 4: + fdc37c93x->com1_regs[fdc37c93x->index] = val; + break; + case 5: + fdc37c93x->com2_regs[fdc37c93x->index] = val; + break; + case 6: + fdc37c93x->rtc_regs[fdc37c93x->index] = val; + break; + case 7: + fdc37c93x->kbd_regs[fdc37c93x->index] = val; + break; + case 8: + fdc37c93x->auxio_regs[fdc37c93x->index] = val; + break; + case 9: + fdc37c93x->accessbus_regs[fdc37c93x->index] = val; + break; + } + + fdc_remove(); + if ((fdc37c93x->global_regs[0x22] & 0x01) && (fdc37c93x->fdc_regs[0x30] & 0x01)) + { +// pclog("FDC enabled\n"); + fdc_add(); + } +/* else + pclog("FDC disabled\n");*/ + + lpt1_remove(); + lpt2_remove(); + addr = (fdc37c93x->lpt_regs[0x61] & 0xfc) | ((fdc37c93x->lpt_regs[0x60] & 3) << 8); + if ((fdc37c93x->global_regs[0x22] & (1 << 3)) && (fdc37c93x->lpt_regs[0x30] & 0x01)) + { +// pclog("LPT addr = %04x\n", addr); + lpt1_init(addr); + } +/* else + pclog("LPT disabled\n");*/ + + serial1_remove(); + addr = (fdc37c93x->com1_regs[0x61] & 0xf8) | ((fdc37c93x->com1_regs[0x60] & 3) << 8); + irq = fdc37c93x->com1_regs[0x70] & 0xf; + if ((fdc37c93x->global_regs[0x22] & (1 << 4)) && (fdc37c93x->com1_regs[0x30] & 0x01)) + { +// pclog("COM1 addr = %04x, IRQ = %i\n", addr, irq); + serial1_set(addr, irq); + } +/* else + pclog("COM1 disabled\n");*/ + + serial2_remove(); + addr = (fdc37c93x->com2_regs[0x61] & 0xf8) | ((fdc37c93x->com2_regs[0x60] & 3) << 8); + irq = fdc37c93x->com2_regs[0x70] & 0xf; + if ((fdc37c93x->global_regs[0x22] & (1 << 5)) && (fdc37c93x->com2_regs[0x30] & 0x01)) + { +// pclog("COM2 addr = %04x, IRQ = %i\n", addr, irq); + serial2_set(addr, irq); + } +/* else + pclog("COM2 disabled\n");*/ + + + fdc_update_enh_mode(fdc37c93x->fdc_regs[0xf0] & 1); + + fdc_update_densel_force((fdc37c93x->fdc_regs[0xf1] & 0x0c) >> 2); + fdd_swap = (fdc37c93x->fdc_regs[0xf0] & (1 << 4)) ? 1 : 0; + } + } + else + { + if (port == 0x3f0) + write_lock(fdc37c93x, val); + } +} + +uint8_t fdc37c93x_read(uint16_t port, void *p) +{ + fdc37c93x_t *fdc37c93x = (fdc37c93x_t *)p; + +// pclog("Read SuperIO %04x %02x\n", port, fdc37c665_curreg); + if (fdc37c93x->lock[0] == 0x55 && fdc37c93x->lock[1] == 0x55) + { + if (port == 0x3f1) + { + if (fdc37c93x->index < 0x30) + return fdc37c93x->global_regs[fdc37c93x->index]; + else switch (fdc37c93x->global_regs[7]) + { + case 0: + return fdc37c93x->fdc_regs[fdc37c93x->index]; + case 1: + return fdc37c93x->ide1_regs[fdc37c93x->index]; + case 2: + return fdc37c93x->ide2_regs[fdc37c93x->index]; + case 3: + return fdc37c93x->lpt_regs[fdc37c93x->index]; + case 4: + return fdc37c93x->com1_regs[fdc37c93x->index]; + case 5: + return fdc37c93x->com2_regs[fdc37c93x->index]; + case 6: + return fdc37c93x->rtc_regs[fdc37c93x->index]; + case 7: + return fdc37c93x->kbd_regs[fdc37c93x->index]; + case 8: + return fdc37c93x->auxio_regs[fdc37c93x->index]; + case 9: + return fdc37c93x->accessbus_regs[fdc37c93x->index]; + } + } + } + return 0xff; +} + +void fdc37c932fr_init() +{ + fdc37c93x_t *fdc37c93x = &fdc37c93x_global; + int c; + + io_sethandler(0x03f0, 0x0002, fdc37c93x_read, NULL, NULL, fdc37c93x_write, NULL, NULL, fdc37c93x); + + fdc_update_is_nsc(0); + + memset(&fdc37c93x_global, 0, sizeof(fdc37c93x_global)); + + fdc37c93x->global_regs[0x03] = 0x03; + fdc37c93x->global_regs[0x20] = 0x03; + fdc37c93x->global_regs[0x21] = 0x01; + fdc37c93x->global_regs[0x24] = 0x04; + fdc37c93x->global_regs[0x26] = 0xf0; + fdc37c93x->global_regs[0x27] = 0x03; + + fdc37c93x->fdc_regs[0x60] = 0x03; + fdc37c93x->fdc_regs[0x61] = 0xf0; + fdc37c93x->fdc_regs[0x70] = 0x06; + fdc37c93x->fdc_regs[0x74] = 0x02; + fdc37c93x->fdc_regs[0xf0] = 0x0e; + fdc37c93x->fdc_regs[0xf2] = 0xff; + + fdc37c93x->ide1_regs[0x60] = 0x01; + fdc37c93x->ide1_regs[0x61] = 0xf0; + fdc37c93x->ide1_regs[0x62] = 0x03; + fdc37c93x->ide1_regs[0x63] = 0xf6; + fdc37c93x->ide1_regs[0x70] = 0x0e; + fdc37c93x->ide1_regs[0xf0] = 0x0c; + fdc37c93x->ide1_regs[0xf1] = 0x0d; + + fdc37c93x->lpt_regs[0x74] = 0x04; + fdc37c93x->lpt_regs[0xf0] = 0x3c; + + fdc37c93x->com2_regs[0x74] = 0x04; + fdc37c93x->com2_regs[0xf1] = 0x02; + fdc37c93x->com2_regs[0xf2] = 0x03; + + fdc37c93x->rtc_regs[0x63] = 0x70; + fdc37c93x->rtc_regs[0xf4] = 0x03; + + fdc37c93x->auxio_regs[0xb1] = 0x80; + fdc37c93x->auxio_regs[0xc0] = 0x01; + fdc37c93x->auxio_regs[0xc1] = 0x01; + fdc37c93x->auxio_regs[0xc5] = 0x01; + fdc37c93x->auxio_regs[0xc6] = 0x01; + fdc37c93x->auxio_regs[0xc7] = 0x01; + fdc37c93x->auxio_regs[0xc8] = 0x01; + fdc37c93x->auxio_regs[0xc9] = 0x80; + for (c = 0xcb; c < 0xee; c++) + fdc37c93x->auxio_regs[c] = 0x01; + + fdc_update_densel_polarity(1); + fdc_update_densel_force(0); + fdd_swap = 0; +} diff --git a/src/fdc37c93x.h b/src/fdc37c93x.h new file mode 100644 index 0000000..e661c3d --- /dev/null +++ b/src/fdc37c93x.h @@ -0,0 +1 @@ +extern void fdc37c932fr_init(); diff --git a/src/model.c b/src/model.c index 900b7f8..d9f0c06 100644 --- a/src/model.c +++ b/src/model.c @@ -20,6 +20,7 @@ #include "dma.h" #include "fdc.h" #include "fdc37c665.h" +#include "fdc37c93x.h" #include "gameport.h" #include "headland.h" #include "i430fx.h" @@ -716,7 +717,7 @@ void at_p55va_init() pci_slot(0x0B); i430vx_init(); piix_init(7, 0x08, 0x09, 0x0A, 0x0B); - um8669f_init(); + fdc37c932fr_init(); device_add(&intel_flash_bxt_device); }