1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // WARNING this file was generated by generate_nacl_bindings.py
6 // Do not edit by hand.
11 #include "mojo/public/c/system/core.h"
12 #include "mojo/public/platform/nacl/mojo_irt.h"
13 #include "native_client/src/public/chrome_main.h"
14 #include "native_client/src/public/imc_syscalls.h"
15 #include "native_client/src/public/imc_types.h"
16 #include "native_client/src/public/irt_core.h"
18 #define NACL_MOJO_DESC (NACL_CHROME_DESC_BASE + 3)
20 static void DoMojoCall(uint32_t params
[], nacl_abi_size_t num_params
) {
21 struct NaClAbiNaClImcMsgIoVec iov
[1] = {
24 struct NaClAbiNaClImcMsgHdr msgh
= {iov
, 1, NULL
, 0};
25 // Note: return value unchecked. We're relying on the result parameter being
26 // unmodified - if the syscall fails, the Mojo function will return whatever
27 // the result parameter was initialized to before this function was called.
28 imc_sendmsg(NACL_MOJO_DESC
, &msgh
, 0);
31 static MojoResult
irt_MojoCreateSharedBuffer(
32 const struct MojoCreateSharedBufferOptions
* options
,
34 MojoHandle
* shared_buffer_handle
) {
36 MojoResult result
= MOJO_RESULT_INVALID_ARGUMENT
;
38 params
[1] = (uint32_t)(options
);
39 params
[2] = (uint32_t)(&num_bytes
);
40 params
[3] = (uint32_t)(shared_buffer_handle
);
41 params
[4] = (uint32_t)(&result
);
42 DoMojoCall(params
, sizeof(params
));
46 static MojoResult
irt_MojoDuplicateBufferHandle(
47 MojoHandle buffer_handle
,
48 const struct MojoDuplicateBufferHandleOptions
* options
,
49 MojoHandle
* new_buffer_handle
) {
51 MojoResult result
= MOJO_RESULT_INVALID_ARGUMENT
;
53 params
[1] = (uint32_t)(&buffer_handle
);
54 params
[2] = (uint32_t)(options
);
55 params
[3] = (uint32_t)(new_buffer_handle
);
56 params
[4] = (uint32_t)(&result
);
57 DoMojoCall(params
, sizeof(params
));
61 static MojoResult
irt_MojoMapBuffer(
62 MojoHandle buffer_handle
,
66 MojoMapBufferFlags flags
) {
68 MojoResult result
= MOJO_RESULT_INVALID_ARGUMENT
;
70 params
[1] = (uint32_t)(&buffer_handle
);
71 params
[2] = (uint32_t)(&offset
);
72 params
[3] = (uint32_t)(&num_bytes
);
73 params
[4] = (uint32_t)(buffer
);
74 params
[5] = (uint32_t)(&flags
);
75 params
[6] = (uint32_t)(&result
);
76 DoMojoCall(params
, sizeof(params
));
80 static MojoResult
irt_MojoUnmapBuffer(void* buffer
) {
82 MojoResult result
= MOJO_RESULT_INVALID_ARGUMENT
;
84 params
[1] = (uint32_t)(&buffer
);
85 params
[2] = (uint32_t)(&result
);
86 DoMojoCall(params
, sizeof(params
));
90 static MojoResult
irt_MojoCreateDataPipe(
91 const struct MojoCreateDataPipeOptions
* options
,
92 MojoHandle
* data_pipe_producer_handle
,
93 MojoHandle
* data_pipe_consumer_handle
) {
95 MojoResult result
= MOJO_RESULT_INVALID_ARGUMENT
;
97 params
[1] = (uint32_t)(options
);
98 params
[2] = (uint32_t)(data_pipe_producer_handle
);
99 params
[3] = (uint32_t)(data_pipe_consumer_handle
);
100 params
[4] = (uint32_t)(&result
);
101 DoMojoCall(params
, sizeof(params
));
105 static MojoResult
irt_MojoWriteData(
106 MojoHandle data_pipe_producer_handle
,
107 const void* elements
,
109 MojoWriteDataFlags flags
) {
111 MojoResult result
= MOJO_RESULT_INVALID_ARGUMENT
;
113 params
[1] = (uint32_t)(&data_pipe_producer_handle
);
114 params
[2] = (uint32_t)(elements
);
115 params
[3] = (uint32_t)(num_bytes
);
116 params
[4] = (uint32_t)(&flags
);
117 params
[5] = (uint32_t)(&result
);
118 DoMojoCall(params
, sizeof(params
));
122 static MojoResult
irt_MojoBeginWriteData(
123 MojoHandle data_pipe_producer_handle
,
125 uint32_t* buffer_num_bytes
,
126 MojoWriteDataFlags flags
) {
128 MojoResult result
= MOJO_RESULT_INVALID_ARGUMENT
;
130 params
[1] = (uint32_t)(&data_pipe_producer_handle
);
131 params
[2] = (uint32_t)(buffer
);
132 params
[3] = (uint32_t)(buffer_num_bytes
);
133 params
[4] = (uint32_t)(&flags
);
134 params
[5] = (uint32_t)(&result
);
135 DoMojoCall(params
, sizeof(params
));
139 static MojoResult
irt_MojoEndWriteData(
140 MojoHandle data_pipe_producer_handle
,
141 uint32_t num_bytes_written
) {
143 MojoResult result
= MOJO_RESULT_INVALID_ARGUMENT
;
145 params
[1] = (uint32_t)(&data_pipe_producer_handle
);
146 params
[2] = (uint32_t)(&num_bytes_written
);
147 params
[3] = (uint32_t)(&result
);
148 DoMojoCall(params
, sizeof(params
));
152 static MojoResult
irt_MojoReadData(
153 MojoHandle data_pipe_consumer_handle
,
156 MojoReadDataFlags flags
) {
158 MojoResult result
= MOJO_RESULT_INVALID_ARGUMENT
;
160 params
[1] = (uint32_t)(&data_pipe_consumer_handle
);
161 params
[2] = (uint32_t)(elements
);
162 params
[3] = (uint32_t)(num_bytes
);
163 params
[4] = (uint32_t)(&flags
);
164 params
[5] = (uint32_t)(&result
);
165 DoMojoCall(params
, sizeof(params
));
169 static MojoResult
irt_MojoBeginReadData(
170 MojoHandle data_pipe_consumer_handle
,
172 uint32_t* buffer_num_bytes
,
173 MojoReadDataFlags flags
) {
175 MojoResult result
= MOJO_RESULT_INVALID_ARGUMENT
;
177 params
[1] = (uint32_t)(&data_pipe_consumer_handle
);
178 params
[2] = (uint32_t)(buffer
);
179 params
[3] = (uint32_t)(buffer_num_bytes
);
180 params
[4] = (uint32_t)(&flags
);
181 params
[5] = (uint32_t)(&result
);
182 DoMojoCall(params
, sizeof(params
));
186 static MojoResult
irt_MojoEndReadData(
187 MojoHandle data_pipe_consumer_handle
,
188 uint32_t num_bytes_read
) {
190 MojoResult result
= MOJO_RESULT_INVALID_ARGUMENT
;
192 params
[1] = (uint32_t)(&data_pipe_consumer_handle
);
193 params
[2] = (uint32_t)(&num_bytes_read
);
194 params
[3] = (uint32_t)(&result
);
195 DoMojoCall(params
, sizeof(params
));
199 static MojoTimeTicks
irt_MojoGetTimeTicksNow() {
201 MojoTimeTicks result
= 0;
203 params
[1] = (uint32_t)(&result
);
204 DoMojoCall(params
, sizeof(params
));
208 static MojoResult
irt_MojoClose(MojoHandle handle
) {
210 MojoResult result
= MOJO_RESULT_INVALID_ARGUMENT
;
212 params
[1] = (uint32_t)(&handle
);
213 params
[2] = (uint32_t)(&result
);
214 DoMojoCall(params
, sizeof(params
));
218 static MojoResult
irt_MojoWait(
220 MojoHandleSignals signals
,
221 MojoDeadline deadline
,
222 struct MojoHandleSignalsState
* signals_state
) {
224 MojoResult result
= MOJO_RESULT_INVALID_ARGUMENT
;
226 params
[1] = (uint32_t)(&handle
);
227 params
[2] = (uint32_t)(&signals
);
228 params
[3] = (uint32_t)(&deadline
);
229 params
[4] = (uint32_t)(signals_state
);
230 params
[5] = (uint32_t)(&result
);
231 DoMojoCall(params
, sizeof(params
));
235 static MojoResult
irt_MojoWaitMany(
236 const MojoHandle
* handles
,
237 const MojoHandleSignals
* signals
,
238 uint32_t num_handles
,
239 MojoDeadline deadline
,
240 uint32_t* result_index
,
241 struct MojoHandleSignalsState
* signals_states
) {
243 MojoResult result
= MOJO_RESULT_INVALID_ARGUMENT
;
245 params
[1] = (uint32_t)(handles
);
246 params
[2] = (uint32_t)(signals
);
247 params
[3] = (uint32_t)(&num_handles
);
248 params
[4] = (uint32_t)(&deadline
);
249 params
[5] = (uint32_t)(result_index
);
250 params
[6] = (uint32_t)(signals_states
);
251 params
[7] = (uint32_t)(&result
);
252 DoMojoCall(params
, sizeof(params
));
256 static MojoResult
irt_MojoCreateMessagePipe(
257 const struct MojoCreateMessagePipeOptions
* options
,
258 MojoHandle
* message_pipe_handle0
,
259 MojoHandle
* message_pipe_handle1
) {
261 MojoResult result
= MOJO_RESULT_INVALID_ARGUMENT
;
263 params
[1] = (uint32_t)(options
);
264 params
[2] = (uint32_t)(message_pipe_handle0
);
265 params
[3] = (uint32_t)(message_pipe_handle1
);
266 params
[4] = (uint32_t)(&result
);
267 DoMojoCall(params
, sizeof(params
));
271 static MojoResult
irt_MojoWriteMessage(
272 MojoHandle message_pipe_handle
,
275 const MojoHandle
* handles
,
276 uint32_t num_handles
,
277 MojoWriteMessageFlags flags
) {
279 MojoResult result
= MOJO_RESULT_INVALID_ARGUMENT
;
281 params
[1] = (uint32_t)(&message_pipe_handle
);
282 params
[2] = (uint32_t)(bytes
);
283 params
[3] = (uint32_t)(&num_bytes
);
284 params
[4] = (uint32_t)(handles
);
285 params
[5] = (uint32_t)(&num_handles
);
286 params
[6] = (uint32_t)(&flags
);
287 params
[7] = (uint32_t)(&result
);
288 DoMojoCall(params
, sizeof(params
));
292 static MojoResult
irt_MojoReadMessage(
293 MojoHandle message_pipe_handle
,
297 uint32_t* num_handles
,
298 MojoReadMessageFlags flags
) {
300 MojoResult result
= MOJO_RESULT_INVALID_ARGUMENT
;
302 params
[1] = (uint32_t)(&message_pipe_handle
);
303 params
[2] = (uint32_t)(bytes
);
304 params
[3] = (uint32_t)(num_bytes
);
305 params
[4] = (uint32_t)(handles
);
306 params
[5] = (uint32_t)(num_handles
);
307 params
[6] = (uint32_t)(&flags
);
308 params
[7] = (uint32_t)(&result
);
309 DoMojoCall(params
, sizeof(params
));
313 static MojoResult
irt__MojoGetInitialHandle(MojoHandle
* handle
) {
315 MojoResult result
= MOJO_RESULT_INVALID_ARGUMENT
;
317 params
[1] = (uint32_t)(handle
);
318 params
[2] = (uint32_t)(&result
);
319 DoMojoCall(params
, sizeof(params
));
323 struct nacl_irt_mojo kIrtMojo
= {
324 &irt_MojoCreateSharedBuffer
,
325 &irt_MojoDuplicateBufferHandle
,
327 &irt_MojoUnmapBuffer
,
328 &irt_MojoCreateDataPipe
,
330 &irt_MojoBeginWriteData
,
331 &irt_MojoEndWriteData
,
333 &irt_MojoBeginReadData
,
334 &irt_MojoEndReadData
,
335 &irt_MojoGetTimeTicksNow
,
339 &irt_MojoCreateMessagePipe
,
340 &irt_MojoWriteMessage
,
341 &irt_MojoReadMessage
,
342 &irt__MojoGetInitialHandle
,
346 size_t mojo_irt_query(const char* interface_ident
,
349 static const size_t size
= sizeof(kIrtMojo
);
350 if (0 == strcmp(interface_ident
, NACL_IRT_MOJO_v0_1
)) {
351 if (size
<= tablesize
) {
352 memcpy(table
, &kIrtMojo
, size
);