source: rtems/cpukit/rtems/src/regioncreate.c @ f7ba2945

5
Last change on this file since f7ba2945 was e366f77, checked in by Sebastian Huber <sebastian.huber@…>, on 01/31/17 at 07:08:24

score: Add _Thread_queue_Object_name

Add the special thread queue name _Thread_queue_Object_name to mark
thread queues embedded in an object with identifier. Using the special
thread state STATES_THREAD_QUEUE_WITH_IDENTIFIER is not reliable for
this purpose since the thread wait information and thread state are
protected by different SMP locks in separate critical sections. Remove
STATES_THREAD_QUEUE_WITH_IDENTIFIER.

Add and use _Thread_queue_Object_initialize().

Update #2858.

  • Property mode set to 100644
File size: 2.6 KB
Line 
1/**
2 * @file
3 *
4 * @brief rtems_region_create
5 * @ingroup ClassicRegion Regions
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-1999.
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/regionimpl.h>
22#include <rtems/rtems/attrimpl.h>
23#include <rtems/rtems/support.h>
24#include <rtems/score/apimutex.h>
25#include <rtems/score/threadqimpl.h>
26
27/*
28 *  rtems_region_create
29 *
30 *  This directive creates a region of physical contiguous memory area
31 *  from which variable sized segments can be allocated.
32 *
33 *  Input parameters:
34 *    name             - user defined region name
35 *    starting_address - physical start address of region
36 *    length           - physical length in bytes
37 *    page_size        - page size in bytes
38 *    attribute_set    - region attributes
39 *    id               - address of region id to set
40 *
41 *  Output parameters:
42 *    id               - region id
43 *    RTEMS_SUCCESSFUL - if successful
44 *    error code       - if unsuccessful
45 */
46
47rtems_status_code rtems_region_create(
48  rtems_name          name,
49  void               *starting_address,
50  uintptr_t           length,
51  uintptr_t           page_size,
52  rtems_attribute     attribute_set,
53  rtems_id           *id
54)
55{
56  rtems_status_code  return_status;
57  Region_Control    *the_region;
58
59  if ( !rtems_is_name_valid( name ) )
60    return RTEMS_INVALID_NAME;
61
62  if ( !starting_address )
63    return RTEMS_INVALID_ADDRESS;
64
65  if ( !id )
66    return RTEMS_INVALID_ADDRESS;
67
68  the_region = _Region_Allocate();
69
70    if ( !the_region )
71      return_status = RTEMS_TOO_MANY;
72
73    else {
74      _Thread_queue_Object_initialize( &the_region->Wait_queue );
75
76      if ( _Attributes_Is_priority( attribute_set ) ) {
77        the_region->wait_operations = &_Thread_queue_Operations_priority;
78      } else {
79        the_region->wait_operations = &_Thread_queue_Operations_FIFO;
80      }
81
82      the_region->maximum_segment_size = _Heap_Initialize(
83        &the_region->Memory, starting_address, length, page_size
84      );
85
86      if ( !the_region->maximum_segment_size ) {
87        _Region_Free( the_region );
88        return_status = RTEMS_INVALID_SIZE;
89      } else {
90        the_region->attribute_set = attribute_set;
91
92        _Objects_Open(
93          &_Region_Information,
94          &the_region->Object,
95          (Objects_Name) name
96        );
97
98        *id = the_region->Object.id;
99        return_status = RTEMS_SUCCESSFUL;
100      }
101    }
102
103  _Objects_Allocator_unlock();
104
105  return return_status;
106}
Note: See TracBrowser for help on using the repository browser.