xref: /DragonOS/kernel/src/process/abi.rs (revision f9fe30be89e89499aad4ef52b4648986bef5a7d8)
1 /// An enumeration of the possible values for the `AT_*` constants.
2 #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3 pub enum AtType {
4     /// End of vector.
5     Null,
6     /// Entry should be ignored.
7     Ignore,
8     /// File descriptor of program.
9     ExecFd,
10     /// Program headers for program.
11     Phdr,
12     /// Size of program header entry.
13     PhEnt,
14     /// Number of program headers.
15     PhNum,
16     /// System page size.
17     PageSize,
18     /// Base address of interpreter.
19     Base,
20     /// Flags.
21     Flags,
22     /// Entry point of program.
23     Entry,
24     /// Program is not ELF.
25     NotElf,
26     /// Real uid.
27     Uid,
28     /// Effective uid.
29     EUid,
30     /// Real gid.
31     Gid,
32     /// Effective gid.
33     EGid,
34     /// String identifying CPU for optimizations.
35     Platform,
36     /// Arch dependent hints at CPU capabilities.
37     HwCap,
38     /// Frequency at which times() increments.
39     ClkTck,
40     /// Secure mode boolean.
41     Secure,
42     /// String identifying real platform, may differ from AT_PLATFORM.
43     BasePlatform,
44     /// Address of 16 random bytes.
45     Random,
46     /// Extension of AT_HWCAP.
47     HwCap2,
48     /// Filename of program.
49     ExecFn,
50     /// Minimal stack size for signal delivery.
51     MinSigStackSize,
52 }
53 
54 impl TryFrom<u32> for AtType {
55     type Error = &'static str;
56 
57     fn try_from(value: u32) -> Result<Self, Self::Error> {
58         match value {
59             0 => Ok(AtType::Null),
60             1 => Ok(AtType::Ignore),
61             2 => Ok(AtType::ExecFd),
62             3 => Ok(AtType::Phdr),
63             4 => Ok(AtType::PhEnt),
64             5 => Ok(AtType::PhNum),
65             6 => Ok(AtType::PageSize),
66             7 => Ok(AtType::Base),
67             8 => Ok(AtType::Flags),
68             9 => Ok(AtType::Entry),
69             10 => Ok(AtType::NotElf),
70             11 => Ok(AtType::Uid),
71             12 => Ok(AtType::EUid),
72             13 => Ok(AtType::Gid),
73             14 => Ok(AtType::EGid),
74             15 => Ok(AtType::Platform),
75             16 => Ok(AtType::HwCap),
76             17 => Ok(AtType::ClkTck),
77             23 => Ok(AtType::Secure),
78             24 => Ok(AtType::BasePlatform),
79             25 => Ok(AtType::Random),
80             26 => Ok(AtType::HwCap2),
81             31 => Ok(AtType::ExecFn),
82             51 => Ok(AtType::MinSigStackSize),
83             _ => Err("Invalid value for AtType"),
84         }
85     }
86 }
87 
88 bitflags! {
89     pub struct WaitOption: u32{
90         const WNOHANG = 0x00000001;
91         const WUNTRACED = 0x00000002;
92         const WSTOPPED = 0x00000002;
93         const WEXITED = 0x00000004;
94         const WCONTINUED = 0x00000008;
95         const WNOWAIT = 0x01000000;
96         const WNOTHREAD = 0x20000000;
97         const WALL = 0x40000000;
98         const WCLONE = 0x80000000;
99     }
100 }
101