I cannot seem to get the pci_attach_device() call to work with one
particular card I have, with class 06 (the gateway class, although
this is not a gateway, but a simple IP carrier card.) It works with
other cards, and I am beginning to think this is a library problem, or
my understanding of the library.
I wrote some code to do the pci_attach_device() call and map memory,
printing out diagnostic stuff. Below is the code, and the output for
each card. Note that for both the ATI card and the Acromag cards the
configuration registers have PCI address assigned as they should, But,
for the Acromag card only the info structure has 0’s for the
addresses.
Does this have something to do with the class being 06, maybe?
…
******************* The core of the code is:
/*
- Look up Display Controller, Acromag APC8620 IP Carrier
Board
*/
info.VendorId = 0x1002; /* Try ATI board /
info.DeviceId = 0x4742;
//info.VendorId = 0x10b5; / Acromag /
//info.DeviceId = 0x1024; / APC8620 */
/*
- Do pci_attach_device() to find device, and create handle
*/
hdl = pci_attach_device(NULL, PCI_SEARCH_VENDEV | PCI_SHARE |
PCI_INIT_ALL, pidx, &info);
if (hdl == NULL) {
fprintf(stderr, “First pci_attach_device()
failed.\n”);
exit(1);
}
printf(“pci_attach_device() succeeded. Info:\n”);
/*
- Print info
*/
pcishow(info);
printf(“Binary printout of info:\n”);
phex((char ) &info, sizeof(info));
/
- Read and print config space
*/
if (pci_read_config(hdl, 0, 64, 1, buff) != PCI_SUCCESS) {
printf(“pci_read_config() failed.\n”);
pci_detach_device(hdl);
exit(1);
}
printf(“Big-Endian Config. space, as shown in manuals:\n”);
pciconfigshow((uint32_t *) buff, 16);
*****************Here is the output for vendor and device IDs for ATI
graphics card (first list), and Acromag APC8620 (second):
\
card yields:
Running acrotest with vendor and device ids for ATI graphics
card yields:
pci_attach() successful.
pci_attach_device() succeeded. Info:
Bus = 1 Class code = 0x00030000
CpuIoTranslation = 0x00000000000
CpuMemTranslation = 0x00000000000
CpuBmstrTranslation = 0x00000000000
Vendor id = (0x1002) ATI Technologies
Device id = (0x4742)
Aperture 0: CPU Base 0x000d4000000 PCI Base 0x000d4000000 Length
16777216 bytes Type MEM
Aperture 1: CPU Base 0x0000000c000 PCI Base 0x0000000c001 Length
256 bytes Type IO
Aperture 2: CPU Base 0x000d6000000 PCI Base 0x000d6000000 Length
4096 bytes Type MEM
Binary printout of info:
42 47 02 10 00 00 00 00 01 00 0c 00 00 00 00 00 00 00 03 00
0b 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 0
00 00 00 00 01 c0 00 00 00 00 00 00 00 00 00 d6 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 d4 00 00 00 00 01 c0 00 00 00 00 00 00
00 00 00 d6 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 01 00 00
00 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
Big-Endian Config. space, as shown in manuals:
47 42 10 02 02 90 00 87 03 00 00 5c 00 00 20 08 d4 00 00 00
00 00 c0 01 d6 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 47 42 10 02 00 00 00 00 00 00 00 50 00 00 00 00
00 08 01 0b
Mapping first area at 0x00000000d4000000 of 16777216 bytes into
process space.
mmap_device_memory() success! Processor address = 0x00000000