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

Side by Side Diff: mojo/monacl/gen/mojo_syscall.cc.template

Issue 385983008: Mojo + NaCl prototype. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Better diff Created 6 years, 5 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
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 // WARNING this file was generated by $script_name
6 // Do not edit by hand.
7
8 #include "mojo/monacl/mojo_syscall.h"
9
10 #include <stdio.h>
11
12 #include "mojo/public/c/system/core.h"
13 #include "native_client/src/public/nacl_app.h"
14 #include "native_client/src/shared/platform/nacl_log.h"
15 #include "native_client/src/trusted/desc/nacl_desc_custom.h"
16 #include "native_client/src/trusted/service_runtime/nacl_copy.h"
17 #include "native_client/src/trusted/service_runtime/sel_ldr.h"
18
19 static INLINE uintptr_t NaClUserToSysAddrArray(
20 struct NaClApp *nap,
21 uintptr_t uaddr,
22 size_t count,
23 size_t size) {
24 // TODO overflow checking
25 size_t range = count * size;
26 return NaClUserToSysAddrRange(nap, uaddr, range);
27 }
28
29 void MojoDescDestroy(void *handle) {
30 UNREFERENCED_PARAMETER(handle);
31 NaClLog(LOG_ERROR, "Called destroy...\n");
32 }
33
34 ssize_t MojoDescSendMsg(void *handle,
35 const struct NaClImcTypedMsgHdr *msg,
36 int flags) {
37 UNREFERENCED_PARAMETER(flags);
38
39 struct NaClApp *nap = static_cast<struct NaClApp*>(handle);
40
41 if (msg->iov_length != 1 || msg->iov[0].length < 8 || msg->ndesc_length != 0) {
42 NaClLog(LOG_ERROR, "Malformed message.\n");
43 return -1;
44 }
45
46 uint32_t *params = static_cast<uint32_t*>(msg->iov[0].base);
47 uint32_t numParams = msg->iov[0].length / sizeof(*params);
48
49 uint32_t msgType = params[0];
50 //printf("Message: %d.\n", msgType);
51 switch (msgType) {
52 $body
53 default:
54 return -1;
55 }
56
57 return -1;
58 }
59
60 ssize_t MojoDescRecvMsg(void *handle,
61 struct NaClImcTypedMsgHdr *msg,
62 int flags) {
63 UNREFERENCED_PARAMETER(handle);
64 UNREFERENCED_PARAMETER(msg);
65 UNREFERENCED_PARAMETER(flags);
66
67 NaClLog(LOG_FATAL, "MojoDescRecvMsg: Not implemented\n");
Mark Seaborn 2014/07/21 16:31:39 Don't introduce more Chrome-side uses of NaClLog()
Nick Bray (chromium) 2014/07/21 22:38:36 sel_ldr.h included for range checks. sel_ldr incl
Mark Seaborn 2014/07/21 23:25:44 Right -- that kind of conflict is the reason why y
68 return 0;
69 }
70
71 struct NaClDesc *MakeMojoDesc(struct NaClApp *nap) {
72 struct NaClDescCustomFuncs funcs = NACL_DESC_CUSTOM_FUNCS_INITIALIZER;
73 funcs.Destroy = MojoDescDestroy;
74 funcs.SendMsg = MojoDescSendMsg;
75 funcs.RecvMsg = MojoDescRecvMsg;
76 return NaClDescMakeCustomDesc(nap, &funcs);
77 }
78
79 #define NACL_MOJO_DESC 5
80
81 void InjectMojo(struct NaClApp *nap) {
82 NaClAppSetDesc(nap, NACL_MOJO_DESC, MakeMojoDesc(nap));
83 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698