1#-
2# Copyright (c) 1998 Doug Rabson
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8# 1. Redistributions of source code must retain the above copyright
9#    notice, this list of conditions and the following disclaimer.
10# 2. Redistributions in binary form must reproduce the above copyright
11#    notice, this list of conditions and the following disclaimer in the
12#    documentation and/or other materials provided with the distribution.
13#
14# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24# SUCH DAMAGE.
25#
26# $FreeBSD: releng/11.0/sys/dev/pci/pci_if.m 299932 2016-05-16 09:31:44Z andrew $
27#
28
29#include <sys/bus.h>
30#include <dev/pci/pcivar.h>
31
32INTERFACE pci;
33
34CODE {
35	static int
36	null_msi_count(device_t dev, device_t child)
37	{
38		return (0);
39	}
40
41	static int
42	null_msix_bar(device_t dev, device_t child)
43	{
44		return (-1);
45	}
46
47	static device_t
48	null_create_iov_child(device_t bus, device_t pf, uint16_t rid,
49	    uint16_t vid, uint16_t did)
50	{
51		device_printf(bus, "PCI_IOV not implemented on this bus.\n");
52		return (NULL);
53	}
54};
55
56HEADER {
57	struct nvlist;
58
59	enum pci_id_type {
60	    PCI_ID_RID,
61	    PCI_ID_MSI,
62	};
63}
64
65
66METHOD u_int32_t read_config {
67	device_t	dev;
68	device_t	child;
69	int		reg;
70	int		width;
71};
72
73METHOD void write_config {
74	device_t	dev;
75	device_t	child;
76	int		reg;
77	u_int32_t	val;
78	int		width;
79};
80
81METHOD int get_powerstate {
82	device_t	dev;
83	device_t	child;
84};
85
86METHOD int set_powerstate {
87	device_t	dev;
88	device_t	child;
89	int		state;
90};
91
92METHOD int get_vpd_ident {
93	device_t	dev;
94	device_t	child;
95	const char	**identptr;
96};
97
98METHOD int get_vpd_readonly {
99	device_t	dev;
100	device_t	child;
101	const char	*kw;
102	const char	**vptr;
103};
104
105METHOD int enable_busmaster {
106	device_t	dev;
107	device_t	child;
108};
109
110METHOD int disable_busmaster {
111	device_t	dev;
112	device_t	child;
113};
114
115METHOD int enable_io {
116	device_t	dev;
117	device_t	child;
118	int		space;
119};
120
121METHOD int disable_io {
122	device_t	dev;
123	device_t	child;
124	int		space;
125};
126
127METHOD int assign_interrupt {
128	device_t	dev;
129	device_t	child;
130};
131
132METHOD int find_cap {
133	device_t	dev;
134	device_t	child;
135	int		capability;
136	int		*capreg;
137};
138
139METHOD int find_extcap {
140	device_t	dev;
141	device_t	child;
142	int		capability;
143	int		*capreg;
144};
145
146METHOD int find_htcap {
147	device_t	dev;
148	device_t	child;
149	int		capability;
150	int		*capreg;
151};
152
153METHOD int alloc_msi {
154	device_t	dev;
155	device_t	child;
156	int		*count;
157};
158
159METHOD int alloc_msix {
160	device_t	dev;
161	device_t	child;
162	int		*count;
163};
164
165METHOD void enable_msi {
166	device_t	dev;
167	device_t	child;
168	uint64_t	address;
169	uint16_t	data;
170};
171
172METHOD void enable_msix {
173	device_t	dev;
174	device_t	child;
175	u_int		index;
176	uint64_t	address;
177	uint32_t	data;
178};
179
180METHOD void disable_msi {
181	device_t	dev;
182	device_t	child;
183};
184
185METHOD int remap_msix {
186	device_t	dev;
187	device_t	child;
188	int		count;
189	const u_int	*vectors;
190};
191
192METHOD int release_msi {
193	device_t	dev;
194	device_t	child;
195};
196
197METHOD int msi_count {
198	device_t	dev;
199	device_t	child;
200} DEFAULT null_msi_count;
201
202METHOD int msix_count {
203	device_t	dev;
204	device_t	child;
205} DEFAULT null_msi_count;
206
207METHOD int msix_pba_bar {
208	device_t	dev;
209	device_t	child;
210} DEFAULT null_msix_bar;
211
212METHOD int msix_table_bar {
213	device_t	dev;
214	device_t	child;
215} DEFAULT null_msix_bar;
216
217METHOD int get_id {
218	device_t	dev;
219	device_t	child;
220	enum pci_id_type type;
221	uintptr_t	*id;
222};
223
224METHOD struct pci_devinfo * alloc_devinfo {
225	device_t	dev;
226};
227
228METHOD void child_added {
229	device_t	dev;
230	device_t	child;
231};
232
233METHOD int iov_attach {
234	device_t	dev;
235	device_t	child;
236	struct nvlist	*pf_schema;
237	struct nvlist	*vf_schema;
238};
239
240METHOD int iov_detach {
241	device_t	dev;
242	device_t	child;
243};
244
245METHOD device_t create_iov_child {
246	device_t bus;
247	device_t pf;
248	uint16_t rid;
249	uint16_t vid;
250	uint16_t did;
251} DEFAULT null_create_iov_child;
252