mesa: refactor: move glTexParameter-related functions into new texparam.c file
[mesa.git] / src / mesa / main / mm.h
1 /*
2 * GLX Hardware Device Driver common code
3 * Copyright (C) 1999 Wittawat Yamwong
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included
13 * in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
21 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */
23
24
25 /**
26 * Memory manager code. Primarily used by device drivers to manage texture
27 * heaps, etc.
28 */
29
30
31 #ifndef MM_H
32 #define MM_H
33
34
35 #include "imports.h"
36
37
38 struct mem_block {
39 struct mem_block *next, *prev;
40 struct mem_block *next_free, *prev_free;
41 struct mem_block *heap;
42 int ofs,size;
43 unsigned int free:1;
44 unsigned int reserved:1;
45 };
46
47
48
49 /**
50 * input: total size in bytes
51 * return: a heap pointer if OK, NULL if error
52 */
53 extern struct mem_block *mmInit(int ofs, int size);
54
55 /**
56 * Allocate 'size' bytes with 2^align2 bytes alignment,
57 * restrict the search to free memory after 'startSearch'
58 * depth and back buffers should be in different 4mb banks
59 * to get better page hits if possible
60 * input: size = size of block
61 * align2 = 2^align2 bytes alignment
62 * startSearch = linear offset from start of heap to begin search
63 * return: pointer to the allocated block, 0 if error
64 */
65 extern struct mem_block *mmAllocMem(struct mem_block *heap, int size, int align2,
66 int startSearch);
67
68 /**
69 * Free block starts at offset
70 * input: pointer to a block
71 * return: 0 if OK, -1 if error
72 */
73 extern int mmFreeMem(struct mem_block *b);
74
75 /**
76 * Free block starts at offset
77 * input: pointer to a heap, start offset
78 * return: pointer to a block
79 */
80 extern struct mem_block *mmFindBlock(struct mem_block *heap, int start);
81
82 /**
83 * destroy MM
84 */
85 extern void mmDestroy(struct mem_block *mmInit);
86
87 /**
88 * For debuging purpose.
89 */
90 extern void mmDumpMemInfo(const struct mem_block *mmInit);
91
92 #endif