Sync with HEAD.
[dragonfly.git] / sys / dev / drm / sis_ds.h
blob5012d26ea3769aa585b733a85298067bc0281140
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
3 */
4 /*
5 * Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
6 * All rights reserved.
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:
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.
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.
27 * Authors:
28 * Sung-Ching Lin <sclin@sis.com.tw>
30 * $DragonFly: src/sys/dev/drm/sis_ds.h,v 1.1 2008/04/05 18:12:29 hasso Exp $
33 #ifndef __SIS_DS_H__
34 #define __SIS_DS_H__
36 /* Set Data Structure */
38 #define SET_SIZE 5000
40 typedef unsigned long ITEM_TYPE;
42 typedef struct {
43 ITEM_TYPE val;
44 int alloc_next, free_next;
45 } list_item_t;
47 typedef struct {
48 int alloc;
49 int free;
50 int trace;
51 list_item_t list[SET_SIZE];
52 } set_t;
54 set_t *setInit(void);
55 int setAdd(set_t * set, ITEM_TYPE item);
56 int setDel(set_t * set, ITEM_TYPE item);
57 int setFirst(set_t * set, ITEM_TYPE * item);
58 int setNext(set_t * set, ITEM_TYPE * item);
59 int setDestroy(set_t * set);
62 * GLX Hardware Device Driver common code
63 * Copyright (C) 1999 Wittawat Yamwong
65 * Permission is hereby granted, free of charge, to any person obtaining a
66 * copy of this software and associated documentation files (the "Software"),
67 * to deal in the Software without restriction, including without limitation
68 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
69 * and/or sell copies of the Software, and to permit persons to whom the
70 * Software is furnished to do so, subject to the following conditions:
72 * The above copyright notice and this permission notice shall be included
73 * in all copies or substantial portions of the Software.
75 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
76 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
77 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
78 * WITTAWAT YAMWONG, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
79 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
80 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
81 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
85 struct mem_block_t {
86 struct mem_block_t *next;
87 struct mem_block_t *heap;
88 int ofs, size;
89 int align;
90 unsigned int free:1;
91 unsigned int reserved:1;
93 typedef struct mem_block_t TMemBlock;
94 typedef struct mem_block_t *PMemBlock;
96 /* a heap is just the first block in a chain */
97 typedef struct mem_block_t memHeap_t;
99 static __inline__ int mmBlockSize(PMemBlock b)
101 return b->size;
104 static __inline__ int mmOffset(PMemBlock b)
106 return b->ofs;
109 static __inline__ void mmMarkReserved(PMemBlock b)
111 b->reserved = 1;
115 * input: total size in bytes
116 * return: a heap pointer if OK, NULL if error
118 memHeap_t *mmInit(int ofs, int size);
121 * Allocate 'size' bytes with 2^align2 bytes alignment,
122 * restrict the search to free memory after 'startSearch'
123 * depth and back buffers should be in different 4mb banks
124 * to get better page hits if possible
125 * input: size = size of block
126 * align2 = 2^align2 bytes alignment
127 * startSearch = linear offset from start of heap to begin search
128 * return: pointer to the allocated block, 0 if error
130 PMemBlock mmAllocMem(memHeap_t * heap, int size, int align2, int startSearch);
133 * Returns 1 if the block 'b' is part of the heap 'heap'
135 int mmBlockInHeap(PMemBlock heap, PMemBlock b);
138 * Free block starts at offset
139 * input: pointer to a block
140 * return: 0 if OK, -1 if error
142 int mmFreeMem(PMemBlock b);
144 /* For debuging purpose. */
145 void mmDumpMemInfo(memHeap_t * mmInit);
147 #endif /* __SIS_DS_H__ */