Adding upstream version 3.50~pre5.
[syslinux-debian/hramrach.git] / com32 / modules / pcitest.c
blobc5e72e34740b9b282ff0defd00298511c61083fc
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 * ----------------------------------------------------------------------- */
14 * pcitest.c
18 #include <inttypes.h>
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <string.h>
22 #include <console.h>
23 #include <com32.h>
24 #include <sys/pci.h>
25 #include <stdbool.h>
27 #ifdef DEBUG
28 # define dprintf printf
29 #else
30 # define dprintf(...) ((void)0)
31 #endif
33 char display_line;
34 #define moreprintf(...) \
35 do { \
36 display_line++; \
37 if (display_line == 24) { \
38 char tempbuf[10]; \
39 display_line=0; \
40 printf("Press enter to continue\n"); \
41 fgets(tempbuf, sizeof tempbuf, stdin); \
42 } \
43 printf ( __VA_ARGS__); \
44 } while (0);
46 void display_pci_devices(s_pci_device_list *pci_device_list) {
47 int pci_dev;
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) {
59 int bus;
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) {
64 int pci_dev;
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);
84 return 1;