1 | /* |
---|
2 | * Extension Manager -- rtems_extension_create |
---|
3 | * |
---|
4 | * |
---|
5 | * COPYRIGHT (c) 1989-2002. |
---|
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.rtems.com/license/LICENSE. |
---|
11 | * |
---|
12 | * $Id$ |
---|
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 | * rtems_extension_create |
---|
24 | * |
---|
25 | * This directive creates a extension and performs some initialization. |
---|
26 | * |
---|
27 | * Input parameters: |
---|
28 | * name - extension name |
---|
29 | * extension_table - pointer to extension set information |
---|
30 | * id - pointer to extension id |
---|
31 | * |
---|
32 | * Output parameters: |
---|
33 | * id - extension id |
---|
34 | * RTEMS_SUCCESSFUL - if successful |
---|
35 | * error code - if unsuccessful |
---|
36 | */ |
---|
37 | |
---|
38 | rtems_status_code rtems_extension_create( |
---|
39 | rtems_name name, |
---|
40 | rtems_extensions_table *extension_table, |
---|
41 | Objects_Id *id |
---|
42 | ) |
---|
43 | { |
---|
44 | Extension_Control *the_extension; |
---|
45 | |
---|
46 | if ( !rtems_is_name_valid( name ) ) |
---|
47 | return RTEMS_INVALID_NAME; |
---|
48 | |
---|
49 | _Thread_Disable_dispatch(); /* to prevent deletion */ |
---|
50 | |
---|
51 | the_extension = _Extension_Allocate(); |
---|
52 | |
---|
53 | if ( !the_extension ) { |
---|
54 | _Thread_Enable_dispatch(); |
---|
55 | return RTEMS_TOO_MANY; |
---|
56 | } |
---|
57 | |
---|
58 | _User_extensions_Add_set( &the_extension->Extension, extension_table ); |
---|
59 | |
---|
60 | _Objects_Open( &_Extension_Information, &the_extension->Object, &name ); |
---|
61 | |
---|
62 | *id = the_extension->Object.id; |
---|
63 | _Thread_Enable_dispatch(); |
---|
64 | return RTEMS_SUCCESSFUL; |
---|
65 | } |
---|