1 | /* |
---|
2 | * Object Handler |
---|
3 | * |
---|
4 | * |
---|
5 | * COPYRIGHT (c) 1989-1998. |
---|
6 | * On-Line Applications Research Corporation (OAR). |
---|
7 | * Copyright assigned to U.S. Government, 1994. |
---|
8 | * |
---|
9 | * The license and distribution terms for this file may be |
---|
10 | * found in the file LICENSE in this distribution or at |
---|
11 | * http://www.OARcorp.com/rtems/license.html. |
---|
12 | * |
---|
13 | * $Id$ |
---|
14 | */ |
---|
15 | |
---|
16 | #include <rtems/system.h> |
---|
17 | #include <rtems/score/address.h> |
---|
18 | #include <rtems/score/chain.h> |
---|
19 | #include <rtems/score/object.h> |
---|
20 | #if defined(RTEMS_MULTIPROCESSING) |
---|
21 | #include <rtems/score/objectmp.h> |
---|
22 | #endif |
---|
23 | #include <rtems/score/thread.h> |
---|
24 | #include <rtems/score/wkspace.h> |
---|
25 | #include <rtems/score/sysstate.h> |
---|
26 | #include <rtems/score/isr.h> |
---|
27 | |
---|
28 | /*PAGE |
---|
29 | * |
---|
30 | * _Objects_Get_next |
---|
31 | * |
---|
32 | * Like _Objects_Get, but considers the 'id' as a "hint" and |
---|
33 | * finds next valid one after that point. |
---|
34 | * Mostly used for monitor and debug traversal of an object. |
---|
35 | * |
---|
36 | * Input parameters: |
---|
37 | * information - pointer to entry in table for this class |
---|
38 | * id - object id to search for |
---|
39 | * location - address of where to store the location |
---|
40 | * next_id - address to store next id to try |
---|
41 | * |
---|
42 | * Output parameters: |
---|
43 | * returns - address of object if local |
---|
44 | * location - one of the following: |
---|
45 | * OBJECTS_ERROR - invalid object ID |
---|
46 | * OBJECTS_REMOTE - remote object |
---|
47 | * OBJECTS_LOCAL - local object |
---|
48 | * next_id - will contain a reasonable "next" id to continue traversal |
---|
49 | * |
---|
50 | * NOTE: |
---|
51 | * assumes can add '1' to an id to get to next index. |
---|
52 | */ |
---|
53 | |
---|
54 | Objects_Control * |
---|
55 | _Objects_Get_next( |
---|
56 | Objects_Information *information, |
---|
57 | Objects_Id id, |
---|
58 | Objects_Locations *location_p, |
---|
59 | Objects_Id *next_id_p |
---|
60 | ) |
---|
61 | { |
---|
62 | Objects_Control *object; |
---|
63 | Objects_Id next_id; |
---|
64 | |
---|
65 | if (_Objects_Get_index(id) == OBJECTS_ID_INITIAL_INDEX) |
---|
66 | next_id = information->minimum_id; |
---|
67 | else |
---|
68 | next_id = id; |
---|
69 | |
---|
70 | do { |
---|
71 | /* walked off end of list? */ |
---|
72 | if (_Objects_Get_index(next_id) > information->maximum) |
---|
73 | { |
---|
74 | *location_p = OBJECTS_ERROR; |
---|
75 | goto final; |
---|
76 | } |
---|
77 | |
---|
78 | /* try to grab one */ |
---|
79 | object = _Objects_Get(information, next_id, location_p); |
---|
80 | |
---|
81 | next_id++; |
---|
82 | |
---|
83 | } while (*location_p != OBJECTS_LOCAL); |
---|
84 | |
---|
85 | *next_id_p = next_id; |
---|
86 | return object; |
---|
87 | |
---|
88 | final: |
---|
89 | *next_id_p = OBJECTS_ID_FINAL; |
---|
90 | return 0; |
---|
91 | } |
---|