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

4.115
Last change on this file since e6b31b27 was f5d6c8b, checked in by Sebastian Huber <sebastian.huber@…>, on 04/27/15 at 14:25:52

score: Delete Thread_queue_Control::timeout_status

Use a parameter for _Thread_queue_Enqueue() instead to reduce memory
usage.

  • Property mode set to 100644
File size: 2.7 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_Initialize(
75        &the_region->Wait_queue,
76        _Attributes_Is_priority( attribute_set ) ?
77           THREAD_QUEUE_DISCIPLINE_PRIORITY : THREAD_QUEUE_DISCIPLINE_FIFO
78      );
79
80      the_region->maximum_segment_size = _Heap_Initialize(
81        &the_region->Memory, starting_address, length, page_size
82      );
83
84      if ( !the_region->maximum_segment_size ) {
85        _Region_Free( the_region );
86        return_status = RTEMS_INVALID_SIZE;
87      } else {
88        the_region->starting_address      = starting_address;
89        the_region->length                = length;
90        the_region->page_size             = page_size;
91        the_region->attribute_set         = attribute_set;
92        the_region->number_of_used_blocks = 0;
93
94        _Objects_Open(
95          &_Region_Information,
96          &the_region->Object,
97          (Objects_Name) name
98        );
99
100        *id = the_region->Object.id;
101        return_status = RTEMS_SUCCESSFUL;
102      }
103    }
104
105  _Objects_Allocator_unlock();
106
107  return return_status;
108}
Note: See TracBrowser for help on using the repository browser.