PageRenderTime 32ms CodeModel.GetById 21ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/packages/libc/src/kernelioctl.pp

https://github.com/slibre/freepascal
Puppet | 196 lines | 160 code | 36 blank | 0 comment | 0 complexity | 91c6a81990f8cb5d35a83310d93988c4 MD5 | raw file
Possible License(s): LGPL-2.0, LGPL-2.1, LGPL-3.0
  1{$mode objfpc}
  2{$h+}
  3
  4{$if not defined(linux) or not defined(cpui386)}
  5  {$error The KernelIoctl unit is a legacy Kylix-compatibility unit that is only supported on Linux/i386. It is known not to work in various ways on other OSes and architectures (including Linux/x86_64). }
  6{$endif}
  7
  8Unit kernelioctl;
  9
 10Interface
 11
 12const
 13   _IOC_NRBITS = 8;
 14   _IOC_TYPEBITS = 8;
 15   _IOC_SIZEBITS = 14;
 16   _IOC_DIRBITS = 2;
 17   _IOC_NRMASK = (1 shl _IOC_NRBITS) - 1;
 18   _IOC_TYPEMASK = (1 shl _IOC_TYPEBITS) - 1;
 19   _IOC_SIZEMASK = (1 shl _IOC_SIZEBITS) - 1;
 20   _IOC_DIRMASK = (1 shl _IOC_DIRBITS) - 1;
 21   _IOC_NRSHIFT = 0;
 22   _IOC_TYPESHIFT = _IOC_NRSHIFT + _IOC_NRBITS;
 23   _IOC_SIZESHIFT = _IOC_TYPESHIFT + _IOC_TYPEBITS;
 24   _IOC_DIRSHIFT = _IOC_SIZESHIFT + _IOC_SIZEBITS;
 25   _IOC_NONE = 0;
 26   _IOC_WRITE = 1;
 27   _IOC_READ = 2;
 28
 29Function _IOC(dir, __type, nr, size: cardinal): cardinal;
 30Function _IOR(_type,nr,size : cardinal) : cardinal;
 31Function _IOW(_type,nr,size : cardinal) : cardinal;
 32Function _IOWR(_type,nr,size : cardinal) : cardinal;
 33Function _IOC_DIR(nr : cardinal) : cardinal;
 34Function _IOC_TYPE(nr : cardinal) : cardinal;
 35Function _IOC_NR(nr : cardinal) : cardinal;
 36Function _IOC_SIZE(nr : cardinal) : cardinal;
 37Function _IO(__type, nr: Cardinal): cardinal;
 38
 39
 40const
 41  IOC_IN = _IOC_WRITE shl _IOC_DIRSHIFT;
 42  IOC_OUT = _IOC_READ shl _IOC_DIRSHIFT;
 43  IOC_INOUT = (_IOC_WRITE or _IOC_READ) shl _IOC_DIRSHIFT;
 44  IOCSIZE_MASK = _IOC_SIZEMASK shl _IOC_SIZESHIFT;
 45  IOCSIZE_SHIFT = _IOC_SIZESHIFT;
 46
 47const
 48   TCGETS = $5401;
 49   TCSETS = $5402;
 50   TCSETSW = $5403;
 51   TCSETSF = $5404;
 52   TCGETA = $5405;
 53   TCSETA = $5406;
 54   TCSETAW = $5407;
 55   TCSETAF = $5408;
 56   TCSBRK = $5409;
 57   TCXONC = $540A;
 58   TCFLSH = $540B;
 59   TIOCEXCL = $540C;
 60   TIOCNXCL = $540D;
 61   TIOCSCTTY = $540E;
 62   TIOCGPGRP = $540F;
 63   TIOCSPGRP = $5410;
 64   TIOCOUTQ = $5411;
 65   TIOCSTI = $5412;
 66   TIOCGWINSZ = $5413;
 67   TIOCSWINSZ = $5414;
 68   TIOCMGET = $5415;
 69   TIOCMBIS = $5416;
 70   TIOCMBIC = $5417;
 71   TIOCMSET = $5418;
 72   TIOCGSOFTCAR = $5419;
 73   TIOCSSOFTCAR = $541A;
 74   FIONREAD = $541B;
 75   TIOCINQ = FIONREAD;
 76   TIOCLINUX = $541C;
 77   TIOCCONS = $541D;
 78   TIOCGSERIAL = $541E;
 79   TIOCSSERIAL = $541F;
 80   TIOCPKT = $5420;
 81   FIONBIO = $5421;
 82   TIOCNOTTY = $5422;
 83   TIOCSETD = $5423;
 84   TIOCGETD = $5424;
 85   TCSBRKP = $5425;
 86   TIOCTTYGSTRUCT = $5426;
 87   TIOCSBRK = $5427;
 88   TIOCCBRK = $5428;
 89   TIOCGSID = $5429;
 90
 91Function TIOCGPTN : Cardinal;
 92Function TIOCSPTLCK : Cardinal;
 93Function TIOCGDEV : Cardinal;
 94
 95const
 96   FIONCLEX = $5450;
 97   FIOCLEX = $5451;
 98   FIOASYNC = $5452;
 99   TIOCSERCONFIG = $5453;
