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