2 * Copyright 2008, Google Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
15 * * Neither the name of Google Inc. nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 * NaCl Service Runtime. IMC API.
36 #ifndef NATIVE_CLIENT_SERVICE_RUNTIME_INCLUDE_SYS_NACL_IMC_API_H_
37 #define NATIVE_CLIENT_SERVICE_RUNTIME_INCLUDE_SYS_NACL_IMC_API_H_
40 * This file defines the C API for NativeClient applications. The
41 * ABI is implicitly defined.
44 #include "native_client/service_runtime/include/bits/nacl_imc_api.h"
50 /* TODO: there should be one instance to avoid conflicting definitions.
52 #ifndef __nacl_handle_defined
53 #define __nacl_handle_defined
55 typedef HANDLE NaClHandle
;
57 typedef int NaClHandle
;
61 struct NaClImcMsgIoVec
{
66 struct NaClImcMsgHdr
{
67 struct NaClImcMsgIoVec
*iov
;
75 * NACL_ABI_IMC_IOVEC_MAX: How many struct NaClIOVec are permitted?
76 * These are copied to kernel space in order to translate/validate
77 * addresses, and are on the thread stack when processing
78 * NaClSysSendmsg and NaClSysRecvmsg syscalls. Each object takes 8
79 * bytes, so beware running into NACL_KERN_STACK_SIZE above.
81 #define NACL_ABI_IMC_IOVEC_MAX 256
84 * NAC_ABI_IMC_DESC_MAX: How many descriptors are permitted? Each
85 * object is 4 bytes. An array of ints are on the kernel stack.
87 * TODO: coordinate w/ NACL_HANDLE_COUNT_MAX in nacl_imc_c.h.
88 * Current IMC-imposed limit seems way too small.
90 #define NACL_ABI_IMC_USER_DESC_MAX 8
91 #define NACL_ABI_IMC_DESC_MAX 8
94 * NACL_ABI_IMC_USER_BYTES_MAX: read must go into a kernel buffer first
95 * before a variable-length header describing the number and types of
96 * NaClHandles encoded is parsed, with the rest of the data not yet
97 * consumed turning into user data.
99 #define NACL_ABI_IMC_USER_BYTES_MAX (128 << 10)
100 #define NACL_ABI_IMC_BYTES_MAX \
101 (NACL_ABI_IMC_USER_BYTES_MAX \
102 + (1 + NACL_PATH_MAX) * NACL_ABI_IMC_USER_DESC_MAX + 16)
104 * 4096 + (1 + 28) * 256 = 11520, so the read buffer must be malloc'd
105 * or be part of the NaClAppThread structure; the kernel thread stack
106 * is too small for it.
108 * NB: the header has an end tag and the size is rounded up to the
116 #endif /* NATIVE_CLIENT_SERVICE_RUNTIME_INCLUDE_SYS_NACL_IMC_API_H_ */