ppc64: Re-enable SF bit after returning from ELF binary
[openbios.git] / drivers / pci_database.c
blobac4762152e2b638ba170764fb44653565b00d1ea
1 #include "config.h"
2 #include "libopenbios/bindings.h"
3 #include "drivers/pci.h"
4 #include "libc/vsprintf.h"
6 #include "pci_database.h"
8 /* PCI devices database */
10 typedef struct pci_class_t pci_class_t;
11 typedef struct pci_subclass_t pci_subclass_t;
12 typedef struct pci_iface_t pci_iface_t;
14 struct pci_iface_t {
15 uint8_t iface;
16 const char *name;
17 const char *type;
18 const pci_dev_t *devices;
19 int (*config_cb)(const pci_config_t *config);
20 const void *private;
23 struct pci_subclass_t {
24 uint8_t subclass;
25 const char *name;
26 const char *type;
27 const pci_dev_t *devices;
28 const pci_iface_t *iface;
29 int (*config_cb)(const pci_config_t *config);
30 const void *private;
33 struct pci_class_t {
34 const char *name;
35 const char *type;
36 const pci_subclass_t *subc;
39 /* Current machine description */
41 static const pci_subclass_t undef_subclass[] = {
43 0xFF, NULL, NULL, NULL, NULL,
44 NULL, NULL,
48 static const pci_dev_t ide_devices[] = {
50 PCI_VENDOR_ID_CMD, PCI_DEVICE_ID_CMD_646, /* CMD646 IDE controller */
51 "pci-ide", "pci-ata", NULL,
52 "pci1095,646\0pci1095,646\0pciclass,01018f\0",
53 0, 0, 0,
54 ide_config_cb2, NULL,
57 0xFFFF, 0xFFFF,
58 NULL, NULL, NULL, NULL,
59 -1, -1, -1,
60 NULL, NULL,
64 static const pci_subclass_t mass_subclass[] = {
66 PCI_SUBCLASS_STORAGE_SCSI, "SCSI bus controller",
67 NULL, NULL, NULL,
68 NULL, NULL,
71 PCI_SUBCLASS_STORAGE_IDE, "IDE controller",
72 "ide", ide_devices, NULL,
73 NULL, NULL,
76 PCI_SUBCLASS_STORAGE_FLOPPY, "Floppy disk controller",
77 NULL, NULL, NULL,
78 NULL, NULL,
81 PCI_SUBCLASS_STORAGE_IPI, "IPI bus controller",
82 NULL, NULL, NULL,
83 NULL, NULL,
86 PCI_SUBCLASS_STORAGE_RAID, "RAID controller",
87 NULL, NULL, NULL,
88 NULL, NULL,
91 PCI_SUBCLASS_STORAGE_ATA, "ATA controller",
92 "ata", NULL, NULL,
93 NULL, NULL,
96 PCI_SUBCLASS_STORAGE_OTHER, "misc mass-storage controller",
97 NULL, NULL, NULL,
98 NULL, NULL,
101 0xFF, NULL,
102 NULL, NULL, NULL,
103 NULL, NULL,
107 static const pci_dev_t eth_devices[] = {
109 PCI_VENDOR_ID_REALTEK, PCI_DEVICE_ID_REALTEK_RTL8029,
110 NULL, "NE2000", "NE2000 PCI", NULL,
111 0, 0, 0,
112 NULL, "ethernet",
115 0xFFFF, 0xFFFF,
116 NULL, NULL, NULL, NULL,
117 -1, -1, -1,
118 NULL, NULL,
122 static const pci_subclass_t net_subclass[] = {
124 PCI_SUBCLASS_NETWORK_ETHERNET, "ethernet controller",
125 NULL, eth_devices, NULL,
126 eth_config_cb, "ethernet",
129 PCI_SUBCLASS_NETWORK_TOKEN_RING, "token ring controller",
130 NULL, NULL, NULL,
131 NULL, NULL,
134 PCI_SUBCLASS_NETWORK_FDDI, "FDDI controller",
135 NULL, NULL, NULL,
136 NULL, NULL,
139 PCI_SUBCLASS_NETWORK_ATM, "ATM controller",
140 NULL, NULL, NULL,
141 NULL, NULL,
144 PCI_SUBCLASS_NETWORK_ISDN, "ISDN controller",
145 NULL, NULL, NULL,
146 NULL, NULL,
149 PCI_SUBCLASS_NETWORK_WORDFIP, "WordFip controller",
150 NULL, NULL, NULL,
151 NULL, NULL,
154 PCI_SUBCLASS_NETWORK_PICMG214, "PICMG 2.14 controller",
155 NULL, NULL, NULL,
156 NULL, NULL,
159 PCI_SUBCLASS_NETWORK_OTHER, "misc network controller",
160 NULL, NULL, NULL,
161 NULL, NULL,
164 0xFF, NULL,
165 NULL, NULL, NULL,
166 NULL, NULL,
170 static const pci_dev_t vga_devices[] = {
172 PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RAGE128_PF,
173 NULL, "ATY", "ATY Rage128", "VGA\0",
174 0, 0, 0,
175 NULL, NULL,
178 PCI_VENDOR_ID_QEMU, PCI_DEVICE_ID_QEMU_VGA,
179 NULL, "QEMU,VGA", "Qemu VGA", "VGA\0",
180 0, 0, 0,
181 NULL, NULL,
184 0xFFFF, 0xFFFF,
185 NULL, NULL, NULL, NULL,
186 -1, -1, -1,
187 NULL, NULL,
191 static const struct pci_iface_t vga_iface[] = {
193 0x00, "VGA controller", NULL,
194 vga_devices, &vga_config_cb, NULL,
197 0x01, "8514 compatible controller", NULL,
198 NULL, NULL, NULL,
201 0xFF, NULL, NULL,
202 NULL, NULL, NULL,
206 static const pci_subclass_t displ_subclass[] = {
208 PCI_SUBCLASS_DISPLAY_VGA, "display controller",
209 NULL, NULL, vga_iface,
210 NULL, NULL,
213 PCI_SUBCLASS_DISPLAY_XGA, "XGA display controller",
214 NULL, NULL, NULL,
215 NULL, NULL,
218 PCI_SUBCLASS_DISPLAY_3D, "3D display controller",
219 NULL, NULL, NULL,
220 NULL, NULL,
223 PCI_SUBCLASS_DISPLAY_OTHER, "misc display controller",
224 NULL, NULL, NULL,
225 NULL, NULL,
228 0xFF, NULL,
229 NULL, NULL, NULL,
230 NULL, NULL,
234 static const pci_subclass_t media_subclass[] = {
236 PCI_SUBCLASS_MULTIMEDIA_VIDEO, "video device",
237 NULL, NULL, NULL,
238 NULL, NULL,
241 PCI_SUBCLASS_MULTIMEDIA_AUDIO, "audio device",
242 NULL, NULL, NULL,
243 NULL, NULL,
246 PCI_SUBCLASS_MULTIMEDIA_PHONE, "computer telephony device",
247 NULL, NULL, NULL,
248 NULL, NULL,
251 PCI_SUBCLASS_MULTIMEDIA_OTHER, "misc multimedia device",
252 NULL, NULL, NULL,
253 NULL, NULL,
256 0xFF, NULL,
257 NULL, NULL, NULL,
258 NULL, NULL,
262 static const pci_subclass_t mem_subclass[] = {
264 PCI_SUBCLASS_MEMORY_RAM, "RAM controller",
265 NULL, NULL, NULL,
266 NULL, NULL,
269 PCI_SUBCLASS_MEMORY_FLASH, "flash controller",
270 NULL, NULL, NULL,
271 NULL, NULL,
274 0xFF, NULL,
275 NULL, NULL, NULL,
276 NULL, NULL,
281 static const pci_dev_t hbrg_devices[] = {
283 PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_U3_AGP, NULL,
284 "pci", "AAPL,UniNorth", "u3-agp\0",
285 3, 2, 1,
286 host_config_cb, NULL,
289 PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_UNI_N_AGP, NULL,
290 "pci", "AAPL,UniNorth", "uni-north\0",
291 3, 2, 1,
292 host_config_cb, NULL,
295 PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_UNI_N_PCI, NULL,
296 "pci", "AAPL,UniNorth", "uni-north\0",
297 3, 2, 1,
298 host_config_cb, NULL,
301 PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_UNI_N_I_PCI, NULL,
302 "pci", "AAPL,UniNorth", "uni-north\0",
303 3, 2, 1,
304 NULL, NULL
307 PCI_VENDOR_ID_MOTOROLA, PCI_DEVICE_ID_MOTOROLA_MPC106, "pci",
308 "pci", "MOT,MPC106", "grackle\0",
309 3, 2, 1,
310 host_config_cb, NULL
313 PCI_VENDOR_ID_MOTOROLA, PCI_DEVICE_ID_MOTOROLA_RAVEN, NULL,
314 "pci-bridge", "PREP Host PCI Bridge - Motorola Raven", NULL,
315 3, 2, 1,
316 NULL, NULL,
319 PCI_VENDOR_ID_SUN, PCI_DEVICE_ID_SUN_SABRE, NULL,
320 "pci", "SUNW,sabre", "pci108e,a000\0pciclass,0\0",
321 3, 2, 1,
322 sabre_config_cb, NULL,
325 0xFFFF, 0xFFFF,
326 NULL, NULL, NULL, NULL,
327 -1, -1, -1,
328 NULL, NULL,
332 static const pci_dev_t PCIbrg_devices[] = {
334 PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_21154, NULL,
335 "pci-bridge", "DEV,21154", "DEV,21154\0pci-bridge\0",
336 3, 2, 1,
337 bridge_config_cb, NULL,
340 PCI_VENDOR_ID_SUN, PCI_DEVICE_ID_SUN_SIMBA, NULL,
341 "pci", "SUNW,simba", "pci108e,5000\0pciclass,060400\0",
342 3, 2, 1,
343 bridge_config_cb, NULL,
346 0xFFFF, 0xFFFF,
347 NULL, NULL, NULL, NULL,
348 -1, -1, -1,
349 NULL, NULL,
353 static const pci_dev_t miscbrg_devices[] = {
355 PCI_VENDOR_ID_SUN, PCI_DEVICE_ID_SUN_EBUS, NULL,
356 "ebus", "ebus", "pci108e,1000\0pciclass,068000\0",
357 2, 1, 1,
358 ebus_config_cb, NULL,
361 0xFFFF, 0xFFFF,
362 NULL, NULL, NULL, NULL,
363 -1, -1, -1,
364 NULL, NULL,
368 static const pci_subclass_t bridg_subclass[] = {
370 PCI_SUBCLASS_BRIDGE_HOST, "PCI host bridge",
371 "pci", hbrg_devices, NULL,
372 NULL, NULL,
375 PCI_SUBCLASS_BRIDGE_ISA, "ISA bridge",
376 NULL, NULL, NULL,
377 NULL, NULL,
380 PCI_SUBCLASS_BRIDGE_EISA, "EISA bridge",
381 NULL, NULL, NULL,
382 NULL, NULL,
385 PCI_SUBCLASS_BRIDGE_MC, "MCA bridge",
386 NULL, NULL, NULL,
387 NULL, NULL,
390 PCI_SUBCLASS_BRIDGE_PCI, "PCI-to-PCI bridge",
391 "pci", PCIbrg_devices, NULL,
392 NULL, NULL,
395 PCI_SUBCLASS_BRIDGE_PCMCIA, "PCMCIA bridge",
396 NULL, NULL, NULL,
397 NULL, NULL,
400 PCI_SUBCLASS_BRIDGE_NUBUS, "NUBUS bridge",
401 NULL, NULL, NULL,
402 NULL, NULL,
405 PCI_SUBCLASS_BRIDGE_CARDBUS, "cardbus bridge",
406 NULL, NULL, NULL,
407 NULL, NULL,
410 PCI_SUBCLASS_BRIDGE_RACEWAY, "raceway bridge",
411 NULL, NULL, NULL,
412 NULL, NULL,
415 PCI_SUBCLASS_BRIDGE_PCI_SEMITP, "semi-transparent PCI-to-PCI bridge",
416 NULL, NULL, NULL,
417 NULL, NULL,
420 PCI_SUBCLASS_BRIDGE_IB_PCI, "infiniband-to-PCI bridge",
421 NULL, NULL, NULL,
422 NULL, NULL,
425 PCI_SUBCLASS_BRIDGE_OTHER, "misc PCI bridge",
426 NULL, miscbrg_devices, NULL,
427 NULL, NULL,
430 0xFF, NULL,
431 NULL, NULL, NULL,
432 NULL, NULL,
436 static const pci_iface_t serial_iface[] = {
438 0x00, "XT serial controller", NULL,
439 NULL, NULL, NULL,
442 0x01, "16450 serial controller", NULL,
443 NULL, NULL, NULL,
446 0x02, "16550 serial controller", NULL,
447 NULL, NULL, NULL,
450 0x03, "16650 serial controller", NULL,
451 NULL, NULL, NULL,
454 0x04, "16750 serial controller", NULL,
455 NULL, NULL, NULL,
458 0x05, "16850 serial controller", NULL,
459 NULL, NULL, NULL,
462 0x06, "16950 serial controller", NULL,
463 NULL, NULL, NULL,
466 0xFF, NULL, NULL,
467 NULL, NULL, NULL,
471 static const pci_iface_t par_iface[] = {
473 0x00, "parallel port", NULL,
474 NULL, NULL, NULL,
477 0x01, "bi-directional parallel port", NULL,
478 NULL, NULL, NULL,
481 0x02, "ECP 1.x parallel port", NULL,
482 NULL, NULL, NULL,
485 0x03, "IEEE 1284 controller", NULL,
486 NULL, NULL, NULL,
489 0xFE, "IEEE 1284 device", NULL,
490 NULL, NULL, NULL,
493 0xFF, NULL, NULL,
494 NULL, NULL, NULL,
498 static const pci_iface_t modem_iface[] = {
500 0x00, "generic modem", NULL,
501 NULL, NULL, NULL,
504 0x01, "Hayes 16450 modem", NULL,
505 NULL, NULL, NULL,
508 0x02, "Hayes 16550 modem", NULL,
509 NULL, NULL, NULL,
512 0x03, "Hayes 16650 modem", NULL,
513 NULL, NULL, NULL,
516 0x04, "Hayes 16750 modem", NULL,
517 NULL, NULL, NULL,
520 0xFF, NULL, NULL,
521 NULL, NULL, NULL,
525 static const pci_subclass_t comm_subclass[] = {
527 PCI_SUBCLASS_COMMUNICATION_SERIAL, "serial controller",
528 NULL, NULL, serial_iface,
529 NULL, NULL,
532 PCI_SUBCLASS_COMMUNICATION_PARALLEL, "parallel port",
533 NULL, NULL, par_iface,
534 NULL, NULL,
537 PCI_SUBCLASS_COMMUNICATION_MULTISERIAL, "multiport serial controller",
538 NULL, NULL, NULL,
539 NULL, NULL,
542 PCI_SUBCLASS_COMMUNICATION_MODEM, "modem",
543 NULL, NULL, modem_iface,
544 NULL, NULL,
547 PCI_SUBCLASS_COMMUNICATION_GPIB, "GPIB controller",
548 NULL, NULL, NULL,
549 NULL, NULL,
552 PCI_SUBCLASS_COMMUNICATION_SC, "smart card",
553 NULL, NULL, NULL,
554 NULL, NULL,
557 PCI_SUBCLASS_COMMUNICATION_OTHER, "misc communication device",
558 NULL, NULL, NULL,
559 NULL, NULL,
562 0xFF, NULL,
563 NULL, NULL, NULL,
564 NULL, NULL,
568 static const pci_iface_t pic_iface[] = {
570 0x00, "8259 PIC", NULL,
571 NULL, NULL, NULL,
574 0x01, "ISA PIC", NULL,
575 NULL, NULL, NULL,
578 0x02, "EISA PIC", NULL,
579 NULL, NULL, NULL,
582 0x10, "I/O APIC", NULL,
583 NULL, NULL, NULL,
586 0x20, "I/O APIC", NULL,
587 NULL, NULL, NULL,
590 0xFF, NULL, NULL,
591 NULL, NULL, NULL,
595 static const pci_iface_t dma_iface[] = {
597 0x00, "8237 DMA controller", NULL,
598 NULL, NULL, NULL,
601 0x01, "ISA DMA controller", NULL,
602 NULL, NULL, NULL,
605 0x02, "EISA DMA controller", NULL,
606 NULL, NULL, NULL,
609 0xFF, NULL, NULL,
610 NULL, NULL, NULL,
614 static const pci_iface_t tmr_iface[] = {
616 0x00, "8254 system timer", NULL,
617 NULL, NULL, NULL,
620 0x01, "ISA system timer", NULL,
621 NULL, NULL, NULL,
624 0x02, "EISA system timer", NULL,
625 NULL, NULL, NULL,
628 0xFF, NULL, NULL,
629 NULL, NULL, NULL,
633 static const pci_iface_t rtc_iface[] = {
635 0x00, "generic RTC controller", NULL,
636 NULL, NULL, NULL,
639 0x01, "ISA RTC controller", NULL,
640 NULL, NULL, NULL,
643 0xFF, NULL, NULL,
644 NULL, NULL, NULL,
648 static const pci_dev_t sys_devices[] = {
649 /* IBM MPIC controller */
651 PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OPENPIC,
652 "open-pic", "MPIC", NULL, "chrp,open-pic\0",
653 0, 0, 2,
654 NULL, NULL,
656 /* IBM MPIC2 controller */
658 PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OPENPIC2,
659 "open-pic", "MPIC2", NULL, "chrp,open-pic\0",
660 0, 0, 2,
661 NULL, NULL,
664 0xFFFF, 0xFFFF,
665 NULL, NULL, NULL, NULL,
666 -1, -1, -1,
667 NULL, NULL,
671 static const pci_subclass_t sys_subclass[] = {
673 PCI_SUBCLASS_SYSTEM_PIC, "PIC",
674 NULL, NULL, pic_iface,
675 NULL, NULL,
678 PCI_SUBCLASS_SYSTEM_DMA, "DMA controller",
679 NULL, NULL, dma_iface,
680 NULL, NULL,
683 PCI_SUBCLASS_SYSTEM_TIMER, "system timer",
684 NULL, NULL, tmr_iface,
685 NULL, NULL,
688 PCI_SUBCLASS_SYSTEM_RTC, "RTC controller",
689 NULL, NULL, rtc_iface,
690 NULL, NULL,
693 PCI_SUBCLASS_SYSTEM_PCI_HOTPLUG, "PCI hotplug controller",
694 NULL, NULL, NULL,
695 NULL, NULL,
698 PCI_SUBCLASS_SYSTEM_OTHER, "misc system peripheral",
699 NULL, sys_devices, NULL,
700 NULL, NULL,
703 0xFF, NULL,
704 NULL, NULL, NULL,
705 NULL, NULL,
709 static const pci_subclass_t inp_subclass[] = {
711 PCI_SUBCLASS_INPUT_KEYBOARD, "keyboard controller",
712 NULL, NULL, NULL,
713 NULL, NULL,
716 PCI_SUBCLASS_INPUT_PEN, "digitizer",
717 NULL, NULL, NULL,
718 NULL, NULL,
721 PCI_SUBCLASS_INPUT_MOUSE, "mouse controller",
722 NULL, NULL, NULL,
723 NULL, NULL,
726 PCI_SUBCLASS_INPUT_SCANNER, "scanner controller",
727 NULL, NULL, NULL,
728 NULL, NULL,
731 PCI_SUBCLASS_INPUT_GAMEPORT, "gameport controller",
732 NULL, NULL, NULL,
733 NULL, NULL,
736 PCI_SUBCLASS_INPUT_OTHER, "misc input device",
737 NULL, NULL, NULL,
738 NULL, NULL,
741 0xFF, NULL,
742 NULL, NULL, NULL,
743 NULL, NULL,
747 static const pci_subclass_t dock_subclass[] = {
749 PCI_SUBCLASS_DOCKING_GENERIC, "generic docking station",
750 NULL, NULL, NULL,
751 NULL, NULL,
754 PCI_SUBCLASS_DOCKING_OTHER, "misc docking station",
755 NULL, NULL, NULL,
756 NULL, NULL,
759 0xFF, NULL,
760 NULL, NULL, NULL,
761 NULL, NULL,
765 static const pci_subclass_t cpu_subclass[] = {
767 PCI_SUBCLASS_PROCESSOR_386, "i386 processor",
768 NULL, NULL, NULL,
769 NULL, NULL,
772 PCI_SUBCLASS_PROCESSOR_486, "i486 processor",
773 NULL, NULL, NULL,
774 NULL, NULL,
777 PCI_SUBCLASS_PROCESSOR_PENTIUM, "pentium processor",
778 NULL, NULL, NULL,
779 NULL, NULL,
782 PCI_SUBCLASS_PROCESSOR_ALPHA, "alpha processor",
783 NULL, NULL, NULL,
784 NULL, NULL,
787 PCI_SUBCLASS_PROCESSOR_POWERPC, "PowerPC processor",
788 NULL, NULL, NULL,
789 NULL, NULL,
792 PCI_SUBCLASS_PROCESSOR_MIPS, "MIPS processor",
793 NULL, NULL, NULL,
794 NULL, NULL,
797 PCI_SUBCLASS_PROCESSOR_CO, "co-processor",
798 NULL, NULL, NULL,
799 NULL, NULL,
802 0xFF, NULL,
803 NULL, NULL, NULL,
804 NULL, NULL,
808 static const pci_iface_t usb_iface[] = {
810 0x00, "UHCI USB controller", NULL,
811 NULL, NULL, NULL,
814 0x10, "OHCI USB controller", NULL,
815 NULL, NULL, NULL,
818 0x20, "EHCI USB controller", NULL,
819 NULL, NULL, NULL,
822 0x80, "misc USB controller", NULL,
823 NULL, NULL, NULL,
826 0xFE, "USB device", NULL,
827 NULL, NULL, NULL,
830 0xFF, NULL, NULL,
831 NULL, NULL, NULL,
835 static const pci_iface_t ipmi_iface[] = {
837 0x00, "IPMI SMIC interface", NULL,
838 NULL, NULL, NULL,
841 0x01, "IPMI keyboard interface", NULL,
842 NULL, NULL, NULL,
845 0x02, "IPMI block transfer interface", NULL,
846 NULL, NULL, NULL,
849 0xFF, NULL, NULL,
850 NULL, NULL, NULL,
854 static const pci_subclass_t ser_subclass[] = {
856 PCI_SUBCLASS_SERIAL_FIREWIRE, "Firewire bus controller",
857 "ieee1394", NULL, NULL,
858 NULL, NULL,
861 PCI_SUBCLASS_SERIAL_ACCESS, "ACCESS bus controller",
862 NULL, NULL, NULL,
863 NULL, NULL,
866 PCI_SUBCLASS_SERIAL_SSA, "SSA controller",
867 NULL, NULL, NULL,
868 NULL, NULL,
871 PCI_SUBCLASS_SERIAL_USB, "USB controller",
872 "usb", NULL, usb_iface,
873 NULL, NULL,
876 PCI_SUBCLASS_SERIAL_FIBER, "fibre channel controller",
877 NULL, NULL, NULL,
878 NULL, NULL,
881 PCI_SUBCLASS_SERIAL_SMBUS, "SMBus controller",
882 NULL, NULL, NULL,
883 NULL, NULL,
886 PCI_SUBCLASS_SERIAL_IB, "InfiniBand controller",
887 NULL, NULL, NULL,
888 NULL, NULL,
891 PCI_SUBCLASS_SERIAL_IPMI, "IPMI interface",
892 NULL, NULL, ipmi_iface,
893 NULL, NULL,
896 PCI_SUBCLASS_SERIAL_SERCOS, "SERCOS controller",
897 NULL, NULL, ipmi_iface,
898 NULL, NULL,
901 PCI_SUBCLASS_SERIAL_CANBUS, "CANbus controller",
902 NULL, NULL, ipmi_iface,
903 NULL, NULL,
906 0xFF, NULL,
907 NULL, NULL, NULL,
908 NULL, NULL,
912 static const pci_subclass_t wrl_subclass[] = {
914 PCI_SUBCLASS_WIRELESS_IRDA, "IRDA controller",
915 NULL, NULL, NULL,
916 NULL, NULL,
919 PCI_SUBCLASS_WIRELESS_CIR, "consumer IR controller",
920 NULL, NULL, NULL,
921 NULL, NULL,
924 PCI_SUBCLASS_WIRELESS_RF_CONTROLLER, "RF controller",
925 NULL, NULL, NULL,
926 NULL, NULL,
929 PCI_SUBCLASS_WIRELESS_BLUETOOTH, "bluetooth controller",
930 NULL, NULL, NULL,
931 NULL, NULL,
934 PCI_SUBCLASS_WIRELESS_BROADBAND, "broadband controller",
935 NULL, NULL, NULL,
936 NULL, NULL,
939 PCI_SUBCLASS_WIRELESS_OTHER, "misc wireless controller",
940 NULL, NULL, NULL,
941 NULL, NULL,
944 0xFF, NULL,
945 NULL, NULL, NULL,
946 NULL, NULL,
950 static const pci_subclass_t sat_subclass[] = {
952 PCI_SUBCLASS_SATELLITE_TV, "satellite TV controller",
953 NULL, NULL, NULL,
954 NULL, NULL,
957 PCI_SUBCLASS_SATELLITE_AUDIO, "satellite audio controller",
958 NULL, NULL, NULL,
959 NULL, NULL,
962 PCI_SUBCLASS_SATELLITE_VOICE, "satellite voice controller",
963 NULL, NULL, NULL,
964 NULL, NULL,
967 PCI_SUBCLASS_SATELLITE_DATA, "satellite data controller",
968 NULL, NULL, NULL,
969 NULL, NULL,
972 0xFF, NULL,
973 NULL, NULL, NULL,
974 NULL, NULL,
978 static const pci_subclass_t crypt_subclass[] = {
980 PCI_SUBCLASS_CRYPT_NETWORK, "cryptographic network controller",
981 NULL, NULL, NULL,
982 NULL, NULL,
985 PCI_SUBCLASS_CRYPT_ENTERTAINMENT,
986 "cryptographic entertainment controller",
987 NULL, NULL, NULL,
988 NULL, NULL,
991 PCI_SUBCLASS_CRYPT_OTHER, "misc cryptographic controller",
992 NULL, NULL, NULL,
993 NULL, NULL,
996 0xFF, NULL,
997 NULL, NULL, NULL,
998 NULL, NULL,
1002 static const pci_subclass_t spc_subclass[] = {
1004 PCI_SUBCLASS_SP_DPIO, "DPIO module",
1005 NULL, NULL, NULL,
1006 NULL, NULL,
1009 PCI_SUBCLASS_SP_PERF, "performances counters",
1010 NULL, NULL, NULL,
1011 NULL, NULL,
1014 PCI_SUBCLASS_SP_SYNCH, "communication synchronisation",
1015 NULL, NULL, NULL,
1016 NULL, NULL,
1019 PCI_SUBCLASS_SP_MANAGEMENT, "management card",
1020 NULL, NULL, NULL,
1021 NULL, NULL,
1024 PCI_SUBCLASS_SP_OTHER, "misc signal processing controller",
1025 NULL, NULL, NULL,
1026 NULL, NULL,
1029 0xFF, NULL,
1030 NULL, NULL, NULL,
1031 NULL, NULL,
1035 static const pci_class_t pci_classes[] = {
1036 /* 0x00 */
1037 { "undefined", NULL, undef_subclass, },
1038 /* 0x01 */
1039 { "mass-storage controller", NULL, mass_subclass, },
1040 /* 0x02 */
1041 { "network controller", "network", net_subclass, },
1042 /* 0x03 */
1043 { "display controller", "display", displ_subclass, },
1044 /* 0x04 */
1045 { "multimedia device", NULL, media_subclass, },
1046 /* 0x05 */
1047 { "memory controller", "memory-controller", mem_subclass, },
1048 /* 0x06 */
1049 { "PCI bridge", NULL, bridg_subclass, },
1050 /* 0x07 */
1051 { "communication device", NULL, comm_subclass,},
1052 /* 0x08 */
1053 { "system peripheral", NULL, sys_subclass, },
1054 /* 0x09 */
1055 { "input device", NULL, inp_subclass, },
1056 /* 0x0A */
1057 { "docking station", NULL, dock_subclass, },
1058 /* 0x0B */
1059 { "processor", NULL, cpu_subclass, },
1060 /* 0x0C */
1061 { "serial bus controller", NULL, ser_subclass, },
1062 /* 0x0D */
1063 { "wireless controller", NULL, wrl_subclass, },
1064 /* 0x0E */
1065 { "intelligent I/O controller", NULL, NULL, },
1066 /* 0x0F */
1067 { "satellite communication controller", NULL, sat_subclass, },
1068 /* 0x10 */
1069 { "cryptographic controller", NULL, crypt_subclass, },
1070 /* 0x11 */
1071 { "signal processing controller", NULL, spc_subclass, },
1074 static const pci_dev_t misc_pci[] = {
1075 /* Heathrow Mac I/O */
1077 PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_343S1201,
1078 "mac-io", "mac-io", "AAPL,343S1201", "heathrow\0",
1079 1, 1, 1,
1080 &macio_heathrow_config_cb, NULL,
1082 /* Paddington Mac I/O */
1084 PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_343S1211,
1085 "mac-io", "mac-io", "AAPL,343S1211", "paddington\0heathrow\0",
1086 1, 1, 1,
1087 &macio_heathrow_config_cb, NULL,
1089 /* KeyLargo Mac I/O */
1091 PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_UNI_N_KEYL,
1092 "mac-io", "mac-io", "AAPL,Keylargo", "Keylargo\0",
1093 1, 1, 1,
1094 &macio_keylargo_config_cb, NULL,
1097 0xFFFF, 0xFFFF,
1098 NULL, NULL, NULL, NULL,
1099 -1, -1, -1,
1100 NULL, NULL,
1104 const pci_dev_t *pci_find_device (uint8_t class, uint8_t subclass,
1105 uint8_t iface, uint16_t vendor,
1106 uint16_t product)
1108 int (*config_cb)(const pci_config_t *config);
1109 const pci_class_t *pclass;
1110 const pci_subclass_t *psubclass;
1111 const pci_iface_t *piface;
1112 const pci_dev_t *dev;
1113 const void *private;
1114 pci_dev_t *new;
1115 const char *name, *type;
1117 name = "unknown";
1118 type = "unknown";
1119 config_cb = NULL;
1120 private = NULL;
1122 if (class == 0x00 && subclass == 0x01) {
1123 /* Special hack for old style VGA devices */
1124 class = 0x03;
1125 subclass = 0x00;
1126 } else if (class == 0xFF) {
1127 /* Special case for misc devices */
1128 dev = misc_pci;
1129 goto find_device;
1131 if (class > (sizeof(pci_classes) / sizeof(pci_class_t))) {
1132 name = "invalid PCI device";
1133 type = "invalid";
1134 goto bad_device;
1136 pclass = &pci_classes[class];
1137 name = pclass->name;
1138 type = pclass->type;
1139 for (psubclass = pclass->subc; ; psubclass++) {
1140 if (psubclass->subclass == 0xFF)
1141 goto bad_device;
1142 if (psubclass->subclass == subclass) {
1143 if (psubclass->name != NULL)
1144 name = psubclass->name;
1145 if (psubclass->type != NULL)
1146 type = psubclass->type;
1147 if (psubclass->config_cb != NULL) {
1148 config_cb = psubclass->config_cb;
1150 if (psubclass->private != NULL)
1151 private = psubclass->private;
1152 if (psubclass->iface != NULL)
1153 break;
1154 dev = psubclass->devices;
1155 goto find_device;
1158 for (piface = psubclass->iface; ; piface++) {
1159 if (piface->iface == 0xFF) {
1160 dev = psubclass->devices;
1161 break;
1163 if (piface->iface == iface) {
1164 if (piface->name != NULL)
1165 name = piface->name;
1166 if (piface->type != NULL)
1167 type = piface->type;
1168 if (piface->config_cb != NULL) {
1169 config_cb = piface->config_cb;
1171 if (piface->private != NULL)
1172 private = piface->private;
1173 dev = piface->devices;
1174 break;
1177 find_device:
1178 if (dev == NULL)
1179 goto bad_device;
1180 for (;; dev++) {
1181 if (dev->vendor == 0xFFFF && dev->product == 0xFFFF) {
1182 goto bad_device;
1184 if (dev->vendor == vendor && dev->product == product) {
1185 if (dev->name != NULL)
1186 name = dev->name;
1187 if (dev->type != NULL)
1188 type = dev->type;
1189 if (dev->config_cb != NULL) {
1190 config_cb = dev->config_cb;
1192 if (dev->private != NULL)
1193 private = dev->private;
1194 new = malloc(sizeof(pci_dev_t));
1195 if (new == NULL)
1196 return NULL;
1197 new->vendor = vendor;
1198 new->product = product;
1199 new->type = type;
1200 new->name = name;
1201 new->model = dev->model;
1202 new->compat = dev->compat;
1203 new->acells = dev->acells;
1204 new->scells = dev->scells;
1205 new->icells = dev->icells;
1206 new->config_cb = config_cb;
1207 new->private = private;
1209 return new;
1212 bad_device:
1213 printk("Cannot manage '%s' PCI device type '%s':\n %x %x (%x %x %x)\n",
1214 name, type, vendor, product, class, subclass, iface);
1216 return NULL;