source: rtems/c/src/exec/rtems/src/dpmem.c @ 3a4ae6c

4.104.114.84.95
Last change on this file since 3a4ae6c was 3a4ae6c, checked in by Joel Sherrill <joel.sherrill@…>, on 09/11/95 at 19:35:39

The word "RTEMS" almost completely removed from the core.

Configuration Table Template file added and all tests
modified to use this. All gvar.h and conftbl.h files
removed from test directories.

Configuration parameter maximum_devices added.

Core semaphore and mutex handlers added and RTEMS API Semaphore
Manager updated to reflect this.

Initialization sequence changed to invoke API specific initialization
routines. Initialization tasks table now owned by RTEMS Tasks Manager.

Added user extension for post-switch.

Utilized user extensions to implement API specific functionality
like signal dispatching.

Added extensions to the System Initialization Thread so that an
API can register a function to be invoked while the system
is being initialized. These are largely equivalent to the
pre-driver and post-driver hooks.

Added the Modules file oar-go32_p5, modified oar-go32, and modified
the file make/custom/go32.cfg to look at an environment varable which
determines what CPU model is being used.

All BSPs updated to reflect named devices and clock driver's IOCTL
used by the Shared Memory Driver. Also merged clock isr into
main file and removed ckisr.c where possible.

Updated spsize to reflect new and moved variables.

Makefiles for the executive source and include files updated to show
break down of files into Core, RTEMS API, and Neither.

Header and inline files installed into subdirectory based on whether
logically in the Core or a part of the RTEMS API.

  • Property mode set to 100644
