source: rtems/cpukit/rtems/src/regioncreate.c @ 4efe1955

4.115
Last change on this file since 4efe1955 was 4efe1955, checked in by Mathew Kallada <matkallada@…>, on 12/06/12 at 00:46:05

rtems misc: Clean up Doxygen GCI Task #5

http://www.google-melange.com/gci/task/view/google/gci2012/8015207

  • Property mode set to 100644
File size: 3.0 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.com/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/system.h>
22#include <rtems/rtems/status.h>
23#include <rtems/rtems/support.h>
24#include <rtems/score/object.h>
25#include <rtems/rtems/options.h>
26#include <rtems/rtems/region.h>
27#include <rtems/score/states.h>
28#include <rtems/score/thread.h>
29#include <rtems/score/apimutex.h>
30
31/*
32 *  rtems_region_create
33 *
34 *  This directive creates a region of physical contiguous memory area
35 *  from which variable sized segments can be allocated.
36 *
37 *  Input parameters:
38 *    name             - user defined region name
39 *    starting_address - physical start address of region
40 *    length           - physical length in bytes
41 *    page_size        - page size in bytes
42 *    attribute_set    - region attributes
43 *    id               - address of region id to set
44 *
45 *  Output parameters:
46 *    id               - region id
47 *    RTEMS_SUCCESSFUL - if successful
48 *    error code       - if unsuccessful
49 */
50
51rtems_status_code rtems_region_create(
52  rtems_name          name,
53  void               *starting_address,
54  uintptr_t           length,
55  uintptr_t           page_size,
56  rtems_attribute     attribute_set,
57  rtems_id           *id
58)
59{
60  rtems_status_code  return_status;
61  Region_Control    *the_region;
62
63  if ( !rtems_is_name_valid( name ) )
64    return RTEMS_INVALID_NAME;
65
66  if ( !starting_address )
67    return RTEMS_INVALID_ADDRESS;
68
69  if ( !id )
70    return RTEMS_INVALID_ADDRESS;
71
72  _RTEMS_Lock_allocator();                      /* to prevent deletion */
73
74    the_region = _Region_Allocate();
75
76    if ( !the_region )
77      return_status = RTEMS_TOO_MANY;
78
79    else {
80
81      the_region->maximum_segment_size = _Heap_Initialize(
82        &the_region->Memory, starting_address, length, page_size
83      );
84
85      if ( !the_region->maximum_segment_size ) {
86        _Region_Free( the_region );
87        return_status = RTEMS_INVALID_SIZE;
88      }
89
90      else {
91
92        the_region->starting_address      = starting_address;
93        the_region->length                = length;
94        the_region->page_size             = page_size;
95        the_region->attribute_set         = attribute_set;
96        the_region->number_of_used_blocks = 0;
97
98        _Thread_queue_Initialize(
99          &the_region->Wait_queue,
100          _Attributes_Is_priority( attribute_set ) ?
101             THREAD_QUEUE_DISCIPLINE_PRIORITY : THREAD_QUEUE_DISCIPLINE_FIFO,
102          STATES_WAITING_FOR_SEGMENT,
103          RTEMS_TIMEOUT
104        );
105
106        _Objects_Open(
107          &_Region_Information,
108          &the_region->Object,
109          (Objects_Name) name
110        );
111
112        *id = the_region->Object.id;
113        return_status = RTEMS_SUCCESSFUL;
114      }
115    }
116
117  _RTEMS_Unlock_allocator();
118  return return_status;
119}
Note: See TracBrowser for help on using the repository browser.