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