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