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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/nacl/generator/mojo_syscall.cc.tmpl
diff --git a/mojo/nacl/generator/mojo_syscall.cc.tmpl b/mojo/nacl/generator/mojo_syscall.cc.tmpl
new file mode 100644
index 0000000000000000000000000000000000000000..136e672311fbcc41f993e80ec3a16c1b90b51608
--- /dev/null
+++ b/mojo/nacl/generator/mojo_syscall.cc.tmpl
@@ -0,0 +1,66 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+{{generator_warning}}
+
+#include "mojo/nacl/mojo_syscall.h"
+
+#include <stdio.h>
+
+#include "mojo/nacl/mojo_syscall_internal.h"
+#include "mojo/public/c/system/core.h"
+#include "native_client/src/public/chrome_main.h"
+#include "native_client/src/public/nacl_app.h"
+#include "native_client/src/trusted/desc/nacl_desc_custom.h"
+
+namespace {
+
+void MojoDescDestroy(void* handle) {
+}
+
+ssize_t MojoDescSendMsg(void* handle,
+ const struct NaClImcTypedMsgHdr* msg,
+ int flags) {
+ struct NaClApp* nap = static_cast<struct NaClApp*>(handle);
+
+ if (msg->iov_length != 1 || msg->ndesc_length != 0) {
+ return -1;
+ }
+
+ uint32_t volatile* params = static_cast<uint32_t volatile*>(msg->iov[0].base);
+ size_t num_params = msg->iov[0].length / sizeof(*params);
+
+ if (num_params < 1) {
+ return -1;
+ }
+
+ uint32_t msg_type = params[0];
+ switch (msg_type) {
+{{body}}
+ }
+
+ return -1;
+}
+
+ssize_t MojoDescRecvMsg(void* handle,
+ struct NaClImcTypedMsgHdr* msg,
+ int flags) {
+ return -1;
+}
+
+struct NaClDesc* MakeMojoDesc(struct NaClApp* nap) {
+ struct NaClDescCustomFuncs funcs = NACL_DESC_CUSTOM_FUNCS_INITIALIZER;
+ funcs.Destroy = MojoDescDestroy;
+ funcs.SendMsg = MojoDescSendMsg;
+ funcs.RecvMsg = MojoDescRecvMsg;
+ return NaClDescMakeCustomDesc(nap, &funcs);
+}
+
+} // namespace
+
+#define NACL_MOJO_DESC (NACL_CHROME_DESC_BASE + 2)
+
+void InjectMojo(struct NaClApp* nap) {
+ NaClAppSetDesc(nap, NACL_MOJO_DESC, MakeMojoDesc(nap));
+}
« 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