interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / vendor / libc / src / unix / linux_like / l4re / mod.rs

204 lines · 7178 bytes Raw Blame History
1///! L4Re specifics
2///! This module contains definitions required by various L4Re libc backends.
3///! Some of them are formally not part of the libc, but are a dependency of the
4///! libc and hence we should provide them here.
5use crate::prelude::*;
6
7pub type l4_umword_t = c_ulong; // Unsigned machine word.
8pub type pthread_t = *mut c_void;
9
10pub type dev_t = u64;
11pub type socklen_t = u32;
12pub type mode_t = u32;
13pub type ino64_t = u64;
14pub type off64_t = i64;
15pub type blkcnt64_t = i64;
16pub type rlim64_t = u64;
17pub type nfds_t = c_ulong;
18pub type nl_item = c_int;
19pub type idtype_t = c_uint;
20pub type loff_t = c_longlong;
21pub type pthread_key_t = c_uint;
22pub type pthread_once_t = c_int;
23pub type pthread_spinlock_t = c_int;
24
25s! {
26 /// CPU sets.
27 pub struct l4_sched_cpu_set_t {
28 // from the L4Re docs
29 /// Combination of granularity and offset.
30 ///
31 /// The granularity defines how many CPUs each bit in map describes.
32 /// The offset is the number of the first CPU described by the first
33 /// bit in the bitmap.
34 /// offset must be a multiple of 2^graularity.
35 ///
36 /// | MSB | LSB |
37 /// | ---------------- | ------------------- |
38 /// | 8bit granularity | 24bit offset .. |
39 gran_offset: l4_umword_t,
40 /// Bitmap of CPUs.
41 map: l4_umword_t,
42 }
43
44 pub struct pthread_attr_t {
45 __detachstate: c_int,
46 __schedpolicy: c_int,
47 __schedparam: super::__sched_param,
48 __inheritsched: c_int,
49 __scope: c_int,
50 __guardsize: size_t,
51 __stackaddr_set: c_int,
52 __stackaddr: *mut c_void, // better don't use it
53 __stacksize: size_t,
54 // L4Re specifics
55 pub affinity: l4_sched_cpu_set_t,
56 pub create_flags: c_uint,
57 }
58}
59
60// L4Re requires a min stack size of 64k; that isn't defined in uClibc, but
61// somewhere in the core libraries. uClibc wants 16k, but that's not enough.
62pub const PTHREAD_STACK_MIN: usize = 65536;
63
64pub const BOTHER: crate::speed_t = 0o010000;
65
66pub const RLIMIT_CPU: crate::__rlimit_resource_t = 0;
67pub const RLIMIT_FSIZE: crate::__rlimit_resource_t = 1;
68pub const RLIMIT_DATA: crate::__rlimit_resource_t = 2;
69pub const RLIMIT_STACK: crate::__rlimit_resource_t = 3;
70pub const RLIMIT_CORE: crate::__rlimit_resource_t = 4;
71pub const RLIMIT_RSS: crate::__rlimit_resource_t = 5;
72pub const RLIMIT_NPROC: crate::__rlimit_resource_t = 6;
73pub const RLIMIT_NOFILE: crate::__rlimit_resource_t = 7;
74pub const RLIMIT_MEMLOCK: crate::__rlimit_resource_t = 8;
75pub const RLIMIT_AS: crate::__rlimit_resource_t = 9;
76pub const RLIMIT_LOCKS: crate::__rlimit_resource_t = 10;
77pub const RLIMIT_SIGPENDING: crate::__rlimit_resource_t = 11;
78pub const RLIMIT_MSGQUEUE: crate::__rlimit_resource_t = 12;
79pub const RLIMIT_NICE: crate::__rlimit_resource_t = 13;
80pub const RLIMIT_RTPRIO: crate::__rlimit_resource_t = 14;
81pub const RLIMIT_RTTIME: crate::__rlimit_resource_t = 15;
82pub const RLIMIT_NLIMITS: crate::__rlimit_resource_t = RLIM_NLIMITS;
83pub const RLIM_NLIMITS: crate::__rlimit_resource_t = 16;
84
85pub const SOL_SOCKET: c_int = 1;
86
87// pub const SO_DEBUG: c_int = 1;
88pub const SO_REUSEADDR: c_int = 2;
89pub const SO_TYPE: c_int = 3;
90pub const SO_ERROR: c_int = 4;
91pub const SO_DONTROUTE: c_int = 5;
92pub const SO_BROADCAST: c_int = 6;
93pub const SO_SNDBUF: c_int = 7;
94pub const SO_RCVBUF: c_int = 8;
95pub const SO_KEEPALIVE: c_int = 9;
96pub const SO_OOBINLINE: c_int = 10;
97pub const SO_NO_CHECK: c_int = 11;
98pub const SO_PRIORITY: c_int = 12;
99pub const SO_LINGER: c_int = 13;
100pub const SO_BSDCOMPAT: c_int = 14;
101pub const SO_PASSCRED: c_int = 16;
102pub const SO_PEERCRED: c_int = 17;
103pub const SO_RCVLOWAT: c_int = 18;
104pub const SO_SNDLOWAT: c_int = 19;
105pub const SO_RCVTIMEO: c_int = 20;
106pub const SO_SNDTIMEO: c_int = 21;
107pub const SO_SECURITY_AUTHENTICATION: c_int = 22;
108pub const SO_SECURITY_ENCRYPTION_TRANSPORT: c_int = 23;
109pub const SO_SECURITY_ENCRYPTION_NETWORK: c_int = 24;
110pub const SO_BINDTODEVICE: c_int = 25;
111pub const SO_ATTACH_FILTER: c_int = 26;
112pub const SO_DETACH_FILTER: c_int = 27;
113pub const SO_PEERNAME: c_int = 28;
114
115pub const SO_ACCEPTCONN: c_int = 30;
116pub const SO_PEERSEC: c_int = 31;
117
118pub const TCGETS: Ioctl = 0x5401;
119pub const TCSETS: Ioctl = 0x5402;
120pub const TCSETSW: Ioctl = 0x5403;
121pub const TCSETSF: Ioctl = 0x5404;
122pub const TCGETA: Ioctl = 0x5405;
123pub const TCSETA: Ioctl = 0x5406;
124pub const TCSETAW: Ioctl = 0x5407;
125pub const TCSETAF: Ioctl = 0x5408;
126pub const TCSBRK: Ioctl = 0x5409;
127pub const TCXONC: Ioctl = 0x540A;
128pub const TCFLSH: Ioctl = 0x540B;
129pub const TIOCM_LE: c_int = 0x001;
130pub const TIOCM_DTR: c_int = 0x002;
131pub const TIOCM_RTS: c_int = 0x004;
132pub const TIOCM_ST: c_int = 0x008;
133pub const TIOCM_SR: c_int = 0x010;
134pub const TIOCM_CTS: c_int = 0x020;
135pub const TIOCM_CAR: c_int = 0x040;
136pub const TIOCM_CD: c_int = TIOCM_CAR;
137pub const TIOCM_RNG: c_int = 0x080;
138pub const TIOCM_RI: c_int = TIOCM_RNG;
139pub const TIOCM_DSR: c_int = 0x100;
140pub const TIOCEXCL: Ioctl = 0x540C;
141pub const TIOCNXCL: Ioctl = 0x540D;
142pub const TIOCSCTTY: Ioctl = 0x540E;
143pub const TIOCGPGRP: Ioctl = 0x540F;
144pub const TIOCSPGRP: Ioctl = 0x5410;
145pub const TIOCOUTQ: Ioctl = 0x5411;
146pub const TIOCSTI: Ioctl = 0x5412;
147pub const TIOCGWINSZ: Ioctl = 0x5413;
148pub const TIOCSWINSZ: Ioctl = 0x5414;
149pub const TIOCMGET: Ioctl = 0x5415;
150pub const TIOCMBIS: Ioctl = 0x5416;
151pub const TIOCMBIC: Ioctl = 0x5417;
152pub const TIOCMSET: Ioctl = 0x5418;
153pub const TIOCGSOFTCAR: Ioctl = 0x5419;
154pub const TIOCSSOFTCAR: Ioctl = 0x541A;
155pub const FIONREAD: Ioctl = 0x541B;
156pub const TIOCINQ: Ioctl = FIONREAD;
157pub const TIOCLINUX: Ioctl = 0x541C;
158pub const TIOCCONS: Ioctl = 0x541D;
159pub const TIOCGSERIAL: Ioctl = 0x541E;
160pub const TIOCSSERIAL: Ioctl = 0x541F;
161pub const TIOCPKT: Ioctl = 0x5420;
162pub const FIONBIO: Ioctl = 0x5421;
163pub const TIOCNOTTY: Ioctl = 0x5422;
164pub const TIOCSETD: Ioctl = 0x5423;
165pub const TIOCGETD: Ioctl = 0x5424;
166pub const TCSBRKP: Ioctl = 0x5425;
167pub const TIOCSBRK: Ioctl = 0x5427;
168pub const TIOCCBRK: Ioctl = 0x5428;
169pub const TIOCGSID: Ioctl = 0x5429;
170pub const TIOCGPTN: Ioctl = 0x80045430;
171pub const TIOCSPTLCK: Ioctl = 0x40045431;
172pub const FIONCLEX: Ioctl = 0x5450;
173pub const FIOCLEX: Ioctl = 0x5451;
174pub const FIOASYNC: Ioctl = 0x5452;
175pub const TIOCSERCONFIG: Ioctl = 0x5453;
176pub const TIOCSERGWILD: Ioctl = 0x5454;
177pub const TIOCSERSWILD: Ioctl = 0x5455;
178pub const TIOCGLCKTRMIOS: Ioctl = 0x5456;
179pub const TIOCSLCKTRMIOS: Ioctl = 0x5457;
180pub const TIOCSERGSTRUCT: Ioctl = 0x5458;
181pub const TIOCSERGETLSR: Ioctl = 0x5459;
182pub const TIOCSERGETMULTI: Ioctl = 0x545A;
183pub const TIOCSERSETMULTI: Ioctl = 0x545B;
184pub const TIOCMIWAIT: Ioctl = 0x545C;
185pub const TIOCGICOUNT: Ioctl = 0x545D;
186
187pub const BLKSSZGET: Ioctl = 0x1268;
188
189cfg_if! {
190 if #[cfg(not(target_env = "uclibc"))] {
191 pub const NLMSG_NOOP: c_int = 0x1;
192 pub const NLMSG_ERROR: c_int = 0x2;
193 pub const NLMSG_DONE: c_int = 0x3;
194 pub const NLMSG_OVERRUN: c_int = 0x4;
195 pub const NLMSG_MIN_TYPE: c_int = 0x10;
196 }
197}
198
199cfg_if! {
200 if #[cfg(target_env = "uclibc")] {
201 mod uclibc;
202 pub use self::uclibc::*;
203 }
204}