1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @ingroup RTEMSImplClassicUserExt |
---|
5 | * |
---|
6 | * @brief This source file contains the implementation of |
---|
7 | * rtems_extension_create() and the User Extensions Manager system |
---|
8 | * initialization. |
---|
9 | */ |
---|
10 | |
---|
11 | /* |
---|
12 | * COPYRIGHT (c) 1989-2007. |
---|
13 | * On-Line Applications Research Corporation (OAR). |
---|
14 | * |
---|
15 | * The license and distribution terms for this file may be |
---|
16 | * found in the file LICENSE in this distribution or at |
---|
17 | * http://www.rtems.org/license/LICENSE. |
---|
18 | */ |
---|
19 | |
---|
20 | #ifdef HAVE_CONFIG_H |
---|
21 | #include "config.h" |
---|
22 | #endif |
---|
23 | |
---|
24 | #include <rtems/extensionimpl.h> |
---|
25 | #include <rtems/rtems/support.h> |
---|
26 | #include <rtems/score/userextimpl.h> |
---|
27 | #include <rtems/sysinit.h> |
---|
28 | |
---|
29 | rtems_status_code rtems_extension_create( |
---|
30 | rtems_name name, |
---|
31 | const rtems_extensions_table *extension_table, |
---|
32 | rtems_id *id |
---|
33 | ) |
---|
34 | { |
---|
35 | Extension_Control *the_extension; |
---|
36 | |
---|
37 | if ( !rtems_is_name_valid( name ) ) { |
---|
38 | return RTEMS_INVALID_NAME; |
---|
39 | } |
---|
40 | |
---|
41 | if ( extension_table == NULL ) { |
---|
42 | return RTEMS_INVALID_ADDRESS; |
---|
43 | } |
---|
44 | |
---|
45 | if ( id == NULL ) { |
---|
46 | return RTEMS_INVALID_ADDRESS; |
---|
47 | } |
---|
48 | |
---|
49 | the_extension = _Extension_Allocate(); |
---|
50 | |
---|
51 | if ( the_extension == NULL ) { |
---|
52 | _Objects_Allocator_unlock(); |
---|
53 | return RTEMS_TOO_MANY; |
---|
54 | } |
---|
55 | |
---|
56 | _User_extensions_Add_set_with_table( &the_extension->Extension, extension_table ); |
---|
57 | |
---|
58 | _Objects_Open( |
---|
59 | &_Extension_Information, |
---|
60 | &the_extension->Object, |
---|
61 | (Objects_Name) name |
---|
62 | ); |
---|
63 | |
---|
64 | *id = the_extension->Object.id; |
---|
65 | _Objects_Allocator_unlock(); |
---|
66 | return RTEMS_SUCCESSFUL; |
---|
67 | } |
---|
68 | |
---|
69 | static void _Extension_Manager_initialization( void ) |
---|
70 | { |
---|
71 | _Objects_Initialize_information( &_Extension_Information); |
---|
72 | } |
---|
73 | |
---|
74 | RTEMS_SYSINIT_ITEM( |
---|
75 | _Extension_Manager_initialization, |
---|
76 | RTEMS_SYSINIT_USER_EXTENSIONS, |
---|
77 | RTEMS_SYSINIT_ORDER_MIDDLE |
---|
78 | ); |
---|