source: rtems/cpukit/rtems/src/dpmemcreate.c @ a29d2e7

4.104.114.84.95
Last change on this file since a29d2e7 was 1095ec1, checked in by Ralf Corsepius <ralf.corsepius@…>, on 01/18/05 at 09:03:45

Include config.h.

  • Property mode set to 100644
File size: 2.0 KB
Line 
1/*
2 *  Dual Port Memory Manager
3 *
4 *  COPYRIGHT (c) 1989-1999.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#if HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <rtems/system.h>
19#include <rtems/rtems/status.h>
20#include <rtems/rtems/support.h>
21#include <rtems/score/address.h>
22#include <rtems/rtems/dpmem.h>
23#include <rtems/score/object.h>
24#include <rtems/score/thread.h>
25#include <rtems/rtems/dpmem.h>
26
27/*PAGE
28 *
29 *  rtems_port_create
30 *
31 *  This directive creates a port into a dual-ported memory area.
32 *
33 *  Input parameters:
34 *    name           - user defined port name
35 *    internal_start - internal start address of port
36 *    external_start - external start address of port
37 *    length         - physical length in bytes
38 *    id             - address of port id to set
39 *
40 *  Output parameters:
41 *    id       - port id
42 *    RTEMS_SUCCESSFUL - if successful
43 *    error code - if unsuccessful
44 */
45
46rtems_status_code rtems_port_create(
47  rtems_name    name,
48  void         *internal_start,
49  void         *external_start,
50  uint32_t      length,
51  Objects_Id   *id
52)
53{
54  register Dual_ported_memory_Control *the_port;
55
56  if ( !rtems_is_name_valid( name) )
57    return RTEMS_INVALID_NAME;
58
59  if ( !id )
60    return RTEMS_INVALID_ADDRESS;
61
62  if ( !_Addresses_Is_aligned( internal_start ) ||
63       !_Addresses_Is_aligned( external_start ) )
64    return RTEMS_INVALID_ADDRESS;
65
66  _Thread_Disable_dispatch();             /* to prevent deletion */
67
68  the_port = _Dual_ported_memory_Allocate();
69
70  if ( !the_port ) {
71    _Thread_Enable_dispatch();
72    return RTEMS_TOO_MANY;
73  }
74
75  the_port->internal_base = internal_start;
76  the_port->external_base = external_start;
77  the_port->length        = length - 1;
78
79  _Objects_Open(
80    &_Dual_ported_memory_Information,
81    &the_port->Object,
82    (Objects_Name) name
83  );
84
85  *id = the_port->Object.id;
86  _Thread_Enable_dispatch();
87  return RTEMS_SUCCESSFUL;
88}
Note: See TracBrowser for help on using the repository browser.