source: rtems/cpukit/rtems/src/regioncreate.c @ 21275b58

Last change on this file since 21275b58 was 21275b58, checked in by Sebastian Huber <sebastian.huber@…>, on Nov 22, 2018 at 6:14:51 PM

score: Static Objects_Information initialization

Statically allocate the objects information together with the initial
set of objects either via <rtems/confdefs.h>. Provide default object
informations with zero objects via librtemscpu.a. This greatly
simplifies the workspace size estimate. RTEMS applications which do not
use the unlimited objects option are easier to debug since all objects
reside now in statically allocated objects of the right types.

Close #3621.

  • Property mode set to 100644
File size: 2.3 KB
Line 
1/**
2 * @file
3 *
4 * @brief rtems_region_create
5 * @ingroup ClassicRegion Regions
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-1999.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/rtems/regionimpl.h>
22#include <rtems/rtems/attrimpl.h>
23#include <rtems/rtems/support.h>
24#include <rtems/score/apimutex.h>
25#include <rtems/score/threadqimpl.h>
26#include <rtems/sysinit.h>
27
28rtems_status_code rtems_region_create(
29  rtems_name          name,
30  void               *starting_address,
31  uintptr_t           length,
32  uintptr_t           page_size,
33  rtems_attribute     attribute_set,
34  rtems_id           *id
35)
36{
37  rtems_status_code  return_status;
38  Region_Control    *the_region;
39
40  if ( !rtems_is_name_valid( name ) )
41    return RTEMS_INVALID_NAME;
42
43  if ( !starting_address )
44    return RTEMS_INVALID_ADDRESS;
45
46  if ( !id )
47    return RTEMS_INVALID_ADDRESS;
48
49  the_region = _Region_Allocate();
50
51    if ( !the_region )
52      return_status = RTEMS_TOO_MANY;
53
54    else {
55      _Thread_queue_Object_initialize( &the_region->Wait_queue );
56
57      if ( _Attributes_Is_priority( attribute_set ) ) {
58        the_region->wait_operations = &_Thread_queue_Operations_priority;
59      } else {
60        the_region->wait_operations = &_Thread_queue_Operations_FIFO;
61      }
62
63      the_region->maximum_segment_size = _Heap_Initialize(
64        &the_region->Memory, starting_address, length, page_size
65      );
66
67      if ( !the_region->maximum_segment_size ) {
68        _Region_Free( the_region );
69        return_status = RTEMS_INVALID_SIZE;
70      } else {
71        the_region->attribute_set = attribute_set;
72
73        _Objects_Open(
74          &_Region_Information,
75          &the_region->Object,
76          (Objects_Name) name
77        );
78
79        *id = the_region->Object.id;
80        return_status = RTEMS_SUCCESSFUL;
81      }
82    }
83
84  _Objects_Allocator_unlock();
85
86  return return_status;
87}
88
89static void _Region_Manager_initialization( void )
90{
91  _Objects_Initialize_information( &_Region_Information );
92}
93
94RTEMS_SYSINIT_ITEM(
95  _Region_Manager_initialization,
96  RTEMS_SYSINIT_CLASSIC_REGION,
97  RTEMS_SYSINIT_ORDER_MIDDLE
98);
Note: See TracBrowser for help on using the repository browser.