move a20 handling into getHostAddr method of BX_MEM

This commit is contained in:
Stanislav Shwartsman 2009-03-08 21:23:40 +00:00
parent 55d20d99ee
commit 6fe0b40b44
6 changed files with 32 additions and 36 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: cpu.cc,v 1.271 2009-02-20 17:05:03 sshwarts Exp $
// $Id: cpu.cc,v 1.272 2009-03-08 21:23:35 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -142,7 +142,7 @@ no_async_event:
}
#if BX_SUPPORT_ICACHE
bx_phy_address pAddr = BX_CPU_THIS_PTR pAddrA20Page + eipBiased;
bx_phy_address pAddr = BX_CPU_THIS_PTR pAddrPage + eipBiased;
bxICacheEntry_c *entry = BX_CPU_THIS_PTR iCache.get_entry(pAddr);
bxInstruction_c *i = entry->i;
@ -732,21 +732,20 @@ void BX_CPU_C::prefetch(void)
Bit8u *fetchPtr = 0;
if ((tlbEntry->lpf == lpf) && !(tlbEntry->accessBits & USER_PL)) {
BX_CPU_THIS_PTR pAddrA20Page = A20ADDR(tlbEntry->ppf);
fetchPtr = (Bit8u*) (tlbEntry->hostPageAddr);
BX_CPU_THIS_PTR pAddrPage = tlbEntry->ppf;
fetchPtr = (Bit8u*) tlbEntry->hostPageAddr;
}
else {
bx_phy_address pAddr;
if (BX_CPU_THIS_PTR cr0.get_PG()) {
pAddr = translate_linear(laddr, CPL, BX_EXECUTE);
pAddr = A20ADDR(pAddr);
}
else {
pAddr = A20ADDR(laddr);
pAddr = laddr;
}
BX_CPU_THIS_PTR pAddrA20Page = LPFOf(pAddr);
BX_CPU_THIS_PTR pAddrPage = LPFOf(pAddr);
}
if (fetchPtr) {
@ -754,12 +753,12 @@ void BX_CPU_C::prefetch(void)
}
else {
BX_CPU_THIS_PTR eipFetchPtr = BX_MEM(0)->getHostMemAddr(BX_CPU_THIS,
BX_CPU_THIS_PTR pAddrA20Page, BX_EXECUTE);
BX_CPU_THIS_PTR pAddrPage, BX_EXECUTE);
}
// Sanity checks
if (! BX_CPU_THIS_PTR eipFetchPtr) {
bx_phy_address pAddr = BX_CPU_THIS_PTR pAddrA20Page + pageOffset;
bx_phy_address pAddr = BX_CPU_THIS_PTR pAddrPage + pageOffset;
if (pAddr >= BX_MEM(0)->get_memory_len()) {
BX_PANIC(("prefetch: running in bogus memory, pAddr=0x" FMT_PHY_ADDRX, pAddr));
}
@ -769,11 +768,11 @@ void BX_CPU_C::prefetch(void)
}
#if BX_SUPPORT_ICACHE
BX_CPU_THIS_PTR currPageWriteStampPtr = pageWriteStampTable.getPageWriteStampPtr(BX_CPU_THIS_PTR pAddrA20Page);
BX_CPU_THIS_PTR currPageWriteStampPtr = pageWriteStampTable.getPageWriteStampPtr(BX_CPU_THIS_PTR pAddrPage);
Bit32u pageWriteStamp = *(BX_CPU_THIS_PTR currPageWriteStampPtr);
pageWriteStamp &= ~ICacheWriteStampFetchModeMask; // Clear out old fetch mode bits
pageWriteStamp |= BX_CPU_THIS_PTR fetchModeMask; // And add new ones
pageWriteStampTable.setPageWriteStamp(BX_CPU_THIS_PTR pAddrA20Page, pageWriteStamp);
pageWriteStampTable.setPageWriteStamp(BX_CPU_THIS_PTR pAddrPage, pageWriteStamp);
#endif
}

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: cpu.h,v 1.579 2009-02-28 09:28:18 sshwarts Exp $
// $Id: cpu.h,v 1.580 2009-03-08 21:23:36 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -939,8 +939,8 @@ public: // for now...
bx_address eipPageBias;
Bit32u eipPageWindowSize;
const Bit8u *eipFetchPtr;
bx_phy_address pAddrA20Page; // Guest physical address of current instruction
// page with A20() already applied.
bx_phy_address pAddrPage; // Guest physical address of current instruction page
#if BX_CPU_LEVEL >= 4 && BX_SUPPORT_ALIGNMENT_CHECK
unsigned alignment_check_mask;
#endif
@ -3873,10 +3873,10 @@ enum {
#define BxOSizeGrp 0x0070 // Group encoding: 0111
#define BxLockable 0x0100 // bit 8
#define BxArithDstRM 0x0200 // bit 8
#define BxArithDstRM 0x0200 // bit 9
#if BX_SUPPORT_TRACE_CACHE
#define BxTraceEnd 0x0400 // bit 9
#define BxTraceEnd 0x0400 // bit 10
#else
#define BxTraceEnd 0
#endif

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: paging.cc,v 1.171 2009-02-23 17:09:39 sshwarts Exp $
// $Id: paging.cc,v 1.172 2009-03-08 21:23:37 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -1236,8 +1236,7 @@ bx_phy_address BX_CPU_C::translate_linear(bx_address laddr, unsigned curr_pl, un
// Attempt to get a host pointer to this physical page. Put that
// pointer in the TLB cache. Note if the request is vetoed, NULL
// will be returned, and it's OK to OR zero in anyways.
tlbEntry->hostPageAddr = (bx_hostpageaddr_t) BX_MEM(0)->getHostMemAddr(BX_CPU_THIS,
A20ADDR(ppf), rw);
tlbEntry->hostPageAddr = (bx_hostpageaddr_t) BX_MEM(0)->getHostMemAddr(BX_CPU_THIS, ppf, rw);
if (tlbEntry->hostPageAddr) {
// All access allowed also via direct pointer
@ -1423,7 +1422,7 @@ void BX_CPU_C::access_write_linear(bx_address laddr, unsigned len, unsigned curr
// Request a direct write pointer so we can do either R or W.
bx_hostpageaddr_t hostPageAddr = (bx_hostpageaddr_t)
BX_MEM(0)->getHostMemAddr(BX_CPU_THIS, A20ADDR(lpf), BX_WRITE);
BX_MEM(0)->getHostMemAddr(BX_CPU_THIS, lpf, BX_WRITE);
if (hostPageAddr) {
tlbEntry->lpf = lpf; // Got direct write pointer OK
@ -1586,7 +1585,7 @@ void BX_CPU_C::access_read_linear(bx_address laddr, unsigned len, unsigned curr_
// Request a direct write pointer so we can do either R or W.
bx_hostpageaddr_t hostPageAddr = (bx_hostpageaddr_t)
BX_MEM(0)->getHostMemAddr(BX_CPU_THIS, A20ADDR(lpf), BX_READ);
BX_MEM(0)->getHostMemAddr(BX_CPU_THIS, lpf, BX_READ);
if (hostPageAddr) {
tlbEntry->lpf = lpf; // Got direct read pointer OK.
@ -1656,10 +1655,8 @@ void BX_CPU_C::access_read_linear(bx_address laddr, unsigned len, unsigned curr_
void BX_CPU_C::access_write_physical(bx_phy_address paddr, unsigned len, void *data)
{
#if BX_SUPPORT_APIC
bx_phy_address a20addr = A20ADDR(paddr);
if (BX_CPU_THIS_PTR lapic.is_selected(a20addr)) {
BX_CPU_THIS_PTR lapic.write(a20addr, data, len);
if (BX_CPU_THIS_PTR lapic.is_selected(paddr)) {
BX_CPU_THIS_PTR lapic.write(paddr, data, len);
return;
}
#endif
@ -1670,10 +1667,8 @@ void BX_CPU_C::access_write_physical(bx_phy_address paddr, unsigned len, void *d
void BX_CPU_C::access_read_physical(bx_phy_address paddr, unsigned len, void *data)
{
#if BX_SUPPORT_APIC
bx_phy_address a20addr = A20ADDR(paddr);
if (BX_CPU_THIS_PTR lapic.is_selected(a20addr)) {
BX_CPU_THIS_PTR lapic.read(a20addr, data, len);
if (BX_CPU_THIS_PTR lapic.is_selected(paddr)) {
BX_CPU_THIS_PTR lapic.read(paddr, data, len);
return;
}
#endif

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: memory.h,v 1.55 2009-02-08 09:05:52 vruppert Exp $
// $Id: memory.h,v 1.56 2009-03-08 21:23:39 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -111,7 +111,7 @@ public:
BX_MEM_SMF bx_bool dbg_set_mem(bx_phy_address addr, unsigned len, Bit8u *buf);
BX_MEM_SMF bx_bool dbg_crc32(bx_phy_address addr1, bx_phy_address addr2, Bit32u *crc);
#endif
BX_MEM_SMF Bit8u* getHostMemAddr(BX_CPU_C *cpu, bx_phy_address a20Addr, unsigned rw);
BX_MEM_SMF Bit8u* getHostMemAddr(BX_CPU_C *cpu, bx_phy_address addr, unsigned rw);
BX_MEM_SMF bx_bool registerMemoryHandlers(void *param, memory_handler_t read_handler,
memory_handler_t write_handler, bx_phy_address begin_addr, bx_phy_address end_addr);
BX_MEM_SMF bx_bool unregisterMemoryHandlers(memory_handler_t read_handler, memory_handler_t write_handler,

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: misc_mem.cc,v 1.125 2009-02-18 22:25:04 sshwarts Exp $
// $Id: misc_mem.cc,v 1.126 2009-03-08 21:23:39 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -75,7 +75,7 @@ void BX_MEM_C::init_memory(Bit32u memsize)
{
unsigned idx;
BX_DEBUG(("Init $Id: misc_mem.cc,v 1.125 2009-02-18 22:25:04 sshwarts Exp $"));
BX_DEBUG(("Init $Id: misc_mem.cc,v 1.126 2009-03-08 21:23:39 sshwarts Exp $"));
if (BX_MEM_THIS actual_vector != NULL) {
BX_INFO (("freeing existing memory vector"));
@ -510,8 +510,10 @@ bx_bool BX_MEM_C::dbg_crc32(bx_phy_address addr1, bx_phy_address addr2, Bit32u *
// 0xf0000 - 0xfffff Upper BIOS Area (64K)
//
Bit8u *BX_MEM_C::getHostMemAddr(BX_CPU_C *cpu, bx_phy_address a20Addr, unsigned rw)
Bit8u *BX_MEM_C::getHostMemAddr(BX_CPU_C *cpu, bx_phy_address addr, unsigned rw)
{
bx_phy_address a20Addr = A20ADDR(addr);
#if BX_SUPPORT_APIC
if (cpu != NULL) {
if (cpu->lapic.is_selected(a20Addr))

View File

@ -48,8 +48,8 @@ diff -u -r1.136 bochs.h
#define BX_RW 2
+#define BX_MEM_GET_HOST_MEM_ADDR_READ(addr) BX_MEM(0)->getHostMemAddr(BX_CPU(0),A20ADDR(addr), BX_READ)
+#define BX_MEM_GET_HOST_MEM_ADDR_WRITE(addr) BX_MEM(0)->getHostMemAddr(BX_CPU(0),A20ADDR(addr), BX_WRITE)
+#define BX_MEM_GET_HOST_MEM_ADDR_READ(addr) BX_MEM(0)->getHostMemAddr(NULL, addr, BX_READ)
+#define BX_MEM_GET_HOST_MEM_ADDR_WRITE(addr) BX_MEM(0)->getHostMemAddr(NULL, addr, BX_WRITE)