summaryrefslogtreecommitdiffstats
path: root/kernel-headers/linux/rpmsg_omx.h
blob: c6ce94b7a952f059cc7090c92aa462d1590d64b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/*
 * OMX offloading remote processor driver
 *
 * Copyright(c) 2011 Texas Instruments. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * * Redistributions of source code must retain the above copyright
 *   notice, this list of conditions and the following disclaimer.
 * * Redistributions in binary form must reproduce the above copyright
 *   notice, this list of conditions and the following disclaimer in
 *   the documentation and/or other materials provided with the
 *   distribution.
 * * Neither the name Texas Instruments nor the names of its
 *   contributors may be used to endorse or promote products derived
 *   from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef RPMSG_OMX_H
#define RPMSG_OMX_H

#include <linux/ioctl.h>

/**
 * struct omx_pvr_data - metadata passed to/from userspace for a pvr register
 * @fd:           a file descriptor representing a pvr handle
 * @num_handles:  field filled by driver. userspace uses this to determine
 *                number of handles associated with fd
 * @handles:      opaque pointers pointing to buffers
 */
struct omx_pvr_data {
	int fd;
	unsigned int num_handles;
	void *handles[2];
};

#define OMX_IOC_MAGIC	'X'

#define OMX_IOCCONNECT		_IOW(OMX_IOC_MAGIC, 1, char *)
#define OMX_IOCIONREGISTER	_IOWR(OMX_IOC_MAGIC, 2, struct ion_fd_data)
#define OMX_IOCIONUNREGISTER	_IOWR(OMX_IOC_MAGIC, 3, struct ion_fd_data)
#define OMX_IOCPVRREGISTER	_IOWR(OMX_IOC_MAGIC, 4, struct omx_pvr_data)
#define OMX_IOC_MAXNR	(4)
#ifdef __KERNEL__

/**
 * enum omx_msg_types - various message types currently supported
 *
 * @OMX_CONN_REQ: a connection request message type. the message should carry
 * the name of the OMX service which we try to connect to. An instance of
 * that service will be created remotely, and its address will be sent as
 * a reply.
 *
 * @OMX_CONN_RSP: a response to a connection request. the message will carry
 * an error code (success/failure), and if connection established successfully,
 * the addr field will carry the address of the newly created OMX instance.
 *
 * @OMX_DISCONNECT: disconnect remote OMX instance. this message tells
 * remote processor to release the resources coupled with this connection
 *
 * @OMX_RAW_MSG: a message that should be propagated as-is to the user.
 * this would immediately enable user space development to start.
 * as we progress, most likely this message won't be needed anymore.
 */
enum omx_msg_types {
	OMX_CONN_REQ = 0,
	OMX_CONN_RSP = 1,
	OMX_DISCONNECT = 4,
	OMX_RAW_MSG = 5,
	/* todo: do we need a disconnect response ? ION refcounts should allow
	 * asynchronous release of relevant buffers */
};

/**
 * enum omx_error_codes - various error codes that will be used
 *
 * @OMX_SUCCESS: success
 *
 * @OMX_NOTSUPP: not supported
 *
 * @OMX_NOMEM: remote processor is out of memory
 */
enum omx_error_codes {
	OMX_SUCCESS = 0,
	OMX_NOTSUPP = 1,
	OMX_NOMEM = 2,
};

/* keep documenting... */
enum omx_state {
	OMX_UNCONNECTED,
	OMX_CONNECTED,
	OMX_FAIL,
};

/**
 * struct omx_msg_hdr - common header for all OMX messages
 * @type:	type of message, see enum omx_msg_types
 * @flags:	currently unused, should be zero
 * @len:	length of msg payload (in bytes)
 * @data:	the msg payload (depends on the message type)
 *
 * All OMX messages will start with this common header (which will begin
 * right after the standard rpmsg header ends).
 */
struct omx_msg_hdr {
	u32 type;
	u32 flags;
	u32 len;
	char data[0];
} __packed;

struct omx_conn_rsp {
	u32 status;
	u32 addr;
} __packed;

struct omx_disc_req {
	u32 addr;
} __packed;


#endif /* __KERNEL__ */

/* temporarily exposed to user space too */
struct omx_conn_req {
	char name[48];
} __packed;

/* the packet structure (actual message sent to omx service) */
struct omx_packet {
	uint16_t      desc;	/* descriptor, and omx service status */
	uint16_t      msg_id;	/* message id */
	uint32_t      flags;	/* Set to a fixed value for now. */
	uint32_t      fxn_idx;	/* Index into OMX service's function table.*/
	int32_t       result;	/* The OMX function status. */
	uint32_t      data_size;/* Size of in/out data to/from the function. */
	uint32_t      data[0];	/* Payload of data_size char's passed to
				   function. */
};

#endif /* RPMSG_OMX_H */