summaryrefslogtreecommitdiff
path: root/arch/arm/mach-tegra/nvrm/core/common/nvrm_rpc.h
blob: d74ab4e3077644bd04ba44c5b518a3df55b05af4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
/*
 * Copyright (c) 2010 NVIDIA Corporation.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 *
 * Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation
 * and/or other materials provided with the distribution.
 *
 * Neither the name of the NVIDIA Corporation nor the names of its contributors
 * may be used to endorse or promote products derived from this software
 * without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 */

#ifndef NVRM_RPC_H
#define NVRM_RPC_H

/*
 * nvrm_cpu_avp_rpc_private.h defines the private implementation functions to facilitate 
 * communication between processors (cpu and avp).
 */

#include "nvcommon.h"
#include "nvos.h"
#include "nvrm_init.h"
#include "nvrm_message.h"

#ifdef __cplusplus
extern "C"
{
#endif  /* __cplusplus */


/**
 * Initialize RPC
 * 
 * Init the RPC.  Both the service and client
 * to the service must call this API before calling to create each endpoint of the connection
 * via NvRmPrivRPCConnect
 *
 * If PortName is too long or does not exist debug mode 
 * assert is encountered.
 *
 * @param hDeviceHandle rm device handle
 * @param rpcPortName the port name
 * @param hRPCHandle the RPC transport handle
 *
 * @retval NvError_SemaphoreCreateFailed Creaion of semaphore failed.
 */ 
 NvError NvRmPrivRPCInit( NvRmDeviceHandle hDeviceHandle, char* rpcPortName, NvRmRPCHandle *hRPCHandle );
/**
 * De-intialize the RPC and other resources.
 * @param hRPCHandle the RPC transport handle
 *
 */
void NvRmPrivRPCDeInit( NvRmRPCHandle hRPCHandle );

/**
 * Connect to RPC port
 * 
 * Creates one end of a RPC connection.  Both the service and client
 * to the service must call this API to create each endpoint of the connection
 * through a specified port
 *
 * If PortName is too long or does not exist debug mode 
 * assert is encountered.
 *
 * @param hRPCHandle the RPC transport handle
 * 
 * @retval NvSuccess Transport endpoint successfully allocated
 * @retval NvError_InsufficientMemory Not enough memory to allocate endpoint
 * @retval NvError_MutexCreateFailed Creaion of mutex failed.
 * @retval NvError_SemaphoreCreateFailed Creaion of semaphore failed.
 * @retval NvError_SharedMemAllocFailed Creaion of shared memory allocation
 * failed.
 * @retval NvError_NotInitialized The transport is not able to initialzed the
 * threads.
 */ 
 NvError NvRmPrivRPCConnect( NvRmRPCHandle hRPCHandle );

 /**
 * Connect to RPC port
 * 
 * Creates one end of a RPC connection.  Both the service and client
 * to the service must call this API to create each endpoint of the connection
 * through a specified port
 *
 * If PortName is too long or does not exist debug mode 
 * assert is encountered.
 *
 * @param hRPCHandle the RPC transport handle
 * 
 * @retval NvSuccess Transport endpoint successfully allocated
 * @retval NvError_InsufficientMemory Not enough memory to allocate endpoint
 * @retval NvError_MutexCreateFailed Creaion of mutex failed.
 * @retval NvError_SemaphoreCreateFailed Creaion of semaphore failed.
 * @retval NvError_SharedMemAllocFailed Creaion of shared memory allocation
 * failed.
 * @retval NvError_NotInitialized The transport is not able to initialzed the
 * threads.
 */ 
 NvError NvRmPrivRPCWaitForConnect( NvRmRPCHandle hRPCHandle );
 /**
 * Receive the message from the port. This will read the message if it is 
 * available for this port otherwise it will return the
 * NvError_TransportMessageBoxEmpty error.
 * 
 * @param hRPCHandle the RPC transport handle
 * @param pMessageBuffer The pointer to the receive message buffer where the
 * received message will be copied.
 * @param pMessageSize Pointer to the variable where the length of the message 
 * will be stored.
 * 
 * @retval NvSuccess Message received successfully.
 * @retval NvError_NotInitialized hTransport is not open.
 * @retval NvError_InvalidState The port is not connection state.
 * @retval NvError_TransportMessageBoxEmpty The message box empty and not able 
 * to receive the message.
 * @retval NvError_TransportIncompleteMessage The received message for this
 * port is longer than the configured message length for this port. It copied
 * the maximm size of the configured length of the message for this port and
 * return the incomplete message buffer.
 * @retval NvError_TransportMessageOverflow The port receives the message more
 * than the configured queue depth count for this port and hence message
 * overflow has been ocuured.
 */

 NvError NvRmPrivRPCRecvMsg( NvRmRPCHandle hRPCHandle, void* pMessageBuffer, NvU32 * pMessageSize );

 /**
 * Send Message.
 *
 * Sends a message to the other port which is connected to this port.
 * Its a wrapper to rm transport send message
 *
 * @param hRPCHandle the RPC transport handle
 * @param pMessageBuffer The pointer to the message buffer where message which 
 * need to be send is available.
 * @param MessageSize Specifies the size of the message.
 * 
 */
void
NvRmPrivRPCSendMsg(NvRmRPCHandle hRPCHandle,
                   void* pMessageBuffer,
                   NvU32 MessageSize);

/**
 * Send and Recieve message.
 *
 * Send and Recieve a message between port.
 * Its a wrapper to rm transport send message with response
 *
 * @param hRPCHandle the RPC transport handle
 * @param pRecvMessageBuffer The pointer to the receive message buffer where the
 * received message will be copied.
 * @param MaxSize The maximum size in bytes that may be copied to the buffer
 * @param pMessageSize Pointer to the variable where the length of the message 
 * will be stored.
 * @param pSendMessageBuffer The pointer to the message buffer where message which 
 * need to be send is available.
 * @param MessageSize Specifies the size of the message.
 * 
 */
void
NvRmPrivRPCSendMsgWithResponse(NvRmRPCHandle hRPCHandle,
                               void* pRecvMessageBuffer,
                               NvU32 MaxSize,
                               NvU32 *pMessageSize,
                               void* pSendMessageBuffer,
                               NvU32 MessageSize);


/**
 * Closes a transport connection.  Proper closure of this connection requires
 * that both the client and service call this API.  Therefore, it is expected
 * that the client and service message one another to coordinate the close.
 *
 */
void NvRmPrivRPCClose(NvRmRPCHandle hRPCHandle);

NvError  NvRmPrivInitService(NvRmDeviceHandle hDeviceHandle);

void NvRmPrivServiceDeInit(void);

#ifdef __cplusplus
}
#endif  /* __cplusplus */


#endif