123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- /*
- * Remote Processor Procedure Call Driver
- *
- * Copyright (C) 2012-2017 Texas Instruments Incorporated - http://www.ti.com/
- *
- * 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 _UAPI_LINUX_RPMSG_RPC_H_
- #define _UAPI_LINUX_RPMSG_RPC_H_
- #include <linux/ioctl.h>
- /**
- * struct rppc_buf_fds - rppc buffer registration/deregistration
- * @num: number of file descriptors
- * @fds: pointer to the array holding the file descriptors
- */
- struct rppc_buf_fds {
- uint32_t num;
- int32_t *fds;
- };
- /*
- * ioctl definitions
- */
- #define RPPC_IOC_MAGIC 'r'
- #define RPPC_IOC_CREATE _IOW(RPPC_IOC_MAGIC, 1, char *)
- #define RPPC_IOC_BUFREGISTER _IOW(RPPC_IOC_MAGIC, 2, struct rppc_buf_fds)
- #define RPPC_IOC_BUFUNREGISTER _IOW(RPPC_IOC_MAGIC, 3, struct rppc_buf_fds)
- #define RPPC_IOC_MAXNR (4)
- #define RPPC_MAX_PARAMETERS (10)
- #define RPPC_MAX_TRANSLATIONS (1024)
- #define RPPC_MAX_INST_NAMELEN (48)
- /**
- * enum rppc_param_type - RPC function parameter type
- * @RPPC_PARAM_TYPE_UNKNOWN: unrecognized parameter
- * @RPPC_PARAM_TYPE_ATOMIC: an atomic data type, 1 byte to architecture limit
- * sized bytes
- * @RPPC_PARAM_TYPE_PTR: a pointer to shared memory. The fd field in the
- * structures rppc_param and rppc_param_translation must
- * contain the file descriptor of the associated dma_buf
- * @RPPC_PARAM_TYPE_STRUCT: (unsupported) a structure type. Will be architecture
- * width aligned in memory
- *
- * These enum values are used to identify the parameter type for every
- * parameter argument of the remote function.
- */
- enum rppc_param_type {
- RPPC_PARAM_TYPE_UNKNOWN = 0,
- RPPC_PARAM_TYPE_ATOMIC,
- RPPC_PARAM_TYPE_PTR,
- RPPC_PARAM_TYPE_STRUCT,
- };
- /**
- * struct rppc_param_translation - pointer translation helper structure
- * @index: index of the parameter where the translation needs to be done in.
- * used for computing the primary offset and mapping into kernel
- * the page from the buffer referred to in the corresponding parameter
- * @offset: offset from the primary base pointer to the pointer to translate.
- * This is the secondary offset, and used either for mentioning the
- * offset from an structure array element base, or within a single
- * structure which itself is at an offset in an allocated buffer
- * @base: the base user virtual address of the pointer to translate (used to
- * calculate translated pointer offset)
- * @fd: dma_buf file descriptor of the allocated buffer pointer within which
- * the translated pointer is present
- */
- struct rppc_param_translation {
- uint32_t index;
- ptrdiff_t offset;
- size_t base;
- int32_t fd;
- };
- /**
- * struct rppc_param - descriptor structure for each parameter
- * @type: type of the parameter, as dictated by enum rppc_param_type
- * @size: size of the data (for atomic types) or size of the containing
- * structure in which translations are performed
- * @data: either the parameter value itself (for atomic type) or
- * the actual user space pointer address to the data (for pointer type)
- * @base: the base user space pointer address of the original allocated buffer,
- * providing a reference if data has the pointer that is at an offset
- * from the original pointer
- * @fd: file descriptor of the exported allocation (will be used to
- * import the associated dma_buf within the driver).
- */
- struct rppc_param {
- uint32_t type;
- size_t size;
- size_t data;
- size_t base;
- int32_t fd;
- };
- /**
- * struct rppc_function - descriptor structure for the remote function
- * @fxn_id: index of the function to invoke on the opened rppc device
- * @num_params: number of parameters filled in the params field
- * @params: array of parameter descriptor structures
- * @num_translations: number of in-place translations to be performed within
- * the arguments.
- * @translations: an open array of the translation descriptor structures, whose
- * length is given in @num_translations. Used for translating
- * the pointers within the function data.
- *
- * This is the primary descriptor structure passed down from the userspace,
- * describing the function, its parameter arguments and the needed translations.
- */
- struct rppc_function {
- uint32_t fxn_id;
- uint32_t num_params;
- struct rppc_param params[RPPC_MAX_PARAMETERS];
- uint32_t num_translations;
- struct rppc_param_translation translations[0];
- };
- /**
- * struct rppc_function_return - function return status descriptor structure
- * @fxn_id: index of the function invoked on the opened rppc device
- * @status: return value of the executed function
- */
- struct rppc_function_return {
- uint32_t fxn_id;
- uint32_t status;
- };
- /**
- * struct rppc_create_instance - rppc channel connector helper
- * @name: Name of the rppc server device to establish a connection with
- */
- struct rppc_create_instance {
- char name[RPPC_MAX_INST_NAMELEN];
- };
- /*
- * helper macros for manipulating the function index in the marshalled packet
- */
- #define RPPC_DESC_EXEC_SYNC (0x0100)
- #define RPPC_DESC_TYPE_MASK (0x0F00)
- /*
- * helper macros for manipulating the function index in the marshalled packet.
- * The remote functions are offset by one relative to the client
- * XXX: Remove the relative offset
- */
- #define RPPC_SET_FXN_IDX(idx) (((idx) + 1) | 0x80000000)
- #define RPPC_FXN_MASK(idx) (((idx) - 1) & 0x7FFFFFFF)
- /**
- * struct rppc_packet - the actual marshalled packet
- * @desc: type of function execution, currently only synchronous function
- * invocations are supported
- * @msg_id: an incremental message index identifier
- * @flags: a combination of job id and pool id of the worker threads
- * of the server
- * @fxn_id: id of the function to execute
- * @result: result of the remotely executed function
- * @data_size: size of the payload packet
- * @data: variable payload, containing the marshalled function data.
- *
- * This is actually a condensed structure of the Remote Command Messaging
- * (RCM) structure. The initial fields of the structure are used by the
- * remote-side server to schedule the execution of the function. The actual
- * variable payload data starts from the .data field. This marshalled packet
- * is the payload for a rpmsg message.
- *
- * XXX: remove or mask unneeded fields, some fields can be stripped down
- */
- struct rppc_packet {
- uint16_t desc;
- uint16_t msg_id;
- uint32_t flags;
- uint32_t fxn_id;
- int32_t result;
- uint32_t data_size;
- uint8_t data[0];
- } __packed;
- #endif /* _UAPI_LINUX_RPMSG_RPC_H_ */
|