1 /**************************************************************************
3 * Copyright 2006-2008 Tungsten Graphics, Inc., Cedar Park, TX., USA
5 * Copyright 2009 Vmware, Inc., Palo Alto, CA., USA
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the
10 * "Software"), to deal in the Software without restriction, including
11 * without limitation the rights to use, copy, modify, merge, publish,
12 * distribute, sub license, and/or sell copies of the Software, and to
13 * permit persons to whom the Software is furnished to do so, subject to
14 * the following conditions:
16 * The above copyright notice and this permission notice (including the
17 * next paragraph) shall be included in all copies or substantial portions
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
23 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
24 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
25 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
26 * USE OR OTHER DEALINGS IN THE SOFTWARE.
28 **************************************************************************/
30 * Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com>
31 * Keith Whitwell <keithw-at-tungstengraphics-dot-com>
34 #ifndef _WSBM_MANAGER_H_
35 #define _WSBM_MANAGER_H_
36 #include "wsbm_fencemgr.h"
37 #include "wsbm_util.h"
38 #include "wsbm_driver.h"
40 #define WSBM_VERSION_MAJOR 1
41 #define WSBM_VERSION_MINOR 1
42 #define WSBM_VERSION_PL 0
44 struct _WsbmFenceObject;
45 struct _WsbmBufferObject;
46 struct _WsbmBufferPool;
47 struct _WsbmBufferList;
50 * These flags mimics the TTM closely, but since
51 * this library is not dependant on TTM, we need to
52 * replicate them here, and if there is a discrepancy,
53 * that needs to be resolved in the buffer pool using
57 #define WSBM_PL_MASK_MEM 0x0000FFFF
59 #define WSBM_PL_FLAG_SYSTEM (1 << 0)
60 #define WSBM_PL_FLAG_TT (1 << 1)
61 #define WSBM_PL_FLAG_VRAM (1 << 2)
62 #define WSBM_PL_FLAG_PRIV0 (1 << 3)
63 #define WSBM_PL_FLAG_SWAPPED (1 << 15)
64 #define WSBM_PL_FLAG_CACHED (1 << 16)
65 #define WSBM_PL_FLAG_UNCACHED (1 << 17)
66 #define WSBM_PL_FLAG_WC (1 << 18)
67 #define WSBM_PL_FLAG_SHARED (1 << 20)
68 #define WSBM_PL_FLAG_NO_EVICT (1 << 21)
70 #define WSBM_ACCESS_READ (1 << 0)
71 #define WSBM_ACCESS_WRITE (1 << 1)
73 #define WSBM_SYNCCPU_READ WSBM_ACCESS_READ
74 #define WSBM_SYNCCPU_WRITE WSBM_ACCESS_WRITE
75 #define WSBM_SYNCCPU_DONT_BLOCK (1 << 2)
76 #define WSBM_SYNCCPU_TRY_CACHED (1 << 3)
78 extern void *wsbmBOMap(struct _WsbmBufferObject *buf, unsigned mode);
79 extern void wsbmBOUnmap(struct _WsbmBufferObject *buf);
80 extern int wsbmBOSyncForCpu(struct _WsbmBufferObject *buf, unsigned mode);
81 extern void wsbmBOReleaseFromCpu(struct _WsbmBufferObject *buf,
84 extern unsigned long wsbmBOOffsetHint(struct _WsbmBufferObject *buf);
85 extern unsigned long wsbmBOPoolOffset(struct _WsbmBufferObject *buf);
87 extern uint32_t wsbmBOPlacementHint(struct _WsbmBufferObject *buf);
88 extern struct _WsbmBufferObject *wsbmBOReference(struct _WsbmBufferObject
90 extern void wsbmBOUnreference(struct _WsbmBufferObject **p_buf);
92 extern int wsbmBOData(struct _WsbmBufferObject *r_buf,
93 unsigned size, const void *data,
94 struct _WsbmBufferPool *pool, uint32_t placement);
95 extern int wsbmBOSetStatus(struct _WsbmBufferObject *buf,
96 uint32_t setPlacement, uint32_t clrPlacement);
97 extern int wsbmBOSubData(struct _WsbmBufferObject *buf,
98 unsigned long offset, unsigned long size,
100 int (*accelCopy) (struct _WsbmBufferObject *,
101 struct _WsbmBufferObject *));
102 extern struct _WsbmBufferObject *wsbmBOClone(struct _WsbmBufferObject *buf,
103 int (*accelCopy) (struct
110 extern int wsbmBOGetSubData(struct _WsbmBufferObject *buf,
111 unsigned long offset, unsigned long size,
113 extern int wsbmGenBuffers(struct _WsbmBufferPool *pool,
115 struct _WsbmBufferObject *buffers[],
116 unsigned alignment, uint32_t placement);
118 struct _WsbmBufferObject *wsbmBOCreateSimple(struct _WsbmBufferPool *pool,
125 extern void wsbmDeleteBuffers(unsigned n,
126 struct _WsbmBufferObject *buffers[]);
127 extern struct _WsbmBufferList *wsbmBOCreateList(int target,
128 int hasKernelBuffers);
129 extern int wsbmBOResetList(struct _WsbmBufferList *list);
130 extern int wsbmBOAddListItem(struct _WsbmBufferList *list,
131 struct _WsbmBufferObject *buf,
132 uint64_t flags, uint64_t mask, int *itemLoc,
133 struct _ValidateNode **node);
135 extern void wsbmBOFreeList(struct _WsbmBufferList *list);
136 extern int wsbmBOFenceUserList(struct _WsbmBufferList *list,
137 struct _WsbmFenceObject *fence);
139 extern int wsbmBOUnrefUserList(struct _WsbmBufferList *list);
140 extern int wsbmBOValidateUserList(struct _WsbmBufferList *list);
141 extern int wsbmBOUnvalidateUserList(struct _WsbmBufferList *list);
143 extern void wsbmBOFence(struct _WsbmBufferObject *buf,
144 struct _WsbmFenceObject *fence);
146 extern void wsbmPoolTakeDown(struct _WsbmBufferPool *pool);
147 extern int wsbmBOSetReferenced(struct _WsbmBufferObject *buf,
148 unsigned long handle);
149 unsigned long wsbmBOSize(struct _WsbmBufferObject *buf);
150 extern void wsbmBOWaitIdle(struct _WsbmBufferObject *buf, int lazy);
151 extern int wsbmBOOnList(const struct _WsbmBufferObject *buf);
153 extern void wsbmPoolTakeDown(struct _WsbmBufferPool *pool);
155 extern void wsbmReadLockKernelBO(void);
156 extern void wsbmReadUnlockKernelBO(void);
157 extern void wsbmWriteLockKernelBO(void);
158 extern void wsbmWriteUnlockKernelBO(void);
160 extern int wsbmInit(struct _WsbmThreadFuncs *tf, struct _WsbmVNodeFuncs *vf);
161 extern void wsbmTakedown(void);
162 extern int wsbmIsInitialized(void);
163 extern void wsbmCommonDataSet(void *d);
164 extern void *wsbmCommonDataGet(void);
166 extern struct _ValidateList *wsbmGetKernelValidateList(struct _WsbmBufferList
168 extern struct _ValidateList *wsbmGetUserValidateList(struct _WsbmBufferList
171 extern struct _ValidateNode *validateListNode(void *iterator);
172 extern void *validateListIterator(struct _ValidateList *list);
173 extern void *validateListNext(struct _ValidateList *list, void *iterator);
175 extern uint32_t wsbmKBufHandle(const struct _WsbmKernelBuf *);
176 extern void wsbmUpdateKBuf(struct _WsbmKernelBuf *,
178 uint32_t placement, uint32_t fence_flags);
180 extern struct _WsbmKernelBuf *wsbmKBuf(const struct _WsbmBufferObject *buf);