Skip to content

Commit 4236b4c

Browse files
committed
Update ioctl.jl
1 parent 836680e commit 4236b4c

File tree

1 file changed

+126
-28
lines changed

1 file changed

+126
-28
lines changed

src/ioctl.jl

Lines changed: 126 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,131 @@
11
module IOCTL
22

3-
const TIOCGETP = Sys.islinux() ? 0 : 1074164744 # Get parameters -- V6/V7 gtty()
4-
const TIOCSETP = Sys.islinux() ? 1 : -2147060727 # Set parameters -- V6/V7 stty()
5-
6-
const TIOCSETN = 2 # V7: as above, but no flushtty
7-
const TIOCEXCL = 3 # V7: set exclusive use of tty
8-
const TIOCNXCL = 4 # V7: reset excl. use of tty
9-
const TIOCHPCL = 5 # V7: hang up on last close
10-
const TIOCFLUSH = 6 # V7: flush buffers
11-
12-
const TIOCSTI = 7 # simulate terminal input
13-
const TIOCSBRK = 8 # set break bit
14-
const TIOCCBRK = 9 # clear break bit
15-
const TIOCSDTR = 10 # set data terminal ready
16-
const TIOCCDTR = 11 # clear data terminal ready
17-
const TIOCGPGRP = 12 # get pgrp of tty
18-
const TIOCSPGRP = 13 # set pgrp of tty
3+
4+
if Sys.islinux()
5+
# Most generic definitions for ioctl for Linux
6+
# https://github.com/torvalds/linux/blob/b6839ef26e549de68c10359d45163b0cfb031183/tools/include/uapi/asm-generic/ioctls.h
7+
8+
const TCGETS = 0x5401
9+
const TCSETS = 0x5402
10+
const TCSETSW = 0x5403
11+
const TCSETSF = 0x5404
12+
const TCGETA = 0x5405
13+
const TCSETA = 0x5406
14+
const TCSETAW = 0x5407
15+
const TCSETAF = 0x5408
16+
const TCSBRK = 0x5409
17+
const TCXONC = 0x540A
18+
const TCFLSH = 0x540B
19+
const TIOCEXCL = 0x540C
20+
const TIOCNXCL = 0x540D
21+
const TIOCSCTTY = 0x540E
22+
const TIOCGPGRP = 0x540F
23+
const TIOCSPGRP = 0x5410
24+
const TIOCOUTQ = 0x5411
25+
const TIOCSTI = 0x5412
26+
const TIOCGWINSZ = 0x5413
27+
const TIOCSWINSZ = 0x5414
28+
const TIOCMGET = 0x5415
29+
const TIOCMBIS = 0x5416
30+
const TIOCMBIC = 0x5417
31+
const TIOCMSET = 0x5418
32+
const TIOCGSOFTCAR = 0x5419
33+
const TIOCSSOFTCAR = 0x541A
34+
const FIONREAD = 0x541B
35+
const TIOCINQ = FIONREAD
36+
const TIOCLINUX = 0x541C
37+
const TIOCCONS = 0x541D
38+
const TIOCGSERIAL = 0x541E
39+
const TIOCSSERIAL = 0x541F
40+
const TIOCPKT = 0x5420
41+
const FIONBIO = 0x5421
42+
const TIOCNOTTY = 0x5422
43+
const TIOCSETD = 0x5423
44+
const TIOCGETD = 0x5424
45+
const TCSBRKP = 0x5425 # /* Needed for POSIX tcsendbreak() */
46+
const TIOCSBRK = 0x5427 # /* BSD compatibility */
47+
const TIOCCBRK = 0x5428 # /* BSD compatibility */
48+
const TIOCGSID = 0x5429 # /* Return the session ID of FD */
49+
const TIOCGRS485 = 0x542E
50+
const TIOCSRS485 = 0x542F
51+
const TIOCGPTN = 0 # TODO # /* Get Pty Number (of pty-mux device) */
52+
const TIOCSPTLCK = 0 # TODO # /* Lock/unlock Pty */
53+
const TIOCGDEV = 0 # TODO # /* Get primary device node of /dev/console */
54+
const TCGETX = 0x5432 # /* SYS5 TCGETX compatibility */
55+
const TCSETX = 0x5433
56+
const TCSETXF = 0x5434
57+
const TCSETXW = 0x5435
58+
const TIOCSIG = 0 # TODO # /* pty: generate signal */
59+
const TIOCVHANGUP = 0x5437
60+
const TIOCGPKT = 0 # TODO # /* Get packet mode state */
61+
const TIOCGPTLCK = 0 # TODO # /* Get Pty lock state */
62+
const TIOCGEXCL = 0 # TODO # /* Get exclusive mode state */
63+
const TIOCGPTPEER = 0 # TODO # /* Safely open the slave */
64+
const TIOCGISO7816 = 0 # TODO
65+
const TIOCSISO7816 = 0 # TODO
66+
67+
const FIONCLEX = 0x5450
68+
const FIOCLEX = 0x5451
69+
const FIOASYNC = 0x5452
70+
const TIOCSERCONFIG = 0x5453
71+
const TIOCSERGWILD = 0x5454
72+
const TIOCSERSWILD = 0x5455
73+
const TIOCGLCKTRMIOS = 0x5456
74+
const TIOCSLCKTRMIOS = 0x5457
75+
const TIOCSERGSTRUCT = 0x5458 # /* For debugging only */
76+
const TIOCSERGETLSR = 0x5459 # /* Get line status register */
77+
const TIOCSERGETMULTI = 0x545A # /* Get multiport config */
78+
const TIOCSERSETMULTI = 0x545B # /* Set multiport config */
79+
80+
const TIOCMIWAIT = 0x545C # /* wait for a change on serial input line(s) */
81+
const TIOCGICOUNT = 0x545D # /* read serial port inline interrupt counts */
82+
const TIOCPKT_DATA = 0
83+
const TIOCPKT_FLUSHREAD = 1
84+
const TIOCPKT_FLUSHWRITE = 2
85+
const TIOCPKT_STOP = 4
86+
const TIOCPKT_START = 8
87+
const TIOCPKT_NOSTOP = 16
88+
const TIOCPKT_DOSTOP = 32
89+
const TIOCPKT_IOCTL = 64
90+
91+
const TIOCSER_TEMT = 0x01 # /* Transmitter physically empty */
92+
93+
else
94+
95+
# MACOS
96+
const TIOCGETP = Sys.islinux() ? 0 : 1074164744 # Get parameters -- V6/V7 gtty()
97+
const TIOCSETP = Sys.islinux() ? 1 : -2147060727 # Set parameters -- V6/V7 stty()
98+
99+
const TIOCSETN = 2 # V7: as above, but no flushtty
100+
const TIOCEXCL = 3 # V7: set exclusive use of tty
101+
const TIOCNXCL = 4 # V7: reset excl. use of tty
102+
const TIOCHPCL = 5 # V7: hang up on last close
103+
const TIOCFLUSH = 6 # V7: flush buffers
104+
105+
const TIOCSTI = 7 # simulate terminal input
106+
const TIOCSBRK = 8 # set break bit
107+
const TIOCCBRK = 9 # clear break bit
108+
const TIOCSDTR = 10 # set data terminal ready
109+
const TIOCCDTR = 11 # clear data terminal ready
110+
const TIOCGPGRP = 12 # get pgrp of tty
111+
const TIOCSPGRP = 13 # set pgrp of tty
112+
113+
const TCGETP = 1076130901
114+
const TCGETA = 1075082331
115+
const TCSETAW = -2146143143
116+
117+
const FIONREAD = 22 # get # bytes to read
118+
119+
const TIOCGETD = 23 # Get line discipline
120+
const TIOCSETD = 24 # Set line discipline
121+
122+
const TIOCGWINSZ = 1074295912 # Get window size info
123+
const TIOCSWINSZ = 26 # Set window size info (maybe gen SIGWINCH)
124+
125+
end
126+
127+
# TODO: check that these values make sense
128+
19129
const TIOCGETC = Sys.islinux() ? 14 : 1074164754 # get special characters
20130
const TIOCSETC = Sys.islinux() ? 15 : -2147060719 # set special characters
21131
const TIOCLBIS = Sys.islinux() ? 16 : 0x8004747f # set bits in local mode word
@@ -25,18 +135,6 @@ const TIOCLSET = Sys.islinux() ? 19 : 0x8004747d # set local mode mask
25135
const TIOCSLTC = Sys.islinux() ? 20 : -2147060619 # set local special chars
26136
const TIOCGLTC = Sys.islinux() ? 21 : 1074164852 # get local special chars
27137

28-
const TCGETP = 1076130901
29-
const TCGETA = 1075082331
30-
const TCSETAW = -2146143143
31-
32-
const FIONREAD = 22 # get # bytes to read
33-
34-
const TIOCGETD = 23 # Get line discipline
35-
const TIOCSETD = 24 # Set line discipline
36-
37-
const TIOCGWINSZ = Sys.islinux() ? 25 : 1074295912 # Get window size info
38-
const TIOCSWINSZ = 26 # Set window size info (maybe gen SIGWINCH)
39-
40138
const ALLDELAY =0177400 # Delay algorithm selection
41139
const BSDELAY = 0100000 # Select backspace delays
42140
const BS0 = 0

0 commit comments

Comments
 (0)