1 /*
2 * Copyright (c) 2014 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.
5 */
6
7 #include "native_client/src/public/irt_core.h"
8 #include "native_client/src/untrusted/irt/irt.h"
9 #include "native_client/src/untrusted/irt/irt_dev.h"
10 #include "native_client/src/untrusted/irt/irt_interfaces.h"
11
12 /*
13 * This is a list of IRT interface implementations to include in the NaCl
14 * core IRT, but not in IRTs built by embedders of NaCl (such as Chromium).
15 *
16 * Chromium provides its own implementation of open_resource().
17 * open_resource() is disabled under PNaCl (see irt.h), but we don't need
18 * to conditionalize its availability here since this definition is only
19 * used for the core IRT.
20 *
21 * Similarly, Chromium provides its own implementations of the PNaCl
22 * translator compile/link interfaces.
23 */
24 static const struct nacl_irt_interface irt_interfaces[] = {
25 { NACL_IRT_RESOURCE_OPEN_v0_1, &nacl_irt_resource_open,
26 sizeof(nacl_irt_resource_open), NULL },
27 { NACL_IRT_PRIVATE_PNACL_TRANSLATOR_LINK_v0_1,
28 &nacl_irt_private_pnacl_translator_link,
29 sizeof(nacl_irt_private_pnacl_translator_link), NULL },
30 { NACL_IRT_PRIVATE_PNACL_TRANSLATOR_COMPILE_v0_1,
31 &nacl_irt_private_pnacl_translator_compile,
32 sizeof(nacl_irt_private_pnacl_translator_compile), NULL },
33 };
34
irt_query(const char * interface_ident,void * table,size_t tablesize)35 static size_t irt_query(const char *interface_ident,
36 void *table, size_t tablesize) {
37 size_t result = nacl_irt_query_core(interface_ident, table, tablesize);
38 if (result != 0)
39 return result;
40 return nacl_irt_query_list(interface_ident, table, tablesize,
41 irt_interfaces, sizeof(irt_interfaces));
42 }
43
nacl_irt_start(uint32_t * info)44 void nacl_irt_start(uint32_t *info) {
45 nacl_irt_init(info);
46 nacl_irt_enter_user_code(info, irt_query);
47 }
48