OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [exec/] [score/] [include/] [rtems/] [score/] [chain.h] - Blame information for rev 593

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*  chain.h
2
 *
3
 *  This include file contains all the constants and structures associated
4
 *  with the Doubly Linked Chain Handler.
5
 *
6
 *  COPYRIGHT (c) 1989-1999.
7
 *  On-Line Applications Research Corporation (OAR).
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: chain.h,v 1.2 2001-09-27 11:59:32 chris Exp $
14
 */
15
 
16
#ifndef __RTEMS_CHAIN_h
17
#define __RTEMS_CHAIN_h
18
 
19
#ifdef __cplusplus
20
extern "C" {
21
#endif
22
 
23
#include <rtems/score/address.h>
24
 
25
/*
26
 *  This is used to manage each element (node) which is placed
27
 *  on a chain.
28
 *
29
 *  NOTE:  Typically, a more complicated structure will use the
30
 *         chain package.  The more complicated structure will
31
 *         include a chain node as the first element in its
32
 *         control structure.  It will then call the chain package
33
 *         with a pointer to that node element.  The node pointer
34
 *         and the higher level structure start at the same address
35
 *         so the user can cast the pointers back and forth.
36
 *
37
 */
38
 
39
typedef struct Chain_Node_struct Chain_Node;
40
 
41
struct Chain_Node_struct {
42
  Chain_Node *next;
43
  Chain_Node *previous;
44
};
45
 
46
/*
47
 *  This is used to manage a chain.  A chain consists of a doubly
48
 *  linked list of zero or more nodes.
49
 *
50
 *  NOTE:  This implementation does not require special checks for
51
 *         manipulating the first and last elements on the chain.
52
 *         To accomplish this the chain control structure is
53
 *         treated as two overlapping chain nodes.  The permanent
54
 *         head of the chain overlays a node structure on the
55
 *         first and permanent_null fields.  The permanent tail
56
 *         of the chain overlays a node structure on the
57
 *         permanent_null and last elements of the structure.
58
 *
59
 */
60
 
61
typedef struct {
62
  Chain_Node *first;
63
  Chain_Node *permanent_null;
64
  Chain_Node *last;
65
} Chain_Control;
66
 
67
/*
68
 *  _Chain_Initialize
69
 *
70
 *  DESCRIPTION:
71
 *
72
 *  This routine initializes the_chain structure to manage the
73
 *  contiguous array of number_nodes nodes which starts at
74
 *  starting_address.  Each node is of node_size bytes.
75
 *
76
 */
77
 
78
void _Chain_Initialize(
79
  Chain_Control *the_chain,
80
  void          *starting_address,
81
  unsigned32     number_nodes,
82
  unsigned32     node_size
83
);
84
 
85
/*
86
 *  _Chain_Get_first_unprotected
87
 */
88
 
89
#ifndef USE_INLINES
90
Chain_Node *_Chain_Get_first_unprotected(
91
  Chain_Control *the_chain
92
);
93
#endif
94
 
95
/*
96
 *  _Chain_Extract
97
 *
98
 *  DESCRIPTION:
99
 *
100
 *  This routine extracts the_node from the chain on which it resides.
101
 *  It disables interrupts to insure the atomicity of the
102
 *  extract operation.
103
 *
104
 */
105
 
106
void _Chain_Extract(
107
  Chain_Node *the_node
108
);
109
 
110
/*
111
 *  _Chain_Get
112
 *
113
 *  DESCRIPTION:
114
 *
115
 *  This function removes the first node from the_chain and returns
116
 *  a pointer to that node.  If the_chain is empty, then NULL is returned.
117
 *  It disables interrupts to insure the atomicity of the
118
 *  get operation.
119
 *
120
 */
121
 
122
Chain_Node *_Chain_Get(
123
  Chain_Control *the_chain
124
);
125
 
126
/*
127
 *  _Chain_Insert
128
 *
129
 *  DESCRIPTION:
130
 *
131
 *  This routine inserts the_node on a chain immediately following
132
 *  after_node.  It disables interrupts to insure the atomicity
133
 *  of the extract operation.
134
 *
135
 */
136
 
137
void _Chain_Insert(
138
  Chain_Node *after_node,
139
  Chain_Node *the_node
140
);
141
 
142
/*
143
 *  _Chain_Append
144
 *
145
 *  DESCRIPTION:
146
 *
147
 *  This routine appends the_node onto the end of the_chain.
148
 *  It disables interrupts to insure the atomicity of the
149
 *  append operation.
150
 *
151
 */
152
 
153
void _Chain_Append(
154
  Chain_Control *the_chain,
155
  Chain_Node    *the_node
156
);
157
 
158
#ifndef __RTEMS_APPLICATION__
159
#include <rtems/score/chain.inl>
160
#endif
161
 
162
#ifdef __cplusplus
163
}
164
#endif
165
 
166
#endif
167
/* end of include file */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.