sis_ds.h revision 119895
1119895Sanholt/* sis_ds.h -- Private header for Direct Rendering Manager -*- linux-c -*- 2119895Sanholt * Created: Mon Jan 4 10:05:05 1999 by sclin@sis.com.tw 3119895Sanholt * 4119895Sanholt * Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan. 5119895Sanholt * All rights reserved. 6119895Sanholt * 7119895Sanholt * Permission is hereby granted, free of charge, to any person obtaining a 8119895Sanholt * copy of this software and associated documentation files (the "Software"), 9119895Sanholt * to deal in the Software without restriction, including without limitation 10119895Sanholt * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11119895Sanholt * and/or sell copies of the Software, and to permit persons to whom the 12119895Sanholt * Software is furnished to do so, subject to the following conditions: 13119895Sanholt * 14119895Sanholt * The above copyright notice and this permission notice (including the next 15119895Sanholt * paragraph) shall be included in all copies or substantial portions of the 16119895Sanholt * Software. 17119895Sanholt * 18119895Sanholt * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19119895Sanholt * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20119895Sanholt * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21119895Sanholt * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 22119895Sanholt * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 23119895Sanholt * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24119895Sanholt * DEALINGS IN THE SOFTWARE. 25119895Sanholt * 26119895Sanholt * Authors: 27119895Sanholt * Sung-Ching Lin <sclin@sis.com.tw> 28119895Sanholt * 29119895Sanholt * $FreeBSD: head/sys/dev/drm/sis_ds.h 119895 2003-09-09 00:24:31Z anholt $ 30119895Sanholt */ 31119895Sanholt 32119895Sanholt#ifndef __SIS_DS_H__ 33119895Sanholt#define __SIS_DS_H__ 34119895Sanholt 35119895Sanholt/* Set Data Structure */ 36119895Sanholt 37119895Sanholt#define SET_SIZE 5000 38119895Sanholt 39119895Sanholttypedef unsigned int ITEM_TYPE; 40119895Sanholt 41119895Sanholttypedef struct { 42119895Sanholt ITEM_TYPE val; 43119895Sanholt int alloc_next, free_next; 44119895Sanholt} list_item_t; 45119895Sanholt 46119895Sanholttypedef struct { 47119895Sanholt int alloc; 48119895Sanholt int free; 49119895Sanholt int trace; 50119895Sanholt list_item_t list[SET_SIZE]; 51119895Sanholt} set_t; 52119895Sanholt 53119895Sanholtset_t *setInit(void); 54119895Sanholtint setAdd(set_t *set, ITEM_TYPE item); 55119895Sanholtint setDel(set_t *set, ITEM_TYPE item); 56119895Sanholtint setFirst(set_t *set, ITEM_TYPE *item); 57119895Sanholtint setNext(set_t *set, ITEM_TYPE *item); 58119895Sanholtint setDestroy(set_t *set); 59119895Sanholt 60119895Sanholt/* 61119895Sanholt * GLX Hardware Device Driver common code 62119895Sanholt * Copyright (C) 1999 Keith Whitwell 63119895Sanholt * 64119895Sanholt * Permission is hereby granted, free of charge, to any person obtaining a 65119895Sanholt * copy of this software and associated documentation files (the "Software"), 66119895Sanholt * to deal in the Software without restriction, including without limitation 67119895Sanholt * the rights to use, copy, modify, merge, publish, distribute, sublicense, 68119895Sanholt * and/or sell copies of the Software, and to permit persons to whom the 69119895Sanholt * Software is furnished to do so, subject to the following conditions: 70119895Sanholt * 71119895Sanholt * The above copyright notice and this permission notice shall be included 72119895Sanholt * in all copies or substantial portions of the Software. 73119895Sanholt * 74119895Sanholt * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 75119895Sanholt * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 76119895Sanholt * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 77119895Sanholt * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, 78119895Sanholt * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 79119895Sanholt * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 80119895Sanholt * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 81119895Sanholt * 82119895Sanholt */ 83119895Sanholt 84119895Sanholtstruct mem_block_t { 85119895Sanholt struct mem_block_t *next; 86119895Sanholt struct mem_block_t *heap; 87119895Sanholt int ofs,size; 88119895Sanholt int align; 89119895Sanholt int free:1; 90119895Sanholt int reserved:1; 91119895Sanholt}; 92119895Sanholttypedef struct mem_block_t TMemBlock; 93119895Sanholttypedef struct mem_block_t *PMemBlock; 94119895Sanholt 95119895Sanholt/* a heap is just the first block in a chain */ 96119895Sanholttypedef struct mem_block_t memHeap_t; 97119895Sanholt 98119895Sanholtstatic __inline__ int mmBlockSize(PMemBlock b) 99119895Sanholt{ 100119895Sanholt return b->size; 101119895Sanholt} 102119895Sanholt 103119895Sanholtstatic __inline__ int mmOffset(PMemBlock b) 104119895Sanholt{ 105119895Sanholt return b->ofs; 106119895Sanholt} 107119895Sanholt 108119895Sanholtstatic __inline__ void mmMarkReserved(PMemBlock b) 109119895Sanholt{ 110119895Sanholt b->reserved = 1; 111119895Sanholt} 112119895Sanholt 113119895Sanholt/* 114119895Sanholt * input: total size in bytes 115119895Sanholt * return: a heap pointer if OK, NULL if error 116119895Sanholt */ 117119895SanholtmemHeap_t *mmInit( int ofs, int size ); 118119895Sanholt 119119895SanholtmemHeap_t *mmAddRange( memHeap_t *heap, 120119895Sanholt int ofs, 121119895Sanholt int size ); 122119895Sanholt 123119895Sanholt/* 124119895Sanholt * Allocate 'size' bytes with 2^align2 bytes alignment, 125119895Sanholt * restrict the search to free memory after 'startSearch' 126119895Sanholt * depth and back buffers should be in different 4mb banks 127119895Sanholt * to get better page hits if possible 128119895Sanholt * input: size = size of block 129119895Sanholt * align2 = 2^align2 bytes alignment 130119895Sanholt * startSearch = linear offset from start of heap to begin search 131119895Sanholt * return: pointer to the allocated block, 0 if error 132119895Sanholt */ 133119895SanholtPMemBlock mmAllocMem( memHeap_t *heap, int size, int align2, int startSearch ); 134119895Sanholt 135119895Sanholt/* 136119895Sanholt * Returns 1 if the block 'b' is part of the heap 'heap' 137119895Sanholt */ 138119895Sanholtint mmBlockInHeap( PMemBlock heap, PMemBlock b ); 139119895Sanholt 140119895Sanholt/* 141119895Sanholt * Free block starts at offset 142119895Sanholt * input: pointer to a block 143119895Sanholt * return: 0 if OK, -1 if error 144119895Sanholt */ 145119895Sanholtint mmFreeMem( PMemBlock b ); 146119895Sanholt 147119895Sanholt/* 148119895Sanholt * Reserve 'size' bytes block start at offset 149119895Sanholt * This is used to prevent allocation of memory already used 150119895Sanholt * by the X server for the front buffer, pixmaps, and cursor 151119895Sanholt * input: size, offset 152119895Sanholt * output: 0 if OK, -1 if error 153119895Sanholt */ 154119895Sanholtint mmReserveMem( memHeap_t *heap, int offset,int size ); 155119895Sanholtint mmFreeReserved( memHeap_t *heap, int offset ); 156119895Sanholt 157119895Sanholt/* 158119895Sanholt * destroy MM 159119895Sanholt */ 160119895Sanholtvoid mmDestroy( memHeap_t *mmInit ); 161119895Sanholt 162119895Sanholt/* For debuging purpose. */ 163119895Sanholtvoid mmDumpMemInfo( memHeap_t *mmInit ); 164119895Sanholt 165119895Sanholt#endif /* __SIS_DS_H__ */ 166