xref: /freebsd/sys/dev/pci/pci_if.m (revision 39ee7a7a6bdd1557b1c3532abf60d139798ac88b)
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
31INTERFACE pci;
32
33CODE {
34	static int
35	null_msi_count(device_t dev, device_t child)
36	{
37		return (0);
38	}
39
40	static device_t
41	null_create_iov_child(device_t bus, device_t pf, uint16_t rid,
42	    uint16_t vid, uint16_t did)
43	{
44		device_printf(bus, "PCI_IOV not implemented on this bus.\n");
45		return (NULL);
46	}
47};
48
49HEADER {
50	struct nvlist;
51}
52
53
54METHOD u_int32_t read_config {
55	device_t	dev;
56	device_t	child;
57	int		reg;
58	int		width;
59};
60
61METHOD void write_config {
62	device_t	dev;
63	device_t	child;
64	int		reg;
65	u_int32_t	val;
66	int		width;
67};
68
69METHOD int get_powerstate {
70	device_t	dev;
71	device_t	child;
72};
73
74METHOD int set_powerstate {
75	device_t	dev;
76	device_t	child;
77	int		state;
78};
79
80METHOD int get_vpd_ident {
81	device_t	dev;
82	device_t	child;
83	const char	**identptr;
84};
85
86METHOD int get_vpd_readonly {
87	device_t	dev;
88	device_t	child;
89	const char	*kw;
90	const char	**vptr;
91};
92
93METHOD int enable_busmaster {
94	device_t	dev;
95	device_t	child;
96};
97
98METHOD int disable_busmaster {
99	device_t	dev;
100	device_t	child;
101};
102
103METHOD int enable_io {
104	device_t	dev;
105	device_t	child;
106	int		space;
107};
108
109METHOD int disable_io {
110	device_t	dev;
111	device_t	child;
112	int		space;
113};
114
115METHOD int assign_interrupt {
116	device_t	dev;
117	device_t	child;
118};
119
120METHOD int find_cap {
121	device_t	dev;
122	device_t	child;
123	int		capability;
124	int		*capreg;
125};
126
127METHOD int find_extcap {
128	device_t	dev;
129	device_t	child;
130	int		capability;
131	int		*capreg;
132};
133
134METHOD int find_htcap {
135	device_t	dev;
136	device_t	child;
137	int		capability;
138	int		*capreg;
139};
140
141METHOD int alloc_msi {
142	device_t	dev;
143	device_t	child;
144	int		*count;
145};
146
147METHOD int alloc_msix {
148	device_t	dev;
149	device_t	child;
150	int		*count;
151};
152
153METHOD void enable_msi {
154	device_t	dev;
155	device_t	child;
156	uint64_t	address;
157	uint16_t	data;
158};
159
160METHOD void enable_msix {
161	device_t	dev;
162	device_t	child;
163	u_int		index;
164	uint64_t	address;
165	uint32_t	data;
166};
167
168METHOD void disable_msi {
169	device_t	dev;
170	device_t	child;
171};
172
173METHOD int remap_msix {
174	device_t	dev;
175	device_t	child;
176	int		count;
177	const u_int	*vectors;
178};
179
180METHOD int release_msi {
181	device_t	dev;
182	device_t	child;
183};
184
185METHOD int msi_count {
186	device_t	dev;
187	device_t	child;
188} DEFAULT null_msi_count;
189
190METHOD int msix_count {
191	device_t	dev;
192	device_t	child;
193} DEFAULT null_msi_count;
194
195METHOD uint16_t get_rid {
196	device_t	dev;
197	device_t	child;
198};
199
200METHOD void child_added {
201	device_t	dev;
202	device_t	child;
203};
204
205METHOD int iov_attach {
206	device_t	dev;
207	device_t	child;
208	struct nvlist	*pf_schema;
209	struct nvlist	*vf_schema;
210};
211
212METHOD int iov_detach {
213	device_t	dev;
214	device_t	child;
215};
216
217METHOD device_t create_iov_child {
218	device_t bus;
219	device_t pf;
220	uint16_t rid;
221	uint16_t vid;
222	uint16_t did;
223} DEFAULT null_create_iov_child;
224