1 /* 2 * OMX offloading remote processor driver 3 * 4 * Copyright(c) 2011 Texas Instruments. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 10 * * Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * * Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in 14 * the documentation and/or other materials provided with the 15 * distribution. 16 * * Neither the name Texas Instruments nor the names of its 17 * contributors may be used to endorse or promote products derived 18 * from this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33 #ifndef RPMSG_OMX_H 34 #define RPMSG_OMX_H 35 36 #include <linux/ioctl.h> 37 38 #define OMX_IOC_MAGIC 'X' 39 40 #define OMX_IOCCONNECT _IOW(OMX_IOC_MAGIC, 1, char *) 41 #define OMX_IOCIONREGISTER _IOWR(OMX_IOC_MAGIC, 2, struct ion_fd_data) 42 #define OMX_IOCIONUNREGISTER _IOWR(OMX_IOC_MAGIC, 3, struct ion_fd_data) 43 44 #define OMX_IOC_MAXNR (3) 45 46 #ifdef __KERNEL__ 47 48 /** 49 * enum omx_msg_types - various message types currently supported 50 * 51 * @OMX_CONN_REQ: a connection request message type. the message should carry 52 * the name of the OMX service which we try to connect to. An instance of 53 * that service will be created remotely, and its address will be sent as 54 * a reply. 55 * 56 * @OMX_CONN_RSP: a response to a connection request. the message will carry 57 * an error code (success/failure), and if connection established successfully, 58 * the addr field will carry the address of the newly created OMX instance. 59 * 60 * @OMX_DISCONNECT: disconnect remote OMX instance. this message tells 61 * remote processor to release the resources coupled with this connection 62 * 63 * @OMX_RAW_MSG: a message that should be propagated as-is to the user. 64 * this would immediately enable user space development to start. 65 * as we progress, most likely this message won't be needed anymore. 66 */ 67 enum omx_msg_types { 68 OMX_CONN_REQ = 0, 69 OMX_CONN_RSP = 1, 70 OMX_DISCONNECT = 4, 71 OMX_RAW_MSG = 5, 72 /* todo: do we need a disconnect response ? ION refcounts should allow 73 * asynchronous release of relevant buffers */ 74 }; 75 76 /** 77 * enum omx_error_codes - various error codes that will be used 78 * 79 * @OMX_SUCCESS: success 80 * 81 * @OMX_NOTSUPP: not supported 82 * 83 * @OMX_NOMEM: remote processor is out of memory 84 */ 85 enum omx_error_codes { 86 OMX_SUCCESS = 0, 87 OMX_NOTSUPP = 1, 88 OMX_NOMEM = 2, 89 }; 90 91 /* keep documenting... */ 92 enum omx_state { 93 OMX_UNCONNECTED, 94 OMX_CONNECTED, 95 OMX_FAIL, 96 }; 97 98 /** 99 * struct omx_msg_hdr - common header for all OMX messages 100 * @type: type of message, see enum omx_msg_types 101 * @flags: currently unused, should be zero 102 * @len: length of msg payload (in bytes) 103 * @data: the msg payload (depends on the message type) 104 * 105 * All OMX messages will start with this common header (which will begin 106 * right after the standard rpmsg header ends). 107 */ 108 struct omx_msg_hdr { 109 u32 type; 110 u32 flags; 111 u32 len; 112 char data[0]; 113 } __packed; 114 115 struct omx_conn_rsp { 116 u32 status; 117 u32 addr; 118 } __packed; 119 120 struct omx_disc_req { 121 u32 addr; 122 } __packed; 123 124 125 #endif /* __KERNEL__ */ 126 127 /* temporarily exposed to user space too */ 128 struct omx_conn_req { 129 char name[48]; 130 } __packed; 131 132 /* the packet structure (actual message sent to omx service) */ 133 struct omx_packet { 134 uint16_t desc; /* descriptor, and omx service status */ 135 uint16_t msg_id; /* message id */ 136 uint32_t flags; /* Set to a fixed value for now. */ 137 uint32_t fxn_idx; /* Index into OMX service's function table.*/ 138 int32_t result; /* The OMX function status. */ 139 uint32_t data_size;/* Size of in/out data to/from the function. */ 140 uint32_t data[0]; /* Payload of data_size char's passed to 141 function. */ 142 }; 143 144 #endif /* RPMSG_OMX_H */ 145