Alan Hourihane | 18ce40c | 2001-05-17 15:20:40 +0000 | [diff] [blame] | 1 | /* sis_ds.h -- Private header for Direct Rendering Manager -*- linux-c -*- |
| 2 | * Created: Mon Jan 4 10:05:05 1999 by sclin@sis.com.tw |
Eric Anholt | c6344e8 | 2005-11-28 23:10:41 +0000 | [diff] [blame] | 3 | */ |
| 4 | /* |
Alan Hourihane | 18ce40c | 2001-05-17 15:20:40 +0000 | [diff] [blame] | 5 | * Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan. |
| 6 | * All rights reserved. |
| 7 | * |
| 8 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 9 | * copy of this software and associated documentation files (the "Software"), |
| 10 | * to deal in the Software without restriction, including without limitation |
| 11 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 12 | * and/or sell copies of the Software, and to permit persons to whom the |
| 13 | * Software is furnished to do so, subject to the following conditions: |
Jon Smirl | 9f9a8f1 | 2004-09-30 21:12:10 +0000 | [diff] [blame] | 14 | * |
Alan Hourihane | 18ce40c | 2001-05-17 15:20:40 +0000 | [diff] [blame] | 15 | * The above copyright notice and this permission notice (including the next |
| 16 | * paragraph) shall be included in all copies or substantial portions of the |
| 17 | * Software. |
Jon Smirl | 9f9a8f1 | 2004-09-30 21:12:10 +0000 | [diff] [blame] | 18 | * |
Alan Hourihane | 18ce40c | 2001-05-17 15:20:40 +0000 | [diff] [blame] | 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 22 | * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 23 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 24 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 25 | * DEALINGS IN THE SOFTWARE. |
Jon Smirl | 9f9a8f1 | 2004-09-30 21:12:10 +0000 | [diff] [blame] | 26 | * |
Alan Hourihane | 18ce40c | 2001-05-17 15:20:40 +0000 | [diff] [blame] | 27 | * Authors: |
| 28 | * Sung-Ching Lin <sclin@sis.com.tw> |
Jon Smirl | 9f9a8f1 | 2004-09-30 21:12:10 +0000 | [diff] [blame] | 29 | * |
Alan Hourihane | 18ce40c | 2001-05-17 15:20:40 +0000 | [diff] [blame] | 30 | */ |
| 31 | |
Eric Anholt | fabc64d | 2003-08-29 19:24:36 +0000 | [diff] [blame] | 32 | #ifndef __SIS_DS_H__ |
| 33 | #define __SIS_DS_H__ |
Alan Hourihane | 18ce40c | 2001-05-17 15:20:40 +0000 | [diff] [blame] | 34 | |
| 35 | /* Set Data Structure */ |
| 36 | |
| 37 | #define SET_SIZE 5000 |
Alan Hourihane | 18ce40c | 2001-05-17 15:20:40 +0000 | [diff] [blame] | 38 | |
Eric Anholt | 853adb8 | 2004-05-11 04:43:43 +0000 | [diff] [blame] | 39 | typedef unsigned long ITEM_TYPE; |
Alan Hourihane | 18ce40c | 2001-05-17 15:20:40 +0000 | [diff] [blame] | 40 | |
| 41 | typedef struct { |
Eric Anholt | fabc64d | 2003-08-29 19:24:36 +0000 | [diff] [blame] | 42 | ITEM_TYPE val; |
| 43 | int alloc_next, free_next; |
Alan Hourihane | 18ce40c | 2001-05-17 15:20:40 +0000 | [diff] [blame] | 44 | } list_item_t; |
| 45 | |
| 46 | typedef struct { |
Eric Anholt | fabc64d | 2003-08-29 19:24:36 +0000 | [diff] [blame] | 47 | int alloc; |
| 48 | int free; |
| 49 | int trace; |
| 50 | list_item_t list[SET_SIZE]; |
Alan Hourihane | 18ce40c | 2001-05-17 15:20:40 +0000 | [diff] [blame] | 51 | } set_t; |
| 52 | |
| 53 | set_t *setInit(void); |
Jon Smirl | 9f9a8f1 | 2004-09-30 21:12:10 +0000 | [diff] [blame] | 54 | int setAdd(set_t * set, ITEM_TYPE item); |
| 55 | int setDel(set_t * set, ITEM_TYPE item); |
| 56 | int setFirst(set_t * set, ITEM_TYPE * item); |
| 57 | int setNext(set_t * set, ITEM_TYPE * item); |
| 58 | int setDestroy(set_t * set); |
Alan Hourihane | 18ce40c | 2001-05-17 15:20:40 +0000 | [diff] [blame] | 59 | |
Alan Hourihane | 18ce40c | 2001-05-17 15:20:40 +0000 | [diff] [blame] | 60 | /* |
| 61 | * GLX Hardware Device Driver common code |
Keith Whitwell | 08758b2 | 2004-11-01 10:52:18 +0000 | [diff] [blame] | 62 | * Copyright (C) 1999 Wittawat Yamwong |
Alan Hourihane | 18ce40c | 2001-05-17 15:20:40 +0000 | [diff] [blame] | 63 | * |
| 64 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 65 | * copy of this software and associated documentation files (the "Software"), |
| 66 | * to deal in the Software without restriction, including without limitation |
| 67 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 68 | * and/or sell copies of the Software, and to permit persons to whom the |
| 69 | * Software is furnished to do so, subject to the following conditions: |
| 70 | * |
| 71 | * The above copyright notice and this permission notice shall be included |
| 72 | * in all copies or substantial portions of the Software. |
| 73 | * |
| 74 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 75 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 76 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
Dave Airlie | b2be72c | 2006-01-02 03:44:23 +0000 | [diff] [blame] | 77 | * WITTAWAT YAMWONG, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, |
Jon Smirl | 9f9a8f1 | 2004-09-30 21:12:10 +0000 | [diff] [blame] | 78 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
| 79 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE |
Alan Hourihane | 18ce40c | 2001-05-17 15:20:40 +0000 | [diff] [blame] | 80 | * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 81 | * |
| 82 | */ |
| 83 | |
Alan Hourihane | 18ce40c | 2001-05-17 15:20:40 +0000 | [diff] [blame] | 84 | struct mem_block_t { |
Eric Anholt | fabc64d | 2003-08-29 19:24:36 +0000 | [diff] [blame] | 85 | struct mem_block_t *next; |
| 86 | struct mem_block_t *heap; |
Jon Smirl | 9f9a8f1 | 2004-09-30 21:12:10 +0000 | [diff] [blame] | 87 | int ofs, size; |
Eric Anholt | fabc64d | 2003-08-29 19:24:36 +0000 | [diff] [blame] | 88 | int align; |
Dave Airlie | f197110 | 2004-12-03 10:22:15 +0000 | [diff] [blame] | 89 | unsigned int free:1; |
| 90 | unsigned int reserved:1; |
Alan Hourihane | 18ce40c | 2001-05-17 15:20:40 +0000 | [diff] [blame] | 91 | }; |
| 92 | typedef struct mem_block_t TMemBlock; |
| 93 | typedef struct mem_block_t *PMemBlock; |
| 94 | |
| 95 | /* a heap is just the first block in a chain */ |
| 96 | typedef struct mem_block_t memHeap_t; |
| 97 | |
| 98 | static __inline__ int mmBlockSize(PMemBlock b) |
Eric Anholt | fabc64d | 2003-08-29 19:24:36 +0000 | [diff] [blame] | 99 | { |
| 100 | return b->size; |
| 101 | } |
Alan Hourihane | 18ce40c | 2001-05-17 15:20:40 +0000 | [diff] [blame] | 102 | |
| 103 | static __inline__ int mmOffset(PMemBlock b) |
Eric Anholt | fabc64d | 2003-08-29 19:24:36 +0000 | [diff] [blame] | 104 | { |
| 105 | return b->ofs; |
| 106 | } |
Alan Hourihane | 18ce40c | 2001-05-17 15:20:40 +0000 | [diff] [blame] | 107 | |
| 108 | static __inline__ void mmMarkReserved(PMemBlock b) |
Eric Anholt | fabc64d | 2003-08-29 19:24:36 +0000 | [diff] [blame] | 109 | { |
| 110 | b->reserved = 1; |
| 111 | } |
Alan Hourihane | 18ce40c | 2001-05-17 15:20:40 +0000 | [diff] [blame] | 112 | |
Jon Smirl | 9f9a8f1 | 2004-09-30 21:12:10 +0000 | [diff] [blame] | 113 | /* |
Alan Hourihane | 18ce40c | 2001-05-17 15:20:40 +0000 | [diff] [blame] | 114 | * input: total size in bytes |
| 115 | * return: a heap pointer if OK, NULL if error |
| 116 | */ |
Jon Smirl | 9f9a8f1 | 2004-09-30 21:12:10 +0000 | [diff] [blame] | 117 | memHeap_t *mmInit(int ofs, int size); |
Alan Hourihane | 18ce40c | 2001-05-17 15:20:40 +0000 | [diff] [blame] | 118 | |
Alan Hourihane | 18ce40c | 2001-05-17 15:20:40 +0000 | [diff] [blame] | 119 | /* |
| 120 | * Allocate 'size' bytes with 2^align2 bytes alignment, |
| 121 | * restrict the search to free memory after 'startSearch' |
| 122 | * depth and back buffers should be in different 4mb banks |
| 123 | * to get better page hits if possible |
| 124 | * input: size = size of block |
| 125 | * align2 = 2^align2 bytes alignment |
| 126 | * startSearch = linear offset from start of heap to begin search |
| 127 | * return: pointer to the allocated block, 0 if error |
| 128 | */ |
Jon Smirl | 9f9a8f1 | 2004-09-30 21:12:10 +0000 | [diff] [blame] | 129 | PMemBlock mmAllocMem(memHeap_t * heap, int size, int align2, int startSearch); |
Eric Anholt | fabc64d | 2003-08-29 19:24:36 +0000 | [diff] [blame] | 130 | |
| 131 | /* |
| 132 | * Returns 1 if the block 'b' is part of the heap 'heap' |
| 133 | */ |
Jon Smirl | 9f9a8f1 | 2004-09-30 21:12:10 +0000 | [diff] [blame] | 134 | int mmBlockInHeap(PMemBlock heap, PMemBlock b); |
Alan Hourihane | 18ce40c | 2001-05-17 15:20:40 +0000 | [diff] [blame] | 135 | |
| 136 | /* |
| 137 | * Free block starts at offset |
| 138 | * input: pointer to a block |
| 139 | * return: 0 if OK, -1 if error |
| 140 | */ |
Jon Smirl | 9f9a8f1 | 2004-09-30 21:12:10 +0000 | [diff] [blame] | 141 | int mmFreeMem(PMemBlock b); |
Alan Hourihane | 18ce40c | 2001-05-17 15:20:40 +0000 | [diff] [blame] | 142 | |
Alan Hourihane | 18ce40c | 2001-05-17 15:20:40 +0000 | [diff] [blame] | 143 | /* For debuging purpose. */ |
Jon Smirl | 9f9a8f1 | 2004-09-30 21:12:10 +0000 | [diff] [blame] | 144 | void mmDumpMemInfo(memHeap_t * mmInit); |
Alan Hourihane | 18ce40c | 2001-05-17 15:20:40 +0000 | [diff] [blame] | 145 | |
Jon Smirl | 9f9a8f1 | 2004-09-30 21:12:10 +0000 | [diff] [blame] | 146 | #endif /* __SIS_DS_H__ */ |