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

Last change on this file since e366f77 was e366f77, checked in by Sebastian Huber <sebastian.huber@…>, on Jan 31, 2017 at 7:08:24 AM

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
RevLine 
[4efe1955]1/**
2 * @file
[5aa64518]3 *
[4efe1955]4 * @brief rtems_region_create
5 * @ingroup ClassicRegion Regions
6 */
7
8/*
[08311cc3]9 *  COPYRIGHT (c) 1989-1999.
[5aa64518]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.
[5aa64518]15 */
16
[1095ec1]17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
[fe6c170c]21#include <rtems/rtems/regionimpl.h>
[63d229d]22#include <rtems/rtems/attrimpl.h>
[5aa64518]23#include <rtems/rtems/support.h>
[90015e7f]24#include <rtems/score/apimutex.h>
[a112364]25#include <rtems/score/threadqimpl.h>
[5aa64518]26
[64adc13]27/*
[5aa64518]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:
[e980b219]42 *    id               - region id
[5aa64518]43 *    RTEMS_SUCCESSFUL - if successful
[e980b219]44 *    error code       - if unsuccessful
[5aa64518]45 */
46
47rtems_status_code rtems_region_create(
48  rtems_name          name,
49  void               *starting_address,
[dea3eccb]50  uintptr_t           length,
51  uintptr_t           page_size,
[e980b219]52  rtems_attribute     attribute_set,
[d3b72ca3]53  rtems_id           *id
[5aa64518]54)
55{
[5700b804]56  rtems_status_code  return_status;
57  Region_Control    *the_region;
[5aa64518]58
59  if ( !rtems_is_name_valid( name ) )
60    return RTEMS_INVALID_NAME;
61
[e980b219]62  if ( !starting_address )
63    return RTEMS_INVALID_ADDRESS;
64
65  if ( !id )
66    return RTEMS_INVALID_ADDRESS;
67
[23fec9f]68  the_region = _Region_Allocate();
[5700b804]69
70    if ( !the_region )
71      return_status = RTEMS_TOO_MANY;
72
73    else {
[e366f77]74      _Thread_queue_Object_initialize( &the_region->Wait_queue );
[1e1a91e]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      }
[5700b804]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;
[02c4c441]89      } else {
[acf7cf3b]90        the_region->attribute_set = attribute_set;
[5700b804]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
[23fec9f]103  _Objects_Allocator_unlock();
104
[5700b804]105  return return_status;
[5aa64518]106}
Note: See TracBrowser for help on using the repository browser.