source: rtems/cpukit/score/src/chain.c @ dd687d9

4.104.114.84.95
Last change on this file since dd687d9 was dd687d9, checked in by Joel Sherrill <joel.sherrill@…>, on 09/04/03 at 18:56:05

2003-09-04 Joel Sherrill <joel@…>

  • include/rtems/debug.h, include/rtems/seterr.h, include/rtems/system.h, include/rtems/score/address.h, include/rtems/score/apiext.h, include/rtems/score/apimutex.h, include/rtems/score/bitfield.h, include/rtems/score/chain.h, include/rtems/score/context.h, include/rtems/score/copyrt.h, include/rtems/score/coremsg.h, include/rtems/score/coremutex.h, include/rtems/score/coresem.h, include/rtems/score/heap.h, include/rtems/score/interr.h, include/rtems/score/isr.h, include/rtems/score/mpci.h, include/rtems/score/mppkt.h, include/rtems/score/object.h, include/rtems/score/objectmp.h, include/rtems/score/priority.h, include/rtems/score/stack.h, include/rtems/score/states.h, include/rtems/score/sysstate.h, include/rtems/score/thread.h, include/rtems/score/threadmp.h, include/rtems/score/threadq.h, include/rtems/score/tod.h, include/rtems/score/tqdata.h, include/rtems/score/userext.h, include/rtems/score/watchdog.h, include/rtems/score/wkspace.h, inline/rtems/score/address.inl, inline/rtems/score/chain.inl, inline/rtems/score/coremsg.inl, inline/rtems/score/coremutex.inl, inline/rtems/score/coresem.inl, inline/rtems/score/heap.inl, inline/rtems/score/isr.inl, inline/rtems/score/mppkt.inl, inline/rtems/score/object.inl, inline/rtems/score/objectmp.inl, inline/rtems/score/priority.inl, inline/rtems/score/stack.inl, inline/rtems/score/states.inl, inline/rtems/score/sysstate.inl, inline/rtems/score/thread.inl, inline/rtems/score/threadmp.inl, inline/rtems/score/tod.inl, inline/rtems/score/tqdata.inl, inline/rtems/score/userext.inl, inline/rtems/score/watchdog.inl, inline/rtems/score/wkspace.inl, macros/rtems/score/address.inl, macros/rtems/score/chain.inl, macros/rtems/score/coremsg.inl, macros/rtems/score/coremutex.inl, macros/rtems/score/coresem.inl, macros/rtems/score/heap.inl, macros/rtems/score/isr.inl, macros/rtems/score/mppkt.inl, macros/rtems/score/object.inl, macros/rtems/score/objectmp.inl, macros/rtems/score/priority.inl, macros/rtems/score/stack.inl, macros/rtems/score/states.inl, macros/rtems/score/sysstate.inl, macros/rtems/score/thread.inl, macros/rtems/score/threadmp.inl, macros/rtems/score/tod.inl, macros/rtems/score/tqdata.inl, macros/rtems/score/userext.inl, macros/rtems/score/watchdog.inl, macros/rtems/score/wkspace.inl, src/apiext.c, src/chain.c, src/coremsg.c, src/coremsgbroadcast.c, src/coremsgclose.c, src/coremsgflush.c, src/coremsgflushsupp.c, src/coremsgflushwait.c, src/coremsginsert.c, src/coremsgseize.c, src/coremsgsubmit.c, src/coremutex.c, src/coremutexflush.c, src/coremutexseize.c, src/coremutexsurrender.c, src/coresem.c, src/coresemflush.c, src/coresemseize.c, src/coresemsurrender.c, src/coretod.c, src/coretodset.c, src/coretodtickle.c, src/coretodtoseconds.c, src/coretodvalidate.c, src/heap.c, src/heapallocate.c, src/heapextend.c, src/heapfree.c, src/heapgetinfo.c, src/heapsizeofuserarea.c, src/heapwalk.c, src/interr.c, src/isr.c, src/iterateoverthreads.c, src/mpci.c, src/object.c, src/objectallocate.c, src/objectallocatebyindex.c, src/objectclearname.c, src/objectcomparenameraw.c, src/objectcomparenamestring.c, src/objectcopynameraw.c, src/objectcopynamestring.c, src/objectextendinformation.c, src/objectfree.c, src/objectget.c, src/objectgetbyindex.c, src/objectgetisr.c, src/objectgetnext.c, src/objectgetnoprotection.c, src/objectidtoname.c, src/objectinitializeinformation.c, src/objectmp.c, src/objectnametoid.c, src/objectshrinkinformation.c, src/thread.c, src/threadchangepriority.c, src/threadclearstate.c, src/threadclose.c, src/threadcreateidle.c, src/threaddelayended.c, src/threaddispatch.c, src/threadevaluatemode.c, src/threadget.c, src/threadhandler.c, src/threadidlebody.c, src/threadinitialize.c, src/threadloadenv.c, src/threadmp.c, src/threadq.c, src/threadqdequeue.c, src/threadqdequeuefifo.c, src/threadqdequeuepriority.c, src/threadqenqueue.c, src/threadqenqueuefifo.c, src/threadqenqueuepriority.c, src/threadqextract.c, src/threadqextractfifo.c, src/threadqextractpriority.c, src/threadqextractwithproxy.c, src/threadqfirst.c, src/threadqfirstfifo.c, src/threadqfirstpriority.c, src/threadqflush.c, src/threadqtimeout.c, src/threadready.c, src/threadreset.c, src/threadresettimeslice.c, src/threadrestart.c, src/threadresume.c, src/threadrotatequeue.c, src/threadsetpriority.c, src/threadsetstate.c, src/threadsettransient.c, src/threadstackallocate.c, src/threadstackfree.c, src/threadstart.c, src/threadstartmultitasking.c, src/threadsuspend.c, src/threadtickletimeslice.c, src/threadyieldprocessor.c, src/userext.c, src/watchdog.c, src/watchdogadjust.c, src/watchdoginsert.c, src/watchdogremove.c, src/watchdogtickle.c, src/wkspace.c: URL for license changed.
  • Property mode set to 100644
