µ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++ project (https://micro-os-plus.github.io/).
3
* Copyright (c) 2018-2025 Liviu Ionescu. All rights reserved.
4
*
5
* Permission to use, copy, modify, and/or distribute this software
6
* for any purpose is hereby granted, under the terms of the MIT license.
7
*
8
* If a copy of the license was not distributed with this file, it can
9
* be obtained from https://opensource.org/licenses/mit.
10
*/
11
12
#ifndef POSIX_SYS_IOCTL_H_
13
#define POSIX_SYS_IOCTL_H_
14
15
// ----------------------------------------------------------------------------
16
17
// Avoid warnings for _IOC* definitions.
18
#pragma GCC system_header
19
20
/*
21
* From:
22
* https://github.com/torvalds/linux/blob/master/include/uapi/asm-generic/ioctl.h
23
*
24
* The following is for compatibility across the various Linux
25
* platforms. The generic ioctl numbering scheme doesn't really enforce
26
* a type field. De facto, however, the top 8 bits of the lower 16
27
* bits are indeed used as a type field, so we might just as well make
28
* this explicit here. Please be sure to use the decoding macros
29
* below from now on.
30
*/
31
#define _IOC_NRBITS 8
32
#define _IOC_TYPEBITS 8
33
34
#ifndef _IOC_SIZEBITS
35
#define _IOC_SIZEBITS 14
36
#endif
37
38
#ifndef _IOC_DIRBITS
39
#define _IOC_DIRBITS 2
40
#endif
41
42
#define _IOC_NRMASK ((1 << _IOC_NRBITS) - 1)
43
#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS) - 1)
44
#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS) - 1)
45
#define _IOC_DIRMASK ((1 << _IOC_DIRBITS) - 1)
46
47
#define _IOC_NRSHIFT 0
48
#define _IOC_TYPESHIFT (_IOC_NRSHIFT + _IOC_NRBITS)
49
#define _IOC_SIZESHIFT (_IOC_TYPESHIFT + _IOC_TYPEBITS)
50
#define _IOC_DIRSHIFT (_IOC_SIZESHIFT + _IOC_SIZEBITS)
51
52
/*
53
* Direction bits, which any architecture can choose to override
54
* before including this file.
55
*
56
* NOTE: _IOC_WRITE means userland is writing and kernel is
57
* reading. _IOC_READ means userland is reading and kernel is writing.
58
*/
59
60
#ifndef _IOC_NONE
61
#define _IOC_NONE 0U
62
#endif
63
64
#ifndef _IOC_WRITE
65
#define _IOC_WRITE 1U
66
#endif
67
68
#ifndef _IOC_READ
69
#define _IOC_READ 2U
70
#endif
71
72
#define _IOC(dir, type, nr, size) \
73
(((dir) << _IOC_DIRSHIFT) | ((type) << _IOC_TYPESHIFT) \
74
| ((nr) << _IOC_NRSHIFT) | ((size) << _IOC_SIZESHIFT))
75
76
#ifndef __KERNEL__
77
#define _IOC_TYPECHECK(t) (sizeof (t))
78
#endif
79
80
// ----------------------------------------------------------------------------
81
82
/*
83
* From: https://github.com/torvalds/linux/blob/master/include/uapi/linux/fs.h
84
*
85
* Used to create numbers.
86
*
87
* NOTE: _IOW means userland is writing and kernel is reading. _IOR
88
* means userland is reading and kernel is writing.
89
*/
90
#define _IO(type, nr) _IOC (_IOC_NONE, (type), (nr), 0)
91
#define _IOR(type, nr, size) \
92
_IOC (_IOC_READ, (type), (nr), (_IOC_TYPECHECK (size)))
93
#define _IOW(type, nr, size) \
94
_IOC (_IOC_WRITE, (type), (nr), (_IOC_TYPECHECK (size)))
95
#define _IOWR(type, nr, size) \
96
_IOC (_IOC_READ | _IOC_WRITE, (type), (nr), (_IOC_TYPECHECK (size)))
97
98
/* 108-111 have been used for various private purposes. */
99
100
#define BLKSSZGET _IO (0x12, 104)
/* get block logical device sector size */
101
#define BLKGETSIZE64 \
102
_IOR (0x12, 114, size_t)
/* get device size in bytes (u64 *arg) */
103
#define BLKPBSZGET _IO (0x12, 123)
/* get block physical device sector size \
104
*/
105
106
// ----------------------------------------------------------------------------
107
108
#endif
/* POSIX_SYS_IOCTL_H_ */
include
cmsis-plus
posix
sys
ioctl.h
Generated by
1.9.7