jam | 76bcf0c | 2015-10-02 21:01:28 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Ken Rockot | dba46db | 2018-07-04 18:41:04 | [diff] [blame] | 5 | #include "mojo/core/entrypoints.h" |
rockot | b04b89b5 | 2016-06-09 03:58:56 | [diff] [blame] | 6 | |
Avi Drissman | 2e88ac37 | 2015-12-21 18:14:57 | [diff] [blame] | 7 | #include <stdint.h> |
| 8 | |
Ken Rockot | dba46db | 2018-07-04 18:41:04 | [diff] [blame] | 9 | #include "mojo/core/core.h" |
rockot | 85dce086 | 2015-11-13 01:33:59 | [diff] [blame] | 10 | #include "mojo/public/c/system/buffer.h" |
| 11 | #include "mojo/public/c/system/data_pipe.h" |
| 12 | #include "mojo/public/c/system/functions.h" |
| 13 | #include "mojo/public/c/system/message_pipe.h" |
rockot | 28a287e | 2016-05-24 02:51:37 | [diff] [blame] | 14 | #include "mojo/public/c/system/platform_handle.h" |
Ken Rockot | 0db0bcf | 2018-07-12 22:01:12 | [diff] [blame] | 15 | #include "mojo/public/c/system/quota.h" |
jam | 76bcf0c | 2015-10-02 21:01:28 | [diff] [blame] | 16 | |
Ken Rockot | 898d796d5 | 2018-03-23 19:03:52 | [diff] [blame] | 17 | namespace { |
jam | 76bcf0c | 2015-10-02 21:01:28 | [diff] [blame] | 18 | |
Ken Rockot | dba46db | 2018-07-04 18:41:04 | [diff] [blame] | 19 | mojo::core::Core* g_core; |
Ken Rockot | 898d796d5 | 2018-03-23 19:03:52 | [diff] [blame] | 20 | |
jam | 76bcf0c | 2015-10-02 21:01:28 | [diff] [blame] | 21 | extern "C" { |
rockot | c637caf9b | 2016-02-10 09:57:08 | [diff] [blame] | 22 | |
Ken Rockot | 773a51f | 2018-03-24 09:01:12 | [diff] [blame] | 23 | MojoResult MojoInitializeImpl(const struct MojoInitializeOptions* options) { |
| 24 | NOTREACHED() << "Do not call MojoInitialize() as an EDK embedder!"; |
| 25 | return MOJO_RESULT_OK; |
| 26 | } |
| 27 | |
rockot | b04b89b5 | 2016-06-09 03:58:56 | [diff] [blame] | 28 | MojoTimeTicks MojoGetTimeTicksNowImpl() { |
jam | 76bcf0c | 2015-10-02 21:01:28 | [diff] [blame] | 29 | return g_core->GetTimeTicksNow(); |
| 30 | } |
| 31 | |
rockot | b04b89b5 | 2016-06-09 03:58:56 | [diff] [blame] | 32 | MojoResult MojoCloseImpl(MojoHandle handle) { |
jam | 76bcf0c | 2015-10-02 21:01:28 | [diff] [blame] | 33 | return g_core->Close(handle); |
| 34 | } |
| 35 | |
rockot | c794954 | 2017-03-16 09:03:47 | [diff] [blame] | 36 | MojoResult MojoQueryHandleSignalsStateImpl( |
| 37 | MojoHandle handle, |
| 38 | MojoHandleSignalsState* signals_state) { |
| 39 | return g_core->QueryHandleSignalsState(handle, signals_state); |
| 40 | } |
| 41 | |
Ken Rockot | c12080c | 2018-05-03 18:10:21 | [diff] [blame] | 42 | MojoResult MojoCreateMessagePipeImpl( |
| 43 | const MojoCreateMessagePipeOptions* options, |
| 44 | MojoHandle* message_pipe_handle0, |
| 45 | MojoHandle* message_pipe_handle1) { |
| 46 | return g_core->CreateMessagePipe(options, message_pipe_handle0, |
| 47 | message_pipe_handle1); |
rockot | 49b69e6b27 | 2016-03-02 03:46:37 | [diff] [blame] | 48 | } |
| 49 | |
Ken Rockot | c12080c | 2018-05-03 18:10:21 | [diff] [blame] | 50 | MojoResult MojoWriteMessageImpl(MojoHandle message_pipe_handle, |
| 51 | MojoMessageHandle message, |
| 52 | const MojoWriteMessageOptions* options) { |
| 53 | return g_core->WriteMessage(message_pipe_handle, message, options); |
rockot | 9eadaba | 2017-03-15 23:57:47 | [diff] [blame] | 54 | } |
| 55 | |
Ken Rockot | c12080c | 2018-05-03 18:10:21 | [diff] [blame] | 56 | MojoResult MojoReadMessageImpl(MojoHandle message_pipe_handle, |
| 57 | const MojoReadMessageOptions* options, |
| 58 | MojoMessageHandle* message) { |
| 59 | return g_core->ReadMessage(message_pipe_handle, options, message); |
rockot | 9eadaba | 2017-03-15 23:57:47 | [diff] [blame] | 60 | } |
| 61 | |
Ken Rockot | c12080c | 2018-05-03 18:10:21 | [diff] [blame] | 62 | MojoResult MojoFuseMessagePipesImpl( |
| 63 | MojoHandle handle0, |
| 64 | MojoHandle handle1, |
| 65 | const MojoFuseMessagePipesOptions* options) { |
| 66 | return g_core->FuseMessagePipes(handle0, handle1, options); |
rockot | 49b69e6b27 | 2016-03-02 03:46:37 | [diff] [blame] | 67 | } |
| 68 | |
Ken Rockot | f3208fc | 2018-03-07 20:35:08 | [diff] [blame] | 69 | MojoResult MojoCreateMessageImpl(const MojoCreateMessageOptions* options, |
| 70 | MojoMessageHandle* message) { |
| 71 | return g_core->CreateMessage(options, message); |
| 72 | } |
| 73 | |
Ken Rockot | c12080c | 2018-05-03 18:10:21 | [diff] [blame] | 74 | MojoResult MojoDestroyMessageImpl(MojoMessageHandle message) { |
| 75 | return g_core->DestroyMessage(message); |
| 76 | } |
| 77 | |
Ken Rockot | f3208fc | 2018-03-07 20:35:08 | [diff] [blame] | 78 | MojoResult MojoSerializeMessageImpl( |
| 79 | MojoMessageHandle message, |
| 80 | const MojoSerializeMessageOptions* options) { |
| 81 | return g_core->SerializeMessage(message, options); |
Ken Rockot | 15b2b0b | 2017-06-12 20:36:05 | [diff] [blame] | 82 | } |
| 83 | |
Ken Rockot | 8e49dd7 | 2018-03-07 18:06:40 | [diff] [blame] | 84 | MojoResult MojoAppendMessageDataImpl( |
Ken Rockot | fdf158da | 2017-06-12 20:45:29 | [diff] [blame] | 85 | MojoMessageHandle message, |
Ken Rockot | 8e49dd7 | 2018-03-07 18:06:40 | [diff] [blame] | 86 | uint32_t additional_payload_size, |
| 87 | const MojoHandle* handles, |
| 88 | uint32_t num_handles, |
| 89 | const MojoAppendMessageDataOptions* options, |
Ken Rockot | fdf158da | 2017-06-12 20:45:29 | [diff] [blame] | 90 | void** buffer, |
Ken Rockot | 8e49dd7 | 2018-03-07 18:06:40 | [diff] [blame] | 91 | uint32_t* buffer_size) { |
| 92 | return g_core->AppendMessageData(message, additional_payload_size, handles, |
| 93 | num_handles, options, buffer, buffer_size); |
| 94 | } |
| 95 | |
| 96 | MojoResult MojoGetMessageDataImpl(MojoMessageHandle message, |
| 97 | const MojoGetMessageDataOptions* options, |
| 98 | void** buffer, |
| 99 | uint32_t* num_bytes, |
| 100 | MojoHandle* handles, |
| 101 | uint32_t* num_handles) { |
| 102 | return g_core->GetMessageData(message, options, buffer, num_bytes, handles, |
| 103 | num_handles); |
rockot | 72d05a46 | 2016-04-26 19:56:50 | [diff] [blame] | 104 | } |
| 105 | |
Ken Rockot | f3208fc | 2018-03-07 20:35:08 | [diff] [blame] | 106 | MojoResult MojoSetMessageContextImpl( |
Ken Rockot | 559b70d | 2017-07-17 22:35:24 | [diff] [blame] | 107 | MojoMessageHandle message, |
| 108 | uintptr_t context, |
| 109 | MojoMessageContextSerializer serializer, |
Ken Rockot | f3208fc | 2018-03-07 20:35:08 | [diff] [blame] | 110 | MojoMessageContextDestructor destructor, |
| 111 | const MojoSetMessageContextOptions* options) { |
| 112 | return g_core->SetMessageContext(message, context, serializer, destructor, |
| 113 | options); |
Ken Rockot | 559b70d | 2017-07-17 22:35:24 | [diff] [blame] | 114 | } |
| 115 | |
Ken Rockot | f3208fc | 2018-03-07 20:35:08 | [diff] [blame] | 116 | MojoResult MojoGetMessageContextImpl( |
| 117 | MojoMessageHandle message, |
| 118 | const MojoGetMessageContextOptions* options, |
| 119 | uintptr_t* context) { |
| 120 | return g_core->GetMessageContext(message, options, context); |
Ken Rockot | 15b2b0b | 2017-06-12 20:36:05 | [diff] [blame] | 121 | } |
| 122 | |
Ken Rockot | c12080c | 2018-05-03 18:10:21 | [diff] [blame] | 123 | MojoResult MojoNotifyBadMessageImpl( |
| 124 | MojoMessageHandle message, |
| 125 | const char* error, |
Ken Rockot | 1da30ca | 2018-05-17 00:02:59 | [diff] [blame] | 126 | uint32_t error_num_bytes, |
Ken Rockot | c12080c | 2018-05-03 18:10:21 | [diff] [blame] | 127 | const MojoNotifyBadMessageOptions* options) { |
| 128 | return g_core->NotifyBadMessage(message, error, error_num_bytes, options); |
rockot | b1e74df | 2016-03-14 13:18:30 | [diff] [blame] | 129 | } |
| 130 | |
rockot | b04b89b5 | 2016-06-09 03:58:56 | [diff] [blame] | 131 | MojoResult MojoCreateDataPipeImpl(const MojoCreateDataPipeOptions* options, |
| 132 | MojoHandle* data_pipe_producer_handle, |
| 133 | MojoHandle* data_pipe_consumer_handle) { |
jam | 76bcf0c | 2015-10-02 21:01:28 | [diff] [blame] | 134 | return g_core->CreateDataPipe(options, data_pipe_producer_handle, |
| 135 | data_pipe_consumer_handle); |
| 136 | } |
| 137 | |
rockot | b04b89b5 | 2016-06-09 03:58:56 | [diff] [blame] | 138 | MojoResult MojoWriteDataImpl(MojoHandle data_pipe_producer_handle, |
| 139 | const void* elements, |
| 140 | uint32_t* num_elements, |
Ken Rockot | c12080c | 2018-05-03 18:10:21 | [diff] [blame] | 141 | const MojoWriteDataOptions* options) { |
jam | 76bcf0c | 2015-10-02 21:01:28 | [diff] [blame] | 142 | return g_core->WriteData(data_pipe_producer_handle, elements, num_elements, |
Ken Rockot | c12080c | 2018-05-03 18:10:21 | [diff] [blame] | 143 | options); |
jam | 76bcf0c | 2015-10-02 21:01:28 | [diff] [blame] | 144 | } |
| 145 | |
rockot | b04b89b5 | 2016-06-09 03:58:56 | [diff] [blame] | 146 | MojoResult MojoBeginWriteDataImpl(MojoHandle data_pipe_producer_handle, |
Ken Rockot | c12080c | 2018-05-03 18:10:21 | [diff] [blame] | 147 | const MojoBeginWriteDataOptions* options, |
rockot | b04b89b5 | 2016-06-09 03:58:56 | [diff] [blame] | 148 | void** buffer, |
Ken Rockot | c12080c | 2018-05-03 18:10:21 | [diff] [blame] | 149 | uint32_t* buffer_num_elements) { |
| 150 | return g_core->BeginWriteData(data_pipe_producer_handle, options, buffer, |
| 151 | buffer_num_elements); |
jam | 76bcf0c | 2015-10-02 21:01:28 | [diff] [blame] | 152 | } |
| 153 | |
rockot | b04b89b5 | 2016-06-09 03:58:56 | [diff] [blame] | 154 | MojoResult MojoEndWriteDataImpl(MojoHandle data_pipe_producer_handle, |
Ken Rockot | c12080c | 2018-05-03 18:10:21 | [diff] [blame] | 155 | uint32_t num_elements_written, |
| 156 | const MojoEndWriteDataOptions* options) { |
| 157 | return g_core->EndWriteData(data_pipe_producer_handle, num_elements_written, |
| 158 | options); |
jam | 76bcf0c | 2015-10-02 21:01:28 | [diff] [blame] | 159 | } |
| 160 | |
rockot | b04b89b5 | 2016-06-09 03:58:56 | [diff] [blame] | 161 | MojoResult MojoReadDataImpl(MojoHandle data_pipe_consumer_handle, |
Ken Rockot | c12080c | 2018-05-03 18:10:21 | [diff] [blame] | 162 | const MojoReadDataOptions* options, |
rockot | b04b89b5 | 2016-06-09 03:58:56 | [diff] [blame] | 163 | void* elements, |
Ken Rockot | c12080c | 2018-05-03 18:10:21 | [diff] [blame] | 164 | uint32_t* num_elements) { |
| 165 | return g_core->ReadData(data_pipe_consumer_handle, options, elements, |
| 166 | num_elements); |
jam | 76bcf0c | 2015-10-02 21:01:28 | [diff] [blame] | 167 | } |
| 168 | |
rockot | b04b89b5 | 2016-06-09 03:58:56 | [diff] [blame] | 169 | MojoResult MojoBeginReadDataImpl(MojoHandle data_pipe_consumer_handle, |
Ken Rockot | c12080c | 2018-05-03 18:10:21 | [diff] [blame] | 170 | const MojoBeginReadDataOptions* options, |
rockot | b04b89b5 | 2016-06-09 03:58:56 | [diff] [blame] | 171 | const void** buffer, |
Ken Rockot | c12080c | 2018-05-03 18:10:21 | [diff] [blame] | 172 | uint32_t* buffer_num_elements) { |
| 173 | return g_core->BeginReadData(data_pipe_consumer_handle, options, buffer, |
| 174 | buffer_num_elements); |
jam | 76bcf0c | 2015-10-02 21:01:28 | [diff] [blame] | 175 | } |
| 176 | |
rockot | b04b89b5 | 2016-06-09 03:58:56 | [diff] [blame] | 177 | MojoResult MojoEndReadDataImpl(MojoHandle data_pipe_consumer_handle, |
Ken Rockot | c12080c | 2018-05-03 18:10:21 | [diff] [blame] | 178 | uint32_t num_elements_read, |
| 179 | const MojoEndReadDataOptions* options) { |
| 180 | return g_core->EndReadData(data_pipe_consumer_handle, num_elements_read, |
| 181 | options); |
jam | 76bcf0c | 2015-10-02 21:01:28 | [diff] [blame] | 182 | } |
| 183 | |
rockot | b04b89b5 | 2016-06-09 03:58:56 | [diff] [blame] | 184 | MojoResult MojoCreateSharedBufferImpl( |
jam | 76bcf0c | 2015-10-02 21:01:28 | [diff] [blame] | 185 | uint64_t num_bytes, |
Ken Rockot | c12080c | 2018-05-03 18:10:21 | [diff] [blame] | 186 | const MojoCreateSharedBufferOptions* options, |
jam | 76bcf0c | 2015-10-02 21:01:28 | [diff] [blame] | 187 | MojoHandle* shared_buffer_handle) { |
Ken Rockot | c12080c | 2018-05-03 18:10:21 | [diff] [blame] | 188 | return g_core->CreateSharedBuffer(num_bytes, options, shared_buffer_handle); |
jam | 76bcf0c | 2015-10-02 21:01:28 | [diff] [blame] | 189 | } |
| 190 | |
rockot | b04b89b5 | 2016-06-09 03:58:56 | [diff] [blame] | 191 | MojoResult MojoDuplicateBufferHandleImpl( |
jam | 76bcf0c | 2015-10-02 21:01:28 | [diff] [blame] | 192 | MojoHandle buffer_handle, |
Lei Zhang | 7b81888 | 2018-03-24 01:38:40 | [diff] [blame] | 193 | const MojoDuplicateBufferHandleOptions* options, |
jam | 76bcf0c | 2015-10-02 21:01:28 | [diff] [blame] | 194 | MojoHandle* new_buffer_handle) { |
| 195 | return g_core->DuplicateBufferHandle(buffer_handle, options, |
| 196 | new_buffer_handle); |
| 197 | } |
| 198 | |
rockot | b04b89b5 | 2016-06-09 03:58:56 | [diff] [blame] | 199 | MojoResult MojoMapBufferImpl(MojoHandle buffer_handle, |
| 200 | uint64_t offset, |
| 201 | uint64_t num_bytes, |
Ken Rockot | c12080c | 2018-05-03 18:10:21 | [diff] [blame] | 202 | const MojoMapBufferOptions* options, |
| 203 | void** buffer) { |
| 204 | return g_core->MapBuffer(buffer_handle, offset, num_bytes, options, buffer); |
jam | 76bcf0c | 2015-10-02 21:01:28 | [diff] [blame] | 205 | } |
| 206 | |
rockot | b04b89b5 | 2016-06-09 03:58:56 | [diff] [blame] | 207 | MojoResult MojoUnmapBufferImpl(void* buffer) { |
jam | 76bcf0c | 2015-10-02 21:01:28 | [diff] [blame] | 208 | return g_core->UnmapBuffer(buffer); |
| 209 | } |
| 210 | |
Lei Zhang | 7b81888 | 2018-03-24 01:38:40 | [diff] [blame] | 211 | MojoResult MojoGetBufferInfoImpl(MojoHandle buffer_handle, |
Ken Rockot | c12080c | 2018-05-03 18:10:21 | [diff] [blame] | 212 | const MojoGetBufferInfoOptions* options, |
Lei Zhang | 7b81888 | 2018-03-24 01:38:40 | [diff] [blame] | 213 | MojoSharedBufferInfo* info) { |
| 214 | return g_core->GetBufferInfo(buffer_handle, options, info); |
| 215 | } |
| 216 | |
Ken Rockot | c12080c | 2018-05-03 18:10:21 | [diff] [blame] | 217 | MojoResult MojoCreateTrapImpl(MojoTrapEventHandler handler, |
| 218 | const MojoCreateTrapOptions* options, |
| 219 | MojoHandle* trap_handle) { |
| 220 | return g_core->CreateTrap(handler, options, trap_handle); |
| 221 | } |
| 222 | |
| 223 | MojoResult MojoAddTriggerImpl(MojoHandle trap_handle, |
| 224 | MojoHandle handle, |
| 225 | MojoHandleSignals signals, |
| 226 | MojoTriggerCondition condition, |
| 227 | uintptr_t context, |
| 228 | const MojoAddTriggerOptions* options) { |
| 229 | return g_core->AddTrigger(trap_handle, handle, signals, condition, context, |
| 230 | options); |
| 231 | } |
| 232 | |
| 233 | MojoResult MojoRemoveTriggerImpl(MojoHandle trap_handle, |
| 234 | uintptr_t context, |
| 235 | const MojoRemoveTriggerOptions* options) { |
| 236 | return g_core->RemoveTrigger(trap_handle, context, options); |
| 237 | } |
| 238 | |
| 239 | MojoResult MojoArmTrapImpl(MojoHandle trap_handle, |
| 240 | const MojoArmTrapOptions* options, |
Ken Rockot | 7831a95 | 2018-07-12 01:11:30 | [diff] [blame] | 241 | uint32_t* num_blocking_events, |
| 242 | MojoTrapEvent* blocking_events) { |
| 243 | return g_core->ArmTrap(trap_handle, options, num_blocking_events, |
| 244 | blocking_events); |
Ken Rockot | c12080c | 2018-05-03 18:10:21 | [diff] [blame] | 245 | } |
| 246 | |
Ken Rockot | 88be045 | 2018-05-16 17:31:04 | [diff] [blame] | 247 | MojoResult MojoWrapPlatformHandleImpl( |
rockot | 28a287e | 2016-05-24 02:51:37 | [diff] [blame] | 248 | const MojoPlatformHandle* platform_handle, |
Ken Rockot | 88be045 | 2018-05-16 17:31:04 | [diff] [blame] | 249 | const MojoWrapPlatformHandleOptions* options, |
rockot | 28a287e | 2016-05-24 02:51:37 | [diff] [blame] | 250 | MojoHandle* mojo_handle) { |
Ken Rockot | a22cf31 | 2018-06-21 19:56:54 | [diff] [blame] | 251 | return g_core->WrapPlatformHandle(platform_handle, options, mojo_handle); |
rockot | 28a287e | 2016-05-24 02:51:37 | [diff] [blame] | 252 | } |
| 253 | |
Ken Rockot | 88be045 | 2018-05-16 17:31:04 | [diff] [blame] | 254 | MojoResult MojoUnwrapPlatformHandleImpl( |
rockot | 28a287e | 2016-05-24 02:51:37 | [diff] [blame] | 255 | MojoHandle mojo_handle, |
Ken Rockot | 88be045 | 2018-05-16 17:31:04 | [diff] [blame] | 256 | const MojoUnwrapPlatformHandleOptions* options, |
| 257 | MojoPlatformHandle* platform_handle) { |
Ken Rockot | a22cf31 | 2018-06-21 19:56:54 | [diff] [blame] | 258 | return g_core->UnwrapPlatformHandle(mojo_handle, options, platform_handle); |
Ken Rockot | 88be045 | 2018-05-16 17:31:04 | [diff] [blame] | 259 | } |
| 260 | |
| 261 | MojoResult MojoWrapPlatformSharedMemoryRegionImpl( |
| 262 | const MojoPlatformHandle* platform_handles, |
| 263 | uint32_t num_platform_handles, |
| 264 | uint64_t num_bytes, |
| 265 | const MojoSharedBufferGuid* guid, |
| 266 | MojoPlatformSharedMemoryRegionAccessMode access_mode, |
| 267 | const MojoWrapPlatformSharedMemoryRegionOptions* options, |
| 268 | MojoHandle* mojo_handle) { |
| 269 | return g_core->WrapPlatformSharedMemoryRegion( |
| 270 | platform_handles, num_platform_handles, num_bytes, guid, access_mode, |
| 271 | options, mojo_handle); |
| 272 | } |
| 273 | |
| 274 | MojoResult MojoUnwrapPlatformSharedMemoryRegionImpl( |
| 275 | MojoHandle mojo_handle, |
| 276 | const MojoUnwrapPlatformSharedMemoryRegionOptions* options, |
| 277 | MojoPlatformHandle* platform_handles, |
| 278 | uint32_t* num_platform_handles, |
| 279 | uint64_t* num_bytes, |
Ken Rockot | 61a3aab | 2017-06-20 16:19:57 | [diff] [blame] | 280 | MojoSharedBufferGuid* guid, |
Ken Rockot | 88be045 | 2018-05-16 17:31:04 | [diff] [blame] | 281 | MojoPlatformSharedMemoryRegionAccessMode* access_mode) { |
| 282 | return g_core->UnwrapPlatformSharedMemoryRegion( |
| 283 | mojo_handle, options, platform_handles, num_platform_handles, num_bytes, |
| 284 | guid, access_mode); |
rockot | 28a287e | 2016-05-24 02:51:37 | [diff] [blame] | 285 | } |
| 286 | |
Ken Rockot | f86cdb8b | 2018-05-19 23:35:01 | [diff] [blame] | 287 | MojoResult MojoCreateInvitationImpl(const MojoCreateInvitationOptions* options, |
| 288 | MojoHandle* invitation_handle) { |
| 289 | return g_core->CreateInvitation(options, invitation_handle); |
| 290 | } |
| 291 | |
| 292 | MojoResult MojoAttachMessagePipeToInvitationImpl( |
| 293 | MojoHandle invitation_handle, |
Ken Rockot | 189566cd | 2018-05-24 21:04:17 | [diff] [blame] | 294 | const void* name, |
| 295 | uint32_t name_num_bytes, |
Ken Rockot | f86cdb8b | 2018-05-19 23:35:01 | [diff] [blame] | 296 | const MojoAttachMessagePipeToInvitationOptions* options, |
| 297 | MojoHandle* message_pipe_handle) { |
Ken Rockot | 189566cd | 2018-05-24 21:04:17 | [diff] [blame] | 298 | return g_core->AttachMessagePipeToInvitation( |
| 299 | invitation_handle, name, name_num_bytes, options, message_pipe_handle); |
Ken Rockot | f86cdb8b | 2018-05-19 23:35:01 | [diff] [blame] | 300 | } |
| 301 | |
| 302 | MojoResult MojoExtractMessagePipeFromInvitationImpl( |
| 303 | MojoHandle invitation_handle, |
Ken Rockot | 189566cd | 2018-05-24 21:04:17 | [diff] [blame] | 304 | const void* name, |
| 305 | uint32_t name_num_bytes, |
Ken Rockot | f86cdb8b | 2018-05-19 23:35:01 | [diff] [blame] | 306 | const MojoExtractMessagePipeFromInvitationOptions* options, |
| 307 | MojoHandle* message_pipe_handle) { |
Ken Rockot | 189566cd | 2018-05-24 21:04:17 | [diff] [blame] | 308 | return g_core->ExtractMessagePipeFromInvitation( |
| 309 | invitation_handle, name, name_num_bytes, options, message_pipe_handle); |
Ken Rockot | f86cdb8b | 2018-05-19 23:35:01 | [diff] [blame] | 310 | } |
| 311 | |
| 312 | MojoResult MojoSendInvitationImpl( |
| 313 | MojoHandle invitation_handle, |
| 314 | const MojoPlatformProcessHandle* process_handle, |
| 315 | const MojoInvitationTransportEndpoint* transport_endpoint, |
| 316 | MojoProcessErrorHandler error_handler, |
| 317 | uintptr_t error_handler_context, |
| 318 | const MojoSendInvitationOptions* options) { |
| 319 | return g_core->SendInvitation(invitation_handle, process_handle, |
| 320 | transport_endpoint, error_handler, |
| 321 | error_handler_context, options); |
| 322 | } |
| 323 | |
| 324 | MojoResult MojoAcceptInvitationImpl( |
| 325 | const MojoInvitationTransportEndpoint* transport_endpoint, |
| 326 | const MojoAcceptInvitationOptions* options, |
| 327 | MojoHandle* invitation_handle) { |
| 328 | return g_core->AcceptInvitation(transport_endpoint, options, |
| 329 | invitation_handle); |
| 330 | } |
| 331 | |
Ken Rockot | 0db0bcf | 2018-07-12 22:01:12 | [diff] [blame] | 332 | MojoResult MojoSetQuotaImpl(MojoHandle handle, |
| 333 | MojoQuotaType type, |
| 334 | uint64_t limit, |
| 335 | const MojoSetQuotaOptions* options) { |
| 336 | return g_core->SetQuota(handle, type, limit, options); |
| 337 | } |
| 338 | |
| 339 | MojoResult MojoQueryQuotaImpl(MojoHandle handle, |
| 340 | MojoQuotaType type, |
| 341 | const MojoQueryQuotaOptions* options, |
| 342 | uint64_t* current_limit, |
| 343 | uint64_t* current_usage) { |
| 344 | return g_core->QueryQuota(handle, type, options, current_limit, |
| 345 | current_usage); |
| 346 | } |
| 347 | |
jam | 76bcf0c | 2015-10-02 21:01:28 | [diff] [blame] | 348 | } // extern "C" |
rockot | b04b89b5 | 2016-06-09 03:58:56 | [diff] [blame] | 349 | |
Ken Rockot | 898d796d5 | 2018-03-23 19:03:52 | [diff] [blame] | 350 | MojoSystemThunks g_thunks = {sizeof(MojoSystemThunks), |
Ken Rockot | 773a51f | 2018-03-24 09:01:12 | [diff] [blame] | 351 | MojoInitializeImpl, |
Ken Rockot | 898d796d5 | 2018-03-23 19:03:52 | [diff] [blame] | 352 | MojoGetTimeTicksNowImpl, |
| 353 | MojoCloseImpl, |
| 354 | MojoQueryHandleSignalsStateImpl, |
| 355 | MojoCreateMessagePipeImpl, |
| 356 | MojoWriteMessageImpl, |
| 357 | MojoReadMessageImpl, |
Ken Rockot | c12080c | 2018-05-03 18:10:21 | [diff] [blame] | 358 | MojoFuseMessagePipesImpl, |
| 359 | MojoCreateMessageImpl, |
| 360 | MojoDestroyMessageImpl, |
| 361 | MojoSerializeMessageImpl, |
| 362 | MojoAppendMessageDataImpl, |
| 363 | MojoGetMessageDataImpl, |
| 364 | MojoSetMessageContextImpl, |
| 365 | MojoGetMessageContextImpl, |
| 366 | MojoNotifyBadMessageImpl, |
Ken Rockot | 898d796d5 | 2018-03-23 19:03:52 | [diff] [blame] | 367 | MojoCreateDataPipeImpl, |
| 368 | MojoWriteDataImpl, |
| 369 | MojoBeginWriteDataImpl, |
| 370 | MojoEndWriteDataImpl, |
| 371 | MojoReadDataImpl, |
| 372 | MojoBeginReadDataImpl, |
| 373 | MojoEndReadDataImpl, |
| 374 | MojoCreateSharedBufferImpl, |
| 375 | MojoDuplicateBufferHandleImpl, |
| 376 | MojoMapBufferImpl, |
| 377 | MojoUnmapBufferImpl, |
Lei Zhang | 7b81888 | 2018-03-24 01:38:40 | [diff] [blame] | 378 | MojoGetBufferInfoImpl, |
Ken Rockot | 898d796d5 | 2018-03-23 19:03:52 | [diff] [blame] | 379 | MojoCreateTrapImpl, |
| 380 | MojoAddTriggerImpl, |
| 381 | MojoRemoveTriggerImpl, |
| 382 | MojoArmTrapImpl, |
Ken Rockot | 898d796d5 | 2018-03-23 19:03:52 | [diff] [blame] | 383 | MojoWrapPlatformHandleImpl, |
| 384 | MojoUnwrapPlatformHandleImpl, |
Ken Rockot | 88be045 | 2018-05-16 17:31:04 | [diff] [blame] | 385 | MojoWrapPlatformSharedMemoryRegionImpl, |
Ken Rockot | f86cdb8b | 2018-05-19 23:35:01 | [diff] [blame] | 386 | MojoUnwrapPlatformSharedMemoryRegionImpl, |
| 387 | MojoCreateInvitationImpl, |
| 388 | MojoAttachMessagePipeToInvitationImpl, |
| 389 | MojoExtractMessagePipeFromInvitationImpl, |
| 390 | MojoSendInvitationImpl, |
Ken Rockot | 0db0bcf | 2018-07-12 22:01:12 | [diff] [blame] | 391 | MojoAcceptInvitationImpl, |
| 392 | MojoSetQuotaImpl, |
| 393 | MojoQueryQuotaImpl}; |
Ken Rockot | 898d796d5 | 2018-03-23 19:03:52 | [diff] [blame] | 394 | |
| 395 | } // namespace |
| 396 | |
rockot | b04b89b5 | 2016-06-09 03:58:56 | [diff] [blame] | 397 | namespace mojo { |
Ken Rockot | dba46db | 2018-07-04 18:41:04 | [diff] [blame] | 398 | namespace core { |
rockot | b04b89b5 | 2016-06-09 03:58:56 | [diff] [blame] | 399 | |
Ken Rockot | 898d796d5 | 2018-03-23 19:03:52 | [diff] [blame] | 400 | // static |
| 401 | Core* Core::Get() { |
| 402 | return g_core; |
| 403 | } |
| 404 | |
| 405 | void InitializeCore() { |
| 406 | g_core = new Core; |
| 407 | } |
| 408 | |
| 409 | const MojoSystemThunks& GetSystemThunks() { |
| 410 | return g_thunks; |
rockot | b04b89b5 | 2016-06-09 03:58:56 | [diff] [blame] | 411 | } |
| 412 | |
Ken Rockot | dba46db | 2018-07-04 18:41:04 | [diff] [blame] | 413 | } // namespace core |
rockot | b04b89b5 | 2016-06-09 03:58:56 | [diff] [blame] | 414 | } // namespace mojo |