/*
- * $Id: access.c,v 1.1 1999/01/22 21:05:12 mj Exp $
+ * $Id: access.c,v 1.7 2000/04/21 11:58:00 mj Exp $
*
* The PCI Library -- User Access
*
NULL,
NULL,
#endif
+#ifdef HAVE_PM_FBSD_DEVICE
+ &pm_fbsd_device,
+#else
+ NULL,
+#endif
+#ifdef HAVE_PM_AIX_DEVICE
+ &pm_aix_device,
+#else
+ NULL,
+#endif
#ifdef HAVE_PM_DUMP
&pm_dump,
#else
{
a->debug("...OK\n");
a->methods = pci_methods[i];
+ a->method = i;
break;
}
a->debug("...No.\n");
{
if (pos & (len-1))
d->access->error("Unaligned read: pos=%02x, len=%d", pos, len);
- if (!d->methods->read(d, pos, buf, len))
+ if (pos + len <= d->cache_len)
+ memcpy(buf, d->cache + pos, len);
+ else if (!d->methods->read(d, pos, buf, len))
memset(buf, 0xff, len);
}
{
if (pos & (len-1))
d->access->error("Unaligned write: pos=%02x,len=%d", pos, len);
+ if (pos + len <= d->cache_len)
+ memcpy(d->cache + pos, buf, len);
return d->methods->write(d, pos, buf, len);
}
int
pci_write_block(struct pci_dev *d, int pos, byte *buf, int len)
{
+ if (pos < d->cache_len)
+ {
+ int l = (pos + len >= d->cache_len) ? (d->cache_len - pos) : len;
+ memcpy(d->cache + pos, buf, l);
+ }
return d->methods->write(d, pos, buf, len);
}
-void
+int
pci_fill_info(struct pci_dev *d, int flags)
{
if (flags & PCI_FILL_RESCAN)
d->known_fields = 0;
}
if (flags & ~d->known_fields)
- d->methods->fill_info(d, flags & ~d->known_fields);
- d->known_fields |= flags;
+ d->known_fields |= d->methods->fill_info(d, flags & ~d->known_fields);
+ return d->known_fields;
+}
+
+void
+pci_setup_cache(struct pci_dev *d, byte *cache, int len)
+{
+ d->cache = cache;
+ d->cache_len = len;
}