|
| 1 | +//! ABI for μITRON derivatives |
| 2 | +pub type int_t = crate::os::raw::c_int; |
| 3 | +pub type uint_t = crate::os::raw::c_uint; |
| 4 | +pub type bool_t = int_t; |
| 5 | + |
| 6 | +/// Kernel object ID |
| 7 | +pub type ID = int_t; |
| 8 | + |
| 9 | +/// The current task. |
| 10 | +pub const TSK_SELF: ID = 0; |
| 11 | + |
| 12 | +/// Relative time |
| 13 | +pub type RELTIM = u32; |
| 14 | + |
| 15 | +/// Timeout (a valid `RELTIM` value or `TMO_FEVR`) |
| 16 | +pub type TMO = u32; |
| 17 | + |
| 18 | +/// The infinite timeout value |
| 19 | +pub const TMO_FEVR: TMO = TMO::MAX; |
| 20 | + |
| 21 | +/// The maximum valid value of `RELTIM` |
| 22 | +pub const TMAX_RELTIM: RELTIM = 4_000_000_000; |
| 23 | + |
| 24 | +/// System time |
| 25 | +pub type SYSTIM = u64; |
| 26 | + |
| 27 | +/// Error code type |
| 28 | +pub type ER = int_t; |
| 29 | + |
| 30 | +/// Error code type, `ID` on success |
| 31 | +pub type ER_ID = int_t; |
| 32 | + |
| 33 | +/// Task or interrupt priority |
| 34 | +pub type PRI = int_t; |
| 35 | + |
| 36 | +/// The special value of `PRI` representing the current task's priority. |
| 37 | +pub const TPRI_SELF: PRI = 0; |
| 38 | + |
| 39 | +/// Object attributes |
| 40 | +pub type ATR = uint_t; |
| 41 | + |
| 42 | +/// Use the priority inheritance protocol |
| 43 | +#[cfg(target_os = "solid_asp3")] |
| 44 | +pub const TA_INHERIT: ATR = 0x02; |
| 45 | + |
| 46 | +/// Activate the task on creation |
| 47 | +pub const TA_ACT: ATR = 0x01; |
| 48 | + |
| 49 | +/// The maximum count of a semaphore |
| 50 | +pub const TMAX_MAXSEM: uint_t = uint_t::MAX; |
| 51 | + |
| 52 | +/// Callback parameter |
| 53 | +pub type EXINF = isize; |
| 54 | + |
| 55 | +/// Task entrypoint |
| 56 | +pub type TASK = Option<unsafe extern "C" fn(EXINF)>; |
| 57 | + |
| 58 | +// Error codes |
| 59 | +pub const E_OK: ER = 0; |
| 60 | +pub const E_SYS: ER = -5; |
| 61 | +pub const E_NOSPT: ER = -9; |
| 62 | +pub const E_RSFN: ER = -10; |
| 63 | +pub const E_RSATR: ER = -11; |
| 64 | +pub const E_PAR: ER = -17; |
| 65 | +pub const E_ID: ER = -18; |
| 66 | +pub const E_CTX: ER = -25; |
| 67 | +pub const E_MACV: ER = -26; |
| 68 | +pub const E_OACV: ER = -27; |
| 69 | +pub const E_ILUSE: ER = -28; |
| 70 | +pub const E_NOMEM: ER = -33; |
| 71 | +pub const E_NOID: ER = -34; |
| 72 | +pub const E_NORES: ER = -35; |
| 73 | +pub const E_OBJ: ER = -41; |
| 74 | +pub const E_NOEXS: ER = -42; |
| 75 | +pub const E_QOVR: ER = -43; |
| 76 | +pub const E_RLWAI: ER = -49; |
| 77 | +pub const E_TMOUT: ER = -50; |
| 78 | +pub const E_DLT: ER = -51; |
| 79 | +pub const E_CLS: ER = -52; |
| 80 | +pub const E_RASTER: ER = -53; |
| 81 | +pub const E_WBLK: ER = -57; |
| 82 | +pub const E_BOVR: ER = -58; |
| 83 | +pub const E_COMM: ER = -65; |
| 84 | + |
| 85 | +#[derive(Clone, Copy)] |
| 86 | +#[repr(C)] |
| 87 | +pub struct T_CSEM { |
| 88 | + pub sematr: ATR, |
| 89 | + pub isemcnt: uint_t, |
| 90 | + pub maxsem: uint_t, |
| 91 | +} |
| 92 | + |
| 93 | +#[derive(Clone, Copy)] |
| 94 | +#[repr(C)] |
| 95 | +pub struct T_CMTX { |
| 96 | + pub mtxatr: ATR, |
| 97 | + pub ceilpri: PRI, |
| 98 | +} |
| 99 | + |
| 100 | +#[derive(Clone, Copy)] |
| 101 | +#[repr(C)] |
| 102 | +pub struct T_CTSK { |
| 103 | + pub tskatr: ATR, |
| 104 | + pub exinf: EXINF, |
| 105 | + pub task: TASK, |
| 106 | + pub itskpri: PRI, |
| 107 | + pub stksz: usize, |
| 108 | + pub stk: *mut u8, |
| 109 | +} |
| 110 | + |
| 111 | +extern "C" { |
| 112 | + #[link_name = "__asp3_acre_tsk"] |
| 113 | + pub fn acre_tsk(pk_ctsk: *const T_CTSK) -> ER_ID; |
| 114 | + #[link_name = "__asp3_get_tid"] |
| 115 | + pub fn get_tid(p_tskid: *mut ID) -> ER; |
| 116 | + #[link_name = "__asp3_dly_tsk"] |
| 117 | + pub fn dly_tsk(dlytim: RELTIM) -> ER; |
| 118 | + #[link_name = "__asp3_ter_tsk"] |
| 119 | + pub fn ter_tsk(tskid: ID) -> ER; |
| 120 | + #[link_name = "__asp3_del_tsk"] |
| 121 | + pub fn del_tsk(tskid: ID) -> ER; |
| 122 | + #[link_name = "__asp3_get_pri"] |
| 123 | + pub fn get_pri(tskid: ID, p_tskpri: *mut PRI) -> ER; |
| 124 | + #[link_name = "__asp3_rot_rdq"] |
| 125 | + pub fn rot_rdq(tskpri: PRI) -> ER; |
| 126 | + #[link_name = "__asp3_slp_tsk"] |
| 127 | + pub fn slp_tsk() -> ER; |
| 128 | + #[link_name = "__asp3_tslp_tsk"] |
| 129 | + pub fn tslp_tsk(tmout: TMO) -> ER; |
| 130 | + #[link_name = "__asp3_wup_tsk"] |
| 131 | + pub fn wup_tsk(tskid: ID) -> ER; |
| 132 | + #[link_name = "__asp3_unl_cpu"] |
| 133 | + pub fn unl_cpu() -> ER; |
| 134 | + #[link_name = "__asp3_dis_dsp"] |
| 135 | + pub fn dis_dsp() -> ER; |
| 136 | + #[link_name = "__asp3_ena_dsp"] |
| 137 | + pub fn ena_dsp() -> ER; |
| 138 | + #[link_name = "__asp3_sns_dsp"] |
| 139 | + pub fn sns_dsp() -> bool_t; |
| 140 | + #[link_name = "__asp3_get_tim"] |
| 141 | + pub fn get_tim(p_systim: *mut SYSTIM) -> ER; |
| 142 | + #[link_name = "__asp3_acre_mtx"] |
| 143 | + pub fn acre_mtx(pk_cmtx: *const T_CMTX) -> ER_ID; |
| 144 | + #[link_name = "__asp3_del_mtx"] |
| 145 | + pub fn del_mtx(tskid: ID) -> ER; |
| 146 | + #[link_name = "__asp3_loc_mtx"] |
| 147 | + pub fn loc_mtx(mtxid: ID) -> ER; |
| 148 | + #[link_name = "__asp3_ploc_mtx"] |
| 149 | + pub fn ploc_mtx(mtxid: ID) -> ER; |
| 150 | + #[link_name = "__asp3_tloc_mtx"] |
| 151 | + pub fn tloc_mtx(mtxid: ID, tmout: TMO) -> ER; |
| 152 | + #[link_name = "__asp3_unl_mtx"] |
| 153 | + pub fn unl_mtx(mtxid: ID) -> ER; |
| 154 | + pub fn exd_tsk() -> ER; |
| 155 | +} |
0 commit comments