162306a36Sopenharmony_ci/* 262306a36Sopenharmony_ci * include/asm-ppc/rheap.h 362306a36Sopenharmony_ci * 462306a36Sopenharmony_ci * Header file for the implementation of a remote heap. 562306a36Sopenharmony_ci * 662306a36Sopenharmony_ci * Author: Pantelis Antoniou <panto@intracom.gr> 762306a36Sopenharmony_ci * 862306a36Sopenharmony_ci * 2004 (c) INTRACOM S.A. Greece. This file is licensed under 962306a36Sopenharmony_ci * the terms of the GNU General Public License version 2. This program 1062306a36Sopenharmony_ci * is licensed "as is" without any warranty of any kind, whether express 1162306a36Sopenharmony_ci * or implied. 1262306a36Sopenharmony_ci */ 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ci#ifndef __ASM_PPC_RHEAP_H__ 1562306a36Sopenharmony_ci#define __ASM_PPC_RHEAP_H__ 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ci#include <linux/list.h> 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_citypedef struct _rh_block { 2062306a36Sopenharmony_ci struct list_head list; 2162306a36Sopenharmony_ci unsigned long start; 2262306a36Sopenharmony_ci int size; 2362306a36Sopenharmony_ci const char *owner; 2462306a36Sopenharmony_ci} rh_block_t; 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_citypedef struct _rh_info { 2762306a36Sopenharmony_ci unsigned int alignment; 2862306a36Sopenharmony_ci int max_blocks; 2962306a36Sopenharmony_ci int empty_slots; 3062306a36Sopenharmony_ci rh_block_t *block; 3162306a36Sopenharmony_ci struct list_head empty_list; 3262306a36Sopenharmony_ci struct list_head free_list; 3362306a36Sopenharmony_ci struct list_head taken_list; 3462306a36Sopenharmony_ci unsigned int flags; 3562306a36Sopenharmony_ci} rh_info_t; 3662306a36Sopenharmony_ci 3762306a36Sopenharmony_ci#define RHIF_STATIC_INFO 0x1 3862306a36Sopenharmony_ci#define RHIF_STATIC_BLOCK 0x2 3962306a36Sopenharmony_ci 4062306a36Sopenharmony_citypedef struct _rh_stats { 4162306a36Sopenharmony_ci unsigned long start; 4262306a36Sopenharmony_ci int size; 4362306a36Sopenharmony_ci const char *owner; 4462306a36Sopenharmony_ci} rh_stats_t; 4562306a36Sopenharmony_ci 4662306a36Sopenharmony_ci#define RHGS_FREE 0 4762306a36Sopenharmony_ci#define RHGS_TAKEN 1 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_ci/* Create a remote heap dynamically */ 5062306a36Sopenharmony_ciextern rh_info_t *rh_create(unsigned int alignment); 5162306a36Sopenharmony_ci 5262306a36Sopenharmony_ci/* Destroy a remote heap, created by rh_create() */ 5362306a36Sopenharmony_ciextern void rh_destroy(rh_info_t * info); 5462306a36Sopenharmony_ci 5562306a36Sopenharmony_ci/* Initialize in place a remote info block */ 5662306a36Sopenharmony_ciextern void rh_init(rh_info_t * info, unsigned int alignment, int max_blocks, 5762306a36Sopenharmony_ci rh_block_t * block); 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_ci/* Attach a free region to manage */ 6062306a36Sopenharmony_ciextern int rh_attach_region(rh_info_t * info, unsigned long start, int size); 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_ci/* Detach a free region */ 6362306a36Sopenharmony_ciextern unsigned long rh_detach_region(rh_info_t * info, unsigned long start, int size); 6462306a36Sopenharmony_ci 6562306a36Sopenharmony_ci/* Allocate the given size from the remote heap (with alignment) */ 6662306a36Sopenharmony_ciextern unsigned long rh_alloc_align(rh_info_t * info, int size, int alignment, 6762306a36Sopenharmony_ci const char *owner); 6862306a36Sopenharmony_ci 6962306a36Sopenharmony_ci/* Allocate the given size from the remote heap */ 7062306a36Sopenharmony_ciextern unsigned long rh_alloc(rh_info_t * info, int size, const char *owner); 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ci/* Allocate the given size from the given address */ 7362306a36Sopenharmony_ciextern unsigned long rh_alloc_fixed(rh_info_t * info, unsigned long start, int size, 7462306a36Sopenharmony_ci const char *owner); 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_ci/* Free the allocated area */ 7762306a36Sopenharmony_ciextern int rh_free(rh_info_t * info, unsigned long start); 7862306a36Sopenharmony_ci 7962306a36Sopenharmony_ci/* Get stats for debugging purposes */ 8062306a36Sopenharmony_ciextern int rh_get_stats(rh_info_t * info, int what, int max_stats, 8162306a36Sopenharmony_ci rh_stats_t * stats); 8262306a36Sopenharmony_ci 8362306a36Sopenharmony_ci/* Simple dump of remote heap info */ 8462306a36Sopenharmony_ciextern void rh_dump(rh_info_t * info); 8562306a36Sopenharmony_ci 8662306a36Sopenharmony_ci/* Simple dump of remote info block */ 8762306a36Sopenharmony_civoid rh_dump_blk(rh_info_t *info, rh_block_t *blk); 8862306a36Sopenharmony_ci 8962306a36Sopenharmony_ci/* Set owner of taken block */ 9062306a36Sopenharmony_ciextern int rh_set_owner(rh_info_t * info, unsigned long start, const char *owner); 9162306a36Sopenharmony_ci 9262306a36Sopenharmony_ci#endif /* __ASM_PPC_RHEAP_H__ */ 93