xref: /DragonOS/kernel/src/process/abi.rs (revision b7b843beddea12cdedda90f6129b7c9980876112)
140fe15e0SLoGin /// An enumeration of the possible values for the `AT_*` constants.
240fe15e0SLoGin #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
340fe15e0SLoGin pub enum AtType {
440fe15e0SLoGin     /// End of vector.
540fe15e0SLoGin     Null,
640fe15e0SLoGin     /// Entry should be ignored.
740fe15e0SLoGin     Ignore,
840fe15e0SLoGin     /// File descriptor of program.
940fe15e0SLoGin     ExecFd,
1040fe15e0SLoGin     /// Program headers for program.
1140fe15e0SLoGin     Phdr,
1240fe15e0SLoGin     /// Size of program header entry.
1340fe15e0SLoGin     PhEnt,
1440fe15e0SLoGin     /// Number of program headers.
1540fe15e0SLoGin     PhNum,
1640fe15e0SLoGin     /// System page size.
1740fe15e0SLoGin     PageSize,
1840fe15e0SLoGin     /// Base address of interpreter.
1940fe15e0SLoGin     Base,
2040fe15e0SLoGin     /// Flags.
2140fe15e0SLoGin     Flags,
2240fe15e0SLoGin     /// Entry point of program.
2340fe15e0SLoGin     Entry,
2440fe15e0SLoGin     /// Program is not ELF.
2540fe15e0SLoGin     NotElf,
2640fe15e0SLoGin     /// Real uid.
2740fe15e0SLoGin     Uid,
2840fe15e0SLoGin     /// Effective uid.
2940fe15e0SLoGin     EUid,
3040fe15e0SLoGin     /// Real gid.
3140fe15e0SLoGin     Gid,
3240fe15e0SLoGin     /// Effective gid.
3340fe15e0SLoGin     EGid,
3440fe15e0SLoGin     /// String identifying CPU for optimizations.
3540fe15e0SLoGin     Platform,
3640fe15e0SLoGin     /// Arch dependent hints at CPU capabilities.
3740fe15e0SLoGin     HwCap,
3840fe15e0SLoGin     /// Frequency at which times() increments.
3940fe15e0SLoGin     ClkTck,
4040fe15e0SLoGin     /// Secure mode boolean.
4140fe15e0SLoGin     Secure,
4240fe15e0SLoGin     /// String identifying real platform, may differ from AT_PLATFORM.
4340fe15e0SLoGin     BasePlatform,
4440fe15e0SLoGin     /// Address of 16 random bytes.
4540fe15e0SLoGin     Random,
4640fe15e0SLoGin     /// Extension of AT_HWCAP.
4740fe15e0SLoGin     HwCap2,
4840fe15e0SLoGin     /// Filename of program.
4940fe15e0SLoGin     ExecFn,
5040fe15e0SLoGin     /// Minimal stack size for signal delivery.
5140fe15e0SLoGin     MinSigStackSize,
5240fe15e0SLoGin }
5340fe15e0SLoGin 
5440fe15e0SLoGin impl TryFrom<u32> for AtType {
5540fe15e0SLoGin     type Error = &'static str;
5640fe15e0SLoGin 
try_from(value: u32) -> Result<Self, Self::Error>5740fe15e0SLoGin     fn try_from(value: u32) -> Result<Self, Self::Error> {
5840fe15e0SLoGin         match value {
5940fe15e0SLoGin             0 => Ok(AtType::Null),
6040fe15e0SLoGin             1 => Ok(AtType::Ignore),
6140fe15e0SLoGin             2 => Ok(AtType::ExecFd),
6240fe15e0SLoGin             3 => Ok(AtType::Phdr),
6340fe15e0SLoGin             4 => Ok(AtType::PhEnt),
6440fe15e0SLoGin             5 => Ok(AtType::PhNum),
6540fe15e0SLoGin             6 => Ok(AtType::PageSize),
6640fe15e0SLoGin             7 => Ok(AtType::Base),
6740fe15e0SLoGin             8 => Ok(AtType::Flags),
6840fe15e0SLoGin             9 => Ok(AtType::Entry),
6940fe15e0SLoGin             10 => Ok(AtType::NotElf),
7040fe15e0SLoGin             11 => Ok(AtType::Uid),
7140fe15e0SLoGin             12 => Ok(AtType::EUid),
7240fe15e0SLoGin             13 => Ok(AtType::Gid),
7340fe15e0SLoGin             14 => Ok(AtType::EGid),
7440fe15e0SLoGin             15 => Ok(AtType::Platform),
7540fe15e0SLoGin             16 => Ok(AtType::HwCap),
7640fe15e0SLoGin             17 => Ok(AtType::ClkTck),
7740fe15e0SLoGin             23 => Ok(AtType::Secure),
7840fe15e0SLoGin             24 => Ok(AtType::BasePlatform),
7940fe15e0SLoGin             25 => Ok(AtType::Random),
8040fe15e0SLoGin             26 => Ok(AtType::HwCap2),
8140fe15e0SLoGin             31 => Ok(AtType::ExecFn),
8240fe15e0SLoGin             51 => Ok(AtType::MinSigStackSize),
8340fe15e0SLoGin             _ => Err("Invalid value for AtType"),
8440fe15e0SLoGin         }
8540fe15e0SLoGin     }
8640fe15e0SLoGin }
87*b7b843beSGnoCiYeH 
88*b7b843beSGnoCiYeH bitflags! {
89*b7b843beSGnoCiYeH     pub struct WaitOption: u32{
90*b7b843beSGnoCiYeH         const WNOHANG = 0x00000001;
91*b7b843beSGnoCiYeH         const WUNTRACED = 0x00000002;
92*b7b843beSGnoCiYeH         const WSTOPPED = 0x00000002;
93*b7b843beSGnoCiYeH         const WEXITED = 0x00000004;
94*b7b843beSGnoCiYeH         const WCONTINUED = 0x00000008;
95*b7b843beSGnoCiYeH         const WNOWAIT = 0x01000000;
96*b7b843beSGnoCiYeH         const WNOTHREAD = 0x20000000;
97*b7b843beSGnoCiYeH         const WALL = 0x40000000;
98*b7b843beSGnoCiYeH         const WCLONE = 0x80000000;
99*b7b843beSGnoCiYeH     }
100*b7b843beSGnoCiYeH }
101