µOS++ IIIe Reference
7.0.0
The third edition of µOS++, a POSIX inspired open source framework, written in C++
Loading...
Searching...
No Matches
ioctl.h
Go to the documentation of this file.
1
/*
2
* This file is part of the µOS++ distribution.
3
* (https://github.com/micro-os-plus)
4
* Copyright (c) 2018 Liviu Ionescu.
5
*
6
* Permission is hereby granted, free of charge, to any person
7
* obtaining a copy of this software and associated documentation
8
* files (the "Software"), to deal in the Software without
9
* restriction, including without limitation the rights to use,
10
* copy, modify, merge, publish, distribute, sublicense, and/or
11
* sell copies of the Software, and to permit persons to whom
12
* the Software is furnished to do so, subject to the following
13
* conditions:
14
*
15
* The above copyright notice and this permission notice shall be
16
* included in all copies or substantial portions of the Software.
17
*
18
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25
* OTHER DEALINGS IN THE SOFTWARE.
26
*/
27
28
#ifndef POSIX_SYS_IOCTL_H_
29
#define POSIX_SYS_IOCTL_H_
30
31
// ----------------------------------------------------------------------------
32
33
// Avoid warnings for _IOC* definitions.
34
#pragma GCC system_header
35
36
/*
37
* From: https://github.com/torvalds/linux/blob/master/include/uapi/asm-generic/ioctl.h
38
*
39
* The following is for compatibility across the various Linux
40
* platforms. The generic ioctl numbering scheme doesn't really enforce
41
* a type field. De facto, however, the top 8 bits of the lower 16
42
* bits are indeed used as a type field, so we might just as well make
43
* this explicit here. Please be sure to use the decoding macros
44
* below from now on.
45
*/
46
#define _IOC_NRBITS 8
47
#define _IOC_TYPEBITS 8
48
49
#ifndef _IOC_SIZEBITS
50
# define _IOC_SIZEBITS 14
51
#endif
52
53
#ifndef _IOC_DIRBITS
54
# define _IOC_DIRBITS 2
55
#endif
56
57
#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1)
58
#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1)
59
#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1)
60
#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1)
61
62
#define _IOC_NRSHIFT 0
63
#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS)
64
#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS)
65
#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS)
66
67
/*
68
* Direction bits, which any architecture can choose to override
69
* before including this file.
70
*
71
* NOTE: _IOC_WRITE means userland is writing and kernel is
72
* reading. _IOC_READ means userland is reading and kernel is writing.
73
*/
74
75
#ifndef _IOC_NONE
76
# define _IOC_NONE 0U
77
#endif
78
79
#ifndef _IOC_WRITE
80
# define _IOC_WRITE 1U
81
#endif
82
83
#ifndef _IOC_READ
84
# define _IOC_READ 2U
85
#endif
86
87
#define _IOC(dir,type,nr,size) \
88
(((dir) << _IOC_DIRSHIFT) | \
89
((type) << _IOC_TYPESHIFT) | \
90
((nr) << _IOC_NRSHIFT) | \
91
((size) << _IOC_SIZESHIFT))
92
93
#ifndef __KERNEL__
94
#define _IOC_TYPECHECK(t) (sizeof(t))
95
#endif
96
97
// ----------------------------------------------------------------------------
98
99
/*
100
* From: https://github.com/torvalds/linux/blob/master/include/uapi/linux/fs.h
101
*
102
* Used to create numbers.
103
*
104
* NOTE: _IOW means userland is writing and kernel is reading. _IOR
105
* means userland is reading and kernel is writing.
106
*/
107
#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0)
108
#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),(_IOC_TYPECHECK(size)))
109
#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size)))
110
#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size)))
111
112
/* 108-111 have been used for various private purposes. */
113
114
#define BLKSSZGET _IO(0x12,104)
/* get block logical device sector size */
115
#define BLKGETSIZE64 _IOR(0x12,114,size_t)
/* get device size in bytes (u64 *arg) */
116
#define BLKPBSZGET _IO(0x12,123)
/* get block physical device sector size */
117
118
// ----------------------------------------------------------------------------
119
120
#endif
/* POSIX_SYS_IOCTL_H_ */
121
include
cmsis-plus
posix
sys
ioctl.h
Generated by
1.9.7