[60ceb613] | 1 | /** |
---|
| 2 | * @file |
---|
[1dc030f] | 3 | * |
---|
[60ceb613] | 4 | * @brief RTEMS Create Port |
---|
| 5 | * @ingroup ClassicDPMEM |
---|
| 6 | */ |
---|
| 7 | |
---|
| 8 | /* |
---|
[3a638ce] | 9 | * COPYRIGHT (c) 1989-2014. |
---|
[1dc030f] | 10 | * On-Line Applications Research Corporation (OAR). |
---|
| 11 | * |
---|
| 12 | * The license and distribution terms for this file may be |
---|
| 13 | * found in the file LICENSE in this distribution or at |
---|
[c499856] | 14 | * http://www.rtems.org/license/LICENSE. |
---|
[1dc030f] | 15 | */ |
---|
| 16 | |
---|
[1095ec1] | 17 | #if HAVE_CONFIG_H |
---|
| 18 | #include "config.h" |
---|
| 19 | #endif |
---|
| 20 | |
---|
[21275b58] | 21 | #include <rtems/rtems/dpmemimpl.h> |
---|
[1dc030f] | 22 | #include <rtems/rtems/status.h> |
---|
| 23 | #include <rtems/rtems/support.h> |
---|
| 24 | #include <rtems/score/address.h> |
---|
| 25 | #include <rtems/score/thread.h> |
---|
[21275b58] | 26 | #include <rtems/sysinit.h> |
---|
[1dc030f] | 27 | |
---|
| 28 | rtems_status_code rtems_port_create( |
---|
| 29 | rtems_name name, |
---|
| 30 | void *internal_start, |
---|
| 31 | void *external_start, |
---|
[1d496f6] | 32 | uint32_t length, |
---|
[d3b72ca3] | 33 | rtems_id *id |
---|
[1dc030f] | 34 | ) |
---|
| 35 | { |
---|
[23fec9f0] | 36 | Dual_ported_memory_Control *the_port; |
---|
[1dc030f] | 37 | |
---|
[1de98d97] | 38 | if ( !rtems_is_name_valid( name ) ) |
---|
[1dc030f] | 39 | return RTEMS_INVALID_NAME; |
---|
| 40 | |
---|
[e980b219] | 41 | if ( !id ) |
---|
| 42 | return RTEMS_INVALID_ADDRESS; |
---|
| 43 | |
---|
[1dc030f] | 44 | if ( !_Addresses_Is_aligned( internal_start ) || |
---|
| 45 | !_Addresses_Is_aligned( external_start ) ) |
---|
| 46 | return RTEMS_INVALID_ADDRESS; |
---|
| 47 | |
---|
| 48 | the_port = _Dual_ported_memory_Allocate(); |
---|
| 49 | |
---|
| 50 | if ( !the_port ) { |
---|
[23fec9f0] | 51 | _Objects_Allocator_unlock(); |
---|
[1dc030f] | 52 | return RTEMS_TOO_MANY; |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | the_port->internal_base = internal_start; |
---|
| 56 | the_port->external_base = external_start; |
---|
| 57 | the_port->length = length - 1; |
---|
| 58 | |
---|
[50f32b11] | 59 | _Objects_Open( |
---|
[1dc030f] | 60 | &_Dual_ported_memory_Information, |
---|
| 61 | &the_port->Object, |
---|
[6312db3] | 62 | (Objects_Name) name |
---|
[1dc030f] | 63 | ); |
---|
| 64 | |
---|
| 65 | *id = the_port->Object.id; |
---|
[23fec9f0] | 66 | _Objects_Allocator_unlock(); |
---|
[1dc030f] | 67 | return RTEMS_SUCCESSFUL; |
---|
| 68 | } |
---|
[21275b58] | 69 | |
---|
| 70 | static void _Dual_ported_memory_Manager_initialization( void ) |
---|
| 71 | { |
---|
| 72 | _Objects_Initialize_information( &_Dual_ported_memory_Information ); |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | RTEMS_SYSINIT_ITEM( |
---|
| 76 | _Dual_ported_memory_Manager_initialization, |
---|
| 77 | RTEMS_SYSINIT_CLASSIC_DUAL_PORTED_MEMORY, |
---|
| 78 | RTEMS_SYSINIT_ORDER_MIDDLE |
---|
| 79 | ); |
---|