100   TIOCSERGWILD = $5454;
101   TIOCSERSWILD = $5455;
102   TIOCGLCKTRMIOS = $5456;
103   TIOCSLCKTRMIOS = $5457;
104   TIOCSERGSTRUCT = $5458;
105   TIOCSERGETLSR = $5459;
106   TIOCSERGETMULTI = $545A;
107   TIOCSERSETMULTI = $545B;
108   TIOCMIWAIT = $545C;
109   TIOCGICOUNT = $545D;
110   TIOCGHAYESESP = $545E;
111   TIOCSHAYESESP = $545F;
112   TIOCPKT_DATA = 0;
113   TIOCPKT_FLUSHREAD = 1;
114   TIOCPKT_FLUSHWRITE = 2;
115   TIOCPKT_STOP = 4;
116   TIOCPKT_START = 8;
117   TIOCPKT_NOSTOP = 16;
118   TIOCPKT_DOSTOP = 32;
119   TIOCSER_TEMT = $01;
120
121Implementation
122
123Function _IOC(dir, __type, nr, size: cardinal): cardinal;
124
125begin
126  Result:=(dir shl _IOC_DIRSHIFT) or (__type shl _IOC_TYPESHIFT) or
127          (nr shl _IOC_NRSHIFT) or (size shl _IOC_SIZESHIFT);
128end;
129
130
131Function _IO(__type, nr: Cardinal): cardinal;
132begin
133  Result := _IOC(_IOC_NONE,__type,nr,0);
134end;
135
136
137Function _IOR(_type,nr,size : cardinal) : cardinal;
138begin
139   _IOR:=_IOC(_IOC_READ,_type,nr,size);
140end;
141
142
143Function _IOW(_type,nr,size : cardinal) : cardinal;
144begin
145   _IOW:=_IOC(_IOC_WRITE,_type,nr,size);
146end;
147
148
149Function _IOWR(_type,nr,size : cardinal) : cardinal;
150begin
151   _IOWR:=_IOC(_IOC_READ or _IOC_WRITE,_type,nr,size);
152end;
153
154
155Function _IOC_DIR(nr : cardinal) : cardinal;
156begin
157   _IOC_DIR:=(nr shr _IOC_DIRSHIFT) and _IOC_DIRMASK;
158end;
159
160
161Function _IOC_TYPE(nr : cardinal) : cardinal;
162begin
163   _IOC_TYPE:=(nr shr _IOC_TYPESHIFT) and _IOC_TYPEMASK;
164end;
165
166
167Function _IOC_NR(nr : cardinal) : cardinal;
168begin
169   _IOC_NR:=(nr shr _IOC_NRSHIFT) and _IOC_NRMASK;
170end;
171
172
173Function _IOC_SIZE(nr : cardinal) : cardinal;
174begin
175   _IOC_SIZE:=(nr shr _IOC_SIZESHIFT) and _IOC_SIZEMASK;
176end;
177
178
179Function TIOCGPTN : cardinal;
180begin
181   TIOCGPTN:=_IOR(ord('T'),$30,4);
182end;
183
184Function TIOCSPTLCK : cardinal;
185
186begin
187   TIOCSPTLCK:=_IOW(ord('T'),$31,4);
188end;
189
190Function TIOCGDEV : cardinal;
191
192begin
193   TIOCGDEV:=_IOR(ord('T'),$32,4);
194end;
195
196end.