[41c9282] | 1 | /* |
---|
| 2 | * This set of routines starts the application. It includes application, |
---|
| 3 | * board, and monitor specific initialization and configuration. |
---|
| 4 | * The generic CPU dependent initialization has been performed |
---|
| 5 | * before any of these are invoked. |
---|
| 6 | * |
---|
[6dacdf9d] | 7 | * COPYRIGHT (c) 1989-2007. |
---|
[41c9282] | 8 | * On-Line Applications Research Corporation (OAR). |
---|
| 9 | * |
---|
| 10 | * Modified for LEON3 BSP. |
---|
| 11 | * COPYRIGHT (c) 2004. |
---|
| 12 | * Gaisler Research. |
---|
| 13 | * |
---|
| 14 | * The license and distribution terms for this file may be |
---|
| 15 | * found in the file LICENSE in this distribution or at |
---|
| 16 | * http://www.rtems.com/license/LICENSE. |
---|
| 17 | * |
---|
| 18 | * $Id$ |
---|
| 19 | */ |
---|
| 20 | |
---|
| 21 | |
---|
| 22 | #include <string.h> |
---|
| 23 | |
---|
| 24 | #include <bsp.h> |
---|
[d4886a06] | 25 | #include <bsp/bootcard.h> |
---|
[6dacdf9d] | 26 | #include <rtems/bspIo.h> |
---|
[41c9282] | 27 | |
---|
[7db0adc5] | 28 | /* must be identical to STACK_SIZE in start.S */ |
---|
| 29 | #define STACK_SIZE 16 * 1024 |
---|
| 30 | |
---|
[41c9282] | 31 | /* |
---|
| 32 | * Tells us where to put the workspace in case remote debugger is present. |
---|
| 33 | */ |
---|
| 34 | extern uint32_t rdb_start; |
---|
| 35 | |
---|
[4cb04f2] | 36 | /* |
---|
| 37 | * Tells us if data cache snooping is available |
---|
| 38 | */ |
---|
| 39 | int CPU_SPARC_HAS_SNOOPING; |
---|
| 40 | |
---|
| 41 | /* |
---|
| 42 | * set_snooping |
---|
| 43 | * |
---|
| 44 | * Read the data cache configuration register to determine if |
---|
| 45 | * bus snooping is available. This is needed for some drivers so |
---|
| 46 | * that they can select the most efficient copy routines. |
---|
| 47 | * |
---|
| 48 | */ |
---|
| 49 | |
---|
| 50 | static inline int set_snooping(void) |
---|
| 51 | { |
---|
[4c94ffff] | 52 | int tmp; |
---|
| 53 | asm(" lda [%1] 2, %0 " |
---|
| 54 | : "=r"(tmp) |
---|
| 55 | : "r"(0xC) |
---|
| 56 | ); |
---|
| 57 | return (tmp >> 27) & 1; |
---|
[4cb04f2] | 58 | } |
---|
| 59 | |
---|
[41c9282] | 60 | /* |
---|
| 61 | * bsp_pretasking_hook |
---|
| 62 | * |
---|
| 63 | * BSP pretasking hook. Called just before drivers are initialized. |
---|
[4c94ffff] | 64 | * Used to setup libc and install any BSP extensions . |
---|
[41c9282] | 65 | */ |
---|
| 66 | |
---|
| 67 | void bsp_pretasking_hook(void) |
---|
| 68 | { |
---|
| 69 | bsp_spurious_initialize(); |
---|
| 70 | } |
---|
| 71 | |
---|
[4c94ffff] | 72 | /* |
---|
| 73 | * This method returns the base address and size of the area which |
---|
| 74 | * is to be allocated between the RTEMS Workspace and the C Program |
---|
| 75 | * Heap. |
---|
| 76 | */ |
---|
[d4886a06] | 77 | void bsp_get_work_area( |
---|
| 78 | void **work_area_start, |
---|
| 79 | size_t *work_area_size, |
---|
| 80 | void **heap_start, |
---|
| 81 | size_t *heap_size |
---|
[4c94ffff] | 82 | ) |
---|
| 83 | { |
---|
| 84 | /* Tells us where to put the workspace in case remote debugger is present. */ |
---|
| 85 | extern uint32_t rdb_start; |
---|
| 86 | |
---|
[d4886a06] | 87 | *work_area_start = &end; |
---|
| 88 | *work_area_size = (void *)rdb_start - (void *)&end - STACK_SIZE; |
---|
| 89 | *heap_start = BSP_BOOTCARD_HEAP_USES_WORK_AREA; |
---|
| 90 | *heap_size = BSP_BOOTCARD_HEAP_SIZE_DEFAULT; |
---|
[4c94ffff] | 91 | } |
---|
| 92 | |
---|
[41c9282] | 93 | /* |
---|
| 94 | * bsp_start |
---|
| 95 | * |
---|
| 96 | * This routine does the bulk of the system initialization. |
---|
| 97 | */ |
---|
| 98 | void bsp_start( void ) |
---|
| 99 | { |
---|
[4cb04f2] | 100 | CPU_SPARC_HAS_SNOOPING = set_snooping(); |
---|
[41c9282] | 101 | } |
---|