source: rtems/cpukit/sapi/src/extension.c @ 3235ad9

4.104.114.84.95
Last change on this file since 3235ad9 was 3235ad9, checked in by Joel Sherrill <joel.sherrill@…>, on Aug 23, 1995 at 7:30:23 PM

Support for variable length names added to Object Handler. This supports
both fixed length "raw" names and strings from the API's point of view.

Both inline and macro implementations were tested.

  • Property mode set to 100644
File size: 3.7 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/support.h>
18#include <rtems/object.h>
19#include <rtems/thread.h>
20#include <rtems/extension.h>
21
22/*PAGE
23 *
24 *  _Extension_Manager_initialization
25 *
26 *  This routine initializes all extension manager related data structures.
27 *
28 *  Input parameters:
29 *    maximum_extensions - number of extensions to initialize
30 *
31 *  Output parameters:  NONE
32 */
33
34void _Extension_Manager_initialization(
35  unsigned32 maximum_extensions
36)
37{
38  _Objects_Initialize_information(
39    &_Extension_Information,
40    OBJECTS_RTEMS_EXTENSIONS,
41    FALSE,
42    maximum_extensions,
43    sizeof( Extension_Control ),
44    FALSE,
45    RTEMS_MAXIMUM_NAME_LENGTH
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
66rtems_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
112rtems_status_code rtems_extension_ident(
113  rtems_name    name,
114  Objects_Id   *id
115)
116{
117  return _Objects_Name_to_id(
118    &_Extension_Information,
119    &name,
120    RTEMS_SEARCH_LOCAL_NODE,
121    id
122  );
123}
124
125/*PAGE
126 *
127 *  rtems_extension_delete
128 *
129 *  This directive allows a thread to delete a extension.
130 *
131 *  Input parameters:
132 *    id - extension id
133 *
134 *  Output parameters:
135 *    RTEMS_SUCCESSFUL - if successful
136 *    error code - if unsuccessful
137 */
138
139rtems_status_code rtems_extension_delete(
140  Objects_Id id
141)
142{
143  Extension_Control   *the_extension;
144  Objects_Locations    location;
145
146  the_extension = _Extension_Get( id, &location );
147  switch ( location ) {
148    case OBJECTS_ERROR:
149    case OBJECTS_REMOTE:            /* should never return this */
150      return( RTEMS_INVALID_ID );
151    case OBJECTS_LOCAL:
152      _User_extensions_Remove_set( &the_extension->Extension );
153      _Objects_Close( &_Extension_Information, &the_extension->Object );
154      _Extension_Free( the_extension );
155      _Thread_Enable_dispatch();
156      return( RTEMS_SUCCESSFUL );
157  }
158
159  return( RTEMS_INTERNAL_ERROR );   /* unreached - only to remove warnings */
160}
Note: See TracBrowser for help on using the repository browser.