1use crate::bindings::*;
2
3pub type ApexProcessName = ApexName;
4pub type ApexProcessIndex = ApexInteger;
5pub type ApexProcessId = ApexLongInteger;
6
7#[repr(u32)]
8#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
9pub enum ApexProcessState {
10 #[default]
11 Dormant = 0,
12 Ready = 1,
13 Running = 2,
14 Waiting = 3,
15 Faulted = 4,
16}
17
18#[repr(C)]
19#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
20pub struct ApexProcessAttribute {
21 pub period: ApexSystemTime,
22 pub time_capacity: ApexSystemTime,
23 pub entry_point: ApexSystemAddress,
24 pub stack_size: ApexStackSize,
25 pub base_priority: ApexPriority,
26 pub deadline: ApexDeadline,
27 pub name: ApexProcessName,
28}
29
30#[repr(C)]
31#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
32pub struct ApexProcessStatus {
33 pub deadline_time: ApexSystemTime,
34 pub current_priority: ApexPriority,
35 pub process_state: ApexProcessState,
36 pub attributes: ApexProcessAttribute,
37}
38
39pub trait ApexProcessService {
40 fn get_process_id(
41 &self,
42 process_name: &ApexProcessName,
43 ) -> Result<ApexProcessId, ApexReturnCode>;
44
45 fn get_process_status(
46 &self,
47 process_id: ApexProcessId,
48 ) -> Result<ApexProcessStatus, ApexReturnCode>;
49
50 fn create_process(
51 &self,
52 attributes: &ApexProcessAttribute,
53 ) -> Result<ApexProcessId, ApexReturnCode>;
54
55 fn set_priority(
56 &self,
57 process_id: ApexProcessId,
58 priority: ApexPriority,
59 ) -> Result<(), ApexReturnCode>;
60
61 fn suspend_self(&self, time_out: ApexSystemTime) -> Result<(), ApexReturnCode>;
62
63 fn suspend(&self, process_id: ApexProcessId) -> Result<(), ApexReturnCode>;
64
65 fn resume(&self, process_id: ApexProcessId) -> Result<(), ApexReturnCode>;
66
67 fn stop_self(&self) -> !;
68
69 fn stop(&self, process_id: ApexProcessId) -> Result<(), ApexReturnCode>;
70
71 fn start(&self, process_id: ApexProcessId) -> Result<(), ApexReturnCode>;
72
73 fn delayed_start(
74 &self,
75 process_id: ApexProcessId,
76 start_time: ApexSystemTime,
77 ) -> Result<(), ApexReturnCode>;
78
79 fn lock_preemption(&self) -> Result<ApexLockLevel, ApexReturnCode>;
80
81 fn unlock_preemption(&self) -> Result<ApexLockLevel, ApexReturnCode>;
82
83 fn get_my_id(&self) -> Result<ApexProcessId, ApexReturnCode>;
84
85 fn initialize_process_core_affinity(
86 &self,
87 process_id: ApexProcessId,
88 process_core_id: ApexProcessorCoreId,
89 ) -> Result<(), ApexReturnCode>;
90
91 fn get_my_processor_core_id(&self) -> Result<ApexProcessorCoreId, ApexReturnCode>;
92
93 fn get_my_index(&self) -> Result<ApexProcessIndex, ApexReturnCode>;
94}