1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2 /* Copyright (c) 2010-2012 Broadcom. All rights reserved. */
3 
4 #ifndef VCHIQ_IOCTLS_H
5 #define VCHIQ_IOCTLS_H
6 
7 #include <linux/ioctl.h>
8 #include "vchiq_if.h"
9 
10 #define VCHIQ_IOC_MAGIC 0xc4
11 #define VCHIQ_INVALID_HANDLE (~0)
12 
13 struct vchiq_create_service {
14 	struct vchiq_service_params params;
15 	int is_open;
16 	int is_vchi;
17 	unsigned int handle;       /* OUT */
18 };
19 
20 struct vchiq_queue_message {
21 	unsigned int handle;
22 	unsigned int count;
23 	const struct vchiq_element __user *elements;
24 };
25 
26 struct vchiq_queue_bulk_transfer {
27 	unsigned int handle;
28 	void *data;
29 	unsigned int size;
30 	void *userdata;
31 	VCHIQ_BULK_MODE_T mode;
32 };
33 
34 struct vchiq_completion_data {
35 	VCHIQ_REASON_T reason;
36 	struct vchiq_header *header;
37 	void *service_userdata;
38 	void *bulk_userdata;
39 };
40 
41 struct vchiq_await_completion {
42 	unsigned int count;
43 	struct vchiq_completion_data *buf;
44 	unsigned int msgbufsize;
45 	unsigned int msgbufcount; /* IN/OUT */
46 	void **msgbufs;
47 };
48 
49 struct vchiq_dequeue_message {
50 	unsigned int handle;
51 	int blocking;
52 	unsigned int bufsize;
53 	void *buf;
54 };
55 
56 struct vchiq_get_config {
57 	unsigned int config_size;
58 	struct vchiq_config __user *pconfig;
59 };
60 
61 struct vchiq_set_service_option {
62 	unsigned int handle;
63 	VCHIQ_SERVICE_OPTION_T option;
64 	int value;
65 };
66 
67 struct vchiq_dump_mem {
68 	void     *virt_addr;
69 	size_t    num_bytes;
70 };
71 
72 #define VCHIQ_IOC_CONNECT              _IO(VCHIQ_IOC_MAGIC,   0)
73 #define VCHIQ_IOC_SHUTDOWN             _IO(VCHIQ_IOC_MAGIC,   1)
74 #define VCHIQ_IOC_CREATE_SERVICE \
75 	_IOWR(VCHIQ_IOC_MAGIC, 2, struct vchiq_create_service)
76 #define VCHIQ_IOC_REMOVE_SERVICE       _IO(VCHIQ_IOC_MAGIC,   3)
77 #define VCHIQ_IOC_QUEUE_MESSAGE \
78 	_IOW(VCHIQ_IOC_MAGIC,  4, struct vchiq_queue_message)
79 #define VCHIQ_IOC_QUEUE_BULK_TRANSMIT \
80 	_IOWR(VCHIQ_IOC_MAGIC, 5, struct vchiq_queue_bulk_transfer)
81 #define VCHIQ_IOC_QUEUE_BULK_RECEIVE \
82 	_IOWR(VCHIQ_IOC_MAGIC, 6, struct vchiq_queue_bulk_transfer)
83 #define VCHIQ_IOC_AWAIT_COMPLETION \
84 	_IOWR(VCHIQ_IOC_MAGIC, 7, struct vchiq_await_completion)
85 #define VCHIQ_IOC_DEQUEUE_MESSAGE \
86 	_IOWR(VCHIQ_IOC_MAGIC, 8, struct vchiq_dequeue_message)
87 #define VCHIQ_IOC_GET_CLIENT_ID        _IO(VCHIQ_IOC_MAGIC,   9)
88 #define VCHIQ_IOC_GET_CONFIG \
89 	_IOWR(VCHIQ_IOC_MAGIC, 10, struct vchiq_get_config)
90 #define VCHIQ_IOC_CLOSE_SERVICE        _IO(VCHIQ_IOC_MAGIC,   11)
91 #define VCHIQ_IOC_USE_SERVICE          _IO(VCHIQ_IOC_MAGIC,   12)
92 #define VCHIQ_IOC_RELEASE_SERVICE      _IO(VCHIQ_IOC_MAGIC,   13)
93 #define VCHIQ_IOC_SET_SERVICE_OPTION \
94 	_IOW(VCHIQ_IOC_MAGIC,  14, struct vchiq_set_service_option)
95 #define VCHIQ_IOC_DUMP_PHYS_MEM \
96 	_IOW(VCHIQ_IOC_MAGIC,  15, struct vchiq_dump_mem)
97 #define VCHIQ_IOC_LIB_VERSION          _IO(VCHIQ_IOC_MAGIC,   16)
98 #define VCHIQ_IOC_CLOSE_DELIVERED      _IO(VCHIQ_IOC_MAGIC,   17)
99 #define VCHIQ_IOC_MAX                  17
100 
101 #endif
102