2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2007-10-29 18:39:18 +03:00
|
|
|
// $Id: io.cc,v 1.42 2007-10-29 15:39:18 sshwarts Exp $
|
2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2001-04-10 06:20:02 +04:00
|
|
|
// Copyright (C) 2001 MandrakeSoft S.A.
|
2001-04-10 05:04:59 +04:00
|
|
|
//
|
|
|
|
// MandrakeSoft S.A.
|
|
|
|
// 43, rue d'Aboukir
|
|
|
|
// 75002 Paris - France
|
|
|
|
// http://www.linux-mandrake.com/
|
|
|
|
// http://www.mandrakesoft.com/
|
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
|
|
|
|
2001-05-24 22:46:34 +04:00
|
|
|
#define NEED_CPU_REG_SHORTCUTS 1
|
2001-04-10 05:04:59 +04:00
|
|
|
#include "bochs.h"
|
2006-03-07 01:03:16 +03:00
|
|
|
#include "cpu.h"
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
#define LOG_THIS BX_CPU_THIS_PTR
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2006-03-07 01:03:16 +03:00
|
|
|
#include "iodev/iodev.h"
|
|
|
|
|
2002-09-15 06:55:34 +04:00
|
|
|
#if BX_SUPPORT_X86_64==0
|
|
|
|
// Make life easier for merging cpu64 and cpu32 code.
|
|
|
|
#define RDI EDI
|
|
|
|
#define RSI ESI
|
|
|
|
#define RAX EAX
|
2007-09-27 20:11:32 +04:00
|
|
|
#define RCX ECX
|
2002-09-15 06:55:34 +04:00
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-01-05 16:40:47 +03:00
|
|
|
//
|
|
|
|
// Repeat Speedups methods
|
|
|
|
//
|
|
|
|
|
2006-05-08 00:45:42 +04:00
|
|
|
#if BX_SupportRepeatSpeedups
|
|
|
|
Bit32u BX_CPU_C::FastRepINSW(bxInstruction_c *i, bx_address dstOff, Bit16u port, Bit32u wordCount)
|
|
|
|
{
|
2007-10-29 18:39:18 +03:00
|
|
|
Bit32u wordsFitDst;
|
2006-05-08 00:45:42 +04:00
|
|
|
signed int pointerDelta;
|
2007-10-29 18:39:18 +03:00
|
|
|
Bit8u *hostAddrDst;
|
2006-05-08 00:45:42 +04:00
|
|
|
|
|
|
|
bx_segment_reg_t *dstSegPtr = &BX_CPU_THIS_PTR sregs[BX_SEG_REG_ES];
|
|
|
|
|
|
|
|
// Do segment checks for the 1st word. We do not want to
|
|
|
|
// trip an exception beyond this, because the address would
|
|
|
|
// be incorrect. After we know how many bytes we will directly
|
|
|
|
// transfer, we can do the full segment limit check ourselves
|
|
|
|
// without generating an exception.
|
|
|
|
write_virtual_checks(dstSegPtr, dstOff, 2);
|
|
|
|
|
|
|
|
bx_address laddrDst = BX_CPU_THIS_PTR get_segment_base(BX_SEG_REG_ES) + dstOff;
|
2007-10-29 18:39:18 +03:00
|
|
|
// check that the address is word aligned
|
|
|
|
if (laddrDst & 1) return 0;
|
|
|
|
|
|
|
|
#if BX_SupportGuest2HostTLB
|
|
|
|
hostAddrDst = v2h_write_byte(laddrDst, CPL==3);
|
|
|
|
#else
|
|
|
|
bx_phy_address paddrDst;
|
|
|
|
|
2007-07-09 19:16:14 +04:00
|
|
|
if (BX_CPU_THIS_PTR cr0.get_PG())
|
2006-05-08 00:45:42 +04:00
|
|
|
paddrDst = dtranslate_linear(laddrDst, CPL==3, BX_WRITE);
|
|
|
|
else
|
|
|
|
paddrDst = laddrDst;
|
2007-10-29 18:39:18 +03:00
|
|
|
|
2006-05-08 00:45:42 +04:00
|
|
|
// If we want to write directly into the physical memory array,
|
|
|
|
// we need the A20 address.
|
2007-10-29 18:39:18 +03:00
|
|
|
hostAddrDst = BX_CPU_THIS_PTR mem->getHostMemAddr(BX_CPU_THIS,
|
|
|
|
A20ADDR(paddrDst), BX_WRITE, DATA_ACCESS);
|
|
|
|
#endif
|
2006-05-08 00:45:42 +04:00
|
|
|
|
2007-10-29 18:39:18 +03:00
|
|
|
// Check that native host access was not vetoed for that page
|
|
|
|
if (!hostAddrDst) return 0;
|
2006-05-08 00:45:42 +04:00
|
|
|
|
|
|
|
// See how many words can fit in the rest of this page.
|
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
// Counting downward
|
|
|
|
// Note: 1st word must not cross page boundary.
|
2007-10-29 18:39:18 +03:00
|
|
|
if ((laddrDst & 0xfff) > 0xffe) return 0;
|
|
|
|
wordsFitDst = (2 + (laddrDst & 0xfff)) >> 1;
|
2006-05-08 00:45:42 +04:00
|
|
|
pointerDelta = -2;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Counting upward
|
2007-10-29 18:39:18 +03:00
|
|
|
wordsFitDst = (0x1000 - (laddrDst & 0xfff)) >> 1;
|
2006-05-08 00:45:42 +04:00
|
|
|
pointerDelta = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Restrict word count to the number that will fit in this page.
|
|
|
|
if (wordCount > wordsFitDst)
|
|
|
|
wordCount = wordsFitDst;
|
|
|
|
|
|
|
|
// If after all the restrictions, there is anything left to do...
|
|
|
|
if (wordCount) {
|
|
|
|
Bit32u dstSegLimit = dstSegPtr->cache.u.segment.limit_scaled;
|
|
|
|
unsigned count;
|
|
|
|
|
|
|
|
// For 16-bit addressing mode, clamp the segment limits to 16bits
|
|
|
|
// so we don't have to worry about computations using si/di
|
|
|
|
// rolling over 16-bit boundaries.
|
|
|
|
if (!i->as32L()) {
|
|
|
|
if (dstSegLimit > 0xffff)
|
|
|
|
dstSegLimit = 0xffff;
|
|
|
|
}
|
|
|
|
// Before we copy memory, we need to make sure that the segments
|
|
|
|
// allow the accesses up to the given source and dest offset. If
|
|
|
|
// the cache.valid bits have SegAccessWOK and ROK, we know that
|
|
|
|
// the cache is valid for those operations, and that the segments
|
|
|
|
// are non-expand down (thus we can make a simple limit check).
|
|
|
|
if (!(dstSegPtr->cache.valid & SegAccessWOK)) return 0;
|
|
|
|
|
|
|
|
if (BX_CPU_THIS_PTR cpu_mode != BX_MODE_LONG_64)
|
|
|
|
{
|
|
|
|
// Now make sure transfer will fit within the constraints of the
|
|
|
|
// segment boundaries, 0..limit for non expand-down. We know
|
|
|
|
// wordCount >= 1 here.
|
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
// Counting downward
|
|
|
|
Bit32u minOffset = (wordCount-1) << 1;
|
|
|
|
if (dstOff < minOffset) return 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Counting upward
|
|
|
|
Bit32u dstMaxOffset = (dstSegLimit - (wordCount<<1)) + 1;
|
|
|
|
if (dstOff > dstMaxOffset) return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (count=0; count<wordCount; ) {
|
|
|
|
bx_devices.bulkIOQuantumsTransferred = 0;
|
|
|
|
if (BX_CPU_THIS_PTR get_DF()==0) { // Only do accel for DF=0
|
|
|
|
bx_devices.bulkIOHostAddr = hostAddrDst;
|
|
|
|
bx_devices.bulkIOQuantumsRequested = (wordCount - count);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
bx_devices.bulkIOQuantumsRequested = 0;
|
|
|
|
Bit16u temp16 = BX_INP(port, 2);
|
|
|
|
if (bx_devices.bulkIOQuantumsTransferred) {
|
|
|
|
hostAddrDst = bx_devices.bulkIOHostAddr;
|
|
|
|
count += bx_devices.bulkIOQuantumsTransferred;
|
|
|
|
}
|
|
|
|
else {
|
2006-08-01 21:09:05 +04:00
|
|
|
#ifdef BX_LITTLE_ENDIAN
|
2006-05-08 00:45:42 +04:00
|
|
|
* (Bit16u *) hostAddrDst = temp16;
|
2006-08-01 21:09:05 +04:00
|
|
|
#else
|
|
|
|
* (Bit16u *) hostAddrDst = ((temp16 >> 8) | (temp16 << 8));
|
|
|
|
#endif
|
2006-05-08 00:45:42 +04:00
|
|
|
hostAddrDst += pointerDelta;
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
// 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;
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
Bit32u BX_CPU_C::FastRepOUTSW(bxInstruction_c *i, unsigned srcSeg, bx_address srcOff, Bit16u port, Bit32u wordCount)
|
|
|
|
{
|
2007-10-29 18:39:18 +03:00
|
|
|
Bit32u wordsFitSrc;
|
2006-05-08 00:45:42 +04:00
|
|
|
signed int pointerDelta;
|
2007-10-29 18:39:18 +03:00
|
|
|
Bit8u *hostAddrSrc;
|
2006-05-08 00:45:42 +04:00
|
|
|
|
|
|
|
bx_segment_reg_t *srcSegPtr = &BX_CPU_THIS_PTR sregs[srcSeg];
|
|
|
|
|
|
|
|
// Do segment checks for the 1st word. We do not want to
|
|
|
|
// trip an exception beyond this, because the address would
|
|
|
|
// be incorrect. After we know how many bytes we will directly
|
|
|
|
// transfer, we can do the full segment limit check ourselves
|
|
|
|
// without generating an exception.
|
|
|
|
read_virtual_checks(srcSegPtr, srcOff, 2);
|
|
|
|
|
|
|
|
bx_address laddrSrc = BX_CPU_THIS_PTR get_segment_base(srcSeg) + srcOff;
|
2007-10-29 18:39:18 +03:00
|
|
|
// check that the address is word aligned
|
|
|
|
if (laddrSrc & 1) return 0;
|
|
|
|
|
|
|
|
#if BX_SupportGuest2HostTLB
|
|
|
|
hostAddrSrc = v2h_read_byte(laddrSrc, CPL==3);
|
|
|
|
#else
|
|
|
|
bx_phy_address paddrSrc;
|
|
|
|
|
2007-07-09 19:16:14 +04:00
|
|
|
if (BX_CPU_THIS_PTR cr0.get_PG())
|
2006-05-08 00:45:42 +04:00
|
|
|
paddrSrc = dtranslate_linear(laddrSrc, CPL==3, BX_READ);
|
|
|
|
else
|
|
|
|
paddrSrc = laddrSrc;
|
2007-10-29 18:39:18 +03:00
|
|
|
|
2006-05-08 00:45:42 +04:00
|
|
|
// If we want to write directly into the physical memory array,
|
|
|
|
// we need the A20 address.
|
2007-10-29 18:39:18 +03:00
|
|
|
hostAddrSrc = BX_CPU_THIS_PTR mem->getHostMemAddr(BX_CPU_THIS,
|
|
|
|
A20ADDR(paddrSrc), BX_READ, DATA_ACCESS);
|
|
|
|
#endif
|
2006-05-08 00:45:42 +04:00
|
|
|
|
2007-10-29 18:39:18 +03:00
|
|
|
// Check that native host access was not vetoed for that page
|
|
|
|
if (!hostAddrSrc) return 0;
|
2006-05-08 00:45:42 +04:00
|
|
|
|
2007-10-29 18:39:18 +03:00
|
|
|
// See how many words can fit in the rest of this page.
|
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
// Counting downward
|
|
|
|
// Note: 1st word must not cross page boundary.
|
|
|
|
if ((laddrSrc & 0xfff) > 0xffe) return 0;
|
|
|
|
wordsFitSrc = (2 + (laddrSrc & 0xfff)) >> 1;
|
|
|
|
pointerDelta = (unsigned) -2;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Counting upward
|
|
|
|
wordsFitSrc = (0x1000 - (laddrSrc & 0xfff)) >> 1;
|
|
|
|
pointerDelta = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Restrict word count to the number that will fit in this page.
|
|
|
|
if (wordCount > wordsFitSrc)
|
|
|
|
wordCount = wordsFitSrc;
|
|
|
|
|
|
|
|
// If after all the restrictions, there is anything left to do...
|
|
|
|
if (wordCount) {
|
|
|
|
Bit32u srcSegLimit = srcSegPtr->cache.u.segment.limit_scaled;
|
|
|
|
unsigned count;
|
|
|
|
|
|
|
|
// For 16-bit addressing mode, clamp the segment limits to 16bits
|
|
|
|
// so we don't have to worry about computations using si/di
|
|
|
|
// rolling over 16-bit boundaries.
|
|
|
|
if (!i->as32L()) {
|
|
|
|
if (srcSegLimit > 0xffff)
|
|
|
|
srcSegLimit = 0xffff;
|
2006-05-08 00:45:42 +04:00
|
|
|
}
|
|
|
|
|
2007-10-29 18:39:18 +03:00
|
|
|
// Before we copy memory, we need to make sure that the segments
|
|
|
|
// allow the accesses up to the given source and dest offset. If
|
|
|
|
// the cache.valid bits have SegAccessWOK and ROK, we know that
|
|
|
|
// the cache is valid for those operations, and that the segments
|
|
|
|
// are non-expand down (thus we can make a simple limit check).
|
|
|
|
if ( !(srcSegPtr->cache.valid & SegAccessROK) ) return 0;
|
2006-05-08 00:45:42 +04:00
|
|
|
|
2007-10-29 18:39:18 +03:00
|
|
|
if (BX_CPU_THIS_PTR cpu_mode != BX_MODE_LONG_64)
|
|
|
|
{
|
|
|
|
// Now make sure transfer will fit within the constraints of the
|
|
|
|
// segment boundaries, 0..limit for non expand-down. We know
|
|
|
|
// wordCount >= 1 here.
|
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
|
|
|
// Counting downward
|
|
|
|
Bit32u minOffset = (wordCount-1) << 1;
|
|
|
|
if (srcOff < minOffset) return 0;
|
2006-05-08 00:45:42 +04:00
|
|
|
}
|
2007-10-29 18:39:18 +03:00
|
|
|
else {
|
|
|
|
// Counting upward
|
|
|
|
Bit32u srcMaxOffset = (srcSegLimit - (wordCount<<1)) + 1;
|
|
|
|
if (srcOff > srcMaxOffset) return 0;
|
2006-05-08 00:45:42 +04:00
|
|
|
}
|
2007-10-29 18:39:18 +03:00
|
|
|
}
|
2006-05-08 00:45:42 +04:00
|
|
|
|
2007-10-29 18:39:18 +03:00
|
|
|
for (count=0; count<wordCount; ) {
|
|
|
|
bx_devices.bulkIOQuantumsTransferred = 0;
|
|
|
|
if (BX_CPU_THIS_PTR get_DF()==0) { // Only do accel for DF=0
|
|
|
|
bx_devices.bulkIOHostAddr = hostAddrSrc;
|
|
|
|
bx_devices.bulkIOQuantumsRequested = (wordCount - count);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
bx_devices.bulkIOQuantumsRequested = 0;
|
|
|
|
Bit16u temp16 = * (Bit16u *) hostAddrSrc;
|
2006-08-01 21:09:05 +04:00
|
|
|
#ifdef BX_LITTLE_ENDIAN
|
2007-10-29 18:39:18 +03:00
|
|
|
BX_OUTP(port, temp16, 2);
|
2006-08-01 21:09:05 +04:00
|
|
|
#else
|
2007-10-29 18:39:18 +03:00
|
|
|
BX_OUTP(port, ((temp16 >> 8) | (temp16 << 8)), 2);
|
2006-08-01 21:09:05 +04:00
|
|
|
#endif
|
2007-10-29 18:39:18 +03:00
|
|
|
if (bx_devices.bulkIOQuantumsTransferred) {
|
|
|
|
hostAddrSrc = bx_devices.bulkIOHostAddr;
|
|
|
|
count += bx_devices.bulkIOQuantumsTransferred;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
hostAddrSrc += pointerDelta;
|
|
|
|
count++;
|
2006-05-08 00:45:42 +04:00
|
|
|
}
|
2007-10-29 18:39:18 +03:00
|
|
|
// Terminate early if there was an event.
|
|
|
|
if (BX_CPU_THIS_PTR async_event) break;
|
|
|
|
}
|
2006-05-08 00:45:42 +04:00
|
|
|
|
2007-10-29 18:39:18 +03:00
|
|
|
// Reset for next non-bulk IO
|
|
|
|
bx_devices.bulkIOQuantumsRequested = 0;
|
2006-05-08 00:45:42 +04:00
|
|
|
|
2007-10-29 18:39:18 +03:00
|
|
|
return count;
|
2006-05-08 00:45:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2002-09-09 20:56:56 +04:00
|
|
|
|
2007-01-05 16:40:47 +03:00
|
|
|
//
|
|
|
|
// REP INS methods
|
|
|
|
//
|
|
|
|
|
|
|
|
void BX_CPU_C::REP_INSB_YbDX(bxInstruction_c *i)
|
|
|
|
{
|
|
|
|
BX_CPU_THIS_PTR repeat(i, &BX_CPU_C::INSB_YbDX);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BX_CPU_C::REP_INSW_YwDX(bxInstruction_c *i)
|
|
|
|
{
|
|
|
|
BX_CPU_THIS_PTR repeat(i, &BX_CPU_C::INSW_YwDX);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BX_CPU_C::REP_INSD_YdDX(bxInstruction_c *i)
|
|
|
|
{
|
|
|
|
BX_CPU_THIS_PTR repeat(i, &BX_CPU_C::INSD_YdDX);
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// INSB/INSW/INSD methods
|
|
|
|
//
|
|
|
|
|
2005-05-21 00:06:50 +04:00
|
|
|
void BX_CPU_C::INSB_YbDX(bxInstruction_c *i)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
|
|
|
Bit8u value8=0;
|
|
|
|
|
2007-07-09 19:16:14 +04:00
|
|
|
if (BX_CPU_THIS_PTR cr0.get_PE() && (BX_CPU_THIS_PTR get_VM() || (CPL>BX_CPU_THIS_PTR get_IOPL()))) {
|
2006-06-10 02:29:07 +04:00
|
|
|
if (! BX_CPU_THIS_PTR allow_io(DX, 1)) {
|
|
|
|
BX_DEBUG(("INSB_YbDX: I/O access not allowed !"));
|
2001-04-10 05:04:59 +04:00
|
|
|
exception(BX_GP_EXCEPTION, 0, 0);
|
|
|
|
}
|
2005-05-21 00:06:50 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2004-03-02 23:48:48 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
2002-09-18 09:36:48 +04:00
|
|
|
if (i->as64L()) {
|
2002-09-15 06:55:34 +04:00
|
|
|
// Write a zero to memory, to trigger any segment or page
|
|
|
|
// faults before reading from IO port.
|
|
|
|
write_virtual_byte(BX_SEG_REG_ES, RDI, &value8);
|
|
|
|
|
|
|
|
value8 = BX_INP(DX, 1);
|
|
|
|
|
|
|
|
/* no seg override possible */
|
|
|
|
write_virtual_byte(BX_SEG_REG_ES, RDI, &value8);
|
|
|
|
|
2006-05-07 22:27:36 +04:00
|
|
|
if (BX_CPU_THIS_PTR get_DF())
|
2004-03-02 23:48:48 +03:00
|
|
|
RDI--;
|
|
|
|
else
|
|
|
|
RDI++;
|
2005-05-21 00:06:50 +04:00
|
|
|
}
|
2004-03-02 23:48:48 +03:00
|
|
|
else
|
|
|
|
#endif
|
|
|
|
if (i->as32L()) {
|
2001-04-10 05:04:59 +04:00
|
|
|
// Write a zero to memory, to trigger any segment or page
|
|
|
|
// faults before reading from IO port.
|
|
|
|
write_virtual_byte(BX_SEG_REG_ES, EDI, &value8);
|
|
|
|
|
|
|
|
value8 = BX_INP(DX, 1);
|
|
|
|
|
|
|
|
/* no seg override possible */
|
|
|
|
write_virtual_byte(BX_SEG_REG_ES, EDI, &value8);
|
|
|
|
|
2006-05-07 22:27:36 +04:00
|
|
|
if (BX_CPU_THIS_PTR get_DF()) {
|
2002-09-15 06:55:34 +04:00
|
|
|
RDI = EDI - 1;
|
2005-05-21 00:06:50 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
else {
|
2002-09-15 06:55:34 +04:00
|
|
|
RDI = EDI + 1;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
2005-05-21 00:06:50 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
else {
|
|
|
|
// Write a zero to memory, to trigger any segment or page
|
|
|
|
// faults before reading from IO port.
|
|
|
|
write_virtual_byte(BX_SEG_REG_ES, DI, &value8);
|
|
|
|
|
|
|
|
value8 = BX_INP(DX, 1);
|
|
|
|
|
|
|
|
/* no seg override possible */
|
|
|
|
write_virtual_byte(BX_SEG_REG_ES, DI, &value8);
|
|
|
|
|
2006-05-07 22:27:36 +04:00
|
|
|
if (BX_CPU_THIS_PTR get_DF())
|
2004-03-02 23:48:48 +03:00
|
|
|
DI--;
|
|
|
|
else
|
|
|
|
DI++;
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2006-05-07 22:27:36 +04:00
|
|
|
// input word from port to string
|
|
|
|
void BX_CPU_C::INSW_YwDX(bxInstruction_c *i)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2002-09-15 06:55:34 +04:00
|
|
|
bx_address edi;
|
2006-05-07 22:27:36 +04:00
|
|
|
unsigned int incr = 2;
|
|
|
|
|
2004-03-02 23:48:48 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
2006-05-07 22:27:36 +04:00
|
|
|
if (i->as64L())
|
2002-09-15 06:55:34 +04:00
|
|
|
edi = RDI;
|
2004-03-02 23:48:48 +03:00
|
|
|
else
|
|
|
|
#endif
|
|
|
|
if (i->as32L())
|
2001-04-10 05:04:59 +04:00
|
|
|
edi = EDI;
|
|
|
|
else
|
|
|
|
edi = DI;
|
|
|
|
|
2006-05-07 22:27:36 +04:00
|
|
|
Bit16u value16=0;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-10-11 02:20:32 +04:00
|
|
|
#if (BX_SupportRepeatSpeedups) && (BX_DEBUGGER == 0)
|
2006-05-07 22:27:36 +04:00
|
|
|
/* If conditions are right, we can transfer IO to physical memory
|
|
|
|
* in a batch, rather than one instruction at a time.
|
|
|
|
*/
|
|
|
|
if (i->repUsedL() && !BX_CPU_THIS_PTR async_event) {
|
|
|
|
Bit32u wordCount;
|
Integrated patches for:
- Paging code rehash. You must now use --enable-4meg-pages to
use 4Meg pages, with the default of disabled, since we don't well
support 4Meg pages yet. Paging table walks model a real CPU
more closely now, and I fixed some bugs in the old logic.
- Segment check redundancy elimination. After a segment is loaded,
reads and writes are marked when a segment type check succeeds, and
they are skipped thereafter, when possible.
- Repeated IO and memory string copy acceleration. Only some variants
of instructions are available on all platforms, word and dword
variants only on x86 for the moment due to alignment and endian issues.
This is compiled in currently with no option - I should add a configure
option.
- Added a guest linear address to host TLB. Actually, I just stick
the host address (mem.vector[addr] address) in the upper 29 bits
of the field 'combined_access' since they are unused. Convenient
for now. I'm only storing page frame addresses. This was the
simplest for of such a TLB. We can likely enhance this. Also,
I only accelerated the normal read/write routines in access.cc.
Could also modify the read-modify-write versions too. You must
use --enable-guest2host-tlb, to try this out. Currently speeds
up Win95 boot time by about 3.5% for me. More ground to cover...
- Minor mods to CPUI/MOV_CdRd for CMOV.
- Integrated enhancements from Volker to getHostMemAddr() for PCI
being enabled.
2002-09-02 00:12:09 +04:00
|
|
|
|
2002-09-24 08:43:59 +04:00
|
|
|
#if BX_SUPPORT_X86_64
|
2006-05-07 22:27:36 +04:00
|
|
|
if (i->as64L())
|
|
|
|
wordCount = RCX; // Truncated to 32bits. (we're only doing 1 page)
|
|
|
|
else
|
2002-09-24 08:43:59 +04:00
|
|
|
#endif
|
2006-05-07 22:27:36 +04:00
|
|
|
if (i->as32L())
|
|
|
|
wordCount = ECX;
|
|
|
|
else
|
2006-05-08 00:45:42 +04:00
|
|
|
wordCount = CX;
|
|
|
|
|
|
|
|
BX_ASSERT(wordCount > 0);
|
|
|
|
wordCount = FastRepINSW(i, edi, DX, wordCount);
|
|
|
|
if (wordCount)
|
|
|
|
{
|
|
|
|
// Decrement the ticks count by the number of iterations, minus
|
|
|
|
// one, since the main cpu loop will decrement one. Also,
|
|
|
|
// the count is predecremented before examined, so defintely
|
|
|
|
// don't roll it under zero.
|
|
|
|
BX_TICKN(wordCount-1);
|
2006-05-07 22:27:36 +04:00
|
|
|
|
|
|
|
#if BX_SUPPORT_X86_64
|
2006-05-08 00:45:42 +04:00
|
|
|
if (i->as64L())
|
|
|
|
RCX -= (wordCount-1);
|
|
|
|
else
|
2006-05-07 22:27:36 +04:00
|
|
|
#endif
|
2006-05-08 00:45:42 +04:00
|
|
|
if (i->as32L())
|
2007-09-25 20:11:32 +04:00
|
|
|
RCX = ECX - (wordCount-1);
|
2006-05-08 00:45:42 +04:00
|
|
|
else
|
2007-10-29 18:39:18 +03:00
|
|
|
CX -= (wordCount-1);
|
2006-05-08 00:45:42 +04:00
|
|
|
|
|
|
|
incr = wordCount << 1; // count * 2.
|
|
|
|
goto doIncr;
|
2005-05-21 00:06:50 +04:00
|
|
|
}
|
2006-05-07 22:27:36 +04:00
|
|
|
}
|
2007-10-11 02:20:32 +04:00
|
|
|
#endif
|
2002-09-03 23:38:27 +04:00
|
|
|
|
2006-05-07 22:27:36 +04:00
|
|
|
// Write a zero to memory, to trigger any segment or page
|
|
|
|
// faults before reading from IO port.
|
|
|
|
write_virtual_word(BX_SEG_REG_ES, edi, &value16);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2006-05-07 22:27:36 +04:00
|
|
|
value16 = BX_INP(DX, 2);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2006-05-07 22:27:36 +04:00
|
|
|
/* no seg override allowed */
|
|
|
|
write_virtual_word(BX_SEG_REG_ES, edi, &value16);
|
|
|
|
incr = 2;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-10-11 02:20:32 +04:00
|
|
|
#if (BX_SupportRepeatSpeedups) && (BX_DEBUGGER == 0)
|
Integrated patches for:
- Paging code rehash. You must now use --enable-4meg-pages to
use 4Meg pages, with the default of disabled, since we don't well
support 4Meg pages yet. Paging table walks model a real CPU
more closely now, and I fixed some bugs in the old logic.
- Segment check redundancy elimination. After a segment is loaded,
reads and writes are marked when a segment type check succeeds, and
they are skipped thereafter, when possible.
- Repeated IO and memory string copy acceleration. Only some variants
of instructions are available on all platforms, word and dword
variants only on x86 for the moment due to alignment and endian issues.
This is compiled in currently with no option - I should add a configure
option.
- Added a guest linear address to host TLB. Actually, I just stick
the host address (mem.vector[addr] address) in the upper 29 bits
of the field 'combined_access' since they are unused. Convenient
for now. I'm only storing page frame addresses. This was the
simplest for of such a TLB. We can likely enhance this. Also,
I only accelerated the normal read/write routines in access.cc.
Could also modify the read-modify-write versions too. You must
use --enable-guest2host-tlb, to try this out. Currently speeds
up Win95 boot time by about 3.5% for me. More ground to cover...
- Minor mods to CPUI/MOV_CdRd for CMOV.
- Integrated enhancements from Volker to getHostMemAddr() for PCI
being enabled.
2002-09-02 00:12:09 +04:00
|
|
|
doIncr:
|
2002-09-03 23:38:27 +04:00
|
|
|
#endif
|
Integrated patches for:
- Paging code rehash. You must now use --enable-4meg-pages to
use 4Meg pages, with the default of disabled, since we don't well
support 4Meg pages yet. Paging table walks model a real CPU
more closely now, and I fixed some bugs in the old logic.
- Segment check redundancy elimination. After a segment is loaded,
reads and writes are marked when a segment type check succeeds, and
they are skipped thereafter, when possible.
- Repeated IO and memory string copy acceleration. Only some variants
of instructions are available on all platforms, word and dword
variants only on x86 for the moment due to alignment and endian issues.
This is compiled in currently with no option - I should add a configure
option.
- Added a guest linear address to host TLB. Actually, I just stick
the host address (mem.vector[addr] address) in the upper 29 bits
of the field 'combined_access' since they are unused. Convenient
for now. I'm only storing page frame addresses. This was the
simplest for of such a TLB. We can likely enhance this. Also,
I only accelerated the normal read/write routines in access.cc.
Could also modify the read-modify-write versions too. You must
use --enable-guest2host-tlb, to try this out. Currently speeds
up Win95 boot time by about 3.5% for me. More ground to cover...
- Minor mods to CPUI/MOV_CdRd for CMOV.
- Integrated enhancements from Volker to getHostMemAddr() for PCI
being enabled.
2002-09-02 00:12:09 +04:00
|
|
|
|
2004-03-02 23:48:48 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
2002-09-18 09:36:48 +04:00
|
|
|
if (i->as64L()) {
|
2006-05-08 00:45:42 +04:00
|
|
|
if (BX_CPU_THIS_PTR get_DF())
|
2002-09-15 06:55:34 +04:00
|
|
|
RDI = RDI - incr;
|
|
|
|
else
|
|
|
|
RDI = RDI + incr;
|
2005-05-21 00:06:50 +04:00
|
|
|
}
|
2002-09-15 06:55:34 +04:00
|
|
|
else
|
2004-03-02 23:48:48 +03:00
|
|
|
#endif
|
2002-09-18 09:36:48 +04:00
|
|
|
if (i->as32L()) {
|
2006-05-08 00:45:42 +04:00
|
|
|
if (BX_CPU_THIS_PTR get_DF())
|
2002-09-15 06:55:34 +04:00
|
|
|
RDI = EDI - incr;
|
2001-04-10 05:04:59 +04:00
|
|
|
else
|
2002-09-15 06:55:34 +04:00
|
|
|
RDI = EDI + incr;
|
2005-05-21 00:06:50 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
else {
|
2006-05-08 00:45:42 +04:00
|
|
|
if (BX_CPU_THIS_PTR get_DF())
|
2001-04-10 05:04:59 +04:00
|
|
|
DI = DI - incr;
|
|
|
|
else
|
|
|
|
DI = DI + incr;
|
2005-05-21 00:06:50 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2006-05-07 22:27:36 +04:00
|
|
|
// input doubleword from port to string
|
2006-06-10 02:29:07 +04:00
|
|
|
void BX_CPU_C::INSD_YdDX(bxInstruction_c *i)
|
2006-05-07 22:27:36 +04:00
|
|
|
{
|
2007-07-09 19:16:14 +04:00
|
|
|
if (BX_CPU_THIS_PTR cr0.get_PE() && (BX_CPU_THIS_PTR get_VM() || (CPL>BX_CPU_THIS_PTR get_IOPL()))) {
|
2006-05-07 22:27:36 +04:00
|
|
|
if (! BX_CPU_THIS_PTR allow_io(DX, 4)) {
|
2006-06-10 02:29:07 +04:00
|
|
|
BX_DEBUG(("INSD_YdDX: I/O access not allowed !"));
|
2006-05-07 22:27:36 +04:00
|
|
|
exception(BX_GP_EXCEPTION, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bx_address edi;
|
|
|
|
|
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
if (i->as64L())
|
|
|
|
edi = RDI;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
if (i->as32L())
|
|
|
|
edi = EDI;
|
|
|
|
else
|
2007-10-29 18:39:18 +03:00
|
|
|
edi = DI;
|
2006-05-07 22:27:36 +04:00
|
|
|
|
|
|
|
Bit32u value32=0;
|
|
|
|
|
|
|
|
// Write a zero to memory, to trigger any segment or page
|
|
|
|
// faults before reading from IO port.
|
|
|
|
write_virtual_dword(BX_SEG_REG_ES, edi, &value32);
|
|
|
|
|
|
|
|
value32 = BX_INP(DX, 4);
|
|
|
|
|
|
|
|
/* no seg override allowed */
|
|
|
|
write_virtual_dword(BX_SEG_REG_ES, edi, &value32);
|
|
|
|
|
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
if (i->as64L()) {
|
|
|
|
if (BX_CPU_THIS_PTR get_DF())
|
|
|
|
RDI = RDI - 4;
|
|
|
|
else
|
|
|
|
RDI = RDI + 4;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
if (i->as32L()) {
|
|
|
|
if (BX_CPU_THIS_PTR get_DF())
|
|
|
|
RDI = EDI - 4;
|
|
|
|
else
|
|
|
|
RDI = EDI + 4;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (BX_CPU_THIS_PTR get_DF())
|
|
|
|
DI = DI - 4;
|
|
|
|
else
|
|
|
|
DI = DI + 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-05 16:40:47 +03:00
|
|
|
//
|
|
|
|
// REP OUTS methods
|
|
|
|
//
|
|
|
|
|
|
|
|
void BX_CPU_C::REP_OUTSB_DXXb(bxInstruction_c *i)
|
|
|
|
{
|
|
|
|
BX_CPU_THIS_PTR repeat(i, &BX_CPU_C::OUTSB_DXXb);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BX_CPU_C::REP_OUTSW_DXXw(bxInstruction_c *i)
|
|
|
|
{
|
|
|
|
BX_CPU_THIS_PTR repeat(i, &BX_CPU_C::OUTSW_DXXw);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BX_CPU_C::REP_OUTSD_DXXd(bxInstruction_c *i)
|
|
|
|
{
|
|
|
|
BX_CPU_THIS_PTR repeat(i, &BX_CPU_C::OUTSD_DXXd);
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// OUTSB/OUTSW/OUTSD methods
|
|
|
|
//
|
|
|
|
|
2005-05-21 00:06:50 +04:00
|
|
|
void BX_CPU_C::OUTSB_DXXb(bxInstruction_c *i)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
|
|
|
Bit8u value8;
|
2002-09-15 06:55:34 +04:00
|
|
|
bx_address esi;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-07-09 19:16:14 +04:00
|
|
|
if (BX_CPU_THIS_PTR cr0.get_PE() && (BX_CPU_THIS_PTR get_VM() || (CPL>BX_CPU_THIS_PTR get_IOPL()))) {
|
2006-05-07 22:27:36 +04:00
|
|
|
if (! BX_CPU_THIS_PTR allow_io(DX, 1)) {
|
2006-06-10 02:29:07 +04:00
|
|
|
BX_DEBUG(("OUTSB_DXXb: I/O access not allowed !"));
|
2001-04-10 05:04:59 +04:00
|
|
|
exception(BX_GP_EXCEPTION, 0, 0);
|
|
|
|
}
|
2005-05-21 00:06:50 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2004-03-02 23:48:48 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
2002-09-18 09:36:48 +04:00
|
|
|
if (i->as64L())
|
2002-09-15 06:55:34 +04:00
|
|
|
esi = RSI;
|
2004-03-02 23:48:48 +03:00
|
|
|
else
|
|
|
|
#endif
|
|
|
|
if (i->as32L())
|
2001-04-10 05:04:59 +04:00
|
|
|
esi = ESI;
|
|
|
|
else
|
|
|
|
esi = SI;
|
|
|
|
|
2006-05-25 00:57:37 +04:00
|
|
|
read_virtual_byte(i->seg(), esi, &value8);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
BX_OUTP(DX, value8, 1);
|
|
|
|
|
2004-03-02 23:48:48 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
2002-09-18 09:36:48 +04:00
|
|
|
if (i->as64L()) {
|
2006-05-07 22:27:36 +04:00
|
|
|
if (BX_CPU_THIS_PTR get_DF())
|
2004-03-02 23:48:48 +03:00
|
|
|
RSI--;
|
2002-09-17 00:23:38 +04:00
|
|
|
else
|
2004-03-02 23:48:48 +03:00
|
|
|
RSI++;
|
2005-05-21 00:06:50 +04:00
|
|
|
}
|
2004-03-02 23:48:48 +03:00
|
|
|
else
|
|
|
|
#endif
|
|
|
|
if (i->as32L()) {
|
2006-05-07 22:27:36 +04:00
|
|
|
if (BX_CPU_THIS_PTR get_DF())
|
2007-10-29 18:39:18 +03:00
|
|
|
RSI = ESI-1;
|
2001-04-10 05:04:59 +04:00
|
|
|
else
|
2007-10-29 18:39:18 +03:00
|
|
|
RSI = ESI+1;
|
2005-05-21 00:06:50 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
else {
|
2006-05-07 22:27:36 +04:00
|
|
|
if (BX_CPU_THIS_PTR get_DF())
|
2004-03-02 23:48:48 +03:00
|
|
|
SI--;
|
2001-04-10 05:04:59 +04:00
|
|
|
else
|
2004-03-02 23:48:48 +03:00
|
|
|
SI++;
|
2005-05-21 00:06:50 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2006-05-07 22:27:36 +04:00
|
|
|
// output word string to port
|
|
|
|
void BX_CPU_C::OUTSW_DXXw(bxInstruction_c *i)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2002-09-24 08:43:59 +04:00
|
|
|
bx_address esi;
|
2006-05-07 22:27:36 +04:00
|
|
|
unsigned incr = 2;
|
|
|
|
|
2007-07-09 19:16:14 +04:00
|
|
|
if (BX_CPU_THIS_PTR cr0.get_PE() && (BX_CPU_THIS_PTR get_VM() || (CPL>BX_CPU_THIS_PTR get_IOPL()))) {
|
2006-06-10 02:29:07 +04:00
|
|
|
if (! BX_CPU_THIS_PTR allow_io(DX, 2)) {
|
|
|
|
BX_DEBUG(("OUTSW_DXXw: I/O access not allowed !"));
|
2006-05-07 22:27:36 +04:00
|
|
|
exception(BX_GP_EXCEPTION, 0, 0);
|
2006-06-10 02:29:07 +04:00
|
|
|
}
|
2006-05-07 22:27:36 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2004-03-02 23:48:48 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
2002-09-18 09:36:48 +04:00
|
|
|
if (i->as64L())
|
2002-09-15 06:55:34 +04:00
|
|
|
esi = RSI;
|
2004-03-02 23:48:48 +03:00
|
|
|
else
|
|
|
|
#endif
|
|
|
|
if (i->as32L())
|
2001-04-10 05:04:59 +04:00
|
|
|
esi = ESI;
|
|
|
|
else
|
|
|
|
esi = SI;
|
|
|
|
|
2006-05-07 22:27:36 +04:00
|
|
|
Bit16u value16=0;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-10-11 02:20:32 +04:00
|
|
|
#if (BX_SupportRepeatSpeedups) && (BX_DEBUGGER == 0)
|
2006-05-07 22:27:36 +04:00
|
|
|
/* If conditions are right, we can transfer IO to physical memory
|
|
|
|
* in a batch, rather than one instruction at a time.
|
|
|
|
*/
|
|
|
|
if (i->repUsedL() && !BX_CPU_THIS_PTR async_event) {
|
|
|
|
Bit32u wordCount;
|
Integrated patches for:
- Paging code rehash. You must now use --enable-4meg-pages to
use 4Meg pages, with the default of disabled, since we don't well
support 4Meg pages yet. Paging table walks model a real CPU
more closely now, and I fixed some bugs in the old logic.
- Segment check redundancy elimination. After a segment is loaded,
reads and writes are marked when a segment type check succeeds, and
they are skipped thereafter, when possible.
- Repeated IO and memory string copy acceleration. Only some variants
of instructions are available on all platforms, word and dword
variants only on x86 for the moment due to alignment and endian issues.
This is compiled in currently with no option - I should add a configure
option.
- Added a guest linear address to host TLB. Actually, I just stick
the host address (mem.vector[addr] address) in the upper 29 bits
of the field 'combined_access' since they are unused. Convenient
for now. I'm only storing page frame addresses. This was the
simplest for of such a TLB. We can likely enhance this. Also,
I only accelerated the normal read/write routines in access.cc.
Could also modify the read-modify-write versions too. You must
use --enable-guest2host-tlb, to try this out. Currently speeds
up Win95 boot time by about 3.5% for me. More ground to cover...
- Minor mods to CPUI/MOV_CdRd for CMOV.
- Integrated enhancements from Volker to getHostMemAddr() for PCI
being enabled.
2002-09-02 00:12:09 +04:00
|
|
|
|
2002-09-24 08:43:59 +04:00
|
|
|
#if BX_SUPPORT_X86_64
|
2006-05-07 22:27:36 +04:00
|
|
|
if (i->as64L())
|
|
|
|
wordCount = RCX; // Truncated to 32bits. (we're only doing 1 page)
|
|
|
|
else
|
2002-09-24 08:43:59 +04:00
|
|
|
#endif
|
2006-05-07 22:27:36 +04:00
|
|
|
if (i->as32L())
|
|
|
|
wordCount = ECX;
|
|
|
|
else
|
2007-10-29 18:39:18 +03:00
|
|
|
wordCount = CX;
|
2006-05-07 22:27:36 +04:00
|
|
|
|
2006-05-25 00:57:37 +04:00
|
|
|
wordCount = FastRepOUTSW(i, i->seg(), esi, DX, wordCount);
|
2007-10-29 18:39:18 +03:00
|
|
|
if (wordCount) {
|
2006-05-08 00:45:42 +04:00
|
|
|
// Decrement eCX. Note, the main loop will decrement 1 also, so
|
|
|
|
// decrement by one less than expected, like the case above.
|
|
|
|
BX_TICKN(wordCount-1); // Main cpu loop also decrements one more.
|
2006-05-07 22:27:36 +04:00
|
|
|
|
2002-09-24 08:43:59 +04:00
|
|
|
#if BX_SUPPORT_X86_64
|
2006-05-08 00:45:42 +04:00
|
|
|
if (i->as64L())
|
|
|
|
RCX -= (wordCount-1);
|
|
|
|
else
|
2002-09-24 08:43:59 +04:00
|
|
|
#endif
|
2006-05-08 00:45:42 +04:00
|
|
|
if (i->as32L())
|
2007-09-25 20:11:32 +04:00
|
|
|
RCX = ECX - (wordCount-1);
|
2006-05-08 00:45:42 +04:00
|
|
|
else
|
2007-10-29 18:39:18 +03:00
|
|
|
CX -= (wordCount-1);
|
2006-05-08 00:45:42 +04:00
|
|
|
incr = wordCount << 1; // count * 2.
|
2007-10-29 18:39:18 +03:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
read_virtual_word(i->seg(), esi, &value16);
|
|
|
|
BX_OUTP(DX, value16, 2);
|
2005-05-21 00:06:50 +04:00
|
|
|
}
|
2006-05-07 22:27:36 +04:00
|
|
|
}
|
2007-10-29 18:39:18 +03:00
|
|
|
else
|
2002-09-03 23:38:27 +04:00
|
|
|
#endif
|
2007-10-29 18:39:18 +03:00
|
|
|
{
|
|
|
|
read_virtual_word(i->seg(), esi, &value16);
|
|
|
|
BX_OUTP(DX, value16, 2);
|
|
|
|
}
|
Integrated patches for:
- Paging code rehash. You must now use --enable-4meg-pages to
use 4Meg pages, with the default of disabled, since we don't well
support 4Meg pages yet. Paging table walks model a real CPU
more closely now, and I fixed some bugs in the old logic.
- Segment check redundancy elimination. After a segment is loaded,
reads and writes are marked when a segment type check succeeds, and
they are skipped thereafter, when possible.
- Repeated IO and memory string copy acceleration. Only some variants
of instructions are available on all platforms, word and dword
variants only on x86 for the moment due to alignment and endian issues.
This is compiled in currently with no option - I should add a configure
option.
- Added a guest linear address to host TLB. Actually, I just stick
the host address (mem.vector[addr] address) in the upper 29 bits
of the field 'combined_access' since they are unused. Convenient
for now. I'm only storing page frame addresses. This was the
simplest for of such a TLB. We can likely enhance this. Also,
I only accelerated the normal read/write routines in access.cc.
Could also modify the read-modify-write versions too. You must
use --enable-guest2host-tlb, to try this out. Currently speeds
up Win95 boot time by about 3.5% for me. More ground to cover...
- Minor mods to CPUI/MOV_CdRd for CMOV.
- Integrated enhancements from Volker to getHostMemAddr() for PCI
being enabled.
2002-09-02 00:12:09 +04:00
|
|
|
|
2004-03-02 23:48:48 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
2002-09-18 09:36:48 +04:00
|
|
|
if (i->as64L()) {
|
2006-05-07 22:27:36 +04:00
|
|
|
if (BX_CPU_THIS_PTR get_DF())
|
2002-09-15 06:55:34 +04:00
|
|
|
RSI = RSI - incr;
|
|
|
|
else
|
|
|
|
RSI = RSI + incr;
|
2005-05-21 00:06:50 +04:00
|
|
|
}
|
2004-03-02 23:48:48 +03:00
|
|
|
else
|
|
|
|
#endif
|
|
|
|
if (i->as32L()) {
|
2006-05-07 22:27:36 +04:00
|
|
|
if (BX_CPU_THIS_PTR get_DF())
|
2002-09-15 06:55:34 +04:00
|
|
|
RSI = ESI - incr;
|
2001-04-10 05:04:59 +04:00
|
|
|
else
|
2002-09-15 06:55:34 +04:00
|
|
|
RSI = ESI + incr;
|
2005-05-21 00:06:50 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
else {
|
2006-05-07 22:27:36 +04:00
|
|
|
if (BX_CPU_THIS_PTR get_DF())
|
2001-04-10 05:04:59 +04:00
|
|
|
SI = SI - incr;
|
|
|
|
else
|
|
|
|
SI = SI + incr;
|
2005-05-21 00:06:50 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2006-05-07 22:27:36 +04:00
|
|
|
// output doubleword string to port
|
2006-06-10 02:29:07 +04:00
|
|
|
void BX_CPU_C::OUTSD_DXXd(bxInstruction_c *i)
|
2006-05-07 22:27:36 +04:00
|
|
|
{
|
2007-07-09 19:16:14 +04:00
|
|
|
if (BX_CPU_THIS_PTR cr0.get_PE() && (BX_CPU_THIS_PTR get_VM() || (CPL>BX_CPU_THIS_PTR get_IOPL()))) {
|
2006-06-10 02:29:07 +04:00
|
|
|
if (! BX_CPU_THIS_PTR allow_io(DX, 4)) {
|
|
|
|
BX_DEBUG(("OUTSD_DXXd: I/O access not allowed !"));
|
2006-05-07 22:27:36 +04:00
|
|
|
exception(BX_GP_EXCEPTION, 0, 0);
|
2006-06-10 02:29:07 +04:00
|
|
|
}
|
2006-05-07 22:27:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bx_address esi;
|
|
|
|
|
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
if (i->as64L())
|
|
|
|
esi = RSI;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
if (i->as32L())
|
|
|
|
esi = ESI;
|
|
|
|
else
|
2006-05-25 00:57:37 +04:00
|
|
|
esi = SI;
|
2006-05-07 22:27:36 +04:00
|
|
|
|
|
|
|
Bit32u value32=0;
|
2006-05-25 00:57:37 +04:00
|
|
|
read_virtual_dword(i->seg(), esi, &value32);
|
2006-05-07 22:27:36 +04:00
|
|
|
BX_OUTP(DX, value32, 4);
|
|
|
|
|
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
if (i->as64L()) {
|
|
|
|
if (BX_CPU_THIS_PTR get_DF())
|
|
|
|
RSI = RSI - 4;
|
|
|
|
else
|
|
|
|
RSI = RSI + 4;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
if (i->as32L()) {
|
|
|
|
if (BX_CPU_THIS_PTR get_DF())
|
|
|
|
RSI = ESI - 4;
|
|
|
|
else
|
|
|
|
RSI = ESI + 4;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (BX_CPU_THIS_PTR get_DF())
|
|
|
|
SI = SI - 4;
|
|
|
|
else
|
|
|
|
SI = SI + 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-05 16:40:47 +03:00
|
|
|
//
|
|
|
|
// non repeatable IN/OUT methods
|
|
|
|
//
|
|
|
|
|
2005-05-21 00:06:50 +04:00
|
|
|
void BX_CPU_C::IN_ALIb(bxInstruction_c *i)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2004-03-02 23:48:48 +03:00
|
|
|
AL = BX_CPU_THIS_PTR inp8(i->Ib());
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2006-05-07 22:27:36 +04:00
|
|
|
void BX_CPU_C::IN_AXIb(bxInstruction_c *i)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2006-05-07 22:27:36 +04:00
|
|
|
AX = BX_CPU_THIS_PTR inp16(i->Ib());
|
|
|
|
}
|
|
|
|
|
|
|
|
void BX_CPU_C::IN_EAXIb(bxInstruction_c *i)
|
|
|
|
{
|
|
|
|
RAX = BX_CPU_THIS_PTR inp32(i->Ib());
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2005-05-21 00:06:50 +04:00
|
|
|
void BX_CPU_C::OUT_IbAL(bxInstruction_c *i)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2004-03-02 23:48:48 +03:00
|
|
|
BX_CPU_THIS_PTR outp8(i->Ib(), AL);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2006-05-07 22:27:36 +04:00
|
|
|
void BX_CPU_C::OUT_IbAX(bxInstruction_c *i)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2006-05-07 22:27:36 +04:00
|
|
|
BX_CPU_THIS_PTR outp16(i->Ib(), AX);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BX_CPU_C::OUT_IbEAX(bxInstruction_c *i)
|
|
|
|
{
|
|
|
|
BX_CPU_THIS_PTR outp32(i->Ib(), EAX);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2005-05-21 00:06:50 +04:00
|
|
|
void BX_CPU_C::IN_ALDX(bxInstruction_c *i)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2004-03-02 23:48:48 +03:00
|
|
|
AL = BX_CPU_THIS_PTR inp8(DX);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2006-05-07 22:27:36 +04:00
|
|
|
void BX_CPU_C::IN_AXDX(bxInstruction_c *i)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2006-05-07 22:27:36 +04:00
|
|
|
AX = BX_CPU_THIS_PTR inp16(DX);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BX_CPU_C::IN_EAXDX(bxInstruction_c *i)
|
|
|
|
{
|
|
|
|
RAX = BX_CPU_THIS_PTR inp32(DX);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2005-05-21 00:06:50 +04:00
|
|
|
void BX_CPU_C::OUT_DXAL(bxInstruction_c *i)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2004-03-02 23:48:48 +03:00
|
|
|
BX_CPU_THIS_PTR outp8(DX, AL);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2006-05-07 22:27:36 +04:00
|
|
|
void BX_CPU_C::OUT_DXAX(bxInstruction_c *i)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2006-05-07 22:27:36 +04:00
|
|
|
BX_CPU_THIS_PTR outp16(DX, AX);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BX_CPU_C::OUT_DXEAX(bxInstruction_c *i)
|
|
|
|
{
|
|
|
|
BX_CPU_THIS_PTR outp32(DX, EAX);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|