This commit is contained in:
RichardG867
2021-01-12 21:49:13 -03:00
43 changed files with 1701 additions and 385 deletions

109
src/CMakeLists.txt Normal file
View File

@@ -0,0 +1,109 @@
#
# 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, <hrdlickadavid@outlook.com>
#
# 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
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)

16
src/cdrom/CMakeLists.txt Normal file
View File

@@ -0,0 +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, <hrdlickadavid@outlook.com>
#
# Copyright 2020,2021 David Hrdlička.
#
add_library(cdrom OBJECT cdrom.c cdrom_image_backend.c cdrom_image.c)

View File

@@ -0,0 +1,33 @@
#
# 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, <hrdlickadavid@outlook.com>
#
# 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
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()

View File

@@ -0,0 +1,32 @@
#
# 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, <hrdlickadavid@outlook.com>
#
# Copyright 2020,2021 David Hrdlička.
#
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()

View File

@@ -0,0 +1,52 @@
#
# 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, <hrdlickadavid@outlook.com>
#
# 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
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()

32
src/cpu/CMakeLists.txt Normal file
View File

@@ -0,0 +1,32 @@
#
# 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, <hrdlickadavid@outlook.com>
#
# 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)
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()

24
src/device/CMakeLists.txt Normal file
View File

@@ -0,0 +1,24 @@
#
# 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, <hrdlickadavid@outlook.com>
#
# 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
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()

25
src/disk/CMakeLists.txt Normal file
View File

@@ -0,0 +1,25 @@
#
# 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, <hrdlickadavid@outlook.com>
#
# 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)
add_library(zip OBJECT zip.c)
add_library(mo OBJECT mo.c)
add_subdirectory(minivhd)
target_link_libraries(86Box minivhd)

View File

@@ -0,0 +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, <hrdlickadavid@outlook.com>
#
# 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)

View File

