]> mj.ucw.cz Git - pciutils.git/blobdiff - lib/nbsd-libpci.c
More Windows stuff.
[pciutils.git] / lib / nbsd-libpci.c
index e1bebd7d60a056485b4d99e2ec20d19c33ff315d..c9305017f4b0941de6651c82ed7d7616adf02072 100644 (file)
@@ -25,7 +25,7 @@
 static void
 nbsd_config(struct pci_access *a)
 {
-  a->method_params[PCI_ACCESS_NBSD_LIBPCI] = PATH_NBSD_DEVICE;
+  a->method_params[PCI_ACCESS_NBSD_LIBPCI] = PCI_PATH_NBSD_DEVICE;
 }
 
 static int
@@ -67,6 +67,9 @@ nbsd_read(struct pci_dev *d, int pos, byte *buf, int len)
   if (!(len == 1 || len == 2 || len == 4))
     return pci_generic_block_read(d, pos, buf, len);
 
+  if (pos >= 256)
+    return 0;
+
   shift = 8*(pos % 4);
   pos &= ~3;
        
@@ -97,6 +100,9 @@ nbsd_write(struct pci_dev *d, int pos, byte *buf, int len)
   if (!(len == 1 || len == 2 || len == 4))
     return pci_generic_block_write(d, pos, buf, len);
 
+  if (pos >= 256)
+    return 0;
+
   /*
    *  BEWARE: NetBSD seems to support only 32-bit access, so we have
    *  to emulate byte and word writes by read-modify-write, possibly
@@ -104,7 +110,7 @@ nbsd_write(struct pci_dev *d, int pos, byte *buf, int len)
    */
 
   shift = 8*(pos % 4);
-  pos &= 3;
+  pos &= ~3;
   if (len != 4)
     {
       if (pcibus_conf_read(d->access->fd, d->bus, d->dev, d->func, pos, &val) < 0)
@@ -114,10 +120,10 @@ nbsd_write(struct pci_dev *d, int pos, byte *buf, int len)
   switch (len)
     {
     case 1:
-      val = (val & ~(0xff << shift)) | buf[0];
+      val = (val & ~(0xff << shift)) | (buf[0] << shift);
       break;
     case 2:
-      val = (val & ~(0xffff << shift)) | le16_to_cpu(*(u16*)buf);
+      val = (val & ~(0xffff << shift)) | (le16_to_cpu(*(u16*)buf) << shift);
       break;
     case 4:
       val = le32_to_cpu(*(u32*)buf);