source: rtems/cpukit/sapi/src/extension.c @ b06e68ef

4.104.114.84.95
Last change on this file since b06e68ef was ac7d5ef0, checked in by Joel Sherrill <joel.sherrill@…>, on 05/11/95 at 17:39:37

Initial revision

  • Property mode set to 100644
File size: 3.6 KB
Line 
1/*
2 *  Extension Manager
3 *
4 *
5 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
6 *  On-Line Applications Research Corporation (OAR).
7 *  All rights assigned to U.S. Government, 1994.
8 *
9 *  This material may be reproduced by or for the U.S. Government pursuant
10 *  to the copyright license under the clause at DFARS 252.227-7013.  This
11 *  notice must appear in all copies of this file and its derivatives.
12 *
13 *  $Id$
14 */
15
16#include <rtems/system.h>
17#include <rtems/object.h>
18#include <rtems/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
33void _Extension_Manager_initialization(
34  unsigned32 maximum_extensions
35)
36{
37  _Objects_Initialize_information(
38     &_Extension_Information,
39     FALSE,
40     maximum_extensions,
41     sizeof( Extension_Control )
42  );
43}
44
45/*PAGE
46 *
47 *  rtems_extension_create
48 *
49 *  This directive creates a extension and performs some initialization.
50 *
51 *  Input parameters:
52 *    name            - extension name
53 *    extension_table - pointer to extension set information
54 *    id              - pointer to extension id
55 *
56 *  Output parameters:
57 *    id                - extension id
58 *    RTEMS_SUCCESSFUL - if successful
59 *    error code        - if unsuccessful
60 */
61
62rtems_status_code rtems_extension_create(
63  Objects_Name                   name,
64  rtems_extensions_table *extension_table,
65  Objects_Id                    *id
66)
67{
68  Extension_Control *the_extension;
69
70  if ( !_Objects_Is_name_valid( name ) )
71    return ( RTEMS_INVALID_NAME );
72
73  _Thread_Disable_dispatch();         /* to prevent deletion */
74
75  the_extension = _Extension_Allocate();
76
77  if ( !the_extension ) {
78    _Thread_Enable_dispatch();
79    return( RTEMS_TOO_MANY );
80  }
81
82  _User_extensions_Add_set( &the_extension->Extension, extension_table );
83
84  _Objects_Open( &_Extension_Information, &the_extension->Object, name );
85
86  *id = the_extension->Object.id;
87  _Thread_Enable_dispatch();
88  return( RTEMS_SUCCESSFUL );
89}
90
91/*PAGE
92 *
93 *  rtems_extension_ident
94 *
95 *  This directive returns the system ID associated with
96 *  the extension name.
97 *
98 *  Input parameters:
99 *    name - user defined message queue name
100 *    id   - pointer to extension id
101 *
102 *  Output parameters:
103 *    *id               - message queue id
104 *    RTEMS_SUCCESSFUL - if successful
105 *    error code        - if unsuccessful
106 */
107
108rtems_status_code rtems_extension_ident(
109  Objects_Name  name,
110  Objects_Id   *id
111)
112{
113  return _Objects_Name_to_id(
114    &_Extension_Information,
115    name,
116    RTEMS_SEARCH_LOCAL_NODE,
117    id
118  );
119}
120
121/*PAGE
122 *
123 *  rtems_extension_delete
124 *
125 *  This directive allows a thread to delete a extension.
126 *
127 *  Input parameters:
128 *    id - extension id
129 *
130 *  Output parameters:
131 *    RTEMS_SUCCESSFUL - if successful
132 *    error code - if unsuccessful
133 */
134
135rtems_status_code rtems_extension_delete(
136  Objects_Id id
137)
138{
139  Extension_Control   *the_extension;
140  Objects_Locations    location;
141
142  the_extension = _Extension_Get( id, &location );
143  switch ( location ) {
144    case OBJECTS_ERROR:
145    case OBJECTS_REMOTE:            /* should never return this */
146      return( RTEMS_INVALID_ID );
147    case OBJECTS_LOCAL:
148      _User_extensions_Remove_set( &the_extension->Extension );
149      _Objects_Close( &_Extension_Information, &the_extension->Object );
150      _Extension_Free( the_extension );
151      _Thread_Enable_dispatch();
152      return( RTEMS_SUCCESSFUL );
153  }
154
155  return( RTEMS_INTERNAL_ERROR );   /* unreached - only to remove warnings */
156}
Note: See TracBrowser for help on using the repository browser.