[ac7d5ef0] | 1 | /* |
---|
| 2 | * Workspace Handler |
---|
| 3 | * |
---|
[45819022] | 4 | * XXX |
---|
[152e31a] | 5 | * |
---|
[ac7d5ef0] | 6 | * NOTE: |
---|
| 7 | * |
---|
[08311cc3] | 8 | * COPYRIGHT (c) 1989-1999. |
---|
[ac7d5ef0] | 9 | * On-Line Applications Research Corporation (OAR). |
---|
| 10 | * |
---|
[98e4ebf5] | 11 | * The license and distribution terms for this file may be |
---|
| 12 | * found in the file LICENSE in this distribution or at |
---|
[dd687d97] | 13 | * http://www.rtems.com/license/LICENSE. |
---|
[ac7d5ef0] | 14 | * |
---|
[63edbb3f] | 15 | * $Id$ |
---|
[ac7d5ef0] | 16 | */ |
---|
| 17 | |
---|
[a8eed23] | 18 | #if HAVE_CONFIG_H |
---|
| 19 | #include "config.h" |
---|
| 20 | #endif |
---|
| 21 | |
---|
[ac7d5ef0] | 22 | #include <rtems/system.h> |
---|
[5e9b32b] | 23 | #include <rtems/score/wkspace.h> |
---|
| 24 | #include <rtems/score/interr.h> |
---|
[ac7d5ef0] | 25 | |
---|
[8faca06] | 26 | /*PAGE |
---|
| 27 | * |
---|
| 28 | * _Workspace_Handler_initialization |
---|
| 29 | */ |
---|
[05279b84] | 30 | |
---|
[8faca06] | 31 | void _Workspace_Handler_initialization( |
---|
| 32 | void *starting_address, |
---|
[37c7bfcb] | 33 | size_t size |
---|
[8faca06] | 34 | ) |
---|
| 35 | { |
---|
[3127180] | 36 | uint32_t *zero_out_array; |
---|
| 37 | uint32_t index; |
---|
| 38 | uint32_t memory_available; |
---|
[05279b84] | 39 | |
---|
[8faca06] | 40 | if ( !starting_address || !_Addresses_Is_aligned( starting_address ) ) |
---|
| 41 | _Internal_error_Occurred( |
---|
| 42 | INTERNAL_ERROR_CORE, |
---|
| 43 | TRUE, |
---|
| 44 | INTERNAL_ERROR_INVALID_WORKSPACE_ADDRESS |
---|
| 45 | ); |
---|
[05279b84] | 46 | |
---|
[8faca06] | 47 | if ( _CPU_Table.do_zero_of_workspace ) { |
---|
[3127180] | 48 | for( zero_out_array = (uint32_t *) starting_address, index = 0 ; |
---|
| 49 | index < size / sizeof( uint32_t ) ; |
---|
[8faca06] | 50 | index++ ) |
---|
| 51 | zero_out_array[ index ] = 0; |
---|
| 52 | } |
---|
[05279b84] | 53 | |
---|
[8faca06] | 54 | memory_available = _Heap_Initialize( |
---|
| 55 | &_Workspace_Area, |
---|
| 56 | starting_address, |
---|
| 57 | size, |
---|
| 58 | CPU_HEAP_ALIGNMENT |
---|
| 59 | ); |
---|
[05279b84] | 60 | |
---|
[8faca06] | 61 | if ( memory_available == 0 ) |
---|
| 62 | _Internal_error_Occurred( |
---|
| 63 | INTERNAL_ERROR_CORE, |
---|
| 64 | TRUE, |
---|
| 65 | INTERNAL_ERROR_TOO_LITTLE_WORKSPACE |
---|
| 66 | ); |
---|
| 67 | } |
---|
| 68 | |
---|
[ac7d5ef0] | 69 | /*PAGE |
---|
| 70 | * |
---|
| 71 | * _Workspace_Allocate_or_fatal_error |
---|
| 72 | * |
---|
| 73 | */ |
---|
| 74 | |
---|
| 75 | void *_Workspace_Allocate_or_fatal_error( |
---|
[37c7bfcb] | 76 | size_t size |
---|
[ac7d5ef0] | 77 | ) |
---|
| 78 | { |
---|
| 79 | void *memory; |
---|
| 80 | |
---|
| 81 | memory = _Workspace_Allocate( size ); |
---|
| 82 | |
---|
| 83 | if ( memory == NULL ) |
---|
[3a4ae6c] | 84 | _Internal_error_Occurred( |
---|
| 85 | INTERNAL_ERROR_CORE, |
---|
| 86 | TRUE, |
---|
| 87 | INTERNAL_ERROR_WORKSPACE_ALLOCATION |
---|
| 88 | ); |
---|
[ac7d5ef0] | 89 | |
---|
| 90 | return memory; |
---|
| 91 | } |
---|