Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:57

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  *
0006  * @ingroup RTEMSBSPsPowerPCQorIQInterCom
0007  *
0008  * @brief Inter-Processor Communication API.
0009  */
0010 
0011 /*
0012  * Copyright (c) 2011 embedded brains GmbH & Co. KG
0013  *
0014  * Redistribution and use in source and binary forms, with or without
0015  * modification, are permitted provided that the following conditions
0016  * are met:
0017  * 1. Redistributions of source code must retain the above copyright
0018  *    notice, this list of conditions and the following disclaimer.
0019  * 2. Redistributions in binary form must reproduce the above copyright
0020  *    notice, this list of conditions and the following disclaimer in the
0021  *    documentation and/or other materials provided with the distribution.
0022  *
0023  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0024  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0025  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0026  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0027  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0028  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0029  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0030  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0031  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0032  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0033  * POSSIBILITY OF SUCH DAMAGE.
0034  */
0035 
0036 #ifndef LIBBSP_POWERPC_QORIQ_INTERCOM_H
0037 #define LIBBSP_POWERPC_QORIQ_INTERCOM_H
0038 
0039 #include <rtems.h>
0040 #include <rtems/chain.h>
0041 
0042 #ifdef __cplusplus
0043 extern "C" {
0044 #endif /* __cplusplus */
0045 
0046 /**
0047  * @defgroup QorIQInterCom QorIQ - Inter-Processor Communication Support
0048  *
0049  * @ingroup RTEMSBSPsPowerPCQorIQ
0050  *
0051  * @brief Inter-processor communication support.
0052  *
0053  * @{
0054  */
0055 
0056 uint32_t qoriq_spin_lock(uint32_t *lock);
0057 
0058 void qoriq_spin_unlock(uint32_t *lock, uint32_t msr);
0059 
0060 #define INTERCOM_CORE_COUNT 2
0061 
0062 #define INTERCOM_SERVICE_COUNT 8
0063 
0064 typedef enum {
0065     INTERCOM_TYPE_MPCI,
0066     INTERCOM_TYPE_UART_0,
0067     INTERCOM_TYPE_UART_1,
0068     INTERCOM_TYPE_NETWORK,
0069     INTERCOM_TYPE_CUSTOM_0,
0070     INTERCOM_TYPE_CUSTOM_1,
0071     INTERCOM_TYPE_CUSTOM_2,
0072     INTERCOM_TYPE_CUSTOM_3,
0073     INTERCOM_TYPE_CUSTOM_4
0074 } intercom_type;
0075 
0076 typedef enum {
0077     INTERCOM_SIZE_64 = 0,
0078     INTERCOM_SIZE_512,
0079     INTERCOM_SIZE_2K,
0080     INTERCOM_SIZE_4K
0081 } intercom_size;
0082 
0083 typedef struct intercom_packet {
0084     union {
0085         struct intercom_packet *next;
0086         rtems_chain_node node;
0087     } glue;
0088     intercom_type type_index;
0089     intercom_size size_index;
0090     uint32_t flags;
0091     size_t size;
0092     uint32_t cache_line_alignment [2];
0093     char data [];
0094 } intercom_packet;
0095 
0096 typedef void (*intercom_service)(intercom_packet *packet, void *arg);
0097 
0098 void qoriq_intercom_init(void);
0099 
0100 void qoriq_intercom_start(void);
0101 
0102 void qoriq_intercom_service_install(intercom_type type, intercom_service service, void *arg);
0103 
0104 void qoriq_intercom_service_remove(intercom_type type);
0105 
0106 intercom_packet *qoriq_intercom_allocate_packet(intercom_type type, intercom_size size);
0107 
0108 void qoriq_intercom_send_packets(int destination_core, intercom_packet *first, intercom_packet *last);
0109 
0110 static inline void qoriq_intercom_send_packet(int destination_core, intercom_packet *packet)
0111 {
0112     qoriq_intercom_send_packets(destination_core, packet, packet);
0113 }
0114 
0115 void qoriq_intercom_broadcast_packets(intercom_packet *first, intercom_packet *last);
0116 
0117 static inline void qoriq_intercom_broadcast_packet(intercom_packet *packet)
0118 {
0119     qoriq_intercom_broadcast_packets(packet, packet);
0120 }
0121 
0122 void qoriq_intercom_send(int destination_core, intercom_type type, intercom_size size, const void *buf, size_t n);
0123 
0124 void qoriq_intercom_free_packet(intercom_packet *packet);
0125 
0126 intercom_packet *qoriq_intercom_clone_packet(const intercom_packet *packet);
0127 
0128 #ifdef RTEMS_MULTIPROCESSING
0129   extern rtems_mpci_table qoriq_intercom_mpci;
0130 #endif
0131 
0132 /** @} */
0133 
0134 #ifdef __cplusplus
0135 }
0136 #endif /* __cplusplus */
0137 
0138 #endif /* LIBBSP_POWERPC_QORIQ_INTERCOM_H */