OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [exec/] [rtems/] [src/] [regioncreate.c] - Blame information for rev 173

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
2
 *  Region 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.OARcorp.com/rtems/license.html.
11
 *
12
 *  $Id: regioncreate.c,v 1.2 2001-09-27 11:59:19 chris Exp $
13
 */
14
 
15
#include <rtems/system.h>
16
#include <rtems/rtems/status.h>
17
#include <rtems/rtems/support.h>
18
#include <rtems/score/object.h>
19
#include <rtems/rtems/options.h>
20
#include <rtems/rtems/region.h>
21
#include <rtems/score/states.h>
22
#include <rtems/score/thread.h>
23
 
24
/*PAGE
25
 *
26
 *  rtems_region_create
27
 *
28
 *  This directive creates a region of physical contiguous memory area
29
 *  from which variable sized segments can be allocated.
30
 *
31
 *  Input parameters:
32
 *    name             - user defined region name
33
 *    starting_address - physical start address of region
34
 *    length           - physical length in bytes
35
 *    page_size        - page size in bytes
36
 *    attribute_set    - region attributes
37
 *    id               - address of region id to set
38
 *
39
 *  Output parameters:
40
 *    id       - region id
41
 *    RTEMS_SUCCESSFUL - if successful
42
 *    error code - if unsuccessful
43
 */
44
 
45
rtems_status_code rtems_region_create(
46
  rtems_name          name,
47
  void               *starting_address,
48
  unsigned32          length,
49
  unsigned32          page_size,
50
  rtems_attribute  attribute_set,
51
  Objects_Id         *id
52
)
53
{
54
  Region_Control *the_region;
55
 
56
  if ( !rtems_is_name_valid( name ) )
57
    return RTEMS_INVALID_NAME;
58
 
59
  if ( !_Addresses_Is_aligned( starting_address ) )
60
    return RTEMS_INVALID_ADDRESS;
61
 
62
  _Thread_Disable_dispatch();             /* to prevent deletion */
63
 
64
  the_region = _Region_Allocate();
65
 
66
  if ( !the_region ) {
67
    _Thread_Enable_dispatch();
68
    return RTEMS_TOO_MANY;
69
  }
70
 
71
  the_region->maximum_segment_size =
72
    _Heap_Initialize(&the_region->Memory, starting_address, length, page_size);
73
 
74
  if ( !the_region->maximum_segment_size ) {
75
    _Region_Free( the_region );
76
    _Thread_Enable_dispatch();
77
    return RTEMS_INVALID_SIZE;
78
  }
79
 
80
  the_region->starting_address      = starting_address;
81
  the_region->length                = length;
82
  the_region->page_size             = page_size;
83
  the_region->attribute_set         = attribute_set;
84
  the_region->number_of_used_blocks = 0;
85
 
86
  _Thread_queue_Initialize(
87
    &the_region->Wait_queue,
88
    OBJECTS_RTEMS_REGIONS,
89
    _Attributes_Is_priority( attribute_set ) ?
90
       THREAD_QUEUE_DISCIPLINE_PRIORITY : THREAD_QUEUE_DISCIPLINE_FIFO,
91
    STATES_WAITING_FOR_SEGMENT,
92
#if defined(RTEMS_MULTIPROCESSING)
93
    _Region_MP_Send_extract_proxy,
94
#else
95
    NULL,
96
#endif
97
    RTEMS_TIMEOUT
98
  );
99
 
100
  _Objects_Open( &_Region_Information, &the_region->Object, &name );
101
 
102
  *id = the_region->Object.id;
103
  _Thread_Enable_dispatch();
104
  return RTEMS_SUCCESSFUL;
105
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.