summaryrefslogtreecommitdiff
path: root/sys/dev/pci/drm/drm_memory.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/pci/drm/drm_memory.c')
-rw-r--r--sys/dev/pci/drm/drm_memory.c83
1 files changed, 83 insertions, 0 deletions
diff --git a/sys/dev/pci/drm/drm_memory.c b/sys/dev/pci/drm/drm_memory.c
index c727da1202b..44714ca310b 100644
--- a/sys/dev/pci/drm/drm_memory.c
+++ b/sys/dev/pci/drm/drm_memory.c
@@ -174,3 +174,86 @@ drm_mtrr_del(int __unused handle, unsigned long offset, size_t size, int flags)
return 0;
#endif
}
+
+u_int8_t
+drm_read8(drm_local_map_t *map, unsigned long offset)
+{
+ u_int8_t *ptr;
+
+ switch (map->type) {
+ case _DRM_SCATTER_GATHER:
+ ptr = map->handle + offset;
+ return (*ptr);
+
+ default:
+ return (bus_space_read_1(map->bst, map->bsh, offset));
+ }
+}
+
+u_int16_t
+drm_read16(drm_local_map_t *map, unsigned long offset)
+{
+ u_int16_t *ptr;
+ switch (map->type) {
+ case _DRM_SCATTER_GATHER:
+ ptr = map->handle + offset;
+ return (*ptr);
+ default:
+ return (bus_space_read_2(map->bst, map->bsh, offset));
+ }
+}
+
+u_int32_t
+drm_read32(drm_local_map_t *map, unsigned long offset)
+{
+ u_int32_t *ptr;
+ switch (map->type) {
+ case _DRM_SCATTER_GATHER:
+ ptr = map->handle + offset;
+ return (*ptr);
+ default:
+ return (bus_space_read_4(map->bst, map->bsh, offset));
+ }
+}
+
+void
+drm_write8(drm_local_map_t *map, unsigned long offset, u_int8_t val)
+{
+ u_int8_t *ptr;
+ switch (map->type) {
+ case _DRM_SCATTER_GATHER:
+ ptr = map->handle + offset;
+ *ptr = val;
+ break;
+ default:
+ bus_space_write_1(map->bst, map->bsh, offset, val);
+ }
+}
+
+void
+drm_write16(drm_local_map_t *map, unsigned long offset, u_int16_t val)
+{
+ u_int16_t *ptr;
+ switch (map->type) {
+ case _DRM_SCATTER_GATHER:
+ ptr = map->handle + offset;
+ *ptr = val;
+ break;
+ default:
+ bus_space_write_2(map->bst, map->bsh, offset, val);
+ }
+}
+
+void
+drm_write32(drm_local_map_t *map, unsigned long offset, u_int32_t val)
+{
+ u_int32_t *ptr;
+ switch (map->type) {
+ case _DRM_SCATTER_GATHER:
+ ptr = map->handle + offset;
+ *ptr = val;
+ break;
+ default:
+ bus_space_write_4(map->bst, map->bsh, offset, val);
+ }
+}