source: rtems/c/src/exec/score/src/wkspace.c @ 8faca06

4.104.114.84.95
Last change on this file since 8faca06 was 8faca06, checked in by Joel Sherrill <joel.sherrill@…>, on 04/22/96 at 16:46:36

thread.c: added support for optional user provided stack allocator

wkspace.c: made initialization routine a regular subroutine

  • Property mode set to 100644
File size: 1.8 KB
Line 
1/*
2 *  Workspace Handler
3 *
4 *  XXX
5 *
6 *  NOTE:
7 *
8 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
9 *  On-Line Applications Research Corporation (OAR).
10 *  All rights assigned to U.S. Government, 1994.
11 *
12 *  This material may be reproduced by or for the U.S. Government pursuant
13 *  to the copyright license under the clause at DFARS 252.227-7013.  This
14 *  notice must appear in all copies of this file and its derivatives.
15 *
16 *  $Id$
17 */
18
19#include <rtems/system.h>
20#include <rtems/score/wkspace.h>
21#include <rtems/score/interr.h>
22
23/*PAGE
24 *
25 *  _Workspace_Handler_initialization
26 */
27 
28void _Workspace_Handler_initialization(
29  void       *starting_address,
30  unsigned32  size
31)
32{
33  unsigned32 *zero_out_array;
34  unsigned32  index;
35  unsigned32  memory_available;
36 
37  if ( !starting_address || !_Addresses_Is_aligned( starting_address ) )
38    _Internal_error_Occurred(
39      INTERNAL_ERROR_CORE,
40      TRUE,
41      INTERNAL_ERROR_INVALID_WORKSPACE_ADDRESS
42    );
43 
44  if ( _CPU_Table.do_zero_of_workspace ) {
45    for( zero_out_array  = (unsigned32 *) starting_address, index = 0 ;
46         index < size / 4 ;
47         index++ )
48      zero_out_array[ index ] = 0;
49  }
50 
51  memory_available = _Heap_Initialize(
52    &_Workspace_Area,
53    starting_address,
54    size,
55    CPU_HEAP_ALIGNMENT
56  );
57 
58  if ( memory_available == 0 )
59    _Internal_error_Occurred(
60      INTERNAL_ERROR_CORE,
61      TRUE,
62      INTERNAL_ERROR_TOO_LITTLE_WORKSPACE
63    );
64}
65
66/*PAGE
67 *
68 *  _Workspace_Allocate_or_fatal_error
69 *
70 */
71
72void *_Workspace_Allocate_or_fatal_error(
73  unsigned32   size
74)
75{
76  void        *memory;
77
78  memory = _Workspace_Allocate( size );
79
80  if ( memory == NULL )
81    _Internal_error_Occurred(
82      INTERNAL_ERROR_CORE,
83      TRUE,
84      INTERNAL_ERROR_WORKSPACE_ALLOCATION
85    );
86
87  return memory;
88}
Note: See TracBrowser for help on using the repository browser.