Simplify physical memory access by devices
This commit is contained in:
parent
7f82a536b3
commit
8ea32b4279
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: iodev.h,v 1.92 2008-04-17 14:39:32 sshwarts Exp $
|
||||
// $Id: iodev.h,v 1.93 2008-06-11 20:59:50 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2002 MandrakeSoft S.A.
|
||||
@ -531,6 +531,21 @@ private:
|
||||
|
||||
// memory stub has an assumption that there are no memory accesses splitting 4K page
|
||||
BX_CPP_INLINE void DEV_MEM_READ_PHYSICAL(bx_phy_address phy_addr, unsigned len, Bit8u *ptr)
|
||||
{
|
||||
unsigned remainingInPage = 0x1000 - (phy_addr & 0xfff);
|
||||
if (len < remainingInPage) {
|
||||
BX_MEM(0)->readPhysicalPage(NULL, phy_addr, len, ptr);
|
||||
}
|
||||
else {
|
||||
BX_MEM(0)->readPhysicalPage(NULL, phy_addr, remainingInPage, ptr);
|
||||
ptr += remainingInPage;
|
||||
phy_addr += remainingInPage;
|
||||
len -= remainingInPage;
|
||||
BX_MEM(0)->readPhysicalPage(NULL, phy_addr, len, ptr);
|
||||
}
|
||||
}
|
||||
|
||||
BX_CPP_INLINE void DEV_MEM_READ_PHYSICAL_BLOCK(bx_phy_address phy_addr, unsigned len, Bit8u *ptr)
|
||||
{
|
||||
while(len > 0) {
|
||||
unsigned remainingInPage = 0x1000 - (phy_addr & 0xfff);
|
||||
@ -544,6 +559,21 @@ BX_CPP_INLINE void DEV_MEM_READ_PHYSICAL(bx_phy_address phy_addr, unsigned len,
|
||||
|
||||
// memory stub has an assumption that there are no memory accesses splitting 4K page
|
||||
BX_CPP_INLINE void DEV_MEM_WRITE_PHYSICAL(bx_phy_address phy_addr, unsigned len, Bit8u *ptr)
|
||||
{
|
||||
unsigned remainingInPage = 0x1000 - (phy_addr & 0xfff);
|
||||
if (len < remainingInPage) {
|
||||
BX_MEM(0)->writePhysicalPage(NULL, phy_addr, len, ptr);
|
||||
}
|
||||
else {
|
||||
BX_MEM(0)->writePhysicalPage(NULL, phy_addr, remainingInPage, ptr);
|
||||
ptr += remainingInPage;
|
||||
phy_addr += remainingInPage;
|
||||
len -= remainingInPage;
|
||||
BX_MEM(0)->writePhysicalPage(NULL, phy_addr, len, ptr);
|
||||
}
|
||||
}
|
||||
|
||||
BX_CPP_INLINE void DEV_MEM_WRITE_PHYSICAL_BLOCK(bx_phy_address phy_addr, unsigned len, Bit8u *ptr)
|
||||
{
|
||||
while(len > 0) {
|
||||
unsigned remainingInPage = 0x1000 - (phy_addr & 0xfff);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: pci_ide.cc,v 1.32 2008-05-01 20:08:37 sshwarts Exp $
|
||||
// $Id: pci_ide.cc,v 1.33 2008-06-11 20:59:50 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2002 MandrakeSoft S.A.
|
||||
@ -239,7 +239,7 @@ void bx_pci_ide_c::timer()
|
||||
Bit8u channel;
|
||||
Bit32u size, sector_size = 0;
|
||||
struct {
|
||||
bx_phy_address addr;
|
||||
Bit32u addr;
|
||||
Bit32u size;
|
||||
} prd;
|
||||
|
||||
@ -274,12 +274,12 @@ void bx_pci_ide_c::timer()
|
||||
BX_PIDE_THIS s.bmdma[channel].status |= 0x06;
|
||||
return;
|
||||
} else {
|
||||
DEV_MEM_WRITE_PHYSICAL(prd.addr, size, BX_PIDE_THIS s.bmdma[channel].buffer_idx);
|
||||
DEV_MEM_WRITE_PHYSICAL_BLOCK(prd.addr, size, BX_PIDE_THIS s.bmdma[channel].buffer_idx);
|
||||
BX_PIDE_THIS s.bmdma[channel].buffer_idx += size;
|
||||
}
|
||||
} else {
|
||||
BX_DEBUG(("WRITE DMA from addr=0x%08x, size=0x%08x", prd.addr, size));
|
||||
DEV_MEM_READ_PHYSICAL(prd.addr, size, BX_PIDE_THIS s.bmdma[channel].buffer_top);
|
||||
DEV_MEM_READ_PHYSICAL_BLOCK(prd.addr, size, BX_PIDE_THIS s.bmdma[channel].buffer_top);
|
||||
BX_PIDE_THIS s.bmdma[channel].buffer_top += size;
|
||||
count = BX_PIDE_THIS s.bmdma[channel].buffer_top - BX_PIDE_THIS s.bmdma[channel].buffer_idx;
|
||||
while (count > 511) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: pciusb.cc,v 1.63 2008-04-17 14:39:32 sshwarts Exp $
|
||||
// $Id: pciusb.cc,v 1.64 2008-06-11 20:59:50 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2004 MandrakeSoft S.A.
|
||||
@ -931,7 +931,7 @@ bx_bool bx_pciusb_c::DoTransfer(Bit32u address, Bit32u queue_num, struct TD *td)
|
||||
case USB_TOKEN_OUT:
|
||||
case USB_TOKEN_SETUP:
|
||||
if (maxlen > 0) {
|
||||
DEV_MEM_READ_PHYSICAL(td->dword3, maxlen, device_buffer);
|
||||
DEV_MEM_READ_PHYSICAL_BLOCK(td->dword3, maxlen, device_buffer);
|
||||
}
|
||||
ret = dev->handle_packet(&BX_USB_THIS usb_packet);
|
||||
len = maxlen;
|
||||
@ -945,7 +945,7 @@ bx_bool bx_pciusb_c::DoTransfer(Bit32u address, Bit32u queue_num, struct TD *td)
|
||||
ret = USB_RET_BABBLE;
|
||||
}
|
||||
if (len > 0) {
|
||||
DEV_MEM_WRITE_PHYSICAL(td->dword3, len, device_buffer);
|
||||
DEV_MEM_WRITE_PHYSICAL_BLOCK(td->dword3, len, device_buffer);
|
||||
}
|
||||
} else {
|
||||
len = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user