File size: 4.0 KB
Line 
1/*
2 *  Chain Handler
3 *
4 *  NOTE:
5 *
6 *  The order of this file is to allow proper compilation due to the
7 *  order of inlining required by the compiler.
8 *
9 *  COPYRIGHT (c) 1989-1999.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.com/license/LICENSE.
15 *
16 *  $Id$
17 */
18
19#include <rtems/system.h>
20#include <rtems/score/address.h>
21#include <rtems/score/chain.h>
22#include <rtems/score/isr.h>
23
24/*PAGE
25 *
26 *  _Chain_Initialize
27 *
28 *  This kernel routine initializes a doubly linked chain.
29 *
30 *  Input parameters:
31 *    the_chain        - pointer to chain header
32 *    starting_address - starting address of first node
33 *    number_nodes     - number of nodes in chain
34 *    node_size        - size of node in bytes
35 *
36 *  Output parameters:  NONE
37 */
38
39void _Chain_Initialize(
40  Chain_Control *the_chain,
41  void           *starting_address,
42  unsigned32     number_nodes,
43  unsigned32     node_size
44)
45{
46  unsigned32  count;
47  Chain_Node *current;
48  Chain_Node *next;
49
50  count                     = number_nodes;
51  current                   = _Chain_Head( the_chain );
52  the_chain->permanent_null = NULL;
53  next                      = (Chain_Node *)starting_address;
54  while ( count-- ) {
55    current->next  = next;
56    next->previous = current;
57    current        = next;
58    next           = (Chain_Node *)
59                        _Addresses_Add_offset( (void *) next, node_size );
60  }
61  current->next    = _Chain_Tail( the_chain );
62  the_chain->last  = current;
63}
64
65/*PAGE
66 *
67 *  _Chain_Get_first_unprotected
68 */
69
70#ifndef USE_INLINES
71Chain_Node *_Chain_Get_first_unprotected(
72  Chain_Control *the_chain
73)
74{
75  Chain_Node  *return_node;
76  Chain_Node  *new_first;
77
78  return_node         = the_chain->first;
79  new_first           = return_node->next;
80  the_chain->first    = new_first;
81  new_first->previous = _Chain_Head( the_chain );
82
83  return return_node;
84}
85#endif   /* USE_INLINES */
86
87/*PAGE
88 *
89 *  _Chain_Get
90 *
91 *  This kernel routine returns a pointer to a node taken from the
92 *  given chain.
93 *
94 *  Input parameters:
95 *    the_chain - pointer to chain header
96 *
97 *  Output parameters:
98 *    return_node - pointer to node in chain allocated
99 *    CHAIN_END   - if no nodes available
100 *
101 *  INTERRUPT LATENCY:
102 *    only case
103 */
104
105Chain_Node *_Chain_Get(
106  Chain_Control *the_chain
107)
108{
109  ISR_Level          level;
110  Chain_Node *return_node;
111
112  return_node = NULL;
113  _ISR_Disable( level );
114    if ( !_Chain_Is_empty( the_chain ) )
115      return_node = _Chain_Get_first_unprotected( the_chain );
116  _ISR_Enable( level );
117  return return_node;
118}
119
120/*PAGE
121 *
122 *  _Chain_Append
123 *
124 *  This kernel routine puts a node on the end of the specified chain.
125 *
126 *  Input parameters:
127 *    the_chain - pointer to chain header
128 *    node      - address of node to put at rear of chain
129 *
130 *  Output parameters:  NONE
131 *
132 *  INTERRUPT LATENCY:
133 *    only case
134 */
135
136void _Chain_Append(
137  Chain_Control *the_chain,
138  Chain_Node    *node
139)
140{
141  ISR_Level level;
142
143  _ISR_Disable( level );
144    _Chain_Append_unprotected( the_chain, node );
145  _ISR_Enable( level );
146}
147
148/*PAGE
149 *
150 *  _Chain_Extract
151 *
152 *  This kernel routine deletes the given node from a chain.
153 *
154 *  Input parameters:
155 *    node - pointer to node in chain to be deleted
156 *
157 *  Output parameters:  NONE
158 *
159 *  INTERRUPT LATENCY:
160 *    only case
161 */
162
163void _Chain_Extract(
164  Chain_Node *node
165)
166{
167  ISR_Level level;
168
169  _ISR_Disable( level );
170    _Chain_Extract_unprotected( node );
171  _ISR_Enable( level );
172}
173
174/*PAGE
175 *
176 *  _Chain_Insert
177 *
178 *  This kernel routine inserts a given node after a specified node
179 *  a requested chain.
180 *
181 *  Input parameters:
182 *    after_node - pointer to node in chain to be inserted after
183 *    node       - pointer to node to be inserted
184 *
185 *  Output parameters:  NONE
186 *
187 *  INTERRUPT LATENCY:
188 *    only case
189 */
190
191void _Chain_Insert(
192  Chain_Node *after_node,
193  Chain_Node *node
194)
195{
196  ISR_Level level;
197
198  _ISR_Disable( level );
199    _Chain_Insert_unprotected( after_node, node );
200  _ISR_Enable( level );
201}
Note: See TracBrowser for help on using the repository browser.