I got new toy.
This is Cisco Catalyst 3560G with 48 Ethernet 10/100/1000 ports. I create new category “cisco” in this blog, where all related to cisco devices posts will be posted.

I got new toy.
This is Cisco Catalyst 3560G with 48 Ethernet 10/100/1000 ports. I create new category “cisco” in this blog, where all related to cisco devices posts will be posted.

Last night i’m start porting pci library from NetBSD to OpenBSD. Not so many work was needed and initial revision of this port was done less than one hour. I make some tests and.. looks like “just work”.
While i porting this library i found function, which present in NetBSD and not present in OpenBSD. It is pci_findproduct(). I make my own implementation of this function based on pci_findvendor() code (see /usr/src/sys/dev/pci/pci_subr.c file ). Here is code:
const char *
pci_findproduct(pcireg_t id_reg)
{
#ifdef PCIVERBOSE
pci_product_id_t product = PCI_PRODUCT(id_reg);
const struct pci_known_product *kp; kp = pci_known_products;
while (kp->productname != NULL) { /* all have product name */
if (kp->product == product)
break;
kp++;
}
return (kp->productname);
#else
return (NULL);
#endif
}
Here is very simple example of program using libpci:
#include <stdio.h>
#include <pci.h>int
main(int argc, char** argv)
{
printf("%x is %sn", 0x1186, pci_findvendor((pcireg_t) 0x1186));
printf("%x is %sn", 0x168c, pci_findvendor((pcireg_t) 0x168c));
return 0;
}
Compile and run this sample:
saturn% gcc -Wall -o pcilib pcilib.c -lpci saturn% ./pcilib 1186 is D-Link Systems 168c is Atheros
I think this library may be useful for people, who don’t want teach pci(4) and use ioctl(2) for managing PCI devices.
TODO: Man page need to be rewritten and library code cleanup to style(9) also needed.