source: rtems/cpukit/rtems/src/partcreate.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: 3.1 KB
Line 
1/**
2 * @file
3 *
4 * @brief RTEMS Partition Create
5 * @ingroup ClassicPart Partitions
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2014.
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/partimpl.h>
22#include <rtems/rtems/attrimpl.h>
23#include <rtems/rtems/support.h>
24#include <rtems/score/threaddispatch.h>
25#include <rtems/score/sysstate.h>
26#include <rtems/sysinit.h>
27
28
29rtems_status_code rtems_partition_create(
30  rtems_name       name,
31  void            *starting_address,
32  uintptr_t        length,
33  size_t           buffer_size,
34  rtems_attribute  attribute_set,
35  rtems_id        *id
36)
37{
38  Partition_Control *the_partition;
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  if ( length == 0 )
50    return RTEMS_INVALID_SIZE;
51
52  if ( buffer_size == 0 )
53    return RTEMS_INVALID_SIZE;
54
55  if ( length < buffer_size )
56    return RTEMS_INVALID_SIZE;
57
58  if ( !_Partition_Is_buffer_size_aligned( buffer_size ) )
59    return RTEMS_INVALID_SIZE;
60
61  if ( buffer_size < sizeof( Chain_Node ) )
62    return RTEMS_INVALID_SIZE;
63
64  if ( !_Partition_Is_buffer_area_aligned( starting_address ) )
65    return RTEMS_INVALID_ADDRESS;
66
67#if defined(RTEMS_MULTIPROCESSING)
68  if ( _Attributes_Is_global( attribute_set ) &&
69       !_System_state_Is_multiprocessing )
70    return RTEMS_MP_NOT_CONFIGURED;
71#endif
72
73  the_partition = _Partition_Allocate();
74
75  if ( !the_partition ) {
76    _Objects_Allocator_unlock();
77    return RTEMS_TOO_MANY;
78  }
79
80#if defined(RTEMS_MULTIPROCESSING)
81  if ( _Attributes_Is_global( attribute_set ) &&
82       !( _Objects_MP_Allocate_and_open( &_Partition_Information, name,
83                            the_partition->Object.id, false ) ) ) {
84    _Partition_Free( the_partition );
85    _Objects_Allocator_unlock();
86    return RTEMS_TOO_MANY;
87  }
88#endif
89
90  _Partition_Initialize(
91    the_partition,
92    starting_address,
93    length,
94    buffer_size,
95    attribute_set
96  );
97
98  _Objects_Open(
99    &_Partition_Information,
100    &the_partition->Object,
101    (Objects_Name) name
102  );
103
104  *id = the_partition->Object.id;
105#if defined(RTEMS_MULTIPROCESSING)
106  if ( _Attributes_Is_global( attribute_set ) )
107    _Partition_MP_Send_process_packet(
108      PARTITION_MP_ANNOUNCE_CREATE,
109      the_partition->Object.id,
110      name,
111      0                  /* Not used */
112    );
113#endif
114
115  _Objects_Allocator_unlock();
116  return RTEMS_SUCCESSFUL;
117}
118
119static void _Partition_Manager_initialization(void)
120{
121  _Objects_Initialize_information( &_Partition_Information );
122
123  /*
124   *  Register the MP Process Packet routine.
125   */
126
127#if defined(RTEMS_MULTIPROCESSING)
128  _MPCI_Register_packet_processor(
129    MP_PACKET_PARTITION,
130    _Partition_MP_Process_packet
131  );
132#endif
133
134}
135
136RTEMS_SYSINIT_ITEM(
137  _Partition_Manager_initialization,
138  RTEMS_SYSINIT_CLASSIC_PARTITION,
139  RTEMS_SYSINIT_ORDER_MIDDLE
140);
Note: See TracBrowser for help on using the repository browser.