Changeset 1dc030f in rtems


Ignore:
Timestamp:
May 17, 1999, 11:18:20 PM (22 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
0123e3b
Parents:
842db5f3
Message:

Dual-Ported Memory Manager split into one routine per file.

Files:
10 added
3 edited

Legend:

Unmodified
Added
Removed
  • c/src/exec/rtems/src/Makefile.in

    r842db5f3 r1dc030f  
    5555  part partcreate partdelete partgetbuffer partident partreturnbuffer
    5656
     57DPMEM_PIECES=\
     58  dpmem dpmemcreate dpmemdelete dpmemexternal2internal \
     59  dpmemident dpmeminternal2external
     60
    5761C_PIECES=\
    5862  attr $(TASK_PIECES) $(RATEMON_PIECES) \
     
    6165  $(SEMAPHORE_PIECES) $(MESSAGE_QUEUE_PIECES) \
    6266  $(EVENT_PIECES) signal
    63   $(PARTITION_PIECES) $(REGION_PIECES) dpmem \
     67  $(PARTITION_PIECES) $(REGION_PIECES) $(DPMEM_PIECES) \
    6468  $(MP_PIECES)
    6569C_FILES=$(C_PIECES:%=%.c)
  • c/src/exec/rtems/src/dpmem.c

    r842db5f3 r1dc030f  
    5050  );
    5151}
    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 
    72 rtems_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 
    130 rtems_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 
    162 rtems_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_REMOTE:        /* this error cannot be returned */
    172       return RTEMS_INTERNAL_ERROR;
    173 
    174     case OBJECTS_ERROR:
    175       return RTEMS_INVALID_ID;
    176 
    177     case OBJECTS_LOCAL:
    178       _Objects_Close( &_Dual_ported_memory_Information, &the_port->Object );
    179       _Dual_ported_memory_Free( the_port );
    180       _Thread_Enable_dispatch();
    181       return RTEMS_SUCCESSFUL;
    182   }
    183 
    184   return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
    185 }
    186 
    187 /*PAGE
    188  *
    189  *  rtems_port_internal_to_external
    190  *
    191  *  This directive converts an internal dual-ported memory address to an
    192  *  external dual-ported memory address.  If the given internal address
    193  *  is an invalid dual-ported address, then the external address is set
    194  *  to the given internal address.
    195  *
    196  *  Input parameters:
    197  *    id       - id of dual-ported memory object
    198  *    internal - internal address to set
    199  *    external - pointer to external address
    200  *
    201  *  Output parameters:
    202  *    external          - external address
    203  *    RTEMS_SUCCESSFUL - always succeeds
    204  */
    205 
    206 rtems_status_code rtems_port_internal_to_external(
    207   Objects_Id   id,
    208   void        *internal,
    209   void       **external
    210 )
    211 {
    212   register Dual_ported_memory_Control *the_port;
    213   Objects_Locations                    location;
    214   unsigned32                           ending;
    215 
    216   the_port = _Dual_ported_memory_Get( id, &location );
    217   switch ( location ) {
    218     case OBJECTS_REMOTE:        /* this error cannot be returned */
    219       return RTEMS_INTERNAL_ERROR;
    220 
    221     case OBJECTS_ERROR:
    222       return RTEMS_INVALID_ID;
    223 
    224     case OBJECTS_LOCAL:
    225       ending = _Addresses_Subtract( internal, the_port->internal_base );
    226       if ( ending > the_port->length )
    227         *external = internal;
    228       else
    229         *external = _Addresses_Add_offset( the_port->external_base,
    230                                            ending );
    231       _Thread_Enable_dispatch();
    232       return RTEMS_SUCCESSFUL;
    233   }
    234 
    235   return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
    236 }
    237 
    238 /*PAGE
    239  *
    240  *  rtems_port_external_to_internal
    241  *
    242  *  This directive converts an external dual-ported memory address to an
    243  *  internal dual-ported memory address.  If the given external address
    244  *  is an invalid dual-ported address, then the internal address is set
    245  *  to the given external address.
    246  *
    247  *  Input parameters:
    248  *    id       - id of dp memory object
    249  *    external - external address
    250  *    internal - pointer of internal address to set
    251  *
    252  *  Output parameters:
    253  *    internal          - internal address
    254  *    RTEMS_SUCCESSFUL - always succeeds
    255  */
    256 
    257 rtems_status_code rtems_port_external_to_internal(
    258   Objects_Id   id,
    259   void        *external,
    260   void       **internal
    261 )
    262 {
    263   register Dual_ported_memory_Control *the_port;
    264   Objects_Locations                    location;
    265   unsigned32                           ending;
    266 
    267   the_port = _Dual_ported_memory_Get( id, &location );
    268   switch ( location ) {
    269     case OBJECTS_REMOTE:        /* this error cannot be returned */
    270       return RTEMS_INTERNAL_ERROR;
    271 
    272     case OBJECTS_ERROR:
    273       return RTEMS_INVALID_ID;
    274 
    275     case OBJECTS_LOCAL:
    276       ending = _Addresses_Subtract( external, the_port->external_base );
    277       if ( ending > the_port->length )
    278         *internal = external;
    279       else
    280         *internal = _Addresses_Add_offset( the_port->internal_base,
    281                                            ending );
    282       _Thread_Enable_dispatch();
    283       return RTEMS_SUCCESSFUL;
    284   }
    285 
    286   return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
    287 }
  • cpukit/rtems/src/dpmem.c

    r842db5f3 r1dc030f  
    5050  );
    5151}
    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 
    72 rtems_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 
    130 rtems_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 
    162 rtems_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_REMOTE:        /* this error cannot be returned */
    172       return RTEMS_INTERNAL_ERROR;
    173 
    174     case OBJECTS_ERROR:
    175       return RTEMS_INVALID_ID;
    176 
    177     case OBJECTS_LOCAL:
    178       _Objects_Close( &_Dual_ported_memory_Information, &the_port->Object );
    179       _Dual_ported_memory_Free( the_port );
    180       _Thread_Enable_dispatch();
    181       return RTEMS_SUCCESSFUL;
    182   }
    183 
    184   return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
    185 }
    186 
    187 /*PAGE
    188  *
    189  *  rtems_port_internal_to_external
    190  *
    191  *  This directive converts an internal dual-ported memory address to an
    192  *  external dual-ported memory address.  If the given internal address
    193  *  is an invalid dual-ported address, then the external address is set
    194  *  to the given internal address.
    195  *
    196  *  Input parameters:
    197  *    id       - id of dual-ported memory object
    198  *    internal - internal address to set
    199  *    external - pointer to external address
    200  *
    201  *  Output parameters:
    202  *    external          - external address
    203  *    RTEMS_SUCCESSFUL - always succeeds
    204  */
    205 
    206 rtems_status_code rtems_port_internal_to_external(
    207   Objects_Id   id,
    208   void        *internal,
    209   void       **external
    210 )
    211 {
    212   register Dual_ported_memory_Control *the_port;
    213   Objects_Locations                    location;
    214   unsigned32                           ending;
    215 
    216   the_port = _Dual_ported_memory_Get( id, &location );
    217   switch ( location ) {
    218     case OBJECTS_REMOTE:        /* this error cannot be returned */
    219       return RTEMS_INTERNAL_ERROR;
    220 
    221     case OBJECTS_ERROR:
    222       return RTEMS_INVALID_ID;
    223 
    224     case OBJECTS_LOCAL:
    225       ending = _Addresses_Subtract( internal, the_port->internal_base );
    226       if ( ending > the_port->length )
    227         *external = internal;
    228       else
    229         *external = _Addresses_Add_offset( the_port->external_base,
    230                                            ending );
    231       _Thread_Enable_dispatch();
    232       return RTEMS_SUCCESSFUL;
    233   }
    234 
    235   return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
    236 }
    237 
    238 /*PAGE
    239  *
    240  *  rtems_port_external_to_internal
    241  *
    242  *  This directive converts an external dual-ported memory address to an
    243  *  internal dual-ported memory address.  If the given external address
    244  *  is an invalid dual-ported address, then the internal address is set
    245  *  to the given external address.
    246  *
    247  *  Input parameters:
    248  *    id       - id of dp memory object
    249  *    external - external address
    250  *    internal - pointer of internal address to set
    251  *
    252  *  Output parameters:
    253  *    internal          - internal address
    254  *    RTEMS_SUCCESSFUL - always succeeds
    255  */
    256 
    257 rtems_status_code rtems_port_external_to_internal(
    258   Objects_Id   id,
    259   void        *external,
    260   void       **internal
    261 )
    262 {
    263   register Dual_ported_memory_Control *the_port;
    264   Objects_Locations                    location;
    265   unsigned32                           ending;
    266 
    267   the_port = _Dual_ported_memory_Get( id, &location );
    268   switch ( location ) {
    269     case OBJECTS_REMOTE:        /* this error cannot be returned */
    270       return RTEMS_INTERNAL_ERROR;
    271 
    272     case OBJECTS_ERROR:
    273       return RTEMS_INVALID_ID;
    274 
    275     case OBJECTS_LOCAL:
    276       ending = _Addresses_Subtract( external, the_port->external_base );
    277       if ( ending > the_port->length )
    278         *internal = external;
    279       else
    280         *internal = _Addresses_Add_offset( the_port->internal_base,
    281                                            ending );
    282       _Thread_Enable_dispatch();
    283       return RTEMS_SUCCESSFUL;
    284   }
    285 
    286   return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
    287 }
Note: See TracChangeset for help on using the changeset viewer.