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

This commit is contained in:
Joel Sherrill
1995-08-11 14:23:49 +00:00
parent 0b8b9717a4
commit 12f86efd88
9 changed files with 135 additions and 152 deletions

View File

@@ -22,13 +22,15 @@
#define _SHM_INIT
#include <rtems.h>
#include "shm.h"
#include <shm.h>
#include <string.h> /* memset() */
/*
* Need a user extension control to install MPCI_Fatal as
* a fatal error handler extension
* User extension to install MPCI_Fatal as a fatal error
* handler extension
*/
rtems_extensions_table MPCI_Shm_extensions;
rtems_mpci_entry Shm_Initialization(
@@ -38,7 +40,7 @@ rtems_mpci_entry Shm_Initialization(
)
{
rtems_unsigned32 i, *u32_ptr, *endshm, all_initialized;
rtems_unsigned32 i, all_initialized;
rtems_unsigned32 interrupt_cause, interrupt_value;
void *interrupt_address;
Shm_Node_status_control *nscb;
@@ -51,7 +53,7 @@ rtems_mpci_entry Shm_Initialization(
Shm_Local_node = Shm_RTEMS_MP_Configuration->node;
Shm_Maximum_nodes = Shm_RTEMS_MP_Configuration->maximum_nodes;
Shm_Get_configuration( Shm_Local_node ,&Shm_Configuration );
Shm_Get_configuration( Shm_Local_node, &Shm_Configuration );
Shm_Receive_message_count = 0;
Shm_Null_message_count = 0;
@@ -61,13 +63,12 @@ rtems_mpci_entry Shm_Initialization(
* Set the Node Status indicators
*/
#define PEND Shm_Convert(rtems_build_name( 'P', 'E', 'N', 'D' ))
#define COMP Shm_Convert(rtems_build_name( 'C', 'O', 'M', 'P' ))
#define ACTV Shm_Convert(rtems_build_name( 'A', 'C', 'T', 'V' ))
Shm_Pending_initialization = PEND;
Shm_Initialization_complete = COMP;
Shm_Active_node = ACTV;
Shm_Pending_initialization =
Shm_Convert(rtems_build_name( 'P', 'E', 'N', 'D' ));
Shm_Initialization_complete =
Shm_Convert(rtems_build_name( 'C', 'O', 'M', 'P' ));
Shm_Active_node =
Shm_Convert(rtems_build_name( 'A', 'C', 'T', 'V' ));
/*
* Initialize the constants used by the Locked Queue code.
@@ -128,10 +129,11 @@ rtems_mpci_entry Shm_Initialization(
* Zero out the shared memory area.
*/
for ( u32_ptr = (rtems_unsigned32 *)Shm_Configuration->base,
endshm = (rtems_unsigned32 *)END_SHARED_MEM ;
u32_ptr < endshm ; )
*u32_ptr++ = 0;
(void) memset(
(void *) Shm_Configuration->base,
0,
Shm_Configuration->length
);
/*
* Initialize all of the locked queues (the free envelope
@@ -174,18 +176,14 @@ rtems_mpci_entry Shm_Initialization(
* Loop until all nodes have completed initialization.
*/
all_initialized = 0;
for ( ; ; ) {
if ( all_initialized == 1 ) break;
do {
all_initialized = 1;
for ( i = SHM_FIRST_NODE ; i <= Shm_Maximum_nodes ; i++ )
if ( Shm_Node_statuses[ i ].status != Shm_Initialization_complete )
all_initialized = 0;
}
} while ( all_initialized == 0 );
/*
* Tell the other nodes we think that the system is up.

View File

@@ -22,7 +22,7 @@
extern "C" {
#endif
#include "shm.h"
#include <shm.h>
#define MPCI_Initialization( _configuration ) \
Shm_Initialization( _configuration )

View File

@@ -44,8 +44,9 @@ void Shm_Poll()
Shm_Lock( Shm_Local_receive_queue );
tmpfront = Shm_Local_receive_queue->front;
Shm_Unlock( Shm_Local_receive_queue );
if ( Shm_Convert(tmpfront) == Shm_Locked_queue_End_of_list ) return;
rtems_multiprocessing_announce();
Shm_Interrupt_count++;
if ( Shm_Convert(tmpfront) != Shm_Locked_queue_End_of_list ) {
rtems_multiprocessing_announce();
Shm_Interrupt_count++;
}
}
}

View File

@@ -172,16 +172,29 @@ extern "C" {
/* null pointers of different types */
#define NULL_ENV_CB ((Shm_Envelope_control *) 0)
#define NULL_SHM_INFO ((struct shm_info *) 0)
#define NULL_CONVERT 0
#if 0
#define NULL_CONVERT (((rtems_unsigned32 *)())0) /* we want this */
/*
* size of stuff before preamble in envelope.
* It must be a constant since we will use it to generate MAX_PACKET_SIZE
*/
#define SHM_ENVELOPE_PREFIX_OVERHEAD (4 * sizeof(vol_u32))
/*
* The following is adjusted so envelopes are MAX_ENVELOPE_SIZE bytes long.
* It must be >= RTEMS_MINIMUM_PACKET_SIZE in mppkt.h.
*/
#ifndef MAX_ENVELOPE_SIZE
#define MAX_ENVELOPE_SIZE 0x180
#endif
/* The following is adjusted so envelopes are 0x80 bytes long. */
/* It should be >= MIN_PKT_SIZE in rtems.h */
#define MAX_PACKET_SIZE (MAX_ENVELOPE_SIZE - \
SHM_ENVELOPE_PREFIX_OVERHEAD + \
sizeof(Shm_Envelope_preamble) + \
sizeof(Shm_Envelope_postamble))
#define MAX_PACKET_SIZE (80)
/* constants pertinent to Locked Queue routines */
@@ -200,17 +213,6 @@ extern "C" {
* is defined in a system dependent file.
*/
#if 0
#define START_NS_CBS ( (rtems_unsigned8 *) START_SHARED_MEM )
#define START_LQ_CBS ( ((rtems_unsigned8 *) START_NS_CBS) + \
( (sizeof (Shm_Node_status_control)) * (Shm_Maximum_nodes + 1) ) )
#define START_ENVELOPES ( ((rtems_unsigned8 *) START_LQ_CBS) + \
( (sizeof (Shm_Locked_queue_Control)) * (Shm_Maximum_nodes + 1) ) )
#define END_SHMCI_AREA ( (rtems_unsigned8 *) START_ENVELOPES + \
( (sizeof (Shm_Envelope_control)) * Shm_Maximum_envelopes ) )
#define END_SHARED_MEM ((rtems_unsigned32)START_SHARED_MEM+SHARED_MEM_LEN)
#endif
#define START_NS_CBS ((void *)Shm_Configuration->base)
#define START_LQ_CBS ((START_NS_CBS) + \
( (sizeof (Shm_Node_status_control)) * (Shm_Maximum_nodes + 1) ) )
@@ -222,7 +224,7 @@ extern "C" {
/* macros */
#define Shm_Is_master_node() \
#define Shm_Is_master_node() \
( SHM_MASTER == Shm_Local_node )
#define Shm_Free_envelope( ecb ) \
@@ -241,14 +243,14 @@ extern "C" {
#define Shm_Packet_prefix_to_envelope_control_pointer( pkt ) \
((Shm_Envelope_control *)((rtems_unsigned8 *)(pkt) - \
(sizeof(Shm_Envelope_preamble) + 4*sizeof(vol_u32))))
(sizeof(Shm_Envelope_preamble) + SHM_ENVELOPE_PREFIX_OVERHEAD)))
#define Shm_Build_preamble(ecb, node) \
(ecb)->Preamble.endian = Shm_Configuration->format
#define Shm_Build_postamble( ecb )
/* structures */
/* volatile types */
typedef volatile rtems_unsigned8 vol_u8;
typedef volatile rtems_unsigned32 vol_u32;
@@ -271,15 +273,10 @@ typedef struct {
} Shm_Envelope_preamble;
typedef struct {
vol_u32 not_currently_used_0;
vol_u32 not_currently_used_1;
vol_u32 not_currently_used_2;
vol_u32 not_currently_used_3;
/*byte end_of_text;*/
} Shm_Envelope_postable;
} Shm_Envelope_postamble;
/* WARNING! If you change this structure, don't forget to change
* Shm_Envelope_control_to_packet_prefix_pointer() and
* SHM_ENVELOPE_PREFIX_OVERHEAD and
* Shm_Packet_prefix_to_envelope_control_pointer() above.
*/
@@ -305,7 +302,7 @@ typedef struct {
vol_u32 pad0; /* insure the next one is aligned */
Shm_Envelope_preamble Preamble; /* header information */
vol_u8 packet[MAX_PACKET_SIZE]; /* RTEMS INFO */
Shm_Envelope_postable Postamble;/* trailer information */
Shm_Envelope_postamble Postamble;/* trailer information */
} Shm_Envelope_control;
/* This comment block describes the contents of each field
@@ -513,6 +510,8 @@ rtems_mpci_entry Shm_Send_packet(
rtems_packet_prefix *
);
extern rtems_mpci_table MPCI_table;
#ifdef _SHM_INIT
/* multiprocessor communications interface (MPCI) table */
@@ -526,10 +525,6 @@ rtems_mpci_table MPCI_table = {
Shm_Receive_packet /* packet receive procedure */
};
#else
extern rtems_mpci_table MPCI_table;
#endif
#ifdef __cplusplus

