From 55fd5652a8dc8947f9085353bbf157ae1403f449 Mon Sep 17 00:00:00 2001 From: mattx433 <10520670+mattx433@users.noreply.github.com> Date: Thu, 7 Jan 2021 13:42:55 +0100 Subject: [PATCH 01/15] Make mo_format use POSIX functions instead of Win32 ones --- src/disk/mo.c | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/src/disk/mo.c b/src/disk/mo.c index a5adbb108..13715947a 100644 --- a/src/disk/mo.c +++ b/src/disk/mo.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #define HAVE_STDARG_H #include <86box/86box.h> @@ -42,7 +43,7 @@ #include #include #else -#include +#include #endif mo_drive_t mo_drives[MO_NUM]; @@ -1041,46 +1042,41 @@ mo_format(mo_t *dev) { unsigned long size; int ret; - int fd; + int fd = fileno(dev->drv->f); + int64_t liSize = 0; mo_log("MO %i: Formatting media...\n", dev->id); + if (fd == -1) { + mo_log("MO %i: Failed to get file descriptor.\n", dev->id); + return; + } + fseek(dev->drv->f, 0, SEEK_END); size = (uint32_t) ftello64(dev->drv->f); - HANDLE fh; - LARGE_INTEGER liSize; + errno = 0; + rewind(dev->drv->f); - fd = _fileno(dev->drv->f); - fh = (HANDLE)_get_osfhandle(fd); - - liSize.QuadPart = 0; - - ret = (int)SetFilePointerEx(fh, liSize, NULL, FILE_BEGIN); - - if (!ret) { + if (errno) { mo_log("MO %i: Failed seek to start of image file\n", dev->id); return; } - ret = (int)SetEndOfFile(fh); - - if (!ret) { + ret = ftruncate(fd, 0); + if (ret == -1) { mo_log("MO %i: Failed to truncate image file to 0\n", dev->id); return; } - liSize.QuadPart = size; - ret = (int)SetFilePointerEx(fh, liSize, NULL, FILE_BEGIN); - - if (!ret) { + liSize = size; + ret = fseek(dev->drv->f, 0, SEEK_END); + if (ret == -1) { mo_log("MO %i: Failed seek to end of image file\n", dev->id); return; } - - ret = (int)SetEndOfFile(fh); - - if (!ret) { + ret = ftruncate(fd, liSize); + if (ret == -1) { mo_log("MO %i: Failed to truncate image file to %llu\n", dev->id, size); return; } From 19fac1e2182b278261a60595b73a322ea4433403 Mon Sep 17 00:00:00 2001 From: TC1995 Date: Thu, 7 Jan 2021 14:57:07 +0100 Subject: [PATCH 02/15] Fixed mixer initialization on the Sound Blaster 2.0. --- src/sound/snd_sb.c | 92 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 89 insertions(+), 3 deletions(-) diff --git a/src/sound/snd_sb.c b/src/sound/snd_sb.c index 303c69ba1..e1cc18f7e 100644 --- a/src/sound/snd_sb.c +++ b/src/sound/snd_sb.c @@ -1172,7 +1172,8 @@ sb_2_init(const device_t *info) sb_dsp_setaddr(&sb->dsp, addr); sb_dsp_setirq(&sb->dsp, device_get_config_int("irq")); sb_dsp_setdma8(&sb->dsp, device_get_config_int("dma")); - sb_ct1335_mixer_reset(sb); + if (mixer_addr > 0x000) + sb_ct1335_mixer_reset(sb); /* CMS I/O handler is activated on the dedicated sound_cms module DSP I/O handler is activated in sb_dsp_setaddr */ if (sb->opl_enabled) { @@ -1186,7 +1187,7 @@ sb_2_init(const device_t *info) opl2_write, NULL, NULL, &sb->opl); } - if (mixer_addr > 0x0000) { + if (mixer_addr > 0x000) { sb->mixer_enabled = 1; io_sethandler(addr + 4, 0x0002, sb_ct1335_mixer_read, NULL, NULL, sb_ct1335_mixer_write, NULL, NULL, sb); @@ -1558,6 +1559,91 @@ static const device_config_t sb_config[] = } }; + +static const device_config_t sb2_config[] = +{ + { + "base", "Address", CONFIG_HEX16, "", 0x220, "", { 0 }, + { + { + "0x220", 0x220 + }, + { + "0x240", 0x240 + }, + { + "0x260", 0x260 + }, + { + "" + } + } + }, + { + "mixaddr", "Mixer", CONFIG_HEX16, "", 0x220, "", { 0 }, + { + { + "Disabled", 0 + }, + { + "0x220", 0x220 + }, + { + "0x240", 0x240 + }, + { + "0x260", 0x260 + }, + { + "" + } + } + }, + { + "irq", "IRQ", CONFIG_SELECTION, "", 7, "", { 0 }, + { + { + "IRQ 2", 2 + }, + { + "IRQ 3", 3 + }, + { + "IRQ 5", 5 + }, + { + "IRQ 7", 7 + }, + { + "" + } + } + }, + { + "dma", "DMA", CONFIG_SELECTION, "", 1, "", { 0 }, + { + { + "DMA 1", 1 + }, + { + "DMA 3", 3 + }, + { + "" + } + } + }, + { + "opl", "Enable OPL", CONFIG_BINARY, "", 1 + }, + { + "receive_input", "Receive input (SB MIDI)", CONFIG_BINARY, "", 1 + }, + { + "", "", -1 + } +}; + static const device_config_t sb_mcv_config[] = { { @@ -1961,7 +2047,7 @@ const device_t sb_2_device = sb_2_init, sb_close, NULL, { NULL }, sb_speed_changed, NULL, - sb_config + sb2_config }; const device_t sb_pro_v1_device = From 601567576159846ad77a335ef5881a4c1f23f2f4 Mon Sep 17 00:00:00 2001 From: qeeg Date: Thu, 7 Jan 2021 10:22:58 -0600 Subject: [PATCH 03/15] More POSIX fixes --- src/network/net_pcap.c | 6 +++--- src/network/slirp/ip_input.c | 1 + src/network/slirp/mbuf.c | 1 + src/network/slirp/misc.c | 3 ++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/network/net_pcap.c b/src/network/net_pcap.c index 83823cf5d..00509798a 100644 --- a/src/network/net_pcap.c +++ b/src/network/net_pcap.c @@ -81,15 +81,15 @@ struct bpf_program { typedef struct pcap_if pcap_if_t; -typedef struct timeval { +typedef struct net_timeval { long tv_sec; long tv_usec; -} timeval; +} net_timeval; #define PCAP_ERRBUF_SIZE 256 struct pcap_pkthdr { - struct timeval ts; + struct net_timeval ts; bpf_u_int32 caplen; bpf_u_int32 len; }; diff --git a/src/network/slirp/ip_input.c b/src/network/slirp/ip_input.c index 7f017a238..e04d1506d 100644 --- a/src/network/slirp/ip_input.c +++ b/src/network/slirp/ip_input.c @@ -38,6 +38,7 @@ #include "slirp.h" #include "ip_icmp.h" +#include static struct ip *ip_reass(Slirp *slirp, struct ip *ip, struct ipq *fp); static void ip_freef(Slirp *slirp, struct ipq *fp); diff --git a/src/network/slirp/mbuf.c b/src/network/slirp/mbuf.c index 54ec721eb..e59db76d8 100644 --- a/src/network/slirp/mbuf.c +++ b/src/network/slirp/mbuf.c @@ -14,6 +14,7 @@ */ #include "slirp.h" +#include #define MBUF_THRESH 30 diff --git a/src/network/slirp/misc.c b/src/network/slirp/misc.c index 78515cbda..371212b34 100644 --- a/src/network/slirp/misc.c +++ b/src/network/slirp/misc.c @@ -4,6 +4,7 @@ */ #include "slirp.h" +#include #ifdef G_OS_UNIX #include #endif @@ -366,7 +367,7 @@ char *slirp_connection_info(Slirp *slirp) so->so_rcv.sb_cc, so->so_snd.sb_cc); } - return g_string_free(str, FALSE); + return g_string_free(str, false); } int slirp_bind_outbound(struct socket *so, unsigned short af) From 7fcf1c73fdf26bb8ad41e0b4b47f5a8f444dd6f0 Mon Sep 17 00:00:00 2001 From: TC1995 Date: Thu, 7 Jan 2021 17:30:11 +0100 Subject: [PATCH 04/15] Workaround for the Rancho RT1000B BIOSes 8.10R and 8.20R to run on any cpu clock while booting from hard disks (the Longshine and Trantor adapters still work though). --- src/scsi/scsi_ncr5380.c | 73 ++++++++++++++++++++++++++++------------- 1 file changed, 50 insertions(+), 23 deletions(-) diff --git a/src/scsi/scsi_ncr5380.c b/src/scsi/scsi_ncr5380.c index 50dee9d40..c284272b2 100644 --- a/src/scsi/scsi_ncr5380.c +++ b/src/scsi/scsi_ncr5380.c @@ -184,6 +184,17 @@ ncr_log(const char *fmt, ...) static void ncr_callback(void *priv); +static void +ncr_irq(ncr5380_t *ncr_dev, ncr_t *ncr, int set_irq) +{ + if (set_irq) { + ncr->isr |= STATUS_INT; + picint(1 << ncr_dev->irq); + } else { + ncr->isr &= ~STATUS_INT; + picintc(1 << ncr_dev->irq); + } +} static int get_dev_id(uint8_t data) @@ -211,10 +222,17 @@ getmsglen(uint8_t *msgp, int len) } static void -ncr_reset(ncr_t *ncr) +ncr_reset(ncr5380_t *ncr_dev, ncr_t *ncr) { memset(ncr, 0x00, sizeof(ncr_t)); ncr_log("NCR reset\n"); + + timer_stop(&ncr_dev->timer); + + for (int i = 0; i < 8; i++) + scsi_device_reset(&scsi_devices[i]); + + ncr_irq(ncr_dev, ncr, 0); } @@ -222,14 +240,17 @@ static void dma_timer_on(ncr5380_t *ncr_dev) { ncr_t *ncr = &ncr_dev->ncr; + scsi_device_t *dev = &scsi_devices[ncr->target_id]; double period = ncr_dev->period; - /* DMA Timer on: 1 wait period + 64 byte periods + 64 byte periods if first time. */ if (ncr->data_wait & 2) { ncr->data_wait &= ~2; + } + + /* DMA Timer on: 1 wait period + 128 byte periods. Hard disk timings are not emulated at the moment */ + if (dev->type & 5) { period *= 128.0; - } else - period *= 64.0; + } /* This is the 1 us wait period. */ period += 1.0; @@ -407,7 +428,6 @@ ncr_bus_update(void *priv, int bus) ncr_log("CurBus BSY|REQ=%02x\n", ncr->cur_bus); ncr->command_pos = 0; SET_BUS_STATE(ncr, SCSI_PHASE_COMMAND); - picint(1 << ncr_dev->irq); } else { ncr->state = STATE_IDLE; ncr->cur_bus = 0; @@ -580,7 +600,7 @@ ncr_write(uint16_t port, uint8_t val, void *priv) ncr_log("Write: Initiator command register\n"); if ((val & 0x80) && !(ncr->icr & 0x80)) { ncr_log("Resetting the 5380\n"); - ncr_reset(&ncr_dev->ncr); + ncr_reset(ncr_dev, &ncr_dev->ncr); } ncr->icr = val; break; @@ -667,7 +687,6 @@ ncr_read(uint16_t port, void *priv) case 1: /* Initiator Command Register */ ncr_log("Read: Initiator Command register, NCR ICR Read=%02x\n", ncr->icr); - ret = ncr->icr; break; @@ -700,8 +719,7 @@ ncr_read(uint16_t port, void *priv) if ((bus & SCSI_PHASE_MESSAGE_IN) == (ncr->cur_bus & SCSI_PHASE_MESSAGE_IN)) { ncr_log("Phase match\n"); ret |= STATUS_PHASE_MATCH; - } else - picint(1 << ncr_dev->irq); + } ncr_bus_read(ncr_dev); bus = ncr->cur_bus; @@ -722,7 +740,7 @@ ncr_read(uint16_t port, void *priv) if (bus & BUS_MSG) bus_state |= TCR_MSG; if ((ncr->tcr & 7) != bus_state) - ncr->isr |= STATUS_INT; + ncr_irq(ncr_dev, ncr, 1); } if (!(bus & BUS_BSY) && (ncr->mode & MODE_MONITOR_BUSY)) { ncr_log("Busy error\n"); @@ -731,10 +749,13 @@ ncr_read(uint16_t port, void *priv) ret |= (ncr->isr & (STATUS_INT | STATUS_END_OF_DMA)); break; + case 6: + ret = ncr->tx_data; + break; + case 7: /* reset Parity/Interrupt */ - ncr->isr &= ~STATUS_INT; - picintc(1 << ncr_dev->irq); - ncr_log("Reset IRQ\n"); + ncr->isr &= ~(STATUS_BUSY_ERROR | 0x20); + ncr_irq(ncr_dev, ncr, 0); break; default: @@ -976,7 +997,7 @@ ncr_callback(void *priv) { ncr5380_t *ncr_dev = (ncr5380_t *)priv; ncr_t *ncr = &ncr_dev->ncr; - int bus, bt = 0, c = 0; + int bus, c = 0; uint8_t temp, data; ncr_log("DMA mode=%d\n", ncr->dma_mode); @@ -1010,7 +1031,8 @@ ncr_callback(void *priv) if (!ncr_dev->block_count_loaded) break; - while (bt < 64) { +write_start: + { for (c = 0; c < 10; c++) { ncr_bus_read(ncr_dev); if (ncr->cur_bus & BUS_REQ) @@ -1028,7 +1050,6 @@ ncr_callback(void *priv) ncr_bus_update(priv, bus | BUS_ACK); ncr_bus_update(priv, bus & ~BUS_ACK); - bt++; ncr_dev->buffer_pos++; ncr_log("Buffer pos for writing = %d\n", ncr_dev->buffer_pos); @@ -1048,12 +1069,12 @@ ncr_callback(void *priv) ncr->isr |= STATUS_END_OF_DMA; if (ncr->mode & MODE_ENA_EOP_INT) { ncr_log("NCR write irq\n"); - ncr->isr |= STATUS_INT; - picint(1 << ncr_dev->irq); + ncr_irq(ncr_dev, ncr, 1); } } break; } + goto write_start; } break; @@ -1071,7 +1092,8 @@ ncr_callback(void *priv) if (!ncr_dev->block_count_loaded) break; - while (bt < 64) { +read_start: + { for (c = 0; c < 10; c++) { ncr_bus_read(ncr_dev); if (ncr->cur_bus & BUS_REQ) @@ -1091,7 +1113,6 @@ ncr_callback(void *priv) ncr_bus_update(priv, bus & ~BUS_ACK); ncr_dev->buffer[ncr_dev->buffer_pos++] = temp; - bt++; if (ncr_dev->buffer_pos == 128) { ncr_dev->buffer_pos = 0; @@ -1109,12 +1130,12 @@ ncr_callback(void *priv) ncr->isr |= STATUS_END_OF_DMA; if (ncr->mode & MODE_ENA_EOP_INT) { ncr_log("NCR read irq\n"); - ncr->isr |= STATUS_INT; - picint(1 << ncr_dev->irq); + ncr_irq(ncr_dev, ncr, 1); } } break; } + goto read_start; } break; } @@ -1201,7 +1222,7 @@ ncr_init(const device_t *info) sprintf(&temp[strlen(temp)], " IRQ=%d", ncr_dev->irq); ncr_log("%s\n", temp); - ncr_reset(&ncr_dev->ncr); + ncr_reset(ncr_dev, &ncr_dev->ncr); ncr_dev->status_ctrl = STATUS_BUFFER_NOT_READY; ncr_dev->buffer_host_pos = 128; @@ -1277,6 +1298,9 @@ static const device_config_t ncr5380_mmio_config[] = { { "IRQ 5", 5 }, + { + "IRQ 7", 7 + }, { "" } @@ -1318,6 +1342,9 @@ static const device_config_t rancho_config[] = { { "IRQ 5", 5 }, + { + "IRQ 7", 7 + }, { "" } From f8e654feb8dd0e47b8ed33ef9b3c8ba4e8af5e07 Mon Sep 17 00:00:00 2001 From: TC1995 Date: Thu, 7 Jan 2021 17:43:27 +0100 Subject: [PATCH 05/15] BIOS BAR now properly working in the NCR 53c8xx PCI adapters. --- src/scsi/scsi_ncr53c8xx.c | 198 ++++++++++++++++++++++---------------- 1 file changed, 117 insertions(+), 81 deletions(-) diff --git a/src/scsi/scsi_ncr53c8xx.c b/src/scsi/scsi_ncr53c8xx.c index e898e7d76..2ec5932c2 100644 --- a/src/scsi/scsi_ncr53c8xx.c +++ b/src/scsi/scsi_ncr53c8xx.c @@ -10,9 +10,6 @@ * Adapters made by NCR and later Symbios and LSI. These * controllers were designed for the PCI bus. * - * To do: Identify the type of serial EEPROM used and its - * interface. - * * * * Authors: Paul Brook (QEMU) @@ -48,7 +45,17 @@ #include <86box/scsi_device.h> #include <86box/scsi_ncr53c8xx.h> -#define NCR53C8XX_ROM L"roms/scsi/ncr53c8xx/NCR307.BIN" + +#define NCR53C810_SDMS3_ROM L"roms/scsi/ncr53c8xx/810/NCR307.BIN" +#define SYM53C810_SDMS4_ROM L"roms/scsi/ncr53c8xx/810/8XX_64.ROM" +#define NCR53C815_SDMS3_ROM L"roms/scsi/ncr53c8xx/815/NCR307.BIN" +#define SYM53C815_SDMS4_ROM L"roms/scsi/ncr53c8xx/815/8XX_64.ROM" +#define NCR53C825A_SDMS3_ROM L"roms/scsi/ncr53c8xx/825A/NCR307.BIN" +#define SYM53C825A_SDMS4_ROM L"roms/scsi/ncr53c8xx/825A/8XX_64.ROM" +#define NCR53C860_SDMS3_ROM L"roms/scsi/ncr53c8xx/860/NCR307.BIN" +#define SYM53C860_SDMS4_ROM L"roms/scsi/ncr53c8xx/860/8XX_64.ROM" +#define NCR53C875_SDMS3_ROM L"roms/scsi/ncr53c8xx/875/NCR307.BIN" +#define SYM53C875_SDMS4_ROM L"roms/scsi/ncr53c8xx/875/8XX_64.ROM" #define HA_ID 7 @@ -2231,13 +2238,11 @@ ncr53c8xx_ram_set_addr(ncr53c8xx_t *dev, uint32_t base) } -#ifdef USE_BIOS_BAR static void ncr53c8xx_bios_set_addr(ncr53c8xx_t *dev, uint32_t base) { mem_mapping_set_addr(&dev->bios.mapping, base, 0x10000); } -#endif static void @@ -2254,13 +2259,11 @@ ncr53c8xx_ram_disable(ncr53c8xx_t *dev) } -#ifdef USE_BIOS_BAR static void ncr53c8xx_bios_disable(ncr53c8xx_t *dev) { mem_mapping_disable(&dev->bios.mapping); } -#endif uint8_t ncr53c8xx_pci_regs[256]; @@ -2324,47 +2327,37 @@ ncr53c8xx_pci_read(int func, int addr, void *p) case 0x18: return 0; /*Memory space*/ case 0x19: - if (dev->chip < CHIP_825) + if (dev->chip == CHIP_815 || dev->chip < CHIP_825) return 0; return ncr53c8xx_pci_bar[2].addr_regs[1]; case 0x1A: - if (dev->chip < CHIP_825) + if (dev->chip == CHIP_815 || dev->chip < CHIP_825) return 0; return ncr53c8xx_pci_bar[2].addr_regs[2]; case 0x1B: - if (dev->chip < CHIP_825) + if (dev->chip == CHIP_815 || dev->chip < CHIP_825) return 0; return ncr53c8xx_pci_bar[2].addr_regs[3]; case 0x2C: return 0x00; case 0x2D: - if (dev->chip >= CHIP_825) + if (dev->chip >= CHIP_825 || dev->chip != CHIP_815) return 0; return 0x10; case 0x2E: - if (dev->chip >= CHIP_825) + if (dev->chip >= CHIP_825 || dev->chip != CHIP_815) return 0; return 0x01; case 0x2F: return 0x00; -#ifdef USE_BIOS_BAR case 0x30: - if ((dev->chip < CHIP_825) || !dev->has_bios) - return 0; - return ncr53c8xx_pci_bar[3].addr_regs[0]; + return ncr53c8xx_pci_bar[3].addr_regs[0] & 0x01; case 0x31: - if ((dev->chip < CHIP_825) || !dev->has_bios) - return 0; return ncr53c8xx_pci_bar[3].addr_regs[1]; case 0x32: - if ((dev->chip < CHIP_825) || !dev->has_bios) - return 0; return ncr53c8xx_pci_bar[3].addr_regs[2]; case 0x33: - if ((dev->chip < CHIP_825) || !dev->has_bios) - return 0; return ncr53c8xx_pci_bar[3].addr_regs[3]; -#endif case 0x3C: return dev->irq; case 0x3D: @@ -2405,7 +2398,7 @@ ncr53c8xx_pci_write(int func, int addr, uint8_t val, void *p) ncr53c8xx_mem_disable(dev); if ((dev->MMIOBase != 0) && (val & PCI_COMMAND_MEM)) ncr53c8xx_mem_set_addr(dev, dev->MMIOBase); - if (dev->chip >= CHIP_825) { + if (dev->chip != CHIP_815 || dev->chip >= CHIP_825) { ncr53c8xx_ram_disable(dev); if ((dev->RAMBase != 0) && (val & PCI_COMMAND_MEM)) ncr53c8xx_ram_set_addr(dev, dev->RAMBase); @@ -2449,8 +2442,8 @@ ncr53c8xx_pci_write(int func, int addr, uint8_t val, void *p) /* Then let's set the PCI regs. */ ncr53c8xx_pci_bar[1].addr_regs[addr & 3] = val; /* Then let's calculate the new I/O base. */ - ncr53c8xx_pci_bar[1].addr &= 0xffffc000; - dev->MMIOBase = ncr53c8xx_pci_bar[1].addr & 0xffffc000; + ncr53c8xx_pci_bar[1].addr &= 0xfffcf000; + dev->MMIOBase = ncr53c8xx_pci_bar[1].addr & 0xfffcf000; /* Log the new base. */ ncr53c8xx_log("NCR53c8xx: New MMIO base is %08X\n" , dev->MMIOBase); /* We're done, so get out of the here. */ @@ -2461,7 +2454,7 @@ ncr53c8xx_pci_write(int func, int addr, uint8_t val, void *p) return; case 0x19: case 0x1A: case 0x1B: - if (dev->chip < CHIP_825) + if (dev->chip == CHIP_815 || dev->chip < CHIP_825) return; /* RAM Base set. */ /* First, remove the old I/O. */ @@ -2469,8 +2462,8 @@ ncr53c8xx_pci_write(int func, int addr, uint8_t val, void *p) /* Then let's set the PCI regs. */ ncr53c8xx_pci_bar[2].addr_regs[addr & 3] = val; /* Then let's calculate the new I/O base. */ - ncr53c8xx_pci_bar[2].addr &= 0xffffc000; - dev->RAMBase = ncr53c8xx_pci_bar[2].addr & 0xffffc000; + ncr53c8xx_pci_bar[2].addr &= 0xfffcf000; + dev->RAMBase = ncr53c8xx_pci_bar[2].addr & 0xfffcf000; /* Log the new base. */ ncr53c8xx_log("NCR53c8xx: New RAM base is %08X\n" , dev->RAMBase); /* We're done, so get out of the here. */ @@ -2480,10 +2473,8 @@ ncr53c8xx_pci_write(int func, int addr, uint8_t val, void *p) } return; -#ifdef USE_BIOS_BAR case 0x30: case 0x31: case 0x32: case 0x33: - return; - if ((dev->chip < CHIP_825) || !dev->has_bios) + if (dev->has_bios == 0) return; /* BIOS Base set. */ /* First, remove the old I/O. */ @@ -2491,15 +2482,15 @@ ncr53c8xx_pci_write(int func, int addr, uint8_t val, void *p) /* Then let's set the PCI regs. */ ncr53c8xx_pci_bar[3].addr_regs[addr & 3] = val; /* Then let's calculate the new I/O base. */ - ncr53c8xx_pci_bar[3].addr &= 0xffff0001; - dev->BIOSBase = ncr53c8xx_pci_bar[3].addr & 0xffff0000; + ncr53c8xx_pci_bar[3].addr &= 0xfffcf001; + dev->BIOSBase = ncr53c8xx_pci_bar[3].addr & 0xfffcf000; /* Log the new base. */ ncr53c8xx_log("NCR53c8xx: New BIOS base is %08X\n" , dev->BIOSBase); /* We're done, so get out of the here. */ - if (ncr53c8xx_pci_bar[3].addr & 0x00000001) + if (ncr53c8xx_pci_bar[3].addr_regs[0] & 0x01) { ncr53c8xx_bios_set_addr(dev, dev->BIOSBase); - return; -#endif + } + return; case 0x3C: ncr53c8xx_pci_regs[addr] = val; @@ -2518,52 +2509,74 @@ ncr53c8xx_init(const device_t *info) memset(dev, 0x00, sizeof(ncr53c8xx_t)); dev->chip_rev = 0; - // dev->pci_slot = pci_add_card(PCI_ADD_SCSI, ncr53c8xx_pci_read, ncr53c8xx_pci_write, dev); dev->pci_slot = pci_add_card(PCI_ADD_NORMAL, ncr53c8xx_pci_read, ncr53c8xx_pci_write, dev); - ncr53c8xx_pci_bar[0].addr_regs[0] = 1; - ncr53c8xx_pci_bar[1].addr_regs[0] = 0; dev->chip = info->local & 0xff; - ncr53c8xx_pci_regs[0x04] = 3; - - ncr53c8xx_mem_init(dev, 0x0fffff00); - ncr53c8xx_mem_disable(dev); - if (info->local & 0x8000) dev->has_bios = 0; else dev->has_bios = device_get_config_int("bios"); - if (dev->has_bios) - rom_init(&dev->bios, NCR53C8XX_ROM, 0xc8000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); - if (dev->chip >= CHIP_825) { - if (dev->chip == CHIP_875) { - dev->chip_rev = 0x04; - dev->nvr_path = L"ncr53c875.nvr"; - } else if (dev->chip == CHIP_860) { - dev->chip_rev = 0x04; - dev->nvr_path = L"ncr53c860.nvr"; - } else { - dev->chip_rev = 0x26; - dev->nvr_path = L"ncr53c825a.nvr"; - } - ncr53c8xx_pci_bar[2].addr_regs[0] = 0; - ncr53c8xx_pci_bar[3].addr = 0xffff0000; + if (dev->chip == CHIP_875) { + if (dev->has_bios == 2) + rom_init(&dev->bios, SYM53C875_SDMS4_ROM, 0xc8000, 0x10000, 0xffff, 0, MEM_MAPPING_EXTERNAL); + else if (dev->has_bios == 1) + rom_init(&dev->bios, NCR53C875_SDMS3_ROM, 0xc8000, 0x4000, 0x3fff, 0, MEM_MAPPING_EXTERNAL); + dev->chip_rev = 0x04; + dev->nvr_path = L"ncr53c875.nvr"; + } else if (dev->chip == CHIP_860) { + if (dev->has_bios == 2) + rom_init(&dev->bios, SYM53C860_SDMS4_ROM, 0xc8000, 0x10000, 0xffff, 0, MEM_MAPPING_EXTERNAL); + else if (dev->has_bios == 1) + rom_init(&dev->bios, NCR53C860_SDMS3_ROM, 0xc8000, 0x4000, 0x3fff, 0, MEM_MAPPING_EXTERNAL); + dev->chip_rev = 0x04; + dev->nvr_path = L"ncr53c860.nvr"; + } else if (dev->chip == CHIP_825) { + if (dev->has_bios == 2) + rom_init(&dev->bios, SYM53C825A_SDMS4_ROM, 0xc8000, 0x10000, 0xffff, 0, MEM_MAPPING_EXTERNAL); + else if (dev->has_bios == 1) + rom_init(&dev->bios, NCR53C825A_SDMS3_ROM, 0xc8000, 0x4000, 0x3fff, 0, MEM_MAPPING_EXTERNAL); + dev->chip_rev = 0x26; + dev->nvr_path = L"ncr53c825a.nvr"; + } else if (dev->chip == CHIP_810) { + if (dev->has_bios == 2) + rom_init(&dev->bios, SYM53C810_SDMS4_ROM, 0xc8000, 0x10000, 0xffff, 0, MEM_MAPPING_EXTERNAL); + else if (dev->has_bios == 1) + rom_init(&dev->bios, NCR53C810_SDMS3_ROM, 0xc8000, 0x4000, 0x3fff, 0, MEM_MAPPING_EXTERNAL); + dev->nvr_path = L"ncr53c810.nvr"; + } else if (dev->chip == CHIP_815) { + if (dev->has_bios == 2) + rom_init(&dev->bios, SYM53C815_SDMS4_ROM, 0xc8000, 0x10000, 0xffff, 0, MEM_MAPPING_EXTERNAL); + else if (dev->has_bios == 1) + rom_init(&dev->bios, NCR53C815_SDMS3_ROM, 0xc8000, 0x4000, 0x3fff, 0, MEM_MAPPING_EXTERNAL); + dev->chip_rev = 0x04; + dev->nvr_path = L"ncr53c815.nvr"; + } + + ncr53c8xx_pci_bar[0].addr_regs[0] = 1; + ncr53c8xx_pci_bar[1].addr_regs[0] = 0; + ncr53c8xx_pci_regs[0x04] = 3; + + if (dev->has_bios) { + ncr53c8xx_pci_bar[3].addr = 0xffffc000; + } else { + ncr53c8xx_pci_bar[3].addr = 0; + } + + ncr53c8xx_mem_init(dev, 0x0fffff00); + ncr53c8xx_mem_disable(dev); + + ncr53c8xx_pci_bar[2].addr_regs[0] = 0; + + if (dev->chip >= CHIP_825 || (dev->chip != CHIP_815)) { /* Need to make it align on a 16k boundary as that's this emulator's memory mapping granularity. */ ncr53c8xx_ram_init(dev, 0x0fffc000); ncr53c8xx_ram_disable(dev); - -#ifdef USE_BIOS_BAR - if (dev->has_bios) - ncr53c8xx_bios_disable(dev); -#endif - } else { - /* if (dev->has_bios) - rom_init(&dev->bios, NCR53C8XX_ROM, 0xc8000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); */ - - dev->nvr_path = L"ncr53c810.nvr"; } + + if (dev->has_bios) + ncr53c8xx_bios_disable(dev); dev->i2c = i2c_gpio_init("nvr_ncr53c8xx"); dev->eeprom = i2c_eeprom_init(i2c_gpio_get_bus(dev->i2c), 0x50, dev->nvram, sizeof(dev->nvram), 1); @@ -2599,11 +2612,24 @@ ncr53c8xx_close(void *priv) } } - static const device_config_t ncr53c8xx_pci_config[] = { - { - "bios", "Enable BIOS", CONFIG_BINARY, "", 0 - }, + { + "bios", "BIOS", CONFIG_SELECTION, "", 1, "", { 0 }, + { + { + "SDMS 4.x BIOS", 2 + }, + { + "SDMS 3.x BIOS", 1 + }, + { + "Disable BIOS", 0 + }, + { + "" + } + }, + }, { "", "", -1 } @@ -2612,9 +2638,9 @@ static const device_config_t ncr53c8xx_pci_config[] = { const device_t ncr53c810_pci_device = { - "NCR 53C810", + "NCR 53c810", DEVICE_PCI, - 0x01, + CHIP_810, ncr53c8xx_init, ncr53c8xx_close, NULL, { NULL }, NULL, NULL, ncr53c8xx_pci_config @@ -2622,7 +2648,7 @@ const device_t ncr53c810_pci_device = const device_t ncr53c810_onboard_pci_device = { - "NCR 53C810 On-Board", + "NCR 53c810 On-Board", DEVICE_PCI, 0x8001, ncr53c8xx_init, ncr53c8xx_close, NULL, @@ -2630,9 +2656,19 @@ const device_t ncr53c810_onboard_pci_device = NULL }; +const device_t ncr53c815_pci_device = +{ + "NCR 53c815", + DEVICE_PCI, + CHIP_815, + ncr53c8xx_init, ncr53c8xx_close, NULL, + { NULL }, NULL, NULL, + ncr53c8xx_pci_config +}; + const device_t ncr53c825a_pci_device = { - "NCR 53C825A", + "NCR 53c825A", DEVICE_PCI, CHIP_825, ncr53c8xx_init, ncr53c8xx_close, NULL, @@ -2642,7 +2678,7 @@ const device_t ncr53c825a_pci_device = const device_t ncr53c860_pci_device = { - "NCR 53C860", + "NCR 53c860", DEVICE_PCI, CHIP_860, ncr53c8xx_init, ncr53c8xx_close, NULL, @@ -2652,7 +2688,7 @@ const device_t ncr53c860_pci_device = const device_t ncr53c875_pci_device = { - "NCR 53C875", + "NCR 53c875", DEVICE_PCI, CHIP_875, ncr53c8xx_init, ncr53c8xx_close, NULL, From 89377b48d2cecb706fb7fe5671627d615f56a263 Mon Sep 17 00:00:00 2001 From: TC1995 Date: Sat, 9 Jan 2021 15:28:39 +0100 Subject: [PATCH 06/15] Fixed the inaccuracy of the 5380. --- src/scsi/scsi_ncr5380.c | 368 +++++++++++++++++++++------------------- 1 file changed, 189 insertions(+), 179 deletions(-) diff --git a/src/scsi/scsi_ncr5380.c b/src/scsi/scsi_ncr5380.c index c284272b2..defb56d16 100644 --- a/src/scsi/scsi_ncr5380.c +++ b/src/scsi/scsi_ncr5380.c @@ -122,7 +122,7 @@ typedef struct { int8_t irq; int8_t type; int8_t bios_ver; - uint8_t block_count; + uint16_t block_count, block_count_num; uint8_t status_ctrl; uint8_t pad[2]; @@ -181,6 +181,12 @@ ncr_log(const char *fmt, ...) #define SET_BUS_STATE(ncr, state) ncr->cur_bus = (ncr->cur_bus & ~(SCSI_PHASE_MESSAGE_IN)) | (state & (SCSI_PHASE_MESSAGE_IN)) +static void +ncr_dma_send(ncr5380_t *ncr_dev, ncr_t *ncr); + +static void +ncr_dma_initiator_receive(ncr5380_t *ncr_dev, ncr_t *ncr); + static void ncr_callback(void *priv); @@ -235,55 +241,22 @@ ncr_reset(ncr5380_t *ncr_dev, ncr_t *ncr) ncr_irq(ncr_dev, ncr, 0); } - static void -dma_timer_on(ncr5380_t *ncr_dev) +ncr_timer_on(ncr5380_t *ncr_dev, ncr_t *ncr, int callback) { - ncr_t *ncr = &ncr_dev->ncr; - scsi_device_t *dev = &scsi_devices[ncr->target_id]; - double period = ncr_dev->period; - - if (ncr->data_wait & 2) { + double p = ncr_dev->period; + + if (ncr->data_wait & 2) ncr->data_wait &= ~2; + + if (callback) { + p *= 128.0; } + + p += 1.0; - /* DMA Timer on: 1 wait period + 128 byte periods. Hard disk timings are not emulated at the moment */ - if (dev->type & 5) { - period *= 128.0; - } - - /* This is the 1 us wait period. */ - period += 1.0; - - timer_on_auto(&ncr_dev->timer, period); -} - - -static void -wait_timer_on(ncr5380_t *ncr_dev) -{ - /* PIO Wait Timer On: 1 period. */ - timer_on_auto(&ncr_dev->timer, ncr_dev->period); -} - - -static void -set_dma_enable(ncr5380_t *dev, int enable) -{ - if (enable) { - if (!timer_is_enabled(&dev->timer)) - dma_timer_on(dev); - } else - timer_stop(&dev->timer); -} - - -static void -dma_changed(ncr5380_t *dev, int mode, int enable) -{ - dev->dma_enabled = (mode && enable); - - set_dma_enable(dev, dev->dma_enabled && dev->block_count_loaded); + ncr_log("P = %lf\n", p); + timer_on_auto(&ncr_dev->timer, p); } @@ -397,6 +370,8 @@ ncr_bus_update(void *priv, int bus) if (bus & BUS_ARB) ncr->state = STATE_IDLE; + ncr_log("State = %i\n", ncr->state); + switch (ncr->state) { case STATE_IDLE: ncr->clear_req = ncr->wait_data = ncr->wait_complete = 0; @@ -468,7 +443,7 @@ ncr_bus_update(void *priv, int bus) scsi_device_command_phase0(dev, ncr->command); ncr_log("SCSI ID %i: Command %02X: Buffer Length %i, SCSI Phase %02X\n", ncr->target_id, ncr->command[0], dev->buffer_length, dev->phase); - ncr_dev->period = 1.0; /* 1 us default */ + ncr_dev->period = 1.0; ncr->wait_data = 4; ncr->data_wait = 0; @@ -476,14 +451,14 @@ ncr_bus_update(void *priv, int bus) /*If the SCSI phase is Data In or Data Out, allocate the SCSI buffer based on the transfer length of the command*/ if (dev->buffer_length && (dev->phase == SCSI_PHASE_DATA_IN || dev->phase == SCSI_PHASE_DATA_OUT)) { p = scsi_device_get_callback(dev); - if (p <= 0.0) - ncr_dev->period = 0.2/* * ((double) dev->buffer_length) */; - else + if (p <= 0.0) { + ncr_dev->period = 0.2; + } else ncr_dev->period = p / ((double) dev->buffer_length); ncr->data_wait |= 2; + ncr_log("SCSI ID %i: command 0x%02x for p = %lf, update = %lf, len = %i\n", ncr->target_id, ncr->command[0], p, ncr_dev->period, dev->buffer_length); } } - ncr->new_phase = dev->phase; } } @@ -502,9 +477,10 @@ ncr_bus_update(void *priv, int bus) ncr->cur_bus = (ncr->cur_bus & ~BUS_DATAMASK) | BUS_SETDATA(ncr->tx_data) | BUS_DBP | BUS_REQ; if (ncr->data_wait & 2) ncr->data_wait &= ~2; - if (ncr->dma_mode == DMA_IDLE) { + if (ncr->dma_mode == DMA_IDLE) { /*If a data in command that is not read 6/10 has been issued*/ ncr->data_wait |= 1; - wait_timer_on(ncr_dev); + ncr_log("DMA mode idle in\n"); + timer_on_auto(&ncr_dev->timer, ncr_dev->period); } else ncr->clear_req = 3; ncr->cur_bus &= ~BUS_REQ; @@ -514,7 +490,6 @@ ncr_bus_update(void *priv, int bus) break; case STATE_DATAOUT: dev = &scsi_devices[ncr->target_id]; - if ((bus & BUS_ACK) && !(ncr->bus_in & BUS_ACK)) { dev->sc->temp_buffer[ncr->data_pos++] = BUS_GETDATA(bus); @@ -526,11 +501,13 @@ ncr_bus_update(void *priv, int bus) ncr->wait_complete = 8; } else { /*More data is to be transferred, place a request*/ - if (ncr->dma_mode == DMA_IDLE) { + if (ncr->dma_mode == DMA_IDLE) { /*If a data out command that is not write 6/10 has been issued*/ ncr->data_wait |= 1; - wait_timer_on(ncr_dev); - } else + ncr_log("DMA mode idle out\n"); + timer_on_auto(&ncr_dev->timer, ncr_dev->period); + } else { ncr->clear_req = 3; + } ncr->cur_bus &= ~BUS_REQ; ncr_log("CurBus ~REQ_DataOut=%02x\n", ncr->cur_bus); } @@ -615,9 +592,11 @@ ncr_write(uint16_t port, uint8_t val, void *priv) ncr->mode = val; /*Don't stop the timer until it finishes the transfer*/ - if (ncr_dev->block_count_loaded && (ncr->mode & MODE_DMA)) - dma_changed(ncr_dev, ncr->dma_mode, ncr->mode & MODE_DMA); - + if (ncr_dev->block_count_loaded && (ncr->mode & MODE_DMA) && !timer_is_enabled(&ncr_dev->timer)) { + ncr_log("Continuing DMA mode\n"); + ncr_timer_on(ncr_dev, ncr, 0); + } + /*When a pseudo-DMA transfer has completed (Send or Initiator Receive), mark it as complete and idle the status*/ if (!ncr_dev->block_count_loaded && !(ncr->mode & MODE_DMA)) { ncr_log("No DMA mode\n"); @@ -638,18 +617,20 @@ ncr_write(uint16_t port, uint8_t val, void *priv) case 5: /* start DMA Send */ ncr_log("Write: start DMA send register\n"); - ncr_log("Write 6 or 10, block count loaded=%d\n", ncr_dev->block_count_loaded); /*a Write 6/10 has occurred, start the timer when the block count is loaded*/ ncr->dma_mode = DMA_SEND; - dma_changed(ncr_dev, ncr->dma_mode, ncr->mode & MODE_DMA); + if (ncr_dev->block_count_loaded && (ncr->mode & MODE_DMA) && !timer_is_enabled(&ncr_dev->timer)) { + ncr_timer_on(ncr_dev, ncr, 0); + } break; case 7: /* start DMA Initiator Receive */ - ncr_log("Write: start DMA initiator receive register\n"); - ncr_log("Read 6 or 10, block count loaded=%d\n", ncr_dev->block_count_loaded); + ncr_log("Write: start DMA initiator receive register, dma? = %02x\n", ncr->mode & MODE_DMA); /*a Read 6/10 has occurred, start the timer when the block count is loaded*/ ncr->dma_mode = DMA_INITIATOR_RECEIVE; - dma_changed(ncr_dev, ncr->dma_mode, ncr->mode & MODE_DMA); + if (ncr_dev->block_count_loaded && (ncr->mode & MODE_DMA) && !timer_is_enabled(&ncr_dev->timer)) { + ncr_timer_on(ncr_dev, ncr, 0); + } break; default: @@ -657,8 +638,10 @@ ncr_write(uint16_t port, uint8_t val, void *priv) break; } - bus_host = get_bus_host(ncr); - ncr_bus_update(priv, bus_host); + if (ncr->dma_mode == DMA_IDLE) { + bus_host = get_bus_host(ncr); + ncr_bus_update(priv, bus_host); + } } @@ -710,7 +693,7 @@ ncr_read(uint16_t port, void *priv) case 5: /* Bus and Status register */ ncr_log("Read: Bus and Status register\n"); - ret = 0; + ret = 0; bus = get_bus_host(ncr); ncr_log("Get host from Interrupt\n"); @@ -726,6 +709,8 @@ ncr_read(uint16_t port, void *priv) if (bus & BUS_ACK) ret |= STATUS_ACK; + if (bus & BUS_ATN) + ret |= 0x02; if ((bus & BUS_REQ) && (ncr->mode & MODE_DMA)) { ncr_log("Entering DMA mode\n"); @@ -739,8 +724,10 @@ ncr_read(uint16_t port, void *priv) bus_state |= TCR_CD; if (bus & BUS_MSG) bus_state |= TCR_MSG; - if ((ncr->tcr & 7) != bus_state) + if ((ncr->tcr & 7) != bus_state) { ncr_irq(ncr_dev, ncr, 1); + ncr_log("IRQ issued\n"); + } } if (!(bus & BUS_BSY) && (ncr->mode & MODE_MONITOR_BUSY)) { ncr_log("Busy error\n"); @@ -756,6 +743,7 @@ ncr_read(uint16_t port, void *priv) case 7: /* reset Parity/Interrupt */ ncr->isr &= ~(STATUS_BUSY_ERROR | 0x20); ncr_irq(ncr_dev, ncr, 0); + ncr_log("Reset Interrupt\n"); break; default: @@ -800,10 +788,11 @@ memio_read(uint32_t addr, void *priv) break; case 0x3900: - if (ncr_dev->buffer_host_pos >= 128 || !(ncr_dev->status_ctrl & CTRL_DATA_DIR)) + if (ncr_dev->buffer_host_pos >= 128 || !(ncr_dev->status_ctrl & CTRL_DATA_DIR)) { ret = 0xff; - else { + } else { ret = ncr_dev->buffer[ncr_dev->buffer_host_pos++]; + ncr_log("Read Host pos = %i\n", ncr_dev->buffer_host_pos); if (ncr_dev->buffer_host_pos == 128) { ncr_log("Not ready\n"); @@ -850,6 +839,7 @@ static void memio_write(uint32_t addr, uint8_t val, void *priv) { ncr5380_t *ncr_dev = (ncr5380_t *)priv; + ncr_t *ncr = &ncr_dev->ncr; addr &= 0x3fff; @@ -870,6 +860,8 @@ memio_write(uint32_t addr, uint8_t val, void *priv) if (!(ncr_dev->status_ctrl & CTRL_DATA_DIR) && ncr_dev->buffer_host_pos < 128) { ncr_dev->buffer[ncr_dev->buffer_host_pos++] = val; + ncr_log("Write host pos = %i\n", ncr_dev->buffer_host_pos); + if (ncr_dev->buffer_host_pos == 128) { ncr_dev->status_ctrl |= STATUS_BUFFER_NOT_READY; ncr_dev->ncr_busy = 1; @@ -892,11 +884,15 @@ memio_write(uint32_t addr, uint8_t val, void *priv) break; case 0x3981: /* block counter register */ - ncr_log("Write block counter register: val=%d\n", val); + ncr_log("Write block counter register: val=%d, dma mode = %i, period = %lf\n", val, ncr->dma_mode, ncr_dev->period); ncr_dev->block_count = val; ncr_dev->block_count_loaded = 1; - set_dma_enable(ncr_dev, ncr_dev->dma_enabled && ncr_dev->block_count_loaded); + if (ncr->mode & MODE_DMA) { + ncr_log("Start timer, buffer not ready = %02x\n", !(ncr_dev->status_ctrl & STATUS_BUFFER_NOT_READY)); + ncr_timer_on(ncr_dev, ncr, 0); + } + if (ncr_dev->status_ctrl & CTRL_DATA_DIR) { ncr_dev->buffer_host_pos = 128; ncr_dev->status_ctrl |= STATUS_BUFFER_NOT_READY; @@ -991,27 +987,131 @@ t130b_out(uint16_t port, uint8_t val, void *priv) } } +static void +ncr_dma_send(ncr5380_t *ncr_dev, ncr_t *ncr) +{ + scsi_device_t *dev = &scsi_devices[ncr->target_id]; + + int bus, c = 0; + uint8_t data; + + if (scsi_device_get_callback(dev) > 0.0) + ncr_timer_on(ncr_dev, ncr, 1); + + for (c = 0; c < 10; c++) { + ncr_bus_read(ncr_dev); + if (ncr->cur_bus & BUS_REQ) + break; + } + + if (c == 10) + return; + + /* Data ready. */ + data = ncr_dev->buffer[ncr_dev->buffer_pos]; + bus = get_bus_host(ncr) & ~BUS_DATAMASK; + bus |= BUS_SETDATA(data); + + ncr_bus_update(ncr_dev, bus | BUS_ACK); + ncr_bus_update(ncr_dev, bus & ~BUS_ACK); + + ncr_dev->buffer_pos++; + ncr_log("Buffer pos for writing = %d\n", ncr_dev->buffer_pos); + + if (ncr_dev->buffer_pos == 128) { + ncr_dev->buffer_pos = 0; + ncr_dev->buffer_host_pos = 0; + ncr_dev->status_ctrl &= ~STATUS_BUFFER_NOT_READY; + ncr_dev->ncr_busy = 0; + ncr_dev->block_count = (ncr_dev->block_count - 1) & 0xff; + ncr_log("Remaining blocks to be written=%d\n", ncr_dev->block_count); + if (!ncr_dev->block_count) { + ncr_dev->block_count_loaded = 0; + ncr_log("IO End of write transfer\n"); + ncr->tcr |= TCR_LAST_BYTE_SENT; + ncr->isr |= STATUS_END_OF_DMA; + timer_stop(&ncr_dev->timer); + if (ncr->mode & MODE_ENA_EOP_INT) { + ncr_log("NCR write irq\n"); + ncr_irq(ncr_dev, ncr, 1); + } + } + return; + } + ncr_dma_send(ncr_dev, ncr); +} + +static void +ncr_dma_initiator_receive(ncr5380_t *ncr_dev, ncr_t *ncr) +{ + scsi_device_t *dev = &scsi_devices[ncr->target_id]; + + int bus, c = 0; + uint8_t temp; + + if (scsi_device_get_callback(dev) > 0.0) + ncr_timer_on(ncr_dev, ncr, 1); + + for (c = 0; c < 10; c++) { + ncr_bus_read(ncr_dev); + if (ncr->cur_bus & BUS_REQ) + break; + } + + if (c == 10) + return; + + /* Data ready. */ + ncr_bus_read(ncr_dev); + temp = BUS_GETDATA(ncr->cur_bus); + + bus = get_bus_host(ncr); + + ncr_bus_update(ncr_dev, bus | BUS_ACK); + ncr_bus_update(ncr_dev, bus & ~BUS_ACK); + + ncr_dev->buffer[ncr_dev->buffer_pos++] = temp; + ncr_log("Buffer pos for reading = %d\n", ncr_dev->buffer_pos); + + if (ncr_dev->buffer_pos == 128) { + ncr_dev->buffer_pos = 0; + ncr_dev->buffer_host_pos = 0; + ncr_dev->status_ctrl &= ~STATUS_BUFFER_NOT_READY; + ncr_dev->block_count = (ncr_dev->block_count - 1) & 0xff; + ncr_log("Remaining blocks to be read=%d\n", ncr_dev->block_count); + if (!ncr_dev->block_count) { + ncr_dev->block_count_loaded = 0; + ncr_log("IO End of read transfer\n"); + ncr->isr |= STATUS_END_OF_DMA; + timer_stop(&ncr_dev->timer); + if (ncr->mode & MODE_ENA_EOP_INT) { + ncr_log("NCR read irq\n"); + ncr_irq(ncr_dev, ncr, 1); + } + } + return; + } + ncr_dma_initiator_receive(ncr_dev, ncr); +} static void ncr_callback(void *priv) { ncr5380_t *ncr_dev = (ncr5380_t *)priv; ncr_t *ncr = &ncr_dev->ncr; - int bus, c = 0; - uint8_t temp, data; + scsi_device_t *dev = &scsi_devices[ncr->target_id]; - ncr_log("DMA mode=%d\n", ncr->dma_mode); + ncr_log("DMA mode=%d, status ctrl = %02x\n", ncr->dma_mode, ncr_dev->status_ctrl); - if (ncr->data_wait & 1) - ncr->clear_req = 3; - - if (ncr->dma_mode != DMA_IDLE) - dma_timer_on(ncr_dev); + if (ncr->dma_mode != DMA_IDLE && (ncr->mode & MODE_DMA) && ncr_dev->block_count_loaded && scsi_device_get_callback(dev) <= 0.0) + timer_on_auto(&ncr_dev->timer, 10.0); if (ncr->data_wait & 1) { + ncr->clear_req = 3; ncr->data_wait &= ~1; - if (ncr->dma_mode == DMA_IDLE) + if (ncr->dma_mode == DMA_IDLE) { return; + } } switch(ncr->dma_mode) { @@ -1020,62 +1120,16 @@ ncr_callback(void *priv) ncr_log("DMA_SEND with DMA direction set wrong\n"); break; } - - ncr_log("Status for writing=%02x\n", ncr_dev->status_ctrl); - + if (!(ncr_dev->status_ctrl & STATUS_BUFFER_NOT_READY)) { - ncr_log("Buffer ready\n"); + ncr_log("Write buffer status ready\n"); break; } if (!ncr_dev->block_count_loaded) break; -write_start: - { - for (c = 0; c < 10; c++) { - ncr_bus_read(ncr_dev); - if (ncr->cur_bus & BUS_REQ) - break; - } - - if (c == 10) - break; - - /* Data ready. */ - data = ncr_dev->buffer[ncr_dev->buffer_pos]; - bus = get_bus_host(ncr) & ~BUS_DATAMASK; - bus |= BUS_SETDATA(data); - - ncr_bus_update(priv, bus | BUS_ACK); - ncr_bus_update(priv, bus & ~BUS_ACK); - - ncr_dev->buffer_pos++; - ncr_log("Buffer pos for writing = %d\n", ncr_dev->buffer_pos); - - if (ncr_dev->buffer_pos == 128) { - ncr_dev->buffer_pos = 0; - ncr_dev->buffer_host_pos = 0; - ncr_dev->status_ctrl &= ~STATUS_BUFFER_NOT_READY; - ncr_dev->ncr_busy = 0; - ncr_dev->block_count = (ncr_dev->block_count - 1) & 255; - ncr_log("Remaining blocks to be written=%d\n", ncr_dev->block_count); - if (!ncr_dev->block_count) { - ncr_dev->block_count_loaded = 0; - set_dma_enable(ncr_dev, 0); - ncr_log("IO End of write transfer\n"); - - ncr->tcr |= TCR_LAST_BYTE_SENT; - ncr->isr |= STATUS_END_OF_DMA; - if (ncr->mode & MODE_ENA_EOP_INT) { - ncr_log("NCR write irq\n"); - ncr_irq(ncr_dev, ncr, 1); - } - } - break; - } - goto write_start; - } + ncr_dma_send(ncr_dev, ncr); break; case DMA_INITIATOR_RECEIVE: @@ -1084,59 +1138,15 @@ write_start: break; } - ncr_log("Status for reading=%02x\n", ncr_dev->status_ctrl); - - if (!(ncr_dev->status_ctrl & STATUS_BUFFER_NOT_READY)) + if (!(ncr_dev->status_ctrl & STATUS_BUFFER_NOT_READY)) { + ncr_log("Read buffer status ready\n"); break; + } if (!ncr_dev->block_count_loaded) break; -read_start: - { - for (c = 0; c < 10; c++) { - ncr_bus_read(ncr_dev); - if (ncr->cur_bus & BUS_REQ) - break; - } - - if (c == 10) - break; - - /* Data ready. */ - ncr_bus_read(ncr_dev); - temp = BUS_GETDATA(ncr->cur_bus); - - bus = get_bus_host(ncr); - - ncr_bus_update(priv, bus | BUS_ACK); - ncr_bus_update(priv, bus & ~BUS_ACK); - - ncr_dev->buffer[ncr_dev->buffer_pos++] = temp; - - if (ncr_dev->buffer_pos == 128) { - ncr_dev->buffer_pos = 0; - ncr_dev->buffer_host_pos = 0; - ncr_dev->status_ctrl &= ~STATUS_BUFFER_NOT_READY; - ncr_dev->block_count = (ncr_dev->block_count - 1) & 255; - - ncr_log("Remaining blocks to be read=%d\n", ncr_dev->block_count); - - if (!ncr_dev->block_count) { - ncr_dev->block_count_loaded = 0; - set_dma_enable(ncr_dev, 0); - ncr_log("IO End of read transfer\n"); - - ncr->isr |= STATUS_END_OF_DMA; - if (ncr->mode & MODE_ENA_EOP_INT) { - ncr_log("NCR read irq\n"); - ncr_irq(ncr_dev, ncr, 1); - } - } - break; - } - goto read_start; - } + ncr_dma_initiator_receive(ncr_dev, ncr); break; } @@ -1146,7 +1156,7 @@ read_start: ncr_log("Updating DMA\n"); ncr->mode &= ~MODE_DMA; ncr->dma_mode = DMA_IDLE; - dma_changed(ncr_dev, ncr->dma_mode, ncr->mode & MODE_DMA); + timer_on_auto(&ncr_dev->timer, 10.0); } } From 17b5596494a405ffc47d5f3fee95bd9072b3ce56 Mon Sep 17 00:00:00 2001 From: TC1995 Date: Tue, 12 Jan 2021 12:52:00 +0100 Subject: [PATCH 07/15] Fixed the Compaq CGA crash upon initialization. --- src/video/vid_compaq_cga.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/video/vid_compaq_cga.c b/src/video/vid_compaq_cga.c index 95adeb81c..0a82bdee1 100644 --- a/src/video/vid_compaq_cga.c +++ b/src/video/vid_compaq_cga.c @@ -324,10 +324,10 @@ compaq_cga_poll(void *p) ys_temp = (self->cga.lastline - self->cga.firstline); if ((xs_temp > 0) && (ys_temp > 0)) { - if (xsize < 64) xs_temp = 656; - if (ysize < 32) ys_temp = 400; + if (xs_temp < 64) xs_temp = 656; + if (ys_temp < 32) ys_temp = 400; if (!enable_overscan) - xsize -= 16; + xs_temp -= 16; if ((self->cga.cgamode & 8) && ((xs_temp != xsize) || (ys_temp != ysize) || video_force_resize_get())) { xsize = xs_temp; @@ -340,14 +340,14 @@ compaq_cga_poll(void *p) if (enable_overscan) { if (self->cga.composite) - video_blit_memtoscreen(0, self->cga.firstline - 8, 0, ysize + 16, xsize + 16, ysize + 16); + video_blit_memtoscreen(0, self->cga.firstline - 8, 0, (self->cga.lastline - self->cga.firstline) + 16, xsize, (self->cga.lastline - self->cga.firstline) + 16); else - video_blit_memtoscreen_8(0, self->cga.firstline - 8, 0, ysize + 16, xsize + 16, ysize + 16); + video_blit_memtoscreen_8(0, self->cga.firstline - 8, 0, (self->cga.lastline - self->cga.firstline) + 16, xsize, (self->cga.lastline - self->cga.firstline) + 16); } else { if (self->cga.composite) - video_blit_memtoscreen(8, self->cga.firstline, 0, ysize, xsize, ysize); + video_blit_memtoscreen(8, self->cga.firstline, 0, self->cga.lastline - self->cga.firstline, xsize, self->cga.lastline - self->cga.firstline); else - video_blit_memtoscreen_8(8, self->cga.firstline, 0, ysize, xsize, ysize); + video_blit_memtoscreen_8(8, self->cga.firstline, 0, self->cga.lastline - self->cga.firstline, xsize, self->cga.lastline - self->cga.firstline); } } From c97434b48229deb82d49514ba410f45fa1e58e50 Mon Sep 17 00:00:00 2001 From: TC1995 Date: Tue, 12 Jan 2021 13:05:26 +0100 Subject: [PATCH 08/15] Fixed the Racal EtherBlaster nic. --- src/network/net_pcnet.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/network/net_pcnet.c b/src/network/net_pcnet.c index 73f1c01b0..478a51282 100644 --- a/src/network/net_pcnet.c +++ b/src/network/net_pcnet.c @@ -2264,6 +2264,26 @@ pcnet_word_write(nic_t *dev, uint32_t addr, uint16_t val) } } +static uint8_t +pcnet_byte_read(nic_t *dev, uint32_t addr) +{ + uint8_t val = 0xff; + + if (!BCR_DWIO(dev)) { + switch (addr & 0x0f) { + case 0x04: + pcnetSoftReset(dev); + val = 0; + break; + } + } + + pcnetUpdateIrq(dev); + + pcnetlog(3, "%s: pcnet_word_read: addr = %04x, val = %04x, DWIO not set = %04x\n", dev->name, addr & 0x0f, val, !BCR_DWIO(dev)); + + return(val); +} static uint16_t pcnet_word_read(nic_t *dev, uint32_t addr) @@ -2449,7 +2469,9 @@ pcnet_read(nic_t *dev, uint32_t addr, int len) (pcnet_aprom_readb(dev, addr + 2) << 16) | (pcnet_aprom_readb(dev, addr + 3) << 24); } } else { - if (len == 2) + if (len == 1) + retval = pcnet_byte_read(dev, addr); + else if (len == 2) retval = pcnet_word_read(dev, addr); else if (len == 4) retval = pcnet_dword_read(dev, addr); From 765a328365993640d0ea1489e9bf38f9ee974a7f Mon Sep 17 00:00:00 2001 From: TC1995 Date: Tue, 12 Jan 2021 16:31:55 +0100 Subject: [PATCH 09/15] Fixed Printer and Serial configurations on the PS/1 2011/2121 models and PS/2 model 30. --- src/machine/m_ps1.c | 53 ++++++++++++++++++++--------------------- src/machine/m_ps2_isa.c | 49 ++++++++++++++++++++----------------- 2 files changed, 53 insertions(+), 49 deletions(-) diff --git a/src/machine/m_ps1.c b/src/machine/m_ps1.c index ccad28139..350e15e70 100644 --- a/src/machine/m_ps1.c +++ b/src/machine/m_ps1.c @@ -326,25 +326,31 @@ ps1_write(uint16_t port, uint8_t val, void *priv) break; case 0x0102: - lpt1_remove(); - if (val & 0x04) - serial_setup(ps->uart, SERIAL1_ADDR, SERIAL1_IRQ); - else + if (!(ps->ps1_94 & 0x80)) { + lpt1_remove(); serial_remove(ps->uart); - if (val & 0x10) { - switch ((val >> 5) & 3) { - case 0: - lpt1_init(0x03bc); - break; - case 1: - lpt1_init(0x0378); - break; - case 2: - lpt1_init(0x0278); - break; + if (val & 0x04) { + if (val & 0x08) + serial_setup(ps->uart, SERIAL1_ADDR, SERIAL1_IRQ); + else + serial_setup(ps->uart, SERIAL2_ADDR, SERIAL2_IRQ); } + if (val & 0x10) { + switch ((val >> 5) & 3) + { + case 0: + lpt1_init(0x3bc); + break; + case 1: + lpt1_init(0x378); + break; + case 2: + lpt1_init(0x278); + break; + } + } + ps->ps1_102 = val; } - ps->ps1_102 = val; break; case 0x0103: @@ -469,17 +475,16 @@ ps1_setup(int model) ps1_hdc_inform(priv, &ps->ps1_91); } - } - - if (model == 2121) { + + /* Enable the PS/1 VGA controller. */ + device_add(&ps1vga_device); + } else if (model == 2121) { io_sethandler(0x00e0, 2, ps1_read, NULL, NULL, ps1_write, NULL, NULL, ps); -#if 0 rom_init(&ps->high_rom, L"roms/machines/ibmps1_2121/fc0000.bin", 0xfc0000, 0x20000, 0x1ffff, 0, MEM_MAPPING_EXTERNAL); -#endif /* Initialize the video controller. */ if (gfxcard == VID_INTERNAL) @@ -491,12 +496,6 @@ ps1_setup(int model) device_add(&snd_device); } - - /* Enable the PS/1 VGA controller. */ - if (model == 2011) - device_add(&ps1vga_device); - else if (model == 2021) - device_add(&ibm_ps1_2121_device); } static void diff --git a/src/machine/m_ps2_isa.c b/src/machine/m_ps2_isa.c index 226a3eda4..604841b5a 100644 --- a/src/machine/m_ps2_isa.c +++ b/src/machine/m_ps2_isa.c @@ -84,28 +84,33 @@ static void ps2_write(uint16_t port, uint8_t val, void *p) ps2_94 = val; break; case 0x102: - lpt1_remove(); - if (val & 0x04) - serial_setup(ps2_uart, SERIAL1_ADDR, SERIAL1_IRQ); - else - serial_remove(ps2_uart); - if (val & 0x10) - { - switch ((val >> 5) & 3) - { - case 0: - lpt1_init(0x3bc); - break; - case 1: - lpt1_init(0x378); - break; - case 2: - lpt1_init(0x278); - break; - } - } - ps2_102 = val; - break; + if (!(ps2_94 & 0x80)) { + lpt1_remove(); + serial_remove(ps2_uart); + if (val & 0x04) { + if (val & 0x08) + serial_setup(ps2_uart, SERIAL1_ADDR, SERIAL1_IRQ); + else + serial_setup(ps2_uart, SERIAL2_ADDR, SERIAL2_IRQ); + } + if (val & 0x10) { + switch ((val >> 5) & 3) + { + case 0: + lpt1_init(0x3bc); + break; + case 1: + lpt1_init(0x378); + break; + case 2: + lpt1_init(0x278); + break; + } + } + ps2_102 = val; + } + break; + case 0x103: ps2_103 = val; break; From 4a87af237a3893f26c484488aaf5044c32d2965b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hrdli=C4=8Dka?= Date: Tue, 12 Jan 2021 17:06:05 +0100 Subject: [PATCH 10/15] Change `mo_format` to upstream original --- src/disk/mo.c | 68 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 46 insertions(+), 22 deletions(-) diff --git a/src/disk/mo.c b/src/disk/mo.c index 13715947a..bdb5d2824 100644 --- a/src/disk/mo.c +++ b/src/disk/mo.c @@ -15,14 +15,15 @@ * Miran Grca, * Fred N. van Kempen, * - * Copyright 2020 Miran Grca. + * Copyright 2020,2021 Natalia Portillo. + * Copyright 2020,2021 Miran Grca. + * Copyright 2020,2021 Fred N. van Kempen */ #include #include #include #include #include -#include #include #define HAVE_STDARG_H #include <86box/86box.h> @@ -43,7 +44,7 @@ #include #include #else -#include +#include #endif mo_drive_t mo_drives[MO_NUM]; @@ -1040,46 +1041,69 @@ mo_insert(mo_t *dev) void mo_format(mo_t *dev) { - unsigned long size; + long size; int ret; - int fd = fileno(dev->drv->f); - int64_t liSize = 0; + int fd; mo_log("MO %i: Formatting media...\n", dev->id); - if (fd == -1) { - mo_log("MO %i: Failed to get file descriptor.\n", dev->id); - return; - } - fseek(dev->drv->f, 0, SEEK_END); - size = (uint32_t) ftello64(dev->drv->f); + size = ftell(dev->drv->f); - errno = 0; - rewind(dev->drv->f); +#ifdef _WIN32 + HANDLE fh; + LARGE_INTEGER liSize; - if (errno) { + fd = _fileno(dev->drv->f); + fh = (HANDLE)_get_osfhandle(fd); + + liSize.QuadPart = 0; + + ret = (int)SetFilePointerEx(fh, liSize, NULL, FILE_BEGIN); + + if(!ret) { mo_log("MO %i: Failed seek to start of image file\n", dev->id); return; } - ret = ftruncate(fd, 0); - if (ret == -1) { + ret = (int)SetEndOfFile(fh); + + if(!ret) { mo_log("MO %i: Failed to truncate image file to 0\n", dev->id); return; } - liSize = size; - ret = fseek(dev->drv->f, 0, SEEK_END); - if (ret == -1) { + liSize.QuadPart = size; + ret = (int)SetFilePointerEx(fh, liSize, NULL, FILE_BEGIN); + + if(!ret) { mo_log("MO %i: Failed seek to end of image file\n", dev->id); return; } - ret = ftruncate(fd, liSize); - if (ret == -1) { + + ret = (int)SetEndOfFile(fh); + + if(!ret) { mo_log("MO %i: Failed to truncate image file to %llu\n", dev->id, size); return; } +#else + fd = fileno(dev->drv->f); + + ret = ftruncate(fd, 0); + + if(ret) { + mo_log("MO %i: Failed to truncate image file to 0\n", dev->id); + return; + } + + ret = ftruncate(fd, size); + + if(ret) { + mo_log("MO %i: Failed to truncate image file to %llu", dev->id, size); + return; + } +#endif } static int From 11b6604196e9794a6d44e89fab84aecdf1cb3d58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hrdli=C4=8Dka?= Date: Tue, 12 Jan 2021 18:22:40 +0100 Subject: [PATCH 11/15] Add CMake build files --- CMakeLists.txt | 52 +++++++ cmake/TargetArch.cmake | 141 ++++++++++++++++++ src/CMakeLists.txt | 94 ++++++++++++ src/cdrom/CMakeLists.txt | 1 + src/chipset/CMakeLists.txt | 18 +++ src/codegen/CMakeLists.txt | 17 +++ src/codegen_new/CMakeLists.txt | 37 +++++ src/cpu/CMakeLists.txt | 17 +++ src/device/CMakeLists.txt | 9 ++ src/disk/CMakeLists.txt | 10 ++ src/disk/minivhd/CMakeLists.txt | 3 + src/floppy/CMakeLists.txt | 2 + src/game/CMakeLists.txt | 2 + src/include/86box/version.h.in | 31 ++++ src/{include => include_make}/86box/version.h | 2 +- src/machine/CMakeLists.txt | 48 ++++++ src/mem/CMakeLists.txt | 2 + src/network/CMakeLists.txt | 5 + src/network/slirp/CMakeLists.txt | 5 + src/printer/CMakeLists.txt | 1 + src/scsi/CMakeLists.txt | 3 + src/sio/CMakeLists.txt | 9 ++ src/sound/CMakeLists.txt | 30 ++++ src/sound/munt/CMakeLists.txt | 11 ++ src/sound/resid-fp/CMakeLists.txt | 4 + src/video/CMakeLists.txt | 40 +++++ src/win/86Box.rc | 94 ++++++------ src/win/CMakeLists.txt | 33 ++++ src/win/Makefile.mingw | 4 +- 29 files changed, 679 insertions(+), 46 deletions(-) create mode 100644 CMakeLists.txt create mode 100644 cmake/TargetArch.cmake create mode 100644 src/CMakeLists.txt create mode 100644 src/cdrom/CMakeLists.txt create mode 100644 src/chipset/CMakeLists.txt create mode 100644 src/codegen/CMakeLists.txt create mode 100644 src/codegen_new/CMakeLists.txt create mode 100644 src/cpu/CMakeLists.txt create mode 100644 src/device/CMakeLists.txt create mode 100644 src/disk/CMakeLists.txt create mode 100644 src/disk/minivhd/CMakeLists.txt create mode 100644 src/floppy/CMakeLists.txt create mode 100644 src/game/CMakeLists.txt create mode 100644 src/include/86box/version.h.in rename src/{include => include_make}/86box/version.h (93%) create mode 100644 src/machine/CMakeLists.txt create mode 100644 src/mem/CMakeLists.txt create mode 100644 src/network/CMakeLists.txt create mode 100644 src/network/slirp/CMakeLists.txt create mode 100644 src/printer/CMakeLists.txt create mode 100644 src/scsi/CMakeLists.txt create mode 100644 src/sio/CMakeLists.txt create mode 100644 src/sound/CMakeLists.txt create mode 100644 src/sound/munt/CMakeLists.txt create mode 100644 src/sound/resid-fp/CMakeLists.txt create mode 100644 src/video/CMakeLists.txt create mode 100644 src/win/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..37b44585f --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,52 @@ +cmake_minimum_required(VERSION 3.16) + +project(86Box + VERSION 2.10 + DESCRIPTION "Emulator of x86-based systems" + HOMEPAGE_URL "https://86box.github.io/" + LANGUAGES C CXX) + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +include(TargetArch) +target_architecture(CMAKE_TARGET_ARCHITECTURES) + +include(CMakeDependentOption) + +add_compile_definitions(CMAKE) + +option(RELEASE "Release build" OFF) +option(USB "USB support" OFF) +option(DYNAREC "Dynamic recompiler" ON) +option(FLUIDSYNTH "FluidSynth" ON) +option(MUNT "MUNT" ON) +option(VRAMDUMP "Video RAM dumping" OFF) +option(DINPUT "DirectInput" OFF) +option(DISCORD "Discord integration" ON) + +option(NEW_DYNAREC "Use the PCem v15 (\"new\") dynamic recompiler" OFF) + +option(DEV_BRANCH "Development branch" OFF) +CMAKE_DEPENDENT_OPTION(AMD_K5 "AMD K5" ON "DEV_BRANCH" OFF) +CMAKE_DEPENDENT_OPTION(CL5422 "Cirrus Logic CL-GD 5402/5420/5422" ON "DEV_BRANCH" OFF) +CMAKE_DEPENDENT_OPTION(CYRIX_6X86 "Cyrix 6x86" ON "DEV_BRANCH" OFF) +CMAKE_DEPENDENT_OPTION(GUSMAX "Gravis UltraSound MAX" ON "DEV_BRANCH" OFF) +CMAKE_DEPENDENT_OPTION(HEDAKA "Hedaka HED-919" ON "DEV_BRANCH" OFF) +CMAKE_DEPENDENT_OPTION(LASERXT "VTech Laser XT" ON "DEV_BRANCH" OFF) +CMAKE_DEPENDENT_OPTION(MGA "Matrox Mystique graphics adapters" ON "DEV_BRANCH" OFF) +CMAKE_DEPENDENT_OPTION(NO_SIO "Machines without emulated Super I/O chips" ON "DEV_BRANCH" OFF) +CMAKE_DEPENDENT_OPTION(OPEN_AT "OpenAT" ON "DEV_BRANCH" OFF) +CMAKE_DEPENDENT_OPTION(PAS16 "Pro Audio Spectrum 16" OFF "DEV_BRANCH" OFF) +CMAKE_DEPENDENT_OPTION(PS1M2133 "IBM PS/1 model 2133" ON "DEV_BRANCH" OFF) +CMAKE_DEPENDENT_OPTION(PS2M70T4 "IBM PS/2 model 70 (type 4)" ON "DEV_BRANCH" OFF) +CMAKE_DEPENDENT_OPTION(S3TRIO3D2X "S3 Trio3D/2X" ON "DEV_BRANCH" OFF) +CMAKE_DEPENDENT_OPTION(SIO_DETECT "Super I/O Detection Helper" ON "DEV_BRANCH" OFF) +CMAKE_DEPENDENT_OPTION(STPC "STPC machines" ON "DEV_BRANCH" OFF) +CMAKE_DEPENDENT_OPTION(M1489 "ALi M1489" ON "DEV_BRANCH" OFF) +CMAKE_DEPENDENT_OPTION(M6117 "ALi M6117" ON "DEV_BRANCH" OFF) +CMAKE_DEPENDENT_OPTION(VGAWONDER "ATI VGA Wonder (ATI-18800)" ON "DEV_BRANCH" OFF) +CMAKE_DEPENDENT_OPTION(VNC "VNC renderer" ON "DEV_BRANCH" OFF) +CMAKE_DEPENDENT_OPTION(XL24 "ATI VGA Wonder XL24 (ATI-28800-6)" ON "DEV_BRANCH" OFF) +CMAKE_DEPENDENT_OPTION(VECT486VL "HP Vectra 486VL" ON "DEV_BRANCH" OFF) +CMAKE_DEPENDENT_OPTION(DELLS4 "Dell Dimension XPS P60; Dell OptiPlex 560/L" ON "DEV_BRANCH" OFF) + +add_subdirectory(src) diff --git a/cmake/TargetArch.cmake b/cmake/TargetArch.cmake new file mode 100644 index 000000000..c8eb27735 --- /dev/null +++ b/cmake/TargetArch.cmake @@ -0,0 +1,141 @@ +# Based on the Qt 5 processor detection code, so should be very accurate +# https://qt.gitorious.org/qt/qtbase/blobs/master/src/corelib/global/qprocessordetection.h +# Currently handles arm (v5, v6, v7, v8), x86 (32/64), ia64, and ppc (32/64) + +# Regarding POWER/PowerPC, just as is noted in the Qt source, +# "There are many more known variants/revisions that we do not handle/detect." + +set(archdetect_c_code " +#if defined(__arm__) || defined(__TARGET_ARCH_ARM) || defined(_M_ARM) || defined(_M_ARM64) + #if defined(__ARM64_ARCH_8__) \\ + || defined(__aarch64__) \\ + || defined(__ARMv8__) \\ + || defined(__ARMv8_A__) \\ + || (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 8) \\ + || (defined(_M_ARM64) && _M_ARM64 >= 1) + #error cmake_ARCH armv8 + #elif defined(__ARM_ARCH_7__) \\ + || defined(__ARM_ARCH_7A__) \\ + || defined(__ARM_ARCH_7R__) \\ + || defined(__ARM_ARCH_7M__) \\ + || (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 7) \\ + || (defined(_M_ARM) && _M_ARM >= 7) + #error cmake_ARCH armv7 + #elif defined(__ARM_ARCH_6__) \\ + || defined(__ARM_ARCH_6J__) \\ + || defined(__ARM_ARCH_6T2__) \\ + || defined(__ARM_ARCH_6Z__) \\ + || defined(__ARM_ARCH_6K__) \\ + || defined(__ARM_ARCH_6ZK__) \\ + || defined(__ARM_ARCH_6M__) \\ + || (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 6) + #error cmake_ARCH armv6 + #elif defined(__ARM_ARCH_5TEJ__) \\ + || (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 5) + #error cmake_ARCH armv5 + #else + #error cmake_ARCH arm + #endif +#elif defined(__i386) || defined(__i386__) || defined(_M_IX86) + #error cmake_ARCH i386 +#elif defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(_M_X64) + #error cmake_ARCH x86_64 +#elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64) + #error cmake_ARCH ia64 +#elif defined(__ppc__) || defined(__ppc) || defined(__powerpc__) \\ + || defined(_ARCH_COM) || defined(_ARCH_PWR) || defined(_ARCH_PPC) \\ + || defined(_M_MPPC) || defined(_M_PPC) + #if defined(__ppc64__) || defined(__powerpc64__) || defined(__64BIT__) + #error cmake_ARCH ppc64 + #else + #error cmake_ARCH ppc + #endif +#endif +#error cmake_ARCH unknown +") + +# Set ppc_support to TRUE before including this file or ppc and ppc64 +# will be treated as invalid architectures since they are no longer supported by Apple + +function(target_architecture output_var) + if(APPLE AND CMAKE_OSX_ARCHITECTURES) + # On OS X we use CMAKE_OSX_ARCHITECTURES *if* it was set + # First let's normalize the order of the values + + # Note that it's not possible to compile PowerPC applications if you are using + # the OS X SDK version 10.6 or later - you'll need 10.4/10.5 for that, so we + # disable it by default + # See this page for more information: + # http://stackoverflow.com/questions/5333490/how-can-we-restore-ppc-ppc64-as-well-as-full-10-4-10-5-sdk-support-to-xcode-4 + + # Architecture defaults to i386 or ppc on OS X 10.5 and earlier, depending on the CPU type detected at runtime. + # On OS X 10.6+ the default is x86_64 if the CPU supports it, i386 otherwise. + + foreach(osx_arch ${CMAKE_OSX_ARCHITECTURES}) + if("${osx_arch}" STREQUAL "ppc" AND ppc_support) + set(osx_arch_ppc TRUE) + elseif("${osx_arch}" STREQUAL "i386") + set(osx_arch_i386 TRUE) + elseif("${osx_arch}" STREQUAL "x86_64") + set(osx_arch_x86_64 TRUE) + elseif("${osx_arch}" STREQUAL "ppc64" AND ppc_support) + set(osx_arch_ppc64 TRUE) + else() + message(FATAL_ERROR "Invalid OS X arch name: ${osx_arch}") + endif() + endforeach() + + # Now add all the architectures in our normalized order + if(osx_arch_ppc) + list(APPEND ARCH ppc) + endif() + + if(osx_arch_i386) + list(APPEND ARCH i386) + endif() + + if(osx_arch_x86_64) + list(APPEND ARCH x86_64) + endif() + + if(osx_arch_ppc64) + list(APPEND ARCH ppc64) + endif() + else() + file(WRITE "${CMAKE_BINARY_DIR}/arch.c" "${archdetect_c_code}") + + enable_language(C) + + # Detect the architecture in a rather creative way... + # This compiles a small C program which is a series of ifdefs that selects a + # particular #error preprocessor directive whose message string contains the + # target architecture. The program will always fail to compile (both because + # file is not a valid C program, and obviously because of the presence of the + # #error preprocessor directives... but by exploiting the preprocessor in this + # way, we can detect the correct target architecture even when cross-compiling, + # since the program itself never needs to be run (only the compiler/preprocessor) + try_run( + run_result_unused + compile_result_unused + "${CMAKE_BINARY_DIR}" + "${CMAKE_BINARY_DIR}/arch.c" + COMPILE_OUTPUT_VARIABLE ARCH + CMAKE_FLAGS CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} + ) + + # Parse the architecture name from the compiler output + string(REGEX MATCH "cmake_ARCH ([a-zA-Z0-9_]+)" ARCH "${ARCH}") + + # Get rid of the value marker leaving just the architecture name + string(REPLACE "cmake_ARCH " "" ARCH "${ARCH}") + + # If we are compiling with an unknown architecture this variable should + # already be set to "unknown" but in the case that it's empty (i.e. due + # to a typo in the code), then set it to unknown + if (NOT ARCH) + set(ARCH unknown) + endif() + endif() + + set(${output_var} "${ARCH}" PARENT_SCOPE) +endfunction() \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 000000000..18ce46481 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,94 @@ +# WIN32 marks us as a GUI app on Windows +add_executable(86Box WIN32 pc.c config.c random.c timer.c io.c acpi.c apm.c + dma.c ddma.c nmi.c pic.c pit.c port_92.c ppi.c pci.c mca.c usb.c + device.c nvr.c nvr_at.c nvr_ps2.c) + +if(NEW_DYNAREC) + add_compile_definitions(USE_NEW_DYNAREC) +endif() + +if(RELEASE) + add_compile_definitions(RELEASE_BUILD) +endif() + +if(DYNAREC) + add_compile_definitions(USE_DYNAREC) +endif() + +if(VRAMDUMP) + add_compile_definitions(ENABLE_VRAM_DUMP) +endif() + +if(DEV_BRANCH) + add_compile_definitions(DEV_BRANCH) +endif() + +if(VNC) + add_compile_definitions(USE_VNC) + add_library(vnc OBJECT vnc.c vnc_keymap.c) + target_link_libraries(86Box vnc vncserver ws2_32) +endif() + +if(STPC) + add_compile_definitions(USE_STPC) +endif() + +target_link_libraries(86Box cpu chipset mch dev mem fdd game cdrom zip mo hdd + net print scsi sio snd vid plat ui) + +find_package(Freetype REQUIRED) +include_directories(${FREETYPE_INCLUDE_DIRS}) + +find_package(OpenAL CONFIG REQUIRED) +include_directories(${OPENAL_INCLUDE_DIRS}) +target_link_libraries(86Box OpenAL::OpenAL) + +find_package(SDL2 CONFIG REQUIRED) +include_directories(${SDL2_INCLUDE_DIRS}) +target_link_libraries(86Box SDL2::SDL2) + +find_package(PNG REQUIRED) +include_directories(${PNG_INCLUDE_DIRS}) +target_link_libraries(86Box PNG::PNG) + +if(CMAKE_TARGET_ARCHITECTURES STREQUAL "i386") + if(MSVC) + set_target_properties(86Box PROPERTIES LINK_FLAGS "/LARGEADDRESSAWARE") + elseif(MINGW) + set_target_properties(86Box PROPERTIES LINK_FLAGS "-Wl,--large-address-aware") + endif() +endif() + +configure_file(include/86box/version.h.in include/86box/version.h @ONLY) +include_directories(${CMAKE_CURRENT_BINARY_DIR}/include) + +include_directories(include) +if(NEW_DYNAREC) + include_directories(cpu codegen_new) +else() + include_directories(cpu codegen) +endif() + +add_subdirectory(cdrom) +add_subdirectory(chipset) + +add_subdirectory(cpu) +if(NEW_DYNAREC) + add_subdirectory(codegen_new) +else() + add_subdirectory(codegen) +endif() + +add_subdirectory(device) +add_subdirectory(disk) +add_subdirectory(floppy) +add_subdirectory(game) +add_subdirectory(machine) +add_subdirectory(mem) +add_subdirectory(network) +add_subdirectory(printer) +add_subdirectory(sio) +add_subdirectory(scsi) +add_subdirectory(sound) +add_subdirectory(video) +add_subdirectory(win) \ No newline at end of file diff --git a/src/cdrom/CMakeLists.txt b/src/cdrom/CMakeLists.txt new file mode 100644 index 000000000..2756e0be8 --- /dev/null +++ b/src/cdrom/CMakeLists.txt @@ -0,0 +1 @@ +add_library(cdrom OBJECT cdrom.c cdrom_image_backend.c cdrom_image.c) \ No newline at end of file diff --git a/src/chipset/CMakeLists.txt b/src/chipset/CMakeLists.txt new file mode 100644 index 000000000..9b6d78a30 --- /dev/null +++ b/src/chipset/CMakeLists.txt @@ -0,0 +1,18 @@ +add_library(chipset OBJECT acc2168.c cs8230.c ali1429.c headland.c intel_82335.c + cs4031.c intel_420ex.c intel_4x0.c intel_sio.c intel_piix.c ../ioapic.c + neat.c opti495.c opti895.c opti5x7.c scamp.c scat.c via_vt82c49x.c + via_vt82c505.c sis_85c310.c sis_85c4xx.c sis_85c496.c sis_85c50x.c + opti283.c opti291.c umc491.c via_apollo.c via_pipc.c wd76c10.c + vl82c480.c) + +if(STPC) + target_sources(chipset PRIVATE stpc.c) +endif() + +if(M1489) + target_sources(chipset PRIVATE ali1489.c) +endif() + +if(M6117) + target_sources(chipset PRIVATE ali6117.c) +endif() \ No newline at end of file diff --git a/src/codegen/CMakeLists.txt b/src/codegen/CMakeLists.txt new file mode 100644 index 000000000..040f2deab --- /dev/null +++ b/src/codegen/CMakeLists.txt @@ -0,0 +1,17 @@ +if(DYNAREC) + add_library(dynarec OBJECT codegen.c codegen_ops.c) + + if(CMAKE_TARGET_ARCHITECTURES STREQUAL "i386") + target_sources(dynarec PRIVATE codegen_x86.c + codegen_accumulate_x86.c) + elseif(CMAKE_TARGET_ARCHITECTURES STREQUAL "x86_64") + target_sources(dynarec PRIVATE codegen_x86-64.c + codegen_accumulate_x86-64.c) + else() + message(SEND_ERROR + "Dynarec is incompatible with target platform " + ${CMAKE_TARGET_ARCHITECTURES}) + endif() + + target_link_libraries(86Box dynarec cgt) +endif() \ No newline at end of file diff --git a/src/codegen_new/CMakeLists.txt b/src/codegen_new/CMakeLists.txt new file mode 100644 index 000000000..a560c4581 --- /dev/null +++ b/src/codegen_new/CMakeLists.txt @@ -0,0 +1,37 @@ +if(DYNAREC) + add_library(dynarec OBJECT codegen.c codegen_accumulate.c + codegen_allocator.c codegen_block.c codegen_ir.c codegen_ops.c + codegen_ops_3dnow.c codegen_ops_branch.c codegen_ops_arith.c + codegen_ops_fpu_arith.c codegen_ops_fpu_constant.c + codegen_ops_fpu_loadstore.c codegen_ops_fpu_misc.c + codegen_ops_helpers.c codegen_ops_jump.c codegen_ops_logic.c + codegen_ops_misc.c codegen_ops_mmx_arith.c codegen_ops_mmx_cmp.c + codegen_ops_mmx_loadstore.c codegen_ops_mmx_logic.c + codegen_ops_mmx_pack.c codegen_ops_mmx_shift.c codegen_ops_mov.c + codegen_ops_shift.c codegen_ops_stack.c codegen_reg.c) + + if(CMAKE_TARGET_ARCHITECTURES STREQUAL "i386") + target_sources(dynarec PRIVATE codegen_backend_x86.c + codegen_backend_x86_ops.c codegen_backend_x86_ops_fpu.c + codegen_backend_x86_ops_sse.c + codegen_backend_x86_uops.c) + elseif(CMAKE_TARGET_ARCHITECTURES STREQUAL "x86_64") + target_sources(dynarec PRIVATE codegen_backend_x86-64.c + codegen_backend_x86-64_ops.c + codegen_backend_x86-64_ops_sse.c + codegen_backend_x86-64_uops.c) + elseif(CMAKE_TARGET_ARCHITECTURES STREQUAL "armv8") + target_sources(dynarec PRIVATE codegen_backend_arm64.c + codegen_backend_arm64_ops.c codegen_backend_arm64_uops.c + codegen_backend_arm64_imm.c) + elseif(CMAKE_TARGET_ARCHITECTURES MATCHES "arm") + target_sources(dynarec PRIVATE codegen_backend_arm.c + codegen_backend_arm_ops.c codegen_backend_arm_uops.c) + else() + message(SEND_ERROR + "Dynarec is incompatible with target platform " + ${CMAKE_TARGET_ARCHITECTURES}) + endif() + + target_link_libraries(86Box dynarec cgt) +endif() \ No newline at end of file diff --git a/src/cpu/CMakeLists.txt b/src/cpu/CMakeLists.txt new file mode 100644 index 000000000..4c5c6d53e --- /dev/null +++ b/src/cpu/CMakeLists.txt @@ -0,0 +1,17 @@ +add_library(cpu OBJECT cpu.c cpu_table.c 808x.c 386.c 386_common.c 386_dynarec.c + 386_dynarec_ops.c x86seg.c x87.c x87_timings.c) + +if(AMD_K5) + target_compile_definitions(cpu PRIVATE USE_AMD_K5) +endif() + +if(CYRIX_6X86) + target_compile_definitions(cpu PRIVATE USE_CYRIX_6X86) +endif() + +if(DYNAREC) + add_library(cgt OBJECT codegen_timing_486.c codegen_timing_686.c + codegen_timing_common.c codegen_timing_k6.c + codegen_timing_pentium.c codegen_timing_p6.c + codegen_timing_winchip.c codegen_timing_winchip2.c) +endif() \ No newline at end of file diff --git a/src/device/CMakeLists.txt b/src/device/CMakeLists.txt new file mode 100644 index 000000000..9460b5b88 --- /dev/null +++ b/src/device/CMakeLists.txt @@ -0,0 +1,9 @@ +add_library(dev OBJECT bugger.c hwm.c hwm_lm75.c hwm_lm78.c hwm_gl518sm.c + hwm_vt82c686.c ibm_5161.c isamem.c isartc.c ../lpt.c pci_bridge.c + postcard.c serial.c vpc2007.c clock_ics9xxx.c i2c.c i2c_gpio.c + smbus_piix4.c keyboard.c keyboard_xt.c keyboard_at.c mouse.c mouse_bus.c + mouse_serial.c mouse_ps2.c phoenix_486_jumper.c) + +if(LASERXT) + target_compile_definitions(dev PRIVATE USE_LASERXT) +endif() \ No newline at end of file diff --git a/src/disk/CMakeLists.txt b/src/disk/CMakeLists.txt new file mode 100644 index 000000000..2a31f56d2 --- /dev/null +++ b/src/disk/CMakeLists.txt @@ -0,0 +1,10 @@ +add_library(hdd OBJECT hdd.c hdd_image.c hdd_table.c hdc.c hdc_st506_xt.c + hdc_st506_at.c hdc_xta.c hdc_esdi_at.c hdc_esdi_mca.c hdc_xtide.c + hdc_ide.c hdc_ide_opti611.c hdc_ide_cmd640.c hdc_ide_sff8038i.c) + +add_library(zip OBJECT zip.c) + +add_library(mo OBJECT mo.c) + +add_subdirectory(minivhd) +target_link_libraries(86Box minivhd) \ No newline at end of file diff --git a/src/disk/minivhd/CMakeLists.txt b/src/disk/minivhd/CMakeLists.txt new file mode 100644 index 000000000..0d346da17 --- /dev/null +++ b/src/disk/minivhd/CMakeLists.txt @@ -0,0 +1,3 @@ +add_library(minivhd STATIC cwalk.c libxml2_encoding.c minivhd_convert.c + minivhd_create.c minivhd_io.c minivhd_manage.c minivhd_struct_rw.c + minivhd_util.c) \ No newline at end of file diff --git a/src/floppy/CMakeLists.txt b/src/floppy/CMakeLists.txt new file mode 100644 index 000000000..60b2893f3 --- /dev/null +++ b/src/floppy/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(fdd OBJECT fdd.c fdc.c fdc_pii15xb.c fdi2raw.c fdd_common.c + fdd_86f.c fdd_fdi.c fdd_imd.c fdd_img.c fdd_json.c fdd_mfm.c fdd_td0.c) \ No newline at end of file diff --git a/src/game/CMakeLists.txt b/src/game/CMakeLists.txt new file mode 100644 index 000000000..b38921770 --- /dev/null +++ b/src/game/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(game OBJECT gameport.c joystick_standard.c + joystick_ch_flightstick_pro.c joystick_sw_pad.c joystick_tm_fcs.c) \ No newline at end of file diff --git a/src/include/86box/version.h.in b/src/include/86box/version.h.in new file mode 100644 index 000000000..67832258d --- /dev/null +++ b/src/include/86box/version.h.in @@ -0,0 +1,31 @@ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * Definitions for project version, branding, and external links. + * + * Authors: Miran Grca, + * + * Copyright 2020 Miran Grca. + */ + +/* Version info. */ +#define EMU_NAME "@CMAKE_PROJECT_NAME@" +#define EMU_NAME_W L"@CMAKE_PROJECT_NAME@" + +#define EMU_VERSION "@CMAKE_PROJECT_VERSION@" +#define EMU_VERSION_W L"@CMAKE_PROJECT_VERSION@" +#define EMU_VERSION_EX "@CMAKE_PROJECT_VERSION_MAJOR@.@CMAKE_PROJECT_VERSION_MINOR@0" +#define EMU_VERSION_MAJ @CMAKE_PROJECT_VERSION_MAJOR@ +#define EMU_VERSION_MIN @CMAKE_PROJECT_VERSION_MINOR@ + +#define COPYRIGHT_YEAR "2020" + +/* Web URL info. */ +#define EMU_SITE L"@CMAKE_PROJECT_HOMEPAGE_URL@" +#define EMU_ROMS_URL L"https://github.com/86Box/roms/releases/latest" +#define EMU_DOCS_URL L"https://86box.readthedocs.io" diff --git a/src/include/86box/version.h b/src/include_make/86box/version.h similarity index 93% rename from src/include/86box/version.h rename to src/include_make/86box/version.h index ce286e89f..b3da62c6e 100644 --- a/src/include/86box/version.h +++ b/src/include_make/86box/version.h @@ -28,4 +28,4 @@ /* Web URL info. */ #define EMU_SITE L"86box.net" #define EMU_ROMS_URL L"https://github.com/86Box/roms/releases/latest" -#define EMU_DOCS_URL L"https://86box.readthedocs.io" +#define EMU_DOCS_URL L"https://86box.readthedocs.io" \ No newline at end of file diff --git a/src/machine/CMakeLists.txt b/src/machine/CMakeLists.txt new file mode 100644 index 000000000..ec932d11f --- /dev/null +++ b/src/machine/CMakeLists.txt @@ -0,0 +1,48 @@ +add_library(mch OBJECT machine.c machine_table.c m_xt.c m_xt_compaq.c + m_xt_t1000.c m_xt_t1000_vid.c m_xt_xi8088.c m_xt_zenith.c m_pcjr.c + m_amstrad.c m_europc.c m_xt_olivetti.c m_tandy.c m_at.c m_at_commodore.c + m_at_t3100e.c m_at_t3100e_vid.c m_ps1.c m_ps1_hdc.c m_ps2_isa.c + m_ps2_mca.c m_at_compaq.c m_at_286_386sx.c m_at_386dx_486.c + m_at_socket4_5.c m_at_socket7.c m_at_sockets7.c m_at_socket8.c + m_at_slot1.c m_at_slot2.c m_at_socket370.c m_at_misc.c) + +if(HEDAKA) + target_compile_definitions(mch PRIVATE USE_HEDAKA) +endif() + +if(LASERXT) + target_sources(mch PRIVATE m_xt_laserxt.c) + target_compile_definitions(mch PRIVATE USE_LASERXT) +endif() + +if(NO_SIO) + target_compile_definitions(mch PRIVATE NO_SIO) +endif() + +if(OPEN_AT) + target_compile_definitions(mch PRIVATE USE_OPEN_AT) +endif() + +if(PS1M2133) + target_compile_definitions(mch PRIVATE USE_PS1M2133) +endif() + +if(PS2M70T4) + target_compile_definitions(mch PRIVATE USE_PS2M70T4) +endif() + +if(M1489) + target_compile_definitions(mch PRIVATE USE_M1489) +endif() + +if(M6117) + target_compile_definitions(mch PRIVATE USE_M6117) +endif() + +if(VECT486VL) + target_compile_definitions(mch PRIVATE USE_VECT486VL) +endif() + +if(DELLS4) + target_compile_definitions(mch PRIVATE USE_DELLS4) +endif() \ No newline at end of file diff --git a/src/mem/CMakeLists.txt b/src/mem/CMakeLists.txt new file mode 100644 index 000000000..2f8865f9b --- /dev/null +++ b/src/mem/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(mem OBJECT catalyst_flash.c i2c_eeprom.c intel_flash.c mem.c rom.c + smram.c spd.c sst_flash.c) \ No newline at end of file diff --git a/src/network/CMakeLists.txt b/src/network/CMakeLists.txt new file mode 100644 index 000000000..d157342fb --- /dev/null +++ b/src/network/CMakeLists.txt @@ -0,0 +1,5 @@ +add_library(net OBJECT network.c net_pcap.c net_slirp.c net_dp8390.c net_3c503.c + net_ne2000.c net_pcnet.c net_wd8003.c net_plip.c) + +add_subdirectory(slirp) +target_link_libraries(86Box slirp) \ No newline at end of file diff --git a/src/network/slirp/CMakeLists.txt b/src/network/slirp/CMakeLists.txt new file mode 100644 index 000000000..1a12399ea --- /dev/null +++ b/src/network/slirp/CMakeLists.txt @@ -0,0 +1,5 @@ +add_library(slirp STATIC arp_table.c bootp.c cksum.c dnssearch.c if.c ip_icmp.c + ip_input.c ip_output.c mbuf.c misc.c sbuf.c slirp.c socket.c tcp_input.c + tcp_output.c tcp_subr.c tcp_timer.c udp.c util.c version.c) + +target_link_libraries(slirp wsock32 iphlpapi) \ No newline at end of file diff --git a/src/printer/CMakeLists.txt b/src/printer/CMakeLists.txt new file mode 100644 index 000000000..d347aaab0 --- /dev/null +++ b/src/printer/CMakeLists.txt @@ -0,0 +1 @@ +add_library(print OBJECT png.c prt_cpmap.c prt_escp.c prt_text.c prt_ps.c) \ No newline at end of file diff --git a/src/scsi/CMakeLists.txt b/src/scsi/CMakeLists.txt new file mode 100644 index 000000000..d5dadfb8d --- /dev/null +++ b/src/scsi/CMakeLists.txt @@ -0,0 +1,3 @@ +add_library(scsi OBJECT scsi.c scsi_device.c scsi_cdrom.c scsi_disk.c + scsi_x54x.c scsi_aha154x.c scsi_buslogic.c scsi_ncr5380.c + scsi_ncr53c8xx.c scsi_pcscsi.c scsi_spock.c) \ No newline at end of file diff --git a/src/sio/CMakeLists.txt b/src/sio/CMakeLists.txt new file mode 100644 index 000000000..adc7475f1 --- /dev/null +++ b/src/sio/CMakeLists.txt @@ -0,0 +1,9 @@ +add_library(sio OBJECT sio_acc3221.c sio_f82c710.c sio_82091aa.c sio_fdc37c661.c + sio_fdc37c66x.c sio_fdc37c669.c sio_fdc37c93x.c sio_fdc37m60x.c + sio_pc87306.c sio_pc87307.c sio_pc87309.c sio_pc87311.c sio_pc87332.c + sio_prime3c.c sio_w83787f.c sio_w83877f.c sio_w83977f.c sio_um8669f.c + sio_vt82c686.c) + +if(SIO_DETECT) + target_sources(sio PRIVATE sio_detect.c) +endif() \ No newline at end of file diff --git a/src/sound/CMakeLists.txt b/src/sound/CMakeLists.txt new file mode 100644 index 000000000..138f42ebc --- /dev/null +++ b/src/sound/CMakeLists.txt @@ -0,0 +1,30 @@ +add_library(snd OBJECT sound.c openal.c snd_opl.c snd_opl_nuked.c snd_resid.cc + midi.c midi_system.c snd_speaker.c snd_pssj.c snd_lpt_dac.c + snd_lpt_dss.c snd_adlib.c snd_adlibgold.c snd_ad1848.c snd_audiopci.c + snd_azt2316a.c snd_cms.c snd_gus.c snd_sb.c snd_sb_dsp.c snd_emu8k.c + snd_mpu401.c snd_sn76489.c snd_ssi2001.c snd_wss.c snd_ym7128.c) + +if(FLUIDSYNTH) + target_compile_definitions(snd PRIVATE USE_FLUIDSYNTH) + target_sources(snd PRIVATE midi_fluidsynth.c) +endif() + +if(MUNT) + target_compile_definitions(snd PRIVATE USE_MUNT) + target_sources(snd PRIVATE midi_mt32.c) + + add_subdirectory(munt) + target_link_libraries(86Box mt32emu) +endif() + +if(PAS16) + target_compile_definitions(snd PRIVATE USE_PAS16) + target_sources(snd PRIVATE snd_pas16.c) +endif() + +if(GUSMAX) + target_compile_definitions(snd PRIVATE USE_GUSMAX) +endif() + +add_subdirectory(resid-fp) +target_link_libraries(86Box resid-fp) \ No newline at end of file diff --git a/src/sound/munt/CMakeLists.txt b/src/sound/munt/CMakeLists.txt new file mode 100644 index 000000000..0f2b7a268 --- /dev/null +++ b/src/sound/munt/CMakeLists.txt @@ -0,0 +1,11 @@ +add_library(mt32emu STATIC Analog.cpp BReverbModel.cpp File.cpp FileStream.cpp + LA32Ramp.cpp LA32FloatWaveGenerator.cpp LA32WaveGenerator.cpp + MidiStreamParser.cpp Part.cpp Partial.cpp PartialManager.cpp + Poly.cpp ROMInfo.cpp SampleRateConverter.cpp + srchelper/srctools/src/FIRResampler.cpp + srchelper/srctools/src/IIR2xResampler.cpp + srchelper/srctools/src/LinearResampler.cpp + srchelper/srctools/src/ResamplerModel.cpp + srchelper/srctools/src/SincResampler.cpp + srchelper/InternalResampler.cpp Synth.cpp Tables.cpp TVA.cpp TVF.cpp + TVP.cpp sha1/sha1.cpp c_interface/c_interface.cpp) \ No newline at end of file diff --git a/src/sound/resid-fp/CMakeLists.txt b/src/sound/resid-fp/CMakeLists.txt new file mode 100644 index 000000000..8575c1c93 --- /dev/null +++ b/src/sound/resid-fp/CMakeLists.txt @@ -0,0 +1,4 @@ +add_library(resid-fp STATIC convolve-sse.cc convolve.cc envelope.cc extfilt.cc + filter.cc pot.cc sid.cc voice.cc wave.cc wave6581_PST.cc + wave6581_PS_.cc wave6581_P_T.cc wave6581__ST.cc wave8580_PST.cc + wave8580_PS_.cc wave8580_P_T.cc wave8580__ST.cc) \ No newline at end of file diff --git a/src/video/CMakeLists.txt b/src/video/CMakeLists.txt new file mode 100644 index 000000000..2b21a149c --- /dev/null +++ b/src/video/CMakeLists.txt @@ -0,0 +1,40 @@ +add_library(vid OBJECT video.c vid_table.c vid_cga.c vid_cga_comp.c + vid_compaq_cga.c vid_mda.c vid_hercules.c vid_herculesplus.c + vid_incolor.c vid_colorplus.c vid_genius.c vid_pgc.c vid_im1024.c + vid_sigma.c vid_wy700.c vid_ega.c vid_ega_render.c vid_svga.c + vid_svga_render.c vid_ddc.c vid_vga.c vid_ati_eeprom.c vid_ati18800.c + vid_ati28800.c vid_ati_mach64.c vid_ati68860_ramdac.c vid_bt48x_ramdac.c + vid_av9194.c vid_icd2061.c vid_ics2494.c vid_ics2595.c vid_cl54xx.c + vid_et4000.c vid_sc1148x_ramdac.c vid_sc1502x_ramdac.c vid_et4000w32.c + vid_stg_ramdac.c vid_ht216.c vid_oak_oti.c vid_paradise.c + vid_ti_cf62011.c vid_tvga.c vid_tgui9440.c vid_tkd8001_ramdac.c + vid_att20c49x_ramdac.c vid_s3.c vid_s3_virge.c vid_ibm_rgb528_ramdac.c + vid_sdac_ramdac.c vid_voodoo.c vid_voodoo_banshee.c + vid_voodoo_banshee_blitter.c vid_voodoo_blitter.c vid_voodoo_display.c + vid_voodoo_fb.c vid_voodoo_fifo.c vid_voodoo_reg.c vid_voodoo_render.c + vid_voodoo_setup.c vid_voodoo_texture.c vid_ogc.c vid_nga.c) + +if(NOT MSVC) + target_compile_options(vid PRIVATE "-msse2") +endif() + +if(CL5422) + target_compile_definitions(vid PRIVATE USE_CL5422) +endif() + +if(MGA) + target_compile_definitions(vid PRIVATE USE_MGA) + target_sources(vid PRIVATE vid_mga.c) +endif() + +if(S3TRIO3D2X) + target_compile_definitions(vid PRIVATE USE_S3TRIO3D2X) +endif() + +if(VGAWONDER) + target_compile_definitions(vid PRIVATE USE_VGAWONDER) +endif() + +if(XL24) + target_compile_definitions(vid PRIVATE USE_XL24) +endif() \ No newline at end of file diff --git a/src/win/86Box.rc b/src/win/86Box.rc index b71f49e80..8dfa152db 100644 --- a/src/win/86Box.rc +++ b/src/win/86Box.rc @@ -696,68 +696,76 @@ BEGIN END +#ifndef NO_INCLUDE_MANIFEST ///////////////////////////////////////////////////////////////////////////// // // 24 // 1 24 MOVEABLE PURE "86Box.manifest" +#endif ///////////////////////////////////////////////////////////////////////////// // // Icon // +#ifdef CMAKE +#define ICON_PATH +#else +#define ICON_PATH "win/" +#endif + // Icon with lowest ID value placed first to ensure application icon // remains consistent on all systems. #ifdef RELEASE_BUILD /* Icon by Devcore - https://commons.wikimedia.org/wiki/File:Icon_PC_256x256.png */ - 10 ICON DISCARDABLE "win/icons/86Box-RB.ico" + 10 ICON DISCARDABLE ICON_PATH "icons/86Box-RB.ico" #else /* Icon by Devcore - https://commons.wikimedia.org/wiki/File:Icon_PC2_256x256.png */ - 10 ICON DISCARDABLE "win/icons/86Box.ico" + 10 ICON DISCARDABLE ICON_PATH "icons/86Box.ico" #endif - 16 ICON DISCARDABLE "win/icons/floppy_525.ico" - 17 ICON DISCARDABLE "win/icons/floppy_525_active.ico" - 24 ICON DISCARDABLE "win/icons/floppy_35.ico" - 25 ICON DISCARDABLE "win/icons/floppy_35_active.ico" - 32 ICON DISCARDABLE "win/icons/cdrom.ico" - 33 ICON DISCARDABLE "win/icons/cdrom_active.ico" - 48 ICON DISCARDABLE "win/icons/zip.ico" - 49 ICON DISCARDABLE "win/icons/zip_active.ico" - 56 ICON DISCARDABLE "win/icons/mo.ico" - 57 ICON DISCARDABLE "win/icons/mo_active.ico" - 64 ICON DISCARDABLE "win/icons/cassette.ico" - 65 ICON DISCARDABLE "win/icons/cassette_active.ico" - 80 ICON DISCARDABLE "win/icons/hard_disk.ico" - 81 ICON DISCARDABLE "win/icons/hard_disk_active.ico" - 96 ICON DISCARDABLE "win/icons/network.ico" - 97 ICON DISCARDABLE "win/icons/network_active.ico" -144 ICON DISCARDABLE "win/icons/floppy_525_empty.ico" -145 ICON DISCARDABLE "win/icons/floppy_525_empty_active.ico" -152 ICON DISCARDABLE "win/icons/floppy_35_empty.ico" -153 ICON DISCARDABLE "win/icons/floppy_35_empty_active.ico" -160 ICON DISCARDABLE "win/icons/cdrom_empty.ico" -161 ICON DISCARDABLE "win/icons/cdrom_empty_active.ico" -176 ICON DISCARDABLE "win/icons/zip_empty.ico" -177 ICON DISCARDABLE "win/icons/zip_empty_active.ico" -184 ICON DISCARDABLE "win/icons/mo_empty.ico" -185 ICON DISCARDABLE "win/icons/mo_empty_active.ico" -192 ICON DISCARDABLE "win/icons/cassette_empty.ico" -193 ICON DISCARDABLE "win/icons/cassette_empty_active.ico" -240 ICON DISCARDABLE "win/icons/machine.ico" -241 ICON DISCARDABLE "win/icons/display.ico" -242 ICON DISCARDABLE "win/icons/input_devices.ico" -243 ICON DISCARDABLE "win/icons/sound.ico" -244 ICON DISCARDABLE "win/icons/ports.ico" -245 ICON DISCARDABLE "win/icons/other_peripherals.ico" -246 ICON DISCARDABLE "win/icons/floppy_and_cdrom_drives.ico" -247 ICON DISCARDABLE "win/icons/other_removable_devices.ico" -248 ICON DISCARDABLE "win/icons/floppy_disabled.ico" -249 ICON DISCARDABLE "win/icons/cdrom_disabled.ico" -250 ICON DISCARDABLE "win/icons/zip_disabled.ico" -251 ICON DISCARDABLE "win/icons/mo_disabled.ico" -252 ICON DISCARDABLE "win/icons/storage_controllers.ico" + 16 ICON DISCARDABLE ICON_PATH "icons/floppy_525.ico" + 17 ICON DISCARDABLE ICON_PATH "icons/floppy_525_active.ico" + 24 ICON DISCARDABLE ICON_PATH "icons/floppy_35.ico" + 25 ICON DISCARDABLE ICON_PATH "icons/floppy_35_active.ico" + 32 ICON DISCARDABLE ICON_PATH "icons/cdrom.ico" + 33 ICON DISCARDABLE ICON_PATH "icons/cdrom_active.ico" + 48 ICON DISCARDABLE ICON_PATH "icons/zip.ico" + 49 ICON DISCARDABLE ICON_PATH "icons/zip_active.ico" + 56 ICON DISCARDABLE ICON_PATH "icons/mo.ico" + 57 ICON DISCARDABLE ICON_PATH "icons/mo_active.ico" + 64 ICON DISCARDABLE ICON_PATH "icons/cassette.ico" + 65 ICON DISCARDABLE ICON_PATH "icons/cassette_active.ico" + 80 ICON DISCARDABLE ICON_PATH "icons/hard_disk.ico" + 81 ICON DISCARDABLE ICON_PATH "icons/hard_disk_active.ico" + 96 ICON DISCARDABLE ICON_PATH "icons/network.ico" + 97 ICON DISCARDABLE ICON_PATH "icons/network_active.ico" +144 ICON DISCARDABLE ICON_PATH "icons/floppy_525_empty.ico" +145 ICON DISCARDABLE ICON_PATH "icons/floppy_525_empty_active.ico" +152 ICON DISCARDABLE ICON_PATH "icons/floppy_35_empty.ico" +153 ICON DISCARDABLE ICON_PATH "icons/floppy_35_empty_active.ico" +160 ICON DISCARDABLE ICON_PATH "icons/cdrom_empty.ico" +161 ICON DISCARDABLE ICON_PATH "icons/cdrom_empty_active.ico" +176 ICON DISCARDABLE ICON_PATH "icons/zip_empty.ico" +177 ICON DISCARDABLE ICON_PATH "icons/zip_empty_active.ico" +184 ICON DISCARDABLE ICON_PATH "icons/mo_empty.ico" +185 ICON DISCARDABLE ICON_PATH "icons/mo_empty_active.ico" +192 ICON DISCARDABLE ICON_PATH "icons/cassette_empty.ico" +193 ICON DISCARDABLE ICON_PATH "icons/cassette_empty_active.ico" +240 ICON DISCARDABLE ICON_PATH "icons/machine.ico" +241 ICON DISCARDABLE ICON_PATH "icons/display.ico" +242 ICON DISCARDABLE ICON_PATH "icons/input_devices.ico" +243 ICON DISCARDABLE ICON_PATH "icons/sound.ico" +244 ICON DISCARDABLE ICON_PATH "icons/ports.ico" +245 ICON DISCARDABLE ICON_PATH "icons/other_peripherals.ico" +246 ICON DISCARDABLE ICON_PATH "icons/floppy_and_cdrom_drives.ico" +247 ICON DISCARDABLE ICON_PATH "icons/other_removable_devices.ico" +248 ICON DISCARDABLE ICON_PATH "icons/floppy_disabled.ico" +249 ICON DISCARDABLE ICON_PATH "icons/cdrom_disabled.ico" +250 ICON DISCARDABLE ICON_PATH "icons/zip_disabled.ico" +251 ICON DISCARDABLE ICON_PATH "icons/mo_disabled.ico" +252 ICON DISCARDABLE ICON_PATH "icons/storage_controllers.ico" #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// diff --git a/src/win/CMakeLists.txt b/src/win/CMakeLists.txt new file mode 100644 index 000000000..6727b8367 --- /dev/null +++ b/src/win/CMakeLists.txt @@ -0,0 +1,33 @@ +enable_language(RC) + +add_library(plat OBJECT win.c win_dynld.c win_thread.c win_cdrom.c + win_keyboard.c win_crashdump.c win_midi.c win_mouse.c) + +add_library(ui OBJECT win_ui.c win_stbar.c win_sdl.c win_dialog.c win_about.c + win_settings.c win_devconf.c win_snd_gain.c win_new_floppy.c + win_jsconf.c win_media_menu.c 86Box.rc) + +if(MSVC) + # MSVC complains when we include the manifest from 86Box.rc... + # On the bright side, CMake supports passing the manifest as a source + # file when using MSVC, so we might just as well do that! + target_compile_definitions(ui PRIVATE NO_INCLUDE_MANIFEST) + target_sources(86Box PRIVATE 86Box.manifest) +endif() + +if(DINPUT) + target_sources(plat PRIVATE win_joystick.cpp) + target_link_libraries(86Box dinput8) +else() + target_sources(plat PRIVATE win_joystick_rawinput.c) +endif() + +if(DISCORD) + # PUBLIC due to config.c and pc.c + target_compile_definitions(ui PUBLIC USE_DISCORD) + + target_sources(ui PRIVATE win_discord.c) +endif() + +target_link_libraries(86Box advapi32 comctl32 comdlg32 gdi32 shell32 iphlpapi + dxguid imm32 hid setupapi uxtheme version winmm psapi) \ No newline at end of file diff --git a/src/win/Makefile.mingw b/src/win/Makefile.mingw index 46f5d619a..84482185b 100644 --- a/src/win/Makefile.mingw +++ b/src/win/Makefile.mingw @@ -318,7 +318,7 @@ DEPFILE := win/.depends # Set up the correct toolchain flags. OPTS := $(EXTRAS) $(STUFF) -OPTS += -Iinclude \ +OPTS += -Iinclude -Iinclude_make \ -iquote $(CODEGEN) -iquote cpu ifdef EXFLAGS OPTS += $(EXFLAGS) @@ -369,7 +369,7 @@ ifeq ($(ARM64), y) AOPTIM := AFLAGS := -mfloat-abi=hard endif -RFLAGS := --input-format=rc -O coff -Iinclude +RFLAGS := --input-format=rc -O coff -Iinclude -Iinclude_make ifeq ($(RELEASE), y) OPTS += -DRELEASE_BUILD RFLAGS += -DRELEASE_BUILD From 3a0db7daa869258a31a6b18ca6b518cc654110ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hrdli=C4=8Dka?= Date: Tue, 12 Jan 2021 18:23:01 +0100 Subject: [PATCH 12/15] Add `vcpkg.json` for use with CMake/MSVC --- vcpkg.json | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 vcpkg.json diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 000000000..e57a7db16 --- /dev/null +++ b/vcpkg.json @@ -0,0 +1,13 @@ +{ + "name": "86box", + "version-string": "3.0", + "homepage": "https://86box.net/", + "documentation": "http://86box.readthedocs.io/", + "license": "GPL-2.0-or-later", + "dependencies": [ + "freetype", + "libpng", + "openal-soft", + "sdl2" + ] +} \ No newline at end of file From baad934380d55244db857501ee73dee95bc85a84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hrdli=C4=8Dka?= Date: Tue, 12 Jan 2021 18:23:28 +0100 Subject: [PATCH 13/15] Add a CMake build workflow --- .github/workflows/cmake.yml | 102 ++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 .github/workflows/cmake.yml diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml new file mode 100644 index 000000000..89f2cffe5 --- /dev/null +++ b/.github/workflows/cmake.yml @@ -0,0 +1,102 @@ +name: CMake + +on: + + push: + paths: + - src/** + - .github/workflows/** + - vcpkg.json + + pull_request: + paths: + - src/** + - .github/workflows/** + - vcpkg.json + +env: + BUILD_TYPE: Release + +jobs: + mingw: + name: ${{ matrix.target-arch.msystem }} build (DEV_BUILD=${{ matrix.dev-build }}, NEW_DYNAREC=${{ matrix.new-dynarec }}) + + runs-on: windows-latest + + defaults: + run: + shell: msys2 {0} + + strategy: + matrix: + dev-build: ['ON', 'OFF'] + new-dynarec: ['ON', 'OFF'] + target-arch: + - msystem: MINGW32 + prefix: mingw-w64-i686 + - msystem: MINGW64 + prefix: mingw-w64-x86_64 + + steps: + - uses: msys2/setup-msys2@v2 + with: + path-type: inherit + update: true + msystem: ${{ matrix.target-arch.msystem }} + install: >- + ${{ matrix.target-arch.prefix }}-toolchain + ${{ matrix.target-arch.prefix }}-openal + ${{ matrix.target-arch.prefix }}-freetype + ${{ matrix.target-arch.prefix }}-SDL2 + ${{ matrix.target-arch.prefix }}-zlib + ${{ matrix.target-arch.prefix }}-libpng + ${{ matrix.target-arch.prefix }}-libvncserver + - uses: actions/checkout@v2 + - name: Configure CMake + run: >- + cmake -S . -B build + -G "MSYS Makefiles" + -D CMAKE_BUILD_TYPE=$BUILD_TYPE + -D DEV_BRANCH=${{ matrix.dev-build }} + -D NEW_DYNAREC=${{ matrix.new-dynarec }} + -D VNC=OFF + - name: Build + run: cmake --build build --config $BUILD_TYPE + + clang: + name: VS2019 ${{ matrix.toolset }} ${{ matrix.target-arch }} build (DEV_BUILD=${{ matrix.dev-build }}, NEW_DYNAREC=${{ matrix.new-dynarec }}) + + runs-on: windows-latest + + strategy: + fail-fast: false + matrix: + dev-build: ['ON', 'OFF'] + new-dynarec: ['ON', 'OFF'] + target-arch: ['Win32', 'x64', 'ARM', 'ARM64'] + toolset: ['clangcl', 'v141'] + exclude: + - target-arch: 'ARM' + new-dynarec: 'OFF' + - target-arch: 'ARM64' + new-dynarec: 'OFF' + - target-arch: 'ARM' + toolset: 'clangcl' + + steps: + - uses: actions/checkout@v2 + - uses: actions/cache@v2 + with: + path: build/vcpkg_installed + key: vcpkg-${{ hashFiles('vcpkg.json') }}-${{ matrix.target-arch }} + - name: Configure CMake + run: >- + cmake -S . -B build + -G "Visual Studio 16 2019" -A ${{ matrix.target-arch }} -T ${{ matrix.toolset }} + -D CMAKE_TOOLCHAIN_FILE=C:\vcpkg\scripts\buildsystems\vcpkg.cmake + -D CMAKE_BUILD_TYPE=$BUILD_TYPE + -D DEV_BRANCH=${{ matrix.dev-build }} + -D NEW_DYNAREC=${{ matrix.new-dynarec }} + -D VNC=OFF + - name: Build + run: cmake --build build --config $BUILD_TYPE From 96eb8d806e85ff203b395461f69238037ab80403 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hrdli=C4=8Dka?= Date: Tue, 12 Jan 2021 18:05:25 +0100 Subject: [PATCH 14/15] Add copyright headers --- CMakeLists.txt | 15 +++++++++++++++ src/CMakeLists.txt | 15 +++++++++++++++ src/cdrom/CMakeLists.txt | 15 +++++++++++++++ src/chipset/CMakeLists.txt | 15 +++++++++++++++ src/codegen/CMakeLists.txt | 15 +++++++++++++++ src/codegen_new/CMakeLists.txt | 15 +++++++++++++++ src/cpu/CMakeLists.txt | 15 +++++++++++++++ src/device/CMakeLists.txt | 15 +++++++++++++++ src/disk/CMakeLists.txt | 15 +++++++++++++++ src/disk/minivhd/CMakeLists.txt | 15 +++++++++++++++ src/floppy/CMakeLists.txt | 15 +++++++++++++++ src/game/CMakeLists.txt | 15 +++++++++++++++ src/machine/CMakeLists.txt | 15 +++++++++++++++ src/mem/CMakeLists.txt | 15 +++++++++++++++ src/network/CMakeLists.txt | 15 +++++++++++++++ src/network/slirp/CMakeLists.txt | 15 +++++++++++++++ src/printer/CMakeLists.txt | 15 +++++++++++++++ src/scsi/CMakeLists.txt | 15 +++++++++++++++ src/sio/CMakeLists.txt | 15 +++++++++++++++ src/sound/CMakeLists.txt | 15 +++++++++++++++ src/sound/munt/CMakeLists.txt | 15 +++++++++++++++ src/sound/resid-fp/CMakeLists.txt | 15 +++++++++++++++ src/video/CMakeLists.txt | 15 +++++++++++++++ src/win/CMakeLists.txt | 15 +++++++++++++++ 24 files changed, 360 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 37b44585f..f37195cc3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,3 +1,18 @@ +# +# 86Box A hypervisor and IBM PC system emulator that specializes in +# running old operating systems and software designed for IBM +# PC systems and compatibles from 1981 through fairly recent +# system designs based on the PCI bus. +# +# This file is part of the 86Box distribution. +# +# CMake build script. +# +# Authors: David Hrdlička, +# +# Copyright 2020,2021 David Hrdlička. +# + cmake_minimum_required(VERSION 3.16) project(86Box diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 18ce46481..b5e9746a8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,3 +1,18 @@ +# +# 86Box A hypervisor and IBM PC system emulator that specializes in +# running old operating systems and software designed for IBM +# PC systems and compatibles from 1981 through fairly recent +# system designs based on the PCI bus. +# +# This file is part of the 86Box distribution. +# +# CMake build script. +# +# Authors: David Hrdlička, +# +# Copyright 2020,2021 David Hrdlička. +# + # WIN32 marks us as a GUI app on Windows add_executable(86Box WIN32 pc.c config.c random.c timer.c io.c acpi.c apm.c dma.c ddma.c nmi.c pic.c pit.c port_92.c ppi.c pci.c mca.c usb.c diff --git a/src/cdrom/CMakeLists.txt b/src/cdrom/CMakeLists.txt index 2756e0be8..6b6c89022 100644 --- a/src/cdrom/CMakeLists.txt +++ b/src/cdrom/CMakeLists.txt @@ -1 +1,16 @@ +# +# 86Box A hypervisor and IBM PC system emulator that specializes in +# running old operating systems and software designed for IBM +# PC systems and compatibles from 1981 through fairly recent +# system designs based on the PCI bus. +# +# This file is part of the 86Box distribution. +# +# CMake build script. +# +# Authors: David Hrdlička, +# +# Copyright 2020,2021 David Hrdlička. +# + add_library(cdrom OBJECT cdrom.c cdrom_image_backend.c cdrom_image.c) \ No newline at end of file diff --git a/src/chipset/CMakeLists.txt b/src/chipset/CMakeLists.txt index 9b6d78a30..9b7cd39ad 100644 --- a/src/chipset/CMakeLists.txt +++ b/src/chipset/CMakeLists.txt @@ -1,3 +1,18 @@ +# +# 86Box A hypervisor and IBM PC system emulator that specializes in +# running old operating systems and software designed for IBM +# PC systems and compatibles from 1981 through fairly recent +# system designs based on the PCI bus. +# +# This file is part of the 86Box distribution. +# +# CMake build script. +# +# Authors: David Hrdlička, +# +# Copyright 2020,2021 David Hrdlička. +# + add_library(chipset OBJECT acc2168.c cs8230.c ali1429.c headland.c intel_82335.c cs4031.c intel_420ex.c intel_4x0.c intel_sio.c intel_piix.c ../ioapic.c neat.c opti495.c opti895.c opti5x7.c scamp.c scat.c via_vt82c49x.c diff --git a/src/codegen/CMakeLists.txt b/src/codegen/CMakeLists.txt index 040f2deab..7ee69bf3b 100644 --- a/src/codegen/CMakeLists.txt +++ b/src/codegen/CMakeLists.txt @@ -1,3 +1,18 @@ +# +# 86Box A hypervisor and IBM PC system emulator that specializes in +# running old operating systems and software designed for IBM +# PC systems and compatibles from 1981 through fairly recent +# system designs based on the PCI bus. +# +# This file is part of the 86Box distribution. +# +# CMake build script. +# +# Authors: David Hrdlička, +# +# Copyright 2020,2021 David Hrdlička. +# + if(DYNAREC) add_library(dynarec OBJECT codegen.c codegen_ops.c) diff --git a/src/codegen_new/CMakeLists.txt b/src/codegen_new/CMakeLists.txt index a560c4581..0a6db2827 100644 --- a/src/codegen_new/CMakeLists.txt +++ b/src/codegen_new/CMakeLists.txt @@ -1,3 +1,18 @@ +# +# 86Box A hypervisor and IBM PC system emulator that specializes in +# running old operating systems and software designed for IBM +# PC systems and compatibles from 1981 through fairly recent +# system designs based on the PCI bus. +# +# This file is part of the 86Box distribution. +# +# CMake build script. +# +# Authors: David Hrdlička, +# +# Copyright 2020,2021 David Hrdlička. +# + if(DYNAREC) add_library(dynarec OBJECT codegen.c codegen_accumulate.c codegen_allocator.c codegen_block.c codegen_ir.c codegen_ops.c diff --git a/src/cpu/CMakeLists.txt b/src/cpu/CMakeLists.txt index 4c5c6d53e..6fe97a35c 100644 --- a/src/cpu/CMakeLists.txt +++ b/src/cpu/CMakeLists.txt @@ -1,3 +1,18 @@ +# +# 86Box A hypervisor and IBM PC system emulator that specializes in +# running old operating systems and software designed for IBM +# PC systems and compatibles from 1981 through fairly recent +# system designs based on the PCI bus. +# +# This file is part of the 86Box distribution. +# +# CMake build script. +# +# Authors: David Hrdlička, +# +# Copyright 2020,2021 David Hrdlička. +# + add_library(cpu OBJECT cpu.c cpu_table.c 808x.c 386.c 386_common.c 386_dynarec.c 386_dynarec_ops.c x86seg.c x87.c x87_timings.c) diff --git a/src/device/CMakeLists.txt b/src/device/CMakeLists.txt index 9460b5b88..85339108a 100644 --- a/src/device/CMakeLists.txt +++ b/src/device/CMakeLists.txt @@ -1,3 +1,18 @@ +# +# 86Box A hypervisor and IBM PC system emulator that specializes in +# running old operating systems and software designed for IBM +# PC systems and compatibles from 1981 through fairly recent +# system designs based on the PCI bus. +# +# This file is part of the 86Box distribution. +# +# CMake build script. +# +# Authors: David Hrdlička, +# +# Copyright 2020,2021 David Hrdlička. +# + add_library(dev OBJECT bugger.c hwm.c hwm_lm75.c hwm_lm78.c hwm_gl518sm.c hwm_vt82c686.c ibm_5161.c isamem.c isartc.c ../lpt.c pci_bridge.c postcard.c serial.c vpc2007.c clock_ics9xxx.c i2c.c i2c_gpio.c diff --git a/src/disk/CMakeLists.txt b/src/disk/CMakeLists.txt index 2a31f56d2..f0ec758fe 100644 --- a/src/disk/CMakeLists.txt +++ b/src/disk/CMakeLists.txt @@ -1,3 +1,18 @@ +# +# 86Box A hypervisor and IBM PC system emulator that specializes in +# running old operating systems and software designed for IBM +# PC systems and compatibles from 1981 through fairly recent +# system designs based on the PCI bus. +# +# This file is part of the 86Box distribution. +# +# CMake build script. +# +# Authors: David Hrdlička, +# +# Copyright 2020,2021 David Hrdlička. +# + add_library(hdd OBJECT hdd.c hdd_image.c hdd_table.c hdc.c hdc_st506_xt.c hdc_st506_at.c hdc_xta.c hdc_esdi_at.c hdc_esdi_mca.c hdc_xtide.c hdc_ide.c hdc_ide_opti611.c hdc_ide_cmd640.c hdc_ide_sff8038i.c) diff --git a/src/disk/minivhd/CMakeLists.txt b/src/disk/minivhd/CMakeLists.txt index 0d346da17..8afcd4265 100644 --- a/src/disk/minivhd/CMakeLists.txt +++ b/src/disk/minivhd/CMakeLists.txt @@ -1,3 +1,18 @@ +# +# 86Box A hypervisor and IBM PC system emulator that specializes in +# running old operating systems and software designed for IBM +# PC systems and compatibles from 1981 through fairly recent +# system designs based on the PCI bus. +# +# This file is part of the 86Box distribution. +# +# CMake build script. +# +# Authors: David Hrdlička, +# +# Copyright 2020,2021 David Hrdlička. +# + add_library(minivhd STATIC cwalk.c libxml2_encoding.c minivhd_convert.c minivhd_create.c minivhd_io.c minivhd_manage.c minivhd_struct_rw.c minivhd_util.c) \ No newline at end of file diff --git a/src/floppy/CMakeLists.txt b/src/floppy/CMakeLists.txt index 60b2893f3..a3039ddd5 100644 --- a/src/floppy/CMakeLists.txt +++ b/src/floppy/CMakeLists.txt @@ -1,2 +1,17 @@ +# +# 86Box A hypervisor and IBM PC system emulator that specializes in +# running old operating systems and software designed for IBM +# PC systems and compatibles from 1981 through fairly recent +# system designs based on the PCI bus. +# +# This file is part of the 86Box distribution. +# +# CMake build script. +# +# Authors: David Hrdlička, +# +# Copyright 2020,2021 David Hrdlička. +# + add_library(fdd OBJECT fdd.c fdc.c fdc_pii15xb.c fdi2raw.c fdd_common.c fdd_86f.c fdd_fdi.c fdd_imd.c fdd_img.c fdd_json.c fdd_mfm.c fdd_td0.c) \ No newline at end of file diff --git a/src/game/CMakeLists.txt b/src/game/CMakeLists.txt index b38921770..06f700cca 100644 --- a/src/game/CMakeLists.txt +++ b/src/game/CMakeLists.txt @@ -1,2 +1,17 @@ +# +# 86Box A hypervisor and IBM PC system emulator that specializes in +# running old operating systems and software designed for IBM +# PC systems and compatibles from 1981 through fairly recent +# system designs based on the PCI bus. +# +# This file is part of the 86Box distribution. +# +# CMake build script. +# +# Authors: David Hrdlička, +# +# Copyright 2020,2021 David Hrdlička. +# + add_library(game OBJECT gameport.c joystick_standard.c joystick_ch_flightstick_pro.c joystick_sw_pad.c joystick_tm_fcs.c) \ No newline at end of file diff --git a/src/machine/CMakeLists.txt b/src/machine/CMakeLists.txt index ec932d11f..18a43eb03 100644 --- a/src/machine/CMakeLists.txt +++ b/src/machine/CMakeLists.txt @@ -1,3 +1,18 @@ +# +# 86Box A hypervisor and IBM PC system emulator that specializes in +# running old operating systems and software designed for IBM +# PC systems and compatibles from 1981 through fairly recent +# system designs based on the PCI bus. +# +# This file is part of the 86Box distribution. +# +# CMake build script. +# +# Authors: David Hrdlička, +# +# Copyright 2020,2021 David Hrdlička. +# + add_library(mch OBJECT machine.c machine_table.c m_xt.c m_xt_compaq.c m_xt_t1000.c m_xt_t1000_vid.c m_xt_xi8088.c m_xt_zenith.c m_pcjr.c m_amstrad.c m_europc.c m_xt_olivetti.c m_tandy.c m_at.c m_at_commodore.c diff --git a/src/mem/CMakeLists.txt b/src/mem/CMakeLists.txt index 2f8865f9b..6bf044762 100644 --- a/src/mem/CMakeLists.txt +++ b/src/mem/CMakeLists.txt @@ -1,2 +1,17 @@ +# +# 86Box A hypervisor and IBM PC system emulator that specializes in +# running old operating systems and software designed for IBM +# PC systems and compatibles from 1981 through fairly recent +# system designs based on the PCI bus. +# +# This file is part of the 86Box distribution. +# +# CMake build script. +# +# Authors: David Hrdlička, +# +# Copyright 2020,2021 David Hrdlička. +# + add_library(mem OBJECT catalyst_flash.c i2c_eeprom.c intel_flash.c mem.c rom.c smram.c spd.c sst_flash.c) \ No newline at end of file diff --git a/src/network/CMakeLists.txt b/src/network/CMakeLists.txt index d157342fb..e8db1a01e 100644 --- a/src/network/CMakeLists.txt +++ b/src/network/CMakeLists.txt @@ -1,3 +1,18 @@ +# +# 86Box A hypervisor and IBM PC system emulator that specializes in +# running old operating systems and software designed for IBM +# PC systems and compatibles from 1981 through fairly recent +# system designs based on the PCI bus. +# +# This file is part of the 86Box distribution. +# +# CMake build script. +# +# Authors: David Hrdlička, +# +# Copyright 2020,2021 David Hrdlička. +# + add_library(net OBJECT network.c net_pcap.c net_slirp.c net_dp8390.c net_3c503.c net_ne2000.c net_pcnet.c net_wd8003.c net_plip.c) diff --git a/src/network/slirp/CMakeLists.txt b/src/network/slirp/CMakeLists.txt index 1a12399ea..83a8105ba 100644 --- a/src/network/slirp/CMakeLists.txt +++ b/src/network/slirp/CMakeLists.txt @@ -1,3 +1,18 @@ +# +# 86Box A hypervisor and IBM PC system emulator that specializes in +# running old operating systems and software designed for IBM +# PC systems and compatibles from 1981 through fairly recent +# system designs based on the PCI bus. +# +# This file is part of the 86Box distribution. +# +# CMake build script. +# +# Authors: David Hrdlička, +# +# Copyright 2020,2021 David Hrdlička. +# + add_library(slirp STATIC arp_table.c bootp.c cksum.c dnssearch.c if.c ip_icmp.c ip_input.c ip_output.c mbuf.c misc.c sbuf.c slirp.c socket.c tcp_input.c tcp_output.c tcp_subr.c tcp_timer.c udp.c util.c version.c) diff --git a/src/printer/CMakeLists.txt b/src/printer/CMakeLists.txt index d347aaab0..ace9ac0c8 100644 --- a/src/printer/CMakeLists.txt +++ b/src/printer/CMakeLists.txt @@ -1 +1,16 @@ +# +# 86Box A hypervisor and IBM PC system emulator that specializes in +# running old operating systems and software designed for IBM +# PC systems and compatibles from 1981 through fairly recent +# system designs based on the PCI bus. +# +# This file is part of the 86Box distribution. +# +# CMake build script. +# +# Authors: David Hrdlička, +# +# Copyright 2020,2021 David Hrdlička. +# + add_library(print OBJECT png.c prt_cpmap.c prt_escp.c prt_text.c prt_ps.c) \ No newline at end of file diff --git a/src/scsi/CMakeLists.txt b/src/scsi/CMakeLists.txt index d5dadfb8d..444c87b70 100644 --- a/src/scsi/CMakeLists.txt +++ b/src/scsi/CMakeLists.txt @@ -1,3 +1,18 @@ +# +# 86Box A hypervisor and IBM PC system emulator that specializes in +# running old operating systems and software designed for IBM +# PC systems and compatibles from 1981 through fairly recent +# system designs based on the PCI bus. +# +# This file is part of the 86Box distribution. +# +# CMake build script. +# +# Authors: David Hrdlička, +# +# Copyright 2020,2021 David Hrdlička. +# + add_library(scsi OBJECT scsi.c scsi_device.c scsi_cdrom.c scsi_disk.c scsi_x54x.c scsi_aha154x.c scsi_buslogic.c scsi_ncr5380.c scsi_ncr53c8xx.c scsi_pcscsi.c scsi_spock.c) \ No newline at end of file diff --git a/src/sio/CMakeLists.txt b/src/sio/CMakeLists.txt index adc7475f1..8dcb8416e 100644 --- a/src/sio/CMakeLists.txt +++ b/src/sio/CMakeLists.txt @@ -1,3 +1,18 @@ +# +# 86Box A hypervisor and IBM PC system emulator that specializes in +# running old operating systems and software designed for IBM +# PC systems and compatibles from 1981 through fairly recent +# system designs based on the PCI bus. +# +# This file is part of the 86Box distribution. +# +# CMake build script. +# +# Authors: David Hrdlička, +# +# Copyright 2020,2021 David Hrdlička. +# + add_library(sio OBJECT sio_acc3221.c sio_f82c710.c sio_82091aa.c sio_fdc37c661.c sio_fdc37c66x.c sio_fdc37c669.c sio_fdc37c93x.c sio_fdc37m60x.c sio_pc87306.c sio_pc87307.c sio_pc87309.c sio_pc87311.c sio_pc87332.c diff --git a/src/sound/CMakeLists.txt b/src/sound/CMakeLists.txt index 138f42ebc..32d72a34f 100644 --- a/src/sound/CMakeLists.txt +++ b/src/sound/CMakeLists.txt @@ -1,3 +1,18 @@ +# +# 86Box A hypervisor and IBM PC system emulator that specializes in +# running old operating systems and software designed for IBM +# PC systems and compatibles from 1981 through fairly recent +# system designs based on the PCI bus. +# +# This file is part of the 86Box distribution. +# +# CMake build script. +# +# Authors: David Hrdlička, +# +# Copyright 2020,2021 David Hrdlička. +# + add_library(snd OBJECT sound.c openal.c snd_opl.c snd_opl_nuked.c snd_resid.cc midi.c midi_system.c snd_speaker.c snd_pssj.c snd_lpt_dac.c snd_lpt_dss.c snd_adlib.c snd_adlibgold.c snd_ad1848.c snd_audiopci.c diff --git a/src/sound/munt/CMakeLists.txt b/src/sound/munt/CMakeLists.txt index 0f2b7a268..e694bc7ae 100644 --- a/src/sound/munt/CMakeLists.txt +++ b/src/sound/munt/CMakeLists.txt @@ -1,3 +1,18 @@ +# +# 86Box A hypervisor and IBM PC system emulator that specializes in +# running old operating systems and software designed for IBM +# PC systems and compatibles from 1981 through fairly recent +# system designs based on the PCI bus. +# +# This file is part of the 86Box distribution. +# +# CMake build script. +# +# Authors: David Hrdlička, +# +# Copyright 2020,2021 David Hrdlička. +# + add_library(mt32emu STATIC Analog.cpp BReverbModel.cpp File.cpp FileStream.cpp LA32Ramp.cpp LA32FloatWaveGenerator.cpp LA32WaveGenerator.cpp MidiStreamParser.cpp Part.cpp Partial.cpp PartialManager.cpp diff --git a/src/sound/resid-fp/CMakeLists.txt b/src/sound/resid-fp/CMakeLists.txt index 8575c1c93..8b5a16f40 100644 --- a/src/sound/resid-fp/CMakeLists.txt +++ b/src/sound/resid-fp/CMakeLists.txt @@ -1,3 +1,18 @@ +# +# 86Box A hypervisor and IBM PC system emulator that specializes in +# running old operating systems and software designed for IBM +# PC systems and compatibles from 1981 through fairly recent +# system designs based on the PCI bus. +# +# This file is part of the 86Box distribution. +# +# CMake build script. +# +# Authors: David Hrdlička, +# +# Copyright 2020,2021 David Hrdlička. +# + add_library(resid-fp STATIC convolve-sse.cc convolve.cc envelope.cc extfilt.cc filter.cc pot.cc sid.cc voice.cc wave.cc wave6581_PST.cc wave6581_PS_.cc wave6581_P_T.cc wave6581__ST.cc wave8580_PST.cc diff --git a/src/video/CMakeLists.txt b/src/video/CMakeLists.txt index 2b21a149c..9419e3e4a 100644 --- a/src/video/CMakeLists.txt +++ b/src/video/CMakeLists.txt @@ -1,3 +1,18 @@ +# +# 86Box A hypervisor and IBM PC system emulator that specializes in +# running old operating systems and software designed for IBM +# PC systems and compatibles from 1981 through fairly recent +# system designs based on the PCI bus. +# +# This file is part of the 86Box distribution. +# +# CMake build script. +# +# Authors: David Hrdlička, +# +# Copyright 2020,2021 David Hrdlička. +# + add_library(vid OBJECT video.c vid_table.c vid_cga.c vid_cga_comp.c vid_compaq_cga.c vid_mda.c vid_hercules.c vid_herculesplus.c vid_incolor.c vid_colorplus.c vid_genius.c vid_pgc.c vid_im1024.c diff --git a/src/win/CMakeLists.txt b/src/win/CMakeLists.txt index 6727b8367..f8c248ae3 100644 --- a/src/win/CMakeLists.txt +++ b/src/win/CMakeLists.txt @@ -1,3 +1,18 @@ +# +# 86Box A hypervisor and IBM PC system emulator that specializes in +# running old operating systems and software designed for IBM +# PC systems and compatibles from 1981 through fairly recent +# system designs based on the PCI bus. +# +# This file is part of the 86Box distribution. +# +# CMake build script. +# +# Authors: David Hrdlička, +# +# Copyright 2020,2021 David Hrdlička. +# + enable_language(RC) add_library(plat OBJECT win.c win_dynld.c win_thread.c win_cdrom.c From 7ce4bd1a11da1b86479f080a72fc22eb03e1e4b2 Mon Sep 17 00:00:00 2001 From: TC1995 Date: Tue, 12 Jan 2021 20:48:47 +0100 Subject: [PATCH 15/15] Minor fix to the Longshine card, now it formats HDD's as it should. --- src/scsi/scsi_ncr5380.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/scsi/scsi_ncr5380.c b/src/scsi/scsi_ncr5380.c index defb56d16..2760d2623 100644 --- a/src/scsi/scsi_ncr5380.c +++ b/src/scsi/scsi_ncr5380.c @@ -122,7 +122,7 @@ typedef struct { int8_t irq; int8_t type; int8_t bios_ver; - uint16_t block_count, block_count_num; + uint8_t block_count, block_count_num; uint8_t status_ctrl; uint8_t pad[2]; @@ -638,7 +638,7 @@ ncr_write(uint16_t port, uint8_t val, void *priv) break; } - if (ncr->dma_mode == DMA_IDLE) { + if (ncr->dma_mode == DMA_IDLE || ncr_dev->type == 0) { bus_host = get_bus_host(ncr); ncr_bus_update(priv, bus_host); }