aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/rman.h
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2016-05-20 17:57:47 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2016-05-20 17:57:47 +0000
commitcc981af2045c3c0379c237576737f8f128da1ba5 (patch)
tree3aa16fa17a986984dd375052ea627ea43a7d21dd /sys/sys/rman.h
parentc99d7183654cfcc5a3ff71bcad5ff9758feb023e (diff)
downloadsrc-cc981af2045c3c0379c237576737f8f128da1ba5.tar.gz
src-cc981af2045c3c0379c237576737f8f128da1ba5.zip
Add new bus methods for mapping resources.
Add a pair of bus methods that can be used to "map" resources for direct CPU access using bus_space(9). bus_map_resource() creates a mapping and bus_unmap_resource() releases a previously created mapping. Mappings are described by 'struct resource_map' object. Pointers to these objects can be passed as the first argument to the bus_space wrapper API used for bus resources. Drivers that wish to map all of a resource using default settings (for example, using uncacheable memory attributes) do not need to change. However, drivers that wish to use non-default settings can now do so without jumping through hoops. First, an RF_UNMAPPED flag is added to request that a resource is not implicitly mapped with the default settings when it is activated. This permits other activation steps (such as enabling I/O or memory decoding in a device's PCI command register) to be taken without creating a mapping. Right now the AGP drivers don't set RF_ACTIVE to avoid using up a large amount of KVA to map the AGP aperture on 32-bit platforms. Once RF_UNMAPPED is supported on all platforms that support AGP this can be changed to using RF_UNMAPPED with RF_ACTIVE instead. Second, bus_map_resource accepts an optional structure that defines additional settings for a given mapping. For example, a driver can now request to map only a subset of a resource instead of the entire range. The AGP driver could also use this to only map the first page of the aperture (IIRC, it calls pmap_mapdev() directly to map the first page currently). I will also eventually change the PCI-PCI bridge driver to request mappings of the subset of the I/O window resource on its parent side to create mappings for child devices rather than passing child resources directly up to nexus to be mapped. This also permits bridges that do address translation to request suitable mappings from a resource on the "upper" side of the bus when mapping resources on the "lower" side of the bus. Another attribute that can be specified is an alternate memory attribute for memory-mapped resources. This can be used to request a Write-Combining mapping of a PCI BAR in an MI fashion. (Currently the drivers that do this call pmap_change_attr() directly for x86 only.) Note that this commit only adds the MI framework. Each platform needs to add support for handling RF_UNMAPPED and thew new bus_map/unmap_resource methods. Generally speaking, any drivers that are calling rman_set_bustag() and rman_set_bushandle() need to be updated. Discussed on: arch Reviewed by: cem Differential Revision: https://reviews.freebsd.org/D5237
Notes
Notes: svn path=/head/; revision=300317
Diffstat (limited to 'sys/sys/rman.h')
-rw-r--r--sys/sys/rman.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/sys/sys/rman.h b/sys/sys/rman.h
index 16899a9f99b8..9d1cd584d764 100644
--- a/sys/sys/rman.h
+++ b/sys/sys/rman.h
@@ -47,6 +47,7 @@
#define RF_FIRSTSHARE 0x0020 /* first in sharing list */
#define RF_PREFETCHABLE 0x0040 /* resource is prefetchable */
#define RF_OPTIONAL 0x0080 /* for bus_alloc_resources() */
+#define RF_UNMAPPED 0x0100 /* don't map resource when activating */
#define RF_ALIGNMENT_SHIFT 10 /* alignment size bit starts bit 10 */
#define RF_ALIGNMENT_MASK (0x003F << RF_ALIGNMENT_SHIFT)
@@ -105,6 +106,7 @@ struct resource {
};
struct resource_i;
+struct resource_map;
TAILQ_HEAD(resource_head, resource_i);
@@ -127,6 +129,7 @@ bus_space_tag_t rman_get_bustag(struct resource *);
rman_res_t rman_get_end(struct resource *);
struct device *rman_get_device(struct resource *);
u_int rman_get_flags(struct resource *);
+void rman_get_mapping(struct resource *, struct resource_map *);
int rman_get_rid(struct resource *);
rman_res_t rman_get_size(struct resource *);
rman_res_t rman_get_start(struct resource *);
@@ -150,6 +153,7 @@ void rman_set_bushandle(struct resource *_r, bus_space_handle_t _h);
void rman_set_bustag(struct resource *_r, bus_space_tag_t _t);
void rman_set_device(struct resource *_r, struct device *_dev);
void rman_set_end(struct resource *_r, rman_res_t _end);
+void rman_set_mapping(struct resource *, struct resource_map *);
void rman_set_rid(struct resource *_r, int _rid);
void rman_set_start(struct resource *_r, rman_res_t _start);
void rman_set_virtual(struct resource *_r, void *_v);