Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * include/asm-ppc/rheap.h
0003  *
0004  * Header file for the implementation of a remote heap.
0005  *
0006  * Author: Pantelis Antoniou <panto@intracom.gr>
0007  *
0008  * 2004 (c) INTRACOM S.A. Greece. This file is licensed under
0009  * the terms of the GNU General Public License version 2. This program
0010  * is licensed "as is" without any warranty of any kind, whether express
0011  * or implied.
0012  */
0013 
0014 #ifndef __ASM_PPC_RHEAP_H__
0015 #define __ASM_PPC_RHEAP_H__
0016 
0017 #include <linux/list.h>
0018 
0019 typedef struct _rh_block {
0020     struct list_head list;
0021     unsigned long start;
0022     int size;
0023     const char *owner;
0024 } rh_block_t;
0025 
0026 typedef struct _rh_info {
0027     unsigned int alignment;
0028     int max_blocks;
0029     int empty_slots;
0030     rh_block_t *block;
0031     struct list_head empty_list;
0032     struct list_head free_list;
0033     struct list_head taken_list;
0034     unsigned int flags;
0035 } rh_info_t;
0036 
0037 #define RHIF_STATIC_INFO    0x1
0038 #define RHIF_STATIC_BLOCK   0x2
0039 
0040 typedef struct _rh_stats {
0041     unsigned long start;
0042     int size;
0043     const char *owner;
0044 } rh_stats_t;
0045 
0046 #define RHGS_FREE   0
0047 #define RHGS_TAKEN  1
0048 
0049 /* Create a remote heap dynamically */
0050 extern rh_info_t *rh_create(unsigned int alignment);
0051 
0052 /* Destroy a remote heap, created by rh_create() */
0053 extern void rh_destroy(rh_info_t * info);
0054 
0055 /* Initialize in place a remote info block */
0056 extern void rh_init(rh_info_t * info, unsigned int alignment, int max_blocks,
0057             rh_block_t * block);
0058 
0059 /* Attach a free region to manage */
0060 extern int rh_attach_region(rh_info_t * info, unsigned long start, int size);
0061 
0062 /* Detach a free region */
0063 extern unsigned long rh_detach_region(rh_info_t * info, unsigned long start, int size);
0064 
0065 /* Allocate the given size from the remote heap (with alignment) */
0066 extern unsigned long rh_alloc_align(rh_info_t * info, int size, int alignment,
0067         const char *owner);
0068 
0069 /* Allocate the given size from the remote heap */
0070 extern unsigned long rh_alloc(rh_info_t * info, int size, const char *owner);
0071 
0072 /* Allocate the given size from the given address */
0073 extern unsigned long rh_alloc_fixed(rh_info_t * info, unsigned long start, int size,
0074                 const char *owner);
0075 
0076 /* Free the allocated area */
0077 extern int rh_free(rh_info_t * info, unsigned long start);
0078 
0079 /* Get stats for debugging purposes */
0080 extern int rh_get_stats(rh_info_t * info, int what, int max_stats,
0081             rh_stats_t * stats);
0082 
0083 /* Simple dump of remote heap info */
0084 extern void rh_dump(rh_info_t * info);
0085 
0086 /* Simple dump of remote info block */
0087 void rh_dump_blk(rh_info_t *info, rh_block_t *blk);
0088 
0089 /* Set owner of taken block */
0090 extern int rh_set_owner(rh_info_t * info, unsigned long start, const char *owner);
0091 
0092 #endif              /* __ASM_PPC_RHEAP_H__ */