1 | /* Shm_Send_packet |
---|
2 | * |
---|
3 | * This routine is the shared memory driver locked queue write |
---|
4 | * MPCI driver routine. This routine sends the specified packet |
---|
5 | * to the destination specified by "node". A "node" value of |
---|
6 | * zero designates that this packet is to be broadcasted. |
---|
7 | * |
---|
8 | * Input parameters: |
---|
9 | * node - destination of this packet (0 = broadcast) |
---|
10 | * packet - address of packet |
---|
11 | * |
---|
12 | * Output parameters: NONE |
---|
13 | * |
---|
14 | * COPYRIGHT (c) 1989-1997. |
---|
15 | * On-Line Applications Research Corporation (OAR). |
---|
16 | * Copyright assigned to U.S. Government, 1994. |
---|
17 | * |
---|
18 | * The license and distribution terms for this file may in |
---|
19 | * the file LICENSE in this distribution or at |
---|
20 | * http://www.OARcorp.com/rtems/license.html. |
---|
21 | * |
---|
22 | * $Id$ |
---|
23 | */ |
---|
24 | |
---|
25 | #include <rtems.h> |
---|
26 | #include "shm.h" |
---|
27 | |
---|
28 | struct pkt_cpy { |
---|
29 | rtems_unsigned32 packet[MAX_PACKET_SIZE/4]; |
---|
30 | }; |
---|
31 | |
---|
32 | rtems_mpci_entry Shm_Send_packet( |
---|
33 | rtems_unsigned32 node, |
---|
34 | rtems_packet_prefix *packet |
---|
35 | ) |
---|
36 | { |
---|
37 | Shm_Envelope_control *ecb, *tmp_ecb; |
---|
38 | rtems_unsigned32 nnum; |
---|
39 | |
---|
40 | ecb = Shm_Packet_prefix_to_envelope_control_pointer( packet ); |
---|
41 | if ( node ) { |
---|
42 | Shm_Build_preamble( ecb, node ); |
---|
43 | Shm_Build_postamble( ecb ); |
---|
44 | Shm_Append_to_receive_queue( node, ecb ); |
---|
45 | (*Shm_Configuration->cause_intr)( node ); |
---|
46 | } |
---|
47 | else { |
---|
48 | for( nnum = SHM_FIRST_NODE ; nnum <= Shm_Maximum_nodes ; nnum++ ) |
---|
49 | if ( Shm_Local_node != nnum ) { |
---|
50 | tmp_ecb = Shm_Allocate_envelope(); |
---|
51 | if ( !tmp_ecb ) |
---|
52 | rtems_fatal_error_occurred( SHM_NO_FREE_PKTS ); |
---|
53 | Shm_Build_preamble( tmp_ecb, nnum ); |
---|
54 | *((struct pkt_cpy *)tmp_ecb->packet) = *((struct pkt_cpy *)packet); |
---|
55 | Shm_Build_postamble( tmp_ecb ); |
---|
56 | Shm_Append_to_receive_queue( nnum, tmp_ecb ); |
---|
57 | (*Shm_Configuration->cause_intr)( nnum ); |
---|
58 | } |
---|
59 | Shm_Free_envelope( ecb ); |
---|
60 | } |
---|
61 | } |
---|