15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
23 */
24
25 #include <sys/types.h>
26 #include <sys/stat.h>
27 #include <sys/sunndi.h>
28 #include <sys/pci.h>
29 #include <sys/pci_impl.h>
30 #include <sys/pci_cfgspace.h>
31 #include <sys/pci_cfgspace_impl.h>
32 #include <sys/memlist.h>
33 #include <sys/bootconf.h>
34 #include <sys/psw.h>
35
36 /*
37 * pci irq routing information table
38 */
39 int pci_irq_nroutes;
40 static pci_irq_route_t *pci_irq_routes;
41
42
43 static int pci_bios_get_irq_routing(pci_irq_route_t *, int, int *);
44 static void pci_get_irq_routing_table(void);
45
46
47 /*
48 * Retrieve information from the bios needed for system
49 * configuration early during startup.
50 */
51 void
52 startup_pci_bios(void)
53 {
54 pci_get_irq_routing_table();
60 *
61 * Despite the name, the information in the table is only
62 * used to derive slot names for some named pci hot-plug slots.
63 *
64 * Returns the number of irq routing table entries returned
65 * by the bios, or 0 and optionally, the number of entries required.
66 */
67 static int
68 pci_bios_get_irq_routing(pci_irq_route_t *routes, int nroutes, int *nneededp)
69 {
70 struct bop_regs regs;
71 uchar_t *hdrp;
72 uchar_t *bufp;
73 int i, n;
74 int rval = 0;
75
76 if (nneededp)
77 *nneededp = 0;
78
79 /*
80 * Set up irq routing header with the size and address
81 * of some useable low-memory data addresses. Initalize
82 * data area to zero, avoiding memcpy/bzero.
83 */
84 hdrp = (uchar_t *)BIOS_IRQ_ROUTING_HDR;
85 bufp = (uchar_t *)BIOS_IRQ_ROUTING_DATA;
86
87 n = nroutes * sizeof (pci_irq_route_t);
88 for (i = 0; i < n; i++)
89 bufp[i] = 0;
90 ((pci_irq_route_hdr_t *)hdrp)->pir_size = n;
91 ((pci_irq_route_hdr_t *)hdrp)->pir_addr = (uint32_t)(uintptr_t)bufp;
92
93 bzero(®s, sizeof (regs));
94 regs.eax.word.ax = (PCI_FUNCTION_ID << 8) | PCI_GET_IRQ_ROUTING;
95
96 regs.ds = 0xf000;
97 regs.es = FP_SEG((uint_t)(uintptr_t)hdrp);
98 regs.edi.word.di = FP_OFF((uint_t)(uintptr_t)hdrp);
99
|
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
23 */
24
25 #include <sys/types.h>
26 #include <sys/stat.h>
27 #include <sys/sunndi.h>
28 #include <sys/pci.h>
29 #include <sys/pci_impl.h>
30 #include <sys/pci_cfgspace.h>
31 #include <sys/pci_cfgspace_impl.h>
32 #include <sys/memlist.h>
33 #include <sys/bootconf.h>
34 #include <sys/psw.h>
35 #include <sys/machsystm.h>
36
37 /*
38 * pci irq routing information table
39 */
40 int pci_irq_nroutes;
41 static pci_irq_route_t *pci_irq_routes;
42
43
44 static int pci_bios_get_irq_routing(pci_irq_route_t *, int, int *);
45 static void pci_get_irq_routing_table(void);
46
47
48 /*
49 * Retrieve information from the bios needed for system
50 * configuration early during startup.
51 */
52 void
53 startup_pci_bios(void)
54 {
55 pci_get_irq_routing_table();
61 *
62 * Despite the name, the information in the table is only
63 * used to derive slot names for some named pci hot-plug slots.
64 *
65 * Returns the number of irq routing table entries returned
66 * by the bios, or 0 and optionally, the number of entries required.
67 */
68 static int
69 pci_bios_get_irq_routing(pci_irq_route_t *routes, int nroutes, int *nneededp)
70 {
71 struct bop_regs regs;
72 uchar_t *hdrp;
73 uchar_t *bufp;
74 int i, n;
75 int rval = 0;
76
77 if (nneededp)
78 *nneededp = 0;
79
80 /*
81 * If this system does not support BIOS calls, we can't use this
82 * mechanism.
83 */
84 if (!bios_calls_available)
85 return (0);
86
87 /*
88 * Set up irq routing header with the size and address
89 * of some useable low-memory data addresses. Initalize
90 * data area to zero, avoiding memcpy/bzero.
91 */
92 hdrp = (uchar_t *)BIOS_IRQ_ROUTING_HDR;
93 bufp = (uchar_t *)BIOS_IRQ_ROUTING_DATA;
94
95 n = nroutes * sizeof (pci_irq_route_t);
96 for (i = 0; i < n; i++)
97 bufp[i] = 0;
98 ((pci_irq_route_hdr_t *)hdrp)->pir_size = n;
99 ((pci_irq_route_hdr_t *)hdrp)->pir_addr = (uint32_t)(uintptr_t)bufp;
100
101 bzero(®s, sizeof (regs));
102 regs.eax.word.ax = (PCI_FUNCTION_ID << 8) | PCI_GET_IRQ_ROUTING;
103
104 regs.ds = 0xf000;
105 regs.es = FP_SEG((uint_t)(uintptr_t)hdrp);
106 regs.edi.word.di = FP_OFF((uint_t)(uintptr_t)hdrp);
107
|