diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2008-08-21 16:16:47 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2008-08-21 16:16:47 +0000 |
commit | d9be802487b130aa16eb5a438f172471c1f734a0 (patch) | |
tree | 366a3144d60bb4831b9e0657f93cdec7ba816e6a /c | |
parent | 2008-08-21 Sebastian Huber <sebastian.huber@embedded-brains.de> (diff) | |
download | rtems-d9be802487b130aa16eb5a438f172471c1f734a0.tar.bz2 |
2008-08-21 Joel Sherrill <joel.sherrill@oarcorp.com>
* Makefile.am: Added bspclean.c and use shared bsppretaskinghook.c.
* console/console.c: Added poll for char helper.
* include/bsp.h: Add macro definitions for optional reset behavior.
* startup/bspstart.c: Split out bsp_cleanup(). Clean up.
* startup/bspclean.c: New file. Not can press any key on normal
shutdown to reset board when on MPC8313erdb.
Diffstat (limited to 'c')
-rw-r--r-- | c/src/lib/libbsp/powerpc/gen83xx/ChangeLog | 9 | ||||
-rw-r--r-- | c/src/lib/libbsp/powerpc/gen83xx/Makefile.am | 2 | ||||
-rw-r--r-- | c/src/lib/libbsp/powerpc/gen83xx/console/console.c | 4 | ||||
-rw-r--r-- | c/src/lib/libbsp/powerpc/gen83xx/include/bsp.h | 44 | ||||
-rw-r--r-- | c/src/lib/libbsp/powerpc/gen83xx/startup/bspclean.c | 78 | ||||
-rw-r--r-- | c/src/lib/libbsp/powerpc/gen83xx/startup/bspstart.c | 201 |
6 files changed, 205 insertions, 133 deletions
diff --git a/c/src/lib/libbsp/powerpc/gen83xx/ChangeLog b/c/src/lib/libbsp/powerpc/gen83xx/ChangeLog index 4aed65fab1..c7e67ee8f9 100644 --- a/c/src/lib/libbsp/powerpc/gen83xx/ChangeLog +++ b/c/src/lib/libbsp/powerpc/gen83xx/ChangeLog @@ -1,3 +1,12 @@ +2008-08-21 Joel Sherrill <joel.sherrill@oarcorp.com> + + * Makefile.am: Added bspclean.c and use shared bsppretaskinghook.c. + * console/console.c: Added poll for char helper. + * include/bsp.h: Add macro definitions for optional reset behavior. + * startup/bspstart.c: Split out bsp_cleanup(). Clean up. + * startup/bspclean.c: New file. Not can press any key on normal + shutdown to reset board when on MPC8313erdb. + 2008-08-21 Sebastian Huber <sebastian.huber@embedded-brains.de> * startup/cpuinit.h: Uses now powerpc-utility.h. Changed invalid usage diff --git a/c/src/lib/libbsp/powerpc/gen83xx/Makefile.am b/c/src/lib/libbsp/powerpc/gen83xx/Makefile.am index e208c50972..a43209729f 100644 --- a/c/src/lib/libbsp/powerpc/gen83xx/Makefile.am +++ b/c/src/lib/libbsp/powerpc/gen83xx/Makefile.am @@ -47,11 +47,13 @@ startup_SOURCES = ../../shared/bsplibc.c \ ../../shared/bsppost.c \ ../../shared/bootcard.c \ ../../shared/bsppredriverhook.c \ + ../../shared/bsppretaskinghook.c \ ../../shared/sbrk.c \ ../../shared/gnatinstallhandler.c \ ../shared/src/tictac.c \ startup/cpuinit.c \ startup/bspstart.c \ + startup/bspclean.c \ startup/uboot_support.c \ ../shared/uboot_getenv.c diff --git a/c/src/lib/libbsp/powerpc/gen83xx/console/console.c b/c/src/lib/libbsp/powerpc/gen83xx/console/console.c index 7cf92c4eb8..f3cdc9004b 100644 --- a/c/src/lib/libbsp/powerpc/gen83xx/console/console.c +++ b/c/src/lib/libbsp/powerpc/gen83xx/console/console.c @@ -273,3 +273,7 @@ void debug_putc_onlcr(const char c) BSP_output_char_function_type BSP_output_char = debug_putc_onlcr; /* const char arg to be compatible with BSP_output_char decl. */ +int bsp_uart_pollRead(int minor) +{ + return Console_Port_Tbl [0].pDeviceFns->deviceRead(0); +} diff --git a/c/src/lib/libbsp/powerpc/gen83xx/include/bsp.h b/c/src/lib/libbsp/powerpc/gen83xx/include/bsp.h index c5408fe839..b9b8216e98 100644 --- a/c/src/lib/libbsp/powerpc/gen83xx/include/bsp.h +++ b/c/src/lib/libbsp/powerpc/gen83xx/include/bsp.h @@ -32,6 +32,10 @@ #define CONFIG_MPC83XX #define CONFIG_HAS_ETH1 +/* We want to prompt for a reset and then reset the board */ +#define BSP_PRESS_KEY_FOR_RESET 1 +#define BSP_RESET_BOARD_AT_EXIT 1 + #endif /* MPC8313ERDB */ #include <libcpu/powerpc-utility.h> @@ -42,33 +46,33 @@ * Some symbols defined in the linker command file. */ -LINKER_SYMBOL( bsp_ram_start); -LINKER_SYMBOL( bsp_ram_end); -LINKER_SYMBOL( bsp_ram_size); +LINKER_SYMBOL(bsp_ram_start); +LINKER_SYMBOL(bsp_ram_end); +LINKER_SYMBOL(bsp_ram_size); -LINKER_SYMBOL( bsp_rom_start); -LINKER_SYMBOL( bsp_rom_end); -LINKER_SYMBOL( bsp_rom_size); +LINKER_SYMBOL(bsp_rom_start); +LINKER_SYMBOL(bsp_rom_end); +LINKER_SYMBOL(bsp_rom_size); -LINKER_SYMBOL( bsp_section_text_start); -LINKER_SYMBOL( bsp_section_text_end); -LINKER_SYMBOL( bsp_section_text_size); +LINKER_SYMBOL(bsp_section_text_start); +LINKER_SYMBOL(bsp_section_text_end); +LINKER_SYMBOL(bsp_section_text_size); -LINKER_SYMBOL( bsp_section_data_start); -LINKER_SYMBOL( bsp_section_data_end); -LINKER_SYMBOL( bsp_section_data_size); +LINKER_SYMBOL(bsp_section_data_start); +LINKER_SYMBOL(bsp_section_data_end); +LINKER_SYMBOL(bsp_section_data_size); -LINKER_SYMBOL( bsp_section_bss_start); -LINKER_SYMBOL( bsp_section_bss_end); -LINKER_SYMBOL( bsp_section_bss_size); +LINKER_SYMBOL(bsp_section_bss_start); +LINKER_SYMBOL(bsp_section_bss_end); +LINKER_SYMBOL(bsp_section_bss_size); -LINKER_SYMBOL( bsp_interrupt_stack_start); -LINKER_SYMBOL( bsp_interrupt_stack_end); -LINKER_SYMBOL( bsp_interrupt_stack_size); +LINKER_SYMBOL(bsp_interrupt_stack_start); +LINKER_SYMBOL(bsp_interrupt_stack_end); +LINKER_SYMBOL(bsp_interrupt_stack_size); -LINKER_SYMBOL( bsp_work_area_start); +LINKER_SYMBOL(bsp_work_area_start); -LINKER_SYMBOL( IMMRBAR); +LINKER_SYMBOL(IMMRBAR); #ifndef ASM diff --git a/c/src/lib/libbsp/powerpc/gen83xx/startup/bspclean.c b/c/src/lib/libbsp/powerpc/gen83xx/startup/bspclean.c new file mode 100644 index 0000000000..c5326cd28d --- /dev/null +++ b/c/src/lib/libbsp/powerpc/gen83xx/startup/bspclean.c @@ -0,0 +1,78 @@ +/** + * @file + * + * @ingroup mpc83xx + * + * @brief Source for BSP startup code. + */ + +/* + * Copyright (c) 2008 + * Embedded Brains GmbH + * Obere Lagerstr. 30 + * D-82178 Puchheim + * Germany + * rtems@embedded-brains.de + * + * 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$ + */ + +#include <string.h> + +#include <rtems.h> +#include <rtems/bspIo.h> + +#include <bsp.h> +#include <bsp/bootcard.h> + +extern int bsp_uart_pollRead(int minor); + +void bsp_reset(void) +{ + #ifdef MPC8313ERDB + _ISR_Set_level( 0 ); + + /* Set Reset Protection Register (RPR) to "RSTE" */ + mpc83xx.res.rpr = 0x52535445; + + /* + * Wait for Control Register Enabled in the + * Reset Control Enable Register (RCER). + */ + while (mpc83xx.res.rcer != 0x00000001) { + /* Wait */ + } + + /* Set Software Hard Reset in the Reset Control Register (RCR) */ + mpc83xx.res.rcr = 0x00000002; + #else /* MPC8313ERDB */ + + /* Do nothing */ + + #endif /* MPC8313ERDB */ +} + +void bsp_cleanup(void) +{ + #if defined(BSP_PRESS_KEY_FOR_RESET) + printk( "\nEXECUTIVE SHUTDOWN! Any key to reboot..." ); + + /* + * Wait for a key to be pressed + */ + while ( bsp_uart_pollRead(0) == -1 ) { + /* Wait */ + } + #endif + + /* + * Check both conditions -- if you want to ask for reboot, then + * you must have meant to reset the board. + */ + #if defined(BSP_PRESS_KEY_FOR_RESET) || defined(BSP_RESET_BOARD_AT_EXIT) + bsp_reset(); + #endif +} diff --git a/c/src/lib/libbsp/powerpc/gen83xx/startup/bspstart.c b/c/src/lib/libbsp/powerpc/gen83xx/startup/bspstart.c index 5548a6fbc6..32cb9b68a0 100644 --- a/c/src/lib/libbsp/powerpc/gen83xx/startup/bspstart.c +++ b/c/src/lib/libbsp/powerpc/gen83xx/startup/bspstart.c @@ -56,125 +56,125 @@ uint32_t bsp_clicks_per_usec; /* Default decrementer exception handler */ static int mpc83xx_decrementer_exception_handler( BSP_Exception_frame *frame, unsigned number) { - ppc_set_decrementer_register( UINT32_MAX); + ppc_set_decrementer_register(UINT32_MAX); - return 0; + return 0; } -void BSP_panic( char *s) +void BSP_panic(char *s) { - rtems_interrupt_level level; + rtems_interrupt_level level; - rtems_interrupt_disable( level); + rtems_interrupt_disable(level); - printk( "%s PANIC %s\n", _RTEMS_version, s); + printk("%s PANIC %s\n", rtems_get_version_string(), s); - while (1) { - /* Do nothing */ - } + while (1) { + /* Do nothing */ + } } -void _BSP_Fatal_error( unsigned n) +void _BSP_Fatal_error(unsigned n) { - rtems_interrupt_level level; + rtems_interrupt_level level; - rtems_interrupt_disable( level); + rtems_interrupt_disable( level); - printk( "%s PANIC ERROR %u\n", _RTEMS_version, n); + printk( "%s PANIC ERROR %u\n", rtems_get_version_string(), n); - while (1) { - /* Do nothing */ - } + while (1) { + /* Do nothing */ + } } -void bsp_pretasking_hook( void) -{ - /* Do noting */ -} - -void bsp_get_work_area( void **work_area_start, size_t *work_area_size, void **heap_start, size_t *heap_size) +void bsp_get_work_area( + void **work_area_start, + size_t *work_area_size, + void **heap_start, + size_t *heap_size) { #ifdef HAS_UBOOT - char *ram_end = (char *) mpc83xx_uboot_board_info.bi_memstart + mpc83xx_uboot_board_info.bi_memsize; + char *ram_end = (char *) mpc83xx_uboot_board_info.bi_memstart + + mpc83xx_uboot_board_info.bi_memsize; #else /* HAS_UBOOT */ - char *ram_end = bsp_ram_end; + char *ram_end = bsp_ram_end; #endif /* HAS_UBOOT */ - *work_area_start = bsp_work_area_start; - *work_area_size = ram_end - bsp_work_area_start; - *heap_start = BSP_BOOTCARD_HEAP_USES_WORK_AREA; - *heap_size = BSP_BOOTCARD_HEAP_SIZE_DEFAULT; + *work_area_start = bsp_work_area_start; + *work_area_size = ram_end - bsp_work_area_start; + *heap_start = BSP_BOOTCARD_HEAP_USES_WORK_AREA; + *heap_size = BSP_BOOTCARD_HEAP_SIZE_DEFAULT; } void bsp_start( void) { - rtems_status_code sc = RTEMS_SUCCESSFUL; - int rv = 0; + rtems_status_code sc = RTEMS_SUCCESSFUL; + int rv = 0; - ppc_cpu_id_t myCpu; - ppc_cpu_revision_t myCpuRevision; + ppc_cpu_id_t myCpu; + ppc_cpu_revision_t myCpuRevision; - uint32_t interrupt_stack_start = (uint32_t) bsp_interrupt_stack_start; - uint32_t interrupt_stack_size = (uint32_t) bsp_interrupt_stack_size; + uint32_t interrupt_stack_start = (uint32_t) bsp_interrupt_stack_start; + uint32_t interrupt_stack_size = (uint32_t) bsp_interrupt_stack_size; - /* - * Get CPU identification dynamically. Note that the get_ppc_cpu_type() function - * store the result in global variables so that it can be used latter... - */ - myCpu = get_ppc_cpu_type(); - myCpuRevision = get_ppc_cpu_revision(); + /* + * Get CPU identification dynamically. Note that the get_ppc_cpu_type() function + * store the result in global variables so that it can be used latter... + */ + myCpu = get_ppc_cpu_type(); + myCpuRevision = get_ppc_cpu_revision(); - /* Basic CPU initialization */ - cpu_init(); + /* Basic CPU initialization */ + cpu_init(); - /* - * Enable instruction and data caches. Do not force writethrough mode. - */ + /* + * Enable instruction and data caches. Do not force writethrough mode. + */ #if INSTRUCTION_CACHE_ENABLE - rtems_cache_enable_instruction(); + rtems_cache_enable_instruction(); #endif #if DATA_CACHE_ENABLE - rtems_cache_enable_data(); + rtems_cache_enable_data(); #endif - /* - * This is evaluated during runtime, so it should be ok to set it - * before we initialize the drivers. - */ + /* + * This is evaluated during runtime, so it should be ok to set it + * before we initialize the drivers. + */ - /* Initialize some device driver parameters */ + /* Initialize some device driver parameters */ #ifdef HAS_UBOOT - BSP_bus_frequency = mpc83xx_uboot_board_info.bi_busfreq; - bsp_clicks_per_usec = mpc83xx_uboot_board_info.bi_intfreq / 8000000; + BSP_bus_frequency = mpc83xx_uboot_board_info.bi_busfreq; + bsp_clicks_per_usec = mpc83xx_uboot_board_info.bi_intfreq / 8000000; #else /* HAS_UBOOT */ - BSP_bus_frequency = BSP_CLKIN_FRQ * BSP_SYSPLL_MF / BSP_SYSPLL_CKID; - bsp_clicks_per_usec = BSP_bus_frequency / 1000000; + BSP_bus_frequency = BSP_CLKIN_FRQ * BSP_SYSPLL_MF / BSP_SYSPLL_CKID; + bsp_clicks_per_usec = BSP_bus_frequency / 1000000; #endif /* HAS_UBOOT */ - /* Initialize exception handler */ - ppc_exc_initialize( - PPC_INTERRUPT_DISABLE_MASK_DEFAULT, - interrupt_stack_start, - interrupt_stack_size - ); - - /* Install default handler for the decrementer exception */ - rv = ppc_exc_set_handler( ASM_DEC_VECTOR, mpc83xx_decrementer_exception_handler); - if (rv < 0) { - BSP_panic( "Cannot install decrementer exception handler!\n"); - } - - /* Initalize interrupt support */ - sc = bsp_interrupt_initialize(); - if (sc != RTEMS_SUCCESSFUL) { - BSP_panic( "Cannot intitialize interrupt support\n"); - } + /* Initialize exception handler */ + ppc_exc_initialize( + PPC_INTERRUPT_DISABLE_MASK_DEFAULT, + interrupt_stack_start, + interrupt_stack_size + ); + + /* Install default handler for the decrementer exception */ + rv = ppc_exc_set_handler( ASM_DEC_VECTOR, mpc83xx_decrementer_exception_handler); + if (rv < 0) { + BSP_panic( "Cannot install decrementer exception handler!\n"); + } + + /* Initalize interrupt support */ + sc = bsp_interrupt_initialize(); + if (sc != RTEMS_SUCCESSFUL) { + BSP_panic( "Cannot intitialize interrupt support\n"); + } #ifdef SHOW_MORE_INIT_SETTINGS - printk("Exit from bspstart\n"); + printk("Exit from bspstart\n"); #endif } @@ -188,42 +188,17 @@ void bsp_start( void) Thread _Thread_Idle_body( uint32_t ignored) { - while (1) { - asm volatile ( - "mfmsr 3;" - "oris 3, 3, 4;" - "sync;" - "mtmsr 3;" - "isync;" - "ori 3, 3, 0;" - "ori 3, 3, 0" - ); - } - - return NULL; -} - -void bsp_cleanup( void) -{ -#ifdef MPC8313ERDB - - /* Set Reset Protection Register (RPR) to "RSTE" */ - mpc83xx.res.rpr = 0x52535445; - - /* - * Wait for Control Register Enabled in the - * Reset Control Enable Register (RCER). - */ - while (mpc83xx.res.rcer != 0x00000001) { - /* Wait */ - } - - /* Set Software Hard Reset in the Reset Control Register (RCR) */ - mpc83xx.res.rcr = 0x00000002; - -#else /* MPC8313ERDB */ - - /* Do nothing */ - -#endif /* MPC8313ERDB */ + while (1) { + asm volatile ( + "mfmsr 3;" + "oris 3, 3, 4;" + "sync;" + "mtmsr 3;" + "isync;" + "ori 3, 3, 0;" + "ori 3, 3, 0" + ); + } + + return NULL; } |