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