Index: sys/compat/linuxkpi/common/include/linux/dma-buf-map.h =================================================================== --- sys/compat/linuxkpi/common/include/linux/dma-buf-map.h +++ sys/compat/linuxkpi/common/include/linux/dma-buf-map.h @@ -1,5 +1,14 @@ /* Public domain. */ +/* + * FreeBSD: + * was renamed to in Linux 5.18. The + * exported functions and constants were also renamed accordingly. + * + * We still have to maintain compatibility for all the + * DRM driver version we support. + */ + #ifndef _LINUX_DMA_BUF_MAP_H #define _LINUX_DMA_BUF_MAP_H Index: sys/compat/linuxkpi/common/include/linux/iosys-map.h =================================================================== --- /dev/null +++ sys/compat/linuxkpi/common/include/linux/iosys-map.h @@ -0,0 +1,100 @@ +/* Public domain. */ + +/* + * FreeBSD: + * was renamed to in Linux 5.18. The + * exported functions and constants were also renamed accordingly. + * + * We still have to maintain compatibility for all the + * DRM driver version we support. + */ + +#ifndef _LINUX_IOSYS_MAP_H +#define _LINUX_IOSYS_MAP_H + +#include +#include + +struct iosys_map { + union { + void *vaddr_iomem; + void *vaddr; + }; + bool is_iomem; +}; + +static inline void +iosys_map_incr(struct iosys_map *dbm, size_t n) +{ + if (dbm->is_iomem) + dbm->vaddr_iomem += n; + else + dbm->vaddr += n; +} + +static inline void +iosys_map_memcpy_to(struct iosys_map *dbm, const void *src, size_t len) +{ + if (dbm->is_iomem) + memcpy_toio(dbm->vaddr_iomem, src, len); + else + memcpy(dbm->vaddr, src, len); +} + +static inline bool +iosys_map_is_null(const struct iosys_map *dbm) +{ + if (dbm->is_iomem) + return (dbm->vaddr_iomem == NULL); + else + return (dbm->vaddr == NULL); +} + +static inline bool +iosys_map_is_set(const struct iosys_map *dbm) +{ + if (dbm->is_iomem) + return (dbm->vaddr_iomem != NULL); + else + return (dbm->vaddr != NULL); +} + +static inline bool +iosys_map_is_equal( + const struct iosys_map *dbm_a, const struct iosys_map *dbm_b) +{ + if (dbm_a->is_iomem != dbm_b->is_iomem) + return (false); + + if (dbm_a->is_iomem) + return (dbm_a->vaddr_iomem == dbm_b->vaddr_iomem); + else + return (dbm_a->vaddr == dbm_b->vaddr); +} + +static inline void +iosys_map_clear(struct iosys_map *dbm) +{ + if (dbm->is_iomem) { + dbm->vaddr_iomem = NULL; + dbm->is_iomem = false; + } else { + dbm->vaddr = NULL; + } +} + +static inline void +iosys_map_set_vaddr_iomem(struct iosys_map *dbm, void *addr) +{ + dbm->vaddr_iomem = addr; + dbm->is_iomem = true; +} + +static inline void +iosys_map_set_vaddr(struct iosys_map *dbm, void *addr) +{ + dbm->vaddr = addr; + dbm->is_iomem = false; +} + +#endif