View File

@@ -172,16 +172,29 @@ extern "C" {
/* null pointers of different types */
#define NULL_ENV_CB ((Shm_Envelope_control *) 0)
#define NULL_SHM_INFO ((struct shm_info *) 0)
#define NULL_CONVERT 0
#if 0
#define NULL_CONVERT (((rtems_unsigned32 *)())0) /* we want this */
/*
* size of stuff before preamble in envelope.
* It must be a constant since we will use it to generate MAX_PACKET_SIZE
*/
#define SHM_ENVELOPE_PREFIX_OVERHEAD (4 * sizeof(vol_u32))
/*
* The following is adjusted so envelopes are MAX_ENVELOPE_SIZE bytes long.
* It must be >= RTEMS_MINIMUM_PACKET_SIZE in mppkt.h.
*/
#ifndef MAX_ENVELOPE_SIZE
#define MAX_ENVELOPE_SIZE 0x180
#endif
/* The following is adjusted so envelopes are 0x80 bytes long. */
/* It should be >= MIN_PKT_SIZE in rtems.h */
#define MAX_PACKET_SIZE (MAX_ENVELOPE_SIZE - \
SHM_ENVELOPE_PREFIX_OVERHEAD + \
sizeof(Shm_Envelope_preamble) + \
sizeof(Shm_Envelope_postamble))
#define MAX_PACKET_SIZE (80)
/* constants pertinent to Locked Queue routines */
@@ -200,17 +213,6 @@ extern "C" {
* is defined in a system dependent file.
*/
#if 0
#define START_NS_CBS ( (rtems_unsigned8 *) START_SHARED_MEM )
#define START_LQ_CBS ( ((rtems_unsigned8 *) START_NS_CBS) + \
( (sizeof (Shm_Node_status_control)) * (Shm_Maximum_nodes + 1) ) )
#define START_ENVELOPES ( ((rtems_unsigned8 *) START_LQ_CBS) + \
( (sizeof (Shm_Locked_queue_Control)) * (Shm_Maximum_nodes + 1) ) )
#define END_SHMCI_AREA ( (rtems_unsigned8 *) START_ENVELOPES + \
( (sizeof (Shm_Envelope_control)) * Shm_Maximum_envelopes ) )
#define END_SHARED_MEM ((rtems_unsigned32)START_SHARED_MEM+SHARED_MEM_LEN)
#endif
#define START_NS_CBS ((void *)Shm_Configuration->base)
#define START_LQ_CBS ((START_NS_CBS) + \
( (sizeof (Shm_Node_status_control)) * (Shm_Maximum_nodes + 1) ) )
@@ -222,7 +224,7 @@ extern "C" {
/* macros */
#define Shm_Is_master_node() \
#define Shm_Is_master_node() \
( SHM_MASTER == Shm_Local_node )
#define Shm_Free_envelope( ecb ) \
@@ -241,14 +243,14 @@ extern "C" {
#define Shm_Packet_prefix_to_envelope_control_pointer( pkt ) \
((Shm_Envelope_control *)((rtems_unsigned8 *)(pkt) - \
(sizeof(Shm_Envelope_preamble) + 4*sizeof(vol_u32))))
(sizeof(Shm_Envelope_preamble) + SHM_ENVELOPE_PREFIX_OVERHEAD)))
#define Shm_Build_preamble(ecb, node) \
(ecb)->Preamble.endian = Shm_Configuration->format
#define Shm_Build_postamble( ecb )
/* structures */
/* volatile types */
typedef volatile rtems_unsigned8 vol_u8;
typedef volatile rtems_unsigned32 vol_u32;
@@ -271,15 +273,10 @@ typedef struct {
} Shm_Envelope_preamble;
typedef struct {
vol_u32 not_currently_used_0;
vol_u32 not_currently_used_1;
vol_u32 not_currently_used_2;
vol_u32 not_currently_used_3;
/*byte end_of_text;*/
} Shm_Envelope_postable;
} Shm_Envelope_postamble;
/* WARNING! If you change this structure, don't forget to change
* Shm_Envelope_control_to_packet_prefix_pointer() and
* SHM_ENVELOPE_PREFIX_OVERHEAD and
* Shm_Packet_prefix_to_envelope_control_pointer() above.
*/
@@ -305,7 +302,7 @@ typedef struct {
vol_u32 pad0; /* insure the next one is aligned */
Shm_Envelope_preamble Preamble; /* header information */
vol_u8 packet[MAX_PACKET_SIZE]; /* RTEMS INFO */
Shm_Envelope_postable Postamble;/* trailer information */
Shm_Envelope_postamble Postamble;/* trailer information */
} Shm_Envelope_control;
/* This comment block describes the contents of each field
@@ -513,6 +510,8 @@ rtems_mpci_entry Shm_Send_packet(
rtems_packet_prefix *
);
extern rtems_mpci_table MPCI_table;
#ifdef _SHM_INIT
/* multiprocessor communications interface (MPCI) table */
@@ -526,10 +525,6 @@ rtems_mpci_table MPCI_table = {
Shm_Receive_packet /* packet receive procedure */
};
#else
extern rtems_mpci_table MPCI_table;
#endif
#ifdef __cplusplus

