/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Tim Rightnour
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Generic PowerPC functions for dealing with a PCI bridge. For most cases,
* these functions will work just fine, however, some machines may need
* specialized code, so those ports are free to write their own functions
* and call those instead where appropriate.
*/
if (pin == 0) {
/* No IRQ used. */
aprint_error("pci_intr_map: interrupt pin %d\n", pin);
goto bad;
}
if (pin > 4) {
aprint_error("pci_intr_map: bad interrupt pin %d\n", pin);
goto bad;
}
/*
* Section 6.2.4, `Miscellaneous Functions', says that 255 means
* `unknown' or `no connection' on a PC. We assume that a device with
* `no connection' either doesn't have an interrupt (in which case the
* pin number should be 0, and would have been noticed above), or
* wasn't configured by the BIOS (in which case we punt, since there's
* no real way we can know how the interrupt lines are mapped in the
* hardware).
*
* XXX
* Since IRQ 0 is only used by the clock, and we can't actually be sure
* that the BIOS did its job, we also recognize that as meaning that
* the BIOS has not configured the device.
* XXX
* it's perfectly legal to use IRQ 0 on macppc
*/
if (line == 255) {
aprint_error("pci_intr_map: no mapping for pin %c\n", '@' + pin);
goto bad;
#ifdef ICU_LEN
} else {
if (line >= ICU_LEN) {
aprint_error("pci_intr_map: bad interrupt line %d\n", line);
goto bad;
}
#endif
}
*ihp = line;
return 0;
bad:
*ihp = -1;
return 1;
}
/* experimental MSI support */
int
genppc_pci_msi_alloc(const struct pci_attach_args *pa, pci_intr_handle_t **ihps,
int *count, bool exact)
{
return EOPNOTSUPP;
}
/* experimental MSI-X support */
int
genppc_pci_msix_alloc(const struct pci_attach_args *pa,
pci_intr_handle_t **ihps, u_int *table_indexes, int *count, bool exact)
{