4 Configure devices on the PCI bus
6 Created: Jan 2000 by Philip Homburg <philip@cs.vu.nl>
10 #include <machine/pci.h>
11 #include <machine/vm.h>
12 #include <minix/com.h>
14 #include <minix/syslib.h>
15 #include <minix/param.h>
18 #include <machine/pci_amd.h>
19 #include <machine/pci_intel.h>
20 #include <machine/pci_sis.h>
21 #include <machine/pci_via.h>
27 #define irq_mode_pci(irq) ((void)0)
32 #include <minix/sysutil.h>
33 #include <minix/acpi.h>
35 #define PBT_INTEL_HOST 1
36 #define PBT_PCIBRIDGE 2
39 #define BAM_NR 6 /* Number of base-address registers */
48 int pb_isabridge_type
;
52 u8_t (*pb_rreg8
)(int busind
, int devind
, int port
);
53 u16_t (*pb_rreg16
)(int busind
, int devind
, int port
);
54 u32_t (*pb_rreg32
)(int busind
, int devind
, int port
);
55 void (*pb_wreg8
)(int busind
, int devind
, int port
, u8_t value
);
56 void (*pb_wreg16
)(int busind
, int devind
, int port
, u16_t value
);
57 void (*pb_wreg32
)(int busind
, int devind
, int port
, u32_t value
);
58 u16_t (*pb_rsts
)(int busind
);
59 void (*pb_wsts
)(int busind
, u16_t value
);
61 static int nr_pcibus
= 0;
88 EXTERN
struct pci_acl pci_acl
[NR_DRIVERS
];
91 #define PBF_IO 1 /* I/O else memory */
92 #define PBF_INCOMPLETE 2 /* not allocated */
94 static int nr_pcidev
= 0;
96 static void pci_intel_init(void);
97 static void probe_bus(int busind
);
98 static int is_duplicate(u8_t busnr
, u8_t dev
, u8_t func
);
99 static void record_irq(int devind
);
100 static void record_bars_normal(int devind
);
101 static void record_bars_bridge(int devind
);
102 static void record_bars_cardbus(int devind
);
103 static void record_bars(int devind
, int last_reg
);
104 static int record_bar(int devind
, int bar_nr
, int last
);
105 static void complete_bridges(void);
106 static void complete_bars(void);
107 static void update_bridge4dev_io(int devind
, u32_t io_base
, u32_t
109 static int get_freebus(void);
110 static int do_isabridge(int busind
);
111 static void do_pcibridge(int busind
);
112 static int get_busind(int busnr
);
113 static int do_piix(int devind
);
114 static int do_amd_isabr(int devind
);
115 static int do_sis_isabr(int devind
);
116 static int do_via_isabr(int devind
);
118 static void report_vga(int devind
);
120 static char *pci_vid_name(u16_t vid
);
121 static char *pci_baseclass_name(u8_t baseclass
);
122 static char *pci_subclass_name(u8_t baseclass
, u8_t subclass
, u8_t
124 static void ntostr(unsigned n
, char **str
, const char *end
);
126 static u8_t
pci_attr_r8_u(int devind
, int port
);
127 static u32_t
pci_attr_r32_u(int devind
, int port
);
129 static u16_t
pci_attr_rsts(int devind
);
130 static void pci_attr_wsts(int devind
, u16_t value
);
131 static u16_t
pcibr_std_rsts(int busind
);
132 static void pcibr_std_wsts(int busind
, u16_t value
);
133 static u16_t
pcibr_cb_rsts(int busind
);
134 static void pcibr_cb_wsts(int busind
, u16_t value
);
135 static u16_t
pcibr_via_rsts(int busind
);
136 static void pcibr_via_wsts(int busind
, u16_t value
);
137 static u8_t
pcii_rreg8(int busind
, int devind
, int port
);
138 static u16_t
pcii_rreg16(int busind
, int devind
, int port
);
139 static u32_t
pcii_rreg32(int busind
, int devind
, int port
);
140 static void pcii_wreg8(int busind
, int devind
, int port
, u8_t value
);
141 static void pcii_wreg16(int busind
, int devind
, int port
, u16_t value
);
142 static void pcii_wreg32(int busind
, int devind
, int port
, u32_t value
);
143 static u16_t
pcii_rsts(int busind
);
144 static void pcii_wsts(int busind
, u16_t value
);
145 static void print_capabilities(int devind
);
146 static int visible(struct rs_pci
*aclp
, int devind
);
147 static void print_hyper_cap(int devind
, u8_t capptr
);
149 static struct machine machine
;
150 static endpoint_t acpi_ep
;
152 /*===========================================================================*
153 * sef_cb_init_fresh *
154 *===========================================================================*/
155 int sef_cb_init_fresh(int type
, sef_init_info_t
*info
)
157 /* Initialize the pci driver. */
160 struct rprocpub rprocpub
[NR_BOOT_PROCS
];
163 env_parse("pci_debug", "d", 0, &v
, 0, 1);
166 if (sys_getmachine(&machine
)) {
167 printf("PCI: no machine\n");
170 if (machine
.apic_enabled
&&
171 ds_retrieve_label_endpt("acpi", &acpi_ep
) != OK
) {
172 panic("PCI: Cannot use APIC mode without ACPI!\n");
175 /* Only Intel (compatible) PCI controllers are supported at the
180 /* Map all the services in the boot image. */
181 if((r
= sys_safecopyfrom(RS_PROC_NR
, info
->rproctab_gid
, 0,
182 (vir_bytes
) rprocpub
, sizeof(rprocpub
))) != OK
) {
183 panic("sys_safecopyfrom failed: %d", r
);
185 for(i
=0;i
< NR_BOOT_PROCS
;i
++) {
186 if(rprocpub
[i
].in_use
) {
187 if((r
= map_service(&rprocpub
[i
])) != OK
) {
188 panic("unable to map service: %d", r
);
196 /*===========================================================================*
198 *===========================================================================*/
199 int map_service(rpub
)
200 struct rprocpub
*rpub
;
202 /* Map a new service by registering a new acl entry if required. */
205 /* Stop right now if no pci device or class is found. */
206 if(rpub
->pci_acl
.rsp_nr_device
== 0
207 && rpub
->pci_acl
.rsp_nr_class
== 0) {
211 /* Find a free acl slot. */
212 for (i
= 0; i
<NR_DRIVERS
; i
++)
214 if (!pci_acl
[i
].inuse
)
219 printf("PCI: map_service: table is full\n");
223 /* Initialize acl slot. */
224 pci_acl
[i
].inuse
= 1;
225 pci_acl
[i
].acl
= rpub
->pci_acl
;
230 /*===========================================================================*
231 * helper functions for I/O *
232 *===========================================================================*/
233 unsigned pci_inb(u16_t port
) {
236 if ((s
=sys_inb(port
, &value
)) !=OK
)
237 printf("PCI: warning, sys_inb failed: %d\n", s
);
240 unsigned pci_inw(u16_t port
) {
243 if ((s
=sys_inw(port
, &value
)) !=OK
)
244 printf("PCI: warning, sys_inw failed: %d\n", s
);
247 unsigned pci_inl(u16_t port
) {
250 if ((s
=sys_inl(port
, &value
)) !=OK
)
251 printf("PCI: warning, sys_inl failed: %d\n", s
);
254 void pci_outb(u16_t port
, u8_t value
) {
256 if ((s
=sys_outb(port
, value
)) !=OK
)
257 printf("PCI: warning, sys_outb failed: %d\n", s
);
259 void pci_outw(u16_t port
, u16_t value
) {
261 if ((s
=sys_outw(port
, value
)) !=OK
)
262 printf("PCI: warning, sys_outw failed: %d\n", s
);
264 void pci_outl(u16_t port
, u32_t value
) {
266 if ((s
=sys_outl(port
, value
)) !=OK
)
267 printf("PCI: warning, sys_outl failed: %d\n", s
);
270 /*===========================================================================*
272 *===========================================================================*/
273 int pci_find_dev(u8_t bus
, u8_t dev
, u8_t func
, int *devindp
)
277 for (devind
= 0; devind
< nr_pcidev
; devind
++)
279 if (pcidev
[devind
].pd_busnr
== bus
&&
280 pcidev
[devind
].pd_dev
== dev
&&
281 pcidev
[devind
].pd_func
== func
)
286 if (devind
>= nr_pcidev
)
289 if (pcidev
[devind
].pd_inuse
)
296 /*===========================================================================*
298 *===========================================================================*/
308 for (devind
= 0; devind
< nr_pcidev
; devind
++)
311 if (pcidev
[devind
].pd_inuse
)
314 if (!visible(aclp
, devind
))
318 if (devind
>= nr_pcidev
)
321 *vidp
= pcidev
[devind
].pd_vid
;
322 *didp
= pcidev
[devind
].pd_did
;
326 /*===========================================================================*
328 *===========================================================================*/
338 for (devind
= *devindp
+1; devind
< nr_pcidev
; devind
++)
341 if (pcidev
[devind
].pd_inuse
)
344 if (!visible(aclp
, devind
))
348 if (devind
>= nr_pcidev
)
351 *vidp
= pcidev
[devind
].pd_vid
;
352 *didp
= pcidev
[devind
].pd_did
;
356 /*===========================================================================*
358 *===========================================================================*/
359 int pci_reserve_a(devind
, proc
, aclp
)
367 struct minix_mem_range mr
;
369 if (devind
< 0 || devind
>= nr_pcidev
)
371 printf("pci_reserve_a: bad devind: %d\n", devind
);
374 if (!visible(aclp
, devind
))
376 printf("pci_reserve_a: %u is not allowed to reserve %d\n",
381 if(pcidev
[devind
].pd_inuse
&& pcidev
[devind
].pd_proc
!= proc
)
383 pcidev
[devind
].pd_inuse
= 1;
384 pcidev
[devind
].pd_proc
= proc
;
386 for (i
= 0; i
<pcidev
[devind
].pd_bar_nr
; i
++)
388 if (pcidev
[devind
].pd_bar
[i
].pb_flags
& PBF_INCOMPLETE
)
390 printf("pci_reserve_a: BAR %d is incomplete\n", i
);
393 if (pcidev
[devind
].pd_bar
[i
].pb_flags
& PBF_IO
)
395 ior
.ior_base
= pcidev
[devind
].pd_bar
[i
].pb_base
;
396 ior
.ior_limit
= ior
.ior_base
+
397 pcidev
[devind
].pd_bar
[i
].pb_size
-1;
401 "pci_reserve_a: for proc %d, adding I/O range [0x%x..0x%x]\n",
402 proc
, ior
.ior_base
, ior
.ior_limit
);
404 r
= sys_privctl(proc
, SYS_PRIV_ADD_IO
, &ior
);
407 printf("sys_privctl failed for proc %d: %d\n",
413 mr
.mr_base
= pcidev
[devind
].pd_bar
[i
].pb_base
;
414 mr
.mr_limit
= mr
.mr_base
+
415 pcidev
[devind
].pd_bar
[i
].pb_size
-1;
417 r
= sys_privctl(proc
, SYS_PRIV_ADD_MEM
, &mr
);
420 printf("sys_privctl failed for proc %d: %d\n",
425 ilr
= pcidev
[devind
].pd_ilr
;
426 if (ilr
!= PCI_ILR_UNKNOWN
)
428 if(debug
) printf("pci_reserve_a: adding IRQ %d\n", ilr
);
429 r
= sys_privctl(proc
, SYS_PRIV_ADD_IRQ
, &ilr
);
432 printf("sys_privctl failed for proc %d: %d\n",
440 /*===========================================================================*
442 *===========================================================================*/
443 void pci_release(proc
)
448 for (i
= 0; i
<nr_pcidev
; i
++)
450 if (!pcidev
[i
].pd_inuse
)
452 if (pcidev
[i
].pd_proc
!= proc
)
454 pcidev
[i
].pd_inuse
= 0;
458 /*===========================================================================*
460 *===========================================================================*/
461 int pci_ids_s(int devind
, u16_t
*vidp
, u16_t
*didp
)
463 if (devind
< 0 || devind
>= nr_pcidev
)
466 *vidp
= pcidev
[devind
].pd_vid
;
467 *didp
= pcidev
[devind
].pd_did
;
471 /*===========================================================================*
473 *===========================================================================*/
474 void pci_rescan_bus(u8_t busnr
)
478 busind
= get_busind(busnr
);
481 /* Allocate bus numbers for uninitialized bridges */
484 /* Allocate I/O and memory resources for uninitialized devices */
488 /*===========================================================================*
490 *===========================================================================*/
491 int pci_slot_name_s(devind
, cpp
)
495 static char label
[]= "ddd.ddd.ddd";
499 if (devind
< 0 || devind
>= nr_pcidev
)
503 end
= label
+sizeof(label
);
505 ntostr(pcidev
[devind
].pd_busnr
, &p
, end
);
508 ntostr(pcidev
[devind
].pd_dev
, &p
, end
);
511 ntostr(pcidev
[devind
].pd_func
, &p
, end
);
517 /*===========================================================================*
519 *===========================================================================*/
520 char *pci_dev_name(u16_t vid
, u16_t did
)
524 for (i
= 0; pci_device_table
[i
].name
; i
++)
526 if (pci_device_table
[i
].vid
== vid
&&
527 pci_device_table
[i
].did
== did
)
529 return pci_device_table
[i
].name
;
535 /*===========================================================================*
537 *===========================================================================*/
538 int pci_get_bar_s(int devind
, int port
, u32_t
*base
, u32_t
*size
,
543 if (devind
< 0 || devind
>= nr_pcidev
)
546 for (i
= 0; i
< pcidev
[devind
].pd_bar_nr
; i
++)
548 reg
= PCI_BAR
+4*pcidev
[devind
].pd_bar
[i
].pb_nr
;
552 if (pcidev
[devind
].pd_bar
[i
].pb_flags
& PBF_INCOMPLETE
)
555 *base
= pcidev
[devind
].pd_bar
[i
].pb_base
;
556 *size
= pcidev
[devind
].pd_bar
[i
].pb_size
;
558 !!(pcidev
[devind
].pd_bar
[i
].pb_flags
& PBF_IO
);
565 /*===========================================================================*
567 *===========================================================================*/
568 int pci_attr_r8_s(int devind
, int port
, u8_t
*vp
)
570 if (devind
< 0 || devind
>= nr_pcidev
)
572 if (port
< 0 || port
> 255)
575 *vp
= pci_attr_r8_u(devind
, port
);
579 /*===========================================================================*
581 *===========================================================================*/
582 static u8_t
pci_attr_r8_u(devind
, port
)
588 busnr
= pcidev
[devind
].pd_busnr
;
589 busind
= get_busind(busnr
);
590 return pcibus
[busind
].pb_rreg8(busind
, devind
, port
);
593 /*===========================================================================*
595 *===========================================================================*/
596 u16_t
pci_attr_r16(devind
, port
)
602 busnr
= pcidev
[devind
].pd_busnr
;
603 busind
= get_busind(busnr
);
604 return pcibus
[busind
].pb_rreg16(busind
, devind
, port
);
607 /*===========================================================================*
609 *===========================================================================*/
610 int pci_attr_r32_s(int devind
, int port
, u32_t
*vp
)
612 if (devind
< 0 || devind
>= nr_pcidev
)
614 if (port
< 0 || port
> 256-4)
617 *vp
= pci_attr_r32_u(devind
, port
);
621 /*===========================================================================*
623 *===========================================================================*/
624 static u32_t
pci_attr_r32_u(devind
, port
)
630 busnr
= pcidev
[devind
].pd_busnr
;
631 busind
= get_busind(busnr
);
632 return pcibus
[busind
].pb_rreg32(busind
, devind
, port
);
635 /*===========================================================================*
637 *===========================================================================*/
638 void pci_attr_w8(int devind
, int port
, u8_t value
)
642 busnr
= pcidev
[devind
].pd_busnr
;
643 busind
= get_busind(busnr
);
644 pcibus
[busind
].pb_wreg8(busind
, devind
, port
, value
);
647 /*===========================================================================*
649 *===========================================================================*/
650 void pci_attr_w16(int devind
, int port
, u16_t value
)
654 busnr
= pcidev
[devind
].pd_busnr
;
655 busind
= get_busind(busnr
);
656 pcibus
[busind
].pb_wreg16(busind
, devind
, port
, value
);
659 /*===========================================================================*
661 *===========================================================================*/
662 void pci_attr_w32(int devind
, int port
, u32_t value
)
666 busnr
= pcidev
[devind
].pd_busnr
;
667 busind
= get_busind(busnr
);
668 pcibus
[busind
].pb_wreg32(busind
, devind
, port
, value
);
671 /*===========================================================================*
673 *===========================================================================*/
674 static void pci_intel_init()
676 /* Try to detect a know PCI controller. Read the Vendor ID and
677 * the Device ID for function 0 of device 0.
678 * Two times the value 0xffff suggests a system without a (compatible)
681 u32_t bus
, dev
, func
;
683 int s
, i
, r
, busind
, busnr
;
690 vid
= PCII_RREG16_(bus
, dev
, func
, PCI_VID
);
691 did
= PCII_RREG16_(bus
, dev
, func
, PCI_DID
);
692 if (OK
!= (s
=sys_outl(PCII_CONFADD
, PCII_UNSEL
)))
693 printf("PCI: warning, sys_outl failed: %d\n", s
);
696 if (vid
== 0xffff && did
== 0xffff)
697 return; /* Nothing here */
699 for (i
= 0; pci_intel_ctrl
[i
].vid
; i
++)
701 if (pci_intel_ctrl
[i
].vid
== vid
&&
702 pci_intel_ctrl
[i
].did
== did
)
708 if (!pci_intel_ctrl
[i
].vid
)
710 printf("pci_intel_init (warning): unknown PCI-controller:\n"
711 "\tvendor %04X (%s), device %04X\n",
712 vid
, pci_vid_name(vid
), did
);
716 if (nr_pcibus
>= NR_PCIBUS
)
717 panic("too many PCI busses: %d", nr_pcibus
);
720 pcibus
[busind
].pb_type
= PBT_INTEL_HOST
;
721 pcibus
[busind
].pb_needinit
= 0;
722 pcibus
[busind
].pb_isabridge_dev
= -1;
723 pcibus
[busind
].pb_isabridge_type
= 0;
724 pcibus
[busind
].pb_devind
= -1;
725 pcibus
[busind
].pb_busnr
= 0;
726 pcibus
[busind
].pb_rreg8
= pcii_rreg8
;
727 pcibus
[busind
].pb_rreg16
= pcii_rreg16
;
728 pcibus
[busind
].pb_rreg32
= pcii_rreg32
;
729 pcibus
[busind
].pb_wreg8
= pcii_wreg8
;
730 pcibus
[busind
].pb_wreg16
= pcii_wreg16
;
731 pcibus
[busind
].pb_wreg32
= pcii_wreg32
;
732 pcibus
[busind
].pb_rsts
= pcii_rsts
;
733 pcibus
[busind
].pb_wsts
= pcii_wsts
;
735 dstr
= pci_dev_name(vid
, did
);
737 dstr
= "unknown device";
740 printf("pci_intel_init: %s (%04X/%04X)\n",
746 r
= do_isabridge(busind
);
749 busnr
= pcibus
[busind
].pb_busnr
;
751 /* Disable all devices for this bus */
752 for (i
= 0; i
<nr_pcidev
; i
++)
754 if (pcidev
[i
].pd_busnr
!= busnr
)
756 pcidev
[i
].pd_inuse
= 1;
761 /* Look for PCI bridges */
762 do_pcibridge(busind
);
764 /* Allocate bus numbers for uninitialized bridges */
767 /* Allocate I/O and memory resources for uninitialized devices */
771 /*===========================================================================*
773 *===========================================================================*/
774 static void probe_bus(int busind
)
779 u8_t baseclass
, subclass
, infclass
;
784 printf("probe_bus(%d)\n", busind
);
785 if (nr_pcidev
>= NR_PCIDEV
)
786 panic("too many PCI devices: %d", nr_pcidev
);
789 busnr
= pcibus
[busind
].pb_busnr
;
790 for (dev
= 0; dev
<32; dev
++)
793 for (func
= 0; func
< 8; func
++)
795 pcidev
[devind
].pd_busnr
= busnr
;
796 pcidev
[devind
].pd_dev
= dev
;
797 pcidev
[devind
].pd_func
= func
;
799 pci_attr_wsts(devind
,
800 PSR_SSE
|PSR_RMAS
|PSR_RTAS
);
801 vid
= pci_attr_r16(devind
, PCI_VID
);
802 did
= pci_attr_r16(devind
, PCI_DID
);
803 headt
= pci_attr_r8_u(devind
, PCI_HEADT
);
804 sts
= pci_attr_rsts(devind
);
807 printf("vid 0x%x, did 0x%x, headt 0x%x, sts 0x%x\n",
808 vid
, did
, headt
, sts
);
811 if (vid
== NO_VID
&& did
== NO_VID
)
814 break; /* Nothing here */
816 /* Scan all functions of a multifunction
822 if (sts
& (PSR_SSE
|PSR_RMAS
|PSR_RTAS
))
824 static int warned
= 0;
828 "PCI: ignoring bad value 0x%x in sts for QEMU\n",
829 sts
& (PSR_SSE
|PSR_RMAS
|PSR_RTAS
));
834 dstr
= pci_dev_name(vid
, did
);
839 printf("%d.%lu.%lu: %s (%04X/%04X)\n",
840 busnr
, (unsigned long)dev
,
841 (unsigned long)func
, dstr
,
847 "%d.%lu.%lu: Unknown device, vendor %04X (%s), device %04X\n",
848 busnr
, (unsigned long)dev
,
849 (unsigned long)func
, vid
,
850 pci_vid_name(vid
), did
);
852 printf("Device index: %d\n", devind
);
853 printf("Subsystem: Vid 0x%x, did 0x%x\n",
854 pci_attr_r16(devind
, PCI_SUBVID
),
855 pci_attr_r16(devind
, PCI_SUBDID
));
858 baseclass
= pci_attr_r8_u(devind
, PCI_BCR
);
859 subclass
= pci_attr_r8_u(devind
, PCI_SCR
);
860 infclass
= pci_attr_r8_u(devind
, PCI_PIFR
);
861 s
= pci_subclass_name(baseclass
, subclass
, infclass
);
863 s
= pci_baseclass_name(baseclass
);
866 s
= "(unknown class)";
870 printf("\tclass %s (%X/%X/%X)\n", s
,
871 baseclass
, subclass
, infclass
);
874 if (is_duplicate(busnr
, dev
, func
))
876 printf("\tduplicate!\n");
877 if (func
== 0 && !(headt
& PHT_MULTIFUNC
))
884 pcidev
[devind
].pd_baseclass
= baseclass
;
885 pcidev
[devind
].pd_subclass
= subclass
;
886 pcidev
[devind
].pd_infclass
= infclass
;
887 pcidev
[devind
].pd_vid
= vid
;
888 pcidev
[devind
].pd_did
= did
;
889 pcidev
[devind
].pd_inuse
= 0;
890 pcidev
[devind
].pd_bar_nr
= 0;
892 switch(headt
& PHT_MASK
)
895 record_bars_normal(devind
);
898 record_bars_bridge(devind
);
901 record_bars_cardbus(devind
);
904 printf("\t%d.%d.%d: unknown header type %d\n",
910 print_capabilities(devind
);
912 t3
= ((baseclass
<< 16) | (subclass
<< 8) | infclass
);
914 if (t3
== PCI_T3_VGA
|| t3
== PCI_T3_VGA_OLD
)
918 if (nr_pcidev
>= NR_PCIDEV
)
919 panic("too many PCI devices: %d", nr_pcidev
);
922 if (func
== 0 && !(headt
& PHT_MULTIFUNC
))
928 /*===========================================================================*
930 *===========================================================================*/
931 static int is_duplicate(u8_t busnr
, u8_t dev
, u8_t func
)
935 for (i
= 0; i
<nr_pcidev
; i
++)
937 if (pcidev
[i
].pd_busnr
== busnr
&&
938 pcidev
[i
].pd_dev
== dev
&&
939 pcidev
[i
].pd_func
== func
)
947 static int acpi_get_irq(unsigned bus
, unsigned dev
, unsigned pin
)
952 ((struct acpi_get_irq_req
*)&m
)->hdr
.request
= ACPI_REQ_GET_IRQ
;
953 ((struct acpi_get_irq_req
*)&m
)->bus
= bus
;
954 ((struct acpi_get_irq_req
*)&m
)->dev
= dev
;
955 ((struct acpi_get_irq_req
*)&m
)->pin
= pin
;
957 if ((err
= sendrec(acpi_ep
, &m
)) != OK
)
958 panic("PCI: error %d while receiveing from ACPI\n", err
);
960 return ((struct acpi_get_irq_resp
*)&m
)->irq
;
963 static int derive_irq(struct pcidev
* dev
, int pin
)
965 struct pcidev
* parent_bridge
;
968 parent_bridge
= &pcidev
[pcibus
[get_busind(dev
->pd_busnr
)].pb_devind
];
971 * We don't support PCI-Express, no ARI, decode the slot of the device
972 * and mangle the pin as the device is behind a bridge
974 slot
= ((dev
->pd_func
) >> 3) & 0x1f;
976 return acpi_get_irq(parent_bridge
->pd_busnr
,
977 parent_bridge
->pd_dev
, (pin
+ slot
) % 4);
980 /*===========================================================================*
982 *===========================================================================*/
983 static void record_irq(devind
)
986 int ilr
, ipr
, busnr
, busind
, cb_devind
;
988 ilr
= pci_attr_r8_u(devind
, PCI_ILR
);
989 ipr
= pci_attr_r8_u(devind
, PCI_IPR
);
991 if (ipr
&& machine
.apic_enabled
) {
994 irq
= acpi_get_irq(pcidev
[devind
].pd_busnr
,
995 pcidev
[devind
].pd_dev
, ipr
- 1);
998 irq
= derive_irq(&pcidev
[devind
], ipr
- 1);
1002 pci_attr_w8(devind
, PCI_ILR
, ilr
);
1004 printf("PCI: ACPI IRQ %d for "
1005 "device %d.%d.%d INT%c\n",
1007 pcidev
[devind
].pd_busnr
,
1008 pcidev
[devind
].pd_dev
,
1009 pcidev
[devind
].pd_func
,
1013 printf("PCI: no ACPI IRQ routing for "
1014 "device %d.%d.%d INT%c\n",
1015 pcidev
[devind
].pd_busnr
,
1016 pcidev
[devind
].pd_dev
,
1017 pcidev
[devind
].pd_func
,
1024 static int first
= 1;
1025 if (ipr
&& first
&& debug
)
1028 printf("PCI: strange, BIOS assigned IRQ0\n");
1030 ilr
= PCI_ILR_UNKNOWN
;
1032 pcidev
[devind
].pd_ilr
= ilr
;
1033 if (ilr
== PCI_ILR_UNKNOWN
&& !ipr
)
1036 else if (ilr
!= PCI_ILR_UNKNOWN
&& ipr
)
1039 printf("\tIRQ %d for INT%c\n", ilr
, 'A' + ipr
-1);
1041 else if (ilr
!= PCI_ILR_UNKNOWN
)
1044 "PCI: IRQ %d is assigned, but device %d.%d.%d does not need it\n",
1045 ilr
, pcidev
[devind
].pd_busnr
, pcidev
[devind
].pd_dev
,
1046 pcidev
[devind
].pd_func
);
1050 /* Check for cardbus devices */
1051 busnr
= pcidev
[devind
].pd_busnr
;
1052 busind
= get_busind(busnr
);
1053 if (pcibus
[busind
].pb_type
== PBT_CARDBUS
)
1055 cb_devind
= pcibus
[busind
].pb_devind
;
1056 ilr
= pcidev
[cb_devind
].pd_ilr
;
1057 if (ilr
!= PCI_ILR_UNKNOWN
)
1062 "assigning IRQ %d to Cardbus device\n",
1065 pci_attr_w8(devind
, PCI_ILR
, ilr
);
1066 pcidev
[devind
].pd_ilr
= ilr
;
1072 "PCI: device %d.%d.%d uses INT%c but is not assigned any IRQ\n",
1073 pcidev
[devind
].pd_busnr
, pcidev
[devind
].pd_dev
,
1074 pcidev
[devind
].pd_func
, 'A' + ipr
-1);
1079 /*===========================================================================*
1080 * record_bars_normal *
1081 *===========================================================================*/
1082 static void record_bars_normal(devind
)
1085 int i
, j
, clear_01
, clear_23
, pb_nr
;
1087 /* The BAR area of normal devices is six DWORDs in size. */
1088 record_bars(devind
, PCI_BAR_6
);
1090 /* Special case code for IDE controllers in compatibility mode */
1091 if (pcidev
[devind
].pd_baseclass
== PCI_BCR_MASS_STORAGE
&&
1092 pcidev
[devind
].pd_subclass
== PCI_MS_IDE
)
1097 if (!(pcidev
[devind
].pd_infclass
& PCI_IDE_PRI_NATIVE
))
1102 "primary channel is not in native mode, clearing BARs 0 and 1\n");
1106 if (!(pcidev
[devind
].pd_infclass
& PCI_IDE_SEC_NATIVE
))
1111 "secondary channel is not in native mode, clearing BARs 2 and 3\n");
1117 for (i
= 0; i
<pcidev
[devind
].pd_bar_nr
; i
++)
1119 pb_nr
= pcidev
[devind
].pd_bar
[i
].pb_nr
;
1120 if ((pb_nr
== 0 || pb_nr
== 1) && clear_01
)
1122 if (debug
) printf("skipping bar %d\n", pb_nr
);
1123 continue; /* Skip */
1125 if ((pb_nr
== 2 || pb_nr
== 3) && clear_23
)
1127 if (debug
) printf("skipping bar %d\n", pb_nr
);
1128 continue; /* Skip */
1133 continue; /* No need to copy */
1135 pcidev
[devind
].pd_bar
[j
]=
1136 pcidev
[devind
].pd_bar
[i
];
1139 pcidev
[devind
].pd_bar_nr
= j
;
1143 /*===========================================================================*
1144 * record_bars_bridge *
1145 *===========================================================================*/
1146 static void record_bars_bridge(devind
)
1149 u32_t base
, limit
, size
;
1151 /* The generic BAR area of PCI-to-PCI bridges is two DWORDs in size.
1152 * It may contain up to two 32-bit BARs, or one 64-bit BAR.
1154 record_bars(devind
, PCI_BAR_2
);
1156 base
= ((pci_attr_r8_u(devind
, PPB_IOBASE
) & PPB_IOB_MASK
) << 8) |
1157 (pci_attr_r16(devind
, PPB_IOBASEU16
) << 16);
1159 ((pci_attr_r8_u(devind
, PPB_IOLIMIT
) & PPB_IOL_MASK
) << 8) |
1160 ((~PPB_IOL_MASK
& 0xff) << 8) |
1161 (pci_attr_r16(devind
, PPB_IOLIMITU16
) << 16);
1162 size
= limit
-base
+ 1;
1165 printf("\tI/O window: base 0x%x, limit 0x%x, size %d\n",
1169 base
= ((pci_attr_r16(devind
, PPB_MEMBASE
) & PPB_MEMB_MASK
) << 16);
1171 ((pci_attr_r16(devind
, PPB_MEMLIMIT
) & PPB_MEML_MASK
) << 16) |
1172 ((~PPB_MEML_MASK
& 0xffff) << 16);
1173 size
= limit
-base
+ 1;
1176 printf("\tMemory window: base 0x%x, limit 0x%x, size 0x%x\n",
1180 /* Ignore the upper 32 bits */
1181 base
= ((pci_attr_r16(devind
, PPB_PFMEMBASE
) & PPB_PFMEMB_MASK
) << 16);
1183 ((pci_attr_r16(devind
, PPB_PFMEMLIMIT
) &
1184 PPB_PFMEML_MASK
) << 16) |
1185 ((~PPB_PFMEML_MASK
& 0xffff) << 16);
1186 size
= limit
-base
+ 1;
1190 "\tPrefetchable memory window: base 0x%x, limit 0x%x, size 0x%x\n",
1195 /*===========================================================================*
1196 * record_bars_cardbus *
1197 *===========================================================================*/
1198 static void record_bars_cardbus(devind
)
1201 u32_t base
, limit
, size
;
1203 /* The generic BAR area of CardBus devices is one DWORD in size. */
1204 record_bars(devind
, PCI_BAR
);
1206 base
= pci_attr_r32_u(devind
, CBB_MEMBASE_0
);
1207 limit
= pci_attr_r32_u(devind
, CBB_MEMLIMIT_0
) |
1208 (~CBB_MEML_MASK
& 0xffffffff);
1209 size
= limit
-base
+ 1;
1212 printf("\tMemory window 0: base 0x%x, limit 0x%x, size %d\n",
1216 base
= pci_attr_r32_u(devind
, CBB_MEMBASE_1
);
1217 limit
= pci_attr_r32_u(devind
, CBB_MEMLIMIT_1
) |
1218 (~CBB_MEML_MASK
& 0xffffffff);
1219 size
= limit
-base
+ 1;
1222 printf("\tMemory window 1: base 0x%x, limit 0x%x, size %d\n",
1226 base
= pci_attr_r32_u(devind
, CBB_IOBASE_0
);
1227 limit
= pci_attr_r32_u(devind
, CBB_IOLIMIT_0
) |
1228 (~CBB_IOL_MASK
& 0xffffffff);
1229 size
= limit
-base
+ 1;
1232 printf("\tI/O window 0: base 0x%x, limit 0x%x, size %d\n",
1236 base
= pci_attr_r32_u(devind
, CBB_IOBASE_1
);
1237 limit
= pci_attr_r32_u(devind
, CBB_IOLIMIT_1
) |
1238 (~CBB_IOL_MASK
& 0xffffffff);
1239 size
= limit
-base
+ 1;
1242 printf("\tI/O window 1: base 0x%x, limit 0x%x, size %d\n",
1247 /*===========================================================================*
1249 *===========================================================================*/
1250 static void record_bars(int devind
, int last_reg
)
1254 for (i
= 0, reg
= PCI_BAR
; reg
<= last_reg
; i
+= width
, reg
+= 4 * width
)
1256 width
= record_bar(devind
, i
, reg
== last_reg
);
1260 /*===========================================================================*
1262 *===========================================================================*/
1263 static int record_bar(devind
, bar_nr
, last
)
1268 int reg
, prefetch
, type
, dev_bar_nr
, width
;
1272 /* Start by assuming that this is a 32-bit bar, taking up one DWORD. */
1275 reg
= PCI_BAR
+4*bar_nr
;
1277 bar
= pci_attr_r32_u(devind
, reg
);
1278 if (bar
& PCI_BAR_IO
)
1280 /* Disable I/O access before probing for BAR's size */
1281 cmd
= pci_attr_r16(devind
, PCI_CR
);
1282 pci_attr_w16(devind
, PCI_CR
, cmd
& ~PCI_CR_IO_EN
);
1284 /* Probe BAR's size */
1285 pci_attr_w32(devind
, reg
, 0xffffffff);
1286 bar2
= pci_attr_r32_u(devind
, reg
);
1288 /* Restore original state */
1289 pci_attr_w32(devind
, reg
, bar
);
1290 pci_attr_w16(devind
, PCI_CR
, cmd
);
1292 bar
&= PCI_BAR_IO_MASK
; /* Clear non-address bits */
1293 bar2
&= PCI_BAR_IO_MASK
;
1294 bar2
= (~bar2
& 0xffff)+1;
1297 printf("\tbar_%d: %d bytes at 0x%x I/O\n",
1301 dev_bar_nr
= pcidev
[devind
].pd_bar_nr
++;
1302 pcidev
[devind
].pd_bar
[dev_bar_nr
].pb_flags
= PBF_IO
;
1303 pcidev
[devind
].pd_bar
[dev_bar_nr
].pb_base
= bar
;
1304 pcidev
[devind
].pd_bar
[dev_bar_nr
].pb_size
= bar2
;
1305 pcidev
[devind
].pd_bar
[dev_bar_nr
].pb_nr
= bar_nr
;
1308 pcidev
[devind
].pd_bar
[dev_bar_nr
].pb_flags
|=
1314 type
= (bar
& PCI_BAR_TYPE
);
1318 case PCI_TYPE_32_1M
:
1322 /* A 64-bit BAR takes up two consecutive DWORDs. */
1325 printf("PCI: device %d.%d.%d BAR %d extends"
1326 " beyond designated area\n",
1327 pcidev
[devind
].pd_busnr
,
1328 pcidev
[devind
].pd_dev
,
1329 pcidev
[devind
].pd_func
, bar_nr
);
1335 bar2
= pci_attr_r32_u(devind
, reg
+4);
1337 /* If the upper 32 bits of the BAR are not zero, the
1338 * memory is inaccessible to us; ignore the BAR.
1344 printf("\tbar_%d: (64-bit BAR with"
1345 " high bits set)\n", bar_nr
);
1354 /* Ignore the BAR. */
1357 printf("\tbar_%d: (unknown type %x)\n",
1364 /* Disable mem access before probing for BAR's size */
1365 cmd
= pci_attr_r16(devind
, PCI_CR
);
1366 pci_attr_w16(devind
, PCI_CR
, cmd
& ~PCI_CR_MEM_EN
);
1368 /* Probe BAR's size */
1369 pci_attr_w32(devind
, reg
, 0xffffffff);
1370 bar2
= pci_attr_r32_u(devind
, reg
);
1372 /* Restore original values */
1373 pci_attr_w32(devind
, reg
, bar
);
1374 pci_attr_w16(devind
, PCI_CR
, cmd
);
1377 return width
; /* Reg. is not implemented */
1379 prefetch
= !!(bar
& PCI_BAR_PREFETCH
);
1380 bar
&= PCI_BAR_MEM_MASK
; /* Clear non-address bits */
1381 bar2
&= PCI_BAR_MEM_MASK
;
1385 printf("\tbar_%d: 0x%x bytes at 0x%x%s memory%s\n",
1387 prefetch
? " prefetchable" : "",
1388 type
== PCI_TYPE_64
? ", 64-bit" : "");
1391 dev_bar_nr
= pcidev
[devind
].pd_bar_nr
++;
1392 pcidev
[devind
].pd_bar
[dev_bar_nr
].pb_flags
= 0;
1393 pcidev
[devind
].pd_bar
[dev_bar_nr
].pb_base
= bar
;
1394 pcidev
[devind
].pd_bar
[dev_bar_nr
].pb_size
= bar2
;
1395 pcidev
[devind
].pd_bar
[dev_bar_nr
].pb_nr
= bar_nr
;
1398 pcidev
[devind
].pd_bar
[dev_bar_nr
].pb_flags
|=
1406 /*===========================================================================*
1407 * complete_bridges *
1408 *===========================================================================*/
1409 static void complete_bridges()
1411 int i
, freebus
, devind
, prim_busnr
;
1413 for (i
= 0; i
<nr_pcibus
; i
++)
1415 if (!pcibus
[i
].pb_needinit
)
1417 printf("should allocate bus number for bus %d\n", i
);
1418 freebus
= get_freebus();
1419 printf("got bus number %d\n", freebus
);
1421 devind
= pcibus
[i
].pb_devind
;
1423 prim_busnr
= pcidev
[devind
].pd_busnr
;
1424 if (prim_busnr
!= 0)
1427 "complete_bridge: updating subordinate bus number not implemented\n");
1430 pcibus
[i
].pb_needinit
= 0;
1431 pcibus
[i
].pb_busnr
= freebus
;
1433 printf("devind = %d\n", devind
);
1434 printf("prim_busnr= %d\n", prim_busnr
);
1436 pci_attr_w8(devind
, PPB_PRIMBN
, prim_busnr
);
1437 pci_attr_w8(devind
, PPB_SECBN
, freebus
);
1438 pci_attr_w8(devind
, PPB_SUBORDBN
, freebus
);
1440 printf("CR = 0x%x\n", pci_attr_r16(devind
, PCI_CR
));
1441 printf("SECBLT = 0x%x\n", pci_attr_r8_u(devind
, PPB_SECBLT
));
1442 printf("BRIDGECTRL = 0x%x\n",
1443 pci_attr_r16(devind
, PPB_BRIDGECTRL
));
1447 /*===========================================================================*
1449 *===========================================================================*/
1450 static void complete_bars(void)
1452 int i
, j
, bar_nr
, reg
;
1453 u32_t memgap_low
, memgap_high
, iogap_low
, iogap_high
, io_high
,
1454 base
, size
, v32
, diff1
, diff2
;
1457 if(OK
!= sys_getkinfo(&kinfo
))
1458 panic("can't get kinfo");
1460 /* Set memgap_low to just above physical memory */
1461 memgap_low
= kinfo
.mem_high_phys
;
1462 memgap_high
= 0xfe000000; /* Leave space for the CPU (APIC) */
1466 printf("complete_bars: initial gap: [0x%x .. 0x%x>\n",
1467 memgap_low
, memgap_high
);
1470 /* Find the lowest memory base */
1471 for (i
= 0; i
<nr_pcidev
; i
++)
1473 for (j
= 0; j
<pcidev
[i
].pd_bar_nr
; j
++)
1475 if (pcidev
[i
].pd_bar
[j
].pb_flags
& PBF_IO
)
1477 if (pcidev
[i
].pd_bar
[j
].pb_flags
& PBF_INCOMPLETE
)
1479 base
= pcidev
[i
].pd_bar
[j
].pb_base
;
1480 size
= pcidev
[i
].pd_bar
[j
].pb_size
;
1482 if (base
>= memgap_high
)
1483 continue; /* Not in the gap */
1484 if (base
+size
<= memgap_low
)
1485 continue; /* Not in the gap */
1487 /* Reduce the gap by the smallest amount */
1488 diff1
= base
+size
-memgap_low
;
1489 diff2
= memgap_high
-base
;
1492 memgap_low
= base
+size
;
1500 printf("complete_bars: intermediate gap: [0x%x .. 0x%x>\n",
1501 memgap_low
, memgap_high
);
1504 /* Should check main memory size */
1505 if (memgap_high
< memgap_low
)
1507 printf("PCI: bad memory gap: [0x%x .. 0x%x>\n",
1508 memgap_low
, memgap_high
);
1512 iogap_high
= 0x10000;
1515 /* Find the free I/O space */
1516 for (i
= 0; i
<nr_pcidev
; i
++)
1518 for (j
= 0; j
<pcidev
[i
].pd_bar_nr
; j
++)
1520 if (!(pcidev
[i
].pd_bar
[j
].pb_flags
& PBF_IO
))
1522 if (pcidev
[i
].pd_bar
[j
].pb_flags
& PBF_INCOMPLETE
)
1524 base
= pcidev
[i
].pd_bar
[j
].pb_base
;
1525 size
= pcidev
[i
].pd_bar
[j
].pb_size
;
1526 if (base
>= iogap_high
)
1528 if (base
+size
<= iogap_low
)
1534 "pci device %d (%04x/%04x), bar %d: base 0x%x, size 0x%x\n",
1535 i
, pcidev
[i
].pd_vid
, pcidev
[i
].pd_did
,
1539 if (base
+size
-iogap_low
< iogap_high
-base
)
1540 iogap_low
= base
+size
;
1546 if (iogap_high
< iogap_low
)
1550 printf("iogap_high too low, should panic\n");
1553 panic("iogap_high too low: %d", iogap_high
);
1556 printf("I/O range = [0x%x..0x%x>\n", iogap_low
, iogap_high
);
1558 for (i
= 0; i
<nr_pcidev
; i
++)
1560 for (j
= 0; j
<pcidev
[i
].pd_bar_nr
; j
++)
1562 if (pcidev
[i
].pd_bar
[j
].pb_flags
& PBF_IO
)
1564 if (!(pcidev
[i
].pd_bar
[j
].pb_flags
& PBF_INCOMPLETE
))
1566 size
= pcidev
[i
].pd_bar
[j
].pb_size
;
1567 if (size
< I386_PAGE_SIZE
)
1568 size
= I386_PAGE_SIZE
;
1569 base
= memgap_high
-size
;
1570 base
&= ~(u32_t
)(size
-1);
1571 if (base
< memgap_low
)
1572 panic("memory base too low: %d", base
);
1574 bar_nr
= pcidev
[i
].pd_bar
[j
].pb_nr
;
1575 reg
= PCI_BAR
+ 4*bar_nr
;
1576 v32
= pci_attr_r32_u(i
, reg
);
1577 pci_attr_w32(i
, reg
, v32
| base
);
1581 "complete_bars: allocated 0x%x size %d to %d.%d.%d, bar_%d\n",
1582 base
, size
, pcidev
[i
].pd_busnr
,
1583 pcidev
[i
].pd_dev
, pcidev
[i
].pd_func
,
1586 pcidev
[i
].pd_bar
[j
].pb_base
= base
;
1587 pcidev
[i
].pd_bar
[j
].pb_flags
&= ~PBF_INCOMPLETE
;
1590 io_high
= iogap_high
;
1591 for (j
= 0; j
<pcidev
[i
].pd_bar_nr
; j
++)
1593 if (!(pcidev
[i
].pd_bar
[j
].pb_flags
& PBF_IO
))
1595 if (!(pcidev
[i
].pd_bar
[j
].pb_flags
& PBF_INCOMPLETE
))
1597 size
= pcidev
[i
].pd_bar
[j
].pb_size
;
1598 base
= iogap_high
-size
;
1599 base
&= ~(u32_t
)(size
-1);
1601 /* Assume that ISA compatibility is required. Only
1602 * use the lowest 256 bytes out of every 1024 bytes.
1606 if (base
< iogap_low
)
1607 panic("I/O base too low: %d", base
);
1610 bar_nr
= pcidev
[i
].pd_bar
[j
].pb_nr
;
1611 reg
= PCI_BAR
+ 4*bar_nr
;
1612 v32
= pci_attr_r32_u(i
, reg
);
1613 pci_attr_w32(i
, reg
, v32
| base
);
1617 "complete_bars: allocated 0x%x size %d to %d.%d.%d, bar_%d\n",
1618 base
, size
, pcidev
[i
].pd_busnr
,
1619 pcidev
[i
].pd_dev
, pcidev
[i
].pd_func
,
1622 pcidev
[i
].pd_bar
[j
].pb_base
= base
;
1623 pcidev
[i
].pd_bar
[j
].pb_flags
&= ~PBF_INCOMPLETE
;
1626 if (iogap_high
!= io_high
)
1628 update_bridge4dev_io(i
, iogap_high
,
1629 io_high
-iogap_high
);
1633 for (i
= 0; i
<nr_pcidev
; i
++)
1635 for (j
= 0; j
<pcidev
[i
].pd_bar_nr
; j
++)
1637 if (!(pcidev
[i
].pd_bar
[j
].pb_flags
& PBF_INCOMPLETE
))
1639 printf("should allocate resources for device %d\n", i
);
1645 /*===========================================================================*
1646 * update_bridge4dev_io *
1647 *===========================================================================*/
1648 static void update_bridge4dev_io(
1654 int busnr
, busind
, type
, br_devind
;
1657 busnr
= pcidev
[devind
].pd_busnr
;
1658 busind
= get_busind(busnr
);
1659 type
= pcibus
[busind
].pb_type
;
1660 if (type
== PBT_INTEL_HOST
)
1661 return; /* Nothing to do for host controller */
1662 if (type
== PBT_PCIBRIDGE
)
1665 "update_bridge4dev_io: not implemented for PCI bridges\n");
1668 if (type
!= PBT_CARDBUS
)
1669 panic("update_bridge4dev_io: strange bus type: %d", type
);
1673 printf("update_bridge4dev_io: adding 0x%x at 0x%x\n",
1676 br_devind
= pcibus
[busind
].pb_devind
;
1677 pci_attr_w32(br_devind
, CBB_IOLIMIT_0
, io_base
+io_size
-1);
1678 pci_attr_w32(br_devind
, CBB_IOBASE_0
, io_base
);
1680 /* Enable I/O access. Enable busmaster access as well. */
1681 v16
= pci_attr_r16(devind
, PCI_CR
);
1682 pci_attr_w16(devind
, PCI_CR
, v16
| PCI_CR_IO_EN
| PCI_CR_MAST_EN
);
1685 /*===========================================================================*
1687 *===========================================================================*/
1688 static int get_freebus()
1693 for (i
= 0; i
<nr_pcibus
; i
++)
1695 if (pcibus
[i
].pb_needinit
)
1697 if (pcibus
[i
].pb_type
== PBT_INTEL_HOST
)
1699 if (pcibus
[i
].pb_busnr
<= freebus
)
1700 freebus
= pcibus
[i
].pb_busnr
+1;
1701 printf("get_freebus: should check suboridinate bus number\n");
1706 /*===========================================================================*
1708 *===========================================================================*/
1709 static int do_isabridge(busind
)
1712 int i
, j
, r
, type
, busnr
, unknown_bridge
, bridge_dev
;
1720 vid
= did
= 0; /* lint */
1721 busnr
= pcibus
[busind
].pb_busnr
;
1722 for (i
= 0; i
< nr_pcidev
; i
++)
1724 if (pcidev
[i
].pd_busnr
!= busnr
)
1726 t3
= ((pcidev
[i
].pd_baseclass
<< 16) |
1727 (pcidev
[i
].pd_subclass
<< 8) | pcidev
[i
].pd_infclass
);
1728 if (t3
== PCI_T3_ISA
)
1730 /* ISA bridge. Report if no supported bridge is
1736 vid
= pcidev
[i
].pd_vid
;
1737 did
= pcidev
[i
].pd_did
;
1738 for (j
= 0; pci_isabridge
[j
].vid
!= 0; j
++)
1740 if (pci_isabridge
[j
].vid
!= vid
)
1742 if (pci_isabridge
[j
].did
!= did
)
1744 if (pci_isabridge
[j
].checkclass
&&
1745 unknown_bridge
!= i
)
1747 /* This part of multifunction device is
1754 if (pci_isabridge
[j
].vid
)
1761 if (bridge_dev
!= -1)
1763 dstr
= pci_dev_name(vid
, did
);
1765 dstr
= "unknown device";
1768 printf("found ISA bridge (%04X/%04X) %s\n",
1771 pcibus
[busind
].pb_isabridge_dev
= bridge_dev
;
1772 type
= pci_isabridge
[j
].type
;
1773 pcibus
[busind
].pb_isabridge_type
= type
;
1777 r
= do_piix(bridge_dev
);
1780 r
= do_via_isabr(bridge_dev
);
1783 r
= do_amd_isabr(bridge_dev
);
1786 r
= do_sis_isabr(bridge_dev
);
1789 panic("unknown ISA bridge type: %d", type
);
1794 if (unknown_bridge
== -1)
1798 printf("(warning) no ISA bridge found on bus %d\n",
1806 "(warning) unsupported ISA bridge %04X/%04X for bus %d\n",
1807 pcidev
[unknown_bridge
].pd_vid
,
1808 pcidev
[unknown_bridge
].pd_did
, busind
);
1814 * tells acpi which two busses are connected by this bridge. The primary bus
1815 * (pbnr) must be already known to acpi and it must map dev as the connection to
1816 * the secondary (sbnr) bus
1818 static void acpi_map_bridge(unsigned pbnr
, unsigned dev
, unsigned sbnr
)
1823 ((struct acpi_map_bridge_req
*)&m
)->hdr
.request
= ACPI_REQ_MAP_BRIDGE
;
1824 ((struct acpi_map_bridge_req
*)&m
)->primary_bus
= pbnr
;
1825 ((struct acpi_map_bridge_req
*)&m
)->secondary_bus
= sbnr
;
1826 ((struct acpi_map_bridge_req
*)&m
)->device
= dev
;
1828 if ((err
= sendrec(acpi_ep
, &m
)) != OK
)
1829 panic("PCI: error %d while receiveing from ACPI\n", err
);
1831 if (((struct acpi_map_bridge_resp
*)&m
)->err
!= OK
)
1832 printf("PCI: acpi failed to map pci (%d) to pci (%d) bridge\n",
1836 /*===========================================================================*
1838 *===========================================================================*/
1839 static void do_pcibridge(busind
)
1842 int i
, devind
, busnr
;
1845 u8_t sbusn
, baseclass
, subclass
, infclass
, headt
;
1848 vid
= did
= 0; /* lint */
1849 busnr
= pcibus
[busind
].pb_busnr
;
1850 for (devind
= 0; devind
< nr_pcidev
; devind
++)
1853 printf("do_pcibridge: trying %u.%u.%u\n",
1854 pcidev
[devind
].pd_busnr
, pcidev
[devind
].pd_dev
,
1855 pcidev
[devind
].pd_func
);
1858 if (pcidev
[devind
].pd_busnr
!= busnr
)
1861 printf("wrong bus\n");
1866 vid
= pcidev
[devind
].pd_vid
;
1867 did
= pcidev
[devind
].pd_did
;
1868 for (i
= 0; pci_pcibridge
[i
].vid
!= 0; i
++)
1870 if (pci_pcibridge
[i
].vid
!= vid
)
1872 if (pci_pcibridge
[i
].did
!= did
)
1876 type
= pci_pcibridge
[i
].type
;
1877 if (pci_pcibridge
[i
].vid
== 0)
1879 headt
= pci_attr_r8_u(devind
, PCI_HEADT
);
1881 if ((headt
& PHT_MASK
) == PHT_BRIDGE
)
1883 else if ((headt
& PHT_MASK
) == PHT_CARDBUS
)
1888 printf("not a bridge\n");
1890 continue; /* Not a bridge */
1893 baseclass
= pci_attr_r8_u(devind
, PCI_BCR
);
1894 subclass
= pci_attr_r8_u(devind
, PCI_SCR
);
1895 infclass
= pci_attr_r8_u(devind
, PCI_PIFR
);
1896 t3
= ((baseclass
<< 16) | (subclass
<< 8) | infclass
);
1897 if (type
== PCI_PPB_STD
&&
1898 t3
!= PCI_T3_PCI2PCI
&&
1899 t3
!= PCI_T3_PCI2PCI_SUBTR
)
1902 "Unknown PCI class %02x:%02x:%02x for PCI-to-PCI bridge, device %04X/%04X\n",
1903 baseclass
, subclass
, infclass
,
1907 if (type
== PCI_PPB_CB
&&
1908 t3
!= PCI_T3_CARDBUS
)
1911 "Unknown PCI class %02x:%02x:%02x for Cardbus bridge, device %04X/%04X\n",
1912 baseclass
, subclass
, infclass
,
1920 printf("%u.%u.%u: PCI-to-PCI bridge: %04X/%04X\n",
1921 pcidev
[devind
].pd_busnr
,
1922 pcidev
[devind
].pd_dev
,
1923 pcidev
[devind
].pd_func
, vid
, did
);
1926 /* Assume that the BIOS initialized the secondary bus
1929 sbusn
= pci_attr_r8_u(devind
, PPB_SECBN
);
1931 if (nr_pcibus
>= NR_PCIBUS
)
1932 panic("too many PCI busses: %d", nr_pcibus
);
1935 pcibus
[ind
].pb_type
= PBT_PCIBRIDGE
;
1936 pcibus
[ind
].pb_needinit
= 1;
1937 pcibus
[ind
].pb_isabridge_dev
= -1;
1938 pcibus
[ind
].pb_isabridge_type
= 0;
1939 pcibus
[ind
].pb_devind
= devind
;
1940 pcibus
[ind
].pb_busnr
= sbusn
;
1941 pcibus
[ind
].pb_rreg8
= pcibus
[busind
].pb_rreg8
;
1942 pcibus
[ind
].pb_rreg16
= pcibus
[busind
].pb_rreg16
;
1943 pcibus
[ind
].pb_rreg32
= pcibus
[busind
].pb_rreg32
;
1944 pcibus
[ind
].pb_wreg8
= pcibus
[busind
].pb_wreg8
;
1945 pcibus
[ind
].pb_wreg16
= pcibus
[busind
].pb_wreg16
;
1946 pcibus
[ind
].pb_wreg32
= pcibus
[busind
].pb_wreg32
;
1950 pcibus
[ind
].pb_rsts
= pcibr_std_rsts
;
1951 pcibus
[ind
].pb_wsts
= pcibr_std_wsts
;
1954 pcibus
[ind
].pb_type
= PBT_CARDBUS
;
1955 pcibus
[ind
].pb_rsts
= pcibr_cb_rsts
;
1956 pcibus
[ind
].pb_wsts
= pcibr_cb_wsts
;
1959 pcibus
[ind
].pb_rsts
= pcibr_via_rsts
;
1960 pcibus
[ind
].pb_wsts
= pcibr_via_wsts
;
1963 panic("unknown PCI-PCI bridge type: %d", type
);
1966 if (machine
.apic_enabled
)
1967 acpi_map_bridge(pcidev
[devind
].pd_busnr
,
1968 pcidev
[devind
].pd_dev
, sbusn
);
1973 "bus(table) = %d, bus(sec) = %d, bus(subord) = %d\n",
1974 ind
, sbusn
, pci_attr_r8_u(devind
, PPB_SUBORDBN
));
1978 printf("Secondary bus number not initialized\n");
1981 pcibus
[ind
].pb_needinit
= 0;
1985 /* Look for PCI bridges */
1990 /*===========================================================================*
1992 *===========================================================================*/
1993 static int get_busind(busnr
)
1998 for (i
= 0; i
<nr_pcibus
; i
++)
2000 if (pcibus
[i
].pb_busnr
== busnr
)
2003 panic("get_busind: can't find bus: %d", busnr
);
2006 /*===========================================================================*
2008 *===========================================================================*/
2009 static int do_piix(int devind
)
2011 int i
, s
, irqrc
, irq
;
2012 u32_t elcr1
, elcr2
, elcr
;
2015 printf("in piix\n");
2017 if (OK
!= (s
=sys_inb(PIIX_ELCR1
, &elcr1
)))
2018 printf("Warning, sys_inb failed: %d\n", s
);
2019 if (OK
!= (s
=sys_inb(PIIX_ELCR2
, &elcr2
)))
2020 printf("Warning, sys_inb failed: %d\n", s
);
2021 elcr
= elcr1
| (elcr2
<< 8);
2022 for (i
= 0; i
<4; i
++)
2024 irqrc
= pci_attr_r8_u(devind
, PIIX_PIRQRCA
+i
);
2025 if (irqrc
& PIIX_IRQ_DI
)
2028 printf("INT%c: disabled\n", 'A'+i
);
2032 irq
= irqrc
& PIIX_IRQ_MASK
;
2034 printf("INT%c: %d\n", 'A'+i
, irq
);
2035 if (!(elcr
& (1 << irq
)))
2040 "(warning) IRQ %d is not level triggered\n",
2050 /*===========================================================================*
2052 *===========================================================================*/
2053 static int do_amd_isabr(int devind
)
2055 int i
, busnr
, dev
, func
, xdevind
, irq
, edge
;
2059 /* Find required function */
2060 func
= AMD_ISABR_FUNC
;
2061 busnr
= pcidev
[devind
].pd_busnr
;
2062 dev
= pcidev
[devind
].pd_dev
;
2064 /* Fake a device with the required function */
2065 if (nr_pcidev
>= NR_PCIDEV
)
2066 panic("too many PCI devices: %d", nr_pcidev
);
2068 pcidev
[xdevind
].pd_busnr
= busnr
;
2069 pcidev
[xdevind
].pd_dev
= dev
;
2070 pcidev
[xdevind
].pd_func
= func
;
2071 pcidev
[xdevind
].pd_inuse
= 1;
2074 levmask
= pci_attr_r8_u(xdevind
, AMD_ISABR_PCIIRQ_LEV
);
2075 pciirq
= pci_attr_r16(xdevind
, AMD_ISABR_PCIIRQ_ROUTE
);
2076 for (i
= 0; i
<4; i
++)
2078 edge
= (levmask
>> i
) & 1;
2079 irq
= (pciirq
>> (4*i
)) & 0xf;
2083 printf("INT%c: disabled\n", 'A'+i
);
2088 printf("INT%c: %d\n", 'A'+i
, irq
);
2092 "(warning) IRQ %d is not level triggered\n",
2102 /*===========================================================================*
2104 *===========================================================================*/
2105 static int do_sis_isabr(int devind
)
2110 for (i
= 0; i
<4; i
++)
2112 irq
= pci_attr_r8_u(devind
, SIS_ISABR_IRQ_A
+i
);
2113 if (irq
& SIS_IRQ_DISABLED
)
2116 printf("INT%c: disabled\n", 'A'+i
);
2120 irq
&= SIS_IRQ_MASK
;
2122 printf("INT%c: %d\n", 'A'+i
, irq
);
2129 /*===========================================================================*
2131 *===========================================================================*/
2132 static int do_via_isabr(int devind
)
2137 levmask
= pci_attr_r8_u(devind
, VIA_ISABR_EL
);
2140 for (i
= 0; i
<4; i
++)
2145 edge
= (levmask
& VIA_ISABR_EL_INTA
);
2146 irq
= pci_attr_r8_u(devind
, VIA_ISABR_IRQ_R2
) >> 4;
2149 edge
= (levmask
& VIA_ISABR_EL_INTB
);
2150 irq
= pci_attr_r8_u(devind
, VIA_ISABR_IRQ_R2
);
2153 edge
= (levmask
& VIA_ISABR_EL_INTC
);
2154 irq
= pci_attr_r8_u(devind
, VIA_ISABR_IRQ_R3
) >> 4;
2157 edge
= (levmask
& VIA_ISABR_EL_INTD
);
2158 irq
= pci_attr_r8_u(devind
, VIA_ISABR_IRQ_R1
) >> 4;
2167 printf("INT%c: disabled\n", 'A'+i
);
2172 printf("INT%c: %d\n", 'A'+i
, irq
);
2176 "(warning) IRQ %d is not level triggered\n",
2187 /*===========================================================================*
2189 *===========================================================================*/
2190 static void report_vga(devind
)
2193 /* Report the amount of video memory. This is needed by the X11R6
2194 * postinstall script to chmem the X server. Hopefully this can be
2195 * removed when we get virtual memory.
2197 size_t amount
, size
;
2201 for (i
= 0; i
<pcidev
[devind
].pd_bar_nr
; i
++)
2203 if (pcidev
[devind
].pd_bar
[i
].pb_flags
& PBF_IO
)
2205 size
= pcidev
[devind
].pd_bar
[i
].pb_size
;
2212 printf("PCI: video memory for device at %d.%d.%d: %d bytes\n",
2213 pcidev
[devind
].pd_busnr
,
2214 pcidev
[devind
].pd_dev
,
2215 pcidev
[devind
].pd_func
,
2222 /*===========================================================================*
2224 *===========================================================================*/
2225 static char *pci_vid_name(u16_t vid
)
2229 for (i
= 0; pci_vendor_table
[i
].name
; i
++)
2231 if (pci_vendor_table
[i
].vid
== vid
)
2232 return pci_vendor_table
[i
].name
;
2237 /*===========================================================================*
2238 * pci_baseclass_name *
2239 *===========================================================================*/
2240 static char *pci_baseclass_name(u8_t baseclass
)
2244 for (i
= 0; pci_baseclass_table
[i
].name
; i
++)
2246 if (pci_baseclass_table
[i
].baseclass
== baseclass
)
2247 return pci_baseclass_table
[i
].name
;
2252 /*===========================================================================*
2253 * pci_subclass_name *
2254 *===========================================================================*/
2255 static char *pci_subclass_name(u8_t baseclass
, u8_t subclass
, u8_t infclass
)
2259 for (i
= 0; pci_subclass_table
[i
].name
; i
++)
2261 if (pci_subclass_table
[i
].baseclass
!= baseclass
)
2263 if (pci_subclass_table
[i
].subclass
!= subclass
)
2265 if (pci_subclass_table
[i
].infclass
!= infclass
&&
2266 pci_subclass_table
[i
].infclass
!= (u16_t
)-1)
2270 return pci_subclass_table
[i
].name
;
2275 /*===========================================================================*
2277 *===========================================================================*/
2278 static void ntostr(n
, str
, end
)
2295 tmpstr
[i
]= '0' + (n
%10);
2314 /*===========================================================================*
2316 *===========================================================================*/
2317 static u16_t
pci_attr_rsts(devind
)
2322 busnr
= pcidev
[devind
].pd_busnr
;
2323 busind
= get_busind(busnr
);
2324 return pcibus
[busind
].pb_rsts(busind
);
2328 /*===========================================================================*
2330 *===========================================================================*/
2331 static u16_t
pcibr_std_rsts(busind
)
2336 devind
= pcibus
[busind
].pb_devind
;
2337 return pci_attr_r16(devind
, PPB_SSTS
);
2340 /*===========================================================================*
2342 *===========================================================================*/
2343 static void pcibr_std_wsts(int busind
, u16_t value
)
2346 devind
= pcibus
[busind
].pb_devind
;
2349 printf("pcibr_std_wsts(%d, 0x%X), devind= %d\n",
2350 busind
, value
, devind
);
2352 pci_attr_w16(devind
, PPB_SSTS
, value
);
2355 /*===========================================================================*
2357 *===========================================================================*/
2358 static u16_t
pcibr_cb_rsts(busind
)
2362 devind
= pcibus
[busind
].pb_devind
;
2364 return pci_attr_r16(devind
, CBB_SSTS
);
2367 /*===========================================================================*
2369 *===========================================================================*/
2370 static void pcibr_cb_wsts(int busind
, u16_t value
)
2373 devind
= pcibus
[busind
].pb_devind
;
2376 printf("pcibr_cb_wsts(%d, 0x%X), devind= %d\n",
2377 busind
, value
, devind
);
2379 pci_attr_w16(devind
, CBB_SSTS
, value
);
2382 /*===========================================================================*
2384 *===========================================================================*/
2385 static u16_t
pcibr_via_rsts(int busind
)
2390 /*===========================================================================*
2392 *===========================================================================*/
2393 static void pcibr_via_wsts(int busind
, u16_t value
)
2396 devind
= pcibus
[busind
].pb_devind
;
2399 printf("pcibr_via_wsts(%d, 0x%X), devind= %d (not implemented)\n",
2400 busind
, value
, devind
);
2404 /*===========================================================================*
2406 *===========================================================================*/
2407 static void pci_attr_wsts(int devind
, u16_t value
)
2411 busnr
= pcidev
[devind
].pd_busnr
;
2412 busind
= get_busind(busnr
);
2413 pcibus
[busind
].pb_wsts(busind
, value
);
2417 /*===========================================================================*
2419 *===========================================================================*/
2420 static u8_t
pcii_rreg8(busind
, devind
, port
)
2428 v
= PCII_RREG8_(pcibus
[busind
].pb_busnr
,
2429 pcidev
[devind
].pd_dev
, pcidev
[devind
].pd_func
,
2431 if (OK
!= (s
=sys_outl(PCII_CONFADD
, PCII_UNSEL
)))
2432 printf("PCI: warning, sys_outl failed: %d\n", s
);
2434 printf("pcii_rreg8(%d, %d, 0x%X): %d.%d.%d= 0x%X\n",
2435 busind
, devind
, port
,
2436 pcibus
[busind
].pb_bus
, pcidev
[devind
].pd_dev
,
2437 pcidev
[devind
].pd_func
, v
);
2442 /*===========================================================================*
2444 *===========================================================================*/
2445 static u16_t
pcii_rreg16(int busind
, int devind
, int port
)
2450 v
= PCII_RREG16_(pcibus
[busind
].pb_busnr
,
2451 pcidev
[devind
].pd_dev
, pcidev
[devind
].pd_func
,
2453 if (OK
!= (s
=sys_outl(PCII_CONFADD
, PCII_UNSEL
)))
2454 printf("PCI: warning, sys_outl failed: %d\n", s
);
2456 printf("pcii_rreg16(%d, %d, 0x%X): %d.%d.%d= 0x%X\n",
2457 busind
, devind
, port
,
2458 pcibus
[busind
].pb_bus
, pcidev
[devind
].pd_dev
,
2459 pcidev
[devind
].pd_func
, v
);
2464 /*===========================================================================*
2466 *===========================================================================*/
2467 static u32_t
pcii_rreg32(int busind
, int devind
, int port
)
2472 v
= PCII_RREG32_(pcibus
[busind
].pb_busnr
,
2473 pcidev
[devind
].pd_dev
, pcidev
[devind
].pd_func
,
2475 if (OK
!= (s
=sys_outl(PCII_CONFADD
, PCII_UNSEL
)))
2476 printf("PCI: warning, sys_outl failed: %d\n", s
);
2478 printf("pcii_rreg32(%d, %d, 0x%X): %d.%d.%d= 0x%X\n",
2479 busind
, devind
, port
,
2480 pcibus
[busind
].pb_bus
, pcidev
[devind
].pd_dev
,
2481 pcidev
[devind
].pd_func
, v
);
2486 /*===========================================================================*
2488 *===========================================================================*/
2489 static void pcii_wreg8(
2498 printf("pcii_wreg8(%d, %d, 0x%X, 0x%X): %d.%d.%d\n",
2499 busind
, devind
, port
, value
,
2500 pcibus
[busind
].pb_bus
, pcidev
[devind
].pd_dev
,
2501 pcidev
[devind
].pd_func
);
2503 PCII_WREG8_(pcibus
[busind
].pb_busnr
,
2504 pcidev
[devind
].pd_dev
, pcidev
[devind
].pd_func
,
2506 if (OK
!= (s
=sys_outl(PCII_CONFADD
, PCII_UNSEL
)))
2507 printf("PCI: warning, sys_outl failed: %d\n", s
);
2510 /*===========================================================================*
2512 *===========================================================================*/
2513 static void pcii_wreg16(
2522 printf("pcii_wreg16(%d, %d, 0x%X, 0x%X): %d.%d.%d\n",
2523 busind
, devind
, port
, value
,
2524 pcibus
[busind
].pb_bus
, pcidev
[devind
].pd_dev
,
2525 pcidev
[devind
].pd_func
);
2527 PCII_WREG16_(pcibus
[busind
].pb_busnr
,
2528 pcidev
[devind
].pd_dev
, pcidev
[devind
].pd_func
,
2530 if (OK
!= (s
=sys_outl(PCII_CONFADD
, PCII_UNSEL
)))
2531 printf("PCI: warning, sys_outl failed: %d\n", s
);
2534 /*===========================================================================*
2536 *===========================================================================*/
2537 static void pcii_wreg32(
2546 printf("pcii_wreg32(%d, %d, 0x%X, 0x%X): %d.%d.%d\n",
2547 busind
, devind
, port
, value
,
2548 pcibus
[busind
].pb_busnr
, pcidev
[devind
].pd_dev
,
2549 pcidev
[devind
].pd_func
);
2551 PCII_WREG32_(pcibus
[busind
].pb_busnr
,
2552 pcidev
[devind
].pd_dev
, pcidev
[devind
].pd_func
,
2554 if (OK
!= (s
=sys_outl(PCII_CONFADD
, PCII_UNSEL
)))
2555 printf("PCI: warning, sys_outl failed: %d\n",s
);
2558 /*===========================================================================*
2560 *===========================================================================*/
2561 static u16_t
pcii_rsts(int busind
)
2566 v
= PCII_RREG16_(pcibus
[busind
].pb_busnr
, 0, 0, PCI_SR
);
2567 if (OK
!= (s
=sys_outl(PCII_CONFADD
, PCII_UNSEL
)))
2568 printf("PCI: warning, sys_outl failed: %d\n", s
);
2572 /*===========================================================================*
2574 *===========================================================================*/
2575 static void pcii_wsts(int busind
, u16_t value
)
2578 PCII_WREG16_(pcibus
[busind
].pb_busnr
, 0, 0, PCI_SR
, value
);
2579 if (OK
!= (s
=sys_outl(PCII_CONFADD
, PCII_UNSEL
)))
2580 printf("PCI: warning, sys_outl failed: %d\n", s
);
2584 /*===========================================================================*
2585 * print_capabilities *
2586 *===========================================================================*/
2587 static void print_capabilities(int devind
)
2589 u8_t status
, capptr
, type
, next
, subtype
;
2592 /* Check capabilities bit in the device status register */
2593 status
= pci_attr_r16(devind
, PCI_SR
);
2594 if (!(status
& PSR_CAPPTR
))
2597 capptr
= (pci_attr_r8_u(devind
, PCI_CAPPTR
) & PCI_CP_MASK
);
2600 type
= pci_attr_r8_u(devind
, capptr
+CAP_TYPE
);
2601 next
= (pci_attr_r8_u(devind
, capptr
+CAP_NEXT
) & PCI_CP_MASK
);
2604 case 1: str
= "PCI Power Management"; break;
2605 case 2: str
= "AGP"; break;
2606 case 3: str
= "Vital Product Data"; break;
2607 case 4: str
= "Slot Identification"; break;
2608 case 5: str
= "Message Signaled Interrupts"; break;
2609 case 6: str
= "CompactPCI Hot Swap"; break;
2610 case 8: str
= "AMD HyperTransport"; break;
2611 case 0xf: str
= "Secure Device"; break;
2612 default: str
= "(unknown type)"; break;
2615 printf(" @0x%x (0x%08x): capability type 0x%x: %s",
2616 capptr
, pci_attr_r32_u(devind
, capptr
), type
, str
);
2618 print_hyper_cap(devind
, capptr
);
2619 else if (type
== 0x0f)
2621 subtype
= (pci_attr_r8_u(devind
, capptr
+2) & 0x07);
2624 case 0: str
= "Device Exclusion Vector"; break;
2625 case 3: str
= "IOMMU"; break;
2626 default: str
= "(unknown type)"; break;
2628 printf(", sub type 0%o: %s", subtype
, str
);
2636 /*===========================================================================*
2638 *===========================================================================*/
2639 static int visible(aclp
, devind
)
2640 struct rs_pci
*aclp
;
2647 return TRUE
; /* Should be changed when ACLs become
2648 * mandatory. Do note that procfs relies
2649 * on being able to see all devices.
2651 /* Check whether the caller is allowed to get this device. */
2652 for (i
= 0; i
<aclp
->rsp_nr_device
; i
++)
2654 if (aclp
->rsp_device
[i
].vid
== pcidev
[devind
].pd_vid
&&
2655 aclp
->rsp_device
[i
].did
== pcidev
[devind
].pd_did
)
2660 if (!aclp
->rsp_nr_class
)
2663 class_id
= (pcidev
[devind
].pd_baseclass
<< 16) |
2664 (pcidev
[devind
].pd_subclass
<< 8) |
2665 pcidev
[devind
].pd_infclass
;
2666 for (i
= 0; i
<aclp
->rsp_nr_class
; i
++)
2668 if (aclp
->rsp_class
[i
].pciclass
==
2669 (class_id
& aclp
->rsp_class
[i
].mask
))
2678 /*===========================================================================*
2680 *===========================================================================*/
2681 static void print_hyper_cap(int devind
, u8_t capptr
)
2688 v
= pci_attr_r32_u(devind
, capptr
);
2689 printf("print_hyper_cap: @0x%x, off 0 (cap):", capptr
);
2690 cmd
= (v
>> 16) & 0xffff;
2694 printf(" WarmReset");
2699 printf(" DblEnded");
2702 printf(" DevNum %d", (v
& 0x7C0000) >> 18);
2705 type0
= (cmd
& 0xE000) >> 13;
2706 type1
= (cmd
& 0xF800) >> 11;
2707 if (type0
== 0 || type0
== 1)
2709 printf("Capability Type: %s\n",
2710 type0
== 0 ? "Slave or Primary Interface" :
2711 "Host or Secondary Interface");
2716 printf(" Capability Type 0x%x", type1
);
2720 printf(" undecoded 0x%x\n", cmd
);
2723 printf("print_hyper_cap: off 4 (ctl): 0x%x\n",
2724 pci_attr_r32_u(devind
, capptr
+4));
2725 printf("print_hyper_cap: off 8 (freq/rev): 0x%x\n",
2726 pci_attr_r32_u(devind
, capptr
+8));
2727 printf("print_hyper_cap: off 12 (cap): 0x%x\n",
2728 pci_attr_r32_u(devind
, capptr
+12));
2729 printf("print_hyper_cap: off 16 (buf count): 0x%x\n",
2730 pci_attr_r32_u(devind
, capptr
+16));
2731 v
= pci_attr_r32_u(devind
, capptr
+20);
2732 printf("print_hyper_cap: @0x%x, off 20 (bus nr): ",
2734 printf("prim %d", v
& 0xff);
2735 printf(", sec %d", (v
>> 8) & 0xff);
2736 printf(", sub %d", (v
>> 16) & 0xff);
2738 printf(", reserved %d", (v
>> 24) & 0xff);
2740 printf("print_hyper_cap: off 24 (type): 0x%x\n",
2741 pci_attr_r32_u(devind
, capptr
+24));
2746 * $PchId: pci.c,v 1.7 2003/08/07 09:06:51 philip Exp $