source: rtems/cpukit/sapi/src/extension.c @ 9863dbf

4.104.114.84.95
Last change on this file since 9863dbf was 9863dbf, checked in by Joel Sherrill <joel.sherrill@…>, on Aug 18, 1995 at 9:42:58 PM

+ Added object type field to object id.

+ Added name pointer to Object_Control.

+ Modified Object Open and Close to address name field.

+ Removed name as separate element from Thread and Proxy Control.

+ Added parameter "object class" to calls to Initialize Information

  • 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     OBJECTS_RTEMS_EXTENSIONS,
40     FALSE,
41     maximum_extensions,
42     sizeof( Extension_Control )
43  );
44}
45
46/*PAGE
47 *
48 *  rtems_extension_create
49 *
50 *  This directive creates a extension and performs some initialization.
51 *
52 *  Input parameters:
53 *    name            - extension name
54 *    extension_table - pointer to extension set information
55 *    id              - pointer to extension id
56 *
57 *  Output parameters:
58 *    id                - extension id
59 *    RTEMS_SUCCESSFUL - if successful
60 *    error code        - if unsuccessful
61 */
62
63rtems_status_code rtems_extension_create(
64  Objects_Name                   name,
65  rtems_extensions_table *extension_table,
66  Objects_Id                    *id
67)
68{
69  Extension_Control *the_extension;
70
71  if ( !_Objects_Is_name_valid( name ) )
72    return ( RTEMS_INVALID_NAME );
73
74  _Thread_Disable_dispatch();         /* to prevent deletion */
75
76  the_extension = _Extension_Allocate();
77
78  if ( !the_extension ) {
79    _Thread_Enable_dispatch();
80    return( RTEMS_TOO_MANY );
81  }
82
83  _User_extensions_Add_set( &the_extension->Extension, extension_table );
84
85  _Objects_Open( &_Extension_Information, &the_extension->Object, name );
86
87  *id = the_extension->Object.id;
88  _Thread_Enable_dispatch();
89  return( RTEMS_SUCCESSFUL );
90}
91
92/*PAGE
93 *
94 *  rtems_extension_ident
95 *
96 *  This directive returns the system ID associated with
97 *  the extension name.
98 *
99 *  Input parameters:
100 *    name - user defined message queue name
101 *    id   - pointer to extension id
102 *
103 *  Output parameters:
104 *    *id               - message queue id
105 *    RTEMS_SUCCESSFUL - if successful
106 *    error code        - if unsuccessful
107 */
108
109rtems_status_code rtems_extension_ident(
110  Objects_Name  name,
111  Objects_Id   *id
112)
113{
114  return _Objects_Name_to_id(
115    &_Extension_Information,
116    name,
117    RTEMS_SEARCH_LOCAL_NODE,
118    id
119  );
120}
121
122/*PAGE
123 *
124 *  rtems_extension_delete
125 *
126 *  This directive allows a thread to delete a extension.
127 *
128 *  Input parameters:
129 *    id - extension id
130 *
131 *  Output parameters:
132 *    RTEMS_SUCCESSFUL - if successful
133 *    error code - if unsuccessful
134 */
135
136rtems_status_code rtems_extension_delete(
137  Objects_Id id
138)
139{
140  Extension_Control   *the_extension;
141  Objects_Locations    location;
142
143  the_extension = _Extension_Get( id, &location );
144  switch ( location ) {
145    case OBJECTS_ERROR:
146    case OBJECTS_REMOTE:            /* should never return this */
147      return( RTEMS_INVALID_ID );
148    case OBJECTS_LOCAL:
149      _User_extensions_Remove_set( &the_extension->Extension );
150      _Objects_Close( &_Extension_Information, &the_extension->Object );
151      _Extension_Free( the_extension );
152      _Thread_Enable_dispatch();
153      return( RTEMS_SUCCESSFUL );
154  }
155
156  return( RTEMS_INTERNAL_ERROR );   /* unreached - only to remove warnings */
157}
Note: See TracBrowser for help on using the repository browser.