p The .Fn pci_configure_bus function configures a PCI bus for use. This involves: l -bullet t Defining bus numbers for all busses on the system, t Setting the Base Address Registers for all devices, t Setting up the interrupt line register for all devices, and t Configuring bus latency timers for all devices. .El
p In traditional PCs and Alpha systems, the BIOS or firmware takes care of this task, but that is not the case for all systems. .Fn pci_configure_bus should be called prior to the auto-configuration of the bus.
p The .Fa pc argument is a machine-dependant tag used to specify the PCI chipset to the system. This should be the same value used with .Fn pci_make_tag . The extent arguments define memory extents from which the address space for the cards will be taken. These addresses should be in the PCI address space. The .Fa ioext extent is for PCI I/O accesses. The .Fa memext extent is for PCI memory accesses that might have side effects. I.e., that can not be cached. The .Fa pmemext extent is for PCI memory accesses that can be cached. The .Fa pmemext extent will be used for any ROMs and any memory regions that are marked as .Dq prefetchable in their BAR. If an implementation does not distinguish between prefetchable and non-prefetchable memory, it may pass NULL for .Fa pmemext . In this case, prefetchable memory allocations will be made from the non-prefetchable region.
p One of the functions of .Fn pci_configure_bus is to configure interrupt .Dq line information. This must be done on a machine-dependent basis, so a machine-dependent function .Fn pci_conf_interrupt must be defined. The prototype for this function is
p .Fn "void pci_conf_interrupt" "pci_chipset_tag_t pc" "int bus" \ "int device" "int function" "int swiz" "int *iline"
p In this function, .Fa bus , .Fa device , and .Fa function , uniquely identify the item being configured. The .Fa swiz argument is a .Dq swizzle , a sum of the device numbers of the primary interface of the bridges between the host bridge and the current device. The function is responsible for setting the value of .Fa iline . See chapter 9 of the .Dq PCI-to-PCI Bridge Architecture Specification for more information on swizzling (also known as interrupt routing). .Sh EXAMPLES The .Fn pci_conf_interrupt function in the sandpoint implementation looks like:
p d -literal -compact void pci_conf_interrupt(pci_chipset_tag_t pc, int bus, int dev, int func, int swiz, int *iline) { if (bus == 0) { *iline = dev; } else { *iline = 13 + ((swiz + dev + 3) & 3); } } .Ed
p The BeBox has nearly 1GB of PCI I/O memory starting at processor address 0x81000000 (PCI I/O address 0x01000000), and nearly 1GB of PCI memory starting at 0xC0000000 (PCI memory address 0x00000000). The .Fn pci_configure_bus function might be called as follows:
p d -literal -compact struct extent *ioext, *memext; ... ioext = extent_create("pciio", 0x01000000, 0x0fffffff, M_DEVBUF, NULL, 0, EX_NOWAIT); memext = extent_create("pcimem", 0x00000000, 0x0fffffff, M_DEVBUF, NULL, 0, EX_NOWAIT); ... pci_configure_bus(0, ioext, memext, NULL); ... extent_destroy(ioext); extent_destroy(memext); ... .Ed
p Note that this must be called before the PCI bus is attached during autoconfiguration. .Sh ENVIRONMENT The .Fn pci_configure_bus function is only included in the kernel if the kernel is compiled with the .Dv PCI_NETBSD_CONFIGURE option enabled. .Sh RETURN VALUES If successful .Fn pci_configure_bus returns 0. A non-zero return value means that the bus was not completely configured for some reason. A description of the failure will be displayed on the console.
p .Sh SEE ALSO .Xr pci 4 , .Xr extent 9 .Sh HISTORY .Fn pci_configure_bus was added in .Nx 1.6 .