Moved the SCSI BIOS command handler to its own file (scsi_bios_command.c/h);

Removed all the SCSI BIOS ID/LUN swapping nonsense as it's no longer needed;
The makefile now knows the .h dependencies for everything in SOUND/;
Moved hdd*.* and scsi*.* to the HDD and SCSI subdirectories, respectively;
Fixed some leftover path name miscapitalizations in the makefile;
BT-542B is now BT-545C and BT-946C is now BT-958D again;
Implemented the last missing commands for the BT-958D;
MUNT and network are now optional at compile time but enabled by default;
When compiling the development branch, you now have to choose what of (Pro Audio Spectrum 16, Cirrus Logic, NVidia Riva) you want your binary to include.
This commit is contained in:
OBattler
2017-08-27 00:58:44 +02:00
parent b25ee43202
commit ee4af98e1f
46 changed files with 1083 additions and 684 deletions

View File

@@ -1,8 +1,9 @@
#include "ibm.h"
#include "CPU/cpu.h"
#include "device.h"
#include "../ibm.h"
#include "../CPU/cpu.h"
#include "../device.h"
#include "../model.h"
#include "hdd.h"
#include "model.h"
#include "hdd_esdi_at.h"
#include "hdd_esdi_mca.h"

View File

@@ -9,14 +9,14 @@
#include <sys/types.h>
#include "ibm.h"
#include "device.h"
#include "../ibm.h"
#include "../device.h"
#include "hdd_image.h"
#include "io.h"
#include "mem.h"
#include "pic.h"
#include "rom.h"
#include "timer.h"
#include "../io.h"
#include "../mem.h"
#include "../pic.h"
#include "../rom.h"
#include "../timer.h"
#include "hdd_esdi_at.h"

View File

@@ -60,16 +60,16 @@
* Copyright 2017 Fred N. van Kempen.
*/
#include <malloc.h>
#include "ibm.h"
#include "device.h"
#include "dma.h"
#include "../ibm.h"
#include "../device.h"
#include "../dma.h"
#include "hdd_image.h"
#include "io.h"
#include "mca.h"
#include "mem.h"
#include "pic.h"
#include "rom.h"
#include "timer.h"
#include "../io.h"
#include "../mca.h"
#include "../mem.h"
#include "../pic.h"
#include "../rom.h"
#include "../timer.h"
#include "hdd_esdi_mca.h"

View File

@@ -22,15 +22,15 @@
#include <stdarg.h>
#include <wchar.h>
#include "86box.h"
#include "cdrom.h"
#include "ibm.h"
#include "../86box.h"
#include "../cdrom.h"
#include "../ibm.h"
#include "hdd_image.h"
#include "io.h"
#include "pic.h"
#include "timer.h"
#include "cdrom.h"
#include "scsi.h"
#include "../io.h"
#include "../pic.h"
#include "../timer.h"
#include "../cdrom.h"
#include "../SCSI/scsi.h"
#include "hdd_ide_at.h"
/* Bits of 'atastat' */

View File

@@ -16,11 +16,11 @@
* Copyright 2016,2017 Miran Grca.
*/
#include <malloc.h>
#include "ibm.h"
#include "io.h"
#include "mem.h"
#include "rom.h"
#include "device.h"
#include "../ibm.h"
#include "../io.h"
#include "../mem.h"
#include "../rom.h"
#include "../device.h"
#include "hdd_ide_at.h"
#include "hdd_ide_xt.h"

View File

@@ -7,7 +7,7 @@
#include <stdlib.h>
#include <stdint.h>
#include "ibm.h"
#include "../ibm.h"
#include "hdd_ide_at.h"
#include "hdd_image.h"

View File

@@ -1,11 +1,11 @@
#include <malloc.h>
#include "ibm.h"
#include "../ibm.h"
#include "hdd_image.h"
#include "device.h"
#include "io.h"
#include "pic.h"
#include "timer.h"
#include "../device.h"
#include "../io.h"
#include "../pic.h"
#include "../timer.h"
#include "hdd_mfm_at.h"

View File

@@ -1,15 +1,16 @@
#include <malloc.h>
#include <sys/types.h>
#include "ibm.h"
#include "device.h"
#include "dma.h"
#include "../ibm.h"
#include "../device.h"
#include "../dma.h"
#include "hdd_image.h"
#include "io.h"
#include "mem.h"
#include "pic.h"
#include "rom.h"
#include "timer.h"
#include "../io.h"
#include "../mem.h"
#include "../pic.h"
#include "../rom.h"
#include "../timer.h"
#include "hdd_mfm_xebec.h"

View File

@@ -8,7 +8,7 @@
#
# Modified Makefile for Win32 (MinGW32) environment.
#
# Version: @(#)Makefile.mingw 1.0.38 2017/08/24
# Version: @(#)Makefile.mingw 1.0.39 2017/08/26
#
# Authors: Miran Grca, <mgrca8@gmail.com>
# Fred N. van Kempen, <decwiz@yahoo.com>
@@ -55,9 +55,24 @@ endif
ifndef DEV_BRANCH
DEV_BRANCH = n
endif
ifndef CIRRUS
CIRRUS = n
endif
ifndef NV_RIVA
CIRRUS = n
endif
ifndef FLUIDSYNTH
FLUIDSYNTH = y
endif
ifndef MUNT
MUNT = y
endif
ifndef PAS16
PAS16 = n
endif
ifndef NETWORK
NETWORK = y
endif
ifndef X64
X64 = n
endif
@@ -67,11 +82,12 @@ endif
# Nothing should need changing from here on.. #
#########################################################################
VPATH = . CPU \
HDD \
SOUND \
SOUND/MUNT SOUND/MUNT/c_interface SOUND/MUNT/sha1 \
SOUND/MUNT/srchelper \
SOUND/RESID-FP \
VIDEO LZF NETWORK NETWORK/SLIRP WIN
SOUND/munt SOUND/munt/c_interface SOUND/munt/sha1 \
SOUND/munt/srchelper \
SOUND/resid-fp \
SCSI VIDEO lzf NETWORK NETWORK/slirp WIN
PLAT = WIN/
ifeq ($(X64), y)
CPP = g++.exe -m64
@@ -131,6 +147,13 @@ ifeq ($(FLUIDSYNTH), y)
CFLAGS += -DUSE_FLUIDSYNTH
FSYNTHOBJ = midi_fluidsynth.o
endif
ifeq ($(MUNT), y)
CFLAGS += -DUSE_MUNT
endif
ifeq ($(NETWORK), y)
CFLAGS += -DUSE_NETWORK
RFLAGS += -DUSE_NETWORK
endif
ifeq ($(X64), y)
PLATCG = codegen_x86-64.o
CGOPS = codegen_ops_x86-64.h
@@ -142,14 +165,17 @@ VCG = vid_voodoo_codegen_x86.h
endif
ifeq ($(DEV_BRANCH), y)
DBFLAGS = -DDEV_BRANCH
else
DBFLAGS =
endif
ifeq ($(DEV_BRANCH), y)
CFLAGS += -DDEV_BRANCH
ifeq ($(CIRRUS), y)
CFLAGS += -DUSE_CIRRUS
endif
ifeq ($(NV_RIVA), y)
CFLAGS += -DUSE_RIVA
endif
ifeq ($(PAS16), y)
CFLAGS += -DUSE_PAS16
endif
endif
ifeq ($(WALTJE), y)
@@ -196,17 +222,26 @@ DEVOBJ = bugger.o lpt.o $(SERIAL) \
joystick_sw_pad.o joystick_tm_fcs.o \
mouse.o mouse_serial.o mouse_ps2.o mouse_bus.o \
fdd.o fdc.o fdi2raw.o \
hdd.o hdd_image.o \
hdd_mfm_at.o hdd_mfm_xebec.o hdd_esdi_at.o hdd_esdi_mca.o \
hdd_ide_at.o hdd_ide_xt.o piix.o \
disc.o \
disc_86f.o disc_fdi.o disc_imd.o disc_img.o \
disc_random.o disc_td0.o \
cdrom.o \
cdrom_dosbox.o cdrom_image.o cdrom_ioctl.o cdrom_null.o
ifdef USB
HDDOBJ = hdd.o hdd_image.o \
hdd_mfm_at.o hdd_mfm_xebec.o hdd_esdi_at.o hdd_esdi_mca.o \
hdd_ide_at.o hdd_ide_xt.o piix.o
ifeq ($(USB), y)
USBOBJ = usb.o
endif
ifeq ($(MUNT), y)
MUNTOBJ = midi_mt32.o \
Analog.o BReverbModel.o File.o FileStream.o LA32Ramp.o \
LA32FloatWaveGenerator.o LA32WaveGenerator.o \
MidiStreamParser.o Part.o Partial.o PartialManager.o \
Poly.o ROMInfo.o SampleRateConverter_dummy.o Synth.o \
Tables.o TVA.o TVF.o TVP.o sha1.o c_interface.o
endif
ifeq ($(NETWORK), y)
NETOBJ = network.o \
net_pcap.o \
net_slirp.o \
@@ -214,7 +249,14 @@ NETOBJ = network.o \
ip_input.o queue.o tcp_input.o debug.o ip_output.o \
sbuf.o tcp_output.o udp.o if.o mbuf.o slirp.o tcp_subr.o \
net_ne2000.o
SCSIOBJ = scsi.o scsi_device.o scsi_disk.o scsi_buslogic.o scsi_aha154x.o
endif
SCSIOBJ = scsi.o scsi_bios_command.o scsi_device.o scsi_disk.o \
scsi_buslogic.o scsi_aha154x.o
ifeq ($(DEV_BRANCH), y)
ifeq ($(PAS16), y)
PAS16OBJ = snd_pas16.o
endif
endif
SNDOBJ = sound.o \
openal.o \
dbopl.o nukedopl.o \
@@ -223,19 +265,13 @@ SNDOBJ = sound.o \
wave6581_P_T.o wave6581_PS_.o wave6581_PST.o \
wave8580__ST.o wave8580_P_T.o wave8580_PS_.o \
wave8580_PST.o wave.o \
midi.o $(FSYNTHOBJ) \
midi_mt32.o \
Analog.o BReverbModel.o File.o FileStream.o LA32Ramp.o \
LA32FloatWaveGenerator.o LA32WaveGenerator.o \
MidiStreamParser.o Part.o Partial.o PartialManager.o \
Poly.o ROMInfo.o SampleRateConverter_dummy.o Synth.o \
Tables.o TVA.o TVF.o TVP.o sha1.o c_interface.o \
midi.o $(FSYNTHOBJ) $(MUNTOBJ) \
midi_system.o \
snd_speaker.o snd_ps1.o snd_pssj.o \
snd_adlib.o snd_adlibgold.o snd_ad1848.o \
snd_sb.o snd_sb_dsp.o snd_cms.o snd_dbopl.o \
snd_emu8k.o snd_gus.o snd_opl.o \
snd_mpu401.o snd_pas16.o snd_resid.o \
snd_mpu401.o $(PAS16OBJ) snd_resid.o \
snd_sn76489.o snd_ssi2001.o snd_wss.o \
snd_ym7128.o
VIDOBJ = video.o \
@@ -271,20 +307,28 @@ WINOBJ = win.o \
win_settings.o win_deviceconfig.o win_joystickconfig.o \
86Box.res
ifeq ($(DEV_BRANCH), y)
DEVBRANCHOBJ = vid_cl_gd.o vid_cl_gd_blit.o vid_cl_ramdac.o \
vid_nv_riva128.o
ifeq ($(CIRRUS), y)
CIRRUSOBJ = vid_cl_gd.o vid_cl_gd_blit.o vid_cl_ramdac.o
endif
OBJ = $(MAINOBJ) $(CPUOBJ) $(SYSOBJ) $(DEVOBJ) $(USBOBJ) \
$(NETOBJ) $(SCSIOBJ) $(SNDOBJ) $(VIDOBJ) $(WINOBJ) \
$(DEVBRANCHOBJ)
ifeq ($(NV_RIVA), y)
RIVAOBJ = vid_nv_riva128.o
endif
DEVBRANCHOBJ = $(CIRRUSOBJ) $(RIVAOBJ)
endif
OBJ = $(MAINOBJ) $(CPUOBJ) $(SYSOBJ) $(HDDOBJ) $(DEVOBJ) \
$(USBOBJ) $(NETOBJ) $(SCSIOBJ) $(SNDOBJ) $(VIDOBJ) \
$(WINOBJ) $(DEVBRANCHOBJ)
LZFOBJ = lzf_c.o lzf_d.o
LIBS = -mwindows \
-lopenal.dll \
-lddraw -ldinput8 -ldxguid -ld3d9 -ld3dx9 \
-lcomctl32 -lkernel32 -lwsock32 -lwinmm -liphlpapi -lpsapi \
-static -lstdc++ -lgcc
-lcomctl32 -lwinmm
ifeq ($(NETWORK), y)
LIBS += -lkernel32 -lwsock32 -liphlpapi -lpsapi
endif
LIBS += -static -lstdc++ -lgcc
# Build rules.
@@ -535,7 +579,7 @@ pic.o: ibm.h io.h pic.h pit.h
piix.o: ibm.h dma.h hdd_ide_at.h io.h mem.h pci.h piix.h
pit.o: ibm.h CPU/cpu.h dma.h io.h pic.h pit.h device.h timer.h \
model.h SOUND/snd_speaker.h video/video.h
model.h SOUND/snd_speaker.h VIDEO/video.h
ppi.o: ibm.h pit.h plat_keyboard.h plat_mouse.h
@@ -557,13 +601,15 @@ scat.o: ibm.h CPU/cpu.h io.h mem.h device.h model.h
scsi.o: 86box.h ibm.h timer.h device.h cdrom.h scsi.h \
scsi_aha154x.h scsi_buslogic.h
scsi_bios_command.o: ibm.h dma.h scsi.h scsi_bios_command.h scsi_device.h
scsi_device.o: ibm.h scsi.h scsi_disk.h cdrom.h
scsi_aha154x.o: ibm.h io.h mca.h mem.h mca.h rom.h dma.h pic.h timer.h \
device.h cdrom.h scsi.h scsi_disk.h scsi_aha154x.h \
device.h scsi.h scsi_bios_command.h scsi_aha154x.h \
scsi_buslogic.o: ibm.h io.h mem.h rom.h dma.h pic.h pci.h timer.h \
device.h scsi.h scsi_device.h scsi_disk.h cdrom.h \
device.h scsi.h scsi_bios_command.h scsi_device.h \
scsi_buslogic.h
scsi_disk.o: 86box.h cdrom.h hdd_image.h ibm.h hdd_ide_at.h piix.h scsi.h \
@@ -660,6 +706,66 @@ net_slirp.o: NETWORK/slirp/slirp.h NETWORK/slirp/queue.h ibm.h config.h device.h
network.o: ibm.h device.h NETWORK/network.h NETWORK/net_ne2000.h WIN/plat_ui.h
dbopl.o: SOUND/dbopl.h
midi.o: device.h SOUND/midi.h ibm.h WIN/plat_midi.h WIN/plat_ticks.h SOUND/midi_fluidsynth.h SOUND/midi_mt32.h SOUND/midi_system.h
midi_fluidsynth.o: config.h WIN/plat_dynld.h WIN/plat_thread.h WIN/plat_ui.h device.h SOUND/midi_fluidsynth.h SOUND/midi.h SOUND/sound.h
midi_mt32.o: SOUND/munt/c_interface/c_interface.h WIN/plat_thread.h ibm.h device.h mem.h rom.h MIDI/midi_mt32.h MIDI/midi.h \
SOUND/sound.h
midi_system.o: device.h WIN/plat_midi.h SOUND/midi_system.h SOUND/midi.h
nukedopl.o: SOUND/nukedopl.h
openal.o: ibm.h SOUND/sound.h
snd_ad1848.o: ibm.h dma.h pic.h timer.h SOUND/sound.h SOUND/snd_ad1848.h
snd_adlib.o: ibm.h io.h mca.h device.h SOUND/sound.h SOUND/snd_adlib.h SOUND/snd_opl.h
snd_adlibgold.o: ibm.h io.h dma.h pic.h pit.h mem.h rom.h timer.h device.h SOUND/sound.h SOUND/filters.h SOUND/snd_opl.h SOUND/snd_ym7128.h
snd_cms.o: ibm.h io.h device.h SOUND/sound.h SOUND/snd_cms.h
snd_dbopl.o: SOUND/dbopl.h SOUND/nukedopl.h SOUND/snd_dbopl.h
snd_emu8k.o: ibm.h io.h mem.h rom.h timer.h device.h SOUND/sound.h SOUND/snd_emu8k.h
snd_gus.o: ibm.h io.h pic.h dma.h timer.h device.h SOUND/sound.h SOUND/snd_gus.h
snd_mpu401.o: ibm.h device.h io.h pic.h timer.h SOUND/midi.h SOUND/sound.h SOUND/snd_mpu401.h
snd_opl.o: ibm.h io.h timer.h SOUND/sound.h SOUND/snd_opl.h SOUND/snd_dbopl.h
snd_pas16.o: ibm.h io.h pic.h pit.h dma.h timer.h device.h SOUND/sound.h SOUND/snd_opl.h SOUND/snd_pas16.h SOUND/snd_sb_dsp.h \
SOUND\filters.h
snd_ps1.o: ibm.h io.h pic.h timer.h device.h SOUND/sound.h SOUND/snd_ps1.h SOUND/snd_sn76489.h
snd_pssj.o: ibm.h io.h dma.h pic.h timer.h device.h SOUND/sound.h SOUND/snd_pssj.h SOUND/snd_sn76489.h
snd_resid.o: SOUND/resid-fp/sid.h SOUND/snd_resid.h
snd_sb.o: ibm.h io.h mca.h mem.h rom.h device.h SOUND/sound.h SOUND/snd_dbopl.h SOUND/snd_emu8k.h SOUND/snd_mpu401.h \
SOUND/snd_opl.h SOUND/snd_sb.h SOUND/snd_sb_dsp.h SOUND/filters.h
snd_sb_dsp.o: ibm.h io.h pic.h dma.h timer.h device.h SOUND/midi.h SOUND/sound.h SOUND/snd_mpu401.h SOUND/snd_sb_dsp.h
snd_sn76489.o: ibm.h io.h device.h SOUND/sound.h SOUND/snd_sn76489.h
snd_speaker.o: ibm.h SOUND/sound.h SOUND/snd_speaker.h
snd_ssi2001.o: ibm.h io.h device.h SOUND/sound.h SOUND/snd_resid.h SOUND/snd_ssi2001.h
snd_wss.o: ibm.h io.h pic.h dma.h device.h SOUND/sound.h SOUND/snd_ad1848.h SOUND/snd_opl.h SOUND/snd_wss.h
snd_ym7128.o: ibm.h SOUND/snd_ym7128.h
sound.o: ibm.h device.h timer.h cdrom.h WIN/plat_thread.h SOUND/midi.h SOUND/sound.h SOUND/snd_opl.h SOUND/snd_adlib.h \
SOUND/snd_pas16.h SOUND/snd_sb.h SOUND/snd_sb_dsp.h SOUND/snd_wss.h SOUND/filters.h
vid_ati_eeprom.o: ibm.h mem.h rom.h VIDEO/vid_ati_eeprom.h
vid_ati_mach64.o: ibm.h device.h io.h mem.h pci.h rom.h WIN/plat_thread.h VIDEO/video.h VIDEO/vid_svga.h VIDEO/vid_svga_render.h \

