[AGPGART] printk fixups.
[sfrench/cifs-2.6.git] / drivers / char / drm / via_ds.h
1 /*
2  * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
3  * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
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, sub license,
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
15  * next paragraph) shall be included in all copies or substantial portions
16  * of the 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 NON-INFRINGEMENT. IN NO EVENT SHALL
21  * VIA, S3 GRAPHICS, 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 #ifndef _via_ds_h_
27 #define _via_ds_h_
28
29 #include "drmP.h"
30
31 /* Set Data Structure */
32 #define SET_SIZE 5000
33 typedef unsigned long ITEM_TYPE;
34
35 typedef struct {
36         ITEM_TYPE val;
37         int alloc_next, free_next;
38 } list_item_t;
39
40 typedef struct {
41         int alloc;
42         int free;
43         int trace;
44         list_item_t list[SET_SIZE];
45 } set_t;
46
47 set_t *via_setInit(void);
48 int via_setAdd(set_t * set, ITEM_TYPE item);
49 int via_setDel(set_t * set, ITEM_TYPE item);
50 int via_setFirst(set_t * set, ITEM_TYPE * item);
51 int via_setNext(set_t * set, ITEM_TYPE * item);
52 int via_setDestroy(set_t * set);
53
54 #endif
55
56 #ifndef MM_INC
57 #define MM_INC
58
59 struct mem_block_t {
60         struct mem_block_t *next;
61         struct mem_block_t *heap;
62         int ofs, size;
63         int align;
64         unsigned int free:1;
65         unsigned int reserved:1;
66 };
67 typedef struct mem_block_t TMemBlock;
68 typedef struct mem_block_t *PMemBlock;
69
70 /* a heap is just the first block in a chain */
71 typedef struct mem_block_t memHeap_t;
72
73 static __inline__ int mmBlockSize(PMemBlock b)
74 {
75         return b->size;
76 }
77
78 static __inline__ int mmOffset(PMemBlock b)
79 {
80         return b->ofs;
81 }
82
83 static __inline__ void mmMarkReserved(PMemBlock b)
84 {
85         b->reserved = 1;
86 }
87
88 /*
89  * input: total size in bytes
90  * return: a heap pointer if OK, NULL if error
91  */
92 memHeap_t *via_mmInit(int ofs, int size);
93
94 PMemBlock via_mmAllocMem(memHeap_t * heap, int size, int align2,
95                          int startSearch);
96
97 /*
98  * Free block starts at offset
99  * input: pointer to a block
100  * return: 0 if OK, -1 if error
101  */
102 int via_mmFreeMem(PMemBlock b);
103
104 #endif