rheap.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * include/asm-ppc/rheap.h
  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. unsigned long 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 {
  35. unsigned long 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, unsigned long start, int size);
  50. /* Detach a free region */
  51. extern unsigned long rh_detach_region(rh_info_t * info, unsigned long start, int size);
  52. /* Allocate the given size from the remote heap (with alignment) */
  53. extern unsigned long rh_alloc_align(rh_info_t * info, int size, int alignment,
  54. const char *owner);
  55. /* Allocate the given size from the remote heap */
  56. extern unsigned long rh_alloc(rh_info_t * info, int size, const char *owner);
  57. /* Allocate the given size from the given address */
  58. extern unsigned long rh_alloc_fixed(rh_info_t * info, unsigned long start, int size,
  59. const char *owner);
  60. /* Free the allocated area */
  61. extern int rh_free(rh_info_t * info, unsigned long start);
  62. /* Get stats for debugging purposes */
  63. extern int rh_get_stats(rh_info_t * info, int what, int max_stats,
  64. rh_stats_t * stats);
  65. /* Simple dump of remote heap info */
  66. extern void rh_dump(rh_info_t * info);
  67. /* Set owner of taken block */
  68. extern int rh_set_owner(rh_info_t * info, unsigned long start, const char *owner);
  69. #endif /* __ASM_PPC_RHEAP_H__ */