Use access_type param in getHostMemAddr, less efficient but no copy-paste at least
This commit is contained in:
parent
5c3fba4399
commit
b8be848943
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: cpu.cc,v 1.140 2006-03-26 18:58:00 sshwarts Exp $
|
||||
// $Id: cpu.cc,v 1.141 2006-03-26 19:39:37 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -771,7 +771,8 @@ void BX_CPU_C::prefetch(void)
|
||||
BX_CPU_THIS_PTR eipPageWindowSize = 4096;
|
||||
BX_CPU_THIS_PTR pAddrA20Page = pAddr & 0xfffff000;
|
||||
BX_CPU_THIS_PTR eipFetchPtr =
|
||||
BX_CPU_THIS_PTR mem->getHostMemAddrCode(BX_CPU_THIS, BX_CPU_THIS_PTR pAddrA20Page);
|
||||
BX_CPU_THIS_PTR mem->getHostMemAddr(BX_CPU_THIS,
|
||||
BX_CPU_THIS_PTR pAddrA20Page, BX_READ, CODE_ACCESS);
|
||||
|
||||
// Sanity checks
|
||||
if (! BX_CPU_THIS_PTR eipFetchPtr) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: io.cc,v 1.29 2006-03-06 22:02:59 sshwarts Exp $
|
||||
// $Id: io.cc,v 1.30 2006-03-26 19:39:37 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -190,7 +190,7 @@ void BX_CPU_C::INSW_YvDX(bxInstruction_c *i)
|
||||
paddrDst = A20ADDR(paddrDst);
|
||||
|
||||
hostAddrDst = BX_CPU_THIS_PTR mem->getHostMemAddr(BX_CPU_THIS,
|
||||
paddrDst, BX_WRITE);
|
||||
paddrDst, BX_WRITE, DATA_ACCESS);
|
||||
|
||||
// Check that native host access was not vetoed for that page, and
|
||||
// that the address is word aligned.
|
||||
@ -494,7 +494,7 @@ void BX_CPU_C::OUTSW_DXXv(bxInstruction_c *i)
|
||||
paddrSrc = A20ADDR(paddrSrc);
|
||||
|
||||
hostAddrSrc = BX_CPU_THIS_PTR mem->getHostMemAddr(BX_CPU_THIS,
|
||||
paddrSrc, BX_READ);
|
||||
paddrSrc, BX_READ, DATA_ACCESS);
|
||||
|
||||
// Check that native host access was not vetoed for that page, and
|
||||
// that the address is word aligned.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: paging.cc,v 1.68 2006-03-22 20:47:11 sshwarts Exp $
|
||||
// $Id: paging.cc,v 1.69 2006-03-26 19:39:37 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -1005,7 +1005,8 @@ BX_CPU_C::translate_linear(bx_address laddr, unsigned pl, unsigned rw, unsigned
|
||||
// pointer in the TLB cache. Note if the request is vetoed, NULL
|
||||
// will be returned, and it's OK to OR zero in anyways.
|
||||
BX_CPU_THIS_PTR TLB.entry[TLB_index].hostPageAddr =
|
||||
(bx_hostpageaddr_t) BX_CPU_THIS_PTR mem->getHostMemAddr(BX_CPU_THIS, A20ADDR(ppf), rw);
|
||||
(bx_hostpageaddr_t) BX_CPU_THIS_PTR mem->getHostMemAddr(BX_CPU_THIS,
|
||||
A20ADDR(ppf), rw, access_type);
|
||||
|
||||
if (BX_CPU_THIS_PTR TLB.entry[TLB_index].hostPageAddr) {
|
||||
// All access allowed also via direct pointer
|
||||
@ -1199,9 +1200,7 @@ BX_CPU_C::access_linear(bx_address laddr, unsigned length, unsigned pl,
|
||||
return;
|
||||
}
|
||||
else {
|
||||
// access across 2 pages, no need to check for Local APIC here,
|
||||
// correct Local APIC access always 16-byte aligned and
|
||||
// maximum 4-byte length so it cannot page split.
|
||||
// access across 2 pages
|
||||
BX_CPU_THIS_PTR address_xlation.paddress1 =
|
||||
dtranslate_linear(laddr, pl, xlate_rw);
|
||||
BX_CPU_THIS_PTR address_xlation.len1 = 4096 - pageOffset;
|
||||
@ -1294,12 +1293,12 @@ BX_CPU_C::access_linear(bx_address laddr, unsigned length, unsigned pl,
|
||||
tlbEntry->ppf = lpf;
|
||||
// Request a direct write pointer so we can do either R or W.
|
||||
tlbEntry->hostPageAddr = (bx_hostpageaddr_t)
|
||||
BX_CPU_THIS_PTR mem->getHostMemAddr(BX_CPU_THIS, A20ADDR(lpf), BX_WRITE);
|
||||
BX_CPU_THIS_PTR mem->getHostMemAddr(BX_CPU_THIS, A20ADDR(lpf), BX_WRITE, DATA_ACCESS);
|
||||
|
||||
if (! tlbEntry->hostPageAddr) {
|
||||
// Direct write vetoed. Try requesting only direct reads.
|
||||
tlbEntry->hostPageAddr = (bx_hostpageaddr_t)
|
||||
BX_CPU_THIS_PTR mem->getHostMemAddr(BX_CPU_THIS, A20ADDR(lpf), BX_READ);
|
||||
BX_CPU_THIS_PTR mem->getHostMemAddr(BX_CPU_THIS, A20ADDR(lpf), BX_READ, DATA_ACCESS);
|
||||
if (tlbEntry->hostPageAddr) {
|
||||
// Got direct read pointer OK.
|
||||
tlbEntry->accessBits =
|
||||
@ -1336,7 +1335,7 @@ BX_CPU_C::access_linear(bx_address laddr, unsigned length, unsigned pl,
|
||||
// TLB.entry[tlbIndex].ppf field not used for PG==0.
|
||||
// Request a direct write pointer so we can do either R or W.
|
||||
tlbEntry->hostPageAddr = (bx_hostpageaddr_t)
|
||||
BX_CPU_THIS_PTR mem->getHostMemAddr(BX_CPU_THIS, A20ADDR(lpf), BX_WRITE);
|
||||
BX_CPU_THIS_PTR mem->getHostMemAddr(BX_CPU_THIS, A20ADDR(lpf), BX_WRITE, DATA_ACCESS);
|
||||
|
||||
if (tlbEntry->hostPageAddr) {
|
||||
// Got direct write pointer OK. Mark for any operation to succeed.
|
||||
@ -1351,9 +1350,7 @@ BX_CPU_C::access_linear(bx_address laddr, unsigned length, unsigned pl,
|
||||
}
|
||||
}
|
||||
else {
|
||||
// access across 2 pages, no need to check for Local APIC here,
|
||||
// correct Local APIC access always 16-byte aligned and
|
||||
// maximum 4-byte length so it cannot page split.
|
||||
// Access spans two pages.
|
||||
BX_CPU_THIS_PTR address_xlation.paddress1 = laddr;
|
||||
BX_CPU_THIS_PTR address_xlation.len1 = 4096 - pageOffset;
|
||||
BX_CPU_THIS_PTR address_xlation.len2 = length -
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: string.cc,v 1.32 2006-03-06 22:03:04 sshwarts Exp $
|
||||
// $Id: string.cc,v 1.33 2006-03-26 19:39:37 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -68,7 +68,7 @@ Bit32u BX_CPU_C::FastRepMOVSB(bxInstruction_c *i, unsigned srcSeg, bx_address sr
|
||||
// we need the A20 address.
|
||||
paddrSrc = A20ADDR(paddrSrc);
|
||||
Bit8u *hostAddrSrc = BX_CPU_THIS_PTR mem->getHostMemAddr(BX_CPU_THIS,
|
||||
paddrSrc, BX_READ);
|
||||
paddrSrc, BX_READ, DATA_ACCESS);
|
||||
|
||||
if (! hostAddrSrc) return 0;
|
||||
|
||||
@ -85,7 +85,7 @@ Bit32u BX_CPU_C::FastRepMOVSB(bxInstruction_c *i, unsigned srcSeg, bx_address sr
|
||||
// we need the A20 address.
|
||||
paddrDst = A20ADDR(paddrDst);
|
||||
Bit8u *hostAddrDst = BX_CPU_THIS_PTR mem->getHostMemAddr(BX_CPU_THIS,
|
||||
paddrDst, BX_WRITE);
|
||||
paddrDst, BX_WRITE, DATA_ACCESS);
|
||||
|
||||
if (! hostAddrDst) return 0;
|
||||
|
||||
@ -202,7 +202,7 @@ Bit32u BX_CPU_C::FastRepMOVSW(bxInstruction_c *i, unsigned srcSeg, bx_address sr
|
||||
// we need the A20 address.
|
||||
paddrSrc = A20ADDR(paddrSrc);
|
||||
Bit8u *hostAddrSrc = BX_CPU_THIS_PTR mem->getHostMemAddr(BX_CPU_THIS,
|
||||
paddrSrc, BX_READ);
|
||||
paddrSrc, BX_READ, DATA_ACCESS);
|
||||
|
||||
if (! hostAddrSrc) return 0;
|
||||
|
||||
@ -219,7 +219,7 @@ Bit32u BX_CPU_C::FastRepMOVSW(bxInstruction_c *i, unsigned srcSeg, bx_address sr
|
||||
// we need the A20 address.
|
||||
paddrDst = A20ADDR(paddrDst);
|
||||
Bit8u *hostAddrDst = BX_CPU_THIS_PTR mem->getHostMemAddr(BX_CPU_THIS,
|
||||
paddrDst, BX_WRITE);
|
||||
paddrDst, BX_WRITE, DATA_ACCESS);
|
||||
|
||||
if (! hostAddrDst) return 0;
|
||||
|
||||
@ -340,7 +340,7 @@ Bit32u BX_CPU_C::FastRepMOVSD(bxInstruction_c *i, unsigned srcSeg, bx_address sr
|
||||
// we need the A20 address.
|
||||
paddrSrc = A20ADDR(paddrSrc);
|
||||
Bit8u *hostAddrSrc = BX_CPU_THIS_PTR mem->getHostMemAddr(BX_CPU_THIS,
|
||||
paddrSrc, BX_READ);
|
||||
paddrSrc, BX_READ, DATA_ACCESS);
|
||||
|
||||
if (! hostAddrSrc) return 0;
|
||||
|
||||
@ -357,7 +357,7 @@ Bit32u BX_CPU_C::FastRepMOVSD(bxInstruction_c *i, unsigned srcSeg, bx_address sr
|
||||
// we need the A20 address.
|
||||
paddrDst = A20ADDR(paddrDst);
|
||||
Bit8u *hostAddrDst = BX_CPU_THIS_PTR mem->getHostMemAddr(BX_CPU_THIS,
|
||||
paddrDst, BX_WRITE);
|
||||
paddrDst, BX_WRITE, DATA_ACCESS);
|
||||
|
||||
if (! hostAddrDst) return 0;
|
||||
|
||||
@ -472,7 +472,7 @@ Bit32u BX_CPU_C::FastRepSTOSB(bxInstruction_c *i, unsigned dstSeg, bx_address ds
|
||||
// we need the A20 address.
|
||||
paddrDst = A20ADDR(paddrDst);
|
||||
Bit8u *hostAddrDst = BX_CPU_THIS_PTR mem->getHostMemAddr(BX_CPU_THIS,
|
||||
paddrDst, BX_WRITE);
|
||||
paddrDst, BX_WRITE, DATA_ACCESS);
|
||||
|
||||
if (! hostAddrDst) return 0;
|
||||
|
||||
@ -566,7 +566,7 @@ Bit32u BX_CPU_C::FastRepSTOSW(bxInstruction_c *i, unsigned dstSeg, bx_address ds
|
||||
// we need the A20 address.
|
||||
paddrDst = A20ADDR(paddrDst);
|
||||
Bit8u *hostAddrDst = BX_CPU_THIS_PTR mem->getHostMemAddr(BX_CPU_THIS,
|
||||
paddrDst, BX_WRITE);
|
||||
paddrDst, BX_WRITE, DATA_ACCESS);
|
||||
|
||||
if (! hostAddrDst) return 0;
|
||||
|
||||
@ -663,7 +663,7 @@ Bit32u BX_CPU_C::FastRepSTOSD(bxInstruction_c *i, unsigned dstSeg, bx_address ds
|
||||
// we need the A20 address.
|
||||
paddrDst = A20ADDR(paddrDst);
|
||||
Bit8u *hostAddrDst = BX_CPU_THIS_PTR mem->getHostMemAddr(BX_CPU_THIS,
|
||||
paddrDst, BX_WRITE);
|
||||
paddrDst, BX_WRITE, DATA_ACCESS);
|
||||
|
||||
if (! hostAddrDst) return 0;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: memory.h,v 1.33 2006-03-26 18:58:01 sshwarts Exp $
|
||||
// $Id: memory.h,v 1.34 2006-03-26 19:39:37 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -100,8 +100,7 @@ public:
|
||||
BX_MEM_SMF bx_bool dbg_fetch_mem(Bit32u addr, unsigned len, Bit8u *buf);
|
||||
BX_MEM_SMF bx_bool dbg_set_mem(Bit32u addr, unsigned len, Bit8u *buf);
|
||||
BX_MEM_SMF bx_bool dbg_crc32(Bit32u addr1, Bit32u addr2, Bit32u *crc);
|
||||
BX_MEM_SMF Bit8u* getHostMemAddr(BX_CPU_C *cpu, Bit32u a20Addr, unsigned op) BX_CPP_AttrRegparmN(3);
|
||||
BX_MEM_SMF Bit8u* getHostMemAddrCode(BX_CPU_C *cpu, Bit32u a20Addr) BX_CPP_AttrRegparmN(2);;
|
||||
BX_MEM_SMF Bit8u* getHostMemAddr(BX_CPU_C *cpu, Bit32u a20Addr, unsigned op, unsigned access_type);
|
||||
BX_MEM_SMF bx_bool registerMemoryHandlers(void *param, memory_handler_t read_handler,
|
||||
memory_handler_t write_handler, Bit32u begin_addr, Bit32u end_addr);
|
||||
BX_MEM_SMF bx_bool unregisterMemoryHandlers(memory_handler_t read_handler, memory_handler_t write_handler,
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: misc_mem.cc,v 1.82 2006-03-26 18:58:01 sshwarts Exp $
|
||||
// $Id: misc_mem.cc,v 1.83 2006-03-26 19:39:37 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2002 MandrakeSoft S.A.
|
||||
@ -94,7 +94,7 @@ void BX_MEM_C::init_memory(int memsize)
|
||||
{
|
||||
int idx;
|
||||
|
||||
BX_DEBUG(("Init $Id: misc_mem.cc,v 1.82 2006-03-26 18:58:01 sshwarts Exp $"));
|
||||
BX_DEBUG(("Init $Id: misc_mem.cc,v 1.83 2006-03-26 19:39:37 sshwarts Exp $"));
|
||||
// you can pass 0 if memory has been allocated already through
|
||||
// the constructor, or the desired size of memory if it hasn't
|
||||
|
||||
@ -570,83 +570,7 @@ bx_bool BX_MEM_C::dbg_crc32(Bit32u addr1, Bit32u addr2, Bit32u *crc)
|
||||
// 0xf0000 - 0xfffff Upper BIOS Area (64K)
|
||||
//
|
||||
|
||||
Bit8u * BX_CPP_AttrRegparmN(2)
|
||||
BX_MEM_C::getHostMemAddrCode(BX_CPU_C *cpu, Bit32u a20Addr)
|
||||
{
|
||||
BX_ASSERT(cpu != 0); // getHostMemAddrCode could be used only inside the CPU
|
||||
|
||||
#if BX_SUPPORT_APIC
|
||||
bx_generic_apic_c *local_apic = &cpu->local_apic;
|
||||
if (local_apic->get_base() == (a20Addr & ~0xfff))
|
||||
return(NULL); // Vetoed! APIC address space
|
||||
#endif
|
||||
|
||||
// reading from SMMRAM memory space
|
||||
if ((a20Addr & 0xfffe0000) == 0x000a0000) {
|
||||
if (BX_MEM_THIS smram_enabled || cpu->smm_mode())
|
||||
return (Bit8u *) & vector[a20Addr];
|
||||
}
|
||||
|
||||
struct memory_handler_struct *memory_handler = memory_handlers[a20Addr >> 20];
|
||||
while (memory_handler) {
|
||||
if (memory_handler->begin <= a20Addr &&
|
||||
memory_handler->end >= a20Addr) {
|
||||
return(NULL); // Vetoed! memory handler for i/o apic, vram, mmio and PCI PnP
|
||||
}
|
||||
memory_handler = memory_handler->next;
|
||||
}
|
||||
|
||||
if ((a20Addr & 0xfffe0000) == 0x000a0000)
|
||||
return(NULL); // Vetoed! Mem mapped IO (VGA)
|
||||
#if BX_SUPPORT_PCI
|
||||
else if (pci_enabled && ((a20Addr & 0xfffc0000) == 0x000c0000))
|
||||
{
|
||||
switch (DEV_pci_rd_memtype (a20Addr)) {
|
||||
case 0x0: // Read from ROM
|
||||
if ((a20Addr & 0xfffe0000) == 0x000e0000)
|
||||
{
|
||||
return (Bit8u *) & rom[a20Addr & BIOS_MASK];
|
||||
}
|
||||
else
|
||||
{
|
||||
return (Bit8u *) & rom[(a20Addr & EXROM_MASK) + BIOSROMSZ];
|
||||
}
|
||||
break;
|
||||
case 0x1: // Read from ShadowRAM
|
||||
return (Bit8u *) & vector[a20Addr];
|
||||
default:
|
||||
BX_PANIC(("getHostMemAddr(): default case"));
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
else if(a20Addr < BX_MEM_THIS len)
|
||||
{
|
||||
if ((a20Addr & 0xfffc0000) != 0x000c0000) {
|
||||
return (Bit8u *) & vector[a20Addr];
|
||||
}
|
||||
else if ((a20Addr & 0xfffe0000) == 0x000e0000)
|
||||
{
|
||||
return (Bit8u *) & rom[a20Addr & BIOS_MASK];
|
||||
}
|
||||
else
|
||||
{
|
||||
return (Bit8u *) & rom[(a20Addr & EXROM_MASK) + BIOSROMSZ];
|
||||
}
|
||||
}
|
||||
else if (a20Addr >= (Bit32u)~BIOS_MASK)
|
||||
{
|
||||
return (Bit8u *) & rom[a20Addr & BIOS_MASK];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Error, requested addr is out of bounds.
|
||||
return (Bit8u *) & bogus[a20Addr & 0x0fff];
|
||||
}
|
||||
}
|
||||
|
||||
Bit8u * BX_CPP_AttrRegparmN(3)
|
||||
BX_MEM_C::getHostMemAddr(BX_CPU_C *cpu, Bit32u a20Addr, unsigned op)
|
||||
Bit8u *BX_MEM_C::getHostMemAddr(BX_CPU_C *cpu, Bit32u a20Addr, unsigned op, unsigned access_type)
|
||||
{
|
||||
BX_ASSERT(cpu != 0); // getHostMemAddr could be used only inside the CPU
|
||||
|
||||
@ -656,10 +580,11 @@ BX_MEM_C::getHostMemAddr(BX_CPU_C *cpu, Bit32u a20Addr, unsigned op)
|
||||
return(NULL); // Vetoed! APIC address space
|
||||
#endif
|
||||
|
||||
if (op == BX_READ) {
|
||||
// allow direct access to SMMRAM memory space for code and veto data
|
||||
if (access_type == CODE_ACCESS) {
|
||||
// reading from SMMRAM memory space
|
||||
if ((a20Addr & 0xfffe0000) == 0x000a0000) {
|
||||
if (BX_MEM_THIS smram_enabled > 1 || cpu->smm_mode())
|
||||
if (BX_MEM_THIS smram_enabled || cpu->smm_mode())
|
||||
return (Bit8u *) & vector[a20Addr];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user