Enhanced the repeat IO accelerations (enabled by --enable-repeat-speedups)
to request bulk IO operations to IO devices which are bulk IO aware. Currently, I modified only harddrv.cc to be aware. I added some fields to the bx_devices_c class for the IO instructions to place requests and receive responses from the IO device emulation. Devices except the hard drive, don't monitor these fields so they respond as normal. The hard drive now monitors these fields for bulk requests, and if enabled, it memcpy()'s data straight from the disk buffer to memory. This eliminates numerous inp/outp calling sequences per disk sector. I used the fields in bx_devices_c so that I would not have to disrupt most IO device modules. Enhancements can be made to other devices if they use high-bandwidth IO via in/out instructions.
This commit is contained in:
parent
6a9d2e662f
commit
414e97bc32
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: io.cc,v 1.9 2002-09-08 04:08:14 kevinlawton Exp $
|
||||
// $Id: io.cc,v 1.10 2002-09-09 16:56:54 kevinlawton Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -36,6 +36,8 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void
|
||||
BX_CPU_C::INSB_YbDX(BxInstruction_t *i)
|
||||
{
|
||||
@ -141,7 +143,7 @@ BX_CPU_C::INSW_YvDX(BxInstruction_t *i)
|
||||
Bit32u laddrDst, paddrDst, wordsFitDst;
|
||||
Bit8u *hostAddrDst;
|
||||
bx_segment_reg_t *dstSegPtr;
|
||||
unsigned pointerDelta;
|
||||
int pointerDelta;
|
||||
|
||||
dstSegPtr = &BX_CPU_THIS_PTR sregs[BX_SREG_ES];
|
||||
|
||||
@ -172,7 +174,7 @@ BX_CPU_C::INSW_YvDX(BxInstruction_t *i)
|
||||
if ( (paddrDst & 0xfff) > 0xffe )
|
||||
goto noAcceleration;
|
||||
wordsFitDst = (2 + (paddrDst & 0xfff)) >> 1;
|
||||
pointerDelta = (unsigned) -2;
|
||||
pointerDelta = -2;
|
||||
}
|
||||
else {
|
||||
// Counting upward.
|
||||
@ -224,23 +226,33 @@ BX_CPU_C::INSW_YvDX(BxInstruction_t *i)
|
||||
|
||||
for (j=0; j<wordCount; ) {
|
||||
Bit16u temp16;
|
||||
if (j) {
|
||||
// Complete a tick for the last iteration, terminating
|
||||
// with one less tick than iterations, since the main cpu
|
||||
// loop also decrements one. Probably a little anal...
|
||||
BX_TICK1();
|
||||
bx_devices.bulkIOQuantumsTransferred = 0;
|
||||
if ( GetEFlagsDFLogical()==0 ) { // Only do accel for DF=0
|
||||
bx_devices.bulkIOHostAddr = (Bit32u) hostAddrDst;
|
||||
bx_devices.bulkIOQuantumsRequested = (wordCount - j);
|
||||
}
|
||||
else
|
||||
bx_devices.bulkIOQuantumsRequested = 0;
|
||||
temp16 = BX_INP(DX, 2);
|
||||
* (Bit16u *) hostAddrDst = temp16;
|
||||
hostAddrDst += pointerDelta;
|
||||
j++;
|
||||
if ( bx_devices.bulkIOQuantumsTransferred ) {
|
||||
hostAddrDst = (Bit8u*) bx_devices.bulkIOHostAddr;
|
||||
j += bx_devices.bulkIOQuantumsTransferred;
|
||||
}
|
||||
else {
|
||||
* (Bit16u *) hostAddrDst = temp16;
|
||||
hostAddrDst += pointerDelta;
|
||||
j++;
|
||||
}
|
||||
// Terminate early if there was an event.
|
||||
if ( BX_CPU_THIS_PTR async_event )
|
||||
break;
|
||||
}
|
||||
// Reset for next non-bulk IO.
|
||||
bx_devices.bulkIOQuantumsRequested = 0;
|
||||
wordCount = j;
|
||||
// Decrement eCX. Note, the main loop will decrement 1 also, so
|
||||
// decrement by one less than expected, like the case above.
|
||||
BX_TICKN(j-1); // Main cpu loop also decrements one more.
|
||||
if (i->as_32)
|
||||
ECX -= (wordCount-1);
|
||||
else
|
||||
@ -478,23 +490,33 @@ BX_CPU_C::OUTSW_DXXv(BxInstruction_t *i)
|
||||
|
||||
for (j=0; j<wordCount; ) {
|
||||
Bit16u temp16;
|
||||
if (j) {
|
||||
// Complete a tick for the last iteration, terminating
|
||||
// with one less tick than iterations, since the main cpu
|
||||
// loop also decrements one. Probably a little anal...
|
||||
BX_TICK1();
|
||||
bx_devices.bulkIOQuantumsTransferred = 0;
|
||||
if ( GetEFlagsDFLogical()==0 ) { // Only do accel for DF=0
|
||||
bx_devices.bulkIOHostAddr = (Bit32u) hostAddrSrc;
|
||||
bx_devices.bulkIOQuantumsRequested = (wordCount - j);
|
||||
}
|
||||
else
|
||||
bx_devices.bulkIOQuantumsRequested = 0;
|
||||
temp16 = * (Bit16u *) hostAddrSrc;
|
||||
hostAddrSrc += pointerDelta;
|
||||
BX_OUTP(DX, temp16, 2);
|
||||
j++;
|
||||
if ( bx_devices.bulkIOQuantumsTransferred ) {
|
||||
hostAddrSrc = (Bit8u*) bx_devices.bulkIOHostAddr;
|
||||
j += bx_devices.bulkIOQuantumsTransferred;
|
||||
}
|
||||
else {
|
||||
hostAddrSrc += pointerDelta;
|
||||
j++;
|
||||
}
|
||||
// Terminate early if there was an event.
|
||||
if ( BX_CPU_THIS_PTR async_event )
|
||||
break;
|
||||
}
|
||||
// Reset for next non-bulk IO.
|
||||
bx_devices.bulkIOQuantumsRequested = 0;
|
||||
wordCount = j;
|
||||
// Decrement eCX. Note, the main loop will decrement 1 also, so
|
||||
// decrement by one less than expected, like the case above.
|
||||
BX_TICKN(j-1); // Main cpu loop also decrements one more.
|
||||
if (i->as_32)
|
||||
ECX -= (wordCount-1);
|
||||
else
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: devices.cc,v 1.29 2002-08-27 19:54:46 bdenney Exp $
|
||||
// $Id: devices.cc,v 1.30 2002-09-09 16:56:55 kevinlawton Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2002 MandrakeSoft S.A.
|
||||
@ -84,7 +84,7 @@ bx_devices_c::init(BX_MEM_C *newmem)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
BX_DEBUG(("Init $Id: devices.cc,v 1.29 2002-08-27 19:54:46 bdenney Exp $"));
|
||||
BX_DEBUG(("Init $Id: devices.cc,v 1.30 2002-09-09 16:56:55 kevinlawton Exp $"));
|
||||
mem = newmem;
|
||||
|
||||
/* no read / write handlers defined */
|
||||
@ -227,6 +227,11 @@ bx_devices_c::init(BX_MEM_C *newmem)
|
||||
|
||||
timer_handle = bx_pc_system.register_timer( this, timer_handler,
|
||||
(unsigned) BX_IODEV_HANDLER_PERIOD, 1, 1);
|
||||
|
||||
// Clear fields for bulk IO acceleration transfers.
|
||||
bulkIOHostAddr = 0;
|
||||
bulkIOQuantumsRequested = 0;
|
||||
bulkIOQuantumsTransferred = 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: harddrv.cc,v 1.69 2002-08-27 19:54:46 bdenney Exp $
|
||||
// $Id: harddrv.cc,v 1.70 2002-09-09 16:56:56 kevinlawton Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2002 MandrakeSoft S.A.
|
||||
@ -128,7 +128,7 @@ bx_hard_drive_c::~bx_hard_drive_c(void)
|
||||
bx_hard_drive_c::init(bx_devices_c *d, bx_cmos_c *cmos)
|
||||
{
|
||||
BX_HD_THIS devices = d;
|
||||
BX_DEBUG(("Init $Id: harddrv.cc,v 1.69 2002-08-27 19:54:46 bdenney Exp $"));
|
||||
BX_DEBUG(("Init $Id: harddrv.cc,v 1.70 2002-09-09 16:56:56 kevinlawton Exp $"));
|
||||
|
||||
/* HARD DRIVE 0 */
|
||||
|
||||
@ -421,17 +421,41 @@ bx_hard_drive_c::read(Bit32u address, unsigned io_len)
|
||||
if (BX_SELECTED_CONTROLLER.buffer_index >= 512)
|
||||
BX_PANIC(("IO read(1f0): buffer_index >= 512"));
|
||||
|
||||
value32 = 0L;
|
||||
switch(io_len){
|
||||
case 4:
|
||||
value32 |= (BX_SELECTED_CONTROLLER.buffer[BX_SELECTED_CONTROLLER.buffer_index+3] << 24);
|
||||
value32 |= (BX_SELECTED_CONTROLLER.buffer[BX_SELECTED_CONTROLLER.buffer_index+2] << 16);
|
||||
case 2:
|
||||
value32 |= (BX_SELECTED_CONTROLLER.buffer[BX_SELECTED_CONTROLLER.buffer_index+1] << 8);
|
||||
value32 |= BX_SELECTED_CONTROLLER.buffer[BX_SELECTED_CONTROLLER.buffer_index];
|
||||
}
|
||||
#if BX_SupportRepeatSpeedups
|
||||
if (BX_HD_THIS devices->bulkIOQuantumsRequested) {
|
||||
unsigned transferLen, quantumsMax;
|
||||
|
||||
BX_SELECTED_CONTROLLER.buffer_index += io_len;
|
||||
quantumsMax =
|
||||
(512 - BX_SELECTED_CONTROLLER.buffer_index) / io_len;
|
||||
if ( quantumsMax == 0)
|
||||
BX_PANIC(("IO read(1f0): not enough space for read"));
|
||||
BX_HD_THIS devices->bulkIOQuantumsTransferred =
|
||||
BX_HD_THIS devices->bulkIOQuantumsRequested;
|
||||
if (quantumsMax < BX_HD_THIS devices->bulkIOQuantumsTransferred)
|
||||
BX_HD_THIS devices->bulkIOQuantumsTransferred = quantumsMax;
|
||||
transferLen = io_len * BX_HD_THIS devices->bulkIOQuantumsTransferred;
|
||||
memcpy((Bit8u*) BX_HD_THIS devices->bulkIOHostAddr,
|
||||
&BX_SELECTED_CONTROLLER.buffer[BX_SELECTED_CONTROLLER.buffer_index],
|
||||
transferLen);
|
||||
BX_HD_THIS devices->bulkIOHostAddr += transferLen;
|
||||
BX_SELECTED_CONTROLLER.buffer_index += transferLen;
|
||||
value32 = 0; // Value returned not important;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
value32 = 0L;
|
||||
switch(io_len){
|
||||
case 4:
|
||||
value32 |= (BX_SELECTED_CONTROLLER.buffer[BX_SELECTED_CONTROLLER.buffer_index+3] << 24);
|
||||
value32 |= (BX_SELECTED_CONTROLLER.buffer[BX_SELECTED_CONTROLLER.buffer_index+2] << 16);
|
||||
case 2:
|
||||
value32 |= (BX_SELECTED_CONTROLLER.buffer[BX_SELECTED_CONTROLLER.buffer_index+1] << 8);
|
||||
value32 |= BX_SELECTED_CONTROLLER.buffer[BX_SELECTED_CONTROLLER.buffer_index];
|
||||
}
|
||||
|
||||
BX_SELECTED_CONTROLLER.buffer_index += io_len;
|
||||
}
|
||||
|
||||
// if buffer completely read
|
||||
if (BX_SELECTED_CONTROLLER.buffer_index >= 512) {
|
||||
@ -881,16 +905,40 @@ BX_DEBUG(("IO write to %04x = %02x", (unsigned) address, (unsigned) value));
|
||||
if (BX_SELECTED_CONTROLLER.buffer_index >= 512)
|
||||
BX_PANIC(("IO write(1f0): buffer_index >= 512"));
|
||||
|
||||
switch(io_len){
|
||||
case 4:
|
||||
BX_SELECTED_CONTROLLER.buffer[BX_SELECTED_CONTROLLER.buffer_index+3] = (Bit8u)(value >> 24);
|
||||
BX_SELECTED_CONTROLLER.buffer[BX_SELECTED_CONTROLLER.buffer_index+2] = (Bit8u)(value >> 16);
|
||||
case 2:
|
||||
BX_SELECTED_CONTROLLER.buffer[BX_SELECTED_CONTROLLER.buffer_index+1] = (Bit8u)(value >> 8);
|
||||
BX_SELECTED_CONTROLLER.buffer[BX_SELECTED_CONTROLLER.buffer_index] = (Bit8u) value;
|
||||
}
|
||||
#if BX_SupportRepeatSpeedups
|
||||
if (BX_HD_THIS devices->bulkIOQuantumsRequested) {
|
||||
unsigned transferLen, quantumsMax;
|
||||
|
||||
BX_SELECTED_CONTROLLER.buffer_index += io_len;
|
||||
quantumsMax =
|
||||
(512 - BX_SELECTED_CONTROLLER.buffer_index) / io_len;
|
||||
if ( quantumsMax == 0)
|
||||
BX_PANIC(("IO write(1f0): not enough space for write"));
|
||||
BX_HD_THIS devices->bulkIOQuantumsTransferred =
|
||||
BX_HD_THIS devices->bulkIOQuantumsRequested;
|
||||
if (quantumsMax < BX_HD_THIS devices->bulkIOQuantumsTransferred)
|
||||
BX_HD_THIS devices->bulkIOQuantumsTransferred = quantumsMax;
|
||||
transferLen = io_len * BX_HD_THIS devices->bulkIOQuantumsTransferred;
|
||||
memcpy(
|
||||
&BX_SELECTED_CONTROLLER.buffer[BX_SELECTED_CONTROLLER.buffer_index],
|
||||
(Bit8u*) BX_HD_THIS devices->bulkIOHostAddr,
|
||||
transferLen);
|
||||
BX_HD_THIS devices->bulkIOHostAddr += transferLen;
|
||||
BX_SELECTED_CONTROLLER.buffer_index += transferLen;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
switch(io_len){
|
||||
case 4:
|
||||
BX_SELECTED_CONTROLLER.buffer[BX_SELECTED_CONTROLLER.buffer_index+3] = (Bit8u)(value >> 24);
|
||||
BX_SELECTED_CONTROLLER.buffer[BX_SELECTED_CONTROLLER.buffer_index+2] = (Bit8u)(value >> 16);
|
||||
case 2:
|
||||
BX_SELECTED_CONTROLLER.buffer[BX_SELECTED_CONTROLLER.buffer_index+1] = (Bit8u)(value >> 8);
|
||||
BX_SELECTED_CONTROLLER.buffer[BX_SELECTED_CONTROLLER.buffer_index] = (Bit8u) value;
|
||||
}
|
||||
|
||||
BX_SELECTED_CONTROLLER.buffer_index += io_len;
|
||||
}
|
||||
|
||||
/* if buffer completely writtten */
|
||||
if (BX_SELECTED_CONTROLLER.buffer_index >= 512) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: iodev.h,v 1.16 2002-08-27 19:54:46 bdenney Exp $
|
||||
// $Id: iodev.h,v 1.17 2002-09-09 16:56:56 kevinlawton Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2002 MandrakeSoft S.A.
|
||||
@ -120,6 +120,17 @@ public:
|
||||
bx_iodebug_c *iodebug;
|
||||
#endif
|
||||
|
||||
// Some info to pass to devices which can handled bulk IO. This allows
|
||||
// the interface to remain the same for IO devices which can't handle
|
||||
// bulk IO. We should probably implement special INPBulk() and OUTBulk()
|
||||
// functions which stick these values in the bx_devices_c class, and
|
||||
// then call the normal functions rather than having gross globals
|
||||
// variables.
|
||||
Bit32u bulkIOHostAddr;
|
||||
unsigned bulkIOQuantumsRequested;
|
||||
unsigned bulkIOQuantumsTransferred;
|
||||
|
||||
|
||||
private:
|
||||
Bit8u read_handler_id[0x10000]; // 64K
|
||||
struct {
|
||||
|
Loading…
Reference in New Issue
Block a user