1use crate::bindings::*;
2
3pub type ApexPartitionId = ApexLongInteger;
4
5#[repr(u32)]
6#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
7pub enum ApexOperatingMode {
8 #[default]
9 Idle = 0,
10 ColdStart = 1,
11 WarmStart = 2,
12 Normal = 3,
13}
14
15impl TryFrom<ApexUnsigned> for ApexOperatingMode {
16 type Error = ApexUnsigned;
17
18 fn try_from(value: ApexUnsigned) -> Result<Self, Self::Error> {
19 match value {
20 0 => Ok(Self::Idle),
21 1 => Ok(Self::ColdStart),
22 2 => Ok(Self::WarmStart),
23 3 => Ok(Self::Normal),
24 _ => Err(value),
25 }
26 }
27}
28
29#[repr(u32)]
30#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
31pub enum ApexStartCondition {
32 #[default]
33 NormalStart = 0,
34 PartitionRestart = 1,
35 HmModuleRestart = 2,
36 HmPartitionRestart = 3,
37}
38
39impl TryFrom<ApexUnsigned> for ApexStartCondition {
40 type Error = ApexUnsigned;
41
42 fn try_from(value: ApexUnsigned) -> Result<Self, Self::Error> {
43 match value {
44 0 => Ok(Self::NormalStart),
45 1 => Ok(Self::PartitionRestart),
46 2 => Ok(Self::HmModuleRestart),
47 3 => Ok(Self::HmPartitionRestart),
48 _ => Err(value),
49 }
50 }
51}
52
53#[repr(C)]
54#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
55pub struct ApexPartitionStatus {
56 pub period: ApexSystemTime,
57 pub duration: ApexSystemTime,
58 pub identifier: ApexPartitionId,
59 pub lock_level: ApexLockLevel,
60 pub operating_mode: ApexOperatingMode,
61 pub start_condition: ApexStartCondition,
62 pub num_assigned_cores: ApexNumCores,
63}
64
65pub trait ApexPartitionService {
66 fn get_partition_status(&self) -> Result<ApexPartitionStatus, ApexReturnCode>;
67
68 fn set_partition_mode(&self, operating_mode: ApexOperatingMode) -> Result<(), ApexReturnCode>;
69}