From 3359eee9563e3a9928aa25452edcf67addfd0424 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Strohh=C3=A4cker?= Date: Fri, 7 Apr 2006 16:34:07 +0000 Subject: [PATCH] add device control channel handling; fix typo in ems.cpp (#1462677) Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2582 --- include/dos_system.h | 6 +++++- src/dos/dev_con.h | 6 ++++-- src/dos/dos_devices.cpp | 12 +++++++++++- src/dos/dos_ioctl.cpp | 38 +++++++++++++++++++++++++++++++++----- src/dos/dos_mscdex.cpp | 6 ++++-- src/ints/ems.cpp | 8 +++++--- 6 files changed, 62 insertions(+), 14 deletions(-) diff --git a/include/dos_system.h b/include/dos_system.h index 1f0af3f1..5cdb3bd4 100644 --- a/include/dos_system.h +++ b/include/dos_system.h @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: dos_system.h,v 1.31 2006-02-09 11:47:47 qbix79 Exp $ */ +/* $Id: dos_system.h,v 1.32 2006-04-07 16:34:07 c2woody Exp $ */ #ifndef DOSBOX_DOS_SYSTEM_H #define DOSBOX_DOS_SYSTEM_H @@ -30,6 +30,8 @@ #include "cross.h" #endif +#include "mem.h" + #define DOS_NAMELENGTH 12 #define DOS_NAMELENGTH_ASCII (DOS_NAMELENGTH+1) #define DOS_FCBNAME 15 @@ -99,6 +101,8 @@ public: virtual bool Seek(Bit32u * pos,Bit32u type); virtual bool Close(); virtual Bit16u GetInformation(void); + virtual bool ReadFromControlChannel(PhysPt bufptr,Bit16u size,Bit16u * retcode); + virtual bool WriteToControlChannel(PhysPt bufptr,Bit16u size,Bit16u * retcode); void SetDeviceNumber(Bitu num) { devnum=num;} private: Bitu devnum; diff --git a/src/dos/dev_con.h b/src/dos/dev_con.h index 5479014d..1e7c62d2 100644 --- a/src/dos/dev_con.h +++ b/src/dos/dev_con.h @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: dev_con.h,v 1.24 2006-02-26 16:05:13 qbix79 Exp $ */ +/* $Id: dev_con.h,v 1.25 2006-04-07 16:34:07 c2woody Exp $ */ #include "dos_inc.h" #include "../ints/int10.h" @@ -33,6 +33,8 @@ public: bool Close(); void ClearAnsi(void); Bit16u GetInformation(void); + bool ReadFromControlChannel(PhysPt bufptr,Bit16u size,Bit16u * retcode){return false;} + bool WriteToControlChannel(PhysPt bufptr,Bit16u size,Bit16u * retcode){return false;} private: Bit8u readcache; Bit8u lastwrite; @@ -313,7 +315,7 @@ bool device_CON::Write(Bit8u * data,Bit16u * size) { if(ansi.data[0]!=2) {/* every version behaves like type 2 */ LOG(LOG_IOCTL,LOG_NORMAL)("ANSI: esc[%dJ called : not supported handling as 2",ansi.data[0]); } - INT10_ScrollWindow(0,0,999,999,0,ansi.attr,0xFF); + INT10_ScrollWindow(0,0,255,255,0,ansi.attr,0xFF); ClearAnsi(); INT10_SetCursorPos(0,0,0); break; diff --git a/src/dos/dos_devices.cpp b/src/dos/dos_devices.cpp index 341e1cee..83fecee5 100644 --- a/src/dos/dos_devices.cpp +++ b/src/dos/dos_devices.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: dos_devices.cpp,v 1.11 2006-02-09 11:47:48 qbix79 Exp $ */ +/* $Id: dos_devices.cpp,v 1.12 2006-04-07 16:34:07 c2woody Exp $ */ #include #include "dosbox.h" @@ -53,6 +53,8 @@ public: } bool Close() { return true; } Bit16u GetInformation(void) { return 0x8084; } + bool ReadFromControlChannel(PhysPt bufptr,Bit16u size,Bit16u * retcode){return false;} + bool WriteToControlChannel(PhysPt bufptr,Bit16u size,Bit16u * retcode){return false;} }; bool DOS_Device::Read(Bit8u * data,Bit16u * size) { @@ -75,6 +77,14 @@ Bit16u DOS_Device::GetInformation(void) { return Devices[devnum]->GetInformation(); } +bool DOS_Device::ReadFromControlChannel(PhysPt bufptr,Bit16u size,Bit16u * retcode) { + return Devices[devnum]->ReadFromControlChannel(bufptr,size,retcode); +} + +bool DOS_Device::WriteToControlChannel(PhysPt bufptr,Bit16u size,Bit16u * retcode) { + return Devices[devnum]->WriteToControlChannel(bufptr,size,retcode); +} + DOS_File::DOS_File(const DOS_File& orig) { type=orig.type; flags=orig.flags; diff --git a/src/dos/dos_ioctl.cpp b/src/dos/dos_ioctl.cpp index cee95b74..a9c36586 100644 --- a/src/dos/dos_ioctl.cpp +++ b/src/dos/dos_ioctl.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: dos_ioctl.cpp,v 1.26 2006-02-09 11:47:48 qbix79 Exp $ */ +/* $Id: dos_ioctl.cpp,v 1.27 2006-04-07 16:34:07 c2woody Exp $ */ #include #include "dosbox.h" @@ -46,9 +46,38 @@ bool DOS_IOCTL(void) { } switch(reg_al) { case 0x00: /* Get Device Information */ - reg_dx=Files[handle]->GetInformation(); + if (Files[handle]->GetInformation() & 0x8000) { //Check for device + reg_dx=Files[handle]->GetInformation(); + } else { + /* return drive number in lower 5 bits for block devices */ + reg_dx=(Files[handle]->GetInformation()&0xffe0)|drive; + } reg_ax=reg_dx; //Destroyed officially return true; + case 0x02: /* Read from Device Control Channel */ + if (Files[handle]->GetInformation() & 0xc000) { + /* is character device with IOCTL support */ + PhysPt bufptr=PhysMake(SegValue(ds),reg_dx); + Bit16u retcode=0; + if (((DOS_Device*)(Files[handle]))->ReadFromControlChannel(bufptr,reg_cx,&retcode)) { + reg_ax=retcode; + return true; + } + } + DOS_SetError(0x0001); // invalid function + return false; + case 0x03: /* Write to Device Control Channel */ + if (Files[handle]->GetInformation() & 0xc000) { + /* is character device with IOCTL support */ + PhysPt bufptr=PhysMake(SegValue(ds),reg_dx); + Bit16u retcode=0; + if (((DOS_Device*)(Files[handle]))->WriteToControlChannel(bufptr,reg_cx,&retcode)) { + reg_ax=retcode; + return true; + } + } + DOS_SetError(0x0001); // invalid function + return false; case 0x06: /* Get Input Status */ if (Files[handle]->GetInformation() & 0x8000) { //Check for device reg_al=(Files[handle]->GetInformation() & 0x40) ? 0x0 : 0xff; @@ -59,12 +88,11 @@ bool DOS_IOCTL(void) { Files[handle]->Seek(&endlocation, DOS_SEEK_END); if(oldlocation < endlocation){//Still data available reg_al=0xff; - } else - { + } else { reg_al=0x0; //EOF or beyond } Files[handle]->Seek(&oldlocation, DOS_SEEK_SET); //restore filelocation - LOG(LOG_IOCTL,LOG_NORMAL)("06:Used Get Input Status on regualar file with handle %d",handle); + LOG(LOG_IOCTL,LOG_NORMAL)("06:Used Get Input Status on regular file with handle %d",handle); } return true; case 0x07: /* Get Output Status */ diff --git a/src/dos/dos_mscdex.cpp b/src/dos/dos_mscdex.cpp index 506872bc..fa9ceda1 100644 --- a/src/dos/dos_mscdex.cpp +++ b/src/dos/dos_mscdex.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: dos_mscdex.cpp,v 1.37 2006-03-26 11:54:44 qbix79 Exp $ */ +/* $Id: dos_mscdex.cpp,v 1.38 2006-04-07 16:34:07 c2woody Exp $ */ #include #include @@ -1065,7 +1065,9 @@ public: } bool Seek(Bit32u * pos,Bit32u type){return false;} bool Close(){return false;} - Bit16u GetInformation(void){return 0x8093;} + Bit16u GetInformation(void){return 0xc880;} + bool ReadFromControlChannel(PhysPt bufptr,Bit16u size,Bit16u * retcode){return true;} + bool WriteToControlChannel(PhysPt bufptr,Bit16u size,Bit16u * retcode){return true;} private: Bit8u cache; }; diff --git a/src/ints/ems.cpp b/src/ints/ems.cpp index 45357393..f19e79cb 100644 --- a/src/ints/ems.cpp +++ b/src/ints/ems.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: ems.cpp,v 1.47 2006-03-12 20:31:49 c2woody Exp $ */ +/* $Id: ems.cpp,v 1.48 2006-04-07 16:34:07 c2woody Exp $ */ #include #include @@ -79,7 +79,9 @@ public: } bool Seek(Bit32u * pos,Bit32u type){return false;} bool Close(){return false;} - Bit16u GetInformation(void){return 0x8093;} + Bit16u GetInformation(void){return 0xc080;} + bool ReadFromControlChannel(PhysPt bufptr,Bit16u size,Bit16u * retcode){return true;} + bool WriteToControlChannel(PhysPt bufptr,Bit16u size,Bit16u * retcode){return true;} private: Bit8u cache; }; @@ -608,7 +610,7 @@ static Bitu INT67_Handler(void) { } else { switch (reg_al) { case 0x00: /* VCPI Installation Check */ - if (((reg_cx==0) && (reg_di=0x0012)) || (cpu.pmode && (reg_flags & FLAG_VM))) { + if (((reg_cx==0) && (reg_di==0x0012)) || (cpu.pmode && (reg_flags & FLAG_VM))) { /* JEMM detected or already in v86 mode */ reg_ah=EMM_NO_ERROR; reg_bx=0x100;