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.OARcorp.com/rtems/license.html. |
---|
10 | * |
---|
11 | * $Id$ |
---|
12 | */ |
---|
13 | |
---|
14 | #include <rtems/system.h> |
---|
15 | #include <rtems/rtems/status.h> |
---|
16 | #include <rtems/rtems/support.h> |
---|
17 | #include <rtems/score/address.h> |
---|
18 | #include <rtems/rtems/dpmem.h> |
---|
19 | #include <rtems/score/object.h> |
---|
20 | #include <rtems/score/thread.h> |
---|
21 | #include <rtems/rtems/dpmem.h> |
---|
22 | |
---|
23 | /*PAGE |
---|
24 | * |
---|
25 | * rtems_port_create |
---|
26 | * |
---|
27 | * This directive creates a port into a dual-ported memory area. |
---|
28 | * |
---|
29 | * Input parameters: |
---|
30 | * name - user defined port name |
---|
31 | * internal_start - internal start address of port |
---|
32 | * external_start - external start address of port |
---|
33 | * length - physical length in bytes |
---|
34 | * id - address of port id to set |
---|
35 | * |
---|
36 | * Output parameters: |
---|
37 | * id - port id |
---|
38 | * RTEMS_SUCCESSFUL - if successful |
---|
39 | * error code - if unsuccessful |
---|
40 | */ |
---|
41 | |
---|
42 | rtems_status_code rtems_port_create( |
---|
43 | rtems_name name, |
---|
44 | void *internal_start, |
---|
45 | void *external_start, |
---|
46 | unsigned32 length, |
---|
47 | Objects_Id *id |
---|
48 | ) |
---|
49 | { |
---|
50 | register Dual_ported_memory_Control *the_port; |
---|
51 | |
---|
52 | if ( !rtems_is_name_valid( name) ) |
---|
53 | return RTEMS_INVALID_NAME; |
---|
54 | |
---|
55 | if ( !_Addresses_Is_aligned( internal_start ) || |
---|
56 | !_Addresses_Is_aligned( external_start ) ) |
---|
57 | return RTEMS_INVALID_ADDRESS; |
---|
58 | |
---|
59 | _Thread_Disable_dispatch(); /* to prevent deletion */ |
---|
60 | |
---|
61 | the_port = _Dual_ported_memory_Allocate(); |
---|
62 | |
---|
63 | if ( !the_port ) { |
---|
64 | _Thread_Enable_dispatch(); |
---|
65 | return RTEMS_TOO_MANY; |
---|
66 | } |
---|
67 | |
---|
68 | the_port->internal_base = internal_start; |
---|
69 | the_port->external_base = external_start; |
---|
70 | the_port->length = length - 1; |
---|
71 | |
---|
72 | _Objects_Open( |
---|
73 | &_Dual_ported_memory_Information, |
---|
74 | &the_port->Object, |
---|
75 | &name |
---|
76 | ); |
---|
77 | |
---|
78 | *id = the_port->Object.id; |
---|
79 | _Thread_Enable_dispatch(); |
---|
80 | return RTEMS_SUCCESSFUL; |
---|
81 | } |
---|