[57ed393] | 1 | /* bsp_start() |
---|
| 2 | * |
---|
| 3 | * This routine starts the application. It includes application, |
---|
| 4 | * board, and monitor specific initialization and configuration. |
---|
| 5 | * The generic CPU dependent initialization has been performed |
---|
| 6 | * before this routine is invoked. |
---|
| 7 | * |
---|
| 8 | * INPUT: NONE |
---|
| 9 | * |
---|
| 10 | * OUTPUT: NONE |
---|
| 11 | * |
---|
| 12 | * Author: Thomas Doerfler <td@imd.m.isar.de> |
---|
| 13 | * IMD Ingenieurbuero fuer Microcomputertechnik |
---|
| 14 | * |
---|
| 15 | * COPYRIGHT (c) 1998 by IMD |
---|
[6128a4a] | 16 | * |
---|
[57ed393] | 17 | * Changes from IMD are covered by the original distributions terms. |
---|
[6128a4a] | 18 | * This file has been derived from the papyrus BSP: |
---|
[57ed393] | 19 | * |
---|
| 20 | * Author: Andrew Bray <andy@i-cubed.co.uk> |
---|
| 21 | * |
---|
| 22 | * COPYRIGHT (c) 1995 by i-cubed ltd. |
---|
| 23 | * |
---|
| 24 | * To anyone who acknowledges that this file is provided "AS IS" |
---|
| 25 | * without any express or implied warranty: |
---|
| 26 | * permission to use, copy, modify, and distribute this file |
---|
| 27 | * for any purpose is hereby granted without fee, provided that |
---|
| 28 | * the above copyright notice and this notice appears in all |
---|
| 29 | * copies, and that the name of i-cubed limited not be used in |
---|
| 30 | * advertising or publicity pertaining to distribution of the |
---|
| 31 | * software without specific, written prior permission. |
---|
| 32 | * i-cubed limited makes no representations about the suitability |
---|
| 33 | * of this software for any purpose. |
---|
| 34 | * |
---|
| 35 | * Modifications for spooling console driver and control of memory layout |
---|
| 36 | * with linker command file by |
---|
| 37 | * Thomas Doerfler <td@imd.m.isar.de> |
---|
| 38 | * for these modifications: |
---|
| 39 | * COPYRIGHT (c) 1997 by IMD, Puchheim, Germany. |
---|
| 40 | * |
---|
| 41 | * To anyone who acknowledges that this file is provided "AS IS" |
---|
| 42 | * without any express or implied warranty: |
---|
| 43 | * permission to use, copy, modify, and distribute this file |
---|
| 44 | * for any purpose is hereby granted without fee, provided that |
---|
| 45 | * the above copyright notice and this notice appears in all |
---|
| 46 | * copies. IMD makes no representations about the suitability |
---|
| 47 | * of this software for any purpose. |
---|
[6128a4a] | 48 | * |
---|
[57ed393] | 49 | * Derived from c/src/lib/libbsp/no_cpu/no_bsp/startup/bspstart.c: |
---|
| 50 | * |
---|
| 51 | * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. |
---|
| 52 | * On-Line Applications Research Corporation (OAR). |
---|
| 53 | * |
---|
| 54 | * Modifications for PPC405GP by Dennis Ehlin |
---|
| 55 | * |
---|
| 56 | * $Id$ |
---|
| 57 | */ |
---|
| 58 | |
---|
| 59 | #include <string.h> |
---|
| 60 | #include <fcntl.h> |
---|
| 61 | |
---|
| 62 | #include <bsp.h> |
---|
| 63 | #include <rtems/libio.h> |
---|
| 64 | #include <rtems/libcsupport.h> |
---|
| 65 | #include <ictrl.h> |
---|
[6128a4a] | 66 | |
---|
[57ed393] | 67 | /* |
---|
| 68 | * The original table from the application and our copy of it with |
---|
| 69 | * some changes. |
---|
| 70 | */ |
---|
| 71 | |
---|
| 72 | extern rtems_configuration_table Configuration; |
---|
| 73 | |
---|
| 74 | rtems_configuration_table BSP_Configuration; |
---|
| 75 | |
---|
| 76 | rtems_cpu_table Cpu_table; |
---|
| 77 | |
---|
| 78 | char *rtems_progname; |
---|
| 79 | void *bsp_ram_end = (void *)RAM_END; /* first addr behind avail. ram area */ |
---|
| 80 | |
---|
[07e9642c] | 81 | /* |
---|
| 82 | * Driver configuration parameters |
---|
| 83 | */ |
---|
| 84 | uint32_t bsp_serial_per_sec; /* Serial clocks per second */ |
---|
| 85 | boolean bsp_serial_external_clock; |
---|
| 86 | boolean bsp_serial_xon_xoff; |
---|
| 87 | boolean bsp_serial_cts_rts; |
---|
| 88 | uint32_t bsp_serial_rate; |
---|
| 89 | uint32_t bsp_timer_average_overhead; /* Average overhead of timer in ticks */ |
---|
| 90 | uint32_t bsp_timer_least_valid; /* Least valid number from timer */ |
---|
| 91 | boolean bsp_timer_internal_clock; /* TRUE, when timer runs with CPU clk */ |
---|
| 92 | |
---|
[57ed393] | 93 | /* Initialize whatever libc we are using |
---|
| 94 | * called from postdriver hook |
---|
| 95 | */ |
---|
[6128a4a] | 96 | |
---|
[57ed393] | 97 | void bsp_postdriver_hook(void); |
---|
[cba5e81] | 98 | void bsp_libc_init( void *, uint32_t, int ); |
---|
[57ed393] | 99 | |
---|
| 100 | /* |
---|
| 101 | * |
---|
| 102 | * bsp_predriver_hook |
---|
| 103 | * |
---|
| 104 | * Before drivers are setup. |
---|
[6128a4a] | 105 | */ |
---|
[57ed393] | 106 | |
---|
| 107 | void bsp_predriver_hook(void) |
---|
| 108 | { |
---|
| 109 | rtems_status_code status; |
---|
| 110 | /* init the PPC405 external interrupt controller handler... */ |
---|
| 111 | status = ictrl_init(); |
---|
| 112 | } |
---|
| 113 | |
---|
| 114 | /* |
---|
| 115 | * Function: bsp_pretasking_hook |
---|
| 116 | * Created: 95/03/10 |
---|
| 117 | * |
---|
| 118 | * Description: |
---|
| 119 | * BSP pretasking hook. Called just before drivers are initialized. |
---|
| 120 | * Used to setup libc and install any BSP extensions. |
---|
| 121 | * |
---|
| 122 | * NOTES: |
---|
| 123 | * Must not use libc (to do io) from here, since drivers are |
---|
| 124 | * not yet initialized. |
---|
| 125 | * |
---|
| 126 | */ |
---|
[6128a4a] | 127 | |
---|
[57ed393] | 128 | void bsp_pretasking_hook(void) |
---|
| 129 | { |
---|
| 130 | extern int _end; |
---|
| 131 | extern int _heap_end; |
---|
[cba5e81] | 132 | uint32_t heap_start; |
---|
| 133 | uint32_t heap_size; |
---|
| 134 | uint32_t heap_end; |
---|
[57ed393] | 135 | |
---|
[cba5e81] | 136 | heap_start = (uint32_t ) &_end; |
---|
[57ed393] | 137 | if (heap_start & (CPU_ALIGNMENT-1)) |
---|
| 138 | heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1); |
---|
| 139 | |
---|
[cba5e81] | 140 | heap_end = (uint32_t ) &_heap_end; |
---|
[57ed393] | 141 | if (heap_end & (CPU_ALIGNMENT-1)) |
---|
| 142 | heap_end = (heap_end + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1); |
---|
| 143 | |
---|
| 144 | heap_size = heap_end - heap_start; |
---|
| 145 | |
---|
| 146 | bsp_libc_init((void *) heap_start, heap_size, 0); /* 64 * 1024 */ |
---|
[6128a4a] | 147 | |
---|
[57ed393] | 148 | #ifdef RTEMS_DEBUG |
---|
| 149 | rtems_debug_enable( RTEMS_DEBUG_ALL_MASK ); |
---|
| 150 | #endif |
---|
| 151 | |
---|
| 152 | } |
---|
[6128a4a] | 153 | |
---|
[57ed393] | 154 | /* |
---|
| 155 | * bsp_start |
---|
| 156 | * |
---|
| 157 | * This routine does the bulk of the system initialization. |
---|
| 158 | */ |
---|
| 159 | |
---|
| 160 | void bsp_start( void ) |
---|
| 161 | { |
---|
| 162 | /* |
---|
| 163 | * Allocate the memory for the RTEMS Work Space. This can come from |
---|
| 164 | * a variety of places: hard coded address, malloc'ed from outside |
---|
| 165 | * RTEMS world (e.g. simulator or primitive memory manager), or (as |
---|
| 166 | * typically done by stock BSPs) by subtracting the required amount |
---|
| 167 | * of work space from the last physical address on the CPU board. |
---|
| 168 | */ |
---|
| 169 | |
---|
| 170 | /* |
---|
| 171 | * Need to "allocate" the memory for the RTEMS Workspace and |
---|
| 172 | * tell the RTEMS configuration where it is. This memory is |
---|
| 173 | * not malloc'ed. It is just "pulled from the air". |
---|
| 174 | */ |
---|
[6128a4a] | 175 | /* FIME: plan usage of RAM better: |
---|
[57ed393] | 176 | - make top of ram dynamic, |
---|
| 177 | - take out some part for persistant log |
---|
[6128a4a] | 178 | - make rest of ram to heap... |
---|
| 179 | -remove RAM_END from bsp.h, this cannot be valid... |
---|
[57ed393] | 180 | or must be a function call |
---|
| 181 | */ |
---|
| 182 | BSP_Configuration.work_space_start = (void *) |
---|
| 183 | ((char *)(bsp_ram_end)) - BSP_Configuration.work_space_size; |
---|
| 184 | |
---|
| 185 | /* |
---|
| 186 | * initialize the CPU table for this BSP |
---|
| 187 | */ |
---|
| 188 | |
---|
| 189 | Cpu_table.pretasking_hook = bsp_pretasking_hook; /* init libc, etc. */ |
---|
| 190 | Cpu_table.predriver_hook = bsp_predriver_hook; |
---|
| 191 | Cpu_table.postdriver_hook = bsp_postdriver_hook; |
---|
| 192 | Cpu_table.interrupt_stack_size = CONFIGURE_INTERRUPT_STACK_MEMORY; |
---|
| 193 | |
---|
[07e9642c] | 194 | bsp_clicks_per_usec = 300; |
---|
| 195 | bsp_serial_per_sec = 14625000; |
---|
| 196 | bsp_serial_external_clock = 0; |
---|
| 197 | bsp_timer_internal_clock = 1; |
---|
| 198 | bsp_serial_xon_xoff = 0; |
---|
| 199 | bsp_serial_cts_rts = 1; |
---|
| 200 | bsp_serial_rate = 115200; |
---|
| 201 | bsp_timer_average_overhead = 2; |
---|
| 202 | bsp_timer_least_valid = 3; |
---|
| 203 | bsp_exceptions_in_RAM = TRUE; |
---|
[57ed393] | 204 | } |
---|