1 | /* |
---|
2 | * Object Handler |
---|
3 | * |
---|
4 | * |
---|
5 | * COPYRIGHT (c) 1989-2008. |
---|
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 | #if HAVE_CONFIG_H |
---|
16 | #include "config.h" |
---|
17 | #endif |
---|
18 | |
---|
19 | #include <rtems/system.h> |
---|
20 | #include <rtems/score/address.h> |
---|
21 | #include <rtems/score/chain.h> |
---|
22 | #include <rtems/score/object.h> |
---|
23 | #if defined(RTEMS_MULTIPROCESSING) |
---|
24 | #include <rtems/score/objectmp.h> |
---|
25 | #endif |
---|
26 | #include <rtems/score/thread.h> |
---|
27 | #include <rtems/score/wkspace.h> |
---|
28 | #include <rtems/score/sysstate.h> |
---|
29 | #include <rtems/score/isr.h> |
---|
30 | |
---|
31 | /*PAGE |
---|
32 | * |
---|
33 | * _Objects_Name_to_id_u32 |
---|
34 | * |
---|
35 | * These kernel routines search the object table(s) for the given |
---|
36 | * object name and returns the associated object id. |
---|
37 | * |
---|
38 | * Input parameters: |
---|
39 | * information - object information |
---|
40 | * name - user defined object name |
---|
41 | * node - node indentifier (0 indicates any node) |
---|
42 | * id - address of return ID |
---|
43 | * |
---|
44 | * Output parameters: |
---|
45 | * id - object id |
---|
46 | * OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL - if successful |
---|
47 | * error code - if unsuccessful |
---|
48 | */ |
---|
49 | |
---|
50 | Objects_Name_or_id_lookup_errors _Objects_Name_to_id_u32( |
---|
51 | Objects_Information *information, |
---|
52 | uint32_t name, |
---|
53 | uint32_t node, |
---|
54 | Objects_Id *id |
---|
55 | ) |
---|
56 | { |
---|
57 | bool search_local_node; |
---|
58 | Objects_Control *the_object; |
---|
59 | uint32_t index; |
---|
60 | uint32_t name_length; |
---|
61 | #if defined(RTEMS_MULTIPROCESSING) |
---|
62 | Objects_Name name_for_mp; |
---|
63 | #endif |
---|
64 | |
---|
65 | /* ASSERT: information->is_string == FALSE */ |
---|
66 | |
---|
67 | if ( !id ) |
---|
68 | return OBJECTS_INVALID_ADDRESS; |
---|
69 | |
---|
70 | if ( name == 0 ) |
---|
71 | return OBJECTS_INVALID_NAME; |
---|
72 | |
---|
73 | search_local_node = FALSE; |
---|
74 | |
---|
75 | if ( information->maximum != 0 && |
---|
76 | (node == OBJECTS_SEARCH_ALL_NODES || |
---|
77 | node == OBJECTS_SEARCH_LOCAL_NODE || |
---|
78 | _Objects_Is_local_node( node ) |
---|
79 | )) |
---|
80 | search_local_node = TRUE; |
---|
81 | |
---|
82 | if ( search_local_node ) { |
---|
83 | name_length = information->name_length; |
---|
84 | |
---|
85 | for ( index = 1; index <= information->maximum; index++ ) { |
---|
86 | the_object = information->local_table[ index ]; |
---|
87 | if ( !the_object ) |
---|
88 | continue; |
---|
89 | |
---|
90 | if ( name == the_object->name.name_u32 ) { |
---|
91 | *id = the_object->id; |
---|
92 | return OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL; |
---|
93 | } |
---|
94 | } |
---|
95 | } |
---|
96 | |
---|
97 | #if defined(RTEMS_MULTIPROCESSING) |
---|
98 | if ( _Objects_Is_local_node( node ) || node == OBJECTS_SEARCH_LOCAL_NODE ) |
---|
99 | return OBJECTS_INVALID_NAME; |
---|
100 | |
---|
101 | name_for_mp.name_u32 = name; |
---|
102 | return _Objects_MP_Global_name_search( information, name_for_mp, node, id ); |
---|
103 | #else |
---|
104 | return OBJECTS_INVALID_NAME; |
---|
105 | #endif |
---|
106 | } |
---|