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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [exec/] [sapi/] [src/] [extension.c] - Blame information for rev 532

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
2
 *  Extension 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: extension.c,v 1.2 2001-09-27 11:59:20 chris Exp $
13
 */
14
 
15
#include <rtems/system.h>
16
#include <rtems/rtems/support.h>
17
#include <rtems/score/object.h>
18
#include <rtems/score/thread.h>
19
#include <rtems/extension.h>
20
 
21
/*PAGE
22
 *
23
 *  _Extension_Manager_initialization
24
 *
25
 *  This routine initializes all extension manager related data structures.
26
 *
27
 *  Input parameters:
28
 *    maximum_extensions - number of extensions to initialize
29
 *
30
 *  Output parameters:  NONE
31
 */
32
 
33
void _Extension_Manager_initialization(
34
  unsigned32 maximum_extensions
35
)
36
{
37
  _Objects_Initialize_information(
38
    &_Extension_Information,
39
    OBJECTS_RTEMS_EXTENSIONS,
40
    FALSE,
41
    maximum_extensions,
42
    sizeof( Extension_Control ),
43
    FALSE,
44
    RTEMS_MAXIMUM_NAME_LENGTH,
45
    FALSE
46
  );
47
}
48
 
49
/*PAGE
50
 *
51
 *  rtems_extension_create
52
 *
53
 *  This directive creates a extension and performs some initialization.
54
 *
55
 *  Input parameters:
56
 *    name            - extension name
57
 *    extension_table - pointer to extension set information
58
 *    id              - pointer to extension id
59
 *
60
 *  Output parameters:
61
 *    id                - extension id
62
 *    RTEMS_SUCCESSFUL - if successful
63
 *    error code        - if unsuccessful
64
 */
65
 
66
rtems_status_code rtems_extension_create(
67
  rtems_name              name,
68
  rtems_extensions_table *extension_table,
69
  Objects_Id             *id
70
)
71
{
72
  Extension_Control *the_extension;
73
 
74
  if ( !rtems_is_name_valid( name ) )
75
    return RTEMS_INVALID_NAME;
76
 
77
  _Thread_Disable_dispatch();         /* to prevent deletion */
78
 
79
  the_extension = _Extension_Allocate();
80
 
81
  if ( !the_extension ) {
82
    _Thread_Enable_dispatch();
83
    return RTEMS_TOO_MANY;
84
  }
85
 
86
  _User_extensions_Add_set( &the_extension->Extension, extension_table );
87
 
88
  _Objects_Open( &_Extension_Information, &the_extension->Object, &name );
89
 
90
  *id = the_extension->Object.id;
91
  _Thread_Enable_dispatch();
92
  return RTEMS_SUCCESSFUL;
93
}
94
 
95
/*PAGE
96
 *
97
 *  rtems_extension_ident
98
 *
99
 *  This directive returns the system ID associated with
100
 *  the extension name.
101
 *
102
 *  Input parameters:
103
 *    name - user defined message queue name
104
 *    id   - pointer to extension id
105
 *
106
 *  Output parameters:
107
 *    *id               - message queue id
108
 *    RTEMS_SUCCESSFUL - if successful
109
 *    error code        - if unsuccessful
110
 */
111
 
112
rtems_status_code rtems_extension_ident(
113
  rtems_name    name,
114
  Objects_Id   *id
115
)
116
{
117
  Objects_Name_to_id_errors  status;
118
 
119
  status = _Objects_Name_to_id(
120
    &_Extension_Information,
121
    &name,
122
    OBJECTS_SEARCH_LOCAL_NODE,
123
    id
124
  );
125
 
126
  return _Status_Object_name_errors_to_status[ status ];
127
}
128
 
129
/*PAGE
130
 *
131
 *  rtems_extension_delete
132
 *
133
 *  This directive allows a thread to delete a extension.
134
 *
135
 *  Input parameters:
136
 *    id - extension id
137
 *
138
 *  Output parameters:
139
 *    RTEMS_SUCCESSFUL - if successful
140
 *    error code - if unsuccessful
141
 */
142
 
143
rtems_status_code rtems_extension_delete(
144
  Objects_Id id
145
)
146
{
147
  Extension_Control   *the_extension;
148
  Objects_Locations    location;
149
 
150
  the_extension = _Extension_Get( id, &location );
151
  switch ( location ) {
152
    case OBJECTS_ERROR:
153
    case OBJECTS_REMOTE:            /* should never return this */
154
      return RTEMS_INVALID_ID;
155
    case OBJECTS_LOCAL:
156
      _User_extensions_Remove_set( &the_extension->Extension );
157
      _Objects_Close( &_Extension_Information, &the_extension->Object );
158
      _Extension_Free( the_extension );
159
      _Thread_Enable_dispatch();
160
      return RTEMS_SUCCESSFUL;
161
  }
162
 
163
  return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
164
}

powered by: WebSVN 2.1.0

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