@@ -15,7 +15,9 @@
* Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com>
*
* Copyright 2020 Miran Grca.
* Copyright 2020,2021 Natalia Portillo.
* Copyright 2020,2021 Miran Grca.
* Copyright 2020,2021 Fred N. van Kempen
*/
#include <stdio.h>
#include <stdint.h>
@@ -1039,15 +1041,16 @@ mo_insert(mo_t *dev)
void
mo_format(mo_t *dev)
{
unsigned long size;
long size;
int ret;
int fd;
mo_log("MO %i: Formatting media...\n", dev->id);
fseek(dev->drv->f, 0, SEEK_END);
size = (uint32_t) ftello64(dev->drv->f);
size = ftell(dev->drv->f);
#ifdef _WIN32
HANDLE fh;
LARGE_INTEGER liSize;
@@ -1058,14 +1061,14 @@ mo_format(mo_t *dev)
ret = (int)SetFilePointerEx(fh, liSize, NULL, FILE_BEGIN);
if (!ret) {
if(!ret) {
mo_log("MO %i: Failed seek to start of image file\n", dev->id);
return;
}
ret = (int)SetEndOfFile(fh);
if (!ret) {
if(!ret) {
mo_log("MO %i: Failed to truncate image file to 0\n", dev->id);
return;
}
@@ -1073,17 +1076,34 @@ mo_format(mo_t *dev)
liSize.QuadPart = size;
ret = (int)SetFilePointerEx(fh, liSize, NULL, FILE_BEGIN);
if (!ret) {
if(!ret) {
mo_log("MO %i: Failed seek to end of image file\n", dev->id);
return;
}
ret = (int)SetEndOfFile(fh);
if (!ret) {
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

17
src/floppy/CMakeLists.txt Normal file
View File

@@ -0,0 +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, <hrdlickadavid@outlook.com>
#
# 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)

17
src/game/CMakeLists.txt Normal file
View File

@@ -0,0 +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, <hrdlickadavid@outlook.com>
#
# 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)

View File

@@ -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, <mgrca8@gmail.com>
*
* 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"

View File

@@ -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"

View File

@@ -0,0 +1,63 @@
#
# 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, <hrdlickadavid@outlook.com>
#
# 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
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()

View File

@@ -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

View File

@@ -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;

17
src/mem/CMakeLists.txt Normal file
View File

@@ -0,0 +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, <hrdlickadavid@outlook.com>
#
# 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)

View File

@@ -0,0 +1,20 @@
#
# 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, <hrdlickadavid@outlook.com>
#
# 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)
add_subdirectory(slirp)
target_link_libraries(86Box slirp)

View File

@@ -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;
};

View File

@@ -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);

View File

@@ -0,0 +1,20 @@
#
# 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, <hrdlickadavid@outlook.com>
#
# 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)
target_link_libraries(slirp wsock32 iphlpapi)

View File

@@ -38,6 +38,7 @@
#include "slirp.h"
#include "ip_icmp.h"
#include <stddef.h>
static struct ip *ip_reass(Slirp *slirp, struct ip *ip, struct ipq *fp);
static void ip_freef(Slirp *slirp, struct ipq *fp);

View File

@@ -14,6 +14,7 @@
*/
#include "slirp.h"
#include <stddef.h>
#define MBUF_THRESH 30

View File

@@ -4,6 +4,7 @@
*/
#include "slirp.h"
#include <stdbool.h>
#ifdef G_OS_UNIX
#include <sys/un.h>
#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)

View File

@@ -0,0 +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, <hrdlickadavid@outlook.com>
#
# Copyright 2020,2021 David Hrdlička.
#
add_library(print OBJECT png.c prt_cpmap.c prt_escp.c prt_text.c prt_ps.c)

18
src/scsi/CMakeLists.txt Normal file
View File

@@ -0,0 +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, <hrdlickadavid@outlook.com>
#
# 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)

View File

@@ -122,7 +122,7 @@ typedef struct {
int8_t irq;
int8_t type;
int8_t bios_ver;
uint8_t block_count;
uint8_t block_count, block_count_num;
uint8_t status_ctrl;
uint8_t pad[2];
@@ -181,9 +181,26 @@ 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);
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,58 +228,35 @@ 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);
}
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;
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) {
double p = ncr_dev->period;
if (ncr->data_wait & 2)
ncr->data_wait &= ~2;
period *= 128.0;
} else
period *= 64.0;
/* This is the 1 us wait period. */
period += 1.0;
if (callback) {
p *= 128.0;
}
p += 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);
}
@@ -376,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;
@@ -407,7 +403,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;
@@ -448,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;
@@ -456,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;
}
}
@@ -482,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;
@@ -494,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);
@@ -506,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);
}
@@ -580,7 +577,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;
@@ -595,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");
@@ -618,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:
@@ -637,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 || ncr_dev->type == 0) {
bus_host = get_bus_host(ncr);
ncr_bus_update(priv, bus_host);
}
}
@@ -667,7 +670,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;
@@ -691,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");
@@ -700,14 +702,15 @@ 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;
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");
@@ -721,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)
ncr->isr |= STATUS_INT;
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");
@@ -731,10 +736,14 @@ 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);
ncr_log("Reset Interrupt\n");
break;
default:
@@ -779,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");
@@ -829,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;
@@ -849,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;
@@ -871,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;
@@ -970,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, bt = 0, 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) {
@@ -999,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;
while (bt < 64) {
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);
bt++;
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->isr |= STATUS_INT;
picint(1 << ncr_dev->irq);
}
}
break;
}
}
ncr_dma_send(ncr_dev, ncr);
break;
case DMA_INITIATOR_RECEIVE:
@@ -1063,59 +1138,15 @@ ncr_callback(void *priv)
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;
while (bt < 64) {
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;
bt++;
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->isr |= STATUS_INT;
picint(1 << ncr_dev->irq);
}
}
break;
}
}
ncr_dma_initiator_receive(ncr_dev, ncr);
break;
}
@@ -1125,7 +1156,7 @@ ncr_callback(void *priv)
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);
}
}
@@ -1201,7 +1232,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 +1308,9 @@ static const device_config_t ncr5380_mmio_config[] = {
{
"IRQ 5", 5
},
{
"IRQ 7", 7
},
{
""
}
@@ -1318,6 +1352,9 @@ static const device_config_t rancho_config[] = {
{
"IRQ 5", 5
},
{
"IRQ 7", 7
},
{
""
}

View File

@@ -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,

24
src/sio/CMakeLists.txt Normal file
View File

@@ -0,0 +1,24 @@
#
# 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, <hrdlickadavid@outlook.com>
#
# 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
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()

45
src/sound/CMakeLists.txt Normal file
View File

@@ -0,0 +1,45 @@
#
# 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, <hrdlickadavid@outlook.com>
#
# 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
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)

View File

@@ -0,0 +1,26 @@
#
# 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, <hrdlickadavid@outlook.com>
#
# 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
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)

View File

@@ -0,0 +1,19 @@
#
# 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, <hrdlickadavid@outlook.com>
#
# 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
wave8580_PS_.cc wave8580_P_T.cc wave8580__ST.cc)

View File

@@ -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 =

55
src/video/CMakeLists.txt Normal file
View File

@@ -0,0 +1,55 @@
#
# 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, <hrdlickadavid@outlook.com>
#
# 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
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()

View File

@@ -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);
}
}

View File

@@ -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
/////////////////////////////////////////////////////////////////////////////

48
src/win/CMakeLists.txt Normal file
View File

@@ -0,0 +1,48 @@
#
# 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, <hrdlickadavid@outlook.com>
#
# Copyright 2020,2021 David Hrdlička.
#
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)

View File

@@ -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