summaryrefslogtreecommitdiffstats
path: root/share/man/man9/pci.9
blob: 76d35ea5d5887634169abd6cb57bf8df3bc055c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
.\"
.\" Copyright (c) 2003 Bruce M Simpson <bms@spc.org>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD$
.\"
.Dd May 21, 2003
.Dt PCI 9
.Os
.Sh NAME
.Nm pci ,
.Nm pci_read_config ,
.Nm pci_write_config ,
.Nm pci_enable_busmaster ,
.Nm pci_disable_busmaster ,
.Nm pci_enable_io ,
.Nm pci_disable_io ,
.Nm pci_set_powerstate ,
.Nm pci_get_powerstate ,
.Nm pci_find_bsf ,
.Nm pci_find_device
.Nd PCI bus interface
.Sh SYNOPSIS
.In sys/bus.h
.In dev/pci/pcivar.h
.In dev/pci/pcireg.h
.In machine/pci_cfgreg.h
.Pp
.Ft void
.Fn pci_write_config "device_t dev" "int reg" "u_int32_t val" "int width"
.Ft int
.Fn pci_enable_busmaster "device_t dev"
.Ft int
.Fn pci_disable_busmaster "device_t dev"
.Ft int
.Fn pci_enable_io "device_t dev" "int space"
.Ft int
.Fn pci_disable_io "device_t dev" "int space"
.Ft int
.Fn pci_set_powerstate "device_t dev" "int state"
.Ft int
.Fn pci_get_powerstate "device_t dev"
.Ft u_int32_t
.Fn pci_read_config "device_t dev" "int reg" "int width"
.Ft device_t
.Fn pci_find_bsf "u_int8_t" "u_int8_t" "u_int8_t"
.Ft device_t
.Fn pci_find_device "u_int16_t" "u_int16_t"
.Sh DESCRIPTION
The
.Nm
set of functions are used for managing PCI devices.
.Pp
The
.Fn pci_read_config
function is used to read data from the PCI configuration
space of the device
.Fa dev ,
at offset
.Fa reg ,
with
.Fa width
specifying the size of the access.
.Pp
The
.Fn pci_write_config
function is used to write the value
.Fa val
to the PCI configuration
space of the device
.Fa dev ,
at offset
.Fa reg ,
with
.Fa width
specifying the size of the access.
.Pp
The
.Fn pci_enable_busmaster
function enables PCI bus mastering for the device
.Fa dev ,
by setting the
.Dv PCIM_CMD_BUSMASTEREN
bit in the
.Dv PCIR_COMMAND
register.
The
.Fn pci_disable_busmaster
function clears this bit.
.Pp
The
.Fn pci_enable_io
function enables memory or I/O port address decoding for the device
.Fa dev ,
by setting the
.Dv PCIM_CMD_MEMEN
or
.Dv PCIM_CMD_PORTEN
bit in the
.Dv PCIR_COMMAND
register appropriately. The
.Fn pci_disable_io
function clears the appropriate bit.
The
.Fa state
argument specifies which resource is affected; this can be either
.Dv SYS_RES_MEMORY
or
.Dv SYS_RES_IOPORT
as appropriate.
.Pp
.Em NOTE :
These functions should be used in preference to manually manipulating
the configuration space.
.Pp
The
.Fn pci_get_powerstate
function returns the current ACPI power state of the device
.Fa dev .
If the device does not support power management capabilities, then the default
state of
.Dv PCI_POWERSTATE_D0
is returned.
The following power states are defined by ACPI:
.Bl -hang -width PCI_POWERSTATE_UNKNOWN
.It Dv PCI_POWERSTATE_D0
State in which device is on and running.
It is receiving full power from the system and delivering
full functionality to the user.
.It Dv PCI_POWERSTATE_D1
Class-specific low-power state in which device context may or
may not be lot.
Buses in this state cannot do anything to the bus, to
force devices to lose context.
.It Dv PCI_POWERSTATE_D2
Class-specific low-power state in which device context may or
may not be lost.
Attains greater power savings than
.Dv PCI_POWERSTATE_D1 .
Buses in this state can cause devices to lose some context.
Devices
.Em must
be prepared for the bus to be in this state or higher.
.It Dv PCI_POWERSTATE_D3
State in which the device is off and not running.
Device context is lost, and power from the device can
be removed.
.It Dv PCI_POWERSTATE_UNKNOWN
State of the device is unknown.
.El
.Pp
The
.Fn pci_set_powerstate
function is used to transition the device
.Fa dev
to the ACPI power state
.Fa state .
It checks to see if the device is PCI 2.2 compliant.
If so, it checks the
capabilities pointer to determine which power states the device supports.
If the device does not have power management capabilities, the default state
of
.Dv PCI_POWERSTATE_D0
is set.
.Pp
The
.Fn pci_find_bsf
function looks up the
.Vt device_t
of a PCI device, given its
.Fa bus ,
.Fa slot ,
and
.Fa function .
.Pp
The
.Fn pci_find_device
function looks up the
.Vt device_t
of a PCI device, given its
.Fa vendor
and
.Fa device
IDs. Note that there can be multiple matches for this search; this function
only returns the first matching device.
.Sh IMPLEMENTATION NOTES
The
.Vt pci_addr_t
type is varies according to the size of the PCI bus address
space on the target architecture.
.Sh SEE ALSO
.Xr pci 4 ,
.Xr pciconf 8 ,
.Xr bus_alloc_resource 9 ,
.Xr bus_dma 9 ,
.Xr bus_release_resource 9 ,
.Xr bus_setup_intr 9 ,
.Xr bus_teardown_intr 9 ,
.Xr devclass 9 ,
.Xr device 9 ,
.Xr driver 9 ,
.Xr rman 9
.Rs
.%B FreeBSD Developers' Handbook
.%T NewBus
.%O http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/developers-handbook/
.Re
.Rs
.%A Shanley
.%A Anderson
.%B PCI System Architecture
.%N 2nd Edition
.%I Addison-Wesley
.%O ISBN 0-201-30974-2
.Re
.Sh AUTHORS
This man page was written by
.An Bruce M Simpson Aq bms@spc.org .
.Sh BUGS
This manual page does not yet document PAE and how it affects memory-space
mapping of PCI devices.
OpenPOWER on IntegriCloud