James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [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 | |
| 5 | # pylint: disable=F0401 |
| 6 | |
| 7 | import interface_dsl |
| 8 | |
| 9 | def MakeInterface(): |
| 10 | mojo = interface_dsl.Interface() |
| 11 | |
Viet-Trung Luu | 9beb4f7 | 2016-03-09 15:58:11 -0800 | [diff] [blame] | 12 | # This function is not provided by the Mojo system APIs, but instead allows |
| 13 | # trusted code to provide a handle for use by untrusted code. See the |
| 14 | # implementation in mojo_syscall.cc.tmpl. |
| 15 | f = mojo.Func('_MojoGetInitialHandle', 'MojoResult') |
| 16 | f.Param('handle').Out('MojoHandle') |
| 17 | |
| 18 | f = mojo.Func('MojoGetTimeTicksNow', 'MojoTimeTicks') |
| 19 | |
| 20 | f = mojo.Func('MojoClose', 'MojoResult') |
| 21 | f.Param('handle').In('MojoHandle') |
| 22 | |
Viet-Trung Luu | e5ace23 | 2016-05-19 14:54:48 -0700 | [diff] [blame] | 23 | f = mojo.Func('MojoGetRights', 'MojoResult') |
| 24 | f.Param('handle').In('MojoHandle') |
| 25 | f.Param('rights').Out('MojoHandleRights') |
| 26 | |
Viet-Trung Luu | 9beb4f7 | 2016-03-09 15:58:11 -0800 | [diff] [blame] | 27 | f = mojo.Func('MojoWait', 'MojoResult') |
| 28 | f.Param('handle').In('MojoHandle') |
| 29 | f.Param('signals').In('MojoHandleSignals') |
| 30 | f.Param('deadline').In('MojoDeadline') |
| 31 | f.Param('signals_state').OutFixedStruct('MojoHandleSignalsState').Optional() |
| 32 | |
| 33 | f = mojo.Func('MojoWaitMany', 'MojoResult') |
| 34 | f.Param('handles').InArray('MojoHandle', 'num_handles') |
| 35 | f.Param('signals').InArray('MojoHandleSignals', 'num_handles') |
| 36 | f.Param('num_handles').In('uint32_t') |
| 37 | f.Param('deadline').In('MojoDeadline') |
| 38 | f.Param('result_index').Out('uint32_t').Optional() |
| 39 | p = f.Param('signals_states') |
| 40 | p.OutFixedStructArray('MojoHandleSignalsState', 'num_handles').Optional() |
| 41 | |
| 42 | f = mojo.Func('MojoCreateMessagePipe', 'MojoResult') |
Nick Bray | 7adc5c4 | 2014-12-15 13:24:02 -0800 | [diff] [blame] | 43 | p = f.Param('options') |
Viet-Trung Luu | 9beb4f7 | 2016-03-09 15:58:11 -0800 | [diff] [blame] | 44 | p.InExtensibleStruct('MojoCreateMessagePipeOptions').Optional() |
| 45 | f.Param('message_pipe_handle0').Out('MojoHandle') |
| 46 | f.Param('message_pipe_handle1').Out('MojoHandle') |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 47 | |
Viet-Trung Luu | 9beb4f7 | 2016-03-09 15:58:11 -0800 | [diff] [blame] | 48 | f = mojo.Func('MojoWriteMessage', 'MojoResult') |
| 49 | f.Param('message_pipe_handle').In('MojoHandle') |
| 50 | f.Param('bytes').InArray('void', 'num_bytes').Optional() |
| 51 | f.Param('num_bytes').In('uint32_t') |
| 52 | f.Param('handles').InArray('MojoHandle', 'num_handles').Optional() |
| 53 | f.Param('num_handles').In('uint32_t') |
| 54 | f.Param('flags').In('MojoWriteMessageFlags') |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 55 | |
Viet-Trung Luu | 9beb4f7 | 2016-03-09 15:58:11 -0800 | [diff] [blame] | 56 | f = mojo.Func('MojoReadMessage', 'MojoResult') |
| 57 | f.Param('message_pipe_handle').In('MojoHandle') |
| 58 | f.Param('bytes').OutArray('void', 'num_bytes').Optional() |
| 59 | f.Param('num_bytes').InOut('uint32_t').Optional() |
| 60 | f.Param('handles').OutArray('MojoHandle', 'num_handles').Optional() |
| 61 | f.Param('num_handles').InOut('uint32_t').Optional() |
| 62 | f.Param('flags').In('MojoReadMessageFlags') |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 63 | |
| 64 | f = mojo.Func('MojoCreateDataPipe', 'MojoResult') |
Nick Bray | 7adc5c4 | 2014-12-15 13:24:02 -0800 | [diff] [blame] | 65 | p = f.Param('options') |
| 66 | p.InExtensibleStruct('MojoCreateDataPipeOptions').Optional() |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 67 | f.Param('data_pipe_producer_handle').Out('MojoHandle') |
| 68 | f.Param('data_pipe_consumer_handle').Out('MojoHandle') |
| 69 | |
Viet-Trung Luu | d1825d2 | 2016-04-13 17:13:45 -0700 | [diff] [blame] | 70 | f = mojo.Func('MojoSetDataPipeProducerOptions', 'MojoResult') |
| 71 | f.Param('data_pipe_producer_handle').In('MojoHandle') |
| 72 | p = f.Param('options') |
| 73 | p.InExtensibleStruct('MojoDataPipeProducerOptions').Optional() |
| 74 | |
| 75 | f = mojo.Func('MojoGetDataPipeProducerOptions', 'MojoResult') |
| 76 | f.Param('data_pipe_producer_handle').In('MojoHandle') |
| 77 | p = f.Param('options') |
| 78 | p.OutExtensibleStruct('MojoDataPipeProducerOptions', 'options_num_bytes') |
| 79 | f.Param('options_num_bytes').In('uint32_t') |
| 80 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 81 | f = mojo.Func('MojoWriteData', 'MojoResult') |
| 82 | f.Param('data_pipe_producer_handle').In('MojoHandle') |
| 83 | f.Param('elements').InArray('void', 'num_bytes') |
| 84 | f.Param('num_bytes').InOut('uint32_t') |
| 85 | f.Param('flags').In('MojoWriteDataFlags') |
| 86 | |
| 87 | f = mojo.Func('MojoBeginWriteData', 'MojoResult') |
| 88 | f.Param('data_pipe_producer_handle').In('MojoHandle') |
| 89 | f.Param('buffer').Out('void*') |
| 90 | f.Param('buffer_num_bytes').InOut('uint32_t') |
| 91 | f.Param('flags').In('MojoWriteDataFlags') |
Nick Bray | ed1b03f | 2015-04-13 14:22:57 -0700 | [diff] [blame] | 92 | # TODO(ncbray): support two-stage reads and writes. |
| 93 | # https://code.google.com/p/chromium/issues/detail?id=401761 |
| 94 | f.IsBrokenInNaCl() |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 95 | |
| 96 | f = mojo.Func('MojoEndWriteData', 'MojoResult') |
| 97 | f.Param('data_pipe_producer_handle').In('MojoHandle') |
| 98 | f.Param('num_bytes_written').In('uint32_t') |
| 99 | |
Viet-Trung Luu | 58ec2b7 | 2016-04-05 13:43:25 -0700 | [diff] [blame] | 100 | f = mojo.Func('MojoSetDataPipeConsumerOptions', 'MojoResult') |
| 101 | f.Param('data_pipe_consumer_handle').In('MojoHandle') |
| 102 | p = f.Param('options') |
| 103 | p.InExtensibleStruct('MojoDataPipeConsumerOptions').Optional() |
| 104 | |
| 105 | f = mojo.Func('MojoGetDataPipeConsumerOptions', 'MojoResult') |
| 106 | f.Param('data_pipe_consumer_handle').In('MojoHandle') |
| 107 | p = f.Param('options') |
| 108 | p.OutExtensibleStruct('MojoDataPipeConsumerOptions', 'options_num_bytes') |
| 109 | f.Param('options_num_bytes').In('uint32_t') |
| 110 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 111 | f = mojo.Func('MojoReadData', 'MojoResult') |
| 112 | f.Param('data_pipe_consumer_handle').In('MojoHandle') |
| 113 | f.Param('elements').OutArray('void', 'num_bytes') |
| 114 | f.Param('num_bytes').InOut('uint32_t') |
| 115 | f.Param('flags').In('MojoReadDataFlags') |
| 116 | |
| 117 | f = mojo.Func('MojoBeginReadData', 'MojoResult') |
| 118 | f.Param('data_pipe_consumer_handle').In('MojoHandle') |
| 119 | f.Param('buffer').Out('const void*') |
| 120 | f.Param('buffer_num_bytes').InOut('uint32_t') |
| 121 | f.Param('flags').In('MojoReadDataFlags') |
Nick Bray | ed1b03f | 2015-04-13 14:22:57 -0700 | [diff] [blame] | 122 | # TODO(ncbray): support two-stage reads and writes. |
| 123 | # https://code.google.com/p/chromium/issues/detail?id=401761 |
| 124 | f.IsBrokenInNaCl() |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 125 | |
| 126 | f = mojo.Func('MojoEndReadData', 'MojoResult') |
| 127 | f.Param('data_pipe_consumer_handle').In('MojoHandle') |
| 128 | f.Param('num_bytes_read').In('uint32_t') |
| 129 | |
Viet-Trung Luu | 9beb4f7 | 2016-03-09 15:58:11 -0800 | [diff] [blame] | 130 | f = mojo.Func('MojoCreateSharedBuffer', 'MojoResult') |
Nick Bray | 7adc5c4 | 2014-12-15 13:24:02 -0800 | [diff] [blame] | 131 | p = f.Param('options') |
Viet-Trung Luu | 9beb4f7 | 2016-03-09 15:58:11 -0800 | [diff] [blame] | 132 | p.InExtensibleStruct('MojoCreateSharedBufferOptions').Optional() |
| 133 | f.Param('num_bytes').In('uint64_t') |
| 134 | f.Param('shared_buffer_handle').Out('MojoHandle') |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 135 | |
Viet-Trung Luu | 9beb4f7 | 2016-03-09 15:58:11 -0800 | [diff] [blame] | 136 | f = mojo.Func('MojoDuplicateBufferHandle', 'MojoResult') |
| 137 | f.Param('buffer_handle').In('MojoHandle') |
| 138 | p = f.Param('options') |
| 139 | p.InExtensibleStruct('MojoDuplicateBufferHandleOptions').Optional() |
| 140 | f.Param('new_buffer_handle').Out('MojoHandle') |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 141 | |
Viet-Trung Luu | 9beb4f7 | 2016-03-09 15:58:11 -0800 | [diff] [blame] | 142 | f = mojo.Func('MojoGetBufferInformation', 'MojoResult') |
| 143 | f.Param('buffer_handle').In('MojoHandle') |
| 144 | p = f.Param('info') |
| 145 | p.OutExtensibleStruct('MojoBufferInformation', 'info_num_bytes') |
| 146 | f.Param('info_num_bytes').In('uint32_t') |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 147 | |
Viet-Trung Luu | 9beb4f7 | 2016-03-09 15:58:11 -0800 | [diff] [blame] | 148 | f = mojo.Func('MojoMapBuffer', 'MojoResult') |
| 149 | f.Param('buffer_handle').In('MojoHandle') |
| 150 | f.Param('offset').In('uint64_t') |
| 151 | f.Param('num_bytes').In('uint64_t') |
| 152 | f.Param('buffer').Out('void*') |
| 153 | f.Param('flags').In('MojoMapBufferFlags') |
| 154 | # TODO(ncbray): support mmaping. |
| 155 | # https://code.google.com/p/chromium/issues/detail?id=401761 |
| 156 | f.IsBrokenInNaCl() |
| 157 | |
| 158 | f = mojo.Func('MojoUnmapBuffer', 'MojoResult') |
| 159 | f.Param('buffer').In('void*') |
| 160 | # TODO(ncbray): support mmaping. |
| 161 | # https://code.google.com/p/chromium/issues/detail?id=401761 |
| 162 | f.IsBrokenInNaCl() |
Justin TerAvest | 409959d | 2015-01-27 14:59:40 -0700 | [diff] [blame] | 163 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 164 | mojo.Finalize() |
| 165 | |
| 166 | return mojo |