| Index: mojo/monacl/gen/mojo_syscall.cc.template
|
| diff --git a/mojo/monacl/gen/mojo_syscall.cc.template b/mojo/monacl/gen/mojo_syscall.cc.template
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..be2af21a065645ad8e80059cf6737a26e4073240
|
| --- /dev/null
|
| +++ b/mojo/monacl/gen/mojo_syscall.cc.template
|
| @@ -0,0 +1,78 @@
|
| +// 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.
|
| +
|
| +// WARNING this file was generated by $script_name
|
| +// Do not edit by hand.
|
| +
|
| +#include "mojo/monacl/mojo_syscall.h"
|
| +
|
| +#include <stdio.h>
|
| +
|
| +#include "mojo/public/c/system/core.h"
|
| +#include "native_client/src/public/nacl_app.h"
|
| +#include "native_client/src/trusted/desc/nacl_desc_custom.h"
|
| +#include "native_client/src/trusted/service_runtime/nacl_copy.h"
|
| +#include "native_client/src/trusted/service_runtime/sel_ldr.h"
|
| +
|
| +static INLINE uintptr_t NaClUserToSysAddrArray(
|
| + struct NaClApp *nap,
|
| + uintptr_t uaddr,
|
| + size_t count,
|
| + size_t size) {
|
| + // TODO overflow checking
|
| + size_t range = count * size;
|
| + return NaClUserToSysAddrRange(nap, uaddr, range);
|
| +}
|
| +
|
| +void MojoDescDestroy(void *handle) {
|
| + UNREFERENCED_PARAMETER(handle);
|
| +}
|
| +
|
| +ssize_t MojoDescSendMsg(void *handle,
|
| + const struct NaClImcTypedMsgHdr *msg,
|
| + int flags) {
|
| + UNREFERENCED_PARAMETER(flags);
|
| +
|
| + struct NaClApp *nap = static_cast<struct NaClApp*>(handle);
|
| +
|
| + if (msg->iov_length != 1 || msg->iov[0].length < 8 || msg->ndesc_length != 0) {
|
| + return -1;
|
| + }
|
| +
|
| + uint32_t *params = static_cast<uint32_t*>(msg->iov[0].base);
|
| + uint32_t numParams = msg->iov[0].length / sizeof(*params);
|
| +
|
| + uint32_t msgType = params[0];
|
| + switch (msgType) {
|
| +$body
|
| + default:
|
| + return -1;
|
| + }
|
| +
|
| + return -1;
|
| +}
|
| +
|
| +ssize_t MojoDescRecvMsg(void *handle,
|
| + struct NaClImcTypedMsgHdr *msg,
|
| + int flags) {
|
| + UNREFERENCED_PARAMETER(handle);
|
| + UNREFERENCED_PARAMETER(msg);
|
| + UNREFERENCED_PARAMETER(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);
|
| +}
|
| +
|
| +#define NACL_MOJO_DESC 5
|
| +
|
| +void InjectMojo(struct NaClApp *nap) {
|
| + NaClAppSetDesc(nap, NACL_MOJO_DESC, MakeMojoDesc(nap));
|
| +}
|
|
|