[6128a4a] | 1 | /* |
---|
[9b2c969] | 2 | * This routine is an implementation of the bsp_pretasking_hook |
---|
| 3 | * that can be used by all m68k BSPs following linkcmds conventions |
---|
| 4 | * regarding heap, stack, and workspace allocation. |
---|
| 5 | * |
---|
| 6 | * COPYRIGHT (c) 1989-1999. |
---|
| 7 | * On-Line Applications Research Corporation (OAR). |
---|
| 8 | * |
---|
| 9 | * The license and distribution terms for this file may be |
---|
| 10 | * found in the file LICENSE in this distribution or at |
---|
[7e0e4546] | 11 | * http://www.rtems.com/license/LICENSE. |
---|
[9b2c969] | 12 | * |
---|
| 13 | * $Id$ |
---|
| 14 | */ |
---|
| 15 | |
---|
| 16 | #include <bsp.h> |
---|
[e253b4d] | 17 | #include <rtems/libio.h> |
---|
| 18 | #include <rtems/libcsupport.h> |
---|
[9b2c969] | 19 | |
---|
| 20 | /* |
---|
| 21 | * Function: bsp_pretasking_hook |
---|
| 22 | * Created: 95/03/10 |
---|
| 23 | * |
---|
| 24 | * Description: |
---|
| 25 | * BSP pretasking hook. Called just before drivers are initialized. |
---|
| 26 | * Used to setup libc and install any BSP extensions. |
---|
| 27 | * |
---|
| 28 | * NOTES: |
---|
| 29 | * Must not use libc (to do io) from here, since drivers are |
---|
| 30 | * not yet initialized. |
---|
| 31 | * |
---|
| 32 | */ |
---|
| 33 | |
---|
| 34 | extern void bsp_libc_init( void *, unsigned long, int ); |
---|
| 35 | extern rtems_configuration_table BSP_Configuration; |
---|
| 36 | |
---|
[c97f5fd] | 37 | extern char _RamBase[]; |
---|
| 38 | extern char _WorkspaceBase[]; |
---|
| 39 | extern char _HeapSize[]; |
---|
[9b2c969] | 40 | |
---|
[df49c60] | 41 | unsigned long _M68k_Ramsize; |
---|
| 42 | |
---|
[9b2c969] | 43 | void bsp_pretasking_hook(void) |
---|
| 44 | { |
---|
| 45 | void *heapStart; |
---|
[572484f] | 46 | unsigned long heapSize = (unsigned long)_HeapSize; |
---|
[9b2c969] | 47 | unsigned long ramSpace; |
---|
| 48 | |
---|
| 49 | heapStart = (void *) |
---|
[572484f] | 50 | ((unsigned long)_WorkspaceBase + BSP_Configuration.work_space_size); |
---|
| 51 | ramSpace = (unsigned long)_RamBase + _M68k_Ramsize - (unsigned long)heapStart; |
---|
[9b2c969] | 52 | |
---|
[572484f] | 53 | /* |
---|
| 54 | * Can't use 'if(heapSize==0)' because the compiler "knows" that nothing |
---|
| 55 | * can have an address of 0 and proceeds to optimize-away the test. |
---|
| 56 | */ |
---|
| 57 | if (heapSize < 10) |
---|
[9b2c969] | 58 | heapSize = ramSpace; |
---|
| 59 | else if (heapSize > ramSpace) |
---|
| 60 | rtems_fatal_error_occurred (('H'<<24) | ('E'<<16) | ('A'<<8) | 'P'); |
---|
| 61 | |
---|
| 62 | bsp_libc_init(heapStart, heapSize, 0); |
---|
| 63 | |
---|
| 64 | #ifdef RTEMS_DEBUG |
---|
| 65 | rtems_debug_enable( RTEMS_DEBUG_ALL_MASK ); |
---|
| 66 | #endif |
---|
| 67 | |
---|
| 68 | } |
---|