////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2002 Xilinx, Inc.  All rights reserved.
//
// Xilinx, Inc.
// XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS" AS A 
// COURTESY TO YOU.  BY PROVIDING THIS DESIGN, CODE, OR INFORMATION AS
// ONE POSSIBLE   IMPLEMENTATION OF THIS FEATURE, APPLICATION OR 
// STANDARD, XILINX IS MAKING NO REPRESENTATION THAT THIS IMPLEMENTATION
// IS FREE FROM ANY CLAIMS OF INFRINGEMENT, AND YOU ARE RESPONSIBLE 
// FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE FOR YOUR IMPLEMENTATION.  
// XILINX EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH RESPECT TO 
// THE ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO 
// ANY WARRANTIES OR REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE 
// FROM CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY 
// AND FITNESS FOR A PARTICULAR PURPOSE.
// 
// Date   : 2002, November.
// Author : Raj Nagarajan (rajn@xilinx.com)
// Company: Xilinx
// Group  : Emerging Software Technologies
//
// $Id :$
//
//////////////////////////////////////////////////////////////////////////////

/***************************************************************************/
/**
 * @file mem.h 
 *
 * This contains the function decleration for Memory allocation routines.
 ***************************************************************************/
#ifndef _MEM_H
#define _MEM_H

#include <os_config.h>
#include <config_param.h>
#include <config_cparam.h>
#include <sys/queue.h>

#define SEMAQ_START 	(N_PRIO*MAX_READYQ)

/**
 * This is used by buffer management routines.
 * Each Memory Block of different sizes is associated with each structure
 */
struct _malloc_info {
	unsigned int mem_bsize ;	/**< Memory Block Size */
	unsigned char max_blks ;	/**< Max. number of mem blocks */
	unsigned char n_blks ;		/**< No. of mem blocks allocated */
	unsigned short start_blk ;	/**< The starting mem. blk number */
	signed char *start_addr ;	/**< Starting memory location for this bll */
} ;

/*
 * All functions are defined in sys/mem.h
 */
void alloc_pidq_mem( queuep queue, unsigned int qtype, unsigned int qno ) ;
void start_process_init() ;

void alloc_msgq_mem( queuep queue, unsigned int qno ) ;
void msgq_init() ;

void shm_init() ;

void bss_mem_init() ;
int alloc_bss_mem( unsigned int *start, unsigned int *end ) ;
void free_bss_mem( unsigned int memid ) ;

void malloc_init() ;
void *bufmalloc( unsigned int size ) ;
void buffree( void *mem ) ;


#endif
