1 .\" $NetBSD: bus_space.9,v 1.36 2008/05/02 21:36:23 martin Exp $
3 .\" Copyright (c) 1997 The NetBSD Foundation, Inc.
4 .\" All rights reserved.
6 .\" This code is derived from software contributed to The NetBSD Foundation
7 .\" by Christopher G. Demetriou.
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\" notice, this list of conditions and the following disclaimer in the
16 .\" documentation and/or other materials provided with the distribution.
18 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 .\" POSSIBILITY OF SUCH DAMAGE.
35 .Nm bus_space_barrier ,
36 .Nm bus_space_copy_region_1 ,
37 .Nm bus_space_copy_region_2 ,
38 .Nm bus_space_copy_region_4 ,
39 .Nm bus_space_copy_region_8 ,
42 .Nm bus_space_peek_1 ,
43 .Nm bus_space_peek_2 ,
44 .Nm bus_space_peek_4 ,
45 .Nm bus_space_peek_8 ,
46 .Nm bus_space_poke_1 ,
47 .Nm bus_space_poke_2 ,
48 .Nm bus_space_poke_4 ,
49 .Nm bus_space_poke_8 ,
50 .Nm bus_space_read_1 ,
51 .Nm bus_space_read_2 ,
52 .Nm bus_space_read_4 ,
53 .Nm bus_space_read_8 ,
54 .Nm bus_space_read_multi_1 ,
55 .Nm bus_space_read_multi_2 ,
56 .Nm bus_space_read_multi_4 ,
57 .Nm bus_space_read_multi_8 ,
58 .Nm bus_space_read_multi_stream_1 ,
59 .Nm bus_space_read_multi_stream_2 ,
60 .Nm bus_space_read_multi_stream_4 ,
61 .Nm bus_space_read_multi_stream_8 ,
62 .Nm bus_space_read_region_1 ,
63 .Nm bus_space_read_region_2 ,
64 .Nm bus_space_read_region_4 ,
65 .Nm bus_space_read_region_8 ,
66 .Nm bus_space_read_region_stream_1 ,
67 .Nm bus_space_read_region_stream_2 ,
68 .Nm bus_space_read_region_stream_4 ,
69 .Nm bus_space_read_region_stream_8 ,
70 .Nm bus_space_read_stream_1 ,
71 .Nm bus_space_read_stream_2 ,
72 .Nm bus_space_read_stream_4 ,
73 .Nm bus_space_read_stream_8 ,
74 .Nm bus_space_set_region_1 ,
75 .Nm bus_space_set_region_2 ,
76 .Nm bus_space_set_region_4 ,
77 .Nm bus_space_set_region_8 ,
78 .Nm bus_space_subregion ,
82 .Nm bus_space_write_1 ,
83 .Nm bus_space_write_2 ,
84 .Nm bus_space_write_4 ,
85 .Nm bus_space_write_8 ,
86 .Nm bus_space_write_multi_1 ,
87 .Nm bus_space_write_multi_2 ,
88 .Nm bus_space_write_multi_4 ,
89 .Nm bus_space_write_multi_8 ,
90 .Nm bus_space_write_multi_stream_1 ,
91 .Nm bus_space_write_multi_stream_2 ,
92 .Nm bus_space_write_multi_stream_4 ,
93 .Nm bus_space_write_multi_stream_8 ,
94 .Nm bus_space_write_region_1 ,
95 .Nm bus_space_write_region_2 ,
96 .Nm bus_space_write_region_4 ,
97 .Nm bus_space_write_region_8 ,
98 .Nm bus_space_write_region_stream_1 ,
99 .Nm bus_space_write_region_stream_2 ,
100 .Nm bus_space_write_region_stream_4 ,
101 .Nm bus_space_write_region_stream_8 ,
102 .Nm bus_space_write_stream_1 ,
103 .Nm bus_space_write_stream_2 ,
104 .Nm bus_space_write_stream_4 ,
105 .Nm bus_space_write_stream_8
106 .Nd bus space manipulation functions
110 .Fn bus_space_map "bus_space_tag_t space" "bus_addr_t address" \
111 "bus_size_t size" "int flags" "bus_space_handle_t *handlep"
113 .Fn bus_space_unmap "bus_space_tag_t space" "bus_space_handle_t handle" \
116 .Fn bus_space_subregion "bus_space_tag_t space" "bus_space_handle_t handle" \
117 "bus_size_t offset" "bus_size_t size" "bus_space_handle_t *nhandlep"
120 .Fa "bus_space_tag_t space" "bus_addr_t reg_start" "bus_addr_t reg_end"
121 .Fa "bus_size_t size" "bus_size_t alignment" "bus_size_t boundary"
122 .Fa "int flags" "bus_addr_t *addrp" "bus_space_handle_t *handlep"
125 .Fn bus_space_free "bus_space_tag_t space" "bus_space_handle_t handle" \
128 .Fn bus_space_vaddr "bus_space_tag_t space" "bus_space_handle_t handle"
130 .Fn bus_space_mmap "bus_space_tag_t space" "bus_addr_t addr" "off_t off" \
131 "int prot" "int flags"
133 .Fn bus_space_peek_1 "bus_space_tag_t space" "bus_space_handle_t handle" \
134 "bus_size_t offset" "uint8_t *datap"
136 .Fn bus_space_peek_2 "bus_space_tag_t space" "bus_space_handle_t handle" \
137 "bus_size_t offset" "uint16_t *datap"
139 .Fn bus_space_peek_4 "bus_space_tag_t space" "bus_space_handle_t handle" \
140 "bus_size_t offset" "uint32_t *datap"
142 .Fn bus_space_peek_8 "bus_space_tag_t space" "bus_space_handle_t handle" \
143 "bus_size_t offset" "uint64_t *datap"
145 .Fn bus_space_poke_1 "bus_space_tag_t space" "bus_space_handle_t handle" \
146 "bus_size_t offset" "uint8_t data"
148 .Fn bus_space_poke_2 "bus_space_tag_t space" "bus_space_handle_t handle" \
149 "bus_size_t offset" "uint16_t data"
151 .Fn bus_space_poke_4 "bus_space_tag_t space" "bus_space_handle_t handle" \
152 "bus_size_t offset" "uint32_t data"
154 .Fn bus_space_poke_8 "bus_space_tag_t space" "bus_space_handle_t handle" \
155 "bus_size_t offset" "uint64_t data"
157 .Fn bus_space_read_1 "bus_space_tag_t space" "bus_space_handle_t handle" \
160 .Fn bus_space_read_2 "bus_space_tag_t space" "bus_space_handle_t handle" \
163 .Fn bus_space_read_4 "bus_space_tag_t space" "bus_space_handle_t handle" \
166 .Fn bus_space_read_8 "bus_space_tag_t space" "bus_space_handle_t handle" \
169 .Fn bus_space_write_1 "bus_space_tag_t space" "bus_space_handle_t handle" \
170 "bus_size_t offset" "uint8_t value"
172 .Fn bus_space_write_2 "bus_space_tag_t space" "bus_space_handle_t handle" \
173 "bus_size_t offset" "uint16_t value"
175 .Fn bus_space_write_4 "bus_space_tag_t space" "bus_space_handle_t handle" \
176 "bus_size_t offset" "uint32_t value"
178 .Fn bus_space_write_8 "bus_space_tag_t space" "bus_space_handle_t handle" \
179 "bus_size_t offset" "uint64_t value"
181 .Fn bus_space_barrier "bus_space_tag_t space" "bus_space_handle_t handle" \
182 "bus_size_t offset" "bus_size_t length" "int flags"
184 .Fn bus_space_read_region_1 "bus_space_tag_t space" \
185 "bus_space_handle_t handle" "bus_size_t offset" "uint8_t *datap" \
188 .Fn bus_space_read_region_2 "bus_space_tag_t space" \
189 "bus_space_handle_t handle" "bus_size_t offset" "uint16_t *datap" \
192 .Fn bus_space_read_region_4 "bus_space_tag_t space" \
193 "bus_space_handle_t handle" "bus_size_t offset" "uint32_t *datap" \
196 .Fn bus_space_read_region_8 "bus_space_tag_t space" \
197 "bus_space_handle_t handle" "bus_size_t offset" "uint64_t *datap" \
200 .Fn bus_space_read_region_stream_1 "bus_space_tag_t space" \
201 "bus_space_handle_t handle" "bus_size_t offset" "uint8_t *datap" \
204 .Fn bus_space_read_region_stream_2 "bus_space_tag_t space" \
205 "bus_space_handle_t handle" "bus_size_t offset" "uint16_t *datap" \
208 .Fn bus_space_read_region_stream_4 "bus_space_tag_t space" \
209 "bus_space_handle_t handle" "bus_size_t offset" "uint32_t *datap" \
212 .Fn bus_space_read_region_stream_8 "bus_space_tag_t space" \
213 "bus_space_handle_t handle" "bus_size_t offset" "uint64_t *datap" \
216 .Fn bus_space_write_region_1 "bus_space_tag_t space" \
217 "bus_space_handle_t handle" "bus_size_t offset" "const uint8_t *datap" \
220 .Fn bus_space_write_region_2 "bus_space_tag_t space" \
221 "bus_space_handle_t handle" "bus_size_t offset" "const uint16_t *datap" \
224 .Fn bus_space_write_region_4 "bus_space_tag_t space" \
225 "bus_space_handle_t handle" "bus_size_t offset" "const uint32_t *datap" \
228 .Fn bus_space_write_region_8 "bus_space_tag_t space" \
229 "bus_space_handle_t handle" "bus_size_t offset" "const uint64_t *datap" \
232 .Fn bus_space_write_region_stream_1 "bus_space_tag_t space" \
233 "bus_space_handle_t handle" "bus_size_t offset" "const uint8_t *datap" \
236 .Fn bus_space_write_region_stream_2 "bus_space_tag_t space" \
237 "bus_space_handle_t handle" "bus_size_t offset" "const uint16_t *datap" \
240 .Fn bus_space_write_region_stream_4 "bus_space_tag_t space" \
241 "bus_space_handle_t handle" "bus_size_t offset" "const uint32_t *datap" \
244 .Fn bus_space_write_region_stream_8 "bus_space_tag_t space" \
245 "bus_space_handle_t handle" "bus_size_t offset" "const uint64_t *datap" \
248 .Fn bus_space_copy_region_1 "bus_space_tag_t space" \
249 "bus_space_handle_t srchandle" "bus_size_t srcoffset" \
250 "bus_space_handle_t dsthandle" "bus_size_t dstoffset" "bus_size_t count"
252 .Fn bus_space_copy_region_2 "bus_space_tag_t space" \
253 "bus_space_handle_t srchandle" "bus_size_t srcoffset" \
254 "bus_space_handle_t dsthandle" "bus_size_t dstoffset" "bus_size_t count"
256 .Fn bus_space_copy_region_4 "bus_space_tag_t space" \
257 "bus_space_handle_t srchandle" "bus_size_t srcoffset" \
258 "bus_space_handle_t dsthandle" "bus_size_t dstoffset" "bus_size_t count"
260 .Fn bus_space_copy_region_8 "bus_space_tag_t space" \
261 "bus_space_handle_t srchandle" "bus_size_t srcoffset" \
262 "bus_space_handle_t dsthandle" "bus_size_t dstoffset" "bus_size_t count"
264 .Fn bus_space_set_region_1 "bus_space_tag_t space" \
265 "bus_space_handle_t handle" "bus_size_t offset" "uint8_t value" \
268 .Fn bus_space_set_region_2 "bus_space_tag_t space" \
269 "bus_space_handle_t handle" "bus_size_t offset" "uint16_t value" \
272 .Fn bus_space_set_region_4 "bus_space_tag_t space" \
273 "bus_space_handle_t handle" "bus_size_t offset" "uint32_t value" \
276 .Fn bus_space_set_region_8 "bus_space_tag_t space" \
277 "bus_space_handle_t handle" "bus_size_t offset" "uint64_t value" \
280 .Fn bus_space_read_multi_1 "bus_space_tag_t space" \
281 "bus_space_handle_t handle" "bus_size_t offset" "uint8_t *datap" \
284 .Fn bus_space_read_multi_2 "bus_space_tag_t space" \
285 "bus_space_handle_t handle" "bus_size_t offset" "uint16_t *datap" \
288 .Fn bus_space_read_multi_4 "bus_space_tag_t space" \
289 "bus_space_handle_t handle" "bus_size_t offset" "uint32_t *datap" \
292 .Fn bus_space_read_multi_8 "bus_space_tag_t space" \
293 "bus_space_handle_t handle" "bus_size_t offset" "uint64_t *datap" \
296 .Fn bus_space_read_multi_stream_1 "bus_space_tag_t space" \
297 "bus_space_handle_t handle" "bus_size_t offset" "uint8_t *datap" \
300 .Fn bus_space_read_multi_stream_2 "bus_space_tag_t space" \
301 "bus_space_handle_t handle" "bus_size_t offset" "uint16_t *datap" \
304 .Fn bus_space_read_multi_stream_4 "bus_space_tag_t space" \
305 "bus_space_handle_t handle" "bus_size_t offset" "uint32_t *datap" \
308 .Fn bus_space_read_multi_stream_8 "bus_space_tag_t space" \
309 "bus_space_handle_t handle" "bus_size_t offset" "uint64_t *datap" \
312 .Fn bus_space_write_multi_1 "bus_space_tag_t space" \
313 "bus_space_handle_t handle" "bus_size_t offset" "const uint8_t *datap" \
316 .Fn bus_space_write_multi_2 "bus_space_tag_t space" \
317 "bus_space_handle_t handle" "bus_size_t offset" "const uint16_t *datap" \
320 .Fn bus_space_write_multi_4 "bus_space_tag_t space" \
321 "bus_space_handle_t handle" "bus_size_t offset" "const uint32_t *datap" \
324 .Fn bus_space_write_multi_8 "bus_space_tag_t space" \
325 "bus_space_handle_t handle" "bus_size_t offset" "const uint64_t *datap" \
328 .Fn bus_space_write_multi_stream_1 "bus_space_tag_t space" \
329 "bus_space_handle_t handle" "bus_size_t offset" "const uint8_t *datap" \
332 .Fn bus_space_write_multi_stream_2 "bus_space_tag_t space" \
333 "bus_space_handle_t handle" "bus_size_t offset" "const uint16_t *datap" \
336 .Fn bus_space_write_multi_stream_4 "bus_space_tag_t space" \
337 "bus_space_handle_t handle" "bus_size_t offset" "const uint32_t *datap" \
340 .Fn bus_space_write_multi_stream_8 "bus_space_tag_t space" \
341 "bus_space_handle_t handle" "bus_size_t offset" "const uint64_t *datap" \
346 functions exist to allow device drivers
347 machine-independent access to bus memory and register areas.
348 All of the functions and types described in this document can be used
353 Many common devices are used on multiple architectures, but are accessed
354 differently on each because of architectural constraints.
355 For instance, a device which is mapped in one system's I/O space may be
356 mapped in memory space on a second system.
357 On a third system, architectural limitations might change the way
358 registers need to be accessed (e.g., creating a non-linear register space).
359 In some cases, a single
360 driver may need to access the same type of device in multiple ways in a
361 single system or architecture.
364 functions is to allow a single driver source file to manipulate a set
365 of devices on different system architectures, and to allow a single driver
366 object file to manipulate a set of devices on multiple bus types on a
369 Not all busses have to implement all functions described in this
370 document, though that is encouraged if the operations are logically
371 supported by the bus.
372 Unimplemented functions should cause compile-time errors if possible.
374 All of the interface definitions described in this document are shown as
375 function prototypes and discussed as if they were required to be
377 Implementations are encouraged to implement prototyped (type-checked)
378 versions of these interfaces, but may implement them as macros if appropriate.
379 Machine-dependent types, variables, and functions should be marked clearly in
381 to avoid confusion with the
382 machine-independent types and functions, and, if possible, should be
383 given names which make the machine-dependence clear.
384 .Sh CONCEPTS AND GUIDELINES
385 Bus spaces are described by bus space tags, which can be created only by
386 machine-dependent code.
387 A given machine may have several different types of bus space
388 (e.g., memory space and I/O space), and thus may provide multiple different
390 Individual busses or devices on a machine may use more than one bus space
392 For instance, ISA devices are given an ISA memory space tag and an
394 Architectures may have several different tags which represent the same
395 type of space, for instance because of multiple different host bus
398 A range in bus space is described by a bus address and a bus size.
399 The bus address describes the start of the range in bus space.
400 The bus size describes the size of the range in bytes.
401 Busses which are not byte addressable may require use of bus space ranges
402 with appropriately aligned addresses and properly rounded sizes.
404 Access to regions of bus space is facilitated by use of bus space handles,
405 which are usually created by mapping a specific range of a bus space.
406 Handles may also be created by allocating
407 and mapping a range of bus space, the actual location of which is picked
408 by the implementation within bounds specified by the caller of the
411 All of the bus space access functions require one bus space tag
412 argument, at least one handle argument, and at least one offset argument
414 The bus space tag specifies the space, each handle specifies a region in
415 the space, and each offset specifies the offset into the region of the
416 actual location(s) to be accessed.
417 Offsets are given in bytes, though busses may impose alignment constraints.
418 The offset used to access data relative to a given handle must be such
419 that all of the data being accessed is in the mapped region that the
421 Trying to access data outside that region is an error.
423 Because some architectures' memory systems use buffering to improve
424 memory and device access performance, there is a mechanism which can be
427 in the bus space read and write stream.
429 There are two types of barriers: ordering barriers and completion
432 Ordering barriers prevent some operations from bypassing other
434 They are relatively light weight and described in terms of the
435 operations they are intended to order.
436 The important thing to note is that they create specific ordering
437 constraint surrounding bus accesses but do not necessarily force any
438 synchronization themselves.
439 So, if there is enough distance between the memory operations being
440 ordered, the preceding ones could complete by themselves resulting
441 in no performance penalty.
443 For instance, a write before read barrier will force any writes
444 issued before the barrier instruction to complete before any reads
445 after the barrier are issued.
446 This forces processors with write buffers to read data from memory rather
447 than from the pending write in the write buffer.
449 Ordering barriers are usually sufficient for most circumstances,
450 and can be combined together.
451 For instance a read before write barrier can be combined with a write
452 before write barrier to force all memory operations to complete before
453 the next write is started.
455 Completion barriers force all memory operations and any pending
456 exceptions to be completed before any instructions after the
457 barrier may be issued.
458 Completion barriers are extremely expensive and almost never required
459 in device driver code.
460 A single completion barrier can force the processor to stall on memory
461 for hundreds of cycles on some machines.
463 Correctly-written drivers will include all appropriate barriers,
464 and assume only the read/write ordering imposed by the barrier
467 People trying to write portable drivers with the
470 try to make minimal assumptions about what the system allows.
471 In particular, they should expect that the system requires bus space
472 addresses being accessed to be naturally aligned (i.e., base address of
473 handle added to offset is a multiple of the access size), and that the
474 system does alignment checking on pointers (i.e., pointer to objects being
475 read and written must point to properly-aligned data).
477 The descriptions of the
479 functions given below all assume that
480 they are called with proper arguments.
481 If called with invalid arguments or arguments that are out of range
482 (e.g., trying to access data outside of the region mapped when a given
483 handle was created), undefined behaviour results.
484 In that case, they may cause the system to halt, either intentionally
485 (via panic) or unintentionally (by causing a fatal trap or by some other
486 means) or may cause improper operation which is not immediately fatal.
487 Functions which return void or which return data read from bus space
488 (i.e., functions which don't obviously return an error code) do not fail.
489 They could only fail if given invalid arguments, and in that case their
490 behaviour is undefined.
491 Functions which take a count of bytes have undefined results if the specified
495 Several types are defined in
497 to facilitate use of the
499 functions by drivers.
506 type is used to describe bus addresses.
507 It must be an unsigned integral type capable of holding the largest bus
508 address usable by the architecture.
509 This type is primarily used when mapping and unmapping bus space.
515 type is used to describe sizes of ranges in bus space.
516 It must be an unsigned integral type capable of holding the size of the
517 largest bus address range usable on the architecture.
518 This type is used by virtually all of the
520 functions, describing sizes when mapping regions and
521 offsets into regions when performing space access operations.
523 .It Fa bus_space_tag_t
527 type is used to describe a particular bus space on a machine.
528 Its contents are machine-dependent and should be considered opaque by
529 machine-independent code.
530 This type is used by all
532 functions to name the space on which they're operating.
534 .It Fa bus_space_handle_t
537 .Fa bus_space_handle_t
538 type is used to describe a mapping of a range of bus space.
539 Its contents are machine-dependent and should be considered opaque by
540 machine-independent code.
541 This type is used when performing bus space access operations.
543 .Sh MAPPING AND UNMAPPING BUS SPACE
544 Bus space must be mapped before it can be used, and should be
545 unmapped when it is no longer needed.
550 functions provide these capabilities.
552 Some drivers need to be able to pass a subregion of already-mapped bus
553 space to another driver or module within a driver.
555 .Fn bus_space_subregion
556 function allows such subregions to be created.
559 .It Fn bus_space_map "space" "address" "size" "flags" "handlep"
563 function maps the region of bus space named by the
569 If successful, it returns zero and fills in the bus space handle pointed
573 that can be used to access the mapped region.
574 If unsuccessful, it will return non-zero and leave the bus space handle
577 in an undefined state.
581 argument controls how the space is to be mapped.
582 Supported flags include:
583 .Bl -tag -width BUS_SPACE_MAP_CACHEABLE -offset indent
584 .It Dv BUS_SPACE_MAP_CACHEABLE
585 Try to map the space so that accesses can be cached
587 If this flag is not specified, the implementation should map the space so
588 that it will not be cached.
589 This mapping method will only be useful in very rare occasions.
591 This flag must have a value of 1 on all implementations for backward
593 .It Dv BUS_SPACE_MAP_PREFETCHABLE
594 Try to map the space so that accesses can be prefetched by the system,
595 and writes can be buffered.
596 This means, accesses should be side effect free (idempotent).
598 .Fn bus_space_barrier
599 methods will flush the write buffer or force actual read accesses.
600 If this flag is not specified, the
601 implementation should map the space so that it will not be prefetched
603 .It Dv BUS_SPACE_MAP_LINEAR
604 Try to map the space so that its contents can be accessed linearly via
605 normal memory access methods (e.g., pointer dereferencing and structure
609 method can be used to obtain the kernel virtual address of the mapped range.
610 This is useful when software wants to do direct access to a memory
611 device, e.g., a frame buffer.
612 If this flag is specified and linear mapping is not possible, the
615 If this flag is not specified, the system may map the space in whatever
616 way is most convenient.
617 Use of this mapping method is not encouraged for normal device access;
618 where linear access is not essential, use of the
619 .Fn bus_space_read/write
620 methods is strongly recommended.
623 Not all combinations of flags make sense or are supported with all
626 .Dv BUS_SPACE_MAP_CACHEABLE
627 may be meaningless when
628 used on many systems' I/O port spaces, and on some systems
629 .Dv BUS_SPACE_MAP_LINEAR
631 .Dv BUS_SPACE_MAP_PREFETCHABLE
633 When the system hardware or firmware provides hints as to how spaces should be
634 mapped (e.g., the PCI memory mapping registers' "prefetchable" bit), those
635 hints should be followed for maximum compatibility.
636 On some systems, requesting a mapping that cannot be satisfied (e.g.,
637 requesting a non-prefetchable mapping when the system can only provide
638 a prefetchable one) will cause the request to fail.
640 Some implementations may keep track of use of bus space for some or all
641 bus spaces and refuse to allow duplicate allocations.
642 This is encouraged for bus spaces which have no notion of slot-specific
643 space addressing, such as ISA and VME, and for spaces which coexist with
644 those spaces (e.g., EISA and PCI memory and I/O spaces co-existing with
645 ISA memory and I/O spaces).
647 Mapped regions may contain areas for which there is no device on the bus.
648 If space in those areas is accessed, the results are bus-dependent.
650 .It Fn bus_space_unmap "space" "handle" "size"
654 function unmaps a region of bus space mapped with
656 When unmapping a region, the
659 the same as the size given to
661 when mapping that region.
665 is called on a handle, that handle is no longer valid.
666 (If copies were made of the handle they are no longer valid, either.)
668 This function will never fail.
669 If it would fail (e.g., because of an argument error), that indicates
670 a software bug which should cause a panic.
675 .It Fn bus_space_subregion "space" "handle" "offset" "size" "nhandlep"
678 .Fn bus_space_subregion
679 function is a convenience function which makes a
680 new handle to some subregion of an already-mapped region of bus space.
681 The subregion described by the new handle starts at byte offset
683 into the region described by
685 with the size given by
687 and must be wholly contained within the original region.
690 .Fn bus_space_subregion
691 returns zero and fills in the bus
692 space handle pointed to by
694 If unsuccessful, it returns non-zero and leaves the bus space handle
699 In either case, the handle described by
701 remains valid and is unmodified.
703 When done with a handle created by
704 .Fn bus_space_subregion ,
707 Under no circumstances should
709 be used on the handle.
710 Doing so may confuse any resource management being done on the space,
711 and will result in undefined behaviour.
716 is called on a handle, all subregions of that handle become invalid.
718 .It Fn bus_space_vaddr "tag" "handle"
720 This method returns the kernel virtual address of a mapped bus space if and
721 only if it was mapped with the
722 .Dv BUS_SPACE_MAP_LINEAR
724 The range can be accessed by normal (volatile) pointer dereferences.
726 .Dv BUS_SPACE_MAP_PREFETCHABLE
728 .Fn bus_space_barrier
729 method must be used to force a particular access order.
731 .It Fn bus_space_mmap "tag" "addr" "off" "prot" "flags"
733 This method is used to provide support for memory mapping bus space
734 into user applications.
735 If an address space is addressable via volatile pointer dereferences,
737 will return the physical address (possibly encoded as a machine-dependent
738 cookie) of the bus space indicated by
743 is the base address of the device or device region, and
745 is the offset into that region that is being requested.
746 If the request is made with
747 .Dv BUS_SPACE_MAP_LINEAR
748 as a flag, then a linear region must be returned to the caller.
749 If the region cannot be mapped (either the address does not exist,
750 or the constraints can not be met),
756 Note that it is not necessary that the region being requested by a
758 call be mapped into a
759 .Fa bus_space_handle_t .
767 argument indicates the memory protection requested by the user application
770 .Sh ALLOCATING AND FREEING BUS SPACE
771 Some devices require or allow bus space to be allocated by the operating
772 system for device use.
773 When the devices no longer need the space, the
774 operating system should free it for use by other devices.
779 functions provide these capabilities.
782 .It Fn bus_space_alloc "space" "reg_start" "reg_end" "size" "alignment" \
783 "boundary" "flags" "addrp" "handlep"
787 function allocates and maps a region of bus space with the size given by
789 corresponding to the given constraints.
790 If successful, it returns zero, fills in the bus address pointed to by
792 with the bus space address of the allocated region, and fills in
793 the bus space handle pointed to by
795 with the handle that can be used to access that region.
796 If unsuccessful, it returns non-zero and leaves the bus address pointed to by
798 and the bus space handle pointed to by
800 in an undefined state.
802 Constraints on the allocation are given by the
809 The allocated region will start at or after
815 constraint must be a power of two, and the allocated region will start at
816 an address that is an even multiple of that power of two.
819 constraint, if non-zero, ensures that the region is allocated so that
820 .Fa "first address in region"
823 has the same value as
824 .Fa "last address in region"
827 If the constraints cannot be met,
830 It is an error to specify a set of constraints that can never be met
840 parameter is the same as the like-named parameter to
842 the same flag values should be used, and they have the
847 should only be freed with
851 on them causes undefined behaviour.
853 .Fn bus_space_subregion
854 function can be used on handles created by
855 .Fn bus_space_alloc .
857 .It Fn bus_space_free "space" "handle" "size"
861 function unmaps and frees a region of bus space mapped
863 .Fn bus_space_alloc .
864 When unmapping a region, the
866 specified should be the same as the size given to
868 when allocating the region.
872 is called on a handle, that handle is no longer valid.
873 (If copies were made of the handle, they are no longer valid, either.)
875 This function will never fail.
876 If it would fail (e.g., because of an argument error), that indicates
877 a software bug which should cause a panic.
882 .Sh READING AND WRITING SINGLE DATA ITEMS
883 The simplest way to access bus space is to read or write a single data
888 .Fn bus_space_write_N
889 families of functions provide
890 the ability to read and write 1, 2, 4, and 8 byte data items on busses
891 which support those access sizes.
894 .It Fn bus_space_read_1 "space" "handle" "offset"
895 .It Fn bus_space_read_2 "space" "handle" "offset"
896 .It Fn bus_space_read_4 "space" "handle" "offset"
897 .It Fn bus_space_read_8 "space" "handle" "offset"
901 family of functions reads a 1, 2, 4, or 8 byte data item from
902 the offset specified by
904 into the region specified by
906 of the bus space specified by
908 The location being read must lie within the bus space region specified by
911 For portability, the starting address of the region specified by
913 plus the offset should be a multiple of the size of data item being read.
914 On some systems, not obeying this requirement may cause incorrect data to
915 be read, on others it may cause a system crash.
917 Read operations done by the
919 functions may be executed out
920 of order with respect to other pending read and write operations unless
921 order is enforced by use of the
922 .Fn bus_space_barrier
925 These functions will never fail.
926 If they would fail (e.g., because of an argument error), that indicates
927 a software bug which should cause a panic.
928 In that case, they will never return.
930 .It Fn bus_space_write_1 "space" "handle" "offset" "value"
931 .It Fn bus_space_write_2 "space" "handle" "offset" "value"
932 .It Fn bus_space_write_4 "space" "handle" "offset" "value"
933 .It Fn bus_space_write_8 "space" "handle" "offset" "value"
936 .Fn bus_space_write_N
937 family of functions writes a 1, 2, 4, or 8 byte data item to the offset
940 into the region specified by
942 of the bus space specified by
944 The location being written must lie within
945 the bus space region specified by
948 For portability, the starting address of the region specified by
950 plus the offset should be a multiple of the size of data item being
952 On some systems, not obeying this requirement may cause incorrect data
953 to be written, on others it may cause a system crash.
955 Write operations done by the
956 .Fn bus_space_write_N
957 functions may be executed
958 out of order with respect to other pending read and write operations
959 unless order is enforced by use of the
960 .Fn bus_space_barrier
963 These functions will never fail.
964 If they would fail (e.g., because of an argument error), that indicates
965 a software bug which should cause a panic.
966 In that case, they will never return.
968 .Sh PROBING BUS SPACE FOR HARDWARE WHICH MAY NOT RESPOND
972 .Fn bus_space_write_N
973 family of functions is that they provide no protection against
974 exceptions which can occur when no physical hardware or
975 device responds to the read or write cycles.
976 In such a situation, the system typically would panic due to a kernel-mode
982 family of functions provide a mechanism to handle these exceptions
983 gracefully without the risk of crashing the system.
988 .Fn bus_space_write_N ,
989 the peek and poke functions provide the ability to read and
990 write 1, 2, 4, and 8 byte data items on busses which support those
992 All of the constraints specified in the descriptions of the
995 .Fn bus_space_write_N
996 functions also apply to
999 .Fn bus_space_poke_N .
1001 In addition, explicit calls to the
1002 .Fn bus_space_barrier
1003 function are not required as the implementation will ensure all
1004 pending operations complete before the peek or poke operation starts.
1005 The implementation will also ensure that the peek or poke operations
1006 complete before returning.
1008 The return value indicates the outcome of the peek or poke operation.
1009 A return value of zero implies that a hardware device is
1010 responding to the operation at the specified offset in the bus space.
1011 A non-zero return value indicates that the kernel intercepted a
1012 hardware exception (e.g., bus error) when the peek or poke operation
1014 Note that some busses are incapable of generating exceptions when
1015 non-existent hardware is accessed.
1016 In such cases, these functions will always return zero and the value of
1018 .Fn bus_space_peek_N
1019 will be unspecified.
1021 Finally, it should be noted that at this time the
1022 .Fn bus_space_peek_N
1024 .Fn bus_space_poke_N
1025 functions are not re-entrant and should not, therefore, be used
1026 from within an interrupt service routine.
1027 This constraint may be removed at some point in the future.
1030 .It Fn bus_space_peek_1 "space" "handle" "offset" "datap"
1031 .It Fn bus_space_peek_2 "space" "handle" "offset" "datap"
1032 .It Fn bus_space_peek_4 "space" "handle" "offset" "datap"
1033 .It Fn bus_space_peek_8 "space" "handle" "offset" "datap"
1036 .Fn bus_space_peek_N
1037 family of functions cautiously read a 1, 2, 4, or 8 byte data item from
1038 the offset specified by
1040 in the region specified by
1042 of the bus space specified by
1044 The data item read is stored in the location pointed to by
1046 It is permissible for
1048 to be NULL, in which case the data item will be discarded after being read.
1050 .It Fn bus_space_poke_1 "space" "handle" "offset" "value"
1051 .It Fn bus_space_poke_2 "space" "handle" "offset" "value"
1052 .It Fn bus_space_poke_4 "space" "handle" "offset" "value"
1053 .It Fn bus_space_poke_8 "space" "handle" "offset" "value"
1056 .Fn bus_space_poke_N
1057 family of functions cautiously write a 1, 2, 4, or 8 byte data item
1060 to the offset specified by
1062 in the region specified by
1064 of the bus space specified by
1068 In order to allow high-performance buffering implementations to avoid bus
1069 activity on every operation, read and write ordering should be specified
1070 explicitly by drivers when necessary.
1072 .Fn bus_space_barrier
1073 function provides that ability.
1076 .It Fn bus_space_barrier "space" "handle" "offset" "length" "flags"
1079 .Fn bus_space_barrier
1080 function enforces ordering of bus space read and write operations
1081 for the specified subregion (described by the
1085 parameters) of the region named by
1087 in the space named by
1092 argument controls what types of operations are to be ordered.
1093 Supported flags are:
1094 .Bl -tag -width BUS_SPACE_BARRIER_WRITE_BEFORE_WRITE -offset indent
1095 .It Dv BUS_SPACE_BARRIER_READ_BEFORE_READ
1096 Force all reads before the barrier to complete before any reads
1097 after the barrier may be issued.
1098 .It Dv BUS_SPACE_BARRIER_READ_BEFORE_WRITE
1099 Force all reads before the barrier to complete before any writes
1100 after the barrier may be issued.
1101 .It Dv BUS_SPACE_BARRIER_WRITE_BEFORE_READ
1102 Force all writes before the barrier to complete before any reads
1103 after the barrier may be issued.
1104 .It Dv BUS_SPACE_BARRIER_WRITE_BEFORE_WRITE
1105 Force all writes before the barrier to complete before any writes
1106 after the barrier may be issued.
1107 .It Dv BUS_SPACE_BARRIER_SYNC
1108 Force all memory operations and any pending exceptions to be
1109 completed before any instructions after the barrier may be issued.
1112 Those flags can be combined (or-ed together) to enforce ordering on
1113 different combinations of read and write operations.
1115 All of the specified type(s) of operation which are done to the region
1116 before the barrier operation are guaranteed to complete before any of the
1117 specified type(s) of operation done after the barrier.
1119 Example: Consider a hypothetical device with two single-byte ports, one
1120 write-only input port (at offset 0) and a read-only output port (at
1122 Operation of the device is as follows: data bytes are written to the
1123 input port, and are placed by the device on a stack, the top of
1124 which is read by reading from the output port.
1125 The sequence to correctly write two data bytes to the device then read
1126 those two data bytes back would be:
1130 * t and h are the tag and handle for the mapped device's
1133 bus_space_write_1(t, h, 0, data0);
1134 bus_space_barrier(t, h, 0, 1, BUS_SPACE_BARRIER_WRITE_BEFORE_WRITE); /* 1 */
1135 bus_space_write_1(t, h, 0, data1);
1136 bus_space_barrier(t, h, 0, 2, BUS_SPACE_BARRIER_WRITE_BEFORE_READ); /* 2 */
1137 ndata1 = bus_space_read_1(t, h, 1);
1138 bus_space_barrier(t, h, 1, 1, BUS_SPACE_BARRIER_READ_BEFORE_READ); /* 3 */
1139 ndata0 = bus_space_read_1(t, h, 1);
1140 /* data0 == ndata0, data1 == ndata1 */
1143 The first barrier makes sure that the first write finishes before the
1144 second write is issued, so that two writes to the input port are done
1145 in order and are not collapsed into a single write.
1146 This ensures that the data bytes are written to the device correctly and
1149 The second barrier forces the writes to the output port finish before
1150 any of the reads to the input port are issued, thereby making sure
1151 that all of the writes are finished before data is read.
1152 This ensures that the first byte read from the device really is the last
1153 one that was written.
1155 The third barrier makes sure that the first read finishes before the
1156 second read is issued, ensuring that data is read correctly and in order.
1158 The barriers in the example above are specified to cover the absolute
1159 minimum number of bus space locations.
1160 It is correct (and often easier) to make barrier operations cover the
1161 device's whole range of bus space, that is, to specify an offset of zero
1162 and the size of the whole region.
1164 The following barrier operations are obsolete and should be removed
1166 .Bl -tag -width BUS_SPACE_BARRIER_WRITE -offset indent
1167 .It Dv BUS_SPACE_BARRIER_READ
1168 Synchronize read operations.
1169 .It Dv BUS_SPACE_BARRIER_WRITE
1170 Synchronize write operations.
1173 .Sh REGION OPERATIONS
1174 Some devices use buffers which are mapped as regions in bus space.
1175 Often, drivers want to copy the contents of those buffers to or from
1176 memory, e.g., into mbufs which can be passed to higher levels of the
1177 system or from mbufs to be output to a network.
1178 In order to allow drivers to do this as efficiently as possible, the
1179 .Fn bus_space_read_region_N
1181 .Fn bus_space_write_region_N
1182 families of functions are provided.
1184 Drivers occasionally need to copy one region of a bus space to another,
1185 or to set all locations in a region of bus space to contain a single
1188 .Fn bus_space_copy_region_N
1189 family of functions and the
1190 .Fn bus_space_set_region_N
1191 family of functions allow drivers to perform these operations.
1194 .It Fn bus_space_read_region_1 "space" "handle" "offset" "datap" "count"
1195 .It Fn bus_space_read_region_2 "space" "handle" "offset" "datap" "count"
1196 .It Fn bus_space_read_region_4 "space" "handle" "offset" "datap" "count"
1197 .It Fn bus_space_read_region_8 "space" "handle" "offset" "datap" "count"
1200 .Fn bus_space_read_region_N
1201 family of functions reads
1203 1, 2, 4, or 8 byte data items from bus space
1204 starting at byte offset
1206 in the region specified by
1208 of the bus space specified by
1210 and writes them into the array specified by
1212 Each successive data item is read from an offset
1213 1, 2, 4, or 8 bytes after the previous data item (depending on which
1215 All locations being read must lie within the bus space region specified by
1218 For portability, the starting address of the region specified by
1220 plus the offset should be a multiple of the size of data items being
1221 read and the data array pointer should be properly aligned.
1222 On some systems, not obeying these requirements may cause incorrect data
1223 to be read, on others it may cause a system crash.
1225 Read operations done by the
1226 .Fn bus_space_read_region_N
1227 functions may be executed in any order.
1228 They may also be executed out of order with respect to other pending
1229 read and write operations unless order is enforced by use of the
1230 .Fn bus_space_barrier
1232 There is no way to insert barriers between reads of individual bus
1233 space locations executed by the
1234 .Fn bus_space_read_region_N
1237 These functions will never fail.
1238 If they would fail (e.g., because of an argument error), that indicates a
1239 software bug which should cause a panic.
1240 In that case, they will never return.
1242 .It Fn bus_space_write_region_1 "space" "handle" "offset" "datap" "count"
1243 .It Fn bus_space_write_region_2 "space" "handle" "offset" "datap" "count"
1244 .It Fn bus_space_write_region_4 "space" "handle" "offset" "datap" "count"
1245 .It Fn bus_space_write_region_8 "space" "handle" "offset" "datap" "count"
1248 .Fn bus_space_write_region_N
1249 family of functions reads
1251 1, 2, 4, or 8 byte data items from the array
1254 and writes them to bus space starting at byte offset
1256 in the region specified by
1258 of the bus space specified
1261 Each successive data item is written to an offset 1, 2, 4,
1262 or 8 bytes after the previous data item (depending on which function is
1264 All locations being written must lie within the bus space region specified by
1267 For portability, the starting address of the region specified by
1269 plus the offset should be a multiple of the size of data items being
1270 written and the data array pointer should be properly aligned.
1271 On some systems, not obeying these requirements may cause incorrect data
1272 to be written, on others it may cause a system crash.
1274 Write operations done by the
1275 .Fn bus_space_write_region_N
1277 executed in any order.
1278 They may also be executed out of order with respect to other pending read
1279 and write operations unless order is enforced by use of the
1280 .Fn bus_space_barrier
1282 There is no way to insert barriers between writes of individual bus
1283 space locations executed by the
1284 .Fn bus_space_write_region_N
1287 These functions will never fail.
1288 If they would fail (e.g., because of an argument error), that indicates
1289 a software bug which should cause a panic.
1290 In that case, they will never return.
1292 .It Fn bus_space_copy_region_1 "space" "srchandle" "srcoffset" "dsthandle" \
1294 .It Fn bus_space_copy_region_2 "space" "srchandle" "srcoffset" "dsthandle" \
1296 .It Fn bus_space_copy_region_4 "space" "srchandle" "srcoffset" "dsthandle" \
1298 .It Fn bus_space_copy_region_8 "space" "srchandle" "srcoffset" "dsthandle" \
1302 .Fn bus_space_copy_region_N
1303 family of functions copies
1305 1, 2, 4, or 8 byte data items in bus space
1306 from the area starting at byte offset
1308 in the region specified by
1310 of the bus space specified by
1312 to the area starting at byte offset
1314 in the region specified by
1316 in the same bus space.
1317 Each successive data item read or written has an offset 1, 2, 4, or 8
1318 bytes after the previous data item (depending on which function is used).
1319 All locations being read and written must lie within the bus space
1320 region specified by their respective handles.
1322 For portability, the starting addresses of the regions specified by
1323 each handle plus its respective offset should be a multiple of the size
1324 of data items being copied.
1325 On some systems, not obeying this requirement may cause incorrect data
1326 to be copied, on others it may cause a system crash.
1328 Read and write operations done by the
1329 .Fn bus_space_copy_region_N
1330 functions may be executed in any order.
1331 They may also be executed out of order with respect to other pending
1332 read and write operations unless order is enforced by use of the
1333 .Fn bus_space_barrier function .
1334 There is no way to insert barriers between reads or writes of
1335 individual bus space locations executed by the
1336 .Fn bus_space_copy_region_N
1339 Overlapping copies between different subregions of a single region
1340 of bus space are handled correctly by the
1341 .Fn bus_space_copy_region_N
1344 These functions will never fail.
1345 If they would fail (e.g., because of an argument error), that indicates
1346 a software bug which should cause a panic.
1347 In that case, they will never return.
1349 .It Fn bus_space_set_region_1 "space" "handle" "offset" "value" "count"
1350 .It Fn bus_space_set_region_2 "space" "handle" "offset" "value" "count"
1351 .It Fn bus_space_set_region_4 "space" "handle" "offset" "value" "count"
1352 .It Fn bus_space_set_region_8 "space" "handle" "offset" "value" "count"
1355 .Fn bus_space_set_region_N
1356 family of functions writes the given
1361 data items in bus space starting at byte offset
1363 in the region specified by
1365 of the bus space specified by
1367 Each successive data item has an offset 1, 2, 4, or 8 bytes after the
1368 previous data item (depending on which function is used).
1369 All locations being written must lie within the bus space region
1373 For portability, the starting address of the region specified by
1375 plus the offset should be a multiple of the size of data items being
1377 On some systems, not obeying this requirement may cause incorrect data
1378 to be written, on others it may cause a system crash.
1380 Write operations done by the
1381 .Fn bus_space_set_region_N
1383 executed in any order.
1384 They may also be executed out of order with respect to other pending read
1385 and write operations unless order is enforced by use of the
1386 .Fn bus_space_barrier
1388 There is no way to insert barriers between writes of
1389 individual bus space locations executed by the
1390 .Fn bus_space_set_region_N
1393 These functions will never fail.
1394 If they would fail (e.g., because of an argument error), that indicates
1395 a software bug which should cause a panic.
1396 In that case, they will never return.
1398 .Sh READING AND WRITING A SINGLE LOCATION MULTIPLE TIMES
1399 Some devices implement single locations in bus space which are to be read
1400 or written multiple times to communicate data, e.g., some ethernet
1401 devices' packet buffer FIFOs.
1402 In order to allow drivers to manipulate these types of devices as
1403 efficiently as possible, the
1404 .Fn bus_space_read_multi_N
1406 .Fn bus_space_write_multi_N
1407 families of functions are provided.
1410 .It Fn bus_space_read_multi_1 "space" "handle" "offset" "datap" "count"
1411 .It Fn bus_space_read_multi_2 "space" "handle" "offset" "datap" "count"
1412 .It Fn bus_space_read_multi_4 "space" "handle" "offset" "datap" "count"
1413 .It Fn bus_space_read_multi_8 "space" "handle" "offset" "datap" "count"
1416 .Fn bus_space_read_multi_N
1417 family of functions reads
1419 1, 2, 4, or 8 byte data items from bus space
1422 in the region specified by
1424 of the bus space specified by
1426 and writes them into the array specified by
1428 Each successive data item is read from the same location in bus
1430 The location being read must lie within the bus space region specified by
1433 For portability, the starting address of the region specified by
1435 plus the offset should be a multiple of the size of data items being
1436 read and the data array pointer should be properly aligned.
1437 On some systems, not obeying these requirements may cause incorrect data
1438 to be read, on others it may cause a system crash.
1440 Read operations done by the
1441 .Fn bus_space_read_multi_N
1443 executed out of order with respect to other pending read and write
1444 operations unless order is enforced by use of the
1445 .Fn bus_space_barrier
1448 .Fn bus_space_read_multi_N
1449 functions read the same bus space location multiple times, they
1450 place an implicit read barrier between each successive read of that bus
1453 These functions will never fail.
1454 If they would fail (e.g., because of an argument error), that indicates
1455 a software bug which should cause a panic.
1456 In that case, they will never return.
1458 .It Fn bus_space_write_multi_1 "space" "handle" "offset" "datap" "count"
1459 .It Fn bus_space_write_multi_2 "space" "handle" "offset" "datap" "count"
1460 .It Fn bus_space_write_multi_4 "space" "handle" "offset" "datap" "count"
1461 .It Fn bus_space_write_multi_8 "space" "handle" "offset" "datap" "count"
1464 .Fn bus_space_write_multi_N
1465 family of functions reads
1467 1, 2, 4, or 8 byte data items from the array
1470 and writes them into bus space at byte offset
1472 in the region specified by
1474 of the bus space specified by
1476 Each successive data item is written to the same location in
1478 The location being written must lie within the bus space region specified by
1481 For portability, the starting address of the region specified by
1483 plus the offset should be a multiple of the size of data items being
1484 written and the data array pointer should be properly aligned.
1485 On some systems, not obeying these requirements may cause incorrect data
1486 to be written, on others it may cause a system crash.
1488 Write operations done by the
1489 .Fn bus_space_write_multi_N
1490 functions may be executed out of order with respect to other pending
1491 read and write operations unless order is enforced by use of the
1492 .Fn bus_space_barrier
1495 .Fn bus_space_write_multi_N
1496 functions write the same bus space location multiple times, they
1497 place an implicit write barrier between each successive write of that
1500 These functions will never fail.
1501 If they would fail (e.g., because of an argument error), that indicates
1502 a software bug which should cause a panic.
1503 In that case, they will never return.
1505 .Sh STREAM FUNCTIONS
1508 functions imply a host byte-order and a bus byte-order and take care of
1509 any translation for the caller.
1510 In some cases, however, hardware may map a FIFO or some other memory region
1511 for which the caller may want to use multi-word, yet untranslated access.
1512 Access to these types of memory regions should be with the
1513 .Fn bus_space_*_stream_N
1517 .It Fn bus_space_read_stream_1 "space" "handle" "offset"
1518 .It Fn bus_space_read_stream_2 "space" "handle" "offset"
1519 .It Fn bus_space_read_stream_4 "space" "handle" "offset"
1520 .It Fn bus_space_read_stream_8 "space" "handle" "offset"
1521 .It Fn bus_space_read_multi_stream_1 "space" "handle" "offset" "datap" "count"
1522 .It Fn bus_space_read_multi_stream_2 "space" "handle" "offset" "datap" "count"
1523 .It Fn bus_space_read_multi_stream_4 "space" "handle" "offset" "datap" "count"
1524 .It Fn bus_space_read_multi_stream_8 "space" "handle" "offset" "datap" "count"
1525 .It Fn bus_space_read_region_stream_1 "space" "handle" "offset" "datap" "count"
1526 .It Fn bus_space_read_region_stream_2 "space" "handle" "offset" "datap" "count"
1527 .It Fn bus_space_read_region_stream_4 "space" "handle" "offset" "datap" "count"
1528 .It Fn bus_space_read_region_stream_8 "space" "handle" "offset" "datap" "count"
1529 .It Fn bus_space_write_stream_1 "space" "handle" "offset" "value"
1530 .It Fn bus_space_write_stream_2 "space" "handle" "offset" "value"
1531 .It Fn bus_space_write_stream_4 "space" "handle" "offset" "value"
1532 .It Fn bus_space_write_stream_8 "space" "handle" "offset" "value"
1533 .It Fn bus_space_write_multi_stream_1 "space" "handle" "offset" "datap" "count"
1534 .It Fn bus_space_write_multi_stream_2 "space" "handle" "offset" "datap" "count"
1535 .It Fn bus_space_write_multi_stream_4 "space" "handle" "offset" "datap" "count"
1536 .It Fn bus_space_write_multi_stream_8 "space" "handle" "offset" "datap" "count"
1537 .It Fn bus_space_write_region_stream_1 "space" "handle" "offset" "datap" "count"
1538 .It Fn bus_space_write_region_stream_2 "space" "handle" "offset" "datap" "count"
1539 .It Fn bus_space_write_region_stream_4 "space" "handle" "offset" "datap" "count"
1540 .It Fn bus_space_write_region_stream_8 "space" "handle" "offset" "datap" "count"
1543 These functions are defined just as their non-stream counterparts,
1544 except that they provide no byte-order translation.
1545 .Sh EXPECTED CHANGES TO THE BUS_SPACE FUNCTIONS
1546 The definition of the
1548 functions should not yet be considered finalized.
1549 There are several changes and improvements which should be explored,
1554 Providing a mechanism by which incorrectly-written drivers will be
1555 automatically given barriers and properly-written drivers won't be forced
1556 to use more barriers than they need.
1557 This should probably be done via a
1559 in the incorrectly-written drivers.
1560 Unfortunately, at this time, few drivers actually use barriers correctly
1564 implementations on architectures which do buffering must always
1565 do the barriers inside the
1568 That has a potentially significant performance impact.
1572 functions to user-land so that applications
1573 (such as X servers) have easier, more portable access to device space.
1575 Redefining bus space tags and handles so that machine-independent bus
1576 interface drivers (for example PCI to VME bridges) could define and
1577 implement bus spaces without requiring machine-dependent code.
1578 If this is done, it should be done in such a way that machine-dependent
1579 optimizations should remain possible.
1581 Converting bus spaces (such as PCI configuration space) which currently
1582 use space-specific access methods to use the
1584 functions where that is appropriate.
1586 Redefining the way bus space is mapped and allocated, so that mapping
1587 and allocation are done with bus specific functions which return bus
1589 This would allow further optimization than is currently possible, and
1590 would also ease translation of the
1592 functions into user space (since mapping in user space would look like
1593 it just used a different bus-specific mapping function).
1596 The current version of the
1598 interface specification differs slightly from the original
1599 specification that came into wide use.
1600 A few of the function names and arguments have changed
1601 for consistency and increased functionality.
1602 Drivers that were written to the
1603 old, deprecated specification can be compiled by defining the
1604 .Dv __BUS_SPACE_COMPAT_OLDDEFS
1605 preprocessor symbol before including
1606 .Aq Pa machine/bus.h .
1613 functions were introduced in a different form (memory and I/O spaces
1614 were accessed via different sets of functions) in
1616 The functions were merged to work on generic
1620 development cycle, and many drivers were converted to use them.
1621 This document was written later during the
1623 development cycle and the specification was updated to fix some
1624 consistency problems and to add some missing functionality.
1628 interfaces were designed and implemented by the
1632 Primary contributors and implementors were Chris Demetriou,
1633 Jason Thorpe, and Charles Hannum, but the rest of the
1635 developers and the user community played a significant role in development.
1637 Chris Demetriou wrote this manual page.