forked from Imagelibrary/rtems
2007-05-03 Joel Sherrill <joel@OARcorp.com>
* ChangeLog, libcsupport/src/malloc.c, libcsupport/src/mallocfreespace.c, sapi/include/confdefs.h, score/Makefile.am, score/preinstall.am: malloc never blocks so the Region Manager is quite heavy for implementing this. This patch implements the C Program Heap directly in terms of the new Protected Heap handler. This handler is a direct use of a SuperCore Heap in conjunction with the Allocator Mutex used internally by RTEMS. This saves 3184 bytes on most SPARC test executables. * score/include/rtems/score/protectedheap.h, score/src/pheapallocate.c, score/src/pheapallocatealigned.c, score/src/pheapextend.c, score/src/pheapfree.c, score/src/pheapgetblocksize.c, score/src/pheapgetfreeinfo.c, score/src/pheapgetinfo.c, score/src/pheapinit.c, score/src/pheapresizeblock.c, score/src/pheapwalk.c: New files.
This commit is contained in:
@@ -1,3 +1,28 @@
|
||||
2007-05-03 Joel Sherrill <joel@OARcorp.com>
|
||||
|
||||
* ChangeLog, libcsupport/src/malloc.c,
|
||||
libcsupport/src/mallocfreespace.c, sapi/include/confdefs.h,
|
||||
score/Makefile.am, score/preinstall.am: malloc never blocks so the
|
||||
Region Manager is quite heavy for implementing this. This patch
|
||||
implements the C Program Heap directly in terms of the new Protected
|
||||
Heap handler. This handler is a direct use of a SuperCore Heap in
|
||||
conjunction with the Allocator Mutex used internally by RTEMS. This
|
||||
saves 3184 bytes on most SPARC test executables.
|
||||
* score/include/rtems/score/protectedheap.h, score/src/pheapallocate.c,
|
||||
score/src/pheapallocatealigned.c, score/src/pheapextend.c,
|
||||
score/src/pheapfree.c, score/src/pheapgetblocksize.c,
|
||||
score/src/pheapgetfreeinfo.c, score/src/pheapgetinfo.c,
|
||||
score/src/pheapinit.c, score/src/pheapresizeblock.c,
|
||||
score/src/pheapwalk.c: New files.
|
||||
|
||||
2007-05-03 Joel Sherrill <joel@OARcorp.com>
|
||||
|
||||
* libcsupport/src/rmdir.c: Fixed spacing.
|
||||
* libcsupport/Makefile.am, libcsupport/src/newlibc.c: Split _exit from
|
||||
newlibc.c. It is not required for minimum executing and drops 624
|
||||
from SPARC minimum executable.
|
||||
* libcsupport/src/newlibc_exit.c: New file.
|
||||
|
||||
2007-04-17 Joel Sherrill <joel@OARcorp.com>
|
||||
|
||||
* itron/Makefile.am, itron/src/eventflags.c, itron/src/fmempool.c,
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__
|
||||
#include <rtems.h>
|
||||
#include <rtems/libcsupport.h>
|
||||
#include <rtems/score/apimutex.h>
|
||||
#include <rtems/score/protectedheap.h>
|
||||
#ifdef RTEMS_NEWLIB
|
||||
#include <sys/reent.h>
|
||||
#endif
|
||||
@@ -85,9 +85,10 @@ void reportMallocError(const char *msg, struct mallocNode *mp)
|
||||
}
|
||||
#endif
|
||||
|
||||
Heap_Control RTEMS_Malloc_Heap;
|
||||
Chain_Control RTEMS_Malloc_GC_list;
|
||||
|
||||
rtems_id RTEMS_Malloc_Heap;
|
||||
/* rtems_id RTEMS_Malloc_Heap; */
|
||||
size_t RTEMS_Malloc_Sbrk_amount;
|
||||
|
||||
#ifdef RTEMS_DEBUG
|
||||
@@ -119,10 +120,10 @@ void RTEMS_Malloc_Initialize(
|
||||
size_t sbrk_amount
|
||||
)
|
||||
{
|
||||
rtems_status_code status;
|
||||
void *starting_address;
|
||||
uintptr_t old_address;
|
||||
uintptr_t uaddress;
|
||||
uint32_t status;
|
||||
void *starting_address;
|
||||
uintptr_t old_address;
|
||||
uintptr_t uaddress;
|
||||
|
||||
/*
|
||||
* Initialize the garbage collection list to start with nothing on it.
|
||||
@@ -180,15 +181,13 @@ void RTEMS_Malloc_Initialize(
|
||||
* STDIO cannot work because there will be no buffers.
|
||||
*/
|
||||
|
||||
status = rtems_region_create(
|
||||
rtems_build_name( 'H', 'E', 'A', 'P' ),
|
||||
status = _Protected_heap_Initialize(
|
||||
&RTEMS_Malloc_Heap,
|
||||
starting_address,
|
||||
length,
|
||||
CPU_HEAP_ALIGNMENT,
|
||||
RTEMS_DEFAULT_ATTRIBUTES,
|
||||
&RTEMS_Malloc_Heap
|
||||
CPU_HEAP_ALIGNMENT
|
||||
);
|
||||
if ( status != RTEMS_SUCCESSFUL )
|
||||
if ( !status )
|
||||
rtems_fatal_error_occurred( status );
|
||||
|
||||
#ifdef MALLOC_STATS
|
||||
@@ -204,12 +203,11 @@ void *malloc(
|
||||
size_t size
|
||||
)
|
||||
{
|
||||
void *return_this;
|
||||
void *starting_address;
|
||||
void *return_this;
|
||||
void *starting_address;
|
||||
uint32_t the_size;
|
||||
uint32_t sbrk_amount;
|
||||
rtems_status_code status;
|
||||
Chain_Node *to_be_freed;
|
||||
Chain_Node *to_be_freed;
|
||||
|
||||
MSBUMP(malloc_calls, 1);
|
||||
|
||||
@@ -235,23 +233,17 @@ void *malloc(
|
||||
free(to_be_freed);
|
||||
|
||||
/*
|
||||
* Try to give a segment in the current region if there is not
|
||||
* enough space then try to grow the region using rtems_region_extend().
|
||||
* Try to give a segment in the current heap if there is not
|
||||
* enough space then try to grow the heap.
|
||||
* If this fails then return a NULL pointer.
|
||||
*/
|
||||
|
||||
#ifdef MALLOC_ARENA_CHECK
|
||||
size += sizeof(struct mallocNode) + SENTINELSIZE;
|
||||
#endif
|
||||
status = rtems_region_get_segment(
|
||||
RTEMS_Malloc_Heap,
|
||||
size,
|
||||
RTEMS_NO_WAIT,
|
||||
RTEMS_NO_TIMEOUT,
|
||||
&return_this
|
||||
);
|
||||
return_this = _Protected_heap_Allocate( &RTEMS_Malloc_Heap, size );
|
||||
|
||||
if ( status != RTEMS_SUCCESSFUL ) {
|
||||
if ( !return_this ) {
|
||||
/*
|
||||
* Round to the "requested sbrk amount" so hopefully we won't have
|
||||
* to grow again for a while. This effectively does sbrk() calls
|
||||
@@ -269,12 +261,8 @@ void *malloc(
|
||||
== (void*) -1)
|
||||
return (void *) 0;
|
||||
|
||||
status = rtems_region_extend(
|
||||
RTEMS_Malloc_Heap,
|
||||
starting_address,
|
||||
the_size
|
||||
);
|
||||
if ( status != RTEMS_SUCCESSFUL ) {
|
||||
if ( !_Protected_heap_Extend(
|
||||
&RTEMS_Malloc_Heap, starting_address, the_size) ) {
|
||||
sbrk(-the_size);
|
||||
errno = ENOMEM;
|
||||
return (void *) 0;
|
||||
@@ -282,14 +270,8 @@ void *malloc(
|
||||
|
||||
MSBUMP(space_available, the_size);
|
||||
|
||||
status = rtems_region_get_segment(
|
||||
RTEMS_Malloc_Heap,
|
||||
size,
|
||||
RTEMS_NO_WAIT,
|
||||
RTEMS_NO_TIMEOUT,
|
||||
&return_this
|
||||
);
|
||||
if ( status != RTEMS_SUCCESSFUL ) {
|
||||
return_this = _Protected_heap_Allocate( &RTEMS_Malloc_Heap, size );
|
||||
if ( !return_this ) {
|
||||
errno = ENOMEM;
|
||||
return (void *) 0;
|
||||
}
|
||||
@@ -298,10 +280,9 @@ void *malloc(
|
||||
#ifdef MALLOC_STATS
|
||||
if (return_this)
|
||||
{
|
||||
size_t actual_size;
|
||||
size_t actual_size = 0;
|
||||
uint32_t current_depth;
|
||||
status = rtems_region_get_segment_size(
|
||||
RTEMS_Malloc_Heap, return_this, &actual_size);
|
||||
Protected_heap_Get_block_size(&RTEMS_Malloc_Heap, ptr, &actual_size);
|
||||
MSBUMP(lifetime_allocated, actual_size);
|
||||
current_depth = rtems_malloc_stats.lifetime_allocated -
|
||||
rtems_malloc_stats.lifetime_freed;
|
||||
@@ -369,7 +350,6 @@ void *realloc(
|
||||
)
|
||||
{
|
||||
size_t old_size;
|
||||
rtems_status_code status;
|
||||
char *new_area;
|
||||
|
||||
MSBUMP(realloc_calls, 1);
|
||||
@@ -399,24 +379,17 @@ void *realloc(
|
||||
|
||||
#ifdef MALLOC_ARENA_CHECK
|
||||
{
|
||||
void *np;
|
||||
np = malloc(size);
|
||||
if (!np) return np;
|
||||
memcpy(np,ptr,size);
|
||||
free(ptr);
|
||||
return np;
|
||||
void *np;
|
||||
np = malloc(size);
|
||||
if (!np) return np;
|
||||
memcpy(np,ptr,size);
|
||||
free(ptr);
|
||||
return np;
|
||||
}
|
||||
#endif
|
||||
status =
|
||||
rtems_region_resize_segment( RTEMS_Malloc_Heap, ptr, size, &old_size );
|
||||
|
||||
if( status == RTEMS_SUCCESSFUL ) {
|
||||
if ( _Protected_heap_Resize_block( &RTEMS_Malloc_Heap, ptr, size ) ) {
|
||||
return ptr;
|
||||
}
|
||||
else if ( status != RTEMS_UNSATISFIED ) {
|
||||
errno = EINVAL;
|
||||
return (void *) 0;
|
||||
}
|
||||
|
||||
new_area = malloc( size );
|
||||
|
||||
@@ -432,8 +405,7 @@ void *realloc(
|
||||
return (void *) 0;
|
||||
}
|
||||
|
||||
status = rtems_region_get_segment_size( RTEMS_Malloc_Heap, ptr, &old_size );
|
||||
if ( status != RTEMS_SUCCESSFUL ) {
|
||||
if ( !_Protected_heap_Get_block_size(&RTEMS_Malloc_Heap, ptr, &old_size) ) {
|
||||
errno = EINVAL;
|
||||
return (void *) 0;
|
||||
}
|
||||
@@ -449,8 +421,6 @@ void free(
|
||||
void *ptr
|
||||
)
|
||||
{
|
||||
rtems_status_code status;
|
||||
|
||||
MSBUMP(free_calls, 1);
|
||||
|
||||
if ( !ptr )
|
||||
@@ -493,16 +463,14 @@ void free(
|
||||
#endif
|
||||
#ifdef MALLOC_STATS
|
||||
{
|
||||
size_t size;
|
||||
status = rtems_region_get_segment_size( RTEMS_Malloc_Heap, ptr, &size );
|
||||
if ( status == RTEMS_SUCCESSFUL ) {
|
||||
MSBUMP(lifetime_freed, size);
|
||||
}
|
||||
size_t size;
|
||||
if (Protected_heap_Get_block_size(&RTEMS_Malloc_Heap, ptr, &size) ) {
|
||||
MSBUMP(lifetime_freed, size);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
status = rtems_region_return_segment( RTEMS_Malloc_Heap, ptr );
|
||||
if ( status != RTEMS_SUCCESSFUL ) {
|
||||
if ( !_Protected_heap_Free( &RTEMS_Malloc_Heap, ptr ) ) {
|
||||
errno = EINVAL;
|
||||
assert( 0 );
|
||||
}
|
||||
@@ -565,16 +533,7 @@ void malloc_dump(void)
|
||||
|
||||
void malloc_walk(size_t source, size_t printf_enabled)
|
||||
{
|
||||
register Region_Control *the_region;
|
||||
Objects_Locations location;
|
||||
|
||||
_RTEMS_Lock_allocator(); /* to prevent deletion */
|
||||
the_region = _Region_Get( RTEMS_Malloc_Heap, &location );
|
||||
if ( location == OBJECTS_LOCAL )
|
||||
{
|
||||
_Heap_Walk( &the_region->Memory, source, printf_enabled );
|
||||
}
|
||||
_RTEMS_Unlock_allocator();
|
||||
_Protected_heap_Walk( &RTEMS_Malloc_Heap, source, printf_enabled );
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__
|
||||
#include <rtems.h>
|
||||
#include <rtems/libcsupport.h>
|
||||
#include <rtems/score/protectedheap.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -27,7 +28,7 @@
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
extern rtems_id RTEMS_Malloc_Heap;
|
||||
extern Heap_Control RTEMS_Malloc_Heap;
|
||||
|
||||
/*
|
||||
* Find amount of free heap remaining
|
||||
@@ -35,10 +36,8 @@ extern rtems_id RTEMS_Malloc_Heap;
|
||||
|
||||
size_t malloc_free_space( void )
|
||||
{
|
||||
region_information_block heap_info;
|
||||
Heap_Information info;
|
||||
|
||||
if ( !rtems_region_get_free_information( RTEMS_Malloc_Heap, &heap_info ) ) {
|
||||
return (size_t) heap_info.Free.largest;
|
||||
}
|
||||
return (size_t) -1;
|
||||
_Protected_heap_Get_free_information( &RTEMS_Malloc_Heap, &info );
|
||||
return (size_t) info.largest;
|
||||
}
|
||||
|
||||
@@ -70,8 +70,6 @@ extern itron_api_configuration_table Configuration_ITRON_API;
|
||||
#define CONFIGURE_NEWLIB_EXTENSION 0
|
||||
#endif
|
||||
|
||||
#define CONFIGURE_MALLOC_REGION 1
|
||||
|
||||
/*
|
||||
* File descriptors managed by libio
|
||||
*/
|
||||
@@ -1056,8 +1054,7 @@ itron_initialization_tasks_table ITRON_Initialization_tasks[] = {
|
||||
CONFIGURE_LIBIO_SEMAPHORES + CONFIGURE_TERMIOS_SEMAPHORES) + \
|
||||
CONFIGURE_MEMORY_FOR_MESSAGE_QUEUES(CONFIGURE_MAXIMUM_MESSAGE_QUEUES) + \
|
||||
CONFIGURE_MEMORY_FOR_PARTITIONS(CONFIGURE_MAXIMUM_PARTITIONS) + \
|
||||
CONFIGURE_MEMORY_FOR_REGIONS( \
|
||||
CONFIGURE_MAXIMUM_REGIONS + CONFIGURE_MALLOC_REGION ) + \
|
||||
CONFIGURE_MEMORY_FOR_REGIONS( CONFIGURE_MAXIMUM_REGIONS ) + \
|
||||
CONFIGURE_MEMORY_FOR_PORTS(CONFIGURE_MAXIMUM_PORTS) + \
|
||||
CONFIGURE_MEMORY_FOR_PERIODS(CONFIGURE_MAXIMUM_PERIODS) + \
|
||||
CONFIGURE_MEMORY_FOR_BARRIERS(CONFIGURE_MAXIMUM_BARRIERS) + \
|
||||
@@ -1109,7 +1106,7 @@ rtems_api_configuration_table Configuration_RTEMS_API = {
|
||||
CONFIGURE_TERMIOS_SEMAPHORES,
|
||||
CONFIGURE_MAXIMUM_MESSAGE_QUEUES,
|
||||
CONFIGURE_MAXIMUM_PARTITIONS,
|
||||
CONFIGURE_MAXIMUM_REGIONS + CONFIGURE_MALLOC_REGION,
|
||||
CONFIGURE_MAXIMUM_REGIONS,
|
||||
CONFIGURE_MAXIMUM_PORTS,
|
||||
CONFIGURE_MAXIMUM_PERIODS,
|
||||
CONFIGURE_MAXIMUM_BARRIERS,
|
||||
|
||||
@@ -23,7 +23,7 @@ include_rtems_score_HEADERS = include/rtems/score/address.h \
|
||||
include/rtems/score/corebarrier.h include/rtems/score/coremsg.h \
|
||||
include/rtems/score/coremutex.h include/rtems/score/corerwlock.h \
|
||||
include/rtems/score/coresem.h include/rtems/score/corespinlock.h \
|
||||
include/rtems/score/heap.h \
|
||||
include/rtems/score/heap.h include/rtems/score/protectedheap.h \
|
||||
include/rtems/score/interr.h include/rtems/score/isr.h \
|
||||
include/rtems/score/object.h include/rtems/score/priority.h \
|
||||
include/rtems/score/stack.h include/rtems/score/states.h \
|
||||
@@ -100,8 +100,8 @@ libscore_a_SOURCES += src/corespinlock.c src/corespinlockrelease.c \
|
||||
src/corespinlockwait.c
|
||||
|
||||
## HEAP_C_FILES
|
||||
libscore_a_SOURCES += src/heap.c src/heapallocate.c src/heapextend.c src/heapfree.c \
|
||||
src/heapsizeofuserarea.c src/heapwalk.c src/heapgetinfo.c \
|
||||
libscore_a_SOURCES += src/heap.c src/heapallocate.c src/heapextend.c \
|
||||
src/heapfree.c src/heapsizeofuserarea.c src/heapwalk.c src/heapgetinfo.c \
|
||||
src/heapgetfreeinfo.c src/heapallocatealigned.c \
|
||||
src/heapresizeblock.c
|
||||
|
||||
@@ -116,6 +116,12 @@ libscore_a_SOURCES += src/object.c src/objectallocate.c \
|
||||
src/objectshrinkinformation.c src/objectgetnoprotection.c \
|
||||
src/objectidtoname.c
|
||||
|
||||
## PROTECTED_HEAP_C_FILES
|
||||
libscore_a_SOURCES += src/pheapallocatealigned.c src/pheapallocate.c \
|
||||
src/pheapextend.c src/pheapfree.c src/pheapgetblocksize.c \
|
||||
src/pheapgetfreeinfo.c src/pheapgetinfo.c src/pheapinit.c \
|
||||
src/pheapresizeblock.c src/pheapwalk.c
|
||||
|
||||
## THREAD_C_FILES
|
||||
libscore_a_SOURCES += src/thread.c src/threadchangepriority.c \
|
||||
src/threadclearstate.c src/threadclose.c src/threadcreateidle.c \
|
||||
|
||||
215
cpukit/score/include/rtems/score/protectedheap.h
Normal file
215
cpukit/score/include/rtems/score/protectedheap.h
Normal file
@@ -0,0 +1,215 @@
|
||||
/**
|
||||
* @file rtems/score/protectedheap.h
|
||||
*
|
||||
* This include file contains the information pertaining to the
|
||||
* Protected Heap Handler.
|
||||
*
|
||||
* COPYRIGHT (c) 1989-2007.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.com/license/LICENSE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef _RTEMS_SCORE_PROTECTED_HEAP_H
|
||||
#define _RTEMS_SCORE_PROTECTED_HEAP_H
|
||||
|
||||
#include <rtems/score/heap.h>
|
||||
#include <rtems/score/apimutex.h>
|
||||
|
||||
/**
|
||||
* @defgroup ScoreProtHeap Protected Heap Handler
|
||||
*
|
||||
* This handler encapsulates functionality which provides the foundation
|
||||
* Protected Heap services.
|
||||
*
|
||||
* It is a simple wrapper for the help with the addition of the
|
||||
* allocation mutex being used for protection.
|
||||
*/
|
||||
/**@{*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This routine initializes @a the_heap record to manage the
|
||||
* contiguous heap of @a size bytes which starts at @a starting_address.
|
||||
* Blocks of memory are allocated from the heap in multiples of
|
||||
* @a page_size byte units. If @a page_size is 0 or is not multiple of
|
||||
* CPU_ALIGNMENT, it's aligned up to the nearest CPU_ALIGNMENT boundary.
|
||||
*
|
||||
* @param[in] the_heap is the heap to operate upon
|
||||
* @param[in] starting_address is the starting address of the memory for
|
||||
* the heap
|
||||
* @param[in] size is the size in bytes of the memory area for the heap
|
||||
* @param[in] page_size is the size in bytes of the allocation unit
|
||||
*
|
||||
* @return This method returns the maximum memory available. If
|
||||
* unsuccessful, 0 will be returned.
|
||||
*/
|
||||
static inline uint32_t _Protected_heap_Initialize(
|
||||
Heap_Control *the_heap,
|
||||
void *starting_address,
|
||||
size_t size,
|
||||
uint32_t page_size
|
||||
)
|
||||
{
|
||||
return _Heap_Initialize( the_heap, starting_address, size, page_size );
|
||||
}
|
||||
|
||||
/**
|
||||
* This routine grows @a the_heap memory area using the size bytes which
|
||||
* begin at @a starting_address.
|
||||
*
|
||||
* @param[in] the_heap is the heap to operate upon
|
||||
* @param[in] starting_address is the starting address of the memory
|
||||
* to add to the heap
|
||||
* @param[in] size is the size in bytes of the memory area to add
|
||||
* @return a status indicating success or the reason for failure
|
||||
*/
|
||||
boolean _Protected_heap_Extend(
|
||||
Heap_Control *the_heap,
|
||||
void *starting_address,
|
||||
size_t size
|
||||
);
|
||||
|
||||
/**
|
||||
* This function attempts to allocate a block of @a size bytes from
|
||||
* @a the_heap. If insufficient memory is free in @a the_heap to allocate
|
||||
* a block of the requested size, then NULL is returned.
|
||||
*
|
||||
* @param[in] the_heap is the heap to operate upon
|
||||
* @param[in] size is the amount of memory to allocate in bytes
|
||||
* @return NULL if unsuccessful and a pointer to the block if successful
|
||||
*/
|
||||
void *_Protected_heap_Allocate(
|
||||
Heap_Control *the_heap,
|
||||
size_t size
|
||||
);
|
||||
|
||||
/**
|
||||
* This function attempts to allocate a memory block of @a size bytes from
|
||||
* @a the_heap so that the start of the user memory is aligned on the
|
||||
* @a alignment boundary. If @a alignment is 0, it is set to CPU_ALIGNMENT.
|
||||
* Any other value of @a alignment is taken "as is", i.e., even odd
|
||||
* alignments are possible.
|
||||
* Returns pointer to the start of the memory block if success, NULL if
|
||||
* failure.
|
||||
*
|
||||
* @param[in] the_heap is the heap to operate upon
|
||||
* @param[in] size is the amount of memory to allocate in bytes
|
||||
* @param[in] alignment the required alignment
|
||||
* @return NULL if unsuccessful and a pointer to the block if successful
|
||||
*/
|
||||
void *_Protected_heap_Allocate_aligned(
|
||||
Heap_Control *the_heap,
|
||||
size_t size,
|
||||
uint32_t alignment
|
||||
);
|
||||
|
||||
/**
|
||||
* This function sets @a *size to the size of the block of user memory
|
||||
* which begins at @a starting_address. The size returned in @a *size could
|
||||
* be greater than the size requested for allocation.
|
||||
* Returns TRUE if the @a starting_address is in the heap, and FALSE
|
||||
* otherwise.
|
||||
*
|
||||
* @param[in] the_heap is the heap to operate upon
|
||||
* @param[in] starting_address is the starting address of the user block
|
||||
* to obtain the size of
|
||||
* @param[in] size points to a user area to return the size in
|
||||
* @return TRUE if successfully able to determine the size, FALSE otherwise
|
||||
* @return *size filled in with the size of the user area for this block
|
||||
*/
|
||||
boolean _Protected_heap_Get_block_size(
|
||||
Heap_Control *the_heap,
|
||||
void *starting_address,
|
||||
size_t *size
|
||||
);
|
||||
|
||||
/**
|
||||
* This function tries to resize in place the block that is pointed to by the
|
||||
* @a starting_address to the new @a size.
|
||||
*
|
||||
* @param[in] the_heap is the heap to operate upon
|
||||
* @param[in] starting_address is the starting address of the user block
|
||||
* to be resized
|
||||
* @param[in] size is the new size
|
||||
* @param[in] old_mem_size points to a user area to return the size of the
|
||||
* @return TRUE if successfully able to resize the block,
|
||||
* FALSE if the block can't be resized in place,
|
||||
*/
|
||||
boolean _Protected_heap_Resize_block(
|
||||
Heap_Control *the_heap,
|
||||
void *starting_address,
|
||||
size_t size
|
||||
);
|
||||
|
||||
/**
|
||||
* This routine returns the block of memory which begins
|
||||
* at @a starting_address to @a the_heap. Any coalescing which is
|
||||
* possible with the freeing of this routine is performed.
|
||||
*
|
||||
* @param[in] the_heap is the heap to operate upon
|
||||
* @param[in] start_address is the starting address of the user block
|
||||
* to free
|
||||
* @return TRUE if successfully freed, FALSE otherwise
|
||||
*/
|
||||
boolean _Protected_heap_Free(
|
||||
Heap_Control *the_heap,
|
||||
void *start_address
|
||||
);
|
||||
|
||||
/**
|
||||
* This routine walks the heap to verify its integrity.
|
||||
*
|
||||
* @param[in] the_heap is the heap to operate upon
|
||||
* @param[in] source is a user specified integer which may be used to
|
||||
* indicate where in the application this was invoked from
|
||||
* @param[in] do_dump is set to TRUE if errors should be printed
|
||||
* @return TRUE if the test passed fine, FALSE otherwise.
|
||||
*/
|
||||
boolean _Protected_heap_Walk(
|
||||
Heap_Control *the_heap,
|
||||
int source,
|
||||
boolean do_dump
|
||||
);
|
||||
|
||||
/**
|
||||
* This routine walks the heap and tots up the free and allocated
|
||||
* sizes.
|
||||
*
|
||||
* @param[in] the_heap pointer to heap header
|
||||
* @param[in] the_info pointer to a status information area
|
||||
*/
|
||||
void _Protected_heap_Get_information(
|
||||
Heap_Control *the_heap,
|
||||
Heap_Information_block *the_info
|
||||
);
|
||||
|
||||
/**
|
||||
* This heap routine returns information about the free blocks
|
||||
* in the specified heap.
|
||||
*
|
||||
* @param[in] the_heap pointer to heap header.
|
||||
* @param[in] info pointer to the free block information.
|
||||
*
|
||||
* @return free block information filled in.
|
||||
*/
|
||||
void _Protected_heap_Get_free_information(
|
||||
Heap_Control *the_heap,
|
||||
Heap_Information *info
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/**@}*/
|
||||
|
||||
#endif
|
||||
/* end of include file */
|
||||
@@ -91,6 +91,10 @@ $(PROJECT_INCLUDE)/rtems/score/heap.h: include/rtems/score/heap.h $(PROJECT_INCL
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/heap.h
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/heap.h
|
||||
|
||||
$(PROJECT_INCLUDE)/rtems/score/protectedheap.h: include/rtems/score/protectedheap.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/protectedheap.h
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/protectedheap.h
|
||||
|
||||
$(PROJECT_INCLUDE)/rtems/score/interr.h: include/rtems/score/interr.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/interr.h
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/interr.h
|
||||
|
||||
31
cpukit/score/src/pheapallocate.c
Normal file
31
cpukit/score/src/pheapallocate.c
Normal file
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* COPYRIGHT (c) 1989-2007.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.com/license/LICENSE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/score/protectedheap.h>
|
||||
|
||||
void *_Protected_heap_Allocate(
|
||||
Heap_Control *the_heap,
|
||||
size_t size
|
||||
)
|
||||
{
|
||||
void *p;
|
||||
|
||||
_RTEMS_Lock_allocator();
|
||||
p = _Heap_Allocate( the_heap, size );
|
||||
_RTEMS_Unlock_allocator();
|
||||
return p;
|
||||
}
|
||||
|
||||
31
cpukit/score/src/pheapallocatealigned.c
Normal file
31
cpukit/score/src/pheapallocatealigned.c
Normal file
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* COPYRIGHT (c) 1989-2007.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.com/license/LICENSE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/score/protectedheap.h>
|
||||
|
||||
boolean _Protected_heap_Get_block_size(
|
||||
Heap_Control *the_heap,
|
||||
void *starting_address,
|
||||
size_t *size
|
||||
)
|
||||
{
|
||||
boolean status;
|
||||
|
||||
_RTEMS_Lock_allocator();
|
||||
status = _Heap_Size_of_user_area( the_heap, starting_address, size );
|
||||
_RTEMS_Unlock_allocator();
|
||||
return status;
|
||||
}
|
||||
33
cpukit/score/src/pheapextend.c
Normal file
33
cpukit/score/src/pheapextend.c
Normal file
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* COPYRIGHT (c) 1989-2007.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.com/license/LICENSE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/score/protectedheap.h>
|
||||
|
||||
boolean _Protected_heap_Extend(
|
||||
Heap_Control *the_heap,
|
||||
void *starting_address,
|
||||
size_t size
|
||||
)
|
||||
{
|
||||
Heap_Extend_status status;
|
||||
uint32_t amount_extended;
|
||||
|
||||
_RTEMS_Lock_allocator();
|
||||
status = _Heap_Extend(the_heap, starting_address, size, &amount_extended);
|
||||
_RTEMS_Unlock_allocator();
|
||||
return (status == HEAP_EXTEND_SUCCESSFUL);
|
||||
}
|
||||
|
||||
30
cpukit/score/src/pheapfree.c
Normal file
30
cpukit/score/src/pheapfree.c
Normal file
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* COPYRIGHT (c) 1989-2007.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.com/license/LICENSE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/score/protectedheap.h>
|
||||
|
||||
boolean _Protected_heap_Free(
|
||||
Heap_Control *the_heap,
|
||||
void *start_address
|
||||
)
|
||||
{
|
||||
boolean status;
|
||||
|
||||
_RTEMS_Lock_allocator();
|
||||
status = _Heap_Free( the_heap, start_address );
|
||||
_RTEMS_Unlock_allocator();
|
||||
return status;
|
||||
}
|
||||
32
cpukit/score/src/pheapgetblocksize.c
Normal file
32
cpukit/score/src/pheapgetblocksize.c
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* COPYRIGHT (c) 1989-2007.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.com/license/LICENSE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/score/protectedheap.h>
|
||||
|
||||
void *_Protected_heap_Allocate_aligned(
|
||||
Heap_Control *the_heap,
|
||||
size_t size,
|
||||
uint32_t alignment
|
||||
)
|
||||
{
|
||||
void *p;
|
||||
|
||||
_RTEMS_Lock_allocator();
|
||||
p = _Heap_Allocate_aligned( the_heap, size, alignment );
|
||||
_RTEMS_Unlock_allocator();
|
||||
return p;
|
||||
}
|
||||
|
||||
28
cpukit/score/src/pheapgetfreeinfo.c
Normal file
28
cpukit/score/src/pheapgetfreeinfo.c
Normal file
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* COPYRIGHT (c) 1989-2007.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.com/license/LICENSE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/score/protectedheap.h>
|
||||
|
||||
void _Protected_heap_Get_free_information(
|
||||
Heap_Control *the_heap,
|
||||
Heap_Information *info
|
||||
)
|
||||
{
|
||||
_RTEMS_Lock_allocator();
|
||||
_Heap_Get_free_information( the_heap, info );
|
||||
_RTEMS_Unlock_allocator();
|
||||
}
|
||||
|
||||
29
cpukit/score/src/pheapgetinfo.c
Normal file
29
cpukit/score/src/pheapgetinfo.c
Normal file
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* COPYRIGHT (c) 1989-2007.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.com/license/LICENSE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/score/protectedheap.h>
|
||||
|
||||
void _Protected_heap_Get_information(
|
||||
Heap_Control *the_heap,
|
||||
Heap_Information_block *the_info
|
||||
)
|
||||
{
|
||||
Heap_Get_information_status status;
|
||||
|
||||
_RTEMS_Lock_allocator();
|
||||
status = _Heap_Get_information( the_heap, the_info );
|
||||
_RTEMS_Unlock_allocator();
|
||||
}
|
||||
19
cpukit/score/src/pheapinit.c
Normal file
19
cpukit/score/src/pheapinit.c
Normal file
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* COPYRIGHT (c) 1989-2007.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.com/license/LICENSE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/score/protectedheap.h>
|
||||
|
||||
|
||||
35
cpukit/score/src/pheapresizeblock.c
Normal file
35
cpukit/score/src/pheapresizeblock.c
Normal file
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* COPYRIGHT (c) 1989-2007.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.com/license/LICENSE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/score/protectedheap.h>
|
||||
|
||||
boolean _Protected_heap_Resize_block(
|
||||
Heap_Control *the_heap,
|
||||
void *starting_address,
|
||||
size_t size
|
||||
)
|
||||
{
|
||||
Heap_Resize_status status;
|
||||
uint32_t old_mem_size;
|
||||
uint32_t avail_mem_size;
|
||||
|
||||
_RTEMS_Lock_allocator();
|
||||
status = _Heap_Resize_block(
|
||||
the_heap, starting_address, size, &old_mem_size, &avail_mem_size );
|
||||
_RTEMS_Unlock_allocator();
|
||||
return (status == HEAP_RESIZE_SUCCESSFUL);
|
||||
}
|
||||
|
||||
31
cpukit/score/src/pheapwalk.c
Normal file
31
cpukit/score/src/pheapwalk.c
Normal file
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* COPYRIGHT (c) 1989-2007.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.com/license/LICENSE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/score/protectedheap.h>
|
||||
|
||||
boolean _Protected_heap_Walk(
|
||||
Heap_Control *the_heap,
|
||||
int source,
|
||||
boolean do_dump
|
||||
)
|
||||
{
|
||||
boolean status;
|
||||
|
||||
_RTEMS_Lock_allocator();
|
||||
status = _Heap_Walk( the_heap, source, do_dump );
|
||||
_RTEMS_Unlock_allocator();
|
||||
return status;
|
||||
}
|
||||
Reference in New Issue
Block a user