1 /* ----------------------------------------------------------------------- *
3 * Copyright 2006 Erwan Velu - All Rights Reserved
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, Inc., 53 Temple Place Ste 330,
8 * Boston MA 02111-1307, USA; either version 2 of the License, or
9 * (at your option) any later version; incorporated herein by reference.
11 * ----------------------------------------------------------------------- */
28 # define dprintf printf
30 # define dprintf(...) ((void)0)
34 #define moreprintf(...) \
37 if (display_line == 24) { \
40 printf("Press enter to continue\n"); \
41 fgets(tempbuf, sizeof tempbuf, stdin); \
43 printf ( __VA_ARGS__); \
46 void display_pci_devices(s_pci_device_list
*pci_device_list
) {
48 for (pci_dev
=0; pci_dev
< pci_device_list
->count
; pci_dev
++) {
49 s_pci_device
*pci_device
= &pci_device_list
->pci_device
[pci_dev
];
50 printf("PCI: Vendor=%04x Product=%04x Sub_vendor=%04x Sub_Product=%04x Release=%02x\n",
51 pci_device
->vendor
, pci_device
->product
,
52 pci_device
->sub_vendor
, pci_device
->sub_product
,
53 pci_device
->revision
);
55 printf("PCI: %d devices found\n",pci_device_list
->count
);
58 void display_pci_bus(s_pci_bus_list
*pci_bus_list
, bool display_pci_devices
) {
60 for (bus
=0; bus
<pci_bus_list
->count
;bus
++) {
61 s_pci_bus pci_bus
= pci_bus_list
->pci_bus
[bus
];
62 printf("\nPCI BUS No %d:\n", pci_bus
.id
);
63 if (display_pci_devices
) {
65 for (pci_dev
=0; pci_dev
< pci_bus
.pci_device_count
; pci_dev
++) {
66 s_pci_device pci_device
=*(pci_bus
.pci_device
[pci_dev
]);
67 printf("#(%04x:%04x[%04x:%04x])\n",
68 pci_device
.vendor
, pci_device
.product
,
69 pci_device
.sub_vendor
, pci_device
.sub_product
);
73 printf("PCI: %d buses found\n",pci_bus_list
->count
);
76 int main(int argc
, char *argv
[])
78 s_pci_device_list pci_device_list
;
79 s_pci_bus_list pci_bus_list
;
80 openconsole(&dev_null_r
, &dev_stdcon_w
);
81 pci_scan(&pci_bus_list
,&pci_device_list
);
82 // display_pci_devices(&pci_device_list);
83 display_pci_bus(&pci_bus_list
,true);