source: rtems/cpukit/rtems/src/partcreate.c @ 66cb142

Last change on this file since 66cb142 was 66cb142, checked in by Sebastian Huber <sebastian.huber@…>, on Aug 6, 2018 at 8:51:00 AM

rtems: Parameter types in rtems_partition_create()

Use uintptr_t to specify the length of the partition buffer area instead
of uint32_t. This is in line with rtems_region_create(). On 64-bit
targets, the length may exceed 4GiB. Use size_t for the buffer size,
since on some targets the single object size is less than the overall
address range, e.g. m32c sizeof(uintptr_t) > sizeof(size_t).

Update #3486.

  • Property mode set to 100644
File size: 3.2 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
27/*
28 *  rtems_partition_create
29 *
30 *  This directive creates a partiton of fixed sized buffers from the
31 *  given contiguous memory area.
32 *
33 *  Input parameters:
34 *    name             - user defined partition name
35 *    starting_address - physical start address of partition
36 *    length           - physical length in bytes
37 *    buffer_size      - size of buffers in bytes
38 *    attribute_set    - partition attributes
39 *    id               - pointer to partition id
40 *
41 *  Output parameters:
42 *    id               - partition id
43 *    RTEMS_SUCCESSFUL - if successful
44 *    error code       - if unsuccessful
45 */
46
47rtems_status_code rtems_partition_create(
48  rtems_name       name,
49  void            *starting_address,
50  uintptr_t        length,
51  size_t           buffer_size,
52  rtems_attribute  attribute_set,
53  rtems_id        *id
54)
55{
56  Partition_Control *the_partition;
57
58  if ( !rtems_is_name_valid( name ) )
59    return RTEMS_INVALID_NAME;
60
61  if ( !starting_address )
62    return RTEMS_INVALID_ADDRESS;
63
64  if ( !id )
65    return RTEMS_INVALID_ADDRESS;
66
67  if ( length == 0 )
68    return RTEMS_INVALID_SIZE;
69
70  if ( buffer_size == 0 )
71    return RTEMS_INVALID_SIZE;
72
73  if ( length < buffer_size )
74    return RTEMS_INVALID_SIZE;
75
76  if ( !_Partition_Is_buffer_size_aligned( buffer_size ) )
77    return RTEMS_INVALID_SIZE;
78
79  if ( buffer_size < sizeof( Chain_Node ) )
80    return RTEMS_INVALID_SIZE;
81
82  if ( !_Partition_Is_buffer_area_aligned( starting_address ) )
83    return RTEMS_INVALID_ADDRESS;
84
85#if defined(RTEMS_MULTIPROCESSING)
86  if ( _Attributes_Is_global( attribute_set ) &&
87       !_System_state_Is_multiprocessing )
88    return RTEMS_MP_NOT_CONFIGURED;
89#endif
90
91  the_partition = _Partition_Allocate();
92
93  if ( !the_partition ) {
94    _Objects_Allocator_unlock();
95    return RTEMS_TOO_MANY;
96  }
97
98#if defined(RTEMS_MULTIPROCESSING)
99  if ( _Attributes_Is_global( attribute_set ) &&
100       !( _Objects_MP_Allocate_and_open( &_Partition_Information, name,
101                            the_partition->Object.id, false ) ) ) {
102    _Partition_Free( the_partition );
103    _Objects_Allocator_unlock();
104    return RTEMS_TOO_MANY;
105  }
106#endif
107
108  _Partition_Initialize(
109    the_partition,
110    starting_address,
111    length,
112    buffer_size,
113    attribute_set
114  );
115
116  _Objects_Open(
117    &_Partition_Information,
118    &the_partition->Object,
119    (Objects_Name) name
120  );
121
122  *id = the_partition->Object.id;
123#if defined(RTEMS_MULTIPROCESSING)
124  if ( _Attributes_Is_global( attribute_set ) )
125    _Partition_MP_Send_process_packet(
126      PARTITION_MP_ANNOUNCE_CREATE,
127      the_partition->Object.id,
128      name,
129      0                  /* Not used */
130    );
131#endif
132
133  _Objects_Allocator_unlock();
134  return RTEMS_SUCCESSFUL;
135}
Note: See TracBrowser for help on using the repository browser.