summaryrefslogtreecommitdiffstats
path: root/c/src/exec/rtems/headers/dpmem.h
blob: 669eb394d89bad126fdba9740a6c672b9903bbcb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
/*  dpmem.h
 *
 *  This include file contains all the constants and structures associated
 *  with the Dual Ported Memory Manager. This manager provides a mechanism
 *  for converting addresses between internal and external representations
 *  for multiple dual-ported memory areas.
 *
 *  Directives provided are:
 *
 *     + create a port
 *     + get ID of a port
 *     + delete a port
 *     + convert external to internal address
 *     + convert internal to external address
 *
 *
 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
 *  On-Line Applications Research Corporation (OAR).
 *  All rights assigned to U.S. Government, 1994.
 *
 *  This material may be reproduced by or for the U.S. Government pursuant
 *  to the copyright license under the clause at DFARS 252.227-7013.  This
 *  notice must appear in all copies of this file and its derivatives.
 *
 *  $Id$
 */

#ifndef __RTEMS_DUAL_PORTED_MEMORY_h
#define __RTEMS_DUAL_PORTED_MEMORY_h

#ifdef __cplusplus
extern "C" {
#endif

#include <rtems/object.h>

/*
 *  The following structure defines the port control block.  Each port
 *  has a control block associated with it.  This control block contains
 *  all information required to support the port related operations.
 */

typedef struct {
  Objects_Control  Object;
  void            *internal_base; /* base internal address */
  void            *external_base; /* base external address */
  unsigned32       length;        /* length of dual-ported area */
}   Dual_ported_memory_Control;

/*
 *  The following define the internal Dual Ported Memory information.
 */

EXTERN Objects_Information  _Dual_ported_memory_Information;

/*
 *  _Dual_ported_memory_Manager_initialization
 *
 *  DESCRIPTION:
 *
 *  This routine performs the initialization necessary for this manager.
 */

void _Dual_ported_memory_Manager_initialization(
  unsigned32 maximum_ports
);

/*
 *  rtems_port_create
 *
 *  DESCRIPTION:
 *
 *  This routine implements the rtems_port_create directive.  The port
 *  will have the name name.  The port maps onto an area of dual ported
 *  memory of length bytes which has internal_start and external_start
 *  as the internal and external starting addresses, respectively.
 *  It returns the id of the created port in ID.
 */

rtems_status_code rtems_port_create(
  Objects_Name  name,
  void         *internal_start,
  void         *external_start,
  unsigned32    length,
  Objects_Id   *id
);

/*
 *  rtems_port_ident
 *
 *  DESCRIPTION:
 *
 *  This routine implements the rtems_port_ident directive.  This directive
 *  returns the port ID associated with name.  If more than one port is
 *  named name, then the port to which the ID belongs is arbitrary.
 */

rtems_status_code rtems_port_ident(
  Objects_Name  name,
  Objects_Id   *id
);

/*
 *  rtems_port_delete
 *
 *  DESCRIPTION:
 *
 *  This routine implements the rtems_port_delete directive.  It deletes
 *  the port associated with ID.
 */

rtems_status_code rtems_port_delete(
  Objects_Id id
);

/*
 *  rtems_port_external_to_internal
 *
 *  DESCRIPTION:
 *
 *  This routine implements the rtems_port_external_to_internal directive.
 *  It returns the internal port address which maps to the provided
 *  external port address for the specified port ID.
 */

rtems_status_code rtems_port_external_to_internal(
  Objects_Id   id,
  void        *external,
  void       **internal
);

/*
 *  rtems_port_internal_to_external
 *
 *  DESCRIPTION:
 *
 *  This routine implements the Port_internal_to_external directive.
 *  It returns the external port address which maps to the provided
 *  internal port address for the specified port ID.
 */

rtems_status_code rtems_port_internal_to_external(
  Objects_Id   id,
  void        *internal,
  void       **external
);

/*
 *  _Dual_ported_memory_Allocate
 *
 *  DESCRIPTION:
 *
 *  This routine allocates a port control block from the inactive chain
 *  of free port control blocks.
 */

STATIC INLINE Dual_ported_memory_Control
  *_Dual_ported_memory_Allocate ( void );

/*
 *  _Dual_ported_memory_Free
 *
 *  DESCRIPTION:
 *
 *  This routine frees a port control block to the inactive chain
 *  of free port control blocks.
 */

STATIC INLINE void _Dual_ported_memory_Free (
   Dual_ported_memory_Control *the_port
);

/*
 *  _Dual_ported_memory_Get
 *
 *  DESCRIPTION:
 *
 *  This function maps port IDs to port control blocks.  If ID
 *  corresponds to a local port, then it returns the_port control
 *  pointer which maps to ID and location is set to OBJECTS_LOCAL.
 *  Global ports are not supported, thus if ID  does not map to a
 *  local port, location is set to OBJECTS_ERROR and the_port is
 *  undefined.
 */

STATIC INLINE Dual_ported_memory_Control *_Dual_ported_memory_Get (
  Objects_Id         id,
  Objects_Locations *location
);

/*
 *  _Dual_ported_memory_Is_null
 *
 *  DESCRIPTION:
 *
 *  This function returns TRUE if the_port is NULL and FALSE otherwise.
 */

STATIC INLINE boolean _Dual_ported_memory_Is_null(
  Dual_ported_memory_Control *the_port
);

#include <rtems/dpmem.inl>

#ifdef __cplusplus
}
#endif

#endif
/* end of include file */