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