View File

@@ -19,11 +19,11 @@
*/
#include <stdlib.h>
#include <string.h>
#include "86box.h"
#include "ibm.h"
#include "timer.h"
#include "device.h"
#include "cdrom.h"
#include "../86box.h"
#include "../ibm.h"
#include "../timer.h"
#include "../device.h"
#include "../cdrom.h"
#include "scsi.h"
#include "scsi_aha154x.h"
#include "scsi_buslogic.h"
@@ -52,8 +52,8 @@ static SCSI_CARD scsi_cards[] = {
{ "Adaptec AHA-1540B", "aha1540b", &aha1540b_device, aha_device_reset },
{ "Adaptec AHA-1542CF", "aha1542cf", &aha1542cf_device, aha_device_reset },
{ "Adaptec AHA-1640", "aha1640", &aha1640_device, aha_device_reset },
{ "BusLogic BT-542B", "bt542b", &buslogic_device, BuslogicDeviceReset },
{ "BusLogic BT-946C PCI", "bt946c", &buslogic_pci_device, BuslogicDeviceReset },
{ "BusLogic BT-545C", "bt545c", &buslogic_device, BuslogicDeviceReset },
{ "BusLogic BT-958D PCI", "bt958d", &buslogic_pci_device, BuslogicDeviceReset },
{ "", "", NULL, NULL },
};

View File

