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

4.104.114.84.95
Last change on this file since f26145b was 1095ec1, checked in by Ralf Corsepius <ralf.corsepius@…>, on 01/18/05 at 09:03:45

Include config.h.

  • Property mode set to 100644
File size: 3.4 KB
Line 
1/*
2 *  Partition Manager
3 *
4 *
5 *  COPYRIGHT (c) 1989-1999.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 *
12 *  $Id$
13 */
14
15#if HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#include <rtems/system.h>
20#include <rtems/rtems/status.h>
21#include <rtems/rtems/support.h>
22#include <rtems/score/address.h>
23#include <rtems/score/object.h>
24#include <rtems/rtems/part.h>
25#include <rtems/score/thread.h>
26#include <rtems/score/sysstate.h>
27
28/*PAGE
29 *
30 *  rtems_partition_create
31 *
32 *  This directive creates a partiton of fixed sized buffers from the
33 *  given contiguous memory area.
34 *
35 *  Input parameters:
36 *    name             - user defined partition name
37 *    starting_address - physical start address of partition
38 *    length           - physical length in bytes
39 *    buffer_size      - size of buffers in bytes
40 *    attribute_set    - partition attributes
41 *    id               - pointer to partition id
42 *
43 *  Output parameters:
44 *    id               - partition id
45 *    RTEMS_SUCCESSFUL - if successful
46 *    error code       - if unsuccessful
47 */
48
49rtems_status_code rtems_partition_create(
50  rtems_name          name,
51  void               *starting_address,
52  uint32_t            length,
53  uint32_t            buffer_size,
54  rtems_attribute     attribute_set,
55  Objects_Id         *id
56)
57{
58  register Partition_Control *the_partition;
59
60  if ( !rtems_is_name_valid( name ) )
61    return RTEMS_INVALID_NAME;
62
63  if ( !starting_address )
64    return RTEMS_INVALID_ADDRESS;
65
66  if ( !id )
67    return RTEMS_INVALID_ADDRESS;
68
69  if ( length == 0 || buffer_size == 0 || length < buffer_size ||
70         !_Partition_Is_buffer_size_aligned( buffer_size ) )
71    return RTEMS_INVALID_SIZE;
72
73  if ( !_Addresses_Is_aligned( starting_address ) )
74     return RTEMS_INVALID_ADDRESS;
75
76#if defined(RTEMS_MULTIPROCESSING)
77  if ( _Attributes_Is_global( attribute_set ) &&
78       !_System_state_Is_multiprocessing )
79    return RTEMS_MP_NOT_CONFIGURED;
80#endif
81
82  _Thread_Disable_dispatch();               /* prevents deletion */
83
84  the_partition = _Partition_Allocate();
85
86  if ( !the_partition ) {
87    _Thread_Enable_dispatch();
88    return RTEMS_TOO_MANY;
89  }
90
91#if defined(RTEMS_MULTIPROCESSING)
92  if ( _Attributes_Is_global( attribute_set ) &&
93       !( _Objects_MP_Allocate_and_open( &_Partition_Information, name,
94                            the_partition->Object.id, FALSE ) ) ) {
95    _Partition_Free( the_partition );
96    _Thread_Enable_dispatch();
97    return RTEMS_TOO_MANY;
98  }
99#endif
100
101  the_partition->starting_address      = starting_address;
102  the_partition->length                = length;
103  the_partition->buffer_size           = buffer_size;
104  the_partition->attribute_set         = attribute_set;
105  the_partition->number_of_used_blocks = 0;
106
107  _Chain_Initialize( &the_partition->Memory, starting_address,
108                        length / buffer_size, buffer_size );
109
110  _Objects_Open(
111    &_Partition_Information,
112    &the_partition->Object,
113    (Objects_Name) name
114  );
115
116  *id = the_partition->Object.id;
117#if defined(RTEMS_MULTIPROCESSING)
118  if ( _Attributes_Is_global( attribute_set ) )
119    _Partition_MP_Send_process_packet(
120      PARTITION_MP_ANNOUNCE_CREATE,
121      the_partition->Object.id,
122      name,
123      0                  /* Not used */
124    );
125#endif
126
127  _Thread_Enable_dispatch();
128  return RTEMS_SUCCESSFUL;
129}
Note: See TracBrowser for help on using the repository browser.