183827f40a2d97261528087331b0bee6ce2cf27c5root/************************************************************************** 283827f40a2d97261528087331b0bee6ce2cf27c5root * 383827f40a2d97261528087331b0bee6ce2cf27c5root * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, TX., USA 483827f40a2d97261528087331b0bee6ce2cf27c5root * All Rights Reserved. 583827f40a2d97261528087331b0bee6ce2cf27c5root * Copyright 2009 VMware, Inc., Palo Alto, CA., USA 683827f40a2d97261528087331b0bee6ce2cf27c5root * All Rights Reserved. 783827f40a2d97261528087331b0bee6ce2cf27c5root * 883827f40a2d97261528087331b0bee6ce2cf27c5root * Permission is hereby granted, free of charge, to any person obtaining a 983827f40a2d97261528087331b0bee6ce2cf27c5root * copy of this software and associated documentation files (the 1083827f40a2d97261528087331b0bee6ce2cf27c5root * "Software"), to deal in the Software without restriction, including 1183827f40a2d97261528087331b0bee6ce2cf27c5root * without limitation the rights to use, copy, modify, merge, publish, 1283827f40a2d97261528087331b0bee6ce2cf27c5root * distribute, sub license, and/or sell copies of the Software, and to 1383827f40a2d97261528087331b0bee6ce2cf27c5root * permit persons to whom the Software is furnished to do so, subject to 1483827f40a2d97261528087331b0bee6ce2cf27c5root * the following conditions: 1583827f40a2d97261528087331b0bee6ce2cf27c5root * 1683827f40a2d97261528087331b0bee6ce2cf27c5root * The above copyright notice and this permission notice (including the 1783827f40a2d97261528087331b0bee6ce2cf27c5root * next paragraph) shall be included in all copies or substantial portions 1883827f40a2d97261528087331b0bee6ce2cf27c5root * of the Software. 1983827f40a2d97261528087331b0bee6ce2cf27c5root * 2083827f40a2d97261528087331b0bee6ce2cf27c5root * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 2183827f40a2d97261528087331b0bee6ce2cf27c5root * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 2283827f40a2d97261528087331b0bee6ce2cf27c5root * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 2383827f40a2d97261528087331b0bee6ce2cf27c5root * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, 2483827f40a2d97261528087331b0bee6ce2cf27c5root * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 2583827f40a2d97261528087331b0bee6ce2cf27c5root * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 2683827f40a2d97261528087331b0bee6ce2cf27c5root * USE OR OTHER DEALINGS IN THE SOFTWARE. 2783827f40a2d97261528087331b0bee6ce2cf27c5root * 2883827f40a2d97261528087331b0bee6ce2cf27c5root **************************************************************************/ 2983827f40a2d97261528087331b0bee6ce2cf27c5root/* 3083827f40a2d97261528087331b0bee6ce2cf27c5root * Authors: 3183827f40a2d97261528087331b0bee6ce2cf27c5root * Thomas Hellstr�m <thomas-at-tungstengraphics-dot-com> 3283827f40a2d97261528087331b0bee6ce2cf27c5root */ 3383827f40a2d97261528087331b0bee6ce2cf27c5root 3483827f40a2d97261528087331b0bee6ce2cf27c5root#ifndef _WSBM_DRIVER_H 3583827f40a2d97261528087331b0bee6ce2cf27c5root#define _WSBM_DRIVER_H 3683827f40a2d97261528087331b0bee6ce2cf27c5root#include <stdint.h> 3783827f40a2d97261528087331b0bee6ce2cf27c5root#include "wsbm_util.h" 3883827f40a2d97261528087331b0bee6ce2cf27c5root 3983827f40a2d97261528087331b0bee6ce2cf27c5root#define WSBM_MUTEX_SPACE 16 4083827f40a2d97261528087331b0bee6ce2cf27c5root#define WSBM_COND_SPACE 16 4183827f40a2d97261528087331b0bee6ce2cf27c5root 4283827f40a2d97261528087331b0bee6ce2cf27c5rootstruct _WsbmMutex 4383827f40a2d97261528087331b0bee6ce2cf27c5root{ 4483827f40a2d97261528087331b0bee6ce2cf27c5root struct _WsbmThreadFuncs *func; 4583827f40a2d97261528087331b0bee6ce2cf27c5root unsigned long storage[WSBM_MUTEX_SPACE]; 4683827f40a2d97261528087331b0bee6ce2cf27c5root}; 4783827f40a2d97261528087331b0bee6ce2cf27c5root 4883827f40a2d97261528087331b0bee6ce2cf27c5rootstruct _WsbmCond 4983827f40a2d97261528087331b0bee6ce2cf27c5root{ 5083827f40a2d97261528087331b0bee6ce2cf27c5root struct _WsbmThreadFuncs *func; 5183827f40a2d97261528087331b0bee6ce2cf27c5root unsigned long storage[WSBM_COND_SPACE]; 5283827f40a2d97261528087331b0bee6ce2cf27c5root}; 5383827f40a2d97261528087331b0bee6ce2cf27c5root 5483827f40a2d97261528087331b0bee6ce2cf27c5rootstruct _WsbmThreadFuncs 5583827f40a2d97261528087331b0bee6ce2cf27c5root{ 5683827f40a2d97261528087331b0bee6ce2cf27c5root int (*mutexInit) (struct _WsbmMutex *, struct _WsbmThreadFuncs *); 5783827f40a2d97261528087331b0bee6ce2cf27c5root void (*mutexFree) (struct _WsbmMutex *); 5883827f40a2d97261528087331b0bee6ce2cf27c5root void (*mutexLock) (struct _WsbmMutex *); 5983827f40a2d97261528087331b0bee6ce2cf27c5root void (*mutexUnlock) (struct _WsbmMutex *); 6083827f40a2d97261528087331b0bee6ce2cf27c5root int (*condInit) (struct _WsbmCond *, struct _WsbmThreadFuncs *); 6183827f40a2d97261528087331b0bee6ce2cf27c5root void (*condFree) (struct _WsbmCond *); 6283827f40a2d97261528087331b0bee6ce2cf27c5root void (*condWait) (struct _WsbmCond *, struct _WsbmMutex *); 6383827f40a2d97261528087331b0bee6ce2cf27c5root void (*condBroadcast) (struct _WsbmCond *); 6483827f40a2d97261528087331b0bee6ce2cf27c5root}; 6583827f40a2d97261528087331b0bee6ce2cf27c5root 6683827f40a2d97261528087331b0bee6ce2cf27c5rootextern struct _WsbmThreadFuncs *wsbmCurThreadFunc; 6783827f40a2d97261528087331b0bee6ce2cf27c5root 6883827f40a2d97261528087331b0bee6ce2cf27c5root#define WSBM_MUTEX_INIT(_mutex) \ 6983827f40a2d97261528087331b0bee6ce2cf27c5root wsbmThreadFuncs()->mutexInit(_mutex,wsbmThreadFuncs()) 7083827f40a2d97261528087331b0bee6ce2cf27c5root#define WSBM_MUTEX_FREE(_mutex) \ 7183827f40a2d97261528087331b0bee6ce2cf27c5root { \ 7283827f40a2d97261528087331b0bee6ce2cf27c5root (_mutex)->func->mutexFree(_mutex); \ 7383827f40a2d97261528087331b0bee6ce2cf27c5root } 7483827f40a2d97261528087331b0bee6ce2cf27c5root#define WSBM_MUTEX_LOCK(_mutex) \ 7583827f40a2d97261528087331b0bee6ce2cf27c5root (_mutex)->func->mutexLock(_mutex); 7683827f40a2d97261528087331b0bee6ce2cf27c5root#define WSBM_MUTEX_UNLOCK(_mutex) \ 7783827f40a2d97261528087331b0bee6ce2cf27c5root (_mutex)->func->mutexUnlock(_mutex); 7883827f40a2d97261528087331b0bee6ce2cf27c5root 7983827f40a2d97261528087331b0bee6ce2cf27c5root#define WSBM_COND_INIT(_mutex) \ 8083827f40a2d97261528087331b0bee6ce2cf27c5root wsbmThreadFuncs()->condInit(_mutex, wsbmThreadFuncs()) 8183827f40a2d97261528087331b0bee6ce2cf27c5root#define WSBM_COND_FREE(_cond) \ 8283827f40a2d97261528087331b0bee6ce2cf27c5root { \ 8383827f40a2d97261528087331b0bee6ce2cf27c5root (_cond)->func->condFree(_cond); \ 8483827f40a2d97261528087331b0bee6ce2cf27c5root } 8583827f40a2d97261528087331b0bee6ce2cf27c5root#define WSBM_COND_WAIT(_cond, _mutex) \ 8683827f40a2d97261528087331b0bee6ce2cf27c5root (_cond)->func->condWait(_cond, _mutex); 8783827f40a2d97261528087331b0bee6ce2cf27c5root#define WSBM_COND_BROADCAST(_cond) \ 8883827f40a2d97261528087331b0bee6ce2cf27c5root (_cond)->func->condBroadcast(_cond); 8983827f40a2d97261528087331b0bee6ce2cf27c5root 9083827f40a2d97261528087331b0bee6ce2cf27c5rootstruct _WsbmVNodeFuncs 9183827f40a2d97261528087331b0bee6ce2cf27c5root{ 9283827f40a2d97261528087331b0bee6ce2cf27c5root struct _ValidateNode *(*alloc) (struct _WsbmVNodeFuncs *, int); 9383827f40a2d97261528087331b0bee6ce2cf27c5root void (*free) (struct _ValidateNode *); 9483827f40a2d97261528087331b0bee6ce2cf27c5root void (*clear) (struct _ValidateNode *); 9583827f40a2d97261528087331b0bee6ce2cf27c5root}; 9683827f40a2d97261528087331b0bee6ce2cf27c5root 9783827f40a2d97261528087331b0bee6ce2cf27c5rootextern struct _WsbmVNodeFuncs *wsbmCurVNodeFunc; 9883827f40a2d97261528087331b0bee6ce2cf27c5root 9983827f40a2d97261528087331b0bee6ce2cf27c5rootstruct _WsbmBufStorage; 10083827f40a2d97261528087331b0bee6ce2cf27c5rootstruct _WsbmKernelBuf; 10183827f40a2d97261528087331b0bee6ce2cf27c5root 10283827f40a2d97261528087331b0bee6ce2cf27c5rootstruct _ValidateNode 10383827f40a2d97261528087331b0bee6ce2cf27c5root{ 10483827f40a2d97261528087331b0bee6ce2cf27c5root uint32_t hash; 10583827f40a2d97261528087331b0bee6ce2cf27c5root int type_id; 10683827f40a2d97261528087331b0bee6ce2cf27c5root struct _WsbmListHead head; 10783827f40a2d97261528087331b0bee6ce2cf27c5root struct _WsbmListHead hashHead; 10883827f40a2d97261528087331b0bee6ce2cf27c5root int listItem; 10983827f40a2d97261528087331b0bee6ce2cf27c5root uint64_t set_flags; 11083827f40a2d97261528087331b0bee6ce2cf27c5root uint64_t clr_flags; 11183827f40a2d97261528087331b0bee6ce2cf27c5root void *buf; 11283827f40a2d97261528087331b0bee6ce2cf27c5root struct _WsbmVNodeFuncs *func; 11383827f40a2d97261528087331b0bee6ce2cf27c5root}; 11483827f40a2d97261528087331b0bee6ce2cf27c5root 11583827f40a2d97261528087331b0bee6ce2cf27c5rootstatic inline struct _WsbmVNodeFuncs * 11683827f40a2d97261528087331b0bee6ce2cf27c5rootwsbmVNodeFuncs(void) 11783827f40a2d97261528087331b0bee6ce2cf27c5root{ 11883827f40a2d97261528087331b0bee6ce2cf27c5root return wsbmCurVNodeFunc; 11983827f40a2d97261528087331b0bee6ce2cf27c5root} 12083827f40a2d97261528087331b0bee6ce2cf27c5root 12183827f40a2d97261528087331b0bee6ce2cf27c5rootstatic inline struct _WsbmThreadFuncs * 12283827f40a2d97261528087331b0bee6ce2cf27c5rootwsbmThreadFuncs(void) 12383827f40a2d97261528087331b0bee6ce2cf27c5root{ 12483827f40a2d97261528087331b0bee6ce2cf27c5root return wsbmCurThreadFunc; 12583827f40a2d97261528087331b0bee6ce2cf27c5root} 12683827f40a2d97261528087331b0bee6ce2cf27c5root 12783827f40a2d97261528087331b0bee6ce2cf27c5rootextern struct _WsbmThreadFuncs *wsbmNullThreadFuncs(void); 12883827f40a2d97261528087331b0bee6ce2cf27c5root 12983827f40a2d97261528087331b0bee6ce2cf27c5rootextern struct _WsbmThreadFuncs *wsbmPThreadFuncs(void); 13083827f40a2d97261528087331b0bee6ce2cf27c5root 13183827f40a2d97261528087331b0bee6ce2cf27c5root#endif 132