sis_ds.h 4.5 KB

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