blob: 298b782f6a537f13f09e83f72ed6e284dc9cf681 [file] [log] [blame]
Niranjan Yadla19336af2018-04-19 12:19:27 -07001/*******************************************************************************
2* Copyright (C) 2018 Cadence Design Systems, Inc.
3*
4* Permission is hereby granted, free of charge, to any person obtaining
5* a copy of this software and associated documentation files (the
6* "Software"), to use this Software with Cadence processor cores only and
7* not with any other processors and platforms, subject to
8* the following conditions:
9*
10* The above copyright notice and this permission notice shall be included
11* in all copies or substantial portions of the Software.
12*
13* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
14* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
15* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
17* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
18* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
19* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
21******************************************************************************/
22
23/*******************************************************************************
24 * xf-proxy.h
25 *
26 * Proxy commmand/response messages
27 *
28 *******************************************************************************/
29
30#ifndef __XF_H
31#error "xf-proxy.h mustn't be included directly"
32#endif
33
34/*******************************************************************************
35 * Types definitions
36 ******************************************************************************/
37#ifdef XAF_ENABLE_NON_HIKEY
38/* ...command/response message */
39typedef struct xf_proxy_message
40{
41 /* ...session ID */
42 u32 session_id;
43
44 /* ...proxy API command/reponse code */
45 u32 opcode;
46
47 /* ...length of attached buffer */
48 u32 length;
49
50 /* ...physical address of message buffer */
51 u32 address;
52
53} __attribute__((__packed__)) xf_proxy_message_t;
54#else
55/* ...command/response message */
56typedef struct xf_proxy_message
57{
58 /* ...session ID */
59 uint32_t session_id;
60
61 /* ...proxy API command/reponse code */
62 uint32_t opcode;
63
64 /* ...length of attached buffer */
65 uint32_t length;
66
67 /* ...physical address of message buffer */
68 uint64_t address;
69 uint64_t v_address;
70
71}/* __attribute__((__packed__)) */xf_proxy_message_t;
72#endif
73/*******************************************************************************
74 * Ring buffer support
75 ******************************************************************************/
76
77/* ...total length of shared memory queue (for commands and responses) */
78#define XF_PROXY_MESSAGE_QUEUE_LENGTH (1 << 8)
79
80/* ...index mask */
81#define XF_PROXY_MESSAGE_QUEUE_MASK 0xFF
82
83/* ...ring-buffer index */
84#define __XF_QUEUE_IDX(idx, counter) \
85 (((idx) & XF_PROXY_MESSAGE_QUEUE_MASK) | ((counter) << 16))
86
87/* ...retrieve ring-buffer index */
88#define XF_QUEUE_IDX(idx) \
89 ((idx) & XF_PROXY_MESSAGE_QUEUE_MASK)
90
91/* ...increment ring-buffer index */
92#define XF_QUEUE_ADVANCE_IDX(idx) \
93 (((idx) + 0x10001) & (0xFFFF0000 | XF_PROXY_MESSAGE_QUEUE_MASK))
94
95/* ...test if ring buffer is empty */
96#define XF_QUEUE_EMPTY(read, write) \
97 ((read) == (write))
98
99/* ...test if ring buffer is full */
100#define XF_QUEUE_FULL(read, write) \
101 ((write) == (read) + (XF_PROXY_MESSAGE_QUEUE_LENGTH << 16))