Clone of mesa.
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /**************************************************************************
  2. *
  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. * @file
  26. * Memory manager code. Primarily used by device drivers to manage texture
  27. * heaps, etc.
  28. */
  29. #ifndef _U_MM_H_
  30. #define _U_MM_H_
  31. struct mem_block {
  32. struct mem_block *next, *prev;
  33. struct mem_block *next_free, *prev_free;
  34. struct mem_block *heap;
  35. int ofs,size;
  36. unsigned int free:1;
  37. unsigned int reserved:1;
  38. };
  39. /**
  40. * input: total size in bytes
  41. * return: a heap pointer if OK, NULL if error
  42. */
  43. extern struct mem_block *mmInit(int ofs, int size);
  44. /**
  45. * Allocate 'size' bytes with 2^align2 bytes alignment,
  46. * restrict the search to free memory after 'startSearch'
  47. * depth and back buffers should be in different 4mb banks
  48. * to get better page hits if possible
  49. * input: size = size of block
  50. * align2 = 2^align2 bytes alignment
  51. * startSearch = linear offset from start of heap to begin search
  52. * return: pointer to the allocated block, 0 if error
  53. */
  54. extern struct mem_block *mmAllocMem(struct mem_block *heap, int size, int align2,
  55. int startSearch);
  56. /**
  57. * Free block starts at offset
  58. * input: pointer to a block
  59. * return: 0 if OK, -1 if error
  60. */
  61. extern int mmFreeMem(struct mem_block *b);
  62. /**
  63. * Free block starts at offset
  64. * input: pointer to a heap, start offset
  65. * return: pointer to a block
  66. */
  67. extern struct mem_block *mmFindBlock(struct mem_block *heap, int start);
  68. /**
  69. * destroy MM
  70. */
  71. extern void mmDestroy(struct mem_block *mmInit);
  72. /**
  73. * For debuging purpose.
  74. */
  75. extern void mmDumpMemInfo(const struct mem_block *mmInit);
  76. #endif