75bcd4562dc154f3737c4f78b57bb9c638d16b43jg * CDDL HEADER START
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg * The contents of this file are subject to the terms of the
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg * Common Development and Distribution License (the "License").
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg * You may not use this file except in compliance with the License.
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg * See the License for the specific language governing permissions
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg * and limitations under the License.
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg * When distributing Covered Code, include this CDDL HEADER in each
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg * If applicable, add the following below this CDDL HEADER, with the
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg * fields enclosed by brackets "[]" replaced with your own identifying
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg * information: Portions Copyright [yyyy] [name of copyright owner]
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg * CDDL HEADER END
0db3240d392634cfff2f95fb6da34b56b8dc574fStephen Hanson * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg * pci irq routing information table
75bcd4562dc154f3737c4f78b57bb9c638d16b43jgstatic int pci_bios_get_irq_routing(pci_irq_route_t *, int, int *);
75bcd4562dc154f3737c4f78b57bb9c638d16b43jgstatic void pci_get_irq_routing_table(void);
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg * Retrieve information from the bios needed for system
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg * configuration early during startup.
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg * Issue the bios get irq routing information table interrupt
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg * Despite the name, the information in the table is only
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg * used to derive slot names for some named pci hot-plug slots.
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg * Returns the number of irq routing table entries returned
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg * by the bios, or 0 and optionally, the number of entries required.
75bcd4562dc154f3737c4f78b57bb9c638d16b43jgpci_bios_get_irq_routing(pci_irq_route_t *routes, int nroutes, int *nneededp)
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg * Set up irq routing header with the size and address
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg * of some useable low-memory data addresses. Initalize
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg * data area to zero, avoiding memcpy/bzero.
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg for (i = 0; i < n; i++)
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg ((pci_irq_route_hdr_t *)hdrp)->pir_addr = (uint32_t)(uintptr_t)bufp;
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg regs.eax.word.ax = (PCI_FUNCTION_ID << 8) | PCI_GET_IRQ_ROUTING;
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg * Copy resulting irq routing data from low memory up to
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg * the kernel address space, avoiding memcpy as usual.
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg if (n <= nroutes) {
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg for (i = 0; i < n * sizeof (pci_irq_route_t); i++)
75bcd4562dc154f3737c4f78b57bb9c638d16b43jgstatic void
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg * Get irq routing table information.
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg * Allocate a buffer for an initial default number of entries.
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg * If the bios indicates it needs a larger buffer, try it again.
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg * Drive on if it still won't cooperate and play nice after that.
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg routes = kmem_zalloc(n * sizeof (pci_irq_route_t), KM_SLEEP);
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg "pci: unable to get IRQ routing information, "
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg "required buffer space of %d entries exceeds max\n",
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg routes = kmem_zalloc(n * sizeof (pci_irq_route_t), KM_SLEEP);
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg if (nroutes == 0) {
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg "pci: unable to get IRQ routing information, "
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg "required buffer space for %d entries\n", n);
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg * Use the results of the PCI BIOS call that returned the routing tables
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg * to build the 1275 slot-names property for the indicated bus.
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg * Results are returned in buf. Length is return value, -1 is returned on
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg * overflow and zero is returned if no data exists to build a property.
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg return (0);
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg for (i = 0; i < pci_irq_nroutes; i++)
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg for (i = 0; i < pci_irq_nroutes; i++) {
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg return (0);
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg return (-1);
75bcd4562dc154f3737c4f78b57bb9c638d16b43jg for (i = 0; i < pci_irq_nroutes; i++) {