View File

@@ -22,13 +22,15 @@
#define _SHM_INIT
#include <rtems.h>
#include "shm.h"
#include <shm.h>
#include <string.h> /* memset() */
/*
* Need a user extension control to install MPCI_Fatal as
* a fatal error handler extension
* User extension to install MPCI_Fatal as a fatal error
* handler extension
*/
rtems_extensions_table MPCI_Shm_extensions;
rtems_mpci_entry Shm_Initialization(
@@ -38,7 +40,7 @@ rtems_mpci_entry Shm_Initialization(
)
{
rtems_unsigned32 i, *u32_ptr, *endshm, all_initialized;
rtems_unsigned32 i, all_initialized;
rtems_unsigned32 interrupt_cause, interrupt_value;
void *interrupt_address;
Shm_Node_status_control *nscb;
@@ -51,7 +53,7 @@ rtems_mpci_entry Shm_Initialization(
Shm_Local_node = Shm_RTEMS_MP_Configuration->node;
Shm_Maximum_nodes = Shm_RTEMS_MP_Configuration->maximum_nodes;
Shm_Get_configuration( Shm_Local_node ,&Shm_Configuration );
Shm_Get_configuration( Shm_Local_node, &Shm_Configuration );
Shm_Receive_message_count = 0;
Shm_Null_message_count = 0;
@@ -61,13 +63,12 @@ rtems_mpci_entry Shm_Initialization(
* Set the Node Status indicators
*/
#define PEND Shm_Convert(rtems_build_name( 'P', 'E', 'N', 'D' ))
#define COMP Shm_Convert(rtems_build_name( 'C', 'O', 'M', 'P' ))
#define ACTV Shm_Convert(rtems_build_name( 'A', 'C', 'T', 'V' ))
Shm_Pending_initialization = PEND;
Shm_Initialization_complete = COMP;
Shm_Active_node = ACTV;
Shm_Pending_initialization =
Shm_Convert(rtems_build_name( 'P', 'E', 'N', 'D' ));
Shm_Initialization_complete =
Shm_Convert(rtems_build_name( 'C', 'O', 'M', 'P' ));
Shm_Active_node =
Shm_Convert(rtems_build_name( 'A', 'C', 'T', 'V' ));
/*
* Initialize the constants used by the Locked Queue code.
@@ -128,10 +129,11 @@ rtems_mpci_entry Shm_Initialization(
* Zero out the shared memory area.
*/
for ( u32_ptr = (rtems_unsigned32 *)Shm_Configuration->base,
endshm = (rtems_unsigned32 *)END_SHARED_MEM ;
u32_ptr < endshm ; )
*u32_ptr++ = 0;
(void) memset(
(void *) Shm_Configuration->base,
0,
Shm_Configuration->length
);
/*
* Initialize all of the locked queues (the free envelope
@@ -174,18 +176,14 @@ rtems_mpci_entry Shm_Initialization(
* Loop until all nodes have completed initialization.
*/
all_initialized = 0;
for ( ; ; ) {
if ( all_initialized == 1 ) break;
do {
all_initialized = 1;
for ( i = SHM_FIRST_NODE ; i <= Shm_Maximum_nodes ; i++ )
if ( Shm_Node_statuses[ i ].status != Shm_Initialization_complete )
all_initialized = 0;
}
} while ( all_initialized == 0 );
/*
* Tell the other nodes we think that the system is up.

View File

@@ -22,7 +22,7 @@
extern "C" {
#endif
#include "shm.h"
#include <shm.h>
#define MPCI_Initialization( _configuration ) \
Shm_Initialization( _configuration )

View File

@@ -44,8 +44,9 @@ void Shm_Poll()
Shm_Lock( Shm_Local_receive_queue );
tmpfront = Shm_Local_receive_queue->front;
Shm_Unlock( Shm_Local_receive_queue );
if ( Shm_Convert(tmpfront) == Shm_Locked_queue_End_of_list ) return;
rtems_multiprocessing_announce();
Shm_Interrupt_count++;
if ( Shm_Convert(tmpfront) != Shm_Locked_queue_End_of_list ) {
rtems_multiprocessing_announce();
Shm_Interrupt_count++;
}
}
}

View File

@@ -172,16 +172,29 @@ extern "C" {
/* null pointers of different types */
#define NULL_ENV_CB ((Shm_Envelope_control *) 0)
#define NULL_SHM_INFO ((struct shm_info *) 0)
#define NULL_CONVERT 0
#if 0
#define NULL_CONVERT (((rtems_unsigned32 *)())0) /* we want this */
/*
* size of stuff before preamble in envelope.
* It must be a constant since we will use it to generate MAX_PACKET_SIZE
*/
#define SHM_ENVELOPE_PREFIX_OVERHEAD (4 * sizeof(vol_u32))
/*
* The following is adjusted so envelopes are MAX_ENVELOPE_SIZE bytes long.
* It must be >= RTEMS_MINIMUM_PACKET_SIZE in mppkt.h.
*/
#ifndef MAX_ENVELOPE_SIZE
#define MAX_ENVELOPE_SIZE 0x180
#endif
/* The following is adjusted so envelopes are 0x80 bytes long. */
/* It should be >= MIN_PKT_SIZE in rtems.h */
#define MAX_PACKET_SIZE (MAX_ENVELOPE_SIZE - \
SHM_ENVELOPE_PREFIX_OVERHEAD + \
sizeof(Shm_Envelope_preamble) + \
sizeof(Shm_Envelope_postamble))
#define MAX_PACKET_SIZE (80)
/* constants pertinent to Locked Queue routines */
@@ -200,17 +213,6 @@ extern "C" {
* is defined in a system dependent file.
*/
#if 0
#define START_NS_CBS ( (rtems_unsigned8 *) START_SHARED_MEM )
#define START_LQ_CBS ( ((rtems_unsigned8 *) START_NS_CBS) + \
( (sizeof (Shm_Node_status_control)) * (Shm_Maximum_nodes + 1) ) )
#define START_ENVELOPES ( ((rtems_unsigned8 *) START_LQ_CBS) + \
( (sizeof (Shm_Locked_queue_Control)) * (Shm_Maximum_nodes + 1) ) )
#define END_SHMCI_AREA ( (rtems_unsigned8 *) START_ENVELOPES + \
( (sizeof (Shm_Envelope_control)) * Shm_Maximum_envelopes ) )
#define END_SHARED_MEM ((rtems_unsigned32)START_SHARED_MEM+SHARED_MEM_LEN)
#endif
#define START_NS_CBS ((void *)Shm_Configuration->base)
#define START_LQ_CBS ((START_NS_CBS) + \
( (sizeof (Shm_Node_status_control)) * (Shm_Maximum_nodes + 1) ) )
@@ -222,7 +224,7 @@ extern "C" {
/* macros */
#define Shm_Is_master_node() \
#define Shm_Is_master_node() \
( SHM_MASTER == Shm_Local_node )
#define Shm_Free_envelope( ecb ) \
@@ -241,14 +243,14 @@ extern "C" {
#define Shm_Packet_prefix_to_envelope_control_pointer( pkt ) \
((Shm_Envelope_control *)((rtems_unsigned8 *)(pkt) - \
(sizeof(Shm_Envelope_preamble) + 4*sizeof(vol_u32))))
(sizeof(Shm_Envelope_preamble) + SHM_ENVELOPE_PREFIX_OVERHEAD)))
#define Shm_Build_preamble(ecb, node) \
(ecb)->Preamble.endian = Shm_Configuration->format
#define Shm_Build_postamble( ecb )
/* structures */
/* volatile types */
typedef volatile rtems_unsigned8 vol_u8;
typedef volatile rtems_unsigned32 vol_u32;
@@ -271,15 +273,10 @@ typedef struct {
} Shm_Envelope_preamble;
typedef struct {
vol_u32 not_currently_used_0;
vol_u32 not_currently_used_1;
vol_u32 not_currently_used_2;
vol_u32 not_currently_used_3;
/*byte end_of_text;*/
} Shm_Envelope_postable;
} Shm_Envelope_postamble;
/* WARNING! If you change this structure, don't forget to change
* Shm_Envelope_control_to_packet_prefix_pointer() and
* SHM_ENVELOPE_PREFIX_OVERHEAD and
* Shm_Packet_prefix_to_envelope_control_pointer() above.
*/
@@ -305,7 +302,7 @@ typedef struct {
vol_u32 pad0; /* insure the next one is aligned */
Shm_Envelope_preamble Preamble; /* header information */
vol_u8 packet[MAX_PACKET_SIZE]; /* RTEMS INFO */
Shm_Envelope_postable Postamble;/* trailer information */
Shm_Envelope_postamble Postamble;/* trailer information */
} Shm_Envelope_control;
/* This comment block describes the contents of each field
@@ -513,6 +510,8 @@ rtems_mpci_entry Shm_Send_packet(
rtems_packet_prefix *
);
extern rtems_mpci_table MPCI_table;
#ifdef _SHM_INIT
/* multiprocessor communications interface (MPCI) table */
@@ -526,10 +525,6 @@ rtems_mpci_table MPCI_table = {
Shm_Receive_packet /* packet receive procedure */
};
#else
extern rtems_mpci_table MPCI_table;
#endif
#ifdef __cplusplus