Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 std::string g_base_path = ""; |
|
Mark Seaborn
2015/10/28 18:31:43
This is a non-POD initialiser. Chromium has a pol
Sean Klein
2015/10/28 21:39:59
This is interesting. Good to know! I'll be more ca
| |
| 17 *handle = g_mojo_handle; | |
| 18 return MOJO_RESULT_OK; | |
| 19 } | |
| 20 | 18 |
| 21 const struct nacl_irt_mojo kIrtMojo = { | 19 const struct nacl_irt_mojo kIrtMojo = { |
| 22 MojoCreateSharedBuffer, | 20 MojoCreateSharedBuffer, |
| 23 MojoDuplicateBufferHandle, | 21 MojoDuplicateBufferHandle, |
| 24 MojoMapBuffer, | 22 MojoMapBuffer, |
| 25 MojoUnmapBuffer, | 23 MojoUnmapBuffer, |
| 26 MojoCreateDataPipe, | 24 MojoCreateDataPipe, |
| 27 MojoWriteData, | 25 MojoWriteData, |
| 28 MojoBeginWriteData, | 26 MojoBeginWriteData, |
| 29 MojoEndWriteData, | 27 MojoEndWriteData, |
| 30 MojoReadData, | 28 MojoReadData, |
| 31 MojoBeginReadData, | 29 MojoBeginReadData, |
| 32 MojoEndReadData, | 30 MojoEndReadData, |
| 33 MojoGetTimeTicksNow, | 31 MojoGetTimeTicksNow, |
| 34 MojoClose, | 32 MojoClose, |
| 35 MojoWait, | 33 MojoWait, |
| 36 MojoWaitMany, | 34 MojoWaitMany, |
| 37 MojoCreateMessagePipe, | 35 MojoCreateMessagePipe, |
| 38 MojoWriteMessage, | 36 MojoWriteMessage, |
| 39 MojoReadMessage, | 37 MojoReadMessage, |
| 40 _MojoGetInitialHandle, | 38 nacl::MojoGetInitialHandle, |
| 41 }; | 39 }; |
| 42 | 40 |
| 43 const struct nacl_irt_mgl kIrtMGL = { | 41 const struct nacl_irt_mgl kIrtMGL = { |
| 44 MGLCreateContext, | 42 MGLCreateContext, |
| 45 MGLDestroyContext, | 43 MGLDestroyContext, |
| 46 MGLMakeCurrent, | 44 MGLMakeCurrent, |
| 47 MGLGetCurrentContext, | 45 MGLGetCurrentContext, |
| 48 MGLGetProcAddress, | 46 MGLGetProcAddress, |
| 49 }; | 47 }; |
| 50 | 48 |
| 51 const struct nacl_irt_mgl_onscreen kIrtMGLOnScreen = { | 49 const struct nacl_irt_mgl_onscreen kIrtMGLOnScreen = { |
| 52 MGLResizeSurface, | 50 MGLResizeSurface, |
| 53 MGLSwapBuffers, | 51 MGLSwapBuffers, |
| 54 }; | 52 }; |
| 55 | 53 |
| 56 const struct nacl_irt_mgl_signal_sync_point kIrtMGLSignalSyncPoint = { | 54 const struct nacl_irt_mgl_signal_sync_point kIrtMGLSignalSyncPoint = { |
| 57 MGLSignalSyncPoint, | 55 MGLSignalSyncPoint, |
| 58 }; | 56 }; |
| 59 | 57 |
| 58 int NotPNaClFilter() { | |
| 59 return g_running_translator; | |
| 60 } | |
| 61 | |
| 60 const struct nacl_irt_interface kIrtInterfaces[] = { | 62 const struct nacl_irt_interface kIrtInterfaces[] = { |
| 61 {NACL_IRT_MOJO_v0_1, &kIrtMojo, sizeof(kIrtMojo), nullptr}, | 63 // Interface to call Mojo functions |
| 62 {NACL_IRT_MGL_v0_1, &kIrtMGL, sizeof(kIrtMGL), nullptr}, | 64 { NACL_IRT_MOJO_v0_1, |
| 63 {NACL_IRT_MGL_ONSCREEN_v0_1, &kIrtMGLOnScreen, sizeof(kIrtMGLOnScreen), | 65 &kIrtMojo, |
| 64 nullptr}, | 66 sizeof(kIrtMojo), |
| 65 {NACL_IRT_MGL_SIGNAL_SYNC_POINT_v0_1, &kIrtMGLSignalSyncPoint, | 67 nullptr }, |
| 66 sizeof(kIrtMGLSignalSyncPoint), nullptr}, | 68 // Interface to call PNaCl translation |
| 69 { NACL_IRT_PRIVATE_PNACL_TRANSLATOR_COMPILE_v0_1, | |
| 70 &nacl::nacl_irt_private_pnacl_translator_compile, | |
| 71 sizeof(nacl_irt_private_pnacl_translator_compile), | |
| 72 NotPNaClFilter }, | |
| 73 // Interface to call PNaCl linking | |
| 74 { NACL_IRT_PRIVATE_PNACL_TRANSLATOR_LINK_v0_1, | |
| 75 &nacl::nacl_irt_private_pnacl_translator_link, | |
| 76 sizeof(nacl_irt_private_pnacl_translator_link), | |
| 77 NotPNaClFilter }, | |
| 78 // Adds mechanism for opening object files, like crtbegin.o | |
| 79 { NACL_IRT_RESOURCE_OPEN_v0_1, | |
| 80 &nacl::nacl_irt_resource_open, | |
| 81 sizeof(nacl_irt_resource_open), | |
| 82 NotPNaClFilter }, | |
| 83 // GPU functions which give control over MGL context | |
| 84 { NACL_IRT_MGL_v0_1, | |
| 85 &kIrtMGL, | |
| 86 sizeof(kIrtMGL), | |
| 87 nullptr }, | |
| 88 // GPU functions which update framebuffer with respect to the display | |
| 89 { NACL_IRT_MGL_ONSCREEN_v0_1, | |
| 90 &kIrtMGLOnScreen, | |
| 91 sizeof(kIrtMGLOnScreen), | |
| 92 nullptr }, | |
| 93 // GPU functions to synchronize CPU and GPU services | |
| 94 { NACL_IRT_MGL_SIGNAL_SYNC_POINT_v0_1, | |
| 95 &kIrtMGLSignalSyncPoint, | |
| 96 sizeof(kIrtMGLSignalSyncPoint), | |
| 97 nullptr }, | |
| 67 }; | 98 }; |
| 68 | 99 |
| 69 } // namespace | 100 } // namespace |
| 70 | 101 |
| 71 namespace nacl { | 102 namespace nacl { |
| 72 | 103 |
| 104 MojoResult MojoGetInitialHandle(MojoHandle* handle) { | |
| 105 *handle = g_mojo_handle; | |
| 106 return MOJO_RESULT_OK; | |
| 107 } | |
| 108 | |
| 73 void MojoSetInitialHandle(MojoHandle handle) { | 109 void MojoSetInitialHandle(MojoHandle handle) { |
| 74 g_mojo_handle = handle; | 110 g_mojo_handle = handle; |
| 75 } | 111 } |
| 76 | 112 |
| 113 void MojoPnaclTranslatorEnable() { | |
| 114 g_running_translator = true; | |
| 115 } | |
| 116 | |
| 117 void MojoSetBasePath(std::string base_path) { | |
|
Mark Seaborn
2015/10/28 18:31:43
Can be "const std::string&" to avoid one copy.
Sean Klein
2015/10/28 21:39:59
Done, but this function is being removed anyway.
| |
| 118 g_base_path = base_path; | |
| 119 } | |
| 120 | |
| 121 std::string MojoGetBasePath() { | |
| 122 return g_base_path; | |
| 123 } | |
| 124 | |
| 77 size_t MojoIrtNonsfiQuery(const char* interface_ident, | 125 size_t MojoIrtNonsfiQuery(const char* interface_ident, |
| 78 void* table, | 126 void* table, |
| 79 size_t tablesize) { | 127 size_t tablesize) { |
| 80 size_t result = nacl_irt_query_list(interface_ident, table, tablesize, | 128 size_t result = nacl_irt_query_list(interface_ident, table, tablesize, |
| 81 kIrtInterfaces, sizeof(kIrtInterfaces)); | 129 kIrtInterfaces, sizeof(kIrtInterfaces)); |
| 82 if (result != 0) | 130 if (result != 0) |
| 83 return result; | 131 return result; |
| 84 return nacl_irt_query_core(interface_ident, table, tablesize); | 132 return nacl_irt_query_core(interface_ident, table, tablesize); |
| 85 } | 133 } |
| 86 | 134 |
| 87 } // namespace nacl | 135 } // namespace nacl |
| OLD | NEW |