/*-1* Copyright (c) 2014-2022 Hans Petter Selasky. All rights reserved.2*3* Redistribution and use in source and binary forms, with or without4* modification, are permitted provided that the following conditions5* are met:6* 1. Redistributions of source code must retain the above copyright7* notice, this list of conditions and the following disclaimer.8* 2. Redistributions in binary form must reproduce the above copyright9* notice, this list of conditions and the following disclaimer in the10* documentation and/or other materials provided with the distribution.11*12* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND13* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE14* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE15* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE16* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL17* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS18* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)19* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT20* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY21* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF22* SUCH DAMAGE.23*/2425#ifndef _CUSE_IOCTL_H_26#define _CUSE_IOCTL_H_2728#include <sys/ioccom.h>29#include <sys/types.h>3031#define CUSE_BUFFER_MAX (1 << 12) /* bytes */32#define CUSE_DEVICES_MAX 64 /* units */33#define CUSE_BUF_MIN_PTR 0x10000UL34#define CUSE_BUF_MAX_PTR 0x20000UL35#define CUSE_ALLOC_UNIT_MAX 128UL /* units */36#define CUSE_ALLOC_UNIT_SHIFT 24 /* bits */37/* All memory allocations must be less than the following limit */38#define CUSE_ALLOC_BYTES_MAX \39(CUSE_ALLOC_UNIT_MAX << CUSE_ALLOC_UNIT_SHIFT) /* bytes */4041struct cuse_dev;4243struct cuse_data_chunk {44uintptr_t local_ptr;45uintptr_t peer_ptr;46unsigned long length;47};4849struct cuse_alloc_info {50unsigned long page_count;51unsigned long alloc_nr;52};5354struct cuse_command {55struct cuse_dev *dev;56unsigned long fflags;57uintptr_t per_file_handle;58uintptr_t data_pointer;59unsigned long argument;60unsigned long command; /* see CUSE_CMD_XXX */61};6263struct cuse_create_dev {64struct cuse_dev *dev;65uid_t user_id;66gid_t group_id;67int permissions;68char devname[80]; /* /dev/xxxxx */69};7071/* Definition of internal IOCTLs for /dev/cuse */7273#define CUSE_IOCTL_GET_COMMAND _IOR('C', 0, struct cuse_command)74#define CUSE_IOCTL_WRITE_DATA _IOW('C', 1, struct cuse_data_chunk)75#define CUSE_IOCTL_READ_DATA _IOW('C', 2, struct cuse_data_chunk)76#define CUSE_IOCTL_SYNC_COMMAND _IOW('C', 3, int)77#define CUSE_IOCTL_GET_SIG _IOR('C', 4, int)78#define CUSE_IOCTL_ALLOC_MEMORY _IOW('C', 5, struct cuse_alloc_info)79#define CUSE_IOCTL_FREE_MEMORY _IOW('C', 6, struct cuse_alloc_info)80#define CUSE_IOCTL_SET_PFH _IOW('C', 7, uintptr_t)81#define CUSE_IOCTL_CREATE_DEV _IOW('C', 8, struct cuse_create_dev)82#define CUSE_IOCTL_DESTROY_DEV _IOW('C', 9, struct cuse_dev *)83#define CUSE_IOCTL_ALLOC_UNIT _IOR('C',10, int)84#define CUSE_IOCTL_FREE_UNIT _IOW('C',11, int)85#define CUSE_IOCTL_SELWAKEUP _IOW('C',12, int)86#define CUSE_IOCTL_ALLOC_UNIT_BY_ID _IOWR('C',13, int)87#define CUSE_IOCTL_FREE_UNIT_BY_ID _IOWR('C',14, int)8889#endif /* _CUSE_IOCTL_H_ */909192