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.
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:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
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.
31 /* Set Data Structure */
33 typedef unsigned long ITEM_TYPE;
37 int alloc_next, free_next;
44 list_item_t list[SET_SIZE];
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);
60 struct mem_block_t *next;
61 struct mem_block_t *heap;
65 unsigned int reserved:1;
67 typedef struct mem_block_t TMemBlock;
68 typedef struct mem_block_t *PMemBlock;
70 /* a heap is just the first block in a chain */
71 typedef struct mem_block_t memHeap_t;
73 static __inline__ int mmBlockSize(PMemBlock b)
78 static __inline__ int mmOffset(PMemBlock b)
83 static __inline__ void mmMarkReserved(PMemBlock b)
89 * input: total size in bytes
90 * return: a heap pointer if OK, NULL if error
92 memHeap_t *via_mmInit(int ofs, int size);
94 PMemBlock via_mmAllocMem(memHeap_t * heap, int size, int align2,
98 * Free block starts at offset
99 * input: pointer to a block
100 * return: 0 if OK, -1 if error
102 int via_mmFreeMem(PMemBlock b);