sis_ds.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. /*
  5. * Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
  6. * All rights reserved.
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a
  9. * copy of this software and associated documentation files (the "Software"),
  10. * to deal in the Software without restriction, including without limitation
  11. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  12. * and/or sell copies of the Software, and to permit persons to whom the
  13. * Software is furnished to do so, subject to the following conditions:
  14. *
  15. * The above copyright notice and this permission notice (including the next
  16. * paragraph) shall be included in all copies or substantial portions of the
  17. * Software.
  18. *
  19. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  22. * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  23. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  24. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  25. * DEALINGS IN THE SOFTWARE.
  26. *
  27. * Authors:
  28. * Sung-Ching Lin <sclin@sis.com.tw>
  29. *
  30. */
  31. #ifndef __SIS_DS_H__
  32. #define __SIS_DS_H__
  33. /* Set Data Structure */
  34. #define SET_SIZE 5000
  35. typedef unsigned long ITEM_TYPE;
  36. typedef struct {
  37. ITEM_TYPE val;
  38. int alloc_next, free_next;
  39. } list_item_t;
  40. typedef struct {
  41. int alloc;
  42. int free;
  43. int trace;
  44. list_item_t list[SET_SIZE];
  45. } set_t;
  46. set_t *setInit(void);
  47. int setAdd(set_t * set, ITEM_TYPE item);
  48. int setDel(set_t * set, ITEM_TYPE item);
  49. int setFirst(set_t * set, ITEM_TYPE * item);
  50. int setNext(set_t * set, ITEM_TYPE * item);
  51. int setDestroy(set_t * set);
  52. /*
  53. * GLX Hardware Device Driver common code
  54. * Copyright (C) 1999 Wittawat Yamwong
  55. *
  56. * Permission is hereby granted, free of charge, to any person obtaining a
  57. * copy of this software and associated documentation files (the "Software"),
  58. * to deal in the Software without restriction, including without limitation
  59. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  60. * and/or sell copies of the Software, and to permit persons to whom the
  61. * Software is furnished to do so, subject to the following conditions:
  62. *
  63. * The above copyright notice and this permission notice shall be included
  64. * in all copies or substantial portions of the Software.
  65. *
  66. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  67. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  68. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  69. * WITTAWAT YAMWONG, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
  70. * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  71. * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
  72. * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  73. *
  74. */
  75. struct mem_block_t {
  76. struct mem_block_t *next;
  77. struct mem_block_t *heap;
  78. int ofs, size;
  79. int align;
  80. unsigned int free:1;
  81. unsigned int reserved:1;
  82. };
  83. typedef struct mem_block_t TMemBlock;
  84. typedef struct mem_block_t *PMemBlock;
  85. /* a heap is just the first block in a chain */
  86. typedef struct mem_block_t memHeap_t;
  87. static __inline__ int mmBlockSize(PMemBlock b)
  88. {
  89. return b->size;
  90. }
  91. static __inline__ int mmOffset(PMemBlock b)
  92. {
  93. return b->ofs;
  94. }
  95. static __inline__ void mmMarkReserved(PMemBlock b)
  96. {
  97. b->reserved = 1;
  98. }
  99. /*
  100. * input: total size in bytes
  101. * return: a heap pointer if OK, NULL if error
  102. */
  103. memHeap_t *mmInit(int ofs, int size);
  104. /*
  105. * Allocate 'size' bytes with 2^align2 bytes alignment,
  106. * restrict the search to free memory after 'startSearch'
  107. * depth and back buffers should be in different 4mb banks
  108. * to get better page hits if possible
  109. * input: size = size of block
  110. * align2 = 2^align2 bytes alignment
  111. * startSearch = linear offset from start of heap to begin search
  112. * return: pointer to the allocated block, 0 if error
  113. */
  114. PMemBlock mmAllocMem(memHeap_t * heap, int size, int align2, int startSearch);
  115. /*
  116. * Returns 1 if the block 'b' is part of the heap 'heap'
  117. */
  118. int mmBlockInHeap(PMemBlock heap, PMemBlock b);
  119. /*
  120. * Free block starts at offset
  121. * input: pointer to a block
  122. * return: 0 if OK, -1 if error
  123. */
  124. int mmFreeMem(PMemBlock b);
  125. /* For debuging purpose. */
  126. void mmDumpMemInfo(memHeap_t * mmInit);
  127. #endif /* __SIS_DS_H__ */