18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * include/asm-ppc/rheap.h
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Header file for the implementation of a remote heap.
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * Author: Pantelis Antoniou <panto@intracom.gr>
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci * 2004 (c) INTRACOM S.A. Greece. This file is licensed under
98c2ecf20Sopenharmony_ci * the terms of the GNU General Public License version 2. This program
108c2ecf20Sopenharmony_ci * is licensed "as is" without any warranty of any kind, whether express
118c2ecf20Sopenharmony_ci * or implied.
128c2ecf20Sopenharmony_ci */
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#ifndef __ASM_PPC_RHEAP_H__
158c2ecf20Sopenharmony_ci#define __ASM_PPC_RHEAP_H__
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#include <linux/list.h>
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_citypedef struct _rh_block {
208c2ecf20Sopenharmony_ci	struct list_head list;
218c2ecf20Sopenharmony_ci	unsigned long start;
228c2ecf20Sopenharmony_ci	int size;
238c2ecf20Sopenharmony_ci	const char *owner;
248c2ecf20Sopenharmony_ci} rh_block_t;
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_citypedef struct _rh_info {
278c2ecf20Sopenharmony_ci	unsigned int alignment;
288c2ecf20Sopenharmony_ci	int max_blocks;
298c2ecf20Sopenharmony_ci	int empty_slots;
308c2ecf20Sopenharmony_ci	rh_block_t *block;
318c2ecf20Sopenharmony_ci	struct list_head empty_list;
328c2ecf20Sopenharmony_ci	struct list_head free_list;
338c2ecf20Sopenharmony_ci	struct list_head taken_list;
348c2ecf20Sopenharmony_ci	unsigned int flags;
358c2ecf20Sopenharmony_ci} rh_info_t;
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci#define RHIF_STATIC_INFO	0x1
388c2ecf20Sopenharmony_ci#define RHIF_STATIC_BLOCK	0x2
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_citypedef struct _rh_stats {
418c2ecf20Sopenharmony_ci	unsigned long start;
428c2ecf20Sopenharmony_ci	int size;
438c2ecf20Sopenharmony_ci	const char *owner;
448c2ecf20Sopenharmony_ci} rh_stats_t;
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci#define RHGS_FREE	0
478c2ecf20Sopenharmony_ci#define RHGS_TAKEN	1
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci/* Create a remote heap dynamically */
508c2ecf20Sopenharmony_ciextern rh_info_t *rh_create(unsigned int alignment);
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci/* Destroy a remote heap, created by rh_create() */
538c2ecf20Sopenharmony_ciextern void rh_destroy(rh_info_t * info);
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci/* Initialize in place a remote info block */
568c2ecf20Sopenharmony_ciextern void rh_init(rh_info_t * info, unsigned int alignment, int max_blocks,
578c2ecf20Sopenharmony_ci		    rh_block_t * block);
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci/* Attach a free region to manage */
608c2ecf20Sopenharmony_ciextern int rh_attach_region(rh_info_t * info, unsigned long start, int size);
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci/* Detach a free region */
638c2ecf20Sopenharmony_ciextern unsigned long rh_detach_region(rh_info_t * info, unsigned long start, int size);
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci/* Allocate the given size from the remote heap (with alignment) */
668c2ecf20Sopenharmony_ciextern unsigned long rh_alloc_align(rh_info_t * info, int size, int alignment,
678c2ecf20Sopenharmony_ci		const char *owner);
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci/* Allocate the given size from the remote heap */
708c2ecf20Sopenharmony_ciextern unsigned long rh_alloc(rh_info_t * info, int size, const char *owner);
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci/* Allocate the given size from the given address */
738c2ecf20Sopenharmony_ciextern unsigned long rh_alloc_fixed(rh_info_t * info, unsigned long start, int size,
748c2ecf20Sopenharmony_ci			    const char *owner);
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci/* Free the allocated area */
778c2ecf20Sopenharmony_ciextern int rh_free(rh_info_t * info, unsigned long start);
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci/* Get stats for debugging purposes */
808c2ecf20Sopenharmony_ciextern int rh_get_stats(rh_info_t * info, int what, int max_stats,
818c2ecf20Sopenharmony_ci			rh_stats_t * stats);
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci/* Simple dump of remote heap info */
848c2ecf20Sopenharmony_ciextern void rh_dump(rh_info_t * info);
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci/* Simple dump of remote info block */
878c2ecf20Sopenharmony_civoid rh_dump_blk(rh_info_t *info, rh_block_t *blk);
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci/* Set owner of taken block */
908c2ecf20Sopenharmony_ciextern int rh_set_owner(rh_info_t * info, unsigned long start, const char *owner);
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_ci#endif				/* __ASM_PPC_RHEAP_H__ */
93