]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/drm/sis_ds.h
This commit was generated by cvs2svn to compensate for changes in r140094,
[FreeBSD/FreeBSD.git] / sys / dev / drm / sis_ds.h
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  * Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
5  * All rights reserved.
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a
8  * copy of this software and associated documentation files (the "Software"),
9  * to deal in the Software without restriction, including without limitation
10  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11  * and/or sell copies of the Software, and to permit persons to whom the
12  * Software is furnished to do so, subject to the following conditions:
13  * 
14  * The above copyright notice and this permission notice (including the next
15  * paragraph) shall be included in all copies or substantial portions of the
16  * Software.
17  * 
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
21  * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
22  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
23  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24  * DEALINGS IN THE SOFTWARE.
25  * 
26  * Authors:
27  *    Sung-Ching Lin <sclin@sis.com.tw>
28  * 
29  * $FreeBSD$
30  */
31
32 #ifndef __SIS_DS_H__
33 #define __SIS_DS_H__
34
35 /* Set Data Structure */
36
37 #define SET_SIZE 5000
38
39 typedef unsigned long ITEM_TYPE;
40
41 typedef struct {
42         ITEM_TYPE val;
43         int alloc_next, free_next;
44 } list_item_t;
45
46 typedef struct {
47         int alloc;
48         int free;
49         int trace;
50         list_item_t list[SET_SIZE];
51 } set_t;
52
53 set_t *setInit(void);
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);
59
60 /*
61  * GLX Hardware Device Driver common code
62  * Copyright (C) 1999 Keith Whitwell
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
77  * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, 
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 
80  * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
81  *
82  */
83
84 struct mem_block_t {
85         struct mem_block_t *next;
86         struct mem_block_t *heap;
87         int ofs,size;
88         int align;
89         int free:1;
90         int reserved:1;
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)
99 {
100         return b->size;
101 }
102
103 static __inline__ int mmOffset(PMemBlock b)
104 {
105         return b->ofs;
106 }
107
108 static __inline__ void mmMarkReserved(PMemBlock b)
109 {
110         b->reserved = 1;
111 }
112
113 /* 
114  * input: total size in bytes
115  * return: a heap pointer if OK, NULL if error
116  */
117 memHeap_t *mmInit( int ofs, int size );
118
119 memHeap_t *mmAddRange( memHeap_t *heap,
120                        int ofs,
121                        int size );
122
123 /*
124  * Allocate 'size' bytes with 2^align2 bytes alignment,
125  * restrict the search to free memory after 'startSearch'
126  * depth and back buffers should be in different 4mb banks
127  * to get better page hits if possible
128  * input:       size = size of block
129  *              align2 = 2^align2 bytes alignment
130  *              startSearch = linear offset from start of heap to begin search
131  * return: pointer to the allocated block, 0 if error
132  */
133 PMemBlock mmAllocMem( memHeap_t *heap, int size, int align2, int startSearch );
134
135 /*
136  * Returns 1 if the block 'b' is part of the heap 'heap'
137  */
138 int mmBlockInHeap( PMemBlock heap, PMemBlock b );
139
140 /*
141  * Free block starts at offset
142  * input: pointer to a block
143  * return: 0 if OK, -1 if error
144  */
145 int mmFreeMem( PMemBlock b );
146
147 /*
148  * Reserve 'size' bytes block start at offset
149  * This is used to prevent allocation of memory already used
150  * by the X server for the front buffer, pixmaps, and cursor
151  * input: size, offset
152  * output: 0 if OK, -1 if error
153  */
154 int mmReserveMem( memHeap_t *heap, int offset,int size );
155 int mmFreeReserved( memHeap_t *heap, int offset );
156
157 /*
158  * destroy MM
159  */
160 void mmDestroy( memHeap_t *mmInit );
161
162 /* For debuging purpose. */
163 void mmDumpMemInfo( memHeap_t *mmInit );
164
165 #endif /* __SIS_DS_H__ */