RTEMS
partcreate.c
Go to the documentation of this file.
1 
9 /*
10  * COPYRIGHT (c) 1989-2014.
11  * On-Line Applications Research Corporation (OAR).
12  *
13  * The license and distribution terms for this file may be
14  * found in the file LICENSE in this distribution or at
15  * http://www.rtems.org/license/LICENSE.
16  */
17 
18 #ifdef HAVE_CONFIG_H
19 #include "config.h"
20 #endif
21 
22 #include <rtems/rtems/partimpl.h>
23 #include <rtems/rtems/attrimpl.h>
24 #include <rtems/rtems/support.h>
26 #include <rtems/score/sysstate.h>
27 #include <rtems/sysinit.h>
28 
29 
31  rtems_name name,
32  void *starting_address,
33  uintptr_t length,
34  size_t buffer_size,
35  rtems_attribute attribute_set,
36  rtems_id *id
37 )
38 {
39  Partition_Control *the_partition;
40 
41  if ( !rtems_is_name_valid( name ) ) {
42  return RTEMS_INVALID_NAME;
43  }
44 
45  if ( id == NULL ) {
46  return RTEMS_INVALID_ADDRESS;
47  }
48 
49  if ( starting_address == NULL ) {
50  return RTEMS_INVALID_ADDRESS;
51  }
52 
53  if ( length == 0 )
54  return RTEMS_INVALID_SIZE;
55 
56  if ( buffer_size == 0 )
57  return RTEMS_INVALID_SIZE;
58 
59  if ( length < buffer_size )
60  return RTEMS_INVALID_SIZE;
61 
62  if ( !_Partition_Is_buffer_size_aligned( buffer_size ) )
63  return RTEMS_INVALID_SIZE;
64 
65  if ( buffer_size < sizeof( Chain_Node ) )
66  return RTEMS_INVALID_SIZE;
67 
68  if ( !_Partition_Is_buffer_area_aligned( starting_address ) )
69  return RTEMS_INVALID_ADDRESS;
70 
71 #if defined(RTEMS_MULTIPROCESSING)
72  if ( !_System_state_Is_multiprocessing ) {
73  attribute_set = _Attributes_Clear( attribute_set, RTEMS_GLOBAL );
74  }
75 #endif
76 
77  the_partition = _Partition_Allocate();
78 
79  if ( !the_partition ) {
81  return RTEMS_TOO_MANY;
82  }
83 
84 #if defined(RTEMS_MULTIPROCESSING)
85  if ( _Attributes_Is_global( attribute_set ) &&
86  !( _Objects_MP_Allocate_and_open( &_Partition_Information, name,
87  the_partition->Object.id, false ) ) ) {
88  _Partition_Free( the_partition );
90  return RTEMS_TOO_MANY;
91  }
92 #endif
93 
94  _Partition_Initialize(
95  the_partition,
96  starting_address,
97  length,
98  buffer_size,
99  attribute_set
100  );
101 
104  &the_partition->Object,
105  (Objects_Name) name
106  );
107 
108  *id = the_partition->Object.id;
109 #if defined(RTEMS_MULTIPROCESSING)
110  if ( _Attributes_Is_global( attribute_set ) )
111  _Partition_MP_Send_process_packet(
112  PARTITION_MP_ANNOUNCE_CREATE,
113  the_partition->Object.id,
114  name,
115  0 /* Not used */
116  );
117 #endif
118 
120  return RTEMS_SUCCESSFUL;
121 }
122 
123 static void _Partition_Manager_initialization( void )
124 {
126 }
127 
128 RTEMS_SYSINIT_ITEM(
129  _Partition_Manager_initialization,
130  RTEMS_SYSINIT_CLASSIC_PARTITION,
131  RTEMS_SYSINIT_ORDER_MIDDLE
132 );
This status code indicates you have attempted to create too many instances of a particular object cla...
Definition: status.h:112
static __inline__ void _Objects_Allocator_unlock(void)
Unlocks the object allocator mutex.
Definition: objectimpl.h:846
This header file defines support services of the API.
Objects_Control Object
Definition: partdata.h:39
Objects_Information _Partition_Information
The Classic Partition objects information.
Definition: part.c:47
uint32_t rtems_name
This type is used to represent a Classic API object name.
Definition: types.h:227
void _Objects_Initialize_information(Objects_Information *information)
Initializes the specified objects information.
Constants and Structures Related with Thread Dispatch.
static bool rtems_is_name_valid(rtems_status_code name)
Returns true, if the specified object name is valid, otherwise returns false.
Definition: support.h:126
rtems_status_code rtems_partition_create(rtems_name name, void *starting_address, uintptr_t length, size_t buffer_size, rtems_attribute attribute_set, rtems_id *id)
Creates a partition.
Definition: partcreate.c:30
This status code indicates successful completion.
Definition: status.h:86
static __inline__ void _Objects_Open(Objects_Information *information, Objects_Control *the_object, Objects_Name name)
Places the_object control pointer and object name in the Local Pointer and Local Name Tables...
Definition: objectimpl.h:750
rtems_status_code
This enumeration provides status codes for directives of the Classic API.
Definition: status.h:82
This status code indicates that a specified address was invalid.
Definition: status.h:133
uint32_t rtems_attribute
This type is used to represent Classic API attributes.
Definition: attr.h:91
Classic Attributes Implementation.
Objects_Id rtems_id
Values of this type identify an RTEMS object.
Definition: types.h:99
System State Handler API.
RTEMS_INLINE_ROUTINE rtems_attribute _Attributes_Clear(rtems_attribute attribute_set, rtems_attribute mask)
Clears the requested new_attributes in the attribute_set passed in.
Definition: attrimpl.h:75
Classic Partition Manager Implementation.
static __inline__ Partition_Control * _Partition_Allocate(void)
Allocates a partition control block from the inactive chain of free partition control blocks...
Definition: partimpl.h:129
This status code indicates that an object name was invalid.
Definition: status.h:101
static __inline__ void _Partition_Free(Partition_Control *the_partition)
Frees a partition control block to the inactive chain of free partition control blocks.
Definition: partimpl.h:172
#define RTEMS_GLOBAL
This attribute constant indicates that the Classic API object shall be a global resource in a multipr...
Definition: attr.h:173
This status code indicates that a specified size was invalid.
Definition: status.h:128
Objects_Id id
Definition: objectdata.h:43