1 /*
2 * Copyright (c) 2011-2015 Texas Instruments Incorporated
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in
12 * the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name Texas Instruments nor the names of its
15 * contributors may be used to endorse or promote products derived
16 * from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
31 #if !defined (_MESSAGEQCOPYDEFS_H_0x5f84)
32 #define _MESSAGEQCOPYDEFS_H_0x5f84
34 /* Module headers */
35 #include <VirtQueue.h>
36 #include "virtio_ring.h"
37 #include <rpmsg.h>
39 #if defined (__cplusplus)
40 extern "C" {
41 #endif /* defined (__cplusplus) */
44 /* =============================================================================
45 * Macros and types
46 * =============================================================================
47 */
48 /*!
49 * @def MessageQCopy_BUFSIZE
50 * @brief Size of each MessageQCopy message.
51 */
52 #define MessageQCopy_BUFSIZE RPMSG_BUF_SIZE
54 /*!
55 * @def MessageQCopy_ADDRANY
56 * @brief Address used to specify any address.
57 */
58 #define MessageQCopy_ADDRANY RPMSG_ADDR_ANY
60 /*!
61 * @def MessageQCopy_MAXMQS
62 * @brief Maximum number of MQ handles (endpoints) per transport supported.
63 */
64 #define MessageQCopy_MAXMQS 2280u
66 /*!
67 * @def MessageQCopy_NUMVIRTQS
68 * @brief Number of VirtQueues per processor.
69 */
70 #define MessageQCopy_NUMVIRTQS 2u
72 /* Predefined endpoint addresses */
73 /*!
74 * @def MessageQCopy_NS_PORT
75 * @brief Name Service endpoint address.
76 */
77 #define MessageQCopy_NS_PORT (53)
80 #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
82 /*!
83 * @def MessageQCopy_NUMBUFS
84 * @brief Number of buffers per VirtQueue.
85 */
86 #define MessageQCopy_NUMBUFS (256)
88 /*!
89 * @def MessageQCopy_BUFSPACE
90 * @brief Space used by buffers per remote proc.
91 */
92 #define MessageQCopy_BUFSPACE (MessageQCopy_NUMBUFS * RPMSG_BUF_SIZE *\
93 MessageQCopy_NUMVIRTQS)
95 /*!
96 * @def PAGE_SIZE
97 * @brief Page size.
98 */
99 #define PAGE_SIZE (4096)
101 /*!
102 * @def MessageQCopy_MAXRESERVEDEPT
103 * @brief Maximum Value for System Reserved Endpoints.
104 */
105 #define MessageQCopy_MAXRESERVEDEPT 1024
107 /*
108 * The alignment to use between consumer and producer parts of vring.
109 * Note: this is part of the "wire" protocol. If you change this, you need
110 * to update your BIOS image as well
111 */
112 #define MessageQCopy_VRINGALIGN (4096)
114 /*!
115 * @def MessageQCopy_RINGSIZE
116 * @brief Size of the vring. With 256 buffers, our vring will occupy 3 pages.
117 */
118 #define MessageQCopy_RINGSIZE ((DIV_ROUND_UP(vring_size(MessageQCopy_NUMBUFS, \
119 MessageQCopy_VRINGALIGN), PAGE_SIZE)) * PAGE_SIZE)
121 /*!
122 * @def MessageQCopy_IPCMEM
123 * @brief The total IPC space needed to communicate with a remote processor.
124 */
125 #define MessageQCopy_IPCMEM (MessageQCopy_BUFSPACE + MessageQCopy_NUMVIRTQS *\
126 MessageQCopy_RINGSIZE)
129 #if defined (__cplusplus)
130 }
131 #endif /* defined (__cplusplus) */
134 #endif /* !defined (_MESSAGEQCOPY_H_0x5f84) */