Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(179)

Side by Side Diff: mojo/nacl/nonsfi/irt_mojo_nonsfi.cc

Issue 1382713002: Creating a pexe content handler to translate and run pexes. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "mojo/nacl/nonsfi/irt_mojo_nonsfi.h" 5 #include "mojo/nacl/nonsfi/irt_mojo_nonsfi.h"
6 6
7 #include "mojo/public/c/system/functions.h" 7 #include "mojo/public/c/system/functions.h"
8 #include "mojo/public/platform/nacl/mgl_irt.h" 8 #include "mojo/public/platform/nacl/mgl_irt.h"
9 #include "mojo/public/platform/nacl/mojo_irt.h" 9 #include "mojo/public/platform/nacl/mojo_irt.h"
10 #include "native_client/src/public/irt_core.h" 10 #include "native_client/src/public/irt_core.h"
11 #include "native_client/src/untrusted/irt/irt_dev.h"
11 12
12 namespace { 13 namespace {
13 14
14 MojoHandle g_mojo_handle = MOJO_HANDLE_INVALID; 15 MojoHandle g_mojo_handle = MOJO_HANDLE_INVALID;
15 16 bool g_running_translator = false;
16 MojoResult _MojoGetInitialHandle(MojoHandle* handle) {
17 *handle = g_mojo_handle;
18 return MOJO_RESULT_OK;
19 }
20 17
21 const struct nacl_irt_mojo kIrtMojo = { 18 const struct nacl_irt_mojo kIrtMojo = {
22 MojoCreateSharedBuffer, 19 MojoCreateSharedBuffer,
23 MojoDuplicateBufferHandle, 20 MojoDuplicateBufferHandle,
24 MojoMapBuffer, 21 MojoMapBuffer,
25 MojoUnmapBuffer, 22 MojoUnmapBuffer,
26 MojoCreateDataPipe, 23 MojoCreateDataPipe,
27 MojoWriteData, 24 MojoWriteData,
28 MojoBeginWriteData, 25 MojoBeginWriteData,
29 MojoEndWriteData, 26 MojoEndWriteData,
30 MojoReadData, 27 MojoReadData,
31 MojoBeginReadData, 28 MojoBeginReadData,
32 MojoEndReadData, 29 MojoEndReadData,
33 MojoGetTimeTicksNow, 30 MojoGetTimeTicksNow,
34 MojoClose, 31 MojoClose,
35 MojoWait, 32 MojoWait,
36 MojoWaitMany, 33 MojoWaitMany,
37 MojoCreateMessagePipe, 34 MojoCreateMessagePipe,
38 MojoWriteMessage, 35 MojoWriteMessage,
39 MojoReadMessage, 36 MojoReadMessage,
40 _MojoGetInitialHandle, 37 nacl::MojoGetInitialHandle,
41 }; 38 };
42 39
43 const struct nacl_irt_mgl kIrtMGL = { 40 const struct nacl_irt_mgl kIrtMGL = {
44 MGLCreateContext, 41 MGLCreateContext,
45 MGLDestroyContext, 42 MGLDestroyContext,
46 MGLMakeCurrent, 43 MGLMakeCurrent,
47 MGLGetCurrentContext, 44 MGLGetCurrentContext,
48 MGLGetProcAddress, 45 MGLGetProcAddress,
49 }; 46 };
50 47
51 const struct nacl_irt_mgl_onscreen kIrtMGLOnScreen = { 48 const struct nacl_irt_mgl_onscreen kIrtMGLOnScreen = {
52 MGLResizeSurface, 49 MGLResizeSurface,
53 MGLSwapBuffers, 50 MGLSwapBuffers,
54 }; 51 };
55 52
56 const struct nacl_irt_mgl_signal_sync_point kIrtMGLSignalSyncPoint = { 53 const struct nacl_irt_mgl_signal_sync_point kIrtMGLSignalSyncPoint = {
57 MGLSignalSyncPoint, 54 MGLSignalSyncPoint,
58 }; 55 };
59 56
57 int NotPNaClFilter() {
58 return g_running_translator;
59 }
60
60 const struct nacl_irt_interface kIrtInterfaces[] = { 61 const struct nacl_irt_interface kIrtInterfaces[] = {
61 {NACL_IRT_MOJO_v0_1, &kIrtMojo, sizeof(kIrtMojo), nullptr}, 62 // Interface to call Mojo functions
62 {NACL_IRT_MGL_v0_1, &kIrtMGL, sizeof(kIrtMGL), nullptr}, 63 { NACL_IRT_MOJO_v0_1,
63 {NACL_IRT_MGL_ONSCREEN_v0_1, &kIrtMGLOnScreen, sizeof(kIrtMGLOnScreen), 64 &kIrtMojo,
64 nullptr}, 65 sizeof(kIrtMojo),
65 {NACL_IRT_MGL_SIGNAL_SYNC_POINT_v0_1, &kIrtMGLSignalSyncPoint, 66 nullptr },
66 sizeof(kIrtMGLSignalSyncPoint), nullptr}, 67 // Interface to call PNaCl translation
68 { NACL_IRT_PRIVATE_PNACL_TRANSLATOR_COMPILE_v0_1,
69 &nacl::nacl_irt_private_pnacl_translator_compile,
70 sizeof(nacl_irt_private_pnacl_translator_compile),
71 NotPNaClFilter },
72 // Interface to call PNaCl linking
73 { NACL_IRT_PRIVATE_PNACL_TRANSLATOR_LINK_v0_1,
74 &nacl::nacl_irt_private_pnacl_translator_link,
75 sizeof(nacl_irt_private_pnacl_translator_link),
76 NotPNaClFilter },
77 // Adds mechanism for opening object files, like crtbegin.o
78 { NACL_IRT_RESOURCE_OPEN_v0_1,
79 &nacl::nacl_irt_resource_open,
80 sizeof(nacl_irt_resource_open),
81 NotPNaClFilter },
82 // GPU functions which give control over MGL context
83 { NACL_IRT_MGL_v0_1,
84 &kIrtMGL,
85 sizeof(kIrtMGL),
86 nullptr },
87 // GPU functions which update framebuffer with respect to the display
88 { NACL_IRT_MGL_ONSCREEN_v0_1,
89 &kIrtMGLOnScreen,
90 sizeof(kIrtMGLOnScreen),
91 nullptr },
92 // GPU functions to synchronize CPU and GPU services
93 { NACL_IRT_MGL_SIGNAL_SYNC_POINT_v0_1,
94 &kIrtMGLSignalSyncPoint,
95 sizeof(kIrtMGLSignalSyncPoint),
96 nullptr },
67 }; 97 };
68 98
69 } // namespace 99 } // namespace
70 100
71 namespace nacl { 101 namespace nacl {
72 102
103 MojoResult MojoGetInitialHandle(MojoHandle* handle) {
104 *handle = g_mojo_handle;
105 return MOJO_RESULT_OK;
106 }
107
73 void MojoSetInitialHandle(MojoHandle handle) { 108 void MojoSetInitialHandle(MojoHandle handle) {
74 g_mojo_handle = handle; 109 g_mojo_handle = handle;
75 } 110 }
76 111
112 void MojoPnaclTranslatorEnable() {
113 g_running_translator = true;
114 }
115
77 size_t MojoIrtNonsfiQuery(const char* interface_ident, 116 size_t MojoIrtNonsfiQuery(const char* interface_ident,
78 void* table, 117 void* table,
79 size_t tablesize) { 118 size_t tablesize) {
80 size_t result = nacl_irt_query_list(interface_ident, table, tablesize, 119 size_t result = nacl_irt_query_list(interface_ident, table, tablesize,
81 kIrtInterfaces, sizeof(kIrtInterfaces)); 120 kIrtInterfaces, sizeof(kIrtInterfaces));
82 if (result != 0) 121 if (result != 0)
83 return result; 122 return result;
84 return nacl_irt_query_core(interface_ident, table, tablesize); 123 return nacl_irt_query_core(interface_ident, table, tablesize);
85 } 124 }
86 125
87 } // namespace nacl 126 } // namespace nacl
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698