µ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-2023 Liviu Ionescu. All rights reserved.
5
*
6
* Permission to use, copy, modify, and/or distribute this software
7
* for any purpose is hereby granted, under the terms of the MIT license.
8
*
9
* If a copy of the license was not distributed with this file, it can
10
* be obtained from https://opensource.org/licenses/mit/.
11
*/
12
13
#ifndef POSIX_SYS_IOCTL_H_
14
#define POSIX_SYS_IOCTL_H_
15
16
// ----------------------------------------------------------------------------
17
18
// Avoid warnings for _IOC* definitions.
19
#pragma GCC system_header
20
21
/*
22
* From: 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) | \
74
((type) << _IOC_TYPESHIFT) | \
75
((nr) << _IOC_NRSHIFT) | \
76
((size) << _IOC_SIZESHIFT))
77
78
#ifndef __KERNEL__
79
#define _IOC_TYPECHECK(t) (sizeof(t))
80
#endif
81
82
// ----------------------------------------------------------------------------
83
84
/*
85
* From: https://github.com/torvalds/linux/blob/master/include/uapi/linux/fs.h
86
*
87
* Used to create numbers.
88
*
89
* NOTE: _IOW means userland is writing and kernel is reading. _IOR
90
* means userland is reading and kernel is writing.
91
*/
92
#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0)
93
#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),(_IOC_TYPECHECK(size)))
94
#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size)))
95
#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size)))
96
97
/* 108-111 have been used for various private purposes. */
98
99
#define BLKSSZGET _IO(0x12,104)
/* get block logical device sector size */
100
#define BLKGETSIZE64 _IOR(0x12,114,size_t)
/* get device size in bytes (u64 *arg) */
101
#define BLKPBSZGET _IO(0x12,123)
/* get block physical device sector size */
102
103
// ----------------------------------------------------------------------------
104
105
#endif
/* POSIX_SYS_IOCTL_H_ */
106
include
cmsis-plus
posix
sys
ioctl.h
Generated by
1.9.7