rheap.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * include/asm-ppc/rheap.c
  3. *
  4. * Header file for the implementation of a remote heap.
  5. *
  6. * Author: Pantelis Antoniou <panto@intracom.gr>
  7. *
  8. * 2004 (c) INTRACOM S.A. Greece. This file is licensed under
  9. * the terms of the GNU General Public License version 2. This program
  10. * is licensed "as is" without any warranty of any kind, whether express
  11. * or implied.
  12. */
  13. #ifndef __ASM_PPC_RHEAP_H__
  14. #define __ASM_PPC_RHEAP_H__
  15. #include <linux/list.h>
  16. typedef struct _rh_block {
  17. struct list_head list;
  18. void *start;
  19. int size;
  20. const char *owner;
  21. } rh_block_t;
  22. typedef struct _rh_info {
  23. unsigned int alignment;
  24. int max_blocks;
  25. int empty_slots;
  26. rh_block_t *block;
  27. struct list_head empty_list;
  28. struct list_head free_list;
  29. struct list_head taken_list;
  30. unsigned int flags;
  31. } rh_info_t;
  32. #define RHIF_STATIC_INFO 0x1
  33. #define RHIF_STATIC_BLOCK 0x2
  34. typedef struct rh_stats_t {
  35. void *start;
  36. int size;
  37. const char *owner;
  38. } rh_stats_t;
  39. #define RHGS_FREE 0
  40. #define RHGS_TAKEN 1
  41. /* Create a remote heap dynamically */
  42. extern rh_info_t *rh_create(unsigned int alignment);
  43. /* Destroy a remote heap, created by rh_create() */
  44. extern void rh_destroy(rh_info_t * info);
  45. /* Initialize in place a remote info block */
  46. extern void rh_init(rh_info_t * info, unsigned int alignment, int max_blocks,
  47. rh_block_t * block);
  48. /* Attach a free region to manage */
  49. extern int rh_attach_region(rh_info_t * info, void *start, int size);
  50. /* Detach a free region */
  51. extern void *rh_detach_region(rh_info_t * info, void *start, int size);
  52. /* Allocate the given size from the remote heap */
  53. extern void *rh_alloc(rh_info_t * info, int size, const char *owner);
  54. /* Allocate the given size from the given address */
  55. extern void *rh_alloc_fixed(rh_info_t * info, void *start, int size,
  56. const char *owner);
  57. /* Free the allocated area */
  58. extern int rh_free(rh_info_t * info, void *start);
  59. /* Get stats for debugging purposes */
  60. extern int rh_get_stats(rh_info_t * info, int what, int max_stats,
  61. rh_stats_t * stats);
  62. /* Simple dump of remote heap info */
  63. extern void rh_dump(rh_info_t * info);
  64. /* Set owner of taken block */
  65. extern int rh_set_owner(rh_info_t * info, void *start, const char *owner);
  66. #endif /* __ASM_PPC_RHEAP_H__ */