OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 #ifndef NATIVE_CLIENT_SRC_PUBLIC_CHROME_MAIN_H_ | 7 #ifndef NATIVE_CLIENT_SRC_PUBLIC_CHROME_MAIN_H_ |
8 #define NATIVE_CLIENT_SRC_PUBLIC_CHROME_MAIN_H_ 1 | 8 #define NATIVE_CLIENT_SRC_PUBLIC_CHROME_MAIN_H_ 1 |
9 | 9 |
10 #include "native_client/src/include/nacl_base.h" | 10 #include "native_client/src/include/nacl_base.h" |
11 #include "native_client/src/include/portability.h" | 11 #include "native_client/src/include/portability.h" |
12 /* | 12 /* |
13 * nacl_imc_c.h is used to define NaClHandle. This should eventually | 13 * nacl_imc_c.h is used to define NaClHandle. This should eventually |
14 * go away when Chromium's use of SRPC is removed | 14 * go away when Chromium's use of SRPC is removed |
15 * (http://crbug.com/239656). | 15 * (http://crbug.com/239656). |
16 */ | 16 */ |
17 #include "native_client/src/shared/imc/nacl_imc_c.h" | 17 #include "native_client/src/shared/imc/nacl_imc_c.h" |
18 | 18 |
19 EXTERN_C_BEGIN | 19 EXTERN_C_BEGIN |
20 | 20 |
| 21 struct NaClApp; |
21 struct NaClValidationCache; | 22 struct NaClValidationCache; |
22 | 23 |
23 | 24 |
24 /* | 25 /* |
25 * Descriptor number for initial_ipc_desc. This is chosen so as not | 26 * The old, deprecated interface usage is as follows: |
26 * to conflict with NACL_SERVICE_PORT_DESCRIPTOR, | 27 * |
27 * NACL_SERVICE_ADDRESS_DESCRIPTOR and export_addr_to inside | 28 * struct NaClChromeMainArgs *args = NaClChromeMainArgsCreate(); |
28 * NaClChromeMainStart(). | 29 * // Now NaCl is partially initialized, so the following is allowed: |
| 30 * args->initial_ipc_fd = NaClDescMakeCustomDesc(...); |
| 31 * // Fill out more of args... |
| 32 * NaClChromeMainStart(args); |
| 33 * |
| 34 * The new, preferred interface usage is as follows: |
| 35 * |
| 36 * #if OS_POSIX |
| 37 * NaClChromeMainSetUrandomFd(urandom_fd); |
| 38 * #endif |
| 39 * NaClChromeMainInit(); |
| 40 * // The following may be done in any order: |
| 41 * struct NaClApp *nap = NaClAppCreate(); |
| 42 * struct NaClChromeMainArgs *args = NaClChromeMainArgsCreate(); |
| 43 * // Fill out args... |
| 44 * NaClAppSetDesc(nap, NACL_CHROME_DESC_BASE, NaClDescMakeCustomDesc(...)); |
| 45 * NaClChromeMainStartApp(nap, args); |
29 */ | 46 */ |
30 #define NACL_CHROME_INITIAL_IPC_DESC 6 | 47 |
| 48 /* |
| 49 * Embedders of NaCl may use descriptor numbers of |
| 50 * NACL_CHROME_DESC_BASE and higher when setting up a NaClApp's |
| 51 * initial descriptors using NaClAppSetDesc(). |
| 52 * |
| 53 * This number is chosen so as not to conflict with |
| 54 * NACL_SERVICE_PORT_DESCRIPTOR, NACL_SERVICE_ADDRESS_DESCRIPTOR and |
| 55 * export_addr_to inside NaClChromeMainStart(). |
| 56 */ |
| 57 #define NACL_CHROME_DESC_BASE 6 |
| 58 |
| 59 /* |
| 60 * Descriptor number for initial_ipc_desc. |
| 61 * |
| 62 * Deprecated: use NaClAppSetDesc() and NACL_CHROME_DESC_BASE instead. |
| 63 */ |
| 64 #define NACL_CHROME_INITIAL_IPC_DESC NACL_CHROME_DESC_BASE |
31 | 65 |
32 | 66 |
33 struct NaClChromeMainArgs { | 67 struct NaClChromeMainArgs { |
34 /* | 68 /* |
35 * Handle for bootstrapping a NaCl IMC connection to the trusted | 69 * Handle for bootstrapping a NaCl IMC connection to the trusted |
36 * PPAPI plugin. Required. | 70 * PPAPI plugin. Required. |
37 */ | 71 */ |
38 NaClHandle imc_bootstrap_handle; | 72 NaClHandle imc_bootstrap_handle; |
39 | 73 |
40 /* | 74 /* |
41 * File descriptor for the NaCl integrated runtime (IRT) library. | 75 * File descriptor for the NaCl integrated runtime (IRT) library. |
42 * Note that this is a file descriptor even on Windows (where file | 76 * Note that this is a file descriptor even on Windows (where file |
43 * descriptors are emulated by the C runtime library). | 77 * descriptors are emulated by the C runtime library). |
44 * Optional; may be -1. Optional when loading nexes that don't follow | 78 * Optional; may be -1. Optional when loading nexes that don't follow |
45 * NaCl's stable ABI, such as the PNaCl translator. | 79 * NaCl's stable ABI, such as the PNaCl translator. |
46 */ | 80 */ |
47 int irt_fd; | 81 int irt_fd; |
48 | 82 |
49 /* | 83 /* |
50 * Descriptor to provide to untrusted code as descriptor number | 84 * Descriptor to provide to untrusted code as descriptor number |
51 * NACL_CHROME_INITIAL_IPC_DESC. For use by the Chrome-IPC-based | 85 * NACL_CHROME_INITIAL_IPC_DESC. For use by the Chrome-IPC-based |
52 * PPAPI proxy. Optional; may be NULL. | 86 * PPAPI proxy. Optional; may be NULL. |
| 87 * |
| 88 * Deprecated: use NaClAppSetDesc() instead. |
53 */ | 89 */ |
54 struct NaClDesc *initial_ipc_desc; | 90 struct NaClDesc *initial_ipc_desc; |
55 | 91 |
56 /* Whether to enable untrusted hardware exception handling. Boolean. */ | 92 /* Whether to enable untrusted hardware exception handling. Boolean. */ |
57 int enable_exception_handling; | 93 int enable_exception_handling; |
58 | 94 |
59 /* Whether to enable NaCl's built-in GDB RSP debug stub. Boolean. */ | 95 /* Whether to enable NaCl's built-in GDB RSP debug stub. Boolean. */ |
60 int enable_debug_stub; | 96 int enable_debug_stub; |
61 | 97 |
62 /* Whether to enable NaCl's dynamic code system calls. Boolean. */ | 98 /* Whether to enable NaCl's dynamic code system calls. Boolean. */ |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 int (*attach_debug_exception_handler_func)(const void *info, | 145 int (*attach_debug_exception_handler_func)(const void *info, |
110 size_t info_size); | 146 size_t info_size); |
111 #endif | 147 #endif |
112 | 148 |
113 #if NACL_LINUX || NACL_OSX | 149 #if NACL_LINUX || NACL_OSX |
114 /* | 150 /* |
115 * File descriptor for /dev/urandom for reading random data. This | 151 * File descriptor for /dev/urandom for reading random data. This |
116 * takes ownership of the file descriptor. In principle this is | 152 * takes ownership of the file descriptor. In principle this is |
117 * optional and may be -1, although startup may fail if this is not | 153 * optional and may be -1, although startup may fail if this is not |
118 * provided. | 154 * provided. |
| 155 * |
| 156 * Deprecated: use NaClChromeMainSetUrandomFd() instead. |
119 */ | 157 */ |
120 int urandom_fd; | 158 int urandom_fd; |
121 | 159 |
122 /* | 160 /* |
123 * The result of sysconf(_SC_NPROCESSORS_ONLN). The Chrome | 161 * The result of sysconf(_SC_NPROCESSORS_ONLN). The Chrome |
124 * outer-sandbox prevents the glibc implementation of sysconf from | 162 * outer-sandbox prevents the glibc implementation of sysconf from |
125 * working -- which just reads /proc/cpuinfo or similar file -- so | 163 * working -- which just reads /proc/cpuinfo or similar file -- so |
126 * instead, the launcher should fill this in. In principle this is | 164 * instead, the launcher should fill this in. In principle this is |
127 * optional and may be -1, but this will make | 165 * optional and may be -1, but this will make |
128 * sysconf(_SC_NPROCESSORS_ONLN) fail and result in some NaCl | 166 * sysconf(_SC_NPROCESSORS_ONLN) fail and result in some NaCl |
(...skipping 18 matching lines...) Expand all Loading... |
147 /* | 185 /* |
148 * Size of address space reserved at address zero onwards for the | 186 * Size of address space reserved at address zero onwards for the |
149 * sandbox. This is optional and may be 0 if no address space has | 187 * sandbox. This is optional and may be 0 if no address space has |
150 * been reserved, though some sandboxes (such as ARM) might fail in | 188 * been reserved, though some sandboxes (such as ARM) might fail in |
151 * that case. | 189 * that case. |
152 */ | 190 */ |
153 size_t prereserved_sandbox_size; | 191 size_t prereserved_sandbox_size; |
154 #endif | 192 #endif |
155 }; | 193 }; |
156 | 194 |
| 195 #if NACL_LINUX || NACL_OSX |
| 196 /* |
| 197 * Sets a file descriptor for /dev/urandom for reading random data. |
| 198 * This takes ownership of the file descriptor. This is intended for |
| 199 * use inside an outer sandbox where NaCl may not be able to open() |
| 200 * /dev/urandom. |
| 201 * |
| 202 * If this is called, it must be called before NaClChromeMainInit(), |
| 203 * otherwise NaClChromeMainInit() will try to open() /dev/urandom. |
| 204 */ |
| 205 void NaClChromeMainSetUrandomFd(int urandom_fd); |
| 206 #endif |
| 207 |
| 208 /* Initialize NaCl. This must be called before NaClAppCreate(). */ |
| 209 void NaClChromeMainInit(void); |
| 210 |
157 /* Create a new args struct containing default values. */ | 211 /* Create a new args struct containing default values. */ |
158 struct NaClChromeMainArgs *NaClChromeMainArgsCreate(void); | 212 struct NaClChromeMainArgs *NaClChromeMainArgsCreate(void); |
159 | 213 |
160 /* Launch NaCl. */ | 214 /* |
| 215 * Launch NaCl. This does not return. |
| 216 * |
| 217 * Deprecated: use NaClAppCreate() and NaClChromeMainStartApp() instead. |
| 218 */ |
161 void NaClChromeMainStart(struct NaClChromeMainArgs *args); | 219 void NaClChromeMainStart(struct NaClChromeMainArgs *args); |
162 | 220 |
| 221 /* Launch NaCl. This does not return. */ |
| 222 void NaClChromeMainStartApp(struct NaClApp *nap, |
| 223 struct NaClChromeMainArgs *args); |
| 224 |
163 | 225 |
164 EXTERN_C_END | 226 EXTERN_C_END |
165 | 227 |
166 #endif | 228 #endif |
OLD | NEW |