File size: 7.2 KB
Line 
1/*
2 *  Dual Port Memory Manager
3 *
4 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
5 *  On-Line Applications Research Corporation (OAR).
6 *  All rights assigned to U.S. Government, 1994.
7 *
8 *  This material may be reproduced by or for the U.S. Government pursuant
9 *  to the copyright license under the clause at DFARS 252.227-7013.  This
10 *  notice must appear in all copies of this file and its derivatives.
11 *
12 *  $Id$
13 */
14
15#include <rtems/system.h>
16#include <rtems/rtems/status.h>
17#include <rtems/rtems/support.h>
18#include <rtems/core/address.h>
19#include <rtems/rtems/dpmem.h>
20#include <rtems/core/object.h>
21#include <rtems/core/thread.h>
22#include <rtems/rtems/dpmem.h>
23
24/*PAGE
25 *
26 *  _Dual_ported_memory_Manager_initialization
27 *
28 *  This routine initializes all dual-ported memory manager related
29 *  data structures.
30 *
31 *  Input parameters:
32 *    maximum_ports - number of ports to initialize
33 *
34 *  Output parameters:  NONE
35 */
36
37void _Dual_ported_memory_Manager_initialization(
38  unsigned32 maximum_ports
39)
40{
41  _Objects_Initialize_information(
42    &_Dual_ported_memory_Information,
43    OBJECTS_RTEMS_PORTS,
44    FALSE,
45    maximum_ports,
46    sizeof( Dual_ported_memory_Control ),
47    FALSE,
48    RTEMS_MAXIMUM_NAME_LENGTH,
49    FALSE
50  );
51}
52
53/*PAGE
54 *
55 *  rtems_port_create
56 *
57 *  This directive creates a port into a dual-ported memory area.
58 *
59 *  Input parameters:
60 *    name           - user defined port name
61 *    internal_start - internal start address of port
62 *    external_start - external start address of port
63 *    length         - physical length in bytes
64 *    id             - address of port id to set
65 *
66 *  Output parameters:
67 *    id       - port id
68 *    RTEMS_SUCCESSFUL - if successful
69 *    error code - if unsuccessful
70 */
71
72rtems_status_code rtems_port_create(
73  rtems_name    name,
74  void         *internal_start,
75  void         *external_start,
76  unsigned32    length,
77  Objects_Id   *id
78)
79{
80  register Dual_ported_memory_Control *the_port;
81
82  if ( !rtems_is_name_valid( name) )
83    return RTEMS_INVALID_NAME;
84
85  if ( !_Addresses_Is_aligned( internal_start ) ||
86       !_Addresses_Is_aligned( external_start ) )
87    return RTEMS_INVALID_ADDRESS;
88
89  _Thread_Disable_dispatch();             /* to prevent deletion */
90
91  the_port = _Dual_ported_memory_Allocate();
92
93  if ( !the_port ) {
94    _Thread_Enable_dispatch();
95    return RTEMS_TOO_MANY;
96  }
97
98  the_port->internal_base = internal_start;
99  the_port->external_base = external_start;
100  the_port->length        = length - 1;
101
102  _Objects_Open(
103    &_Dual_ported_memory_Information,
104    &the_port->Object,
105    &name
106  );
107
108  *id = the_port->Object.id;
109  _Thread_Enable_dispatch();
110  return RTEMS_SUCCESSFUL;
111}
112
113/*PAGE
114 *
115 *  rtems_port_ident
116 *
117 *  This directive returns the system ID associated with
118 *  the port name.
119 *
120 *  Input parameters:
121 *    name - user defined port name
122 *    id   - pointer to port id
123 *
124 *  Output parameters:
125 *    *id      - port id
126 *    RTEMS_SUCCESSFUL - if successful
127 *    error code - if unsuccessful
128 */
129
130rtems_status_code rtems_port_ident(
131  rtems_name    name,
132  Objects_Id   *id
133)
134{
135  Objects_Name_to_id_errors  status;
136
137  status = _Objects_Name_to_id(
138    &_Dual_ported_memory_Information,
139    &name,
140    OBJECTS_SEARCH_ALL_NODES,
141    id
142  );
143
144  return _Status_Object_name_errors_to_status[ status ];
145}
146
147/*PAGE
148 *
149 *  rtems_port_delete
150 *
151 *  This directive allows a thread to delete a dual-ported memory area
152 *  specified by the dual-ported memory identifier.
153 *
154 *  Input parameters:
155 *    id - dual-ported memory area id
156 *
157 *  Output parameters:
158 *    RTEMS_SUCCESSFUL - if successful
159 *    error code        - if unsuccessful
160 */
161
162rtems_status_code rtems_port_delete(
163  Objects_Id id
164)
165{
166  register Dual_ported_memory_Control *the_port;
167  Objects_Locations                    location;
168
169  the_port = _Dual_ported_memory_Get( id, &location );
170  switch ( location ) {
171    case OBJECTS_ERROR:
172      return RTEMS_INVALID_ID;
173    case OBJECTS_REMOTE:        /* this error cannot be returned */
174      return RTEMS_INTERNAL_ERROR;
175    case OBJECTS_LOCAL:
176      _Objects_Close( &_Dual_ported_memory_Information, &the_port->Object );
177      _Dual_ported_memory_Free( the_port );
178      _Thread_Enable_dispatch();
179      return RTEMS_SUCCESSFUL;
180  }
181
182  return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
183}
184
185/*PAGE
186 *
187 *  rtems_port_internal_to_external
188 *
189 *  This directive converts an internal dual-ported memory address to an
190 *  external dual-ported memory address.  If the given internal address
191 *  is an invalid dual-ported address, then the external address is set
192 *  to the given internal address.
193 *
194 *  Input parameters:
195 *    id       - id of dual-ported memory object
196 *    internal - internal address to set
197 *    external - pointer to external address
198 *
199 *  Output parameters:
200 *    external          - external address
201 *    RTEMS_SUCCESSFUL - always succeeds
202 */
203
204rtems_status_code rtems_port_internal_to_external(
205  Objects_Id   id,
206  void        *internal,
207  void       **external
208)
209{
210  register Dual_ported_memory_Control *the_port;
211  Objects_Locations                    location;
212  unsigned32                           ending;
213
214  the_port = _Dual_ported_memory_Get( id, &location );
215  switch ( location ) {
216    case OBJECTS_ERROR:
217      return RTEMS_INVALID_ID;
218    case OBJECTS_REMOTE:        /* this error cannot be returned */
219      return RTEMS_INTERNAL_ERROR;
220    case OBJECTS_LOCAL:
221      ending = _Addresses_Subtract( internal, the_port->internal_base );
222      if ( ending > the_port->length )
223        *external = internal;
224      else
225        *external = _Addresses_Add_offset( the_port->external_base,
226                                           ending );
227      _Thread_Enable_dispatch();
228      return RTEMS_SUCCESSFUL;
229  }
230
231  return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
232}
233
234/*PAGE
235 *
236 *  rtems_port_external_to_internal
237 *
238 *  This directive converts an external dual-ported memory address to an
239 *  internal dual-ported memory address.  If the given external address
240 *  is an invalid dual-ported address, then the internal address is set
241 *  to the given external address.
242 *
243 *  Input parameters:
244 *    id       - id of dp memory object
245 *    external - external address
246 *    internal - pointer of internal address to set
247 *
248 *  Output parameters:
249 *    internal          - internal address
250 *    RTEMS_SUCCESSFUL - always succeeds
251 */
252
253rtems_status_code rtems_port_external_to_internal(
254  Objects_Id   id,
255  void        *external,
256  void       **internal
257)
258{
259  register Dual_ported_memory_Control *the_port;
260  Objects_Locations                    location;
261  unsigned32                           ending;
262
263  the_port = _Dual_ported_memory_Get( id, &location );
264  switch ( location ) {
265    case OBJECTS_ERROR:
266      return RTEMS_INVALID_ID;
267    case OBJECTS_REMOTE:        /* this error cannot be returned */
268      return RTEMS_INTERNAL_ERROR;
269    case OBJECTS_LOCAL:
270      ending = _Addresses_Subtract( external, the_port->external_base );
271      if ( ending > the_port->length )
272        *internal = external;
273      else
274        *internal = _Addresses_Add_offset( the_port->internal_base,
275                                           ending );
276      _Thread_Enable_dispatch();
277      return RTEMS_SUCCESSFUL;
278  }
279
280  return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
281}
Note: See TracBrowser for help on using the repository browser.