forked from Imagelibrary/rtems
src/irq-legacy.c: Free allocated memory in hander remove
bootcard.c: Check if the heap fits into the work area
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
|
2008-07-28 Sebastian Huber <sebastian.huber@embedded-brains.de>
|
||||||
|
|
||||||
|
* src/irq-legacy.c: Free allocated memory in hander remove.
|
||||||
|
|
||||||
|
* bootcard.c: Check if the heap fits into the work area.
|
||||||
|
|
||||||
2008-07-24 Sebastian Huber <sebastian.huber@embedded-brains.de>
|
2008-07-24 Sebastian Huber <sebastian.huber@embedded-brains.de>
|
||||||
|
|
||||||
* include/bootcard.h: New file.
|
* include/bootcard.h: New file.
|
||||||
|
|||||||
@@ -58,36 +58,49 @@ char *rtems_progname;
|
|||||||
* the RTEMS Workspace and C Program Heap.
|
* the RTEMS Workspace and C Program Heap.
|
||||||
*/
|
*/
|
||||||
#if defined(BSP_BOOTCARD_HANDLES_RAM_ALLOCATION)
|
#if defined(BSP_BOOTCARD_HANDLES_RAM_ALLOCATION)
|
||||||
static void bootcard_bsp_libc_helper(
|
static rtems_status_code bootcard_bsp_libc_helper(
|
||||||
void *work_area_start,
|
void *work_area_start,
|
||||||
size_t work_area_size,
|
size_t work_area_size,
|
||||||
void *heap_start,
|
void *heap_start,
|
||||||
size_t heap_size
|
size_t heap_size
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
size_t heap_size_default = 0;
|
||||||
|
|
||||||
if (heap_start == BSP_BOOTCARD_HEAP_USES_WORK_AREA) {
|
if (heap_start == BSP_BOOTCARD_HEAP_USES_WORK_AREA) {
|
||||||
/* Use the work area start as heap start */
|
/* Use the work area start as heap start */
|
||||||
heap_start = work_area_start;
|
heap_start = work_area_start;
|
||||||
|
|
||||||
/* Ensure proper alignement */
|
/* Ensure proper alignement */
|
||||||
if ((uintptr_t) heap_start & (CPU_ALIGNMENT - 1)) {
|
if ((uintptr_t) heap_start & (CPU_ALIGNMENT - 1)) {
|
||||||
heap_start = (void *) (((uintptr_t) heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT - 1));
|
heap_start = (void *) (((uintptr_t) heap_start + CPU_ALIGNMENT)
|
||||||
|
& ~(CPU_ALIGNMENT - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Use the free space from the start of the work area up to the work
|
* For the default heap size use the free space from the start of the
|
||||||
* space start as heap area.
|
* work area up to the work space start as heap area.
|
||||||
*/
|
*/
|
||||||
if (heap_size == BSP_BOOTCARD_HEAP_SIZE_DEFAULT) {
|
heap_size_default = (char *) Configuration.work_space_start
|
||||||
heap_size = (char *) Configuration.work_space_start
|
|
||||||
- (char *) work_area_start;
|
- (char *) work_area_start;
|
||||||
|
|
||||||
/* Keep it as a multiple of 16 bytes */
|
/* Keep it as a multiple of 16 bytes */
|
||||||
heap_size &= 0xfffffff0;
|
heap_size_default &= ~((size_t) 0xf);
|
||||||
|
|
||||||
|
/* Use default heap size if requested */
|
||||||
|
if (heap_size == BSP_BOOTCARD_HEAP_SIZE_DEFAULT) {
|
||||||
|
heap_size = heap_size_default;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check heap size */
|
||||||
|
if (heap_size > heap_size_default) {
|
||||||
|
return RTEMS_INVALID_SIZE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bsp_libc_init( heap_start, (uint32_t) heap_size, 0);
|
bsp_libc_init( heap_start, (uint32_t) heap_size, 0);
|
||||||
|
|
||||||
|
return RTEMS_SUCCESSFUL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -109,6 +122,7 @@ int boot_card(
|
|||||||
char **envp_p = &envp_pointer;
|
char **envp_p = &envp_pointer;
|
||||||
rtems_interrupt_level bsp_isr_level;
|
rtems_interrupt_level bsp_isr_level;
|
||||||
#if defined(BSP_BOOTCARD_HANDLES_RAM_ALLOCATION)
|
#if defined(BSP_BOOTCARD_HANDLES_RAM_ALLOCATION)
|
||||||
|
rtems_status_code sc = RTEMS_SUCCESSFUL;
|
||||||
void *work_area_start = NULL;
|
void *work_area_start = NULL;
|
||||||
size_t work_area_size = 0;
|
size_t work_area_size = 0;
|
||||||
void *heap_start = NULL;
|
void *heap_start = NULL;
|
||||||
@@ -164,7 +178,7 @@ int boot_card(
|
|||||||
- rtems_configuration_get_work_space_size();
|
- rtems_configuration_get_work_space_size();
|
||||||
|
|
||||||
if ((uintptr_t) work_space_start <= (uintptr_t) work_area_start) {
|
if ((uintptr_t) work_space_start <= (uintptr_t) work_area_start) {
|
||||||
printk( "bootcard: Not enough RAM!!!\n" );
|
printk( "bootcard: Work space to big for work area!\n");
|
||||||
bsp_cleanup();
|
bsp_cleanup();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -175,7 +189,6 @@ int boot_card(
|
|||||||
memset( work_area_start, 0xCF, work_area_size);
|
memset( work_area_start, 0xCF, work_area_size);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -193,12 +206,17 @@ int boot_card(
|
|||||||
* framework.
|
* framework.
|
||||||
*/
|
*/
|
||||||
#if defined(BSP_BOOTCARD_HANDLES_RAM_ALLOCATION)
|
#if defined(BSP_BOOTCARD_HANDLES_RAM_ALLOCATION)
|
||||||
bootcard_bsp_libc_helper(
|
sc = bootcard_bsp_libc_helper(
|
||||||
work_area_start,
|
work_area_start,
|
||||||
work_area_size,
|
work_area_size,
|
||||||
heap_start,
|
heap_start,
|
||||||
heap_size
|
heap_size
|
||||||
);
|
);
|
||||||
|
if (sc != RTEMS_SUCCESSFUL) {
|
||||||
|
printk( "bootcard: Cannot initialize C library!\n");
|
||||||
|
bsp_cleanup();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -169,6 +169,9 @@ int BSP_remove_rtems_irq_handler( const rtems_irq_connect_data *cd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
sc = rtems_interrupt_handler_remove( cd->name, bsp_interrupt_legacy_dispatch, e.legacy_handler_arg);
|
sc = rtems_interrupt_handler_remove( cd->name, bsp_interrupt_legacy_dispatch, e.legacy_handler_arg);
|
||||||
|
|
||||||
|
free( e.legacy_handler_arg);
|
||||||
|
|
||||||
if (sc != RTEMS_SUCCESSFUL) {
|
if (sc != RTEMS_SUCCESSFUL) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user