[b6394ae] | 1 | /* |
---|
[ac7d5ef0] | 2 | * This routine 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 this routine is invoked. |
---|
| 6 | * |
---|
[60b791ad] | 7 | * COPYRIGHT (c) 1989-1998. |
---|
[ac7d5ef0] | 8 | * On-Line Applications Research Corporation (OAR). |
---|
[03f2154e] | 9 | * Copyright assigned to U.S. Government, 1994. |
---|
[ac7d5ef0] | 10 | * |
---|
[98e4ebf5] | 11 | * The license and distribution terms for this file may be |
---|
| 12 | * found in the file LICENSE in this distribution or at |
---|
[03f2154e] | 13 | * http://www.OARcorp.com/rtems/license.html. |
---|
[ac7d5ef0] | 14 | * |
---|
| 15 | * $Id$ |
---|
| 16 | */ |
---|
| 17 | |
---|
[88d594a] | 18 | #include <bsp.h> |
---|
[3a4ae6c] | 19 | #include <rtems/libio.h> |
---|
| 20 | |
---|
[88d594a] | 21 | #include <libcsupport.h> |
---|
[3a4ae6c] | 22 | |
---|
| 23 | #include <string.h> |
---|
| 24 | |
---|
[ac7d5ef0] | 25 | unsigned char *duart_base; |
---|
| 26 | extern struct duart_regs duart_info; |
---|
| 27 | |
---|
| 28 | #define DELAY 5000 |
---|
| 29 | |
---|
| 30 | void led_putnum(); |
---|
| 31 | |
---|
| 32 | /* |
---|
| 33 | * The original table from the application and our copy of it with |
---|
| 34 | * some changes. |
---|
| 35 | */ |
---|
| 36 | |
---|
| 37 | extern rtems_configuration_table Configuration; |
---|
| 38 | rtems_configuration_table BSP_Configuration; |
---|
| 39 | |
---|
| 40 | rtems_cpu_table Cpu_table; |
---|
| 41 | |
---|
[3a4ae6c] | 42 | char *rtems_progname; |
---|
| 43 | |
---|
[b6394ae] | 44 | /* |
---|
| 45 | * Use the shared implementations of the following routines |
---|
[ac7d5ef0] | 46 | */ |
---|
| 47 | |
---|
[b6394ae] | 48 | void bsp_postdriver_hook(void); |
---|
| 49 | void bsp_libc_init( void *, unsigned32, int ); |
---|
[3652ad35] | 50 | |
---|
| 51 | /* |
---|
| 52 | * Function: bsp_pretasking_hook |
---|
| 53 | * Created: 95/03/10 |
---|
| 54 | * |
---|
| 55 | * Description: |
---|
| 56 | * BSP pretasking hook. Called just before drivers are initialized. |
---|
| 57 | * Used to setup libc and install any BSP extensions. |
---|
| 58 | * |
---|
| 59 | * NOTES: |
---|
| 60 | * Must not use libc (to do io) from here, since drivers are |
---|
| 61 | * not yet initialized. |
---|
| 62 | * |
---|
| 63 | */ |
---|
| 64 | |
---|
[b6394ae] | 65 | void bsp_pretasking_hook(void) |
---|
[3652ad35] | 66 | { |
---|
[b6394ae] | 67 | extern int end; |
---|
| 68 | rtems_unsigned32 heap_start; |
---|
| 69 | |
---|
| 70 | heap_start = (rtems_unsigned32) &end; |
---|
| 71 | if (heap_start & (CPU_ALIGNMENT-1)) |
---|
| 72 | heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1); |
---|
| 73 | |
---|
| 74 | /* Create 64 KByte memory region for RTEMS executive */ |
---|
| 75 | bsp_libc_init((void *) heap_start, 64 * 1024, 0); |
---|
[ac7d5ef0] | 76 | |
---|
[3652ad35] | 77 | #ifdef RTEMS_DEBUG |
---|
| 78 | rtems_debug_enable( RTEMS_DEBUG_ALL_MASK ); |
---|
| 79 | #endif |
---|
[ac7d5ef0] | 80 | } |
---|
| 81 | |
---|
[3a4ae6c] | 82 | /* |
---|
[b6394ae] | 83 | * bsp_start |
---|
| 84 | * |
---|
| 85 | * This routine does the bulk of the system initialization. |
---|
[3a4ae6c] | 86 | */ |
---|
| 87 | |
---|
[e2a2ec60] | 88 | void bsp_start( void ) |
---|
[ac7d5ef0] | 89 | { |
---|
[497428a2] | 90 | m68k_isr_entry *monitors_vector_table; |
---|
| 91 | int index; |
---|
[ac7d5ef0] | 92 | |
---|
| 93 | duart_base = (unsigned char *)DUART_ADDR; |
---|
| 94 | |
---|
| 95 | /* |
---|
| 96 | * Set the VBR here to the monitor's default. |
---|
| 97 | */ |
---|
| 98 | |
---|
[497428a2] | 99 | monitors_vector_table = (m68k_isr_entry *)0; |
---|
| 100 | /* This is where you set vector base register = 0 */ |
---|
[ac7d5ef0] | 101 | m68k_set_vbr( monitors_vector_table ); |
---|
| 102 | |
---|
| 103 | /* The vector interrupt table for the 680x0 is in appendix B-2 |
---|
| 104 | of the M68000 Family Programmer's reference table */ |
---|
| 105 | for ( index=2 ; index<=255 ; index++ ) |
---|
| 106 | M68Kvec[ index ] = monitors_vector_table[ 32 ]; |
---|
| 107 | |
---|
| 108 | |
---|
| 109 | M68Kvec[ 2 ] = monitors_vector_table[ 2 ]; /* bus error vector */ |
---|
| 110 | M68Kvec[ 4 ] = monitors_vector_table[ 4 ]; /* breakpoints vector */ |
---|
| 111 | M68Kvec[ 9 ] = monitors_vector_table[ 9 ]; /* trace vector */ |
---|
| 112 | |
---|
| 113 | /* |
---|
| 114 | * Set the VBR here if you do not want to use the monitor's vector table. |
---|
| 115 | */ |
---|
| 116 | |
---|
| 117 | m68k_set_vbr( &M68Kvec ); |
---|
| 118 | |
---|
| 119 | m68k_enable_caching(); |
---|
| 120 | |
---|
| 121 | /* |
---|
| 122 | * we only use a hook to get the C library initialized. |
---|
| 123 | */ |
---|
| 124 | |
---|
[3652ad35] | 125 | Cpu_table.pretasking_hook = bsp_pretasking_hook; /* init libc, etc. */ |
---|
| 126 | |
---|
| 127 | Cpu_table.predriver_hook = NULL; |
---|
| 128 | |
---|
[3a4ae6c] | 129 | Cpu_table.postdriver_hook = bsp_postdriver_hook; |
---|
[3652ad35] | 130 | |
---|
[ac7d5ef0] | 131 | Cpu_table.idle_task = NULL; /* do not override system IDLE task */ |
---|
| 132 | |
---|
| 133 | Cpu_table.do_zero_of_workspace = TRUE; |
---|
| 134 | |
---|
[497428a2] | 135 | Cpu_table.interrupt_vector_table = (m68k_isr_entry *) &M68Kvec; |
---|
[ac7d5ef0] | 136 | |
---|
| 137 | Cpu_table.interrupt_stack_size = 4096; |
---|
| 138 | |
---|
[8cbbe312] | 139 | Cpu_table.extra_mpci_receive_server_stack = 0; |
---|
[ac7d5ef0] | 140 | |
---|
| 141 | /* |
---|
| 142 | * Copy the table |
---|
| 143 | */ |
---|
| 144 | |
---|
| 145 | BSP_Configuration = Configuration; |
---|
| 146 | |
---|
| 147 | BSP_Configuration.work_space_start = (void *) |
---|
| 148 | (RAM_END - BSP_Configuration.work_space_size); |
---|
| 149 | |
---|
[3a4ae6c] | 150 | /* |
---|
| 151 | * Tell libio how many fd's we want and allow it to tweak config |
---|
| 152 | */ |
---|
| 153 | |
---|
| 154 | rtems_libio_config(&BSP_Configuration, BSP_LIBIO_MAX_FDS); |
---|
| 155 | |
---|
[ac7d5ef0] | 156 | /* led_putnum('e'); * for debugging purposes only */ |
---|
| 157 | |
---|
[e2a2ec60] | 158 | /* Clock_exit is done as an atexit() function */ |
---|
[ac7d5ef0] | 159 | } |
---|