diff options
Diffstat (limited to 'nvlib.h')
-rw-r--r-- | nvlib.h | 24 |
1 files changed, 20 insertions, 4 deletions
@@ -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)); } } |