@@ -8,7 +8,7 @@
*
* SCSI controller handler header.
*
* Version: @(#)scsi_h 1.0.3 2017/08/25
* Version: @(#)scsi_h 1.0.4 2017/08/26
*
* Authors: TheCollector1995, <mariogplayer@gmail.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -305,35 +305,6 @@ typedef struct {
#define ADDR_TO_U32(x) (((x).hi<<16)|((x).mid<<8)|((x).lo&0xFF))
#define U32_TO_ADDR(a,x) do {(a).hi=(x)>>16;(a).mid=(x)>>8;(a).lo=(x)&0xFF;}while(0)
#pragma pack(push,1)
typedef struct
{
uint8_t command;
uint8_t id:3,
reserved:2,
lun:3;
union {
struct {
uint16_t cyl;
uint8_t head;
uint8_t sec;
} chs;
struct {
uint8_t lba0; /* MSB */
uint8_t lba1;
uint8_t lba2;
uint8_t lba3; /* LSB */
} lba;
} u;
uint8_t secount;
addr24 dma_address;
} BIOSCMD;
#pragma pack(pop)
#define lba32_blk(p) ((uint32_t)(p->u.lba.lba0<<24) | (p->u.lba.lba1<<16) | \
(p->u.lba.lba2<<8) | p->u.lba.lba3)
extern uint8_t scsi_bios_cmd(uint8_t last_id, BIOSCMD *BiosCmd, int8_t islba);
/*
*

View File

@@ -12,7 +12,7 @@
*
* NOTE: THIS IS CURRENTLY A MESS, but will be cleaned up as I go.
*
* Version: @(#)scsi_aha154x.c 1.0.13 2017/08/25
* Version: @(#)scsi_aha154x.c 1.0.14 2017/08/26
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Original Buslogic version by SA1988 and Miran Grca.
@@ -23,20 +23,19 @@
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include "ibm.h"
#include "io.h"
#include "mca.h"
#include "mem.h"
#include "mca.h"
#include "rom.h"
#include "dma.h"
#include "pic.h"
#include "timer.h"
#include "device.h"
#include "cdrom.h"
#include "../ibm.h"
#include "../io.h"
#include "../mca.h"
#include "../mem.h"
#include "../mca.h"
#include "../rom.h"
#include "../dma.h"
#include "../pic.h"
#include "../timer.h"
#include "../device.h"
#include "scsi.h"
#include "scsi_bios_command.h"
#include "scsi_device.h"
#include "scsi_disk.h"
#include "scsi_aha154x.h"
@@ -1057,7 +1056,6 @@ aha_write(uint16_t port, uint8_t val, void *priv)
BIOSCMD *BiosCmd;
ReplyInquireSetupInformation *ReplyISI;
uint16_t cyl = 0;
uint8_t temp = 0;
pclog("%s: Write Port 0x%02X, Value %02X\n", dev->name, port, val);
@@ -1177,9 +1175,6 @@ aha_0x01:
cyl = ((BiosCmd->u.chs.cyl & 0xff) << 8) | ((BiosCmd->u.chs.cyl >> 8) & 0xff);
BiosCmd->u.chs.cyl = cyl;
}
temp = BiosCmd->id;
BiosCmd->id = BiosCmd->lun;
BiosCmd->lun = temp;
if (dev->type == AHA_1640) {
pclog("BIOS LBA=%06lx (%lu)\n",
lba32_blk(BiosCmd),
@@ -1192,7 +1187,7 @@ aha_0x01:
BiosCmd->u.chs.head,
BiosCmd->u.chs.sec);
}
dev->DataBuf[0] = scsi_bios_cmd(7, BiosCmd, (dev->type==AHA_1640)?1:0);
dev->DataBuf[0] = scsi_bios_command(7, BiosCmd, (dev->type==AHA_1640)?1:0);
pclog("BIOS Completion/Status Code %x\n", dev->DataBuf[0]);
dev->DataReplyLeft = 1;
break;

View File

@@ -0,0 +1,446 @@
/*
* 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.
*
* The shared AHA and Buslogic SCSI BIOS command handler.
*
* Version: @(#)scsi_bios_command.c 1.0.0 2017/08/26
*
* Authors: TheCollector1995, <mariogplayer@gmail.com>
* Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com>
* Copyright 2016,2017 Miran Grca.
* Copyright 2017 Fred N. van Kempen.
*/
#include <stdarg.h>
#include <stdlib.h>
#include "../ibm.h"
#include "../dma.h"
#include "scsi.h"
#include "scsi_bios_command.h"
#include "scsi_device.h"
static void
scsi_bios_command_log(const char *format, ...)
{
#ifdef ENABLE_SCSI_BIOS_COMMAND_LOG
va_list ap;
va_start(ap, format);
vprintf(format, ap);
va_end(ap);
fflush(stdout);
#endif
}
static uint8_t scsi_bios_completion_code(uint8_t *sense)
{
switch (sense[12])
{
case 0x00:
return 0x00;
case 0x20:
return 0x01;
case 0x12:
case 0x21:
return 0x02;
case 0x27:
return 0x03;
case 0x14: case 0x16:
return 0x04;
case 0x10: case 0x11:
return 0x10;
case 0x17: case 0x18:
return 0x11;
case 0x01: case 0x03: case 0x05: case 0x06: case 0x07: case 0x08: case 0x09:
case 0x1B: case 0x1C: case 0x1D:
case 0x40: case 0x41: case 0x42: case 0x43: case 0x44: case 0x45: case 0x46:
case 0x47: case 0x48: case 0x49:
return 0x20;
case 0x15:
case 0x02:
return 0x40;
case 0x04:
case 0x28: case 0x29: case 0x2A:
return 0xAA;
default:
return 0xFF;
}
}
uint8_t scsi_bios_command_08(uint8_t id, uint8_t lun, uint8_t *buffer)
{
uint32_t len = 0;
uint8_t cdb[12] = { GPCMD_READ_CDROM_CAPACITY, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
uint8_t rcbuf[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
int ret = 0;
int i = 0;
uint8_t sc = 0;
ret = scsi_device_read_capacity(id, lun, cdb, rcbuf, &len);
sc = scsi_bios_completion_code(scsi_device_sense(id, lun));
if (ret == 0)
{
return sc;
}
memset(buffer, 0, 6);
for (i = 0; i < 4; i++)
{
buffer[i] = rcbuf[i];
}
for (i = 4; i < 6; i++)
{
buffer[i] = rcbuf[(i + 2) ^ 1];
}
scsi_bios_command_log("BIOS Command 0x08: %02X %02X %02X %02X %02X %02X\n", buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], buffer[5]);
return 0;
}
int scsi_bios_command_15(uint8_t id, uint8_t lun, uint8_t *buffer)
{
uint32_t len = 0;
uint8_t cdb[12] = { GPCMD_READ_CDROM_CAPACITY, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
uint8_t rcbuf[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
int ret = 0;
int i = 0;
uint8_t sc = 0;
ret = scsi_device_read_capacity(id, lun, cdb, rcbuf, &len);
sc = scsi_bios_completion_code(scsi_device_sense(id, lun));
memset(buffer, 0, 6);
for (i = 0; i < 4; i++)
{
buffer[i] = (ret == 0) ? 0 : rcbuf[i];
}
scsi_device_type_data(id, lun, &(buffer[4]), &(buffer[5]));
scsi_bios_command_log("BIOS Command 0x15: %02X %02X %02X %02X %02X %02X\n", buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], buffer[5]);
return sc;
}
static void BuslogicIDCheck(uint8_t id, uint8_t lun)
{
if (!scsi_device_valid(id, lun))
{
fatal("BIOS INT13 CD-ROM on %02i:%02i has disappeared\n", id, lun);
}
}
/* This returns the completion code. */
uint8_t scsi_bios_command(uint8_t last_id, BIOSCMD *BiosCmd, int8_t islba)
{
uint32_t dma_address;
uint32_t lba;
int sector_len = BiosCmd->secount;
int block_shift = 9;
uint8_t ret = 0;
uint8_t cdb[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
if (islba)
lba = lba32_blk(BiosCmd);
else
lba = (BiosCmd->u.chs.cyl << 9) + (BiosCmd->u.chs.head << 5) + BiosCmd->u.chs.sec;
scsi_bios_command_log("BIOS Command = 0x%02X\n", BiosCmd->command);
if ((BiosCmd->id > last_id) || (BiosCmd->lun > 7)) {
return 0x80;
}
SCSIDevices[BiosCmd->id][BiosCmd->lun].InitLength = 0;
if (!scsi_device_present(BiosCmd->id, BiosCmd->lun))
{
scsi_bios_command_log("BIOS Target ID %i and LUN %i have no device attached\n",BiosCmd->id,BiosCmd->lun);
return 0x80;
}
dma_address = ADDR_TO_U32(BiosCmd->dma_address);
scsi_bios_command_log("BIOS Data Buffer write: length %d, pointer 0x%04X\n", sector_len, dma_address);
if (SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer != NULL)
{
free(SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer);
SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer = NULL;
}
block_shift = scsi_device_block_shift(BiosCmd->id, BiosCmd->lun);
switch(BiosCmd->command)
{
case 0x00: /* Reset Disk System, in practice it's a nop */
return 0;
case 0x01: /* Read Status of Last Operation */
BuslogicIDCheck(BiosCmd->id, BiosCmd->lun);
/* Assuming 14 bytes because that's the default length for SCSI sense, and no command-specific
indication is given. */
SCSIDevices[BiosCmd->id][BiosCmd->lun].InitLength = 14;
SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer = (uint8_t *) malloc(14);
memset(SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer, 0, 14);
/* SCSIStatus = scsi_bios_command_08(BiosCmd->id, BiosCmd->lun, SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer) ? SCSI_STATUS_OK : SCSI_STATUS_CHECK_CONDITION; */
if (sector_len > 0)
{
scsi_bios_command_log("BusLogic BIOS DMA: Reading 14 bytes at %08X\n", dma_address);
DMAPageWrite(dma_address, (char *)scsi_device_sense(BiosCmd->id, BiosCmd->lun), 14);
}
if (SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer != NULL)
{
free(SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer);
SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer = NULL;
}
return 0;
break;
case 0x02: /* Read Desired Sectors to Memory */
BuslogicIDCheck(BiosCmd->id, BiosCmd->lun);
SCSIDevices[BiosCmd->id][BiosCmd->lun].InitLength = sector_len << block_shift;
SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer = (uint8_t *) malloc(sector_len << block_shift);
memset(SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer, 0, sector_len << block_shift);
cdb[0] = GPCMD_READ_10;
cdb[1] = (BiosCmd->lun & 7) << 5;
cdb[2] = (lba >> 24) & 0xff;
cdb[3] = (lba >> 16) & 0xff;
cdb[4] = (lba >> 8) & 0xff;
cdb[5] = lba & 0xff;
cdb[7] = (sector_len >> 8) & 0xff;
cdb[8] = sector_len & 0xff;
#if 0
pclog("BIOS CMD(READ, %08lx, %d)\n", lba, BiosCmd->secount);
#endif
scsi_device_command(BiosCmd->id, BiosCmd->lun, 12, cdb);
if (sector_len > 0)
{
scsi_bios_command_log("BIOS DMA: Reading %i bytes at %08X\n", sector_len << block_shift, dma_address);
DMAPageWrite(dma_address, (char *)SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer, sector_len << block_shift);
}
if (SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer != NULL)
{
free(SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer);
SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer = NULL;
}
return scsi_bios_completion_code(scsi_device_sense(BiosCmd->id, BiosCmd->lun));
break;
case 0x03: /* Write Desired Sectors from Memory */
BuslogicIDCheck(BiosCmd->id, BiosCmd->lun);
SCSIDevices[BiosCmd->id][BiosCmd->lun].InitLength = sector_len << block_shift;
SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer = (uint8_t *) malloc(sector_len << block_shift);
memset(SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer, 0, sector_len << block_shift);
if (sector_len > 0)
{
scsi_bios_command_log("BIOS DMA: Reading %i bytes at %08X\n", sector_len << block_shift, dma_address);
DMAPageRead(dma_address, (char *)SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer, sector_len << block_shift);
}
cdb[0] = GPCMD_WRITE_10;
cdb[1] = (BiosCmd->lun & 7) << 5;
cdb[2] = (lba >> 24) & 0xff;
cdb[3] = (lba >> 16) & 0xff;
cdb[4] = (lba >> 8) & 0xff;
cdb[5] = lba & 0xff;
cdb[7] = (sector_len >> 8) & 0xff;
cdb[8] = sector_len & 0xff;
#if 0
pclog("BIOS CMD(WRITE, %08lx, %d)\n", lba, BiosCmd->secount);
#endif
scsi_device_command(BiosCmd->id, BiosCmd->lun, 12, cdb);
if (SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer != NULL)
{
free(SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer);
SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer = NULL;
}
return scsi_bios_completion_code(scsi_device_sense(BiosCmd->id, BiosCmd->lun));
break;
case 0x04: /* Verify Desired Sectors */
BuslogicIDCheck(BiosCmd->id, BiosCmd->lun);
cdb[0] = GPCMD_VERIFY_10;
cdb[1] = (BiosCmd->lun & 7) << 5;
cdb[2] = (lba >> 24) & 0xff;
cdb[3] = (lba >> 16) & 0xff;
cdb[4] = (lba >> 8) & 0xff;
cdb[5] = lba & 0xff;
cdb[7] = (sector_len >> 8) & 0xff;
cdb[8] = sector_len & 0xff;
scsi_device_command(BiosCmd->id, BiosCmd->lun, 12, cdb);
return scsi_bios_completion_code(scsi_device_sense(BiosCmd->id, BiosCmd->lun));
break;
case 0x05: /* Format Track, invalid since SCSI has no tracks */
return 1;
break;
case 0x06: /* Identify SCSI Devices, in practice it's a nop */
return 0;
break;
case 0x07: /* Format Unit */
BuslogicIDCheck(BiosCmd->id, BiosCmd->lun);
cdb[0] = GPCMD_FORMAT_UNIT;
cdb[1] = (BiosCmd->lun & 7) << 5;
scsi_device_command(BiosCmd->id, BiosCmd->lun, 12, cdb);
return scsi_bios_completion_code(scsi_device_sense(BiosCmd->id, BiosCmd->lun));
break;
case 0x08: /* Read Drive Parameters */
BuslogicIDCheck(BiosCmd->id, BiosCmd->lun);
SCSIDevices[BiosCmd->id][BiosCmd->lun].InitLength = 6;
SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer = (uint8_t *) malloc(6);
memset(SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer, 0, 6);
ret = scsi_bios_command_08(BiosCmd->id, BiosCmd->lun, SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer);
scsi_bios_command_log("BIOS DMA: Reading 6 bytes at %08X\n", dma_address);
DMAPageWrite(dma_address, (char *)SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer, 6);
if (SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer != NULL)
{
free(SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer);
SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer = NULL;
}
return ret;
break;
case 0x09: /* Initialize Drive Pair Characteristics, in practice it's a nop */
return 0;
break;
case 0x0C: /* Seek */
BuslogicIDCheck(BiosCmd->id, BiosCmd->lun);
SCSIDevices[BiosCmd->id][BiosCmd->lun].InitLength = sector_len << block_shift;
cdb[0] = GPCMD_SEEK_10;
cdb[1] = (BiosCmd->lun & 7) << 5;
cdb[2] = (lba >> 24) & 0xff;
cdb[3] = (lba >> 16) & 0xff;
cdb[4] = (lba >> 8) & 0xff;
cdb[5] = lba & 0xff;
scsi_device_command(BiosCmd->id, BiosCmd->lun, 12, cdb);
return (SCSIStatus == SCSI_STATUS_OK) ? 1 : 0;
break;
case 0x0D: /* Alternate Disk Reset, in practice it's a nop */
return 0;
break;
case 0x10: /* Test Drive Ready */
BuslogicIDCheck(BiosCmd->id, BiosCmd->lun);
cdb[0] = GPCMD_TEST_UNIT_READY;
cdb[1] = (BiosCmd->lun & 7) << 5;
scsi_device_command(BiosCmd->id, BiosCmd->lun, 12, cdb);
return scsi_bios_completion_code(scsi_device_sense(BiosCmd->id, BiosCmd->lun));
break;
case 0x11: /* Recalibrate */
BuslogicIDCheck(BiosCmd->id, BiosCmd->lun);
cdb[0] = GPCMD_REZERO_UNIT;
cdb[1] = (BiosCmd->lun & 7) << 5;
scsi_device_command(BiosCmd->id, BiosCmd->lun, 12, cdb);
return scsi_bios_completion_code(scsi_device_sense(BiosCmd->id, BiosCmd->lun));
break;
case 0x14: /* Controller Diagnostic */
return 0;
break;
case 0x15: /* Read DASD Type */
BuslogicIDCheck(BiosCmd->id, BiosCmd->lun);
SCSIDevices[BiosCmd->id][BiosCmd->lun].InitLength = 6;
SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer = (uint8_t *) malloc(6);
memset(SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer, 0, 6);
ret = scsi_bios_command_15(BiosCmd->id, BiosCmd->lun, SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer);
scsi_bios_command_log("BusLogic BIOS DMA: Reading 6 bytes at %08X\n", dma_address);
DMAPageWrite(dma_address, (char *)SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer, 6);
if (SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer != NULL)
{
free(SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer);
SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer = NULL;
}
return ret;
break;
default:
scsi_bios_command_log("BusLogic BIOS: Unimplemented command: %02X\n", BiosCmd->command);
return 1;
break;
}
pclog("BIOS Request complete\n");
}

View File

@@ -0,0 +1,47 @@
/*
* 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.
*
* The shared AHA and Buslogic SCSI BIOS command handler's
* headler.
*
* Version: @(#)scsi_bios_command.h 1.0.0 2017/08/26
*
* Authors: TheCollector1995, <mariogplayer@gmail.com>
* Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com>
* Copyright 2016,2017 Miran Grca.
* Copyright 2017 Fred N. van Kempen.
*/
#pragma pack(push,1)
typedef struct
{
uint8_t command;
uint8_t lun:3,
reserved:2,
id:3;
union {
struct {
uint16_t cyl;
uint8_t head;
uint8_t sec;
} chs;
struct {
uint8_t lba0; /* MSB */
uint8_t lba1;
uint8_t lba2;
uint8_t lba3; /* LSB */
} lba;
} u;
uint8_t secount;
addr24 dma_address;
} BIOSCMD;
#pragma pack(pop)
#define lba32_blk(p) ((uint32_t)(p->u.lba.lba0<<24) | (p->u.lba.lba1<<16) | \
(p->u.lba.lba2<<8) | p->u.lba.lba3)
extern uint8_t scsi_bios_command(uint8_t last_id, BIOSCMD *BiosCmd, int8_t islba);

View File

@@ -7,10 +7,10 @@
* Emulation of BusLogic ISA and PCI SCSI controllers. Boards
* supported:
*
* 0 - BT-542B ISA;
* 1 - BT-946C PCI (but BT-542B ISA on non-PCI machines)
* 0 - BT-545C ISA;
* 1 - BT-958D PCI (but BT-545C ISA on non-PCI machines)
*
* Version: @(#)scsi_buslogic.c 1.0.9 2017/08/25
* Version: @(#)scsi_buslogic.c 1.0.10 2017/08/26
*
* Authors: TheCollector1995, <mariogplayer@gmail.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -23,19 +23,18 @@
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include "ibm.h"
#include "io.h"
#include "mem.h"
#include "rom.h"
#include "dma.h"
#include "pic.h"
#include "pci.h"
#include "timer.h"
#include "device.h"
#include "../ibm.h"
#include "../io.h"
#include "../mem.h"
#include "../rom.h"
#include "../dma.h"
#include "../pic.h"
#include "../pci.h"
#include "../timer.h"
#include "../device.h"
#include "scsi.h"
#include "scsi_bios_command.h"
#include "scsi_device.h"
#include "scsi_disk.h"
#include "cdrom.h"
#include "scsi_buslogic.h"
@@ -506,6 +505,7 @@ typedef struct {
bios_size,
bios_mask;
uint8_t AutoSCSIROM[32768];
uint8_t SCAMData[65536];
} Buslogic_t;
#pragma pack(pop)
@@ -542,19 +542,6 @@ BuslogicLog(const char *format, ...)
}
#define pclog BuslogicLog
static void
SpecificLog(const char *format, ...)
{
#ifdef ENABLE_BUSLOGIC_LOG
va_list ap;
va_start(ap, format);
vprintf(format, ap);
va_end(ap);
fflush(stdout);
#endif
}
static void
BuslogicInterrupt(Buslogic_t *bl, int set)
{
@@ -591,13 +578,13 @@ BuslogicGetNVRFileName(Buslogic_t *bl)
switch(bl->chip)
{
case CHIP_BUSLOGIC_ISA:
return L"bt542b.nvr";
return L"bt545c.nvr";
case CHIP_BUSLOGIC_MCA:
return L"bt640.nvr";
return L"bt640a.nvr";
case CHIP_BUSLOGIC_VLB:
return L"bt445s.nvr";
case CHIP_BUSLOGIC_PCI:
return L"bt946c.nvr";
return L"bt958d.nvr";
default:
fatal("Unrecognized BusLogic chip: %i\n", bl->chip);
return NULL;
@@ -623,8 +610,8 @@ BuslogicInitializeAutoSCSIRam(Buslogic_t *bl, uint8_t safe)
case CHIP_BUSLOGIC_ISA:
HALR->structured.autoSCSIData.aHostAdaptertype[1] = '5';
HALR->structured.autoSCSIData.aHostAdaptertype[2] = '4';
HALR->structured.autoSCSIData.aHostAdaptertype[3] = '2';
HALR->structured.autoSCSIData.aHostAdaptertype[4] = 'B';
HALR->structured.autoSCSIData.aHostAdaptertype[3] = '5';
HALR->structured.autoSCSIData.aHostAdaptertype[4] = 'C';
break;
case CHIP_BUSLOGIC_VLB:
HALR->structured.autoSCSIData.aHostAdaptertype[1] = '4';
@@ -636,13 +623,13 @@ BuslogicInitializeAutoSCSIRam(Buslogic_t *bl, uint8_t safe)
HALR->structured.autoSCSIData.aHostAdaptertype[1] = '6';
HALR->structured.autoSCSIData.aHostAdaptertype[2] = '4';
HALR->structured.autoSCSIData.aHostAdaptertype[3] = '0';
HALR->structured.autoSCSIData.aHostAdaptertype[4] = ' ';
HALR->structured.autoSCSIData.aHostAdaptertype[4] = 'A';
break;
case CHIP_BUSLOGIC_PCI:
HALR->structured.autoSCSIData.aHostAdaptertype[1] = '9';
HALR->structured.autoSCSIData.aHostAdaptertype[2] = '4';
HALR->structured.autoSCSIData.aHostAdaptertype[3] = '6';
HALR->structured.autoSCSIData.aHostAdaptertype[4] = 'C';
HALR->structured.autoSCSIData.aHostAdaptertype[2] = '5';
HALR->structured.autoSCSIData.aHostAdaptertype[3] = '8';
HALR->structured.autoSCSIData.aHostAdaptertype[4] = 'D';
break;
}
HALR->structured.autoSCSIData.aHostAdaptertype[5] = ' ';
@@ -1160,7 +1147,7 @@ BuslogicSCSIBIOSDataBufferAllocate(ESCMD *ESCSICmd, uint8_t TargetID, uint8_t LU
DataPointer = ESCSICmd->DataPointer;
DataLength = ESCSICmd->DataLength;
SpecificLog("BIOS Data Buffer write: length %d, pointer 0x%04X\n",
pclog("BIOS Data Buffer write: length %d, pointer 0x%04X\n",
DataLength, DataPointer);
if (SCSIDevices[TargetID][LUN].CmdBuffer != NULL)
@@ -1198,7 +1185,7 @@ BuslogicSCSIBIOSDataBufferFree(ESCMD *ESCSICmd, uint8_t TargetID, uint8_t LUN)
DataLength = ESCSICmd->DataLength;
if ((DataLength != 0) && (ESCSICmd->CDB[0] == GPCMD_TEST_UNIT_READY)) {
SpecificLog("Data length not 0 with TEST UNIT READY: %i (%i)\n",
pclog("Data length not 0 with TEST UNIT READY: %i (%i)\n",
DataLength, SCSIDevices[TargetID][LUN].InitLength);
}
@@ -1206,7 +1193,7 @@ BuslogicSCSIBIOSDataBufferFree(ESCMD *ESCSICmd, uint8_t TargetID, uint8_t LUN)
DataLength = 0;
}
SpecificLog("BIOS Data Buffer read: length %d, pointer 0x%04X\n",
pclog("BIOS Data Buffer read: length %d, pointer 0x%04X\n",
DataLength, DataPointer);
/* If the control byte is 0x00, it means that the transfer direction is set up by the SCSI command without
@@ -1217,7 +1204,7 @@ BuslogicSCSIBIOSDataBufferFree(ESCMD *ESCSICmd, uint8_t TargetID, uint8_t LUN)
{
Address = DataPointer;
SpecificLog("BusLogic BIOS DMA: Writing %i bytes at %08X\n", DataLength, Address);
pclog("BusLogic BIOS DMA: Writing %i bytes at %08X\n", DataLength, Address);
DMAPageWrite(Address, (char *)SCSIDevices[TargetID][LUN].CmdBuffer, DataLength);
}
@@ -1230,7 +1217,7 @@ BuslogicSCSIBIOSDataBufferFree(ESCMD *ESCSICmd, uint8_t TargetID, uint8_t LUN)
}
ESCSICmd->DataLength = Residual;
SpecificLog("BIOS Residual data length for reading: %d\n",
pclog("BIOS Residual data length for reading: %d\n",
ESCSICmd->DataLength);
if (SCSIDevices[TargetID][LUN].CmdBuffer != NULL)
@@ -1257,7 +1244,7 @@ BuslogicSCSIBIOSRequestSetup(Buslogic_t *bl, uint8_t *CmdBuf, uint8_t *DataInBuf
return;
}
SpecificLog("Scanning SCSI Target ID %i\n", ESCSICmd->TargetId);
pclog("Scanning SCSI Target ID %i\n", ESCSICmd->TargetId);
SCSIStatus = SCSI_STATUS_OK;
SCSIDevices[ESCSICmd->TargetId][ESCSICmd->LogicalUnit].InitLength = 0;
@@ -1265,18 +1252,18 @@ BuslogicSCSIBIOSRequestSetup(Buslogic_t *bl, uint8_t *CmdBuf, uint8_t *DataInBuf
BuslogicSCSIBIOSDataBufferAllocate(ESCSICmd, ESCSICmd->TargetId, ESCSICmd->LogicalUnit);
if (!scsi_device_present(ESCSICmd->TargetId, ESCSICmd->LogicalUnit)) {
SpecificLog("SCSI Target ID %i and LUN %i have no device attached\n",ESCSICmd->TargetId,ESCSICmd->LogicalUnit);
pclog("SCSI Target ID %i and LUN %i have no device attached\n",ESCSICmd->TargetId,ESCSICmd->LogicalUnit);
BuslogicSCSIBIOSDataBufferFree(ESCSICmd, ESCSICmd->TargetId, ESCSICmd->LogicalUnit);
/* BuslogicSCSIBIOSSenseBufferFree(ESCSICmd, Id, Lun, 0, 0); */
DataInBuf[2] = CCB_SELECTION_TIMEOUT;
DataInBuf[3] = SCSI_STATUS_OK;
} else {
SpecificLog("SCSI Target ID %i and LUN %i detected and working\n", ESCSICmd->TargetId, ESCSICmd->LogicalUnit);
pclog("SCSI Target ID %i and LUN %i detected and working\n", ESCSICmd->TargetId, ESCSICmd->LogicalUnit);
SpecificLog("Transfer Control %02X\n", ESCSICmd->DataDirection);
SpecificLog("CDB Length %i\n", ESCSICmd->CDBLength);
pclog("Transfer Control %02X\n", ESCSICmd->DataDirection);
pclog("CDB Length %i\n", ESCSICmd->CDBLength);
if (ESCSICmd->DataDirection > 0x03) {
SpecificLog("Invalid control byte: %02X\n",
pclog("Invalid control byte: %02X\n",
ESCSICmd->DataDirection);
}
}
@@ -1285,11 +1272,11 @@ BuslogicSCSIBIOSRequestSetup(Buslogic_t *bl, uint8_t *CmdBuf, uint8_t *DataInBuf
if (!scsi_device_valid(ESCSICmd->TargetId, ESCSICmd->LogicalUnit)) fatal("SCSI target on %02i:%02i has disappeared\n", ESCSICmd->TargetId, ESCSICmd->LogicalUnit);
SpecificLog("SCSI target command being executed on: SCSI ID %i, SCSI LUN %i, Target %i\n", ESCSICmd->TargetId, ESCSICmd->LogicalUnit, target_id);
pclog("SCSI target command being executed on: SCSI ID %i, SCSI LUN %i, Target %i\n", ESCSICmd->TargetId, ESCSICmd->LogicalUnit, target_id);
SpecificLog("SCSI Cdb[0]=0x%02X\n", ESCSICmd->CDB[0]);
pclog("SCSI Cdb[0]=0x%02X\n", ESCSICmd->CDB[0]);
for (i = 1; i < ESCSICmd->CDBLength; i++) {
SpecificLog("SCSI Cdb[%i]=%i\n", i, ESCSICmd->CDB[i]);
pclog("SCSI Cdb[%i]=%i\n", i, ESCSICmd->CDB[i]);
}
memset(temp_cdb, 0, target_cdb_len);
@@ -1317,413 +1304,6 @@ BuslogicSCSIBIOSRequestSetup(Buslogic_t *bl, uint8_t *CmdBuf, uint8_t *DataInBuf
bl->DataReplyLeft = DataReply;
}
static uint8_t BuslogicCompletionCode(uint8_t *sense)
{
switch (sense[12])
{
case 0x00:
return 0x00;
case 0x20:
return 0x01;
case 0x12:
case 0x21:
return 0x02;
case 0x27:
return 0x03;
case 0x14: case 0x16:
return 0x04;
case 0x10: case 0x11:
return 0x10;
case 0x17: case 0x18:
return 0x11;
case 0x01: case 0x03: case 0x05: case 0x06: case 0x07: case 0x08: case 0x09:
case 0x1B: case 0x1C: case 0x1D:
case 0x40: case 0x41: case 0x42: case 0x43: case 0x44: case 0x45: case 0x46:
case 0x47: case 0x48: case 0x49:
return 0x20;
case 0x15:
case 0x02:
return 0x40;
case 0x04:
case 0x28: case 0x29: case 0x2A:
return 0xAA;
default:
return 0xFF;
}
}
uint8_t BuslogicBIOSCommand08(uint8_t id, uint8_t lun, uint8_t *buffer)
{
uint32_t len = 0;
uint8_t cdb[12] = { GPCMD_READ_CDROM_CAPACITY, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
uint8_t rcbuf[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
int ret = 0;
int i = 0;
uint8_t sc = 0;
ret = scsi_device_read_capacity(id, lun, cdb, rcbuf, &len);
sc = BuslogicCompletionCode(scsi_device_sense(id, lun));
if (ret == 0)
{
return sc;
}
memset(buffer, 0, 6);
for (i = 0; i < 4; i++)
{
buffer[i] = rcbuf[i];
}
for (i = 4; i < 6; i++)
{
buffer[i] = rcbuf[(i + 2) ^ 1];
}
SpecificLog("BIOS Command 0x08: %02X %02X %02X %02X %02X %02X\n", buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], buffer[5]);
return 0;
}
int BuslogicBIOSCommand15(uint8_t id, uint8_t lun, uint8_t *buffer)
{
uint32_t len = 0;
uint8_t cdb[12] = { GPCMD_READ_CDROM_CAPACITY, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
uint8_t rcbuf[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
int ret = 0;
int i = 0;
uint8_t sc = 0;
ret = scsi_device_read_capacity(id, lun, cdb, rcbuf, &len);
sc = BuslogicCompletionCode(scsi_device_sense(id, lun));
memset(buffer, 0, 6);
for (i = 0; i < 4; i++)
{
buffer[i] = (ret == 0) ? 0 : rcbuf[i];
}
scsi_device_type_data(id, lun, &(buffer[4]), &(buffer[5]));
SpecificLog("BIOS Command 0x15: %02X %02X %02X %02X %02X %02X\n", buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], buffer[5]);
return sc;
}
static void BuslogicIDCheck(uint8_t id, uint8_t lun)
{
if (!scsi_device_valid(id, lun))
{
fatal("BIOS INT13 CD-ROM on %02i:%02i has disappeared\n", id, lun);
}
}
/* This returns the completion code. */
uint8_t scsi_bios_cmd(uint8_t last_id, BIOSCMD *BiosCmd, int8_t islba)
{
uint32_t dma_address;
uint32_t lba;
int sector_len = BiosCmd->secount;
int block_shift = 9;
uint8_t ret = 0;
uint8_t cdb[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
if (islba)
lba = lba32_blk(BiosCmd);
else
lba = (BiosCmd->u.chs.cyl << 9) + (BiosCmd->u.chs.head << 5) + BiosCmd->u.chs.sec;
SpecificLog("BIOS Command = 0x%02X\n", BiosCmd->command);
if ((BiosCmd->id > last_id) || (BiosCmd->lun > 7)) {
return 0x80;
}
SCSIDevices[BiosCmd->id][BiosCmd->lun].InitLength = 0;
if (!scsi_device_present(BiosCmd->id, BiosCmd->lun))
{
SpecificLog("BIOS Target ID %i and LUN %i have no device attached\n",BiosCmd->id,BiosCmd->lun);
return 0x80;
}
dma_address = ADDR_TO_U32(BiosCmd->dma_address);
SpecificLog("BIOS Data Buffer write: length %d, pointer 0x%04X\n", sector_len, dma_address);
if (SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer != NULL)
{
free(SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer);
SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer = NULL;
}
block_shift = scsi_device_block_shift(BiosCmd->id, BiosCmd->lun);
switch(BiosCmd->command)
{
case 0x00: /* Reset Disk System, in practice it's a nop */
return 0;
case 0x01: /* Read Status of Last Operation */
BuslogicIDCheck(BiosCmd->id, BiosCmd->lun);
/* Assuming 14 bytes because that's the default length for SCSI sense, and no command-specific
indication is given. */
SCSIDevices[BiosCmd->id][BiosCmd->lun].InitLength = 14;
SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer = (uint8_t *) malloc(14);
memset(SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer, 0, 14);
/* SCSIStatus = BuslogicBIOSCommand08(BiosCmd->id, BiosCmd->lun, SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer) ? SCSI_STATUS_OK : SCSI_STATUS_CHECK_CONDITION; */
if (sector_len > 0)
{
SpecificLog("BusLogic BIOS DMA: Reading 14 bytes at %08X\n", dma_address);
DMAPageWrite(dma_address, (char *)scsi_device_sense(BiosCmd->id, BiosCmd->lun), 14);
}
if (SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer != NULL)
{
free(SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer);
SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer = NULL;
}
return 0;
break;
case 0x02: /* Read Desired Sectors to Memory */
BuslogicIDCheck(BiosCmd->id, BiosCmd->lun);
SCSIDevices[BiosCmd->id][BiosCmd->lun].InitLength = sector_len << block_shift;
SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer = (uint8_t *) malloc(sector_len << block_shift);
memset(SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer, 0, sector_len << block_shift);
cdb[0] = GPCMD_READ_10;
cdb[1] = (BiosCmd->lun & 7) << 5;
cdb[2] = (lba >> 24) & 0xff;
cdb[3] = (lba >> 16) & 0xff;
cdb[4] = (lba >> 8) & 0xff;
cdb[5] = lba & 0xff;
cdb[7] = (sector_len >> 8) & 0xff;
cdb[8] = sector_len & 0xff;
#if 0
pclog("BIOS CMD(READ, %08lx, %d)\n", lba, BiosCmd->secount);
#endif
scsi_device_command(BiosCmd->id, BiosCmd->lun, 12, cdb);
if (sector_len > 0)
{
SpecificLog("BIOS DMA: Reading %i bytes at %08X\n", sector_len << block_shift, dma_address);
DMAPageWrite(dma_address, (char *)SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer, sector_len << block_shift);
}
if (SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer != NULL)
{
free(SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer);
SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer = NULL;
}
return BuslogicCompletionCode(scsi_device_sense(BiosCmd->id, BiosCmd->lun));
break;
case 0x03: /* Write Desired Sectors from Memory */
BuslogicIDCheck(BiosCmd->id, BiosCmd->lun);
SCSIDevices[BiosCmd->id][BiosCmd->lun].InitLength = sector_len << block_shift;
SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer = (uint8_t *) malloc(sector_len << block_shift);
memset(SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer, 0, sector_len << block_shift);
if (sector_len > 0)
{
SpecificLog("BIOS DMA: Reading %i bytes at %08X\n", sector_len << block_shift, dma_address);
DMAPageRead(dma_address, (char *)SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer, sector_len << block_shift);
}
cdb[0] = GPCMD_WRITE_10;
cdb[1] = (BiosCmd->lun & 7) << 5;
cdb[2] = (lba >> 24) & 0xff;
cdb[3] = (lba >> 16) & 0xff;
cdb[4] = (lba >> 8) & 0xff;
cdb[5] = lba & 0xff;
cdb[7] = (sector_len >> 8) & 0xff;
cdb[8] = sector_len & 0xff;
#if 0
pclog("BIOS CMD(WRITE, %08lx, %d)\n", lba, BiosCmd->secount);
#endif
scsi_device_command(BiosCmd->id, BiosCmd->lun, 12, cdb);
if (SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer != NULL)
{
free(SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer);
SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer = NULL;
}
return BuslogicCompletionCode(scsi_device_sense(BiosCmd->id, BiosCmd->lun));
break;
case 0x04: /* Verify Desired Sectors */
BuslogicIDCheck(BiosCmd->id, BiosCmd->lun);
cdb[0] = GPCMD_VERIFY_10;
cdb[1] = (BiosCmd->lun & 7) << 5;
cdb[2] = (lba >> 24) & 0xff;
cdb[3] = (lba >> 16) & 0xff;
cdb[4] = (lba >> 8) & 0xff;
cdb[5] = lba & 0xff;
cdb[7] = (sector_len >> 8) & 0xff;
cdb[8] = sector_len & 0xff;
scsi_device_command(BiosCmd->id, BiosCmd->lun, 12, cdb);
return BuslogicCompletionCode(scsi_device_sense(BiosCmd->id, BiosCmd->lun));
break;
case 0x05: /* Format Track, invalid since SCSI has no tracks */
return 1;
break;
case 0x06: /* Identify SCSI Devices, in practice it's a nop */
return 0;
break;
case 0x07: /* Format Unit */
BuslogicIDCheck(BiosCmd->id, BiosCmd->lun);
cdb[0] = GPCMD_FORMAT_UNIT;
cdb[1] = (BiosCmd->lun & 7) << 5;
scsi_device_command(BiosCmd->id, BiosCmd->lun, 12, cdb);
return BuslogicCompletionCode(scsi_device_sense(BiosCmd->id, BiosCmd->lun));
break;
case 0x08: /* Read Drive Parameters */
BuslogicIDCheck(BiosCmd->id, BiosCmd->lun);
SCSIDevices[BiosCmd->id][BiosCmd->lun].InitLength = 6;
SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer = (uint8_t *) malloc(6);
memset(SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer, 0, 6);
ret = BuslogicBIOSCommand08(BiosCmd->id, BiosCmd->lun, SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer);
SpecificLog("BIOS DMA: Reading 6 bytes at %08X\n", dma_address);
DMAPageWrite(dma_address, (char *)SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer, 6);
if (SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer != NULL)
{
free(SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer);
SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer = NULL;
}
return ret;
break;
case 0x09: /* Initialize Drive Pair Characteristics, in practice it's a nop */
return 0;
break;
case 0x0C: /* Seek */
BuslogicIDCheck(BiosCmd->id, BiosCmd->lun);
SCSIDevices[BiosCmd->id][BiosCmd->lun].InitLength = sector_len << block_shift;
cdb[0] = GPCMD_SEEK_10;
cdb[1] = (BiosCmd->lun & 7) << 5;
cdb[2] = (lba >> 24) & 0xff;
cdb[3] = (lba >> 16) & 0xff;
cdb[4] = (lba >> 8) & 0xff;
cdb[5] = lba & 0xff;
scsi_device_command(BiosCmd->id, BiosCmd->lun, 12, cdb);
return (SCSIStatus == SCSI_STATUS_OK) ? 1 : 0;
break;
case 0x0D: /* Alternate Disk Reset, in practice it's a nop */
return 0;
break;
case 0x10: /* Test Drive Ready */
BuslogicIDCheck(BiosCmd->id, BiosCmd->lun);
cdb[0] = GPCMD_TEST_UNIT_READY;
cdb[1] = (BiosCmd->lun & 7) << 5;
scsi_device_command(BiosCmd->id, BiosCmd->lun, 12, cdb);
return BuslogicCompletionCode(scsi_device_sense(BiosCmd->id, BiosCmd->lun));
break;
case 0x11: /* Recalibrate */
BuslogicIDCheck(BiosCmd->id, BiosCmd->lun);
cdb[0] = GPCMD_REZERO_UNIT;
cdb[1] = (BiosCmd->lun & 7) << 5;
scsi_device_command(BiosCmd->id, BiosCmd->lun, 12, cdb);
return BuslogicCompletionCode(scsi_device_sense(BiosCmd->id, BiosCmd->lun));
break;
case 0x14: /* Controller Diagnostic */
return 0;
break;
case 0x15: /* Read DASD Type */
BuslogicIDCheck(BiosCmd->id, BiosCmd->lun);
SCSIDevices[BiosCmd->id][BiosCmd->lun].InitLength = 6;
SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer = (uint8_t *) malloc(6);
memset(SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer, 0, 6);
ret = BuslogicBIOSCommand15(BiosCmd->id, BiosCmd->lun, SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer);
SpecificLog("BusLogic BIOS DMA: Reading 6 bytes at %08X\n", dma_address);
DMAPageWrite(dma_address, (char *)SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer, 6);
if (SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer != NULL)
{
free(SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer);
SCSIDevices[BiosCmd->id][BiosCmd->lun].CmdBuffer = NULL;
}
return ret;
break;
default:
SpecificLog("BusLogic BIOS: Unimplemented command: %02X\n", BiosCmd->command);
return 1;
break;
}
pclog("BIOS Request complete\n");
}
static uint8_t
BuslogicRead(uint16_t Port, void *p)
{
@@ -1822,7 +1402,6 @@ BuslogicWrite(uint16_t Port, uint8_t Val, void *p)
char aModelName[] = "542B "; /* Trailing \0 is fine, that's the filler anyway. */
int cCharsToTransfer;
uint16_t cyl = 0;
uint8_t temp = 0;
FILE *f;
pclog("Buslogic: Write Port 0x%02X, Value %02X\n", Port, Val);
@@ -1860,7 +1439,7 @@ BuslogicWrite(uint16_t Port, uint8_t Val, void *p)
bl->CmdParamLeft = 0;
bl->Status &= ~(STAT_INVCMD | STAT_IDLE);
SpecificLog("Buslogic: Operation Code 0x%02X\n", Val);
pclog("Buslogic: Operation Code 0x%02X\n", Val);
switch (bl->Command) {
case 0x01:
bl->CmdParamLeft = sizeof(MailboxInit_t);
@@ -1934,6 +1513,15 @@ BuslogicWrite(uint16_t Port, uint8_t Val, void *p)
case 0x95: /* Valid only for PCI */
bl->CmdParamLeft = (bl->chip == CHIP_BUSLOGIC_PCI) ? 1 : 0;
break;
case 0x97: /* Valid only for PCI */
case 0xA7: /* Valid only for PCI */
bl->CmdParamLeft = (bl->chip == CHIP_BUSLOGIC_PCI) ? 10 : 0;
case 0xA8: /* Valid only for PCI */
case 0xA9: /* Valid only for PCI */
bl->CmdParamLeft = (bl->chip == CHIP_BUSLOGIC_PCI) ? 4 : 0;
break;
}
} else {
bl->CmdBuf[bl->CmdParam] = Val;
@@ -1944,11 +1532,27 @@ BuslogicWrite(uint16_t Port, uint8_t Val, void *p)
{
bl->CmdParamLeft = bl->CmdBuf[1];
}
if ((bl->CmdParam == 10) && ((bl->Command == 0x97) || (bl->Command == 0xA7)))
{
bl->CmdParamLeft = bl->CmdBuf[6];
bl->CmdParamLeft <<= 8;
bl->CmdParamLeft |= bl->CmdBuf[7];
bl->CmdParamLeft <<= 8;
bl->CmdParamLeft |= bl->CmdBuf[8];
}
if ((bl->CmdParam == 4) && (bl->Command == 0xA9))
{
bl->CmdParamLeft = bl->CmdBuf[3];
bl->CmdParamLeft <<= 8;
bl->CmdParamLeft |= bl->CmdBuf[2];
}
}
if (!bl->CmdParamLeft)
{
SpecificLog("Running Operation Code 0x%02X\n", bl->Command);
pclog("Running Operation Code 0x%02X\n", bl->Command);
bl->DataReply = 0;
switch (bl->Command) {
case 0x00:
@@ -1976,19 +1580,30 @@ BuslogicWrite(uint16_t Port, uint8_t Val, void *p)
case 0x03:
BiosCmd = (BIOSCMD *)bl->CmdBuf;
if (bl->chip != CHIP_BUSLOGIC_MCA) {
cyl = ((BiosCmd->u.chs.cyl & 0xff) << 8) | ((BiosCmd->u.chs.cyl >> 8) & 0xff);
BiosCmd->u.chs.cyl = cyl;
if (bl->chip == CHIP_BUSLOGIC_PCI)
{
temp = BiosCmd->id;
BiosCmd->id = BiosCmd->lun;
BiosCmd->lun = temp;
}
if (bl->chip == CHIP_BUSLOGIC_MCA) {
pclog("BIOS LBA=%06lx (%lu)\n",
lba32_blk(BiosCmd),
lba32_blk(BiosCmd));
} else {
BiosCmd->u.chs.head &= 0xf;
BiosCmd->u.chs.sec &= 0x1f;
pclog("BIOS CHS=%04X/%02X%02X\n",
BiosCmd->u.chs.cyl,
BiosCmd->u.chs.head,
BiosCmd->u.chs.sec);
}
BiosCmd->u.chs.cyl = cyl;
BiosCmd->u.chs.head &= 0x0f;
BiosCmd->u.chs.sec &= 0x1f;
SpecificLog("C: %04X, H: %02X, S: %02X\n", BiosCmd->u.chs.cyl, BiosCmd->u.chs.head, BiosCmd->u.chs.sec);
bl->DataBuf[0] = scsi_bios_cmd(15, BiosCmd, 0);
SpecificLog("BIOS Completion/Status Code %x\n", bl->DataBuf[0]);
pclog("C: %04X, H: %02X, S: %02X\n", BiosCmd->u.chs.cyl, BiosCmd->u.chs.head, BiosCmd->u.chs.sec);
bl->DataBuf[0] = scsi_bios_command(15, BiosCmd, (bl->chip == CHIP_BUSLOGIC_MCA) ? 1 : 0);
pclog("BIOS Completion/Status Code %x\n", bl->DataBuf[0]);
bl->DataReplyLeft = 1;
break;
@@ -1996,7 +1611,7 @@ BuslogicWrite(uint16_t Port, uint8_t Val, void *p)
pclog("Inquire Board\n");
bl->DataBuf[0] = (bl->chip == CHIP_BUSLOGIC_MCA) ? 0x42 : 0x41;
bl->DataBuf[1] = 0x41;
bl->DataBuf[2] = (bl->chip == CHIP_BUSLOGIC_PCI) ? '5' : '2';
bl->DataBuf[2] = (bl->chip == CHIP_BUSLOGIC_PCI) ? '5' : '4';
bl->DataBuf[3] = (bl->chip == CHIP_BUSLOGIC_PCI) ? '0' : '2';
bl->DataReplyLeft = 4;
break;
@@ -2270,14 +1885,14 @@ BuslogicWrite(uint16_t Port, uint8_t Val, void *p)
case CHIP_BUSLOGIC_ISA:
aModelName[0] = '5';
aModelName[1] = '4';
aModelName[2] = '2';
aModelName[3] = 'B';
aModelName[2] = '5';
aModelName[3] = 'C';
break;
case CHIP_BUSLOGIC_MCA:
aModelName[0] = '6';
aModelName[1] = '4';
aModelName[2] = '0';
aModelName[3] = 0x00;
aModelName[3] = 'A';
break;
case CHIP_BUSLOGIC_VLB:
aModelName[0] = '4';
@@ -2287,8 +1902,8 @@ BuslogicWrite(uint16_t Port, uint8_t Val, void *p)
break;
case CHIP_BUSLOGIC_PCI:
aModelName[0] = '9';
aModelName[1] = '4';
aModelName[2] = '6';
aModelName[1] = '5';
aModelName[2] = '8';
aModelName[3] = 'C';
break;
}
@@ -2341,7 +1956,7 @@ BuslogicWrite(uint16_t Port, uint8_t Val, void *p)
ReplyIESI->fHostUltraSCSI = 1;
}
memcpy(ReplyIESI->aFirmwareRevision, (bl->chip == CHIP_BUSLOGIC_PCI) ? "07B" : "21E", sizeof(ReplyIESI->aFirmwareRevision));
SpecificLog("Return Extended Setup Information: %d\n", bl->CmdBuf[0]);
pclog("Return Extended Setup Information: %d\n", bl->CmdBuf[0]);
break;
/* VirtualBox has these two modes implemented in reverse.
@@ -2407,7 +2022,7 @@ BuslogicWrite(uint16_t Port, uint8_t Val, void *p)
case 0x94:
if (bl->CmdBuf[0])
{
SpecificLog("Invalid AutoSCSI command mode %x\n", bl->CmdBuf[0]);
pclog("Invalid AutoSCSI command mode %x\n", bl->CmdBuf[0]);
bl->DataReplyLeft = 0;
bl->Status |= STAT_INVCMD;
}
@@ -2481,8 +2096,57 @@ BuslogicWrite(uint16_t Port, uint8_t Val, void *p)
bl->DataReplyLeft = 0;
break;
case 0x97:
case 0xA7:
/* TODO: Actually correctly implement this whole SCSI BIOS Flash stuff. */
bl->DataReplyLeft = 0;
break;
case 0xA8:
if (bl->chip != CHIP_BUSLOGIC_PCI)
{
bl->DataReplyLeft = 0;
bl->Status |= STAT_INVCMD;
break;
}
Offset = bl->CmdBuf[1];
Offset <<= 8;
Offset |= bl->CmdBuf[0];
bl->DataReplyLeft = bl->CmdBuf[3];
bl->DataReplyLeft <<= 8;
bl->DataReplyLeft |= bl->CmdBuf[2];
memcpy(bl->DataBuf, &(bl->SCAMData[Offset]), bl->DataReplyLeft);
bl->DataReply = 0;
break;
case 0xA9:
if (bl->chip != CHIP_BUSLOGIC_PCI)
{
bl->DataReplyLeft = 0;
bl->Status |= STAT_INVCMD;
break;
}
Offset = bl->CmdBuf[1];
Offset <<= 8;
Offset |= bl->CmdBuf[0];
bl->DataReplyLeft = bl->CmdBuf[3];
bl->DataReplyLeft <<= 8;
bl->DataReplyLeft |= bl->CmdBuf[2];
memcpy(&(bl->SCAMData[Offset]), &(bl->CmdBuf[4]), bl->DataReplyLeft);
bl->DataReplyLeft = 0;
bl->DataReply = 0;
break;
default:
SpecificLog("Invalid command %x\n", bl->Command);
pclog("Invalid command %x\n", bl->Command);
bl->DataReplyLeft = 0;
bl->Status |= STAT_INVCMD;
break;
@@ -3084,6 +2748,15 @@ static void *
BuslogicInit(int chip)
{
Buslogic_t *bl;
wchar_t *bios_rom_name;
uint16_t bios_rom_size;
uint16_t bios_rom_mask;
uint8_t has_autoscsi_rom;
wchar_t *autoscsi_rom_name;
uint16_t autoscsi_rom_size;
uint8_t has_scam_rom;
wchar_t *scam_rom_name;
uint16_t scam_rom_size;
FILE *f;
bl = malloc(sizeof(Buslogic_t));
@@ -3116,6 +2789,38 @@ BuslogicInit(int chip)
}
}
switch(bl->chip)
{
case CHIP_BUSLOGIC_ISA:
default:
bios_rom_name = L"roms/scsi/buslogic/BT-545C_BIOS.rom";
bios_rom_size = 0x4000;
bios_rom_mask = 0x3fff;
has_autoscsi_rom = 1;
autoscsi_rom_name = L"roms/scsi/buslogic/BT-545C_AutoSCSI.rom";
autoscsi_rom_size = 0x4000;
has_scam_rom = 0;
break;
case CHIP_BUSLOGIC_PCI:
bios_rom_name = L"roms/scsi/buslogic/BT-958D_BIOS.rom";
bios_rom_size = 0x8000;
bios_rom_mask = 0x7fff;
has_autoscsi_rom = 1;
autoscsi_rom_name = L"roms/scsi/buslogic/BT-958D_AutoSCSI.rom";
autoscsi_rom_size = 0x8000;
has_scam_rom = 1;
scam_rom_name = L"roms/scsi/buslogic/BT-958D_SCAM.rom";
scam_rom_size = 0x0200;
break;
}
memset(bl->AutoSCSIROM, 0xff, 32768);
memset(bl->SCAMData, 0x00, 65536);
if (bl->has_bios)
{
bl->bios_size = 0x8000;
@@ -3123,26 +2828,30 @@ BuslogicInit(int chip)
bl->bios_mask = (bl->bios_size >> 8) & 0xff;
bl->bios_mask = (0x100 - bl->bios_mask) & 0xff;
if(bl->chip == CHIP_BUSLOGIC_ISA)
{
rom_init(&bl->bios, L"roms/scsi/buslogic/542_470.ROM", 0xd8000, 0x4000, 0x3fff, 0, MEM_MAPPING_EXTERNAL);
}
else
{
/* rom_init(&bl->bios, L"roms/scsi/buslogic/428A494G.BIN", 0xd8000, 0x4000, 0x3fff, 0, MEM_MAPPING_EXTERNAL); */
/* rom_init(&bl->bios, L"roms/scsi/buslogic/BT9X6C_BIOS.rom", 0xd8000, 0x4000, 0x3fff, 0, MEM_MAPPING_EXTERNAL); */
rom_init(&bl->bios, L"roms/scsi/buslogic/Womper97.rom", 0xd8000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL);
}
rom_init(&bl->bios, bios_rom_name, 0xd8000, bios_rom_size, bios_rom_mask, 0, MEM_MAPPING_EXTERNAL);
memset(bl->AutoSCSIROM, 0xff, 32768);
f = romfopen(L"roms/scsi/buslogic/AutoSCSI.rom", L"rb");
if (has_autoscsi_rom)
{
f = romfopen(autoscsi_rom_name, L"rb");
if (f)
{
fread(bl->AutoSCSIROM, 1, 32768, f);
fread(bl->AutoSCSIROM, 1, autoscsi_rom_size, f);
fclose(f);
f = NULL;
}
}
if (has_scam_rom)
{
f = romfopen(scam_rom_name, L"rb");
if (f)
{
fread(bl->SCAMData, 1, scam_rom_size, f);
fclose(f);
f = NULL;
}
}
}
else
{
bl->bios_size = 0;
@@ -3210,14 +2919,14 @@ BuslogicInit(int chip)
static void *
Buslogic_542B_Init(void)
Buslogic_545C_Init(void)
{
return BuslogicInit(CHIP_BUSLOGIC_ISA);
}
static void *
Buslogic_946C_Init(void)
Buslogic_958D_Init(void)
{
return BuslogicInit(CHIP_BUSLOGIC_PCI);
}
@@ -3315,9 +3024,9 @@ static device_config_t BuslogicConfig[] = {
device_t buslogic_device = {
"Buslogic BT-542B ISA",
"Buslogic BT-545C ISA",
0,
Buslogic_542B_Init,
Buslogic_545C_Init,
BuslogicClose,
NULL,
NULL,
@@ -3327,9 +3036,9 @@ device_t buslogic_device = {
};
device_t buslogic_pci_device = {
"Buslogic BT-946C PCI",
"Buslogic BT-958D PCI",
0,
Buslogic_946C_Init,
Buslogic_958D_Init,
BuslogicClose,
NULL,
NULL,

View File

@@ -15,10 +15,10 @@
* Copyright 2016,2017 Miran Grca.
* Copyright 2017 Fred N. van Kempen.
*/
#include "ibm.h"
#include "../ibm.h"
#include "scsi.h"
#include "scsi_disk.h"
#include "cdrom.h"
#include "../cdrom.h"
static uint8_t scsi_null_device_sense[14] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0 };

View File

@@ -16,16 +16,16 @@
#include <stdio.h>
#include <stdarg.h>
#include "86box.h"
#include "cdrom.h"
#include "ibm.h"
#include "hdd_image.h"
#include "hdd_ide_at.h"
#include "piix.h"
#include "../86box.h"
#include "../cdrom.h"
#include "../ibm.h"
#include "../HDD/hdd_image.h"
#include "../HDD/hdd_ide_at.h"
#include "../piix.h"
#include "scsi.h"
#include "scsi_disk.h"
#include "timer.h"
#include "WIN/plat_iodev.h"
#include "../timer.h"
#include "../WIN/plat_iodev.h"
/* Bits of 'status' */

View File

@@ -11,7 +11,9 @@
#ifdef USE_FLUIDSYNTH
# include "midi_fluidsynth.h"
#endif
#include "midi_mt32.h"
#ifdef USE_MUNT
# include "midi_mt32.h"
#endif
#include "midi_system.h"
int midi_device_current = 0;
@@ -30,8 +32,10 @@ static MIDI_DEVICE devices[] =
#ifdef USE_FLUIDSYNTH
{"FluidSynth", "fluidsynth", &fluidsynth_device},
#endif
#ifdef USE_MUNT
{"Roland MT-32 Emulation", "mt32", &mt32_device},
{"Roland CM-32L Emulation", "cm32l", &cm32l_device},
#endif
{SYSTEM_MIDI_NAME, SYSTEM_MIDI_INTERNAL_NAME, &system_midi_device},
{"", "", NULL}
};

View File

@@ -28,9 +28,11 @@
#include "snd_opl.h"
#include "snd_adlib.h"
#include "snd_adlibgold.h"
#if 0
#ifdef DEV_BRANCH
#ifdef USE_PAS16
#include "snd_pas16.h"
#endif
#endif
#include "snd_sb.h"
#include "snd_sb_dsp.h"
#include "snd_wss.h"
@@ -64,8 +66,10 @@ static SOUND_CARD sound_cards[] =
{ "Sound Blaster AWE32", "sbawe32", &sb_awe32_device },
{ "Adlib Gold", "adlibgold", &adgold_device },
{ "Windows Sound System", "wss", &wss_device },
#if 0
#ifdef DEV_BRANCH
#ifdef USE_PAS16
{ "Pro Audio Spectrum 16", "pas16", &pas16_device },
#endif
#endif
{ "", "", NULL }
};

View File

@@ -27,9 +27,11 @@
#include "vid_ati_mach64.h"
#include "vid_cga.h"
#ifdef DEV_BRANCH
#ifdef USE_CIRRUS
#include "vid_cl_ramdac.h" /* vid_cl_gd.c needs this */
#include "vid_cl_gd.h"
#endif
#endif
#include "vid_ega.h"
#include "vid_et4000.h"
#include "vid_et4000w32.h"
@@ -40,8 +42,10 @@
#include "vid_colorplus.h"
#include "vid_mda.h"
#ifdef DEV_BRANCH
#ifdef USE_RIVA
#include "vid_nv_riva128.h"
#endif
#endif
#include "vid_olivetti_m24.h"
#include "vid_oti067.h"
#include "vid_paradise.h"
@@ -94,8 +98,10 @@ static VIDEO_CARD video_cards[] =
{"MDSI Genius", "genius", &genius_device, GFX_GENIUS},
{"Number Nine 9FX (S3 Trio64)", "n9_9fx", &s3_9fx_device, GFX_N9_9FX},
#ifdef DEV_BRANCH
#ifdef USE_RIVA
{"nVidia RIVA 128", "riva128", &riva128_device, GFX_RIVA128},
{"nVidia RIVA TNT", "rivatnt", &rivatnt_device, GFX_RIVATNT},
#endif
#endif
{"OAK OTI-067", "oti067", &oti067_device, GFX_OTI067},
{"OAK OTI-077", "oti077", &oti077_device, GFX_OTI077},

View File

@@ -8,7 +8,7 @@
*
* Windows resource script.
*
* Version: @(#)86Box.rc 1.0.6 2017/08/24
* Version: @(#)86Box.rc 1.0.7 2017/08/26
*
* Authors: Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com>
@@ -131,9 +131,11 @@ BEGIN
# ifdef ENABLE_SERIAL_LOG
MENUITEM "Enable Serial Port logs\tCtrl+F3", IDM_LOG_SERIAL
# endif
#ifdef USE_NETWORK
# ifdef ENABLE_NIC_LOG
MENUITEM "Enable Network logs\tCtrl+F9", IDM_LOG_NIC
# endif
#endif
# ifdef ENABLE_LOG_COMMANDS
# ifdef ENABLE_LOG_TOGGLES
MENUITEM SEPARATOR
@@ -336,6 +338,7 @@ BEGIN
BS_AUTOCHECKBOX | WS_TABSTOP,7,99,94,10
END
#ifdef USE_NETWORK
DLG_CFG_NETWORK DIALOG DISCARDABLE 97, 0, 267, 63
STYLE DS_CONTROL | WS_CHILD
FONT 9, "Segoe UI"
@@ -353,6 +356,7 @@ BEGIN
WS_TABSTOP
PUSHBUTTON "Configure",IDC_CONFIGURE_NET,214,43,46,12
END
#endif
DLG_CFG_PERIPHERALS DIALOG DISCARDABLE 97, 0, 267, 115
STYLE DS_CONTROL | WS_CHILD
@@ -515,16 +519,24 @@ END
177 ICON DISCARDABLE "WIN/ICONS/removable_disk_active.ico"
192 ICON DISCARDABLE "WIN/ICONS/hard_disk.ico"
193 ICON DISCARDABLE "WIN/ICONS/hard_disk_active.ico"
#ifdef USE_NETWORK
208 ICON DISCARDABLE "WIN/ICONS/network.ico"
209 ICON DISCARDABLE "WIN/ICONS/network_active.ico"
#endif
256 ICON DISCARDABLE "WIN/ICONS/machine.ico"
257 ICON DISCARDABLE "WIN/ICONS/display.ico"
258 ICON DISCARDABLE "WIN/ICONS/input_devices.ico"
259 ICON DISCARDABLE "WIN/ICONS/sound.ico"
#ifdef USE_NETWORK
260 ICON DISCARDABLE "WIN/ICONS/network.ico"
261 ICON DISCARDABLE "WIN/ICONS/other_peripherals.ico"
262 ICON DISCARDABLE "WIN/ICONS/hard_disk.ico"
263 ICON DISCARDABLE "WIN/ICONS/removable_devices.ico"
#else
260 ICON DISCARDABLE "WIN/ICONS/other_peripherals.ico"
261 ICON DISCARDABLE "WIN/ICONS/hard_disk.ico"
262 ICON DISCARDABLE "WIN/ICONS/removable_devices.ico"
#endif
384 ICON DISCARDABLE "WIN/ICONS/floppy_525_empty.ico"
385 ICON DISCARDABLE "WIN/ICONS/floppy_525_empty_active.ico"
400 ICON DISCARDABLE "WIN/ICONS/floppy_35_empty.ico"
@@ -615,6 +627,7 @@ BEGIN
BOTTOMMARGIN, 109
END
#ifdef USE_NETWORK
CONFIGUREDLG_NETWORK, DIALOG
BEGIN
LEFTMARGIN, 7
@@ -622,6 +635,7 @@ BEGIN
TOPMARGIN, 7
BOTTOMMARGIN, 56
END
#endif
CONFIGUREDLG_PERIPHERALS, DIALOG
BEGIN
@@ -682,10 +696,16 @@ BEGIN
IDS_2066 "Display"
IDS_2067 "Input devices"
IDS_2068 "Sound"
#ifdef USE_NETWORK
IDS_2069 "Network"
IDS_2070 "Other peripherals"
IDS_2071 "Hard disks"
IDS_2072 "Removable devices"
#else
IDS_2069 "Other peripherals"
IDS_2070 "Hard disks"
IDS_2071 "Removable devices"
#endif
IDS_2073 "Unable to create bitmap file: %s"
IDS_2074 "Use CTRL+ALT+PAGE DOWN to return to windowed mode"
IDS_2075 "CD-ROM images (*.ISO;*.CUE)\0*.ISO;*.CUE\0All files (*.*)\0*.*\0"
@@ -769,9 +789,11 @@ END
STRINGTABLE DISCARDABLE
BEGIN
#ifdef USE_NETWORK
IDS_2139 "PCap failed to set up because it may not be initialized"
IDS_2140 "No PCap devices found"
IDS_2141 "Invalid PCap device"
#endif
IDS_2142 "&Notify disk change"
IDS_2143 "Type"
IDS_2144 "Standard 2-button joystick(s)"

View File

@@ -8,7 +8,7 @@
*
* The Emulator's Windows core.
*
* Version: @(#)win.c 1.0.6 2017/08/24
* Version: @(#)win.c 1.0.7 2017/08/26
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -24,22 +24,24 @@
#include "../device.h"
#include "../disc.h"
#include "../fdd.h"
#include "../hdd.h"
#include "../HDD/hdd.h"
#include "../ibm.h"
#include "../CPU/cpu.h"
#include "../mem.h"
#ifdef USE_NETWORK
#include "../NETWORK/network.h"
#endif
#include "../rom.h"
#include "../nvr.h"
#include "../config.h"
#include "../model.h"
#include "../hdd_ide_at.h"
#include "../HDD/hdd_ide_at.h"
#include "../cdrom.h"
#include "../cdrom_null.h"
#include "../cdrom_ioctl.h"
#include "../cdrom_image.h"
#include "../scsi.h"
#include "../scsi_disk.h"
#include "../SCSI/scsi.h"
#include "../SCSI/scsi_disk.h"
#include "../VIDEO/video.h"
#include "../VIDEO/vid_ega.h"
#include "../mouse.h"
@@ -889,6 +891,7 @@ void create_hd_tip(int part)
wcscpy(sbTips[part], tempTip);
}
#ifdef USE_NETWORK
void create_network_tip(int part)
{
WCHAR tempTip[512];
@@ -902,6 +905,7 @@ void create_network_tip(int part)
sbTips[part] = (WCHAR *) malloc((wcslen(tempTip) << 1) + 2);
wcscpy(sbTips[part], tempTip);
}
#endif
void update_tip(int meaning)
{
@@ -1031,6 +1035,7 @@ void destroy_tips(void)
sbTips = NULL;
}
#ifdef USE_NETWORK
int display_network_icon(void)
{
if (network_card == 0)
@@ -1049,6 +1054,7 @@ int display_network_icon(void)
}
}
}
#endif
void update_status_bar_panes(HWND hwnds)
{
@@ -1062,7 +1068,9 @@ void update_status_bar_panes(HWND hwnds)
int c_ide_dma = 0;
int c_scsi = 0;
#ifdef USE_NETWORK
int do_net = 0;
#endif
sb_ready = 0;
@@ -1073,7 +1081,9 @@ void update_status_bar_panes(HWND hwnds)
c_ide_dma = count_hard_disks(HDD_BUS_IDE_PIO_AND_DMA);
c_scsi = count_hard_disks(HDD_BUS_SCSI);
#ifdef USE_NETWORK
do_net = display_network_icon();
#endif
if (sb_parts > 0)
{
@@ -1168,10 +1178,12 @@ void update_status_bar_panes(HWND hwnds)
{
sb_parts++;
}
#ifdef USE_NETWORK
if (do_net)
{
sb_parts++;
}
#endif
sb_parts++;
iStatusWidths = (int *) malloc(sb_parts * sizeof(int));
@@ -1275,6 +1287,7 @@ void update_status_bar_panes(HWND hwnds)
sb_part_meanings[sb_parts] = SB_HDD | HDD_BUS_SCSI;
sb_parts++;
}
#ifdef USE_NETWORK
if (do_net)
{
edge += SB_ICON_WIDTH;
@@ -1282,6 +1295,7 @@ void update_status_bar_panes(HWND hwnds)
sb_part_meanings[sb_parts] = SB_NETWORK;
sb_parts++;
}
#endif
if (sb_parts)
{
iStatusWidths[sb_parts - 1] += (24 - SB_ICON_WIDTH);
@@ -1342,11 +1356,13 @@ void update_status_bar_panes(HWND hwnds)
sb_part_icons[i] = 192;
create_hd_tip(i);
break;
#ifdef USE_NETWORK
case SB_NETWORK:
/* Hard disk */
sb_part_icons[i] = 208;
create_network_tip(i);
break;
#endif
case SB_TEXT:
/* Status text */
SendMessage(hwnds, SB_SETTEXT, i | SBT_NOBORDERS, (LPARAM) L"");
@@ -1401,10 +1417,12 @@ HWND EmulatorStatusBar(HWND hwndParent, int idStatus, HINSTANCE hinst)
hIcon[i] = LoadIconEx((PCTSTR) i);
}
#ifdef USE_NETWORK
for (i = 208; i < 210; i++)
{
hIcon[i] = LoadIconEx((PCTSTR) i);
}
#endif
for (i = 384; i < 386; i++)
{
@@ -1483,10 +1501,12 @@ void reset_menus(void)
# ifdef ENABLE_SERIAL_LOG
CheckMenuItem(menu, IDM_LOG_SERIAL, MF_UNCHECKED);
# endif
#ifdef USE_NETWORK
# ifdef ENABLE_NIC_LOG
/*FIXME: should be network_setlog(1:0) */
CheckMenuItem(menu, IDM_LOG_NIC, MF_UNCHECKED);
# endif
#endif
#endif
CheckMenuItem(menu, IDM_VID_FORCE43, MF_UNCHECKED);
@@ -1535,10 +1555,12 @@ void reset_menus(void)
# ifdef ENABLE_SERIAL_LOG
CheckMenuItem(menu, IDM_LOG_SERIAL, serial_do_log ? MF_CHECKED : MF_UNCHECKED);
# endif
#ifdef USE_NETWORK
# ifdef ENABLE_NIC_LOG
/*FIXME: should be network_setlog(1:0) */
CheckMenuItem(menu, IDM_LOG_NIC, nic_do_log ? MF_CHECKED : MF_UNCHECKED);
# endif
#endif
#endif
CheckMenuItem(menu, IDM_VID_FORCE43, force_43 ? MF_CHECKED : MF_UNCHECKED);
@@ -1658,7 +1680,9 @@ int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpsz
init_cdrom_host_drives();
#ifdef USE_NETWORK
network_init();
#endif
hwndStatus = EmulatorStatusBar(hwnd, IDC_STATUS, hThisInstance);
@@ -2188,6 +2212,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
break;
#endif
#ifdef USE_NETWORK
#ifdef ENABLE_NIC_LOG
case IDM_LOG_NIC:
/*FIXME: should be network_setlog() */
@@ -2196,6 +2221,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
break;
#endif
#endif
#endif
#ifdef ENABLE_LOG_BREAKPOINT
case IDM_LOG_BREAKPOINT:
@@ -2267,7 +2293,9 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
/* pclog_w(L"NVR path: %s\n", nvr_path); */
mem_resize();
loadbios();
#ifdef USE_NETWORK
network_init();
#endif
reset_menus();
update_status_bar_panes(hwndStatus);
resetpchard_init();

View File

@@ -35,7 +35,7 @@
#include "../cdrom_image.h"
#include "../cdrom_ioctl.h"
#include "../cdrom_null.h"
#include "../scsi_disk.h"
#include "../SCSI/scsi_disk.h"
#include "plat_iodev.h"
#include "win.h"

View File

@@ -8,7 +8,7 @@
*
* Windows 86Box Settings dialog handler.
*
* Version: @(#)win_settings.c 1.0.8 2017/08/24
* Version: @(#)win_settings.c 1.0.9 2017/08/26
*
* Author: Miran Grca, <mgrca8@gmail.com>
* Copyright 2016,2017 Miran Grca.
@@ -30,10 +30,12 @@
#include "../cdrom.h"
#include "../disc.h"
#include "../fdd.h"
#include "../hdd.h"
#include "../hdd_ide_at.h"
#include "../scsi.h"
#include "../HDD/hdd.h"
#include "../HDD/hdd_ide_at.h"
#include "../SCSI/scsi.h"
#ifdef USE_NETWORK
#include "../NETWORK/network.h"
#endif
#include "../SOUND/sound.h"
#include "../SOUND/midi.h"
#include "../SOUND/snd_dbopl.h"
@@ -61,9 +63,11 @@ static int temp_mouse, temp_joystick;
static int temp_sound_card, temp_midi_device, temp_mpu401, temp_SSI2001, temp_GAMEBLASTER, temp_GUS, temp_opl3_type;
static int temp_float;
#ifdef USE_NETWORK
/* Network category */
static int temp_net_type, temp_net_card;
static char temp_pcap_dev[520];
#endif
/* Peripherals category */
static int temp_scsi_card, hdc_ignore, temp_ide_ter, temp_ide_ter_irq, temp_ide_qua, temp_ide_qua_irq;
@@ -92,7 +96,9 @@ static int settings_sound_to_list[20], settings_list_to_sound[20];
static int settings_midi_to_list[20], settings_list_to_midi[20];
static int settings_mouse_to_list[20], settings_list_to_mouse[20];
static int settings_scsi_to_list[20], settings_list_to_scsi[20];
#ifdef USE_NETWORK
static int settings_network_to_list[20], settings_list_to_network[20];
#endif
static char *hdd_names[16];
@@ -132,11 +138,13 @@ static void win_settings_init(void)
temp_opl3_type = opl3_type;
temp_float = sound_is_float;
#ifdef USE_NETWORK
/* Network category */
temp_net_type = network_type;
memset(temp_pcap_dev, '\0', sizeof(temp_pcap_dev));
strcpy(temp_pcap_dev, network_pcap);
temp_net_card = network_card;
#endif
/* Peripherals category */
temp_scsi_card = scsi_card_current;
@@ -200,10 +208,12 @@ static int win_settings_changed(void)
i = i || (opl3_type != temp_opl3_type);
i = i || (sound_is_float != temp_float);
#ifdef USE_NETWORK
/* Network category */
i = i || (network_type != temp_net_type);
i = i || strcmp(temp_pcap_dev, network_pcap);
i = i || (network_card != temp_net_card);
#endif
/* Peripherals category */
i = i || (scsi_card_current != temp_scsi_card);
@@ -303,11 +313,13 @@ static void win_settings_save(void)
opl3_type = temp_opl3_type;
sound_is_float = temp_float;
#ifdef USE_NETWORK
/* Network category */
network_type = temp_net_type;
memset(network_pcap, '\0', sizeof(network_pcap));
strcpy(network_pcap, temp_pcap_dev);
network_card = temp_net_card;
#endif
/* Peripherals category */
scsi_card_current = temp_scsi_card;
@@ -1603,6 +1615,7 @@ static BOOL CALLBACK win_settings_peripherals_proc(HWND hdlg, UINT message, WPAR
}
#ifdef USE_NETWORK
int net_ignore_message = 0;
static void network_recalc_combos(HWND hdlg)
@@ -1802,6 +1815,7 @@ static BOOL CALLBACK win_settings_network_proc(HWND hdlg, UINT message, WPARAM w
return FALSE;
}
#endif
static BOOL win_settings_hard_disks_image_list_init(HWND hwndList)
{
@@ -4160,6 +4174,21 @@ cdrom_bus_skip:
return FALSE;
}
#define SETTINGS_PAGE_MACHINE 0
#define SETTINGS_PAGE_VIDEO 1
#define SETTINGS_PAGE_INPUT 2
#define SETTINGS_PAGE_SOUND 3
#ifdef USE_NETWORK
#define SETTINGS_PAGE_NETWORK 4
#define SETTINGS_PAGE_PERIPHERALS 5
#define SETTINGS_PAGE_HARD_DISKS 6
#define SETTINGS_PAGE_REMOVABLE_DEVICES 7
#else
#define SETTINGS_PAGE_PERIPHERALS 4
#define SETTINGS_PAGE_HARD_DISKS 5
#define SETTINGS_PAGE_REMOVABLE_DEVICES 6
#endif
void win_settings_show_child(HWND hwndParent, DWORD child_id)
{
if (child_id == displayed_category)
@@ -4177,28 +4206,30 @@ void win_settings_show_child(HWND hwndParent, DWORD child_id)
switch(child_id)
{
case 0:
case SETTINGS_PAGE_MACHINE:
hwndChildDialog = CreateDialog(hinstance, (LPCWSTR)DLG_CFG_MACHINE, hwndParent, win_settings_machine_proc);
break;
case 1:
case SETTINGS_PAGE_VIDEO:
hwndChildDialog = CreateDialog(hinstance, (LPCWSTR)DLG_CFG_VIDEO, hwndParent, win_settings_video_proc);
break;
case 2:
case SETTINGS_PAGE_INPUT:
hwndChildDialog = CreateDialog(hinstance, (LPCWSTR)DLG_CFG_INPUT, hwndParent, win_settings_input_proc);
break;
case 3:
case SETTINGS_PAGE_SOUND:
hwndChildDialog = CreateDialog(hinstance, (LPCWSTR)DLG_CFG_SOUND, hwndParent, win_settings_sound_proc);
break;
case 4:
#ifdef USE_NETWORK
case SETTINGS_PAGE_NETWORK:
hwndChildDialog = CreateDialog(hinstance, (LPCWSTR)DLG_CFG_NETWORK, hwndParent, win_settings_network_proc);
break;
case 5:
#endif
case SETTINGS_PAGE_PERIPHERALS:
hwndChildDialog = CreateDialog(hinstance, (LPCWSTR)DLG_CFG_PERIPHERALS, hwndParent, win_settings_peripherals_proc);
break;
case 6:
case SETTINGS_PAGE_HARD_DISKS:
hwndChildDialog = CreateDialog(hinstance, (LPCWSTR)DLG_CFG_HARD_DISKS, hwndParent, win_settings_hard_disks_proc);
break;
case 7:
case SETTINGS_PAGE_REMOVABLE_DEVICES:
hwndChildDialog = CreateDialog(hinstance, (LPCWSTR)DLG_CFG_REMOVABLE_DEVICES, hwndParent, win_settings_removable_devices_proc);
break;
default:
@@ -4220,7 +4251,11 @@ static BOOL win_settings_main_image_list_init(HWND hwndList)
GetSystemMetrics(SM_CYSMICON),
ILC_MASK | ILC_COLOR32, 1, 1);
#ifdef USE_NETWORK
for (i = 0; i < 8; i++)
#else
for (i = 0; i < 7; i++)
#endif
{
hiconItem = LoadIcon(hinstance, (LPCWSTR) (256 + i));
ImageList_AddIcon(hSmall, hiconItem);
@@ -4240,7 +4275,11 @@ static BOOL win_settings_main_insert_categories(HWND hwndList)
lvI.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE;
lvI.stateMask = lvI.iSubItem = lvI.state = 0;
#ifdef USE_NETWORK
for (i = 0; i < 8; i++)
#else
for (i = 0; i < 7; i++)
#endif
{
lvI.pszText = win_language_get_settings_category(i);
lvI.iItem = i;
@@ -4286,7 +4325,11 @@ static BOOL CALLBACK win_settings_main_proc(HWND hdlg, UINT message, WPARAM wPar
if ((((LPNMHDR)lParam)->code == LVN_ITEMCHANGED) && (((LPNMHDR)lParam)->idFrom == IDC_SETTINGSCATLIST))
{
category = -1;
#ifdef USE_NETWORK
for (i = 0; i < 8; i++)
#else
for (i = 0; i < 7; i++)
#endif
{
h = GetDlgItem(hdlg, IDC_SETTINGSCATLIST);
j = ListView_GetItemState(h, i, LVIS_SELECTED);

View File

@@ -23,9 +23,9 @@
#include "cdrom.h"
#include "ibm.h"
#include "piix.h"
#include "scsi.h"
#include "SCSI/scsi.h"
#include "timer.h"
#include "hdd_ide_at.h"
#include "HDD/hdd_ide_at.h"
#include "WIN/plat_iodev.h"
/* Bits of 'status' */

View File

@@ -37,13 +37,15 @@
#include "ibm.h"
#include "CPU/cpu.h"
#include "gameport.h"
#include "hdd.h"
#include "hdd_ide_at.h"
#include "HDD/hdd.h"
#include "HDD/hdd_ide_at.h"
#include "model.h"
#include "mouse.h"
#ifdef USE_NETWORK
#include "NETWORK/network.h"
#endif
#include "nvr.h"
#include "scsi.h"
#include "SCSI/scsi.h"
#include "WIN/plat_joystick.h"
#include "WIN/plat_midi.h"
#include "SOUND/midi.h"
@@ -1064,6 +1066,7 @@ static void loadconfig_sound(void)
}
#ifdef USE_NETWORK
/* Network */
static void loadconfig_network(void)
{
@@ -1118,6 +1121,7 @@ static void loadconfig_network(void)
else
network_card = 0;
}
#endif
/* Other peripherals */
@@ -1730,8 +1734,10 @@ void loadconfig(wchar_t *fn)
/* Sound */
loadconfig_sound();
#ifdef USE_NETWORK
/* Network */
loadconfig_network();
#endif
/* Other peripherals */
loadconfig_other_peripherals();
@@ -2150,6 +2156,7 @@ static void saveconfig_sound(void)
}
#ifdef USE_NETWORK
/* Network */
static void saveconfig_network(void)
{
@@ -2192,6 +2199,7 @@ static void saveconfig_network(void)
config_delete_section_if_empty(cat);
}
#endif
/* Other peripherals */
@@ -2547,8 +2555,10 @@ void saveconfig(void)
/* Sound */
saveconfig_sound();
#ifdef USE_NETWORK
/* Network */
saveconfig_network();
#endif
/* Other peripherals */
saveconfig_other_peripherals();

View File

@@ -22,7 +22,7 @@
#include "io.h"
#include "lpt.h"
#include "serial.h"
#include "hdd_ide_at.h"
#include "HDD/hdd_ide_at.h"
#include "fdc37c665.h"
static uint8_t fdc37c665_lock[2];

View File

@@ -20,7 +20,7 @@
#include "io.h"
#include "lpt.h"
#include "serial.h"
#include "hdd_ide_at.h"
#include "HDD/hdd_ide_at.h"
#include "fdc37c669.h"
static int fdc37c669_locked;

View File

@@ -20,7 +20,7 @@
#include "io.h"
#include "lpt.h"
#include "serial.h"
#include "hdd_ide_at.h"
#include "HDD/hdd_ide_at.h"
#include "fdc37c932fr.h"
static int fdc37c932fr_locked;

View File

@@ -35,7 +35,7 @@
#include "fdc37c932fr.h"
#include "gameport.h"
#include "i82335.h"
#include "hdd_ide_at.h"
#include "HDD/hdd_ide_at.h"
#include "intel.h"
#include "intel_flash.h"
#include "keyboard_amstrad.h"
@@ -70,7 +70,7 @@
#include "VIDEO/vid_tandy.h"
#include "w83877f.h"
#include "wd76c10.h"
#include "hdd_ide_xt.h"
#include "HDD/hdd_ide_xt.h"
#include "bugger.h"

View File

@@ -43,8 +43,8 @@
#include "fdc.h"
#include "fdd.h"
#include "gameport.h"
#include "hdd.h"
#include "hdd_ide_at.h"
#include "HDD/hdd.h"
#include "HDD/hdd_ide_at.h"
#include "cdrom.h"
#include "cdrom_ioctl.h"
#include "cdrom_image.h"
@@ -53,7 +53,9 @@
#include "keyboard_at.h"
#include "SOUND/midi.h"
#include "mouse.h"
#ifdef USE_NETWORK
#include "NETWORK/network.h"
#endif
#ifdef WALTJE
# define UNICODE
# include "plat_dir.h"
@@ -64,7 +66,7 @@
#include "plat_midi.h"
#include "plat_mouse.h"
#include "plat_ui.h"
#include "scsi.h"
#include "SCSI/scsi.h"
#include "serial.h"
#include "SOUND/sound.h"
#include "SOUND/snd_cms.h"
@@ -534,7 +536,9 @@ void resetpchard_init(void)
resetide();
scsi_card_init();
#ifdef USE_NETWORK
network_reset();
#endif
sound_card_init();
if (mpu401_standalone_enable)
@@ -717,5 +721,7 @@ void closepc(void)
closevideo();
device_close_all();
midi_close();
#ifdef USE_NETWORK
network_close();
#endif
}

View File

@@ -21,7 +21,7 @@
#include "io.h"
#include "lpt.h"
#include "serial.h"
#include "hdd_ide_at.h"
#include "HDD/hdd_ide_at.h"
#include "pc87306.h"
static int pc87306_curreg;

View File

@@ -28,7 +28,7 @@
#include "io.h"
#include "mem.h"
#include "pci.h"
#include "hdd_ide_at.h"
#include "HDD/hdd_ide_at.h"
#include "piix.h"

View File

@@ -21,7 +21,7 @@
#include "fdc.h"
#include "fdd.h"
#include "serial.h"
#include "hdd_ide_at.h"
#include "HDD/hdd_ide_at.h"
#include "sis85c471.h"