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

5
Last change on this file since 21275b58 was 21275b58, checked in by Sebastian Huber <sebastian.huber@…>, on 11/22/18 at 18:14:51

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
RevLine 
[4c90eb4]1/**
2 * @file
[842db5f3]3 *
[4c90eb4]4 * @brief RTEMS Partition Create
5 * @ingroup ClassicPart Partitions
6 */
7
8/*
[3a638ce]9 *  COPYRIGHT (c) 1989-2014.
[842db5f3]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
[c499856]14 *  http://www.rtems.org/license/LICENSE.
[842db5f3]15 */
16
[1095ec1]17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
[8695cae]21#include <rtems/rtems/partimpl.h>
[3cf39238]22#include <rtems/rtems/attrimpl.h>
23#include <rtems/rtems/support.h>
24#include <rtems/score/threaddispatch.h>
[842db5f3]25#include <rtems/score/sysstate.h>
[21275b58]26#include <rtems/sysinit.h>
[842db5f3]27
28
29rtems_status_code rtems_partition_create(
[d3b72ca3]30  rtems_name       name,
31  void            *starting_address,
[66cb142]32  uintptr_t        length,
33  size_t           buffer_size,
[d3b72ca3]34  rtems_attribute  attribute_set,
35  rtems_id        *id
[842db5f3]36)
37{
[23fec9f0]38  Partition_Control *the_partition;
[842db5f3]39
40  if ( !rtems_is_name_valid( name ) )
41    return RTEMS_INVALID_NAME;
42
[e980b219]43  if ( !starting_address )
44    return RTEMS_INVALID_ADDRESS;
45
46  if ( !id )
47    return RTEMS_INVALID_ADDRESS;
48
[27bbc05]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 ) )
[842db5f3]62    return RTEMS_INVALID_SIZE;
63
[83ca9f0a]64  if ( !_Partition_Is_buffer_area_aligned( starting_address ) )
65    return RTEMS_INVALID_ADDRESS;
[842db5f3]66
67#if defined(RTEMS_MULTIPROCESSING)
[50f32b11]68  if ( _Attributes_Is_global( attribute_set ) &&
[842db5f3]69       !_System_state_Is_multiprocessing )
70    return RTEMS_MP_NOT_CONFIGURED;
71#endif
72
73  the_partition = _Partition_Allocate();
74
75  if ( !the_partition ) {
[23fec9f0]76    _Objects_Allocator_unlock();
[842db5f3]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,
[eaef4657]83                            the_partition->Object.id, false ) ) ) {
[842db5f3]84    _Partition_Free( the_partition );
[23fec9f0]85    _Objects_Allocator_unlock();
[842db5f3]86    return RTEMS_TOO_MANY;
87  }
88#endif
89
[3570ec6]90  _Partition_Initialize(
91    the_partition,
92    starting_address,
93    length,
94    buffer_size,
95    attribute_set
96  );
[842db5f3]97
[6312db3]98  _Objects_Open(
99    &_Partition_Information,
100    &the_partition->Object,
101    (Objects_Name) name
102  );
[842db5f3]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
[23fec9f0]115  _Objects_Allocator_unlock();
[842db5f3]116  return RTEMS_SUCCESSFUL;
117}
[21275b58]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.