Changeset 12f86efd in rtems


Ignore:
Timestamp:
Aug 11, 1995, 2:23:49 PM (25 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
0e4c603
Parents:
0b8b971
Message:

minor clean up -- switched to memset for zero'ing SHM

Location:
c/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/shmdr/init.c

    r0b8b971 r12f86efd  
    2323
    2424#include <rtems.h>
    25 #include "shm.h"
     25#include <shm.h>
     26
     27#include <string.h>    /* memset() */
    2628
    2729/*
    28  * Need a user extension control to install MPCI_Fatal as
    29  *  a fatal error handler extension
     30 * User extension to install MPCI_Fatal as a fatal error
     31 * handler extension
    3032 */
    31 
     33 
    3234rtems_extensions_table MPCI_Shm_extensions;
    3335
     
    3941)
    4042{
    41   rtems_unsigned32         i, *u32_ptr, *endshm, all_initialized;
     43  rtems_unsigned32         i, all_initialized;
    4244  rtems_unsigned32         interrupt_cause, interrupt_value;
    4345  void                    *interrupt_address;
     
    5254  Shm_Maximum_nodes = Shm_RTEMS_MP_Configuration->maximum_nodes;
    5355
    54   Shm_Get_configuration( Shm_Local_node ,&Shm_Configuration );
     56  Shm_Get_configuration( Shm_Local_node, &Shm_Configuration );
    5557
    5658  Shm_Receive_message_count = 0;
     
    6264   */
    6365
    64 #define PEND Shm_Convert(rtems_build_name( 'P', 'E', 'N', 'D' ))
    65 #define COMP Shm_Convert(rtems_build_name( 'C', 'O', 'M', 'P' ))
    66 #define ACTV Shm_Convert(rtems_build_name( 'A', 'C', 'T', 'V' ))
    67 
    68   Shm_Pending_initialization  = PEND;
    69   Shm_Initialization_complete = COMP;
    70   Shm_Active_node             = ACTV;
     66  Shm_Pending_initialization =
     67    Shm_Convert(rtems_build_name( 'P', 'E', 'N', 'D' ));
     68  Shm_Initialization_complete =
     69    Shm_Convert(rtems_build_name( 'C', 'O', 'M', 'P' ));
     70  Shm_Active_node =
     71    Shm_Convert(rtems_build_name( 'A', 'C', 'T', 'V' ));
    7172
    7273  /*
     
    129130     */
    130131
    131     for ( u32_ptr = (rtems_unsigned32 *)Shm_Configuration->base,
    132           endshm = (rtems_unsigned32 *)END_SHARED_MEM ;
    133           u32_ptr < endshm ; )
    134       *u32_ptr++ = 0;
     132    (void) memset(
     133      (void *) Shm_Configuration->base,
     134      0,
     135      Shm_Configuration->length
     136    );
    135137
    136138    /*
     
    175177     */
    176178
    177     all_initialized = 0;
    178 
    179     for ( ; ; ) {
    180 
    181       if ( all_initialized == 1 ) break;
    182 
     179    do {
    183180      all_initialized = 1;
    184181
     
    186183        if ( Shm_Node_statuses[ i ].status != Shm_Initialization_complete )
    187184          all_initialized = 0;
    188     }
     185
     186    } while ( all_initialized == 0 );
    189187
    190188    /*
  • c/src/lib/libbsp/shmdr/mpci.h

    r0b8b971 r12f86efd  
    2323#endif
    2424
    25 #include "shm.h"
     25#include <shm.h>
    2626
    2727#define MPCI_Initialization( _configuration ) \
  • c/src/lib/libbsp/shmdr/poll.c

    r0b8b971 r12f86efd  
    4545      tmpfront = Shm_Local_receive_queue->front;
    4646      Shm_Unlock( Shm_Local_receive_queue );
    47       if ( Shm_Convert(tmpfront) == Shm_Locked_queue_End_of_list ) return;
    48       rtems_multiprocessing_announce();
    49       Shm_Interrupt_count++;
     47      if ( Shm_Convert(tmpfront) != Shm_Locked_queue_End_of_list ) {
     48        rtems_multiprocessing_announce();
     49        Shm_Interrupt_count++;
     50      }
    5051  }
    5152}
  • c/src/lib/libbsp/shmdr/shm.h

    r0b8b971 r12f86efd  
    173173
    174174#define NULL_ENV_CB             ((Shm_Envelope_control *) 0)
    175 #define NULL_SHM_INFO           ((struct shm_info *) 0)
    176175#define NULL_CONVERT            0
    177 #if 0
    178 #define NULL_CONVERT            (((rtems_unsigned32 *)())0) /* we want this */
    179 #endif
    180 
    181 /* The following is adjusted so envelopes are 0x80 bytes long. */
    182 /* It should be >= MIN_PKT_SIZE in rtems.h                     */
    183 
    184 #define MAX_PACKET_SIZE          (80)
     176
     177/*
     178 * size of stuff before preamble in envelope.
     179 * It must be a constant since we will use it to generate MAX_PACKET_SIZE
     180 */
     181 
     182#define SHM_ENVELOPE_PREFIX_OVERHEAD    (4 * sizeof(vol_u32))
     183
     184/*
     185 *  The following is adjusted so envelopes are MAX_ENVELOPE_SIZE bytes long.
     186 *  It must be >= RTEMS_MINIMUM_PACKET_SIZE in mppkt.h.
     187 */
     188 
     189#ifndef MAX_ENVELOPE_SIZE
     190#define MAX_ENVELOPE_SIZE 0x180
     191#endif
     192
     193#define MAX_PACKET_SIZE  (MAX_ENVELOPE_SIZE -               \
     194                          SHM_ENVELOPE_PREFIX_OVERHEAD +    \
     195                          sizeof(Shm_Envelope_preamble) +   \
     196                          sizeof(Shm_Envelope_postamble))
     197
    185198
    186199/* constants pertinent to Locked Queue routines */
     
    200213 *        is defined in a system dependent file.
    201214 */
    202 
    203 #if 0
    204 #define START_NS_CBS     ( (rtems_unsigned8 *) START_SHARED_MEM )
    205 #define START_LQ_CBS     ( ((rtems_unsigned8 *) START_NS_CBS) + \
    206         ( (sizeof (Shm_Node_status_control)) * (Shm_Maximum_nodes + 1) ) )
    207 #define START_ENVELOPES  ( ((rtems_unsigned8 *) START_LQ_CBS) + \
    208         ( (sizeof (Shm_Locked_queue_Control)) * (Shm_Maximum_nodes + 1) ) )
    209 #define END_SHMCI_AREA    ( (rtems_unsigned8 *) START_ENVELOPES + \
    210         ( (sizeof (Shm_Envelope_control)) * Shm_Maximum_envelopes ) )
    211 #define END_SHARED_MEM   ((rtems_unsigned32)START_SHARED_MEM+SHARED_MEM_LEN)
    212 #endif
    213215
    214216#define START_NS_CBS     ((void *)Shm_Configuration->base)
     
    223225/* macros */
    224226
    225 #define Shm_Is_master_node() \
     227#define Shm_Is_master_node()  \
    226228  ( SHM_MASTER == Shm_Local_node )
    227229
     
    242244#define Shm_Packet_prefix_to_envelope_control_pointer( pkt )   \
    243245   ((Shm_Envelope_control *)((rtems_unsigned8 *)(pkt) - \
    244    (sizeof(Shm_Envelope_preamble) + 4*sizeof(vol_u32))))
     246   (sizeof(Shm_Envelope_preamble) + SHM_ENVELOPE_PREFIX_OVERHEAD)))
    245247
    246248#define Shm_Build_preamble(ecb, node) \
     
    249251#define Shm_Build_postamble( ecb )
    250252
    251 /* structures */
     253/* volatile types */
    252254
    253255typedef volatile rtems_unsigned8  vol_u8;
     
    272274
    273275typedef struct {
    274   vol_u32 not_currently_used_0;
    275   vol_u32 not_currently_used_1;
    276   vol_u32 not_currently_used_2;
    277   vol_u32 not_currently_used_3;
    278   /*byte end_of_text;*/
    279 } Shm_Envelope_postable;
     276} Shm_Envelope_postamble;
    280277
    281278/* WARNING! If you change this structure, don't forget to change
    282  *          Shm_Envelope_control_to_packet_prefix_pointer() and
     279 *          SHM_ENVELOPE_PREFIX_OVERHEAD and
    283280 *          Shm_Packet_prefix_to_envelope_control_pointer() above.
    284281 */
     
    306303  Shm_Envelope_preamble    Preamble; /* header information           */
    307304  vol_u8            packet[MAX_PACKET_SIZE]; /* RTEMS INFO    */
    308   Shm_Envelope_postable   Postamble;/* trailer information          */
     305  Shm_Envelope_postamble   Postamble;/* trailer information          */
    309306} Shm_Envelope_control;
    310307
     
    514511);
    515512
     513extern rtems_mpci_table MPCI_table;
     514
    516515#ifdef _SHM_INIT
    517516
     
    527526};
    528527
    529 #else
    530 
    531 extern rtems_mpci_table MPCI_table;
    532 
    533528#endif
    534529
  • c/src/lib/libbsp/shmdr/shm_driver.h

    r0b8b971 r12f86efd  
    173173
    174174#define NULL_ENV_CB             ((Shm_Envelope_control *) 0)
    175 #define NULL_SHM_INFO           ((struct shm_info *) 0)
    176175#define NULL_CONVERT            0
    177 #if 0
    178 #define NULL_CONVERT            (((rtems_unsigned32 *)())0) /* we want this */
    179 #endif
    180 
    181 /* The following is adjusted so envelopes are 0x80 bytes long. */
    182 /* It should be >= MIN_PKT_SIZE in rtems.h                     */
    183 
    184 #define MAX_PACKET_SIZE          (80)
     176
     177/*
     178 * size of stuff before preamble in envelope.
     179 * It must be a constant since we will use it to generate MAX_PACKET_SIZE
     180 */
     181 
     182#define SHM_ENVELOPE_PREFIX_OVERHEAD    (4 * sizeof(vol_u32))
     183
     184/*
     185 *  The following is adjusted so envelopes are MAX_ENVELOPE_SIZE bytes long.
     186 *  It must be >= RTEMS_MINIMUM_PACKET_SIZE in mppkt.h.
     187 */
     188 
     189#ifndef MAX_ENVELOPE_SIZE
     190#define MAX_ENVELOPE_SIZE 0x180
     191#endif
     192
     193#define MAX_PACKET_SIZE  (MAX_ENVELOPE_SIZE -               \
     194                          SHM_ENVELOPE_PREFIX_OVERHEAD +    \
     195                          sizeof(Shm_Envelope_preamble) +   \
     196                          sizeof(Shm_Envelope_postamble))
     197
    185198
    186199/* constants pertinent to Locked Queue routines */
     
    200213 *        is defined in a system dependent file.
    201214 */
    202 
    203 #if 0
    204 #define START_NS_CBS     ( (rtems_unsigned8 *) START_SHARED_MEM )
    205 #define START_LQ_CBS     ( ((rtems_unsigned8 *) START_NS_CBS) + \
    206         ( (sizeof (Shm_Node_status_control)) * (Shm_Maximum_nodes + 1) ) )
    207 #define START_ENVELOPES  ( ((rtems_unsigned8 *) START_LQ_CBS) + \
    208         ( (sizeof (Shm_Locked_queue_Control)) * (Shm_Maximum_nodes + 1) ) )
    209 #define END_SHMCI_AREA    ( (rtems_unsigned8 *) START_ENVELOPES + \
    210         ( (sizeof (Shm_Envelope_control)) * Shm_Maximum_envelopes ) )
    211 #define END_SHARED_MEM   ((rtems_unsigned32)START_SHARED_MEM+SHARED_MEM_LEN)
    212 #endif
    213215
    214216#define START_NS_CBS     ((void *)Shm_Configuration->base)
     
    223225/* macros */
    224226
    225 #define Shm_Is_master_node() \
     227#define Shm_Is_master_node()  \
    226228  ( SHM_MASTER == Shm_Local_node )
    227229
     
    242244#define Shm_Packet_prefix_to_envelope_control_pointer( pkt )   \
    243245   ((Shm_Envelope_control *)((rtems_unsigned8 *)(pkt) - \
    244    (sizeof(Shm_Envelope_preamble) + 4*sizeof(vol_u32))))
     246   (sizeof(Shm_Envelope_preamble) + SHM_ENVELOPE_PREFIX_OVERHEAD)))
    245247
    246248#define Shm_Build_preamble(ecb, node) \
     
    249251#define Shm_Build_postamble( ecb )
    250252
    251 /* structures */
     253/* volatile types */
    252254
    253255typedef volatile rtems_unsigned8  vol_u8;
     
    272274
    273275typedef struct {
    274   vol_u32 not_currently_used_0;
    275   vol_u32 not_currently_used_1;
    276   vol_u32 not_currently_used_2;
    277   vol_u32 not_currently_used_3;
    278   /*byte end_of_text;*/
    279 } Shm_Envelope_postable;
     276} Shm_Envelope_postamble;
    280277
    281278/* WARNING! If you change this structure, don't forget to change
    282  *          Shm_Envelope_control_to_packet_prefix_pointer() and
     279 *          SHM_ENVELOPE_PREFIX_OVERHEAD and
    283280 *          Shm_Packet_prefix_to_envelope_control_pointer() above.
    284281 */
     
    306303  Shm_Envelope_preamble    Preamble; /* header information           */
    307304  vol_u8            packet[MAX_PACKET_SIZE]; /* RTEMS INFO    */
    308   Shm_Envelope_postable   Postamble;/* trailer information          */
     305  Shm_Envelope_postamble   Postamble;/* trailer information          */
    309306} Shm_Envelope_control;
    310307
     
    514511);
    515512
     513extern rtems_mpci_table MPCI_table;
     514
    516515#ifdef _SHM_INIT
    517516
     
    527526};
    528527
    529 #else
    530 
    531 extern rtems_mpci_table MPCI_table;
    532 
    533528#endif
    534529
  • c/src/libchip/shmdr/init.c

    r0b8b971 r12f86efd  
    2323
    2424#include <rtems.h>
    25 #include "shm.h"
     25#include <shm.h>
     26
     27#include <string.h>    /* memset() */
    2628
    2729/*
    28  * Need a user extension control to install MPCI_Fatal as
    29  *  a fatal error handler extension
     30 * User extension to install MPCI_Fatal as a fatal error
     31 * handler extension
    3032 */
    31 
     33 
    3234rtems_extensions_table MPCI_Shm_extensions;
    3335
     
    3941)
    4042{
    41   rtems_unsigned32         i, *u32_ptr, *endshm, all_initialized;
     43  rtems_unsigned32         i, all_initialized;
    4244  rtems_unsigned32         interrupt_cause, interrupt_value;
    4345  void                    *interrupt_address;
     
    5254  Shm_Maximum_nodes = Shm_RTEMS_MP_Configuration->maximum_nodes;
    5355
    54   Shm_Get_configuration( Shm_Local_node ,&Shm_Configuration );
     56  Shm_Get_configuration( Shm_Local_node, &Shm_Configuration );
    5557
    5658  Shm_Receive_message_count = 0;
     
    6264   */
    6365
    64 #define PEND Shm_Convert(rtems_build_name( 'P', 'E', 'N', 'D' ))
    65 #define COMP Shm_Convert(rtems_build_name( 'C', 'O', 'M', 'P' ))
    66 #define ACTV Shm_Convert(rtems_build_name( 'A', 'C', 'T', 'V' ))
    67 
    68   Shm_Pending_initialization  = PEND;
    69   Shm_Initialization_complete = COMP;
    70   Shm_Active_node             = ACTV;
     66  Shm_Pending_initialization =
     67    Shm_Convert(rtems_build_name( 'P', 'E', 'N', 'D' ));
     68  Shm_Initialization_complete =
     69    Shm_Convert(rtems_build_name( 'C', 'O', 'M', 'P' ));
     70  Shm_Active_node =
     71    Shm_Convert(rtems_build_name( 'A', 'C', 'T', 'V' ));
    7172
    7273  /*
     
    129130     */
    130131
    131     for ( u32_ptr = (rtems_unsigned32 *)Shm_Configuration->base,
    132           endshm = (rtems_unsigned32 *)END_SHARED_MEM ;
    133           u32_ptr < endshm ; )
    134       *u32_ptr++ = 0;
     132    (void) memset(
     133      (void *) Shm_Configuration->base,
     134      0,
     135      Shm_Configuration->length
     136    );
    135137
    136138    /*
     
    175177     */
    176178
    177     all_initialized = 0;
    178 
    179     for ( ; ; ) {
    180 
    181       if ( all_initialized == 1 ) break;
    182 
     179    do {
    183180      all_initialized = 1;
    184181
     
    186183        if ( Shm_Node_statuses[ i ].status != Shm_Initialization_complete )
    187184          all_initialized = 0;
    188     }
     185
     186    } while ( all_initialized == 0 );
    189187
    190188    /*
  • c/src/libchip/shmdr/mpci.h

    r0b8b971 r12f86efd  
    2323#endif
    2424
    25 #include "shm.h"
     25#include <shm.h>
    2626
    2727#define MPCI_Initialization( _configuration ) \
  • c/src/libchip/shmdr/poll.c

    r0b8b971 r12f86efd  
    4545      tmpfront = Shm_Local_receive_queue->front;
    4646      Shm_Unlock( Shm_Local_receive_queue );
    47       if ( Shm_Convert(tmpfront) == Shm_Locked_queue_End_of_list ) return;
    48       rtems_multiprocessing_announce();
    49       Shm_Interrupt_count++;
     47      if ( Shm_Convert(tmpfront) != Shm_Locked_queue_End_of_list ) {
     48        rtems_multiprocessing_announce();
     49        Shm_Interrupt_count++;
     50      }
    5051  }
    5152}
  • c/src/libchip/shmdr/shm_driver.h

    r0b8b971 r12f86efd  
    173173
    174174#define NULL_ENV_CB             ((Shm_Envelope_control *) 0)
    175 #define NULL_SHM_INFO           ((struct shm_info *) 0)
    176175#define NULL_CONVERT            0
    177 #if 0
    178 #define NULL_CONVERT            (((rtems_unsigned32 *)())0) /* we want this */
    179 #endif
    180 
    181 /* The following is adjusted so envelopes are 0x80 bytes long. */
    182 /* It should be >= MIN_PKT_SIZE in rtems.h                     */
    183 
    184 #define MAX_PACKET_SIZE          (80)
     176
     177/*
     178 * size of stuff before preamble in envelope.
     179 * It must be a constant since we will use it to generate MAX_PACKET_SIZE
     180 */
     181 
     182#define SHM_ENVELOPE_PREFIX_OVERHEAD    (4 * sizeof(vol_u32))
     183
     184/*
     185 *  The following is adjusted so envelopes are MAX_ENVELOPE_SIZE bytes long.
     186 *  It must be >= RTEMS_MINIMUM_PACKET_SIZE in mppkt.h.
     187 */
     188 
     189#ifndef MAX_ENVELOPE_SIZE
     190#define MAX_ENVELOPE_SIZE 0x180
     191#endif
     192
     193#define MAX_PACKET_SIZE  (MAX_ENVELOPE_SIZE -               \
     194                          SHM_ENVELOPE_PREFIX_OVERHEAD +    \
     195                          sizeof(Shm_Envelope_preamble) +   \
     196                          sizeof(Shm_Envelope_postamble))
     197
    185198
    186199/* constants pertinent to Locked Queue routines */
     
    200213 *        is defined in a system dependent file.
    201214 */
    202 
    203 #if 0
    204 #define START_NS_CBS     ( (rtems_unsigned8 *) START_SHARED_MEM )
    205 #define START_LQ_CBS     ( ((rtems_unsigned8 *) START_NS_CBS) + \
    206         ( (sizeof (Shm_Node_status_control)) * (Shm_Maximum_nodes + 1) ) )
    207 #define START_ENVELOPES  ( ((rtems_unsigned8 *) START_LQ_CBS) + \
    208         ( (sizeof (Shm_Locked_queue_Control)) * (Shm_Maximum_nodes + 1) ) )
    209 #define END_SHMCI_AREA    ( (rtems_unsigned8 *) START_ENVELOPES + \
    210         ( (sizeof (Shm_Envelope_control)) * Shm_Maximum_envelopes ) )
    211 #define END_SHARED_MEM   ((rtems_unsigned32)START_SHARED_MEM+SHARED_MEM_LEN)
    212 #endif
    213215
    214216#define START_NS_CBS     ((void *)Shm_Configuration->base)
     
    223225/* macros */
    224226
    225 #define Shm_Is_master_node() \
     227#define Shm_Is_master_node()  \
    226228  ( SHM_MASTER == Shm_Local_node )
    227229
     
    242244#define Shm_Packet_prefix_to_envelope_control_pointer( pkt )   \
    243245   ((Shm_Envelope_control *)((rtems_unsigned8 *)(pkt) - \
    244    (sizeof(Shm_Envelope_preamble) + 4*sizeof(vol_u32))))
     246   (sizeof(Shm_Envelope_preamble) + SHM_ENVELOPE_PREFIX_OVERHEAD)))
    245247
    246248#define Shm_Build_preamble(ecb, node) \
     
    249251#define Shm_Build_postamble( ecb )
    250252
    251 /* structures */
     253/* volatile types */
    252254
    253255typedef volatile rtems_unsigned8  vol_u8;
     
    272274
    273275typedef struct {
    274   vol_u32 not_currently_used_0;
    275   vol_u32 not_currently_used_1;
    276   vol_u32 not_currently_used_2;
    277   vol_u32 not_currently_used_3;
    278   /*byte end_of_text;*/
    279 } Shm_Envelope_postable;
     276} Shm_Envelope_postamble;
    280277
    281278/* WARNING! If you change this structure, don't forget to change
    282  *          Shm_Envelope_control_to_packet_prefix_pointer() and
     279 *          SHM_ENVELOPE_PREFIX_OVERHEAD and
    283280 *          Shm_Packet_prefix_to_envelope_control_pointer() above.
    284281 */
     
    306303  Shm_Envelope_preamble    Preamble; /* header information           */
    307304  vol_u8            packet[MAX_PACKET_SIZE]; /* RTEMS INFO    */
    308   Shm_Envelope_postable   Postamble;/* trailer information          */
     305  Shm_Envelope_postamble   Postamble;/* trailer information          */
    309306} Shm_Envelope_control;
    310307
     
    514511);
    515512
     513extern rtems_mpci_table MPCI_table;
     514
    516515#ifdef _SHM_INIT
    517516
     
    527526};
    528527
    529 #else
    530 
    531 extern rtems_mpci_table MPCI_table;
    532 
    533528#endif
    534529
Note: See TracChangeset for help on using the changeset viewer.