summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1995-08-23 19:30:23 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1995-08-23 19:30:23 +0000
commit3235ad9a2cd717df901853ad5220a4aaffae84a9 (patch)
treef73a01d8c3065188a3ab283cf545b3ce7bc4f696 /cpukit/score/src
parentAdded file .. fixed RCS Id (diff)
downloadrtems-3235ad9a2cd717df901853ad5220a4aaffae84a9.tar.bz2
Support for variable length names added to Object Handler. This supports
both fixed length "raw" names and strings from the API's point of view. Both inline and macro implementations were tested.
Diffstat (limited to 'cpukit/score/src')
-rw-r--r--cpukit/score/src/object.c216
-rw-r--r--cpukit/score/src/objectmp.c7
-rw-r--r--cpukit/score/src/thread.c12
3 files changed, 198 insertions, 37 deletions
diff --git a/cpukit/score/src/object.c b/cpukit/score/src/object.c
index 0181903647..5b64ea8802 100644
--- a/cpukit/score/src/object.c
+++ b/cpukit/score/src/object.c
@@ -55,6 +55,7 @@ void _Objects_Handler_initialization(
* the_class - object class
* supports_global - TRUE if this is a global object class
* maximum - maximum objects of this class
+ * is_string - TRUE if names for this object are strings
* size - size of this object's control block
*
* Output parameters: NONE
@@ -65,15 +66,24 @@ void _Objects_Initialize_information(
Objects_Classes the_class,
boolean supports_global,
unsigned32 maximum,
- unsigned32 size
+ unsigned32 size,
+ boolean is_string,
+ unsigned32 maximum_name_length
)
{
unsigned32 minimum_index;
unsigned32 index;
Objects_Control *the_object;
+ unsigned32 name_length;
+ void *name_area;
information->maximum = maximum;
information->the_class = the_class;
+ information->is_string = is_string;
+
+ /*
+ * Calculate minimum and maximum Id's
+ */
if ( maximum == 0 ) minimum_index = 0;
else minimum_index = 1;
@@ -84,24 +94,45 @@ void _Objects_Initialize_information(
information->maximum_id =
_Objects_Build_id( the_class, _Objects_Local_node, maximum );
+ /*
+ * Allocate local pointer table
+ */
+
information->local_table = _Workspace_Allocate_or_fatal_error(
(maximum + 1) * sizeof(Objects_Control *)
);
- information->name_table = _Workspace_Allocate_or_fatal_error(
- (maximum + 1) * sizeof(Objects_Name)
- );
+ /*
+ * Allocate name table
+ */
+
+ name_length = maximum_name_length;
+
+ if (name_length & (OBJECTS_NAME_ALIGNMENT-1))
+ name_length = (name_length + OBJECTS_NAME_ALIGNMENT) &
+ ~(OBJECTS_NAME_ALIGNMENT-1);
+
+ information->name_length = name_length;
+
+ name_area = _Workspace_Allocate_or_fatal_error( (maximum + 1) * name_length );
+ information->name_table = name_area;
+
+ /*
+ * Initialize local pointer table
+ */
- for ( index=0 ; index < maximum ; index++ ) {
+ for ( index=0 ; index <= maximum ; index++ ) {
information->local_table[ index ] = NULL;
- information->name_table[ index ] = 0;
}
+ /*
+ * Initialize objects .. if there are any
+ */
+
if ( maximum == 0 ) {
_Chain_Initialize_empty( &information->Inactive );
} else {
-
_Chain_Initialize(
&information->Inactive,
_Workspace_Allocate_or_fatal_error( maximum * size ),
@@ -110,31 +141,151 @@ void _Objects_Initialize_information(
);
the_object = (Objects_Control *) information->Inactive.first;
- for ( index=1;
- index <= maximum ;
- index++ ) {
+ for ( index=1; index <= maximum ; index++ ) {
the_object->id =
_Objects_Build_id( the_class, _Objects_Local_node, index );
+
+ the_object->name = (void *) name_area;
+
+ name_area = _Addresses_Add_offset( name_area, name_length );
+
the_object = (Objects_Control *) the_object->Node.next;
}
}
- if ( supports_global == TRUE && _Configuration_Is_multiprocessing() ) {
+ /*
+ * Take care of multiprocessing
+ */
- information->global_table = _Workspace_Allocate_or_fatal_error(
- (_Configuration_MP_table->maximum_nodes + 1) * sizeof(Chain_Control)
- );
+ if ( supports_global == TRUE && _Configuration_Is_multiprocessing() ) {
- for ( index=1;
- index <= _Configuration_MP_table->maximum_nodes ;
- index++ )
- _Chain_Initialize_empty( &information->global_table[ index ] );
- }
- else
- information->global_table = NULL;
+ information->global_table = _Workspace_Allocate_or_fatal_error(
+ (_Configuration_MP_table->maximum_nodes + 1) * sizeof(Chain_Control)
+ );
+
+ for ( index=1;
+ index <= _Configuration_MP_table->maximum_nodes ;
+ index++ )
+ _Chain_Initialize_empty( &information->global_table[ index ] );
+ }
+ else
+ information->global_table = NULL;
+}
+
+/*PAGE
+ *
+ * _Objects_Clear_name
+ *
+ * XXX
+ */
+
+void _Objects_Clear_name(
+ void *name,
+ unsigned32 length
+)
+{
+ unsigned32 index;
+ unsigned32 maximum = length / OBJECTS_NAME_ALIGNMENT;
+ unsigned32 *name_ptr = name;
+
+ for ( index=0 ; index < maximum ; index++ )
+ *name_ptr++ = 0;
+}
+
+/*PAGE
+ *
+ * _Objects_Copy_name_string
+ *
+ * XXX
+ */
+
+void _Objects_Copy_name_string(
+ void *source,
+ void *destination
+)
+{
+ unsigned8 *source_p = source;
+ unsigned8 *destination_p = destination;
+
+ do {
+ *destination_p++ = *source_p;
+ } while ( *source_p++ );
+}
+
+/*PAGE
+ *
+ * _Objects_Copy_name_raw
+ *
+ * XXX
+ */
+
+void _Objects_Copy_name_raw(
+ void *source,
+ void *destination,
+ unsigned32 length
+)
+{
+ unsigned32 *source_p = source;
+ unsigned32 *destination_p = destination;
+ unsigned32 tmp_length = length / OBJECTS_NAME_ALIGNMENT;
+
+ while ( tmp_length-- )
+ *destination_p++ = *source_p++;
+}
+
+/*PAGE
+ *
+ * _Objects_Compare_name_string
+ *
+ * XXX
+ */
+
+boolean _Objects_Compare_name_string(
+ void *name_1,
+ void *name_2,
+ unsigned32 length
+)
+{
+ unsigned8 *name_1_p = name_1;
+ unsigned8 *name_2_p = name_2;
+ unsigned32 tmp_length = length;
+
+ do {
+ if ( *name_1_p++ != *name_2_p++ )
+ return FALSE;
+ if ( !tmp_length-- )
+ return FALSE;
+ } while ( *name_1_p );
+
+ return TRUE;
+}
+
+/*PAGE
+ *
+ * _Objects_Compare_name_raw
+ *
+ * XXX
+ */
+
+boolean _Objects_Compare_name_raw(
+ void *name_1,
+ void *name_2,
+ unsigned32 length
+)
+{
+ unsigned32 *name_1_p = name_1;
+ unsigned32 *name_2_p = name_2;
+ unsigned32 tmp_length = length / OBJECTS_NAME_ALIGNMENT;
+
+ while ( tmp_length-- )
+ if ( *name_1_p++ != *name_2_p++ )
+ return FALSE;
+
+ return TRUE;
}
+
/*PAGE
*
* _Objects_Name_to_id
@@ -156,15 +307,17 @@ void _Objects_Initialize_information(
rtems_status_code _Objects_Name_to_id(
Objects_Information *information,
- Objects_Name name,
- unsigned32 node,
- Objects_Id *id
+ Objects_Name name,
+ unsigned32 node,
+ Objects_Id *id
)
{
- boolean search_local_node;
- Objects_Control **objects;
- Objects_Control *the_object;
- unsigned32 index;
+ boolean search_local_node;
+ Objects_Control **objects;
+ Objects_Control *the_object;
+ unsigned32 index;
+ unsigned32 name_length;
+ Objects_Name_comparators compare_them;
if ( name == 0 )
return( RTEMS_INVALID_NAME );
@@ -179,6 +332,11 @@ rtems_status_code _Objects_Name_to_id(
if ( search_local_node ) {
objects = information->local_table;
+ name_length = information->name_length;
+
+ if ( information->is_string ) compare_them = _Objects_Compare_name_string;
+ else compare_them = _Objects_Compare_name_raw;
+
for ( index = 1; index <= information->maximum; index++ ) {
the_object = objects[ index ];
@@ -186,7 +344,7 @@ rtems_status_code _Objects_Name_to_id(
if ( !the_object || !the_object->name )
continue;
- if ( name == *the_object->name ) {
+ if ( (*compare_them)( name, the_object->name, name_length ) ) {
*id = the_object->id;
return( RTEMS_SUCCESSFUL );
}
diff --git a/cpukit/score/src/objectmp.c b/cpukit/score/src/objectmp.c
index d75a34b150..a8b067020d 100644
--- a/cpukit/score/src/objectmp.c
+++ b/cpukit/score/src/objectmp.c
@@ -53,12 +53,12 @@ void _Objects_MP_Handler_initialization (
boolean _Objects_MP_Open (
Objects_Information *information,
- Objects_Name the_name,
+ unsigned32 the_name, /* XXX -- wrong for variable */
Objects_Id the_id,
boolean is_fatal_error
)
{
- Objects_MP_Control *the_global_object;
+ Objects_MP_Control *the_global_object;
the_global_object = _Objects_MP_Allocate_global_object();
if ( _Objects_MP_Is_null_global_object( the_global_object ) ) {
@@ -139,6 +139,7 @@ rtems_status_code _Objects_MP_Global_name_search (
Chain_Control *the_chain;
Chain_Node *the_node;
Objects_MP_Control *the_object;
+ unsigned32 name_to_use = *(unsigned32 *)the_name; /* XXX variable */
if ( nodes_to_search > _Configuration_MP_table->maximum_nodes )
@@ -174,7 +175,7 @@ rtems_status_code _Objects_MP_Global_name_search (
the_object = (Objects_MP_Control *) the_node;
- if ( the_object->name == the_name ) {
+ if ( the_object->name == name_to_use ) {
*the_id = the_object->Object.id;
_Thread_Enable_dispatch();
return ( RTEMS_SUCCESSFUL );
diff --git a/cpukit/score/src/thread.c b/cpukit/score/src/thread.c
index 92c882d749..9793792b44 100644
--- a/cpukit/score/src/thread.c
+++ b/cpukit/score/src/thread.c
@@ -58,11 +58,13 @@ void _Thread_Handler_initialization(
_Thread_Ticks_per_timeslice = ticks_per_timeslice;
_Objects_Initialize_information(
- &_Thread_Information,
- OBJECTS_RTEMS_TASKS,
- TRUE,
- maximum_tasks,
- sizeof( Thread_Control )
+ &_Thread_Information,
+ OBJECTS_RTEMS_TASKS,
+ TRUE,
+ maximum_tasks,
+ sizeof( Thread_Control ),
+ FALSE,
+ RTEMS_MAXIMUM_NAME_LENGTH
);
_Thread_Ready_chain = _Workspace_Allocate_or_fatal_error(