2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2005-10-13 20:22:21 +04:00
|
|
|
// $Id: memory.cc,v 1.43 2005-10-13 16:22:21 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
|
|
|
|
|
|
|
|
|
2004-06-19 19:20:15 +04:00
|
|
|
#include "iodev/iodev.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_MEM_THIS
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
#if BX_PROVIDE_CPU_MEMORY
|
|
|
|
|
2003-03-03 02:59:12 +03:00
|
|
|
void BX_CPP_AttrRegparmN(3)
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
BX_MEM_C::writePhysicalPage(BX_CPU_C *cpu, Bit32u addr, unsigned len, void *data)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
|
|
|
Bit8u *data_ptr;
|
|
|
|
Bit32u a20addr;
|
|
|
|
|
2002-09-22 22:22:24 +04:00
|
|
|
// Note: accesses should always be contained within a single page now.
|
|
|
|
|
2004-08-06 19:49:55 +04:00
|
|
|
#if BX_SUPPORT_IODEBUG
|
2003-02-13 18:04:11 +03:00
|
|
|
bx_iodebug_c::mem_write(cpu, addr, len, data);
|
2001-09-15 03:02:56 +04:00
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2004-07-18 23:40:51 +04:00
|
|
|
a20addr = A20ADDR(addr);
|
2003-02-13 18:04:11 +03:00
|
|
|
BX_INSTR_PHY_WRITE(cpu->which_cpu(), a20addr, len);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
#if BX_DEBUGGER
|
|
|
|
// (mch) Check for physical write break points, TODO
|
2001-05-23 12:02:15 +04:00
|
|
|
// (bbd) Each breakpoint should have an associated CPU#, TODO
|
2001-04-10 05:04:59 +04:00
|
|
|
for (int i = 0; i < num_write_watchpoints; i++)
|
|
|
|
if (write_watchpoint[i] == a20addr) {
|
2002-04-01 08:43:26 +04:00
|
|
|
BX_CPU(0)->watchpoint = a20addr;
|
2001-05-23 12:02:15 +04:00
|
|
|
BX_CPU(0)->break_point = BREAK_POINT_WRITE;
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2005-10-01 13:52:35 +04:00
|
|
|
struct memory_handler_struct *memory_handler = memory_handlers[a20addr >> 20];
|
|
|
|
while (memory_handler) {
|
2005-10-13 20:22:21 +04:00
|
|
|
if (memory_handler->begin <= a20addr &&
|
|
|
|
memory_handler->end >= a20addr &&
|
|
|
|
memory_handler->write_handler(a20addr, len, data, memory_handler->write_param))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
memory_handler = memory_handler->next;
|
2005-10-01 13:52:35 +04:00
|
|
|
}
|
|
|
|
|
2004-07-30 00:15:19 +04:00
|
|
|
#if BX_SUPPORT_ICACHE
|
2002-09-19 23:17:20 +04:00
|
|
|
if (a20addr < BX_MEM_THIS len)
|
2005-04-10 23:42:48 +04:00
|
|
|
pageWriteStampTable.decWriteStamp(a20addr);
|
2002-09-19 23:17:20 +04:00
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2005-01-15 16:10:15 +03:00
|
|
|
#if BX_SUPPORT_APIC
|
2005-10-13 20:22:21 +04:00
|
|
|
bx_generic_apic_c *local_apic = &cpu->local_apic;
|
|
|
|
bx_generic_apic_c *ioapic = bx_devices.ioapic;
|
|
|
|
if (local_apic->is_selected (a20addr, len)) {
|
|
|
|
local_apic->write (a20addr, (Bit32u *)data, len);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (ioapic->is_selected (a20addr, len)) {
|
|
|
|
ioapic->write (a20addr, (Bit32u *)data, len);
|
|
|
|
return;
|
|
|
|
}
|
2005-01-15 16:10:15 +03:00
|
|
|
#endif
|
|
|
|
|
2004-12-04 16:48:53 +03:00
|
|
|
if ( (a20addr + len) <= BX_MEM_THIS len ) {
|
2001-04-10 05:04:59 +04:00
|
|
|
// all of data is within limits of physical memory
|
|
|
|
if ( (a20addr & 0xfff80000) != 0x00080000 ) {
|
|
|
|
if (len == 4) {
|
2002-09-22 22:22:24 +04:00
|
|
|
WriteHostDWordToLittleEndian(&vector[a20addr], *(Bit32u*)data);
|
|
|
|
BX_DBG_DIRTY_PAGE(a20addr >> 12);
|
|
|
|
return;
|
2005-01-15 16:10:15 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
if (len == 2) {
|
2002-09-22 22:22:24 +04:00
|
|
|
WriteHostWordToLittleEndian(&vector[a20addr], *(Bit16u*)data);
|
|
|
|
BX_DBG_DIRTY_PAGE(a20addr >> 12);
|
|
|
|
return;
|
2005-01-15 16:10:15 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
if (len == 1) {
|
2002-09-22 22:22:24 +04:00
|
|
|
* ((Bit8u *) (&vector[a20addr])) = * (Bit8u *) data;
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_DBG_DIRTY_PAGE(a20addr >> 12);
|
|
|
|
return;
|
2005-01-15 16:10:15 +03:00
|
|
|
}
|
2002-09-22 22:22:24 +04:00
|
|
|
// len == other, just fall thru to special cases handling
|
2005-10-13 20:22:21 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
#ifdef BX_LITTLE_ENDIAN
|
|
|
|
data_ptr = (Bit8u *) data;
|
|
|
|
#else // BX_BIG_ENDIAN
|
|
|
|
data_ptr = (Bit8u *) data + (len - 1);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
write_one:
|
|
|
|
if ( (a20addr & 0xfff80000) != 0x00080000 ) {
|
|
|
|
// addr *not* in range 00080000 .. 000FFFFF
|
2001-05-23 12:02:15 +04:00
|
|
|
vector[a20addr] = *data_ptr;
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_DBG_DIRTY_PAGE(a20addr >> 12);
|
|
|
|
inc_one:
|
|
|
|
if (len == 1) return;
|
|
|
|
len--;
|
2002-09-22 22:22:24 +04:00
|
|
|
a20addr++;
|
2001-04-10 05:04:59 +04:00
|
|
|
#ifdef BX_LITTLE_ENDIAN
|
|
|
|
data_ptr++;
|
|
|
|
#else // BX_BIG_ENDIAN
|
|
|
|
data_ptr--;
|
|
|
|
#endif
|
|
|
|
goto write_one;
|
2005-01-15 16:10:15 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
// addr in range 00080000 .. 000FFFFF
|
|
|
|
|
|
|
|
if (a20addr <= 0x0009ffff) {
|
|
|
|
// regular memory 80000 .. 9FFFF
|
2001-05-23 12:02:15 +04:00
|
|
|
vector[a20addr] = *data_ptr;
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_DBG_DIRTY_PAGE(a20addr >> 12);
|
|
|
|
goto inc_one;
|
2005-01-15 16:10:15 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
// adapter ROM C0000 .. DFFFF
|
|
|
|
// ROM BIOS memory E0000 .. FFFFF
|
2004-08-06 19:49:55 +04:00
|
|
|
#if BX_SUPPORT_PCI == 0
|
2001-04-10 05:04:59 +04:00
|
|
|
// ignore write to ROM
|
|
|
|
#else
|
|
|
|
// Write Based on 440fx Programming
|
2004-11-11 23:55:29 +03:00
|
|
|
if ( bx_options.Oi440FXSupport->get () &&
|
|
|
|
((a20addr & 0xfffc0000) == 0x000c0000) )
|
|
|
|
{
|
2002-11-03 20:17:11 +03:00
|
|
|
switch (DEV_pci_wr_memtype(a20addr & 0xFC000)) {
|
2002-08-31 19:35:51 +04:00
|
|
|
case 0x1: // Writes to ShadowRAM
|
2004-08-26 11:58:33 +04:00
|
|
|
BX_DEBUG(("Writing to ShadowRAM: address %08x, data %02x", (unsigned) a20addr, *data_ptr));
|
2004-11-11 23:55:29 +03:00
|
|
|
vector[a20addr] = *data_ptr;
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_DBG_DIRTY_PAGE(a20addr >> 12);
|
|
|
|
goto inc_one;
|
|
|
|
|
2002-08-31 19:35:51 +04:00
|
|
|
case 0x0: // Writes to ROM, Inhibit
|
2002-08-17 13:23:42 +04:00
|
|
|
BX_DEBUG(("Write to ROM ignored: address %08x, data %02x", (unsigned) a20addr, *data_ptr));
|
2001-04-10 05:04:59 +04:00
|
|
|
goto inc_one;
|
2005-01-15 16:10:15 +03:00
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
default:
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
BX_PANIC(("writePhysicalPage: default case"));
|
2001-04-10 05:04:59 +04:00
|
|
|
goto inc_one;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
goto inc_one;
|
2005-01-15 16:10:15 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
else {
|
|
|
|
// some or all of data is outside limits of physical memory
|
|
|
|
|
|
|
|
#ifdef BX_LITTLE_ENDIAN
|
2005-01-15 16:10:15 +03:00
|
|
|
data_ptr = (Bit8u *) data;
|
2001-04-10 05:04:59 +04:00
|
|
|
#else // BX_BIG_ENDIAN
|
2005-01-15 16:10:15 +03:00
|
|
|
data_ptr = (Bit8u *) data + (len - 1);
|
2001-04-10 05:04:59 +04:00
|
|
|
#endif
|
|
|
|
|
2005-01-15 16:10:15 +03:00
|
|
|
for (unsigned i = 0; i < len; i++) {
|
2001-04-10 05:04:59 +04:00
|
|
|
if (a20addr < BX_MEM_THIS len) {
|
2001-05-23 12:02:15 +04:00
|
|
|
vector[a20addr] = *data_ptr;
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_DBG_DIRTY_PAGE(a20addr >> 12);
|
2005-01-15 16:10:15 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
// otherwise ignore byte, since it overruns memory
|
|
|
|
addr++;
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
a20addr = (addr);
|
2001-04-10 05:04:59 +04:00
|
|
|
#ifdef BX_LITTLE_ENDIAN
|
|
|
|
data_ptr++;
|
|
|
|
#else // BX_BIG_ENDIAN
|
|
|
|
data_ptr--;
|
|
|
|
#endif
|
|
|
|
}
|
2005-01-15 16:10:15 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2003-03-03 02:59:12 +03:00
|
|
|
void BX_CPP_AttrRegparmN(3)
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
BX_MEM_C::readPhysicalPage(BX_CPU_C *cpu, Bit32u addr, unsigned len, void *data)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
|
|
|
Bit8u *data_ptr;
|
|
|
|
Bit32u a20addr;
|
|
|
|
|
2004-08-06 19:49:55 +04:00
|
|
|
#if BX_SUPPORT_IODEBUG
|
2003-02-13 18:04:11 +03:00
|
|
|
bx_iodebug_c::mem_read(cpu, addr, len, data);
|
2001-09-15 03:02:56 +04:00
|
|
|
#endif
|
2004-01-15 05:08:37 +03:00
|
|
|
|
2004-07-18 23:40:51 +04:00
|
|
|
a20addr = A20ADDR(addr);
|
2003-02-13 18:04:11 +03:00
|
|
|
BX_INSTR_PHY_READ(cpu->which_cpu(), a20addr, len);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
#if BX_DEBUGGER
|
|
|
|
// (mch) Check for physical read break points, TODO
|
2001-05-23 12:02:15 +04:00
|
|
|
// (bbd) Each breakpoint should have an associated CPU#, TODO
|
2001-04-10 05:04:59 +04:00
|
|
|
for (int i = 0; i < num_read_watchpoints; i++)
|
|
|
|
if (read_watchpoint[i] == a20addr) {
|
2002-04-01 08:43:26 +04:00
|
|
|
BX_CPU(0)->watchpoint = a20addr;
|
2001-05-23 12:02:15 +04:00
|
|
|
BX_CPU(0)->break_point = BREAK_POINT_READ;
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2005-10-01 13:52:35 +04:00
|
|
|
struct memory_handler_struct *memory_handler = memory_handlers[a20addr >> 20];
|
|
|
|
while (memory_handler) {
|
2005-10-13 20:22:21 +04:00
|
|
|
if (memory_handler->begin <= a20addr &&
|
|
|
|
memory_handler->end >= a20addr &&
|
|
|
|
memory_handler->read_handler(a20addr, len, data, memory_handler->read_param))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
memory_handler = memory_handler->next;
|
2005-10-01 13:52:35 +04:00
|
|
|
}
|
|
|
|
|
2005-01-15 16:10:15 +03:00
|
|
|
#if BX_SUPPORT_APIC
|
|
|
|
bx_generic_apic_c *local_apic = &cpu->local_apic;
|
|
|
|
bx_generic_apic_c *ioapic = bx_devices.ioapic;
|
2005-10-13 20:22:21 +04:00
|
|
|
if (local_apic->is_selected (addr, len)) {
|
|
|
|
local_apic->read (addr, data, len);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (ioapic->is_selected (addr, len)) {
|
|
|
|
ioapic->read (addr, data, len);
|
|
|
|
return;
|
|
|
|
}
|
2005-01-15 16:10:15 +03:00
|
|
|
#endif
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
if ( (a20addr + len) <= BX_MEM_THIS len ) {
|
|
|
|
// all of data is within limits of physical memory
|
|
|
|
if ( (a20addr & 0xfff80000) != 0x00080000 ) {
|
|
|
|
if (len == 4) {
|
2002-09-22 22:22:24 +04:00
|
|
|
ReadHostDWordFromLittleEndian(&vector[a20addr], * (Bit32u*) data);
|
|
|
|
return;
|
2005-01-15 16:10:15 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
if (len == 2) {
|
2002-09-22 22:22:24 +04:00
|
|
|
ReadHostWordFromLittleEndian(&vector[a20addr], * (Bit16u*) data);
|
|
|
|
return;
|
2005-01-15 16:10:15 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
if (len == 1) {
|
2005-10-13 20:22:21 +04:00
|
|
|
* (Bit8u *) data = * ((Bit8u *) (&vector[a20addr]));
|
2001-04-10 05:04:59 +04:00
|
|
|
return;
|
|
|
|
}
|
2005-01-15 16:10:15 +03:00
|
|
|
// len == 3 case can just fall thru to special cases handling
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
|
|
|
|
#ifdef BX_LITTLE_ENDIAN
|
|
|
|
data_ptr = (Bit8u *) data;
|
|
|
|
#else // BX_BIG_ENDIAN
|
|
|
|
data_ptr = (Bit8u *) data + (len - 1);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
read_one:
|
|
|
|
if ( (a20addr & 0xfff80000) != 0x00080000 ) {
|
|
|
|
// addr *not* in range 00080000 .. 000FFFFF
|
2001-05-23 12:02:15 +04:00
|
|
|
*data_ptr = vector[a20addr];
|
2001-04-10 05:04:59 +04:00
|
|
|
inc_one:
|
|
|
|
if (len == 1) return;
|
|
|
|
len--;
|
2002-09-22 22:22:24 +04:00
|
|
|
a20addr++;
|
2001-04-10 05:04:59 +04:00
|
|
|
#ifdef BX_LITTLE_ENDIAN
|
|
|
|
data_ptr++;
|
|
|
|
#else // BX_BIG_ENDIAN
|
|
|
|
data_ptr--;
|
|
|
|
#endif
|
|
|
|
goto read_one;
|
2005-01-15 16:10:15 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
// addr in range 00080000 .. 000FFFFF
|
2004-11-11 23:55:29 +03:00
|
|
|
#if BX_SUPPORT_PCI
|
|
|
|
if ( bx_options.Oi440FXSupport->get () &&
|
|
|
|
((a20addr & 0xfffc0000) == 0x000c0000) )
|
|
|
|
{
|
|
|
|
switch (DEV_pci_rd_memtype (a20addr)) {
|
|
|
|
case 0x0: // Read from ROM
|
2005-10-12 21:11:44 +04:00
|
|
|
if ( (a20addr & 0xfffe0000) == 0x000e0000 )
|
|
|
|
{
|
|
|
|
*data_ptr = rom[a20addr & BIOS_MASK];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*data_ptr = rom[(a20addr & EXROM_MASK) + BIOSROMSZ];
|
|
|
|
}
|
2004-11-11 23:55:29 +03:00
|
|
|
goto inc_one;
|
|
|
|
case 0x1: // Read from ShadowRAM
|
|
|
|
*data_ptr = vector[a20addr];
|
|
|
|
goto inc_one;
|
|
|
|
default:
|
|
|
|
BX_PANIC(("readPhysicalPage: default case"));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
goto inc_one;
|
2004-11-11 23:55:29 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif // #if BX_SUPPORT_PCI
|
|
|
|
{
|
2005-10-12 21:11:44 +04:00
|
|
|
if ( (a20addr & 0xfffc0000) != 0x000c0000 ) {
|
|
|
|
*data_ptr = vector[a20addr];
|
|
|
|
}
|
|
|
|
else if ( (a20addr & 0xfffe0000) == 0x000e0000 )
|
|
|
|
{
|
|
|
|
*data_ptr = rom[a20addr & BIOS_MASK];
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
2004-11-11 23:55:29 +03:00
|
|
|
else
|
|
|
|
{
|
2005-10-12 21:11:44 +04:00
|
|
|
*data_ptr = rom[(a20addr & EXROM_MASK) + BIOSROMSZ];
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
2004-11-11 23:55:29 +03:00
|
|
|
goto inc_one;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
2004-11-11 23:55:29 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // some or all of data is outside limits of physical memory
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
#ifdef BX_LITTLE_ENDIAN
|
|
|
|
data_ptr = (Bit8u *) data;
|
|
|
|
#else // BX_BIG_ENDIAN
|
|
|
|
data_ptr = (Bit8u *) data + (len - 1);
|
|
|
|
#endif
|
|
|
|
|
2005-01-15 16:10:15 +03:00
|
|
|
for (unsigned i = 0; i < len; i++) {
|
2001-04-10 05:04:59 +04:00
|
|
|
if (a20addr < BX_MEM_THIS len)
|
2001-05-23 12:02:15 +04:00
|
|
|
*data_ptr = vector[a20addr];
|
2005-10-12 21:11:44 +04:00
|
|
|
else if (a20addr >= (Bit32u)~BIOS_MASK)
|
|
|
|
*data_ptr = rom[a20addr & BIOS_MASK];
|
2001-04-10 05:04:59 +04:00
|
|
|
else
|
|
|
|
*data_ptr = 0xff;
|
|
|
|
addr++;
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
a20addr = (addr);
|
2001-04-10 05:04:59 +04:00
|
|
|
#ifdef BX_LITTLE_ENDIAN
|
|
|
|
data_ptr++;
|
|
|
|
#else // BX_BIG_ENDIAN
|
|
|
|
data_ptr--;
|
|
|
|
#endif
|
|
|
|
}
|
2005-01-15 16:10:15 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // #if BX_PROVIDE_CPU_MEMORY
|