1 /* $NetBSD: object.h,v 1.7 2021/12/19 10:51:56 riastradh Exp $ */ 2 3 /* SPDX-License-Identifier: MIT */ 4 #ifndef __NVKM_OBJECT_H__ 5 #define __NVKM_OBJECT_H__ 6 #include <core/oclass.h> 7 struct nvkm_event; 8 struct nvkm_gpuobj; 9 10 struct nvkm_object { 11 const struct nvkm_object_func *func; 12 struct nvkm_client *client; 13 struct nvkm_engine *engine; 14 s32 oclass; 15 u32 handle; 16 17 struct list_head head; 18 struct list_head tree; 19 u8 route; 20 u64 token; 21 u64 object; 22 struct rb_node node; 23 #ifdef __NetBSD__ 24 bool on_tree; 25 #endif 26 }; 27 28 enum nvkm_object_map { 29 NVKM_OBJECT_MAP_IO, 30 NVKM_OBJECT_MAP_VA 31 }; 32 33 struct nvkm_object_func { 34 void *(*dtor)(struct nvkm_object *); 35 int (*init)(struct nvkm_object *); 36 int (*fini)(struct nvkm_object *, bool suspend); 37 int (*mthd)(struct nvkm_object *, u32 mthd, void *data, u32 size); 38 int (*ntfy)(struct nvkm_object *, u32 mthd, struct nvkm_event **); 39 #ifdef __NetBSD__ 40 int (*map)(struct nvkm_object *, void *argv, u32 argc, 41 enum nvkm_object_map *, 42 bus_space_tag_t *tagp, u64 *addr, u64 *size); 43 #else 44 int (*map)(struct nvkm_object *, void *argv, u32 argc, 45 enum nvkm_object_map *, u64 *addr, u64 *size); 46 #endif 47 int (*unmap)(struct nvkm_object *); 48 int (*rd08)(struct nvkm_object *, u64 addr, u8 *data); 49 int (*rd16)(struct nvkm_object *, u64 addr, u16 *data); 50 int (*rd32)(struct nvkm_object *, u64 addr, u32 *data); 51 int (*wr08)(struct nvkm_object *, u64 addr, u8 data); 52 int (*wr16)(struct nvkm_object *, u64 addr, u16 data); 53 int (*wr32)(struct nvkm_object *, u64 addr, u32 data); 54 int (*bind)(struct nvkm_object *, struct nvkm_gpuobj *, int align, 55 struct nvkm_gpuobj **); 56 int (*sclass)(struct nvkm_object *, int index, struct nvkm_oclass *); 57 }; 58 59 void nvkm_object_ctor(const struct nvkm_object_func *, 60 const struct nvkm_oclass *, struct nvkm_object *); 61 int nvkm_object_new_(const struct nvkm_object_func *, 62 const struct nvkm_oclass *, void *data, u32 size, 63 struct nvkm_object **); 64 int nvkm_object_new(const struct nvkm_oclass *, void *data, u32 size, 65 struct nvkm_object **); 66 void nvkm_object_del(struct nvkm_object **); 67 void *nvkm_object_dtor(struct nvkm_object *); 68 int nvkm_object_init(struct nvkm_object *); 69 int nvkm_object_fini(struct nvkm_object *, bool suspend); 70 int nvkm_object_mthd(struct nvkm_object *, u32 mthd, void *data, u32 size); 71 int nvkm_object_ntfy(struct nvkm_object *, u32 mthd, struct nvkm_event **); 72 #ifdef __NetBSD__ 73 int nvkm_object_map(struct nvkm_object *, void *argv, u32 argc, 74 enum nvkm_object_map *, 75 bus_space_tag_t *, u64 *addr, u64 *size); 76 #else 77 int nvkm_object_map(struct nvkm_object *, void *argv, u32 argc, 78 enum nvkm_object_map *, u64 *addr, u64 *size); 79 #endif 80 int nvkm_object_unmap(struct nvkm_object *); 81 int nvkm_object_rd08(struct nvkm_object *, u64 addr, u8 *data); 82 int nvkm_object_rd16(struct nvkm_object *, u64 addr, u16 *data); 83 int nvkm_object_rd32(struct nvkm_object *, u64 addr, u32 *data); 84 int nvkm_object_wr08(struct nvkm_object *, u64 addr, u8 data); 85 int nvkm_object_wr16(struct nvkm_object *, u64 addr, u16 data); 86 int nvkm_object_wr32(struct nvkm_object *, u64 addr, u32 data); 87 int nvkm_object_bind(struct nvkm_object *, struct nvkm_gpuobj *, int align, 88 struct nvkm_gpuobj **); 89 90 bool nvkm_object_insert(struct nvkm_object *); 91 void nvkm_object_remove(struct nvkm_object *); 92 struct nvkm_object *nvkm_object_search(struct nvkm_client *, u64 object, 93 const struct nvkm_object_func *); 94 #endif 95