[ab20575] | 1 | /* |
---|
| 2 | * bsp_pretasking_hook(). |
---|
| 3 | * Initializes the heap, libc and VME. |
---|
| 4 | * |
---|
| 5 | * COPYRIGHT (c) 1989-1998. |
---|
| 6 | * On-Line Applications Research Corporation (OAR). |
---|
| 7 | * |
---|
| 8 | * The license and distribution terms for this file may be |
---|
| 9 | * found in the file LICENSE in this distribution or at |
---|
| 10 | * http://www.rtems.com/license/LICENSE. |
---|
| 11 | * |
---|
| 12 | * Modified to support the MCP750. |
---|
| 13 | * Modifications Copyright (C) 1999 Eric Valette. valette@crf.canon.fr |
---|
| 14 | * |
---|
| 15 | * $Id$ |
---|
| 16 | */ |
---|
| 17 | |
---|
| 18 | #include <string.h> |
---|
| 19 | |
---|
| 20 | #include <bsp.h> |
---|
| 21 | #ifndef BSP_HAS_NO_VME |
---|
| 22 | #include <bsp/VME.h> |
---|
| 23 | #endif |
---|
| 24 | |
---|
[956c9b58] | 25 | #ifdef SHOW_MORE_INIT_SETTINGS |
---|
| 26 | #include <rtems/bspIo.h> |
---|
| 27 | #endif |
---|
| 28 | |
---|
[73c7cf1] | 29 | #include <rtems/malloc.h> |
---|
| 30 | |
---|
[ab20575] | 31 | void bsp_libc_init( void *, uint32_t, int ); |
---|
| 32 | |
---|
| 33 | /* |
---|
| 34 | * Function: bsp_pretasking_hook |
---|
| 35 | * Created: 95/03/10 |
---|
| 36 | * |
---|
| 37 | * Description: |
---|
| 38 | * BSP pretasking hook. Called just before drivers are initialized. |
---|
| 39 | * Used to setup libc and install any BSP extensions. |
---|
| 40 | * |
---|
| 41 | * NOTES: |
---|
| 42 | * Must not use libc (to do io) from here, since drivers are |
---|
| 43 | * not yet initialized. |
---|
| 44 | * |
---|
| 45 | */ |
---|
| 46 | |
---|
| 47 | void bsp_pretasking_hook(void) |
---|
| 48 | { |
---|
| 49 | uint32_t heap_size; |
---|
| 50 | uint32_t heap_sbrk_spared; |
---|
| 51 | extern uint32_t _bsp_sbrk_init(uint32_t, uint32_t*); |
---|
| 52 | extern void BSP_vme_config(); |
---|
| 53 | |
---|
| 54 | /* make sure it's properly aligned */ |
---|
| 55 | BSP_heap_start = (BSP_heap_start + CPU_ALIGNMENT - 1) & ~(CPU_ALIGNMENT-1); |
---|
| 56 | |
---|
[4b39acf] | 57 | heap_size = (BSP_mem_size - BSP_heap_start) - rtems_configuration_get_work_space_size(); |
---|
[ab20575] | 58 | heap_sbrk_spared=_bsp_sbrk_init(BSP_heap_start, &heap_size); |
---|
| 59 | |
---|
| 60 | #ifdef SHOW_MORE_INIT_SETTINGS |
---|
| 61 | printk( "HEAP start %x size %x (%x bytes spared for sbrk)\n", |
---|
| 62 | BSP_heap_start, heap_size, heap_sbrk_spared); |
---|
| 63 | #endif |
---|
| 64 | |
---|
[73c7cf1] | 65 | /* Must install sbrk helpers since we rely on sbrk for giving |
---|
| 66 | * us even the first chunk of memory (bsp_libc_init(heap start==NULL)) |
---|
| 67 | */ |
---|
| 68 | |
---|
| 69 | rtems_malloc_sbrk_helpers = &rtems_malloc_sbrk_helpers_table; |
---|
| 70 | |
---|
[ab20575] | 71 | bsp_libc_init((void *) 0, heap_size, heap_sbrk_spared); |
---|
| 72 | |
---|
| 73 | /* Note that VME support may be omitted also by |
---|
| 74 | * providing a NULL BSP_vme_config routine |
---|
| 75 | * (e.g., linker script) |
---|
| 76 | */ |
---|
| 77 | #ifndef BSP_HAS_NO_VME |
---|
| 78 | /* |
---|
| 79 | * Initialize VME bridge - needs working PCI |
---|
| 80 | * and IRQ subsystems... |
---|
| 81 | * |
---|
| 82 | * NOTE: vmeUniverse driver now uses shared interrupts. |
---|
[8c6579b] | 83 | * this requires malloc/free which are not available |
---|
[ab20575] | 84 | * from bspstart()... |
---|
| 85 | */ |
---|
| 86 | #ifdef SHOW_MORE_INIT_SETTINGS |
---|
| 87 | printk("Going to initialize VME bridge\n"); |
---|
| 88 | #endif |
---|
| 89 | if ( BSP_vme_config ) |
---|
| 90 | BSP_vme_config(); |
---|
| 91 | #endif |
---|
| 92 | |
---|
| 93 | #ifdef RTEMS_DEBUG |
---|
| 94 | rtems_debug_enable( RTEMS_DEBUG_ALL_MASK ); |
---|
| 95 | #endif |
---|
[956c9b58] | 96 | #ifdef SHOW_MORE_INIT_SETTINGS |
---|
| 97 | printk("Leaving bsp_pretasking_hook\n"); |
---|
| 98 | #endif |
---|
[ab20575] | 99 | } |
---|