forked from Imagelibrary/rtems
2009-10-09 Sebastian Huber <sebastian.huber@embedded-brains.de>
* bootcard: Update for heap API changes.
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
|
2009-10-09 Sebastian Huber <sebastian.huber@embedded-brains.de>
|
||||||
|
|
||||||
|
* bootcard: Update for heap API changes.
|
||||||
|
|
||||||
2009-09-08 Sebastian Huber <sebastian.huber@embedded-brains.de>
|
2009-09-08 Sebastian Huber <sebastian.huber@embedded-brains.de>
|
||||||
|
|
||||||
* include/irq-config.h, include/irq-generic.h, include/irq-info.h,
|
* include/irq-config.h, include/irq-generic.h, include/irq-info.h,
|
||||||
|
|||||||
@@ -1,20 +1,26 @@
|
|||||||
|
/**
|
||||||
|
* @file
|
||||||
|
*
|
||||||
|
* @ingroup bsp_bootcard
|
||||||
|
*
|
||||||
|
* @brief Standard system startup.
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is the C entry point for ALL RTEMS BSPs. It is invoked
|
* This is the C entry point for ALL RTEMS BSPs. It is invoked
|
||||||
* from the assembly language initialization file usually called
|
* from the assembly language initialization file usually called
|
||||||
* start.S. It provides the framework for the BSP initialization
|
* start.S. It provides the framework for the BSP initialization
|
||||||
* sequence. The basic flow of initialization is:
|
* sequence. The basic flow of initialization is:
|
||||||
*
|
*
|
||||||
* + start.S: basic CPU setup (stack, zero BSS)
|
* + start.S: basic CPU setup (stack, zero BSS)
|
||||||
* + boot_card
|
* + boot_card
|
||||||
* + if defined(BSP_BOOTCARD_HANDLES_RAM_ALLOCATION)
|
|
||||||
* - obtain information on BSP memory and allocate RTEMS Workspace
|
|
||||||
* + bspstart.c: bsp_start - more advanced initialization
|
* + bspstart.c: bsp_start - more advanced initialization
|
||||||
|
* + obtain information on BSP memory and allocate RTEMS Workspace
|
||||||
* + rtems_initialize_data_structures
|
* + rtems_initialize_data_structures
|
||||||
* + if defined(BSP_BOOTCARD_HANDLES_RAM_ALLOCATION)
|
* + allocate memory to C Program Heap
|
||||||
* - Allocate memory to C Program Heap
|
* + initialize C Library and C Program Heap
|
||||||
* - initialize C Library and C Program Heap
|
|
||||||
* + bsp_pretasking_hook
|
* + bsp_pretasking_hook
|
||||||
* + if defined(RTEMS_DEBUG)
|
* + if defined( RTEMS_DEBUG )
|
||||||
* - rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
|
* - rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
|
||||||
* + rtems_initialize_before_drivers
|
* + rtems_initialize_before_drivers
|
||||||
* + bsp_predriver_hook
|
* + bsp_predriver_hook
|
||||||
@@ -64,50 +70,27 @@ extern bool rtems_unified_work_area;
|
|||||||
* when the BSP lets the framework handle RAM allocation between
|
* when the BSP lets the framework handle RAM allocation between
|
||||||
* the RTEMS Workspace and C Program Heap.
|
* the RTEMS Workspace and C Program Heap.
|
||||||
*/
|
*/
|
||||||
static rtems_status_code bootcard_bsp_libc_helper(
|
static void bootcard_bsp_libc_helper(
|
||||||
void *work_area_start,
|
void *work_area_start,
|
||||||
intptr_t work_area_size,
|
uintptr_t work_area_size,
|
||||||
void *heap_start,
|
void *heap_start,
|
||||||
intptr_t heap_size
|
uintptr_t heap_size
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
intptr_t heap_size_default = 0;
|
if ( !rtems_unified_work_area &&
|
||||||
|
|
||||||
if ( !rtems_unified_work_area &&
|
|
||||||
heap_start == BSP_BOOTCARD_HEAP_USES_WORK_AREA) {
|
heap_start == BSP_BOOTCARD_HEAP_USES_WORK_AREA) {
|
||||||
/* Place the heap immediately following the work area */
|
uintptr_t work_space_size = rtems_configuration_get_work_space_size();
|
||||||
heap_start = work_area_start + rtems_configuration_get_work_space_size();
|
|
||||||
|
|
||||||
/* Ensure proper alignement */
|
heap_start = (char *) work_area_start + work_space_size;
|
||||||
if ((uintptr_t) heap_start & (CPU_ALIGNMENT - 1)) {
|
|
||||||
heap_start = (void *) (((uintptr_t) heap_start + CPU_ALIGNMENT)
|
|
||||||
& ~(CPU_ALIGNMENT - 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* For the default heap size use the free space from the end of the
|
|
||||||
* work space up to the end of the work area as heap.
|
|
||||||
*/
|
|
||||||
heap_size_default = work_area_size -
|
|
||||||
rtems_configuration_get_work_space_size();
|
|
||||||
|
|
||||||
/* Keep it as a multiple of 16 bytes */
|
|
||||||
heap_size_default &= ~((intptr_t) 0xf);
|
|
||||||
|
|
||||||
/* Use default heap size if requested */
|
|
||||||
if (heap_size == BSP_BOOTCARD_HEAP_SIZE_DEFAULT) {
|
if (heap_size == BSP_BOOTCARD_HEAP_SIZE_DEFAULT) {
|
||||||
|
uintptr_t heap_size_default = work_area_size - work_space_size;
|
||||||
|
|
||||||
heap_size = 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, heap_size, 0);
|
bsp_libc_init(heap_start, heap_size, 0);
|
||||||
|
|
||||||
return RTEMS_SUCCESSFUL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -121,7 +104,6 @@ int boot_card(
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
rtems_interrupt_level bsp_isr_level;
|
rtems_interrupt_level bsp_isr_level;
|
||||||
rtems_status_code sc = RTEMS_SUCCESSFUL;
|
|
||||||
void *work_area_start = NULL;
|
void *work_area_start = NULL;
|
||||||
uintptr_t work_area_size = 0;
|
uintptr_t work_area_size = 0;
|
||||||
void *heap_start = NULL;
|
void *heap_start = NULL;
|
||||||
@@ -154,11 +136,11 @@ int boot_card(
|
|||||||
bsp_get_work_area(&work_area_start, &work_area_size,
|
bsp_get_work_area(&work_area_start, &work_area_size,
|
||||||
&heap_start, &heap_size);
|
&heap_start, &heap_size);
|
||||||
|
|
||||||
if ( (uint32_t) work_area_size <= (uint32_t) Configuration.work_space_size ) {
|
if ( work_area_size <= Configuration.work_space_size ) {
|
||||||
printk(
|
printk(
|
||||||
"bootcard: Work space too big for work area! (0x%08lx > 0x%08lx)\n",
|
"bootcard: work space too big for work area: %p > %p\n",
|
||||||
(uint32_t)Configuration.work_space_size,
|
(void *) Configuration.work_space_size,
|
||||||
(uint32_t)work_area_size
|
(void *) work_area_size
|
||||||
);
|
);
|
||||||
bsp_cleanup();
|
bsp_cleanup();
|
||||||
return -1;
|
return -1;
|
||||||
@@ -168,7 +150,7 @@ int boot_card(
|
|||||||
Configuration.work_space_start = work_area_start;
|
Configuration.work_space_start = work_area_start;
|
||||||
Configuration.work_space_size = work_area_size;
|
Configuration.work_space_size = work_area_size;
|
||||||
} else {
|
} else {
|
||||||
Configuration.work_space_start = (char *) work_area_start;
|
Configuration.work_space_start = work_area_start;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (BSP_DIRTY_MEMORY == 1)
|
#if (BSP_DIRTY_MEMORY == 1)
|
||||||
@@ -184,17 +166,12 @@ int boot_card(
|
|||||||
* Initialize the C library for those BSPs using the shared
|
* Initialize the C library for those BSPs using the shared
|
||||||
* framework.
|
* framework.
|
||||||
*/
|
*/
|
||||||
sc = bootcard_bsp_libc_helper(
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* All BSP to do any required initialization now that RTEMS
|
* All BSP to do any required initialization now that RTEMS
|
||||||
@@ -207,7 +184,7 @@ int boot_card(
|
|||||||
bsp_pretasking_hook();
|
bsp_pretasking_hook();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If debug is enabled, then enable all dynamic RTEMS debug
|
* If debug is enabled, then enable all dynamic RTEMS debug
|
||||||
* capabilities.
|
* capabilities.
|
||||||
*
|
*
|
||||||
* NOTE: Most debug features are conditionally compiled in
|
* NOTE: Most debug features are conditionally compiled in
|
||||||
@@ -226,7 +203,7 @@ int boot_card(
|
|||||||
/*
|
/*
|
||||||
* Execute BSP specific pre-driver hook. Drivers haven't gotten
|
* Execute BSP specific pre-driver hook. Drivers haven't gotten
|
||||||
* to initialize yet so this is a good chance to initialize
|
* to initialize yet so this is a good chance to initialize
|
||||||
* buses, spurious interrupt handlers, etc..
|
* buses, spurious interrupt handlers, etc..
|
||||||
*
|
*
|
||||||
* NOTE: Many BSPs do not require this handler and use the
|
* NOTE: Many BSPs do not require this handler and use the
|
||||||
* shared stub.
|
* shared stub.
|
||||||
|
|||||||
Reference in New Issue
Block a user