Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(374)

Side by Side Diff: mojo/nacl/generator/mojo_syscall.cc.tmpl

Issue 385983008: Mojo + NaCl prototype. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: FinalEdits Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/nacl/generator/libmojo.cc.tmpl ('k') | mojo/nacl/mojo_syscall.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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/nacl/mojo_syscall.h"
8
9 #include <stdio.h>
10
11 #include "mojo/nacl/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->ndesc_length != 0) {
28 return -1;
29 }
30
31 uint32_t volatile* params = static_cast<uint32_t volatile*>(msg->iov[0].base);
32 size_t num_params = msg->iov[0].length / sizeof(*params);
33
34 if (num_params < 1) {
35 return -1;
36 }
37
38 uint32_t msg_type = params[0];
39 switch (msg_type) {
40 {{body}}
41 }
42
43 return -1;
44 }
45
46 ssize_t MojoDescRecvMsg(void* handle,
47 struct NaClImcTypedMsgHdr* msg,
48 int flags) {
49 return -1;
50 }
51
52 struct NaClDesc* MakeMojoDesc(struct NaClApp* nap) {
53 struct NaClDescCustomFuncs funcs = NACL_DESC_CUSTOM_FUNCS_INITIALIZER;
54 funcs.Destroy = MojoDescDestroy;
55 funcs.SendMsg = MojoDescSendMsg;
56 funcs.RecvMsg = MojoDescRecvMsg;
57 return NaClDescMakeCustomDesc(nap, &funcs);
58 }
59
60 } // namespace
61
62 #define NACL_MOJO_DESC (NACL_CHROME_DESC_BASE + 2)
63
64 void InjectMojo(struct NaClApp* nap) {
65 NaClAppSetDesc(nap, NACL_MOJO_DESC, MakeMojoDesc(nap));
66 }
OLDNEW
« no previous file with comments | « mojo/nacl/generator/libmojo.cc.tmpl ('k') | mojo/nacl/mojo_syscall.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698