source: rtems/c/src/lib/libbsp/powerpc/qoriq/shmsupp/intercom-mpci.c @ dc0a7df

4.115
Last change on this file since dc0a7df was dc0a7df, checked in by Sebastian Huber <sebastian.huber@…>, on 07/21/11 at 15:18:02

2011-07-21 Sebastian Huber <sebastian.huber@…>

PR 1799/bsps

  • .cvsignore, ChangeLog?, Makefile.am, README, bsp_specs, configure.ac, clock/clock-config.c, console/console-config.c, console/uart-bridge-master.c, console/uart-bridge-slave.c, include/.cvsignore, include/bsp.h, include/hwreg_vals.h, include/intercom.h, include/irq.h, include/mmu.h, include/qoriq.h, include/tm27.h, include/tsec-config.h, include/u-boot-config.h, include/uart-bridge.h, irq/irq.c, make/custom/qoriq.inc, make/custom/qoriq_core_0.cfg, make/custom/qoriq_core_1.cfg, make/custom/qoriq_p1020rdb.cfg, network/if_intercom.c, network/network.c, rtc/rtc-config.c, shmsupp/intercom-mpci.c, shmsupp/intercom.c, shmsupp/lock.S, start/start.S, startup/bsppredriverhook.c, startup/bspreset.c, startup/bspstart.c, startup/linkcmds.base, startup/linkcmds.qoriq_core_0, startup/linkcmds.qoriq_core_1, startup/linkcmds.qoriq_p1020rdb, startup/mmu-config.c, startup/mmu-tlb1.S, startup/mmu.c: New files.
  • Property mode set to 100644
File size: 2.8 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup QorIQInterCom
5 *
6 * @brief Inter-Processor Communication implementation.
7 */
8
9/*
10 * Copyright (c) 2011 embedded brains GmbH.  All rights reserved.
11 *
12 *  embedded brains GmbH
13 *  Obere Lagerstr. 30
14 *  82178 Puchheim
15 *  Germany
16 *  <rtems@embedded-brains.de>
17 *
18 * The license and distribution terms for this file may be
19 * found in the file LICENSE in this distribution or at
20 * http://www.rtems.com/license/LICENSE.
21 *
22 * $Id$
23 */
24
25#include <assert.h>
26
27#include <libcpu/powerpc-utility.h>
28
29#include <bsp/intercom.h>
30
31#ifdef RTEMS_MULTIPROCESSING
32
33typedef struct {
34        intercom_packet *head;
35        intercom_packet *tail;
36} mpic_fifo;
37
38static mpic_fifo fifo;
39
40static void mpci_service(intercom_packet *packet, void *arg)
41{
42        rtems_interrupt_level level;
43
44        rtems_interrupt_disable(level);
45        packet->glue.next = NULL;
46        if (fifo.head != NULL) {
47                fifo.tail->glue.next = packet;
48        } else {
49                fifo.head = packet;
50        }
51        fifo.tail = packet;
52        rtems_interrupt_enable(level);
53
54        rtems_multiprocessing_announce();
55}
56
57static void mpci_init(void)
58{
59        qoriq_intercom_service_install(INTERCOM_TYPE_MPCI, mpci_service, NULL);
60}
61
62static intercom_packet *packet_of_prefix(rtems_packet_prefix *prefix)
63{
64        return (intercom_packet *) ((char *) prefix - sizeof(intercom_packet));
65}
66
67static rtems_packet_prefix *prefix_of_packet(intercom_packet *packet)
68{
69        return (rtems_packet_prefix *) packet->data;
70}
71
72static void mpci_get_packet(rtems_packet_prefix **prefix_ptr)
73{
74        intercom_packet *packet = qoriq_intercom_allocate_packet(
75                INTERCOM_TYPE_MPCI,
76                INTERCOM_SIZE_512
77        );
78        *prefix_ptr = prefix_of_packet(packet);
79}
80
81static void mpci_return_packet(rtems_packet_prefix *prefix)
82{
83        intercom_packet *packet = packet_of_prefix(prefix);
84
85        qoriq_intercom_free_packet(packet);
86}
87
88static void mpci_send_packet(uint32_t destination_node, rtems_packet_prefix *prefix)
89{
90        intercom_packet *packet = packet_of_prefix(prefix);
91        if (destination_node != MPCI_ALL_NODES) {
92                qoriq_intercom_send_packet((int) destination_node - 1, packet);
93        } else {
94                uint32_t self = ppc_processor_id();
95                int other = self == 0 ? 1 : 0;
96
97                qoriq_intercom_send_packet(other, packet);
98        }
99}
100
101static void mpci_receive_packet(rtems_packet_prefix **prefix_ptr)
102{
103        rtems_interrupt_level level;
104
105        rtems_interrupt_disable(level);
106        intercom_packet *packet = fifo.head;
107        if (packet != NULL) {
108                fifo.head = packet->glue.next;
109                *prefix_ptr = prefix_of_packet(packet);
110        } else {
111                *prefix_ptr = NULL;
112        }
113        rtems_interrupt_enable(level);
114}
115
116rtems_mpci_table qoriq_intercom_mpci = {
117        .default_timeout = UINT32_MAX,
118        .maximum_packet_size = 512 - sizeof(rtems_packet_prefix),
119        .initialization = mpci_init,
120        .get_packet = mpci_get_packet,
121        .return_packet = mpci_return_packet,
122        .send_packet = mpci_send_packet,
123        .receive_packet = mpci_receive_packet
124};
125
126#endif /* RTEMS_MULTIPROCESSING */
Note: See TracBrowser for help on using the repository browser.