source: rtems/cpukit/rtems/src/partcreate.c @ b2de426

5
Last change on this file since b2de426 was 66cb142, checked in by Sebastian Huber <sebastian.huber@…>, on 08/06/18 at 08:51:00

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
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>
26
[64adc13]27/*
[842db5f3]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:
[e980b219]42 *    id               - partition id
[842db5f3]43 *    RTEMS_SUCCESSFUL - if successful
[e980b219]44 *    error code       - if unsuccessful
[842db5f3]45 */
46
47rtems_status_code rtems_partition_create(
[d3b72ca3]48  rtems_name       name,
49  void            *starting_address,
[66cb142]50  uintptr_t        length,
51  size_t           buffer_size,
[d3b72ca3]52  rtems_attribute  attribute_set,
53  rtems_id        *id
[842db5f3]54)
55{
[23fec9f0]56  Partition_Control *the_partition;
[842db5f3]57
58  if ( !rtems_is_name_valid( name ) )
59    return RTEMS_INVALID_NAME;
60
[e980b219]61  if ( !starting_address )
62    return RTEMS_INVALID_ADDRESS;
63
64  if ( !id )
65    return RTEMS_INVALID_ADDRESS;
66
[27bbc05]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 ) )
[842db5f3]80    return RTEMS_INVALID_SIZE;
81
[83ca9f0a]82  if ( !_Partition_Is_buffer_area_aligned( starting_address ) )
83    return RTEMS_INVALID_ADDRESS;
[842db5f3]84
85#if defined(RTEMS_MULTIPROCESSING)
[50f32b11]86  if ( _Attributes_Is_global( attribute_set ) &&
[842db5f3]87       !_System_state_Is_multiprocessing )
88    return RTEMS_MP_NOT_CONFIGURED;
89#endif
90
91  the_partition = _Partition_Allocate();
92
93  if ( !the_partition ) {
[23fec9f0]94    _Objects_Allocator_unlock();
[842db5f3]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,
[eaef4657]101                            the_partition->Object.id, false ) ) ) {
[842db5f3]102    _Partition_Free( the_partition );
[23fec9f0]103    _Objects_Allocator_unlock();
[842db5f3]104    return RTEMS_TOO_MANY;
105  }
106#endif
107
[3570ec6]108  _Partition_Initialize(
109    the_partition,
110    starting_address,
111    length,
112    buffer_size,
113    attribute_set
114  );
[842db5f3]115
[6312db3]116  _Objects_Open(
117    &_Partition_Information,
118    &the_partition->Object,
119    (Objects_Name) name
120  );
[842db5f3]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
[23fec9f0]133  _Objects_Allocator_unlock();
[842db5f3]134  return RTEMS_SUCCESSFUL;
135}
Note: See TracBrowser for help on using the repository browser.