Refine PCI BAR masks handling for drkaiser and gfxnvidia
Use the BAR value returned by pcidev_init which automatically applies
the correct BAR mask for the drkaiser driver. Truncate flash chip
addresses to fit into the 128 kB memory window for drkaiser and pick the
same window size for gfxnvidia.
Uwe tested all operations successfully on a Dr. Kaiser card.
Corresponding to flashrom svn r1089.
Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
diff --git a/gfxnvidia.c b/gfxnvidia.c
index 962ba1a..29e2910 100644
--- a/gfxnvidia.c
+++ b/gfxnvidia.c
@@ -25,6 +25,11 @@
#define PCI_VENDOR_ID_NVIDIA 0x10de
+/* Mask to restrict flash accesses to a 128kB memory window.
+ * FIXME: Is this size a one-fits-all or card dependent?
+ */
+#define GFXNVIDIA_MEMMAP_MASK ((1 << 17) - 1)
+
uint8_t *nvidia_bar;
const struct pcidev_status gfx_nvidia[] = {
@@ -95,10 +100,10 @@
void gfxnvidia_chip_writeb(uint8_t val, chipaddr addr)
{
- mmio_writeb(val, nvidia_bar + addr);
+ mmio_writeb(val, nvidia_bar + (addr & GFXNVIDIA_MEMMAP_MASK));
}
uint8_t gfxnvidia_chip_readb(const chipaddr addr)
{
- return mmio_readb(nvidia_bar + addr);
+ return mmio_readb(nvidia_bar + (addr & GFXNVIDIA_MEMMAP_MASK));
}