1 | /* |
---|
2 | * Object Handler |
---|
3 | * |
---|
4 | * |
---|
5 | * COPYRIGHT (c) 1989-1999. |
---|
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_Initialize_information |
---|
34 | * |
---|
35 | * This routine initializes all object information related data structures. |
---|
36 | * |
---|
37 | * Input parameters: |
---|
38 | * information - object information table |
---|
39 | * maximum - maximum objects of this class |
---|
40 | * size - size of this object's control block |
---|
41 | * is_string - true if names for this object are strings |
---|
42 | * maximum_name_length - maximum length of each object's name |
---|
43 | * When multiprocessing is configured, |
---|
44 | * supports_global - true if this is a global object class |
---|
45 | * extract_callout - pointer to threadq extract callout |
---|
46 | * |
---|
47 | * Output parameters: NONE |
---|
48 | */ |
---|
49 | |
---|
50 | void _Objects_Initialize_information( |
---|
51 | Objects_Information *information, |
---|
52 | Objects_APIs the_api, |
---|
53 | uint32_t the_class, |
---|
54 | uint32_t maximum, |
---|
55 | uint16_t size, |
---|
56 | bool is_string, |
---|
57 | uint32_t maximum_name_length |
---|
58 | #if defined(RTEMS_MULTIPROCESSING) |
---|
59 | , |
---|
60 | bool supports_global, |
---|
61 | Objects_Thread_queue_Extract_callout extract |
---|
62 | #endif |
---|
63 | ) |
---|
64 | { |
---|
65 | static Objects_Control *null_local_table = NULL; |
---|
66 | uint32_t minimum_index; |
---|
67 | uint32_t name_length; |
---|
68 | #if defined(RTEMS_MULTIPROCESSING) |
---|
69 | uint32_t index; |
---|
70 | #endif |
---|
71 | |
---|
72 | information->the_api = the_api; |
---|
73 | information->the_class = the_class; |
---|
74 | #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES) |
---|
75 | information->is_string = is_string; |
---|
76 | #endif |
---|
77 | |
---|
78 | information->local_table = 0; |
---|
79 | information->inactive_per_block = 0; |
---|
80 | information->object_blocks = 0; |
---|
81 | |
---|
82 | information->inactive = 0; |
---|
83 | |
---|
84 | /* |
---|
85 | * Set the entry in the object information table. |
---|
86 | */ |
---|
87 | |
---|
88 | _Objects_Information_table[ the_api ][ the_class ] = information; |
---|
89 | |
---|
90 | /* |
---|
91 | * Set the size of the object |
---|
92 | */ |
---|
93 | |
---|
94 | information->size = size; |
---|
95 | |
---|
96 | /* |
---|
97 | * Are we operating in unlimited, or auto-extend mode |
---|
98 | */ |
---|
99 | |
---|
100 | information->auto_extend = |
---|
101 | (maximum & OBJECTS_UNLIMITED_OBJECTS) ? true : false; |
---|
102 | maximum &= ~OBJECTS_UNLIMITED_OBJECTS; |
---|
103 | |
---|
104 | /* |
---|
105 | * The allocation unit is the maximum value |
---|
106 | */ |
---|
107 | |
---|
108 | information->allocation_size = maximum; |
---|
109 | |
---|
110 | /* |
---|
111 | * Provide a null local table entry for the case of any empty table. |
---|
112 | */ |
---|
113 | |
---|
114 | information->local_table = &null_local_table; |
---|
115 | |
---|
116 | /* |
---|
117 | * Calculate minimum and maximum Id's |
---|
118 | */ |
---|
119 | |
---|
120 | if ( maximum == 0 ) minimum_index = 0; |
---|
121 | else minimum_index = 1; |
---|
122 | |
---|
123 | information->minimum_id = |
---|
124 | _Objects_Build_id( the_api, the_class, _Objects_Local_node, minimum_index ); |
---|
125 | |
---|
126 | /* |
---|
127 | * Calculate the maximum name length |
---|
128 | */ |
---|
129 | |
---|
130 | name_length = maximum_name_length; |
---|
131 | |
---|
132 | if ( name_length & (OBJECTS_NAME_ALIGNMENT-1) ) |
---|
133 | name_length = (name_length + OBJECTS_NAME_ALIGNMENT) & |
---|
134 | ~(OBJECTS_NAME_ALIGNMENT-1); |
---|
135 | |
---|
136 | information->name_length = name_length; |
---|
137 | |
---|
138 | _Chain_Initialize_empty( &information->Inactive ); |
---|
139 | |
---|
140 | /* |
---|
141 | * Initialize objects .. if there are any |
---|
142 | */ |
---|
143 | |
---|
144 | if ( maximum ) { |
---|
145 | |
---|
146 | /* |
---|
147 | * Reset the maximum value. It will be updated when the information is |
---|
148 | * extended. |
---|
149 | */ |
---|
150 | |
---|
151 | information->maximum = 0; |
---|
152 | |
---|
153 | /* |
---|
154 | * Always have the maximum size available so the current performance |
---|
155 | * figures are create are met. If the user moves past the maximum |
---|
156 | * number then a performance hit is taken. |
---|
157 | */ |
---|
158 | |
---|
159 | _Objects_Extend_information( information ); |
---|
160 | |
---|
161 | } |
---|
162 | |
---|
163 | /* |
---|
164 | * Take care of multiprocessing |
---|
165 | */ |
---|
166 | |
---|
167 | #if defined(RTEMS_MULTIPROCESSING) |
---|
168 | information->extract = extract; |
---|
169 | |
---|
170 | if ( (supports_global == true) && _System_state_Is_multiprocessing ) { |
---|
171 | |
---|
172 | information->global_table = |
---|
173 | (Chain_Control *) _Workspace_Allocate_or_fatal_error( |
---|
174 | (_Objects_Maximum_nodes + 1) * sizeof(Chain_Control) |
---|
175 | ); |
---|
176 | |
---|
177 | for ( index=1; index <= _Objects_Maximum_nodes ; index++ ) |
---|
178 | _Chain_Initialize_empty( &information->global_table[ index ] ); |
---|
179 | } |
---|
180 | else |
---|
181 | information->global_table = NULL; |
---|
182 | #endif |
---|
183 | } |
---|