[317a5b5] | 1 | /* |
---|
| 2 | * Object Handler |
---|
| 3 | * |
---|
| 4 | * |
---|
[08311cc3] | 5 | * COPYRIGHT (c) 1989-1999. |
---|
[317a5b5] | 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 |
---|
[dd687d97] | 10 | * http://www.rtems.com/license/LICENSE. |
---|
[317a5b5] | 11 | * |
---|
| 12 | * $Id$ |
---|
| 13 | */ |
---|
| 14 | |
---|
[a8eed23] | 15 | #if HAVE_CONFIG_H |
---|
| 16 | #include "config.h" |
---|
| 17 | #endif |
---|
| 18 | |
---|
[317a5b5] | 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_Get |
---|
| 34 | * |
---|
| 35 | * This routine sets the object pointer for the given |
---|
| 36 | * object id based on the given object information structure. |
---|
| 37 | * |
---|
| 38 | * Input parameters: |
---|
| 39 | * information - pointer to entry in table for this class |
---|
| 40 | * id - object id to search for |
---|
| 41 | * location - address of where to store the location |
---|
| 42 | * |
---|
| 43 | * Output parameters: |
---|
| 44 | * returns - address of object if local |
---|
| 45 | * location - one of the following: |
---|
| 46 | * OBJECTS_ERROR - invalid object ID |
---|
| 47 | * OBJECTS_REMOTE - remote object |
---|
| 48 | * OBJECTS_LOCAL - local object |
---|
| 49 | */ |
---|
| 50 | |
---|
| 51 | Objects_Control *_Objects_Get( |
---|
| 52 | Objects_Information *information, |
---|
| 53 | Objects_Id id, |
---|
| 54 | Objects_Locations *location |
---|
| 55 | ) |
---|
| 56 | { |
---|
| 57 | Objects_Control *the_object; |
---|
[3127180] | 58 | uint32_t index; |
---|
[317a5b5] | 59 | |
---|
[c31c15c] | 60 | #if defined(RTEMS_MULTIPROCESSING) |
---|
| 61 | index = id - information->minimum_id + 1; |
---|
| 62 | #else |
---|
[3b4413c0] | 63 | /* index = _Objects_Get_index( id ); */ |
---|
[e001d84] | 64 | index = id & 0x0000ffff; |
---|
| 65 | /* This should work but doesn't always :( */ |
---|
[3127180] | 66 | /* index = (uint16_t ) id; */ |
---|
[c31c15c] | 67 | #endif |
---|
[317a5b5] | 68 | |
---|
[a0ed4ed] | 69 | if ( information->maximum >= index ) { |
---|
[317a5b5] | 70 | _Thread_Disable_dispatch(); |
---|
[3b4413c0] | 71 | if ( (the_object = information->local_table[ index ]) != NULL ) { |
---|
[317a5b5] | 72 | *location = OBJECTS_LOCAL; |
---|
[3b4413c0] | 73 | return the_object; |
---|
[317a5b5] | 74 | } |
---|
| 75 | _Thread_Enable_dispatch(); |
---|
| 76 | *location = OBJECTS_ERROR; |
---|
[3b4413c0] | 77 | return NULL; |
---|
[317a5b5] | 78 | } |
---|
| 79 | *location = OBJECTS_ERROR; |
---|
[3b4413c0] | 80 | |
---|
[317a5b5] | 81 | #if defined(RTEMS_MULTIPROCESSING) |
---|
[3b4413c0] | 82 | _Objects_MP_Is_remote( information, id, location, &the_object ); |
---|
[317a5b5] | 83 | return the_object; |
---|
| 84 | #else |
---|
| 85 | return NULL; |
---|
| 86 | #endif |
---|
| 87 | } |
---|