2 * Copyright (c) 2008 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file.
8 * NaCl Service Runtime. IMC API.
11 #ifndef _NATIVE_CLIENT_SRC_PUBLIC_IMC_TYPES_H_
12 #define _NATIVE_CLIENT_SRC_PUBLIC_IMC_TYPES_H_
15 * This file defines the C API for NativeClient applications. The
16 * ABI is implicitly defined.
19 #include "native_client/src/trusted/service_runtime/nacl_size_t.h"
25 /* TODO(sehr): there should be one instance to avoid conflicting definitions.
27 #ifndef __nacl_handle_defined
28 #define __nacl_handle_defined
30 typedef HANDLE NaClHandle;
32 typedef int NaClHandle;
36 struct NaClAbiNaClImcMsgIoVec {
37 #ifdef __native_client__
42 nacl_abi_size_t length;
45 struct NaClAbiNaClImcMsgHdr {
46 #ifdef __native_client__
47 struct NaClAbiNaClImcMsgIoVec *iov;
51 nacl_abi_size_t iov_length;
52 #ifdef __native_client__
57 nacl_abi_size_t desc_length;
61 #ifndef __native_client__
62 struct NaClImcMsgIoVec {
67 struct NaClImcMsgHdr {
68 struct NaClImcMsgIoVec *iov;
69 nacl_abi_size_t iov_length;
71 nacl_abi_size_t desc_length;
77 * NACL_ABI_IMC_IOVEC_MAX: How many struct NaClIOVec are permitted?
78 * These are copied to kernel space in order to translate/validate
79 * addresses, and are on the thread stack when processing
80 * NaClSysSendmsg and NaClSysRecvmsg syscalls. Each object takes 8
81 * bytes, so beware running into NACL_KERN_STACK_SIZE above.
83 #define NACL_ABI_IMC_IOVEC_MAX 256
86 * NAC_ABI_IMC_DESC_MAX: How many descriptors are permitted? Each
87 * object is 4 bytes. An array of ints are on the kernel stack.
89 * TODO(bsy): coordinate w/ NACL_HANDLE_COUNT_MAX in nacl_imc_c.h.
90 * Current IMC-imposed limit seems way too small.
92 #define NACL_ABI_IMC_USER_DESC_MAX 8
93 #define NACL_ABI_IMC_DESC_MAX 8
96 * NACL_ABI_IMC_USER_BYTES_MAX: read must go into a kernel buffer first
97 * before a variable-length header describing the number and types of
98 * NaClHandles encoded is parsed, with the rest of the data not yet
99 * consumed turning into user data.
101 #define NACL_ABI_IMC_USER_BYTES_MAX (128 << 10)
102 #define NACL_ABI_IMC_BYTES_MAX \
103 (NACL_ABI_IMC_USER_BYTES_MAX \
104 + (1 + NACL_PATH_MAX) * NACL_ABI_IMC_USER_DESC_MAX + 16)
106 * 4096 + (1 + 28) * 256 = 11520, so the read buffer must be malloc'd
107 * or be part of the NaClAppThread structure; the kernel thread stack
108 * is too small for it.
110 * NB: the header has an end tag and the size is rounded up to the
114 /* these values must match src/shared/imc/nacl_imc{,_c}.h */
115 #define NACL_ABI_RECVMSG_DATA_TRUNCATED 0x1
116 #define NACL_ABI_RECVMSG_DESC_TRUNCATED 0x2
118 #define NACL_ABI_IMC_NONBLOCK 0x1