summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Barbieri <luca@luca-barbieri.com>2010-03-30 19:34:18 +0200
committerLuca Barbieri <luca@luca-barbieri.com>2010-03-30 19:34:18 +0200
commitd4c0c0a141b0a7e8da3c70b06110bb5fe9aa11f5 (patch)
treee4225c88824dee58be34a75b014d94c025adfd00
parenta29411a5f0f492c3503b845c41858e90289ac5b2 (diff)
.
-rw-r--r--nvlib.h24
1 files changed, 20 insertions, 4 deletions
diff --git a/nvlib.h b/nvlib.h
index 581b2fb..c677127 100644
--- a/nvlib.h
+++ b/nvlib.h
@@ -338,6 +338,18 @@ struct nv_device : public nv_region
}
};
+ struct nv_linear_ramin : public nv_region
+ {
+ nv_linear_ramin(struct nv_device* dev)
+ : nv_region(dev)
+ {
+ size = 1 << 24;
+ pci_device_map_range(dev->pci, dev->pci->regions[0].base_addr, size, PCI_DEV_MAP_FLAG_WRITABLE, (void**)&ptr);
+ if (!ptr)
+ throw std::runtime_error("Failed to init RAMIN mapping");
+ }
+ };
+
struct nv_ramht : public nv_region
{
std::shared_ptr<nv_ramin> ramin;
@@ -745,11 +757,11 @@ struct nv_device : public nv_region
struct nv_fifoctx : public nv_region
{
- nv_fifoctx(std::shared_ptr<nv_ramin> ramin, uint32_t offset)
+ nv_fifoctx(std::shared_ptr<nv_region> ramin, uint32_t offset)
: nv_region(ramin->dev)
{
assert(dev->card_type >= NV_50);
- ptr = dev->ramin->ptr + offset;
+ ptr = ramin->ptr + offset;
size = dev->fifoctx_size;
}
@@ -910,6 +922,7 @@ struct nv_device : public nv_region
unsigned ramhts;
std::shared_ptr<nv_ramin> ramin;
+ std::shared_ptr<nv_region> linear_ramin;
std::shared_ptr<nv_ramht> dev_ramht;
std::shared_ptr<nv_ramfc> ramfc;
std::shared_ptr<nv_ramro> ramro;
@@ -1055,6 +1068,9 @@ struct nv_device : public nv_region
ramfc.reset(new nv_ramfc(ramin));
dev_ramht.reset(new nv_ramht(ramin));
ramro.reset(new nv_ramro(ramin));
+ linear_ramin = ramin;
+ } else {
+ linear_ramin.reset(new nv_linear_ramin(this));
}
if(card_type == NV_20 || card_type == NV_30)
@@ -1108,9 +1124,9 @@ struct nv_device : public nv_region
fc = v << 12;
else
fc = v << 8;
- if(fc >= ramin->size)
+ if(fc >= linear_ramin->size)
return std::shared_ptr<nv_fifoctx>();
- return std::shared_ptr<nv_fifoctx>(new nv_fifoctx(ramin, fc));
+ return std::shared_ptr<nv_fifoctx>(new nv_fifoctx(linear_ramin, fc));
}
}