source: rtems/cpukit/score/src/wkspace.c @ 7ff6115

4.104.115
Last change on this file since 7ff6115 was 7ff6115, checked in by Joel Sherrill <joel.sherrill@…>, on 11/20/08 at 20:01:13

2008-11-20 Joel Sherrill <joel.sherrill@…>

  • score/include/rtems/score/heap.h, score/include/rtems/score/protectedheap.h, score/include/rtems/score/wkspace.h, score/src/heap.c, score/src/heapallocate.c, score/src/heapallocatealigned.c, score/src/heapextend.c, score/src/heapresizeblock.c, score/src/heapsizeofuserarea.c, score/src/pheapgetblocksize.c, score/src/wkspace.c: Revert use of ssize_t. This type is not guaranteed to be able to represent a positive number greater than the size of a single allocatable object. We needed a type that is able to represent the size of a pool of multiple allocatable objects or potentially nearly all memory.
  • Property mode set to 100644
File size: 1.8 KB
Line 
1/*
2 *  Workspace Handler
3 *
4 *  COPYRIGHT (c) 1989-2007.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#if HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <rtems/system.h>
19#include <rtems/score/wkspace.h>
20#include <rtems/score/interr.h>
21#include <rtems/config.h>
22
23#include <string.h>  /* for memset */
24
25/*
26 *  _Workspace_Handler_initialization
27 */
28void _Workspace_Handler_initialization(
29  void       *starting_address,
30  size_t      size
31)
32{
33  uint32_t    memory_available;
34
35  if ( !starting_address || !_Addresses_Is_aligned( starting_address ) )
36    _Internal_error_Occurred(
37      INTERNAL_ERROR_CORE,
38      TRUE,
39      INTERNAL_ERROR_INVALID_WORKSPACE_ADDRESS
40    );
41
42  if ( _Configuration_Table->do_zero_of_workspace )
43   memset( starting_address, 0, size );
44
45  memory_available = _Heap_Initialize(
46    &_Workspace_Area,
47    starting_address,
48    size,
49    CPU_HEAP_ALIGNMENT
50  );
51
52  if ( memory_available == 0 )
53    _Internal_error_Occurred(
54      INTERNAL_ERROR_CORE,
55      TRUE,
56      INTERNAL_ERROR_TOO_LITTLE_WORKSPACE
57    );
58}
59
60/*
61 *  _Workspace_Allocate
62 */
63void *_Workspace_Allocate(
64  size_t   size
65)
66{
67   return _Heap_Allocate( &_Workspace_Area, size );
68}
69
70/*
71 *  _Workspace_Free
72 */
73bool _Workspace_Free(
74  void *block
75)
76{
77   return _Heap_Free( &_Workspace_Area, block );
78}
79
80/*
81 *  _Workspace_Allocate_or_fatal_error
82 */
83void *_Workspace_Allocate_or_fatal_error(
84  size_t      size
85)
86{
87  void        *memory;
88
89  memory = _Workspace_Allocate( size );
90
91  if ( memory == NULL )
92    _Internal_error_Occurred(
93      INTERNAL_ERROR_CORE,
94      TRUE,
95      INTERNAL_ERROR_WORKSPACE_ALLOCATION
96    );
97
98  return memory;
99}
Note: See TracBrowser for help on using the repository browser.