OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 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. | |
4 | |
5 $generator_warning | |
6 | |
7 #include "mojo/monacl/mojo_syscall.h" | |
8 | |
9 #include <stdio.h> | |
10 | |
11 #include "mojo/monacl/mojo_syscall_internal.h" | |
12 #include "mojo/public/c/system/core.h" | |
13 #include "native_client/src/public/chrome_main.h" | |
14 #include "native_client/src/public/nacl_app.h" | |
15 #include "native_client/src/trusted/desc/nacl_desc_custom.h" | |
16 | |
17 namespace { | |
18 | |
19 void MojoDescDestroy(void* handle) { | |
20 } | |
21 | |
22 ssize_t MojoDescSendMsg(void* handle, | |
23 const struct NaClImcTypedMsgHdr* msg, | |
24 int flags) { | |
25 struct NaClApp* nap = static_cast<struct NaClApp*>(handle); | |
26 | |
27 if (msg->iov_length != 1 || msg->iov[0].length < 8 || | |
Mark Seaborn
2014/09/10 23:19:21
Minimum should be 4, not 8, surely? This could mo
Nick Bray (chromium)
2014/09/11 00:56:40
Technically correct, (always a return parameter),
| |
28 msg->ndesc_length != 0) { | |
29 return -1; | |
30 } | |
31 | |
32 uint32_t* params = static_cast<uint32_t*>(msg->iov[0].base); | |
Mark Seaborn
2014/09/10 23:19:21
This pointer should be volatile too, since it is r
Nick Bray (chromium)
2014/09/11 00:56:40
Unclear from the API.
Done.
| |
33 size_t num_params = msg->iov[0].length / sizeof(*params); | |
Mark Seaborn
2014/09/10 23:19:20
After:
if (num_params < 1)
return -1;
Nick Bray (chromium)
2014/09/11 00:56:40
Done.
| |
34 | |
35 uint32_t msg_type = params[0]; | |
36 switch (msg_type) { | |
37 $body | |
38 } | |
39 | |
40 return -1; | |
41 } | |
42 | |
43 ssize_t MojoDescRecvMsg(void* handle, | |
44 struct NaClImcTypedMsgHdr* msg, | |
45 int flags) { | |
46 return -1; | |
47 } | |
48 | |
49 struct NaClDesc* MakeMojoDesc(struct NaClApp* nap) { | |
50 struct NaClDescCustomFuncs funcs = NACL_DESC_CUSTOM_FUNCS_INITIALIZER; | |
51 funcs.Destroy = MojoDescDestroy; | |
52 funcs.SendMsg = MojoDescSendMsg; | |
53 funcs.RecvMsg = MojoDescRecvMsg; | |
54 return NaClDescMakeCustomDesc(nap, &funcs); | |
55 } | |
56 | |
57 } // namespace | |
58 | |
59 #define NACL_MOJO_DESC (NACL_CHROME_DESC_BASE + 2) | |
60 | |
61 void InjectMojo(struct NaClApp* nap) { | |
62 NaClAppSetDesc(nap, NACL_MOJO_DESC, MakeMojoDesc(nap)); | |
63 } | |
OLD | NEW |