xref: /titanic_50/usr/src/uts/sun4v/io/px/px_lib4v.h (revision 02e56f3f1bfc8d9977bafb8cb5202f576dcded27)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SYS_PX_LIB4V_H
28 #define	_SYS_PX_LIB4V_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 /*
33  * SUN4V IO API - Version 1.11
34  */
35 
36 #ifdef	__cplusplus
37 extern "C" {
38 #endif
39 
40 /*
41  * The device handle uniquely identifies a SUN4V device.
42  * It consists of the lower 28-bits of the hi-cell of the
43  * first entry of the SUN4V device's "reg" property as
44  * defined by the SUN4V Bus Binding to Open Firmware.
45  */
46 #define	DEVHDLE_MASK	0xFFFFFFF
47 
48 /* PX BDF Shift in a Phyiscal Address - used FMA Fabric only */
49 #define	PX_RA_BDF_SHIFT			8
50 
51 extern uint64_t hvio_config_get(devhandle_t dev_hdl, pci_device_t bdf,
52     pci_config_offset_t off, pci_config_size_t size, pci_cfg_data_t *data_p);
53 extern uint64_t hvio_config_put(devhandle_t dev_hdl, pci_device_t bdf,
54     pci_config_offset_t off, pci_config_size_t size, pci_cfg_data_t data);
55 
56 extern uint64_t hvio_iommu_map(devhandle_t dev_hdl, tsbid_t tsbid,
57     pages_t pages, io_attributes_t io_attributes,
58     io_page_list_t *io_page_list_p, pages_t *pages_mapped);
59 extern uint64_t hvio_iommu_demap(devhandle_t dev_hdl, tsbid_t tsbid,
60     pages_t pages, pages_t *pages_demapped);
61 extern uint64_t hvio_iommu_getmap(devhandle_t dev_hdl, tsbid_t tsbid,
62     io_attributes_t *attributes_p, r_addr_t *r_addr_p);
63 extern uint64_t hvio_iommu_getbypass(devhandle_t dev_hdl, r_addr_t ra,
64     io_attributes_t io_attributes, io_addr_t *io_addr_p);
65 extern uint64_t hvio_dma_sync(devhandle_t dev_hdl, r_addr_t ra,
66     size_t num_bytes, io_sync_direction_t io_sync_direction,
67     size_t *bytes_synched);
68 
69 /*
70  * MSIQ Functions:
71  */
72 extern uint64_t hvio_msiq_conf(devhandle_t dev_hdl, msiqid_t msiq_id,
73     r_addr_t ra, uint_t msiq_rec_cnt);
74 extern uint64_t hvio_msiq_info(devhandle_t dev_hdl, msiqid_t msiq_id,
75     r_addr_t *ra_p, uint_t *msiq_rec_cnt_p);
76 extern uint64_t hvio_msiq_getvalid(devhandle_t dev_hdl, msiqid_t msiq_id,
77     pci_msiq_valid_state_t *msiq_valid_state);
78 extern uint64_t hvio_msiq_setvalid(devhandle_t dev_hdl, msiqid_t msiq_id,
79     pci_msiq_valid_state_t msiq_valid_state);
80 extern uint64_t hvio_msiq_getstate(devhandle_t dev_hdl, msiqid_t msiq_id,
81     pci_msiq_state_t *msiq_state);
82 extern uint64_t hvio_msiq_setstate(devhandle_t dev_hdl, msiqid_t msiq_id,
83     pci_msiq_state_t msiq_state);
84 extern uint64_t hvio_msiq_gethead(devhandle_t dev_hdl, msiqid_t msiq_id,
85     msiqhead_t *msiq_head);
86 extern uint64_t hvio_msiq_sethead(devhandle_t dev_hdl, msiqid_t msiq_id,
87     msiqhead_t msiq_head);
88 extern uint64_t hvio_msiq_gettail(devhandle_t dev_hdl, msiqid_t msiq_id,
89     msiqtail_t *msiq_tail);
90 
91 /*
92  * MSI Functions:
93  */
94 extern uint64_t hvio_msi_getmsiq(devhandle_t dev_hdl, msinum_t msi_num,
95     msiqid_t *msiq_id);
96 extern uint64_t hvio_msi_setmsiq(devhandle_t dev_hdl, msinum_t msi_num,
97     msiqid_t msiq_id, msi_type_t msitype);
98 extern uint64_t hvio_msi_getvalid(devhandle_t dev_hdl, msinum_t msi_num,
99     pci_msi_valid_state_t *msi_valid_state);
100 extern uint64_t hvio_msi_setvalid(devhandle_t dev_hdl, msinum_t msi_num,
101     pci_msi_valid_state_t msi_valid_state);
102 extern uint64_t hvio_msi_getstate(devhandle_t dev_hdl, msinum_t msi_num,
103     pci_msi_state_t *msi_state);
104 extern uint64_t hvio_msi_setstate(devhandle_t dev_hdl, msinum_t msi_num,
105     pci_msi_state_t msi_state);
106 
107 /*
108  * MSG Functions:
109  */
110 extern uint64_t hvio_msg_getmsiq(devhandle_t dev_hdl, pcie_msg_type_t msg_type,
111     msiqid_t *msiq_id);
112 extern uint64_t hvio_msg_setmsiq(devhandle_t dev_hdl, pcie_msg_type_t msg_type,
113     msiqid_t msiq_id);
114 extern uint64_t hvio_msg_getvalid(devhandle_t dev_hdl, pcie_msg_type_t msg_type,
115     pcie_msg_valid_state_t *msg_valid_state);
116 extern uint64_t hvio_msg_setvalid(devhandle_t dev_hdl, pcie_msg_type_t msg_type,
117     pcie_msg_valid_state_t msg_valid_state);
118 
119 typedef struct px_config_acc_pvt {
120 	dev_info_t *dip;
121 	uint32_t raddr;
122 	uint32_t vaddr;
123 } px_config_acc_pvt_t;
124 
125 /*
126  * Peek/poke functionality:
127  */
128 
129 extern uint64_t hvio_peek(devhandle_t dev_hdl, r_addr_t ra, size_t size,
130     uint32_t *status, uint64_t *data_p);
131 extern uint64_t hvio_poke(devhandle_t dev_hdl, r_addr_t ra, size_t size,
132     uint64_t data, pci_device_t bdf, uint32_t *wrt_stat);
133 
134 #ifdef	__cplusplus
135 }
136 #endif
137 
138 #endif	/* _SYS_PX_LIB4V_H */
139