Skip to content

Commit

Permalink
pci: allow 64-bit BAR offsets
Browse files Browse the repository at this point in the history
Signed-off-by: Fotis Xenakis <[email protected]>
Message-Id: <VI1PR03MB4383D028B2BD9554569BFE69A6E10@VI1PR03MB4383.eurprd03.prod.outlook.com>
  • Loading branch information
foxeng authored and wkozaczuk committed Mar 13, 2020
1 parent 7305d0f commit 715a8bd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 29 deletions.
31 changes: 13 additions & 18 deletions drivers/pci-function.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,6 @@ namespace pci {
_addr_lo(0), _addr_hi(0), _addr_64(0), _addr_size(0),
_addr_mmio(mmio_nullptr),
_is_mmio(false), _is_64(false), _is_prefetchable(false)
{
init();
}

bar::~bar()
{

}

void bar::init()
{
u32 val = _dev->pci_readl(_pos);

Expand All @@ -56,6 +46,11 @@ namespace pci {
_addr_64 = ((u64)_addr_hi << 32) | (u64)(_addr_lo);
}

bar::~bar()
{

}

u64 bar::read_bar_size()
{
u32 lo_orig = _dev->pci_readl(_pos);
Expand Down Expand Up @@ -110,7 +105,7 @@ namespace pci {
return _addr_mmio;
}

u64 bar::readq(u32 offset)
u64 bar::readq(u64 offset)
{
if (_is_mmio) {
return mmio_getq(_addr_mmio + offset);
Expand All @@ -119,7 +114,7 @@ namespace pci {
}
}

u32 bar::readl(u32 offset)
u32 bar::readl(u64 offset)
{
if (_is_mmio) {
return mmio_getl(_addr_mmio + offset);
Expand All @@ -128,7 +123,7 @@ namespace pci {
}
}

u16 bar::readw(u32 offset)
u16 bar::readw(u64 offset)
{
if (_is_mmio) {
return mmio_getw(_addr_mmio + offset);
Expand All @@ -137,7 +132,7 @@ namespace pci {
}
}

u8 bar::readb(u32 offset)
u8 bar::readb(u64 offset)
{
if (_is_mmio) {
return mmio_getb(_addr_mmio + offset);
Expand All @@ -146,7 +141,7 @@ namespace pci {
}
}

void bar::writeq(u32 offset, u64 val)
void bar::writeq(u64 offset, u64 val)
{
if (_is_mmio) {
mmio_setq(_addr_mmio + offset, val);
Expand All @@ -155,7 +150,7 @@ namespace pci {
}
}

void bar::writel(u32 offset, u32 val)
void bar::writel(u64 offset, u32 val)
{
if (_is_mmio) {
mmio_setl(_addr_mmio + offset, val);
Expand All @@ -164,7 +159,7 @@ namespace pci {
}
}

void bar::writew(u32 offset, u16 val)
void bar::writew(u64 offset, u16 val)
{
if (_is_mmio) {
mmio_setw(_addr_mmio + offset, val);
Expand All @@ -173,7 +168,7 @@ namespace pci {
}
}

void bar::writeb(u32 offset, u8 val)
void bar::writeb(u64 offset, u8 val)
{
if (_is_mmio) {
mmio_setb(_addr_mmio + offset, val);
Expand Down
19 changes: 8 additions & 11 deletions drivers/pci-function.hh
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,16 @@ namespace pci {
mmioaddr_t get_mmio();

// Access the pio or mmio bar
u64 readq(u32 offset);
u32 readl(u32 offset);
u16 readw(u32 offset);
u8 readb(u32 offset);
void writeq(u32 offset, u64 val);
void writel(u32 offset, u32 val);
void writew(u32 offset, u16 val);
void writeb(u32 offset, u8 val);
u64 readq(u64 offset);
u32 readl(u64 offset);
u16 readw(u64 offset);
u8 readb(u64 offset);
void writeq(u64 offset, u64 val);
void writel(u64 offset, u32 val);
void writew(u64 offset, u16 val);
void writeb(u64 offset, u8 val);

private:

void init();

/* Architecture-specific hook on bar creation, which allows
* rewriting the bar registers. Returns the bar register.
*/
Expand Down

0 comments on commit 715a8bd

Please sign in to comment.