4.115
Line | |
---|
1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Initialize a Chain Header |
---|
5 | * |
---|
6 | * @ingroup ScoreChain |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * COPYRIGHT (c) 1989-2007. |
---|
11 | * On-Line Applications Research Corporation (OAR). |
---|
12 | * |
---|
13 | * The license and distribution terms for this file may be |
---|
14 | * found in the file LICENSE in this distribution or at |
---|
15 | * http://www.rtems.com/license/LICENSE. |
---|
16 | */ |
---|
17 | |
---|
18 | #if HAVE_CONFIG_H |
---|
19 | #include "config.h" |
---|
20 | #endif |
---|
21 | |
---|
22 | #include <rtems/system.h> |
---|
23 | #include <rtems/score/address.h> |
---|
24 | #include <rtems/score/chain.h> |
---|
25 | #include <rtems/score/isr.h> |
---|
26 | |
---|
27 | void _Chain_Initialize( |
---|
28 | Chain_Control *the_chain, |
---|
29 | void *starting_address, |
---|
30 | size_t number_nodes, |
---|
31 | size_t node_size |
---|
32 | ) |
---|
33 | { |
---|
34 | size_t count = number_nodes; |
---|
35 | Chain_Node *head = _Chain_Head( the_chain ); |
---|
36 | Chain_Node *tail = _Chain_Tail( the_chain ); |
---|
37 | Chain_Node *current = head; |
---|
38 | Chain_Node *next = starting_address; |
---|
39 | |
---|
40 | head->previous = NULL; |
---|
41 | |
---|
42 | while ( count-- ) { |
---|
43 | current->next = next; |
---|
44 | next->previous = current; |
---|
45 | current = next; |
---|
46 | next = (Chain_Node *) |
---|
47 | _Addresses_Add_offset( (void *) next, node_size ); |
---|
48 | } |
---|
49 | |
---|
50 | current->next = tail; |
---|
51 | tail->previous = current; |
---|
52 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.