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 // 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/trusted/desc/nacl_desc_custom.h" |
| 15 #include "native_client/src/trusted/service_runtime/nacl_copy.h" |
| 16 #include "native_client/src/trusted/service_runtime/sel_ldr.h" |
| 17 |
| 18 static INLINE uintptr_t NaClUserToSysAddrArray( |
| 19 struct NaClApp *nap, |
| 20 uintptr_t uaddr, |
| 21 size_t count, |
| 22 size_t size) { |
| 23 // TODO overflow checking |
| 24 size_t range = count * size; |
| 25 return NaClUserToSysAddrRange(nap, uaddr, range); |
| 26 } |
| 27 |
| 28 void MojoDescDestroy(void *handle) { |
| 29 UNREFERENCED_PARAMETER(handle); |
| 30 } |
| 31 |
| 32 ssize_t MojoDescSendMsg(void *handle, |
| 33 const struct NaClImcTypedMsgHdr *msg, |
| 34 int flags) { |
| 35 UNREFERENCED_PARAMETER(flags); |
| 36 |
| 37 struct NaClApp *nap = static_cast<struct NaClApp*>(handle); |
| 38 |
| 39 if (msg->iov_length != 1 || msg->iov[0].length < 8 || msg->ndesc_length != 0)
{ |
| 40 return -1; |
| 41 } |
| 42 |
| 43 uint32_t *params = static_cast<uint32_t*>(msg->iov[0].base); |
| 44 uint32_t numParams = msg->iov[0].length / sizeof(*params); |
| 45 |
| 46 uint32_t msgType = params[0]; |
| 47 switch (msgType) { |
| 48 $body |
| 49 default: |
| 50 return -1; |
| 51 } |
| 52 |
| 53 return -1; |
| 54 } |
| 55 |
| 56 ssize_t MojoDescRecvMsg(void *handle, |
| 57 struct NaClImcTypedMsgHdr *msg, |
| 58 int flags) { |
| 59 UNREFERENCED_PARAMETER(handle); |
| 60 UNREFERENCED_PARAMETER(msg); |
| 61 UNREFERENCED_PARAMETER(flags); |
| 62 |
| 63 return -1; |
| 64 } |
| 65 |
| 66 struct NaClDesc *MakeMojoDesc(struct NaClApp *nap) { |
| 67 struct NaClDescCustomFuncs funcs = NACL_DESC_CUSTOM_FUNCS_INITIALIZER; |
| 68 funcs.Destroy = MojoDescDestroy; |
| 69 funcs.SendMsg = MojoDescSendMsg; |
| 70 funcs.RecvMsg = MojoDescRecvMsg; |
| 71 return NaClDescMakeCustomDesc(nap, &funcs); |
| 72 } |
| 73 |
| 74 #define NACL_MOJO_DESC 5 |
| 75 |
| 76 void InjectMojo(struct NaClApp *nap) { |
| 77 NaClAppSetDesc(nap, NACL_MOJO_DESC, MakeMojoDesc(nap)); |
| 78 } |
OLD | NEW |