CVS commit: src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif
Module Name:src Committed By: jmcneill Date: Sat Dec 7 13:31:41 UTC 2019 Modified Files: src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif: os.h Log Message: Fix build for ports without __BUS_SPACE_HAS_STREAM_METHODS defined To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 \ src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/os.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/os.h diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/os.h:1.4 src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/os.h:1.5 --- src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/os.h:1.4 Mon Aug 27 07:35:13 2018 +++ src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/os.h Sat Dec 7 13:31:41 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: os.h,v 1.4 2018/08/27 07:35:13 riastradh Exp $ */ +/* $NetBSD: os.h,v 1.5 2019/12/07 13:31:41 jmcneill Exp $ */ #ifndef __NOUVEAU_OS_H__ #define __NOUVEAU_OS_H__ @@ -74,4 +74,14 @@ #endif /* !ioread32_native */ #endif +#ifdef __NetBSD__ +#include +#ifndef __BUS_SPACE_HAS_STREAM_METHODS +#define bus_space_read_stream_2 bus_space_read_2 +#define bus_space_read_stream_4 bus_space_read_4 +#define bus_space_write_stream_2 bus_space_write_2 +#define bus_space_write_stream_4 bus_space_write_4 +#endif +#endif + #endif
CVS commit: src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif
Module Name:src Committed By: riastradh Date: Mon Aug 27 14:47:29 UTC 2018 Modified Files: src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif: object.h Log Message: Let's not truncate registers to 8-bit when we read them, shall we? To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 \ src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/object.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/object.h diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/object.h:1.5 src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/object.h:1.6 --- src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/object.h:1.5 Mon Aug 27 14:47:16 2018 +++ src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/object.h Mon Aug 27 14:47:29 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: object.h,v 1.5 2018/08/27 14:47:16 riastradh Exp $ */ +/* $NetBSD: object.h,v 1.6 2018/08/27 14:47:29 riastradh Exp $ */ #ifndef __NVIF_OBJECT_H__ #define __NVIF_OBJECT_H__ @@ -60,7 +60,7 @@ nvif_rd08(struct nvif_object *obj, uint6 else return nvif_object_rd(obj, 1, offset); } -static inline uint8_t +static inline uint16_t nvif_rd16(struct nvif_object *obj, uint64_t offset) { if (obj->map.ptr) @@ -69,7 +69,7 @@ nvif_rd16(struct nvif_object *obj, uint6 else return nvif_object_rd(obj, 2, offset); } -static inline uint8_t +static inline uint32_t nvif_rd32(struct nvif_object *obj, uint64_t offset) { if (obj->map.ptr)
CVS commit: src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif
Module Name:src Committed By: riastradh Date: Mon Aug 27 14:47:16 UTC 2018 Modified Files: src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif: object.h Log Message: Use bus_space now that we have the tag and handle. Fix possible byte order issue while here. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 \ src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/object.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/object.h diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/object.h:1.4 src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/object.h:1.5 --- src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/object.h:1.4 Mon Aug 27 07:35:56 2018 +++ src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/object.h Mon Aug 27 14:47:16 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: object.h,v 1.4 2018/08/27 07:35:56 riastradh Exp $ */ +/* $NetBSD: object.h,v 1.5 2018/08/27 14:47:16 riastradh Exp $ */ #ifndef __NVIF_OBJECT_H__ #define __NVIF_OBJECT_H__ @@ -14,51 +14,6 @@ struct nvif_sclass { #ifdef __NetBSD__ # define __nvif_iomem volatile # define __iomem __nvif_iomem -# define ioread8 nvif_object_ioread8 -# define ioread16 nvif_object_ioread32 -# define ioread32 nvif_object_ioread16 -# define iowrite8 nvif_object_iowrite8 -# define iowrite16 nvif_object_iowrite16 -# define iowrite32 nvif_object_iowrite32 -static inline uint8_t -ioread8(const void __iomem *p) -{ - uint8_t v = *(const uint8_t __iomem *)p; - membar_consumer(); - return v; -} -static inline uint8_t -ioread16(const void __iomem *p) -{ - uint16_t v = *(const uint16_t __iomem *)p; - membar_consumer(); - return v; -} -static inline uint8_t -ioread32(const void __iomem *p) -{ - uint32_t v = *(const uint32_t __iomem *)p; - membar_consumer(); - return v; -} -static inline void -iowrite8(uint8_t v, void __iomem *p) -{ - membar_producer(); - *(uint8_t __iomem *)p = v; -} -static inline void -iowrite16(uint16_t v, void __iomem *p) -{ - membar_producer(); - *(uint16_t __iomem *)p = v; -} -static inline void -iowrite32(uint32_t v, void __iomem *p) -{ - membar_producer(); - *(uint32_t __iomem *)p = v; -} #endif struct nvif_object { @@ -76,6 +31,10 @@ struct nvif_object { } map; }; +#ifdef __NetBSD__ +# undef __iomem +#endif + int nvif_object_init(struct nvif_object *, u32 handle, s32 oclass, void *, u32, struct nvif_object *); void nvif_object_fini(struct nvif_object *); @@ -91,55 +50,77 @@ void nvif_object_unmap(struct nvif_objec #define nvif_handle(a) (unsigned long)(void *)(a) #define nvif_object(a) (a)->object -#define nvif_rd(a,f,b,c) ({\ - struct nvif_object *_object = (a); \ - u32 _data; \ - if (likely(_object->map.ptr)) \ - _data = f((u8 __iomem *)_object->map.ptr + (c)); \ - else \ - _data = nvif_object_rd(_object, (b), (c)); \ - _data; \ -}) -#define nvif_wr(a,f,b,c,d) ({ \ - struct nvif_object *_object = (a); \ - if (likely(_object->map.ptr)) \ - f((d), (u8 __iomem *)_object->map.ptr + (c)); \ - else \ - nvif_object_wr(_object, (b), (c), (d));\ -}) #ifdef __NetBSD__ -/* Force expansion now. */ static inline uint8_t nvif_rd08(struct nvif_object *obj, uint64_t offset) { - return nvif_rd(obj, ioread8, 1, offset); + if (obj->map.ptr) + return bus_space_read_1(obj->map.tag, obj->map.handle, + offset); + else + return nvif_object_rd(obj, 1, offset); } static inline uint8_t nvif_rd16(struct nvif_object *obj, uint64_t offset) { - return nvif_rd(obj, ioread16, 2, offset); + if (obj->map.ptr) + return bus_space_read_stream_2(obj->map.tag, obj->map.handle, + offset); + else + return nvif_object_rd(obj, 2, offset); } static inline uint8_t nvif_rd32(struct nvif_object *obj, uint64_t offset) { - return nvif_rd(obj, ioread32, 4, offset); + if (obj->map.ptr) + return bus_space_read_stream_4(obj->map.tag, obj->map.handle, + offset); + else + return nvif_object_rd(obj, 4, offset); } static inline void nvif_wr08(struct nvif_object *obj, uint64_t offset, uint8_t v) { - nvif_wr(obj, iowrite8, 1, offset, v); + if (obj->map.ptr) + bus_space_write_1(obj->map.tag, obj->map.handle, offset, v); + else + nvif_object_wr(obj, 1, offset, v); } static inline void nvif_wr16(struct nvif_object *obj, uint64_t offset,
CVS commit: src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif
Module Name:src Committed By: riastradh Date: Mon Aug 27 07:35:13 UTC 2018 Modified Files: src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif: os.h Log Message: Add some necessary includes to the hodgepodge. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 \ src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/os.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/os.h diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/os.h:1.3 src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/os.h:1.4 --- src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/os.h:1.3 Mon Aug 27 07:32:50 2018 +++ src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/os.h Mon Aug 27 07:35:13 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: os.h,v 1.3 2018/08/27 07:32:50 riastradh Exp $ */ +/* $NetBSD: os.h,v 1.4 2018/08/27 07:35:13 riastradh Exp $ */ #ifndef __NOUVEAU_OS_H__ #define __NOUVEAU_OS_H__ @@ -40,7 +40,13 @@ #include #include #include +#include +#include +#include +#include +#include +#include #include #include #include @@ -48,6 +54,10 @@ #include #include +#ifdef __NetBSD__ +#include /* drm_waitqueue_t, IRQ_HANDLED */ +#endif + #ifndef __NetBSD__ /* XXX ioread */ #ifndef ioread32_native #ifdef __BIG_ENDIAN
CVS commit: src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif
Module Name:src Committed By: riastradh Date: Mon Aug 27 07:32:50 UTC 2018 Modified Files: src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif: os.h Log Message: We need this for something. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 \ src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/os.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/os.h diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/os.h:1.2 src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/os.h:1.3 --- src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/os.h:1.2 Mon Aug 27 04:58:30 2018 +++ src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/os.h Mon Aug 27 07:32:50 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: os.h,v 1.2 2018/08/27 04:58:30 riastradh Exp $ */ +/* $NetBSD: os.h,v 1.3 2018/08/27 07:32:50 riastradh Exp $ */ #ifndef __NOUVEAU_OS_H__ #define __NOUVEAU_OS_H__ @@ -39,6 +39,7 @@ #include #include #include +#include #include #include
CVS commit: src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif
Module Name:src Committed By: riastradh Date: Mon Aug 27 07:32:59 UTC 2018 Modified Files: src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif: driver.h object.h Log Message: Attempt to work out nvif iomem crud. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 \ src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/driver.h \ src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/object.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/driver.h diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/driver.h:1.2 src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/driver.h:1.3 --- src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/driver.h:1.2 Mon Aug 27 04:58:30 2018 +++ src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/driver.h Mon Aug 27 07:32:59 2018 @@ -1,8 +1,13 @@ -/* $NetBSD: driver.h,v 1.2 2018/08/27 04:58:30 riastradh Exp $ */ +/* $NetBSD: driver.h,v 1.3 2018/08/27 07:32:59 riastradh Exp $ */ #ifndef __NVIF_DRIVER_H__ #define __NVIF_DRIVER_H__ +#ifdef __NetBSD__ +# define __nvif_iomem volatile +# define __iomem __nvif_iomem +#endif + struct nvif_driver { const char *name; int (*init)(const char *name, u64 device, const char *cfg, @@ -16,6 +21,10 @@ struct nvif_driver { bool keep; }; +#ifdef __NetBSD__ +# undef __iomem +#endif + extern const struct nvif_driver nvif_driver_nvkm; extern const struct nvif_driver nvif_driver_drm; extern const struct nvif_driver nvif_driver_lib; Index: src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/object.h diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/object.h:1.2 src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/object.h:1.3 --- src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/object.h:1.2 Mon Aug 27 04:58:30 2018 +++ src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/object.h Mon Aug 27 07:32:59 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: object.h,v 1.2 2018/08/27 04:58:30 riastradh Exp $ */ +/* $NetBSD: object.h,v 1.3 2018/08/27 07:32:59 riastradh Exp $ */ #ifndef __NVIF_OBJECT_H__ #define __NVIF_OBJECT_H__ @@ -11,6 +11,56 @@ struct nvif_sclass { int maxver; }; +#ifdef __NetBSD__ +# define __nvif_iomem volatile +# define __iomem __nvif_iomem +# define ioread8 nvif_object_ioread8 +# define ioread16 nvif_object_ioread32 +# define ioread32 nvif_object_ioread16 +# define iowrite8 nvif_object_iowrite8 +# define iowrite16 nvif_object_iowrite16 +# define iowrite32 nvif_object_iowrite32 +static inline uint8_t +ioread8(const void __iomem *p) +{ + uint8_t v = *(const uint8_t __iomem *)p; + membar_consumer(); + return v; +} +static inline uint8_t +ioread16(const void __iomem *p) +{ + uint16_t v = *(const uint16_t __iomem *)p; + membar_consumer(); + return v; +} +static inline uint8_t +ioread32(const void __iomem *p) +{ + uint32_t v = *(const uint32_t __iomem *)p; + membar_consumer(); + return v; +} +static inline void +iowrite8(uint8_t v, void __iomem *p) +{ + membar_producer(); + *(uint8_t __iomem *)p = v; +} +static inline void +iowrite16(uint16_t v, void __iomem *p) +{ + membar_producer(); + *(uint16_t __iomem *)p = v; +} +static inline void +iowrite32(uint32_t v, void __iomem *p) +{ + membar_producer(); + *(uint32_t __iomem *)p = v; +} +#endif + struct nvif_object { struct nvif_client *client; u32 handle; @@ -53,12 +103,46 @@ void nvif_object_unmap(struct nvif_objec else \ nvif_object_wr(_object, (b), (c), (d));\ }) +#ifdef __NetBSD__ +/* Force expansion now. */ +static inline uint8_t +nvif_rd08(struct nvif_object *obj, uint64_t offset) +{ + return nvif_rd(obj, ioread8, 1, offset); +} +static inline uint8_t +nvif_rd16(struct nvif_object *obj, uint64_t offset) +{ + return nvif_rd(obj, ioread16, 2, offset); +} +static inline uint8_t +nvif_rd32(struct nvif_object *obj, uint64_t offset) +{ + return nvif_rd(obj, ioread32, 4, offset); +} +static inline void +nvif_wr08(struct nvif_object *obj, uint64_t offset, uint8_t v) +{ + nvif_wr(obj, iowrite8, 1, offset, v); +} +static inline void +nvif_wr16(struct nvif_object *obj, uint64_t offset, uint16_t v) +{ + nvif_wr(obj, iowrite16, 2, offset, v); +} +static inline void +nvif_wr32(struct nvif_object *obj, uint64_t offset, uint32_t v) +{ + nvif_wr(obj, iowrite32, 4, offset, v); +} +#else #define nvif_rd08(a,b) ({ ((u8)nvif_rd((a), ioread8, 1, (b))); }) #define nvif_rd16(a,b) ({ ((u16)nvif_rd((a), ioread16_native, 2, (b))); }) #define nvif_rd32(a,b) ({ ((u32)nvif_rd((a), ioread32_native, 4, (b))); }) #define nvif_wr08(a,b,c) nvif_wr((a), iowrite8, 1, (b), (u8)(c)) #define nvif_wr16(a,b,c) nvif_wr((a), iowrite16_native, 2, (b), (u16)(c)) #define nvif_wr32(a,b,c) nvif_wr((a), iowrite32_native, 4, (b), (u32)(c)) +#endif