xref: /freebsd/sys/dev/pci/pci_if.m (revision 9a36a337ff9fe0093dc141e79c84f05becf36023)
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$
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
60
61METHOD u_int32_t read_config {
62	device_t	dev;
63	device_t	child;
64	int		reg;
65	int		width;
66};
67
68METHOD void write_config {
69	device_t	dev;
70	device_t	child;
71	int		reg;
72	u_int32_t	val;
73	int		width;
74};
75
76METHOD int get_powerstate {
77	device_t	dev;
78	device_t	child;
79};
80
81METHOD int set_powerstate {
82	device_t	dev;
83	device_t	child;
84	int		state;
85};
86
87METHOD int get_vpd_ident {
88	device_t	dev;
89	device_t	child;
90	const char	**identptr;
91};
92
93METHOD int get_vpd_readonly {
94	device_t	dev;
95	device_t	child;
96	const char	*kw;
97	const char	**vptr;
98};
99
100METHOD int enable_busmaster {
101	device_t	dev;
102	device_t	child;
103};
104
105METHOD int disable_busmaster {
106	device_t	dev;
107	device_t	child;
108};
109
110METHOD int enable_io {
111	device_t	dev;
112	device_t	child;
113	int		space;
114};
115
116METHOD int disable_io {
117	device_t	dev;
118	device_t	child;
119	int		space;
120};
121
122METHOD int assign_interrupt {
123	device_t	dev;
124	device_t	child;
125};
126
127METHOD int find_cap {
128	device_t	dev;
129	device_t	child;
130	int		capability;
131	int		*capreg;
132};
133
134METHOD int find_extcap {
135	device_t	dev;
136	device_t	child;
137	int		capability;
138	int		*capreg;
139};
140
141METHOD int find_htcap {
142	device_t	dev;
143	device_t	child;
144	int		capability;
145	int		*capreg;
146};
147
148METHOD int alloc_msi {
149	device_t	dev;
150	device_t	child;
151	int		*count;
152};
153
154METHOD int alloc_msix {
155	device_t	dev;
156	device_t	child;
157	int		*count;
158};
159
160METHOD void enable_msi {
161	device_t	dev;
162	device_t	child;
163	uint64_t	address;
164	uint16_t	data;
165};
166
167METHOD void enable_msix {
168	device_t	dev;
169	device_t	child;
170	u_int		index;
171	uint64_t	address;
172	uint32_t	data;
173};
174
175METHOD void disable_msi {
176	device_t	dev;
177	device_t	child;
178};
179
180METHOD int remap_msix {
181	device_t	dev;
182	device_t	child;
183	int		count;
184	const u_int	*vectors;
185};
186
187METHOD int release_msi {
188	device_t	dev;
189	device_t	child;
190};
191
192METHOD int msi_count {
193	device_t	dev;
194	device_t	child;
195} DEFAULT null_msi_count;
196
197METHOD int msix_count {
198	device_t	dev;
199	device_t	child;
200} DEFAULT null_msi_count;
201
202METHOD int msix_pba_bar {
203	device_t	dev;
204	device_t	child;
205} DEFAULT null_msix_bar;
206
207METHOD int msix_table_bar {
208	device_t	dev;
209	device_t	child;
210} DEFAULT null_msix_bar;
211
212METHOD int get_id {
213	device_t	dev;
214	device_t	child;
215	enum pci_id_type type;
216	uintptr_t	*id;
217};
218
219METHOD struct pci_devinfo * alloc_devinfo {
220	device_t	dev;
221};
222
223METHOD void child_added {
224	device_t	dev;
225	device_t	child;
226};
227
228METHOD int iov_attach {
229	device_t	dev;
230	device_t	child;
231	struct nvlist	*pf_schema;
232	struct nvlist	*vf_schema;
233};
234
235METHOD int iov_detach {
236	device_t	dev;
237	device_t	child;
238};
239
240METHOD device_t create_iov_child {
241	device_t bus;
242	device_t pf;
243	uint16_t rid;
244	uint16_t vid;
245	uint16_t did;
246} DEFAULT null_create_iov_child;
247