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

4.104.114.84.95
Last change on this file since 3127180 was 3127180, checked in by Ralf Corsepius <ralf.corsepius@…>, on 03/29/04 at 12:51:43

2004-04-29 Ralf Corsepius <ralf_corsepius@…>

  • score/src/Unlimited.txt, score/src/chain.c, score/src/coremsg.c, score/src/coremsgbroadcast.c, score/src/coremsgclose.c, score/src/coremsgflush.c, score/src/coremsgflushsupp.c, score/src/coremsgseize.c, score/src/coremsgsubmit.c, score/src/coremutex.c, score/src/coremutexflush.c, score/src/coresem.c, score/src/coresemflush.c, score/src/coretod.c, score/src/coretodtickle.c, score/src/coretodtoseconds.c, score/src/coretodvalidate.c, score/src/heap.c, score/src/heapallocate.c, score/src/heapextend.c, score/src/heapfree.c, score/src/heapsizeofuserarea.c, score/src/interr.c, score/src/iterateoverthreads.c, score/src/mpci.c, score/src/object.c, score/src/objectallocate.c, score/src/objectallocatebyindex.c, score/src/objectclearname.c, score/src/objectcomparenameraw.c, score/src/objectcomparenamestring.c, score/src/objectcopynameraw.c, score/src/objectcopynamestring.c, score/src/objectextendinformation.c, score/src/objectfree.c, score/src/objectget.c, score/src/objectgetbyindex.c, score/src/objectgetisr.c, score/src/objectgetnoprotection.c, score/src/objectidtoname.c, score/src/objectinitializeinformation.c, score/src/objectmp.c, score/src/objectnametoid.c, score/src/objectshrinkinformation.c, score/src/thread.c, score/src/threadcreateidle.c, score/src/threadget.c, score/src/threadidlebody.c, score/src/threadinitialize.c, score/src/threadmp.c, score/src/threadq.c, score/src/threadqdequeuepriority.c, score/src/threadqenqueuepriority.c, score/src/threadqfirstpriority.c, score/src/threadqflush.c, score/src/threadreset.c, score/src/threadrestart.c, score/src/threadsettransient.c, score/src/threadstackallocate.c, score/src/threadstart.c, score/src/userext.c, score/src/watchdoginsert.c, score/src/wkspace.c: Convert to using c99 fixed size types.
  • Property mode set to 100644
File size: 4.0 KB
RevLine 
[ac7d5ef0]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 *
[08311cc3]9 *  COPYRIGHT (c) 1989-1999.
[ac7d5ef0]10 *  On-Line Applications Research Corporation (OAR).
11 *
[98e4ebf5]12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
[dd687d97]14 *  http://www.rtems.com/license/LICENSE.
[ac7d5ef0]15 *
16 *  $Id$
17 */
18
19#include <rtems/system.h>
[5e9b32b]20#include <rtems/score/address.h>
21#include <rtems/score/chain.h>
22#include <rtems/score/isr.h>
[ac7d5ef0]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,
[3127180]42  uint32_t       number_nodes,
43  uint32_t       node_size
[ac7d5ef0]44)
45{
[3127180]46  uint32_t    count;
[ac7d5ef0]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
[8af72be]70#ifndef RTEMS_INLINES
[ac7d5ef0]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}
[8af72be]85#endif   /* RTEMS_INLINES */
[ac7d5ef0]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.