OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [drivers/] [char/] [drm/] [via_ds.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/*
2
 * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
3
 * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
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, sub license,
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 (including the
13
 * next paragraph) shall be included in all copies or substantial portions
14
 * of the Software.
15
 *
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19
 * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22
 * DEALINGS IN THE SOFTWARE.
23
 */
24
 
25
#ifndef _via_ds_h_
26
#define _via_ds_h_
27
 
28
/* Set Data Structure */
29
 
30
#define SET_SIZE 5000
31
 
32
typedef struct {
33
        unsigned int val;
34
        int alloc_next, free_next;
35
} list_item_t;
36
 
37
typedef struct {
38
        int alloc;
39
        int free;
40
        int trace;
41
        list_item_t list[SET_SIZE];
42
} set_t;
43
 
44
set_t *via_set_init(void);
45
int via_set_add(set_t *set, unsigned int item);
46
int via_set_del(set_t *set, unsigned int item);
47
int via_set_first(set_t *set, unsigned int *item);
48
int via_set_next(set_t *set, unsigned int *item);
49
int via_set_destroy(set_t *set);
50
 
51
#endif
52
 
53
 
54
#ifndef MM_INC
55
#define MM_INC
56
 
57
struct mem_block_t {
58
        struct mem_block_t *next;
59
        struct mem_block_t *heap;
60
        int ofs,size;
61
        int align;
62
        int free:1;
63
        int reserved:1;
64
};
65
typedef struct mem_block_t TMemBlock;
66
typedef struct mem_block_t *PMemBlock;
67
 
68
/* a heap is just the first block in a chain */
69
typedef struct mem_block_t memHeap_t;
70
 
71
static __inline__ int mmBlockSize(PMemBlock b)
72
{
73
        return b->size;
74
}
75
 
76
static __inline__ int mmOffset(PMemBlock b)
77
{
78
        return b->ofs;
79
}
80
 
81
static __inline__ void mmMarkReserved(PMemBlock b)
82
{
83
        b->reserved = 1;
84
}
85
 
86
/*
87
 * input: total size in bytes
88
 * return: a heap pointer if OK, NULL if error
89
 */
90
 
91
memHeap_t *via_mmInit(int ofs, int size);
92
 
93
memHeap_t *via_mmAddRange(memHeap_t *heap, int ofs, int size);
94
 
95
 
96
/*
97
 * Allocate 'size' bytes with 2^align2 bytes alignment,
98
 * restrict the search to free memory after 'startSearch'
99
 * depth and back buffers should be in different 4mb banks
100
 * to get better page hits if possible
101
 * input:       size = size of block
102
 *              align2 = 2^align2 bytes alignment
103
 *              startSearch = linear offset from start of heap to begin search
104
 * return: pointer to the allocated block, 0 if error
105
 */
106
 
107
PMemBlock  via_mmAllocMem(memHeap_t *heap, int size, int align2, int startSearch);
108
 
109
/*
110
 * Free block starts at offset
111
 * input: pointer to a block
112
 * return: 0 if OK, -1 if error
113
 */
114
int  via_mmFreeMem(PMemBlock b);
115
 
116
/*
117
 * Reserve 'size' bytes block start at offset
118
 * This is used to prevent allocation of memory already used
119
 * by the X server for the front buffer, pixmaps, and cursor
120
 * input: size, offset
121
 * output: 0 if OK, -1 if error
122
 */
123
int via_mmReserveMem(memHeap_t *heap, int offset,int size);
124
int via_mmFreeReserved(memHeap_t *heap, int offset);
125
 
126
/*
127
 * destroy MM
128
 */
129
void via_mmDestroy(memHeap_t *mmInit);
130
 
131
/* For debuging purpose. */
132
void via_mmDumpMemInfo(memHeap_t *mmInit);
133
 
134
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.