1 //! ABI for μITRON derivatives 2 pub type int_t = crate::std::os::raw::c_int; 3 pub type uint_t = crate::std::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 /// Service call operational mode 34 pub type MODE = uint_t; 35 36 /// OR waiting condition for an eventflag 37 pub const TWF_ORW: MODE = 0x01; 38 39 /// Object attributes 40 pub type ATR = uint_t; 41 42 /// FIFO wait order 43 pub const TA_FIFO: ATR = 0; 44 /// Only one task is allowed to be in the waiting state for the eventflag 45 pub const TA_WSGL: ATR = 0; 46 /// The eventflag’s bit pattern is cleared when a task is released from the 47 /// waiting state for that eventflag. 48 pub const TA_CLR: ATR = 0x04; 49 50 /// Bit pattern of an eventflag 51 pub type FLGPTN = uint_t; 52 53 /// Task or interrupt priority 54 pub type PRI = int_t; 55 56 /// The special value of `PRI` representing the current task's priority. 57 pub const TPRI_SELF: PRI = 0; 58 59 /// Use the priority inheritance protocol 60 #[cfg(target_os = "solid_asp3")] 61 pub const TA_INHERIT: ATR = 0x02; 62 63 /// Activate the task on creation 64 pub const TA_ACT: ATR = 0x01; 65 66 /// The maximum count of a semaphore 67 pub const TMAX_MAXSEM: uint_t = uint_t::MAX; 68 69 /// Callback parameter 70 pub type EXINF = isize; 71 72 /// Task entrypoint 73 pub type TASK = Option<unsafe extern "C" fn(EXINF)>; 74 75 // Error codes 76 pub const E_OK: ER = 0; 77 pub const E_SYS: ER = -5; 78 pub const E_NOSPT: ER = -9; 79 pub const E_RSFN: ER = -10; 80 pub const E_RSATR: ER = -11; 81 pub const E_PAR: ER = -17; 82 pub const E_ID: ER = -18; 83 pub const E_CTX: ER = -25; 84 pub const E_MACV: ER = -26; 85 pub const E_OACV: ER = -27; 86 pub const E_ILUSE: ER = -28; 87 pub const E_NOMEM: ER = -33; 88 pub const E_NOID: ER = -34; 89 pub const E_NORES: ER = -35; 90 pub const E_OBJ: ER = -41; 91 pub const E_NOEXS: ER = -42; 92 pub const E_QOVR: ER = -43; 93 pub const E_RLWAI: ER = -49; 94 pub const E_TMOUT: ER = -50; 95 pub const E_DLT: ER = -51; 96 pub const E_CLS: ER = -52; 97 pub const E_RASTER: ER = -53; 98 pub const E_WBLK: ER = -57; 99 pub const E_BOVR: ER = -58; 100 pub const E_COMM: ER = -65; 101 102 #[derive(Clone, Copy)] 103 #[repr(C)] 104 pub struct T_CSEM { 105 pub sematr: ATR, 106 pub isemcnt: uint_t, 107 pub maxsem: uint_t, 108 } 109 110 #[derive(Clone, Copy)] 111 #[repr(C)] 112 pub struct T_CFLG { 113 pub flgatr: ATR, 114 pub iflgptn: FLGPTN, 115 } 116 117 #[derive(Clone, Copy)] 118 #[repr(C)] 119 pub struct T_CMTX { 120 pub mtxatr: ATR, 121 pub ceilpri: PRI, 122 } 123 124 #[derive(Clone, Copy)] 125 #[repr(C)] 126 pub struct T_CTSK { 127 pub tskatr: ATR, 128 pub exinf: EXINF, 129 pub task: TASK, 130 pub itskpri: PRI, 131 pub stksz: usize, 132 pub stk: *mut u8, 133 } 134 135 extern "C" { 136 #[link_name = "__asp3_acre_tsk"] 137 pub fn acre_tsk(pk_ctsk: *const T_CTSK) -> ER_ID; 138 #[link_name = "__asp3_get_tid"] 139 pub fn get_tid(p_tskid: *mut ID) -> ER; 140 #[link_name = "__asp3_dly_tsk"] 141 pub fn dly_tsk(dlytim: RELTIM) -> ER; 142 #[link_name = "__asp3_ter_tsk"] 143 pub fn ter_tsk(tskid: ID) -> ER; 144 #[link_name = "__asp3_del_tsk"] 145 pub fn del_tsk(tskid: ID) -> ER; 146 #[link_name = "__asp3_get_pri"] 147 pub fn get_pri(tskid: ID, p_tskpri: *mut PRI) -> ER; 148 #[link_name = "__asp3_rot_rdq"] 149 pub fn rot_rdq(tskpri: PRI) -> ER; 150 #[link_name = "__asp3_slp_tsk"] 151 pub fn slp_tsk() -> ER; 152 #[link_name = "__asp3_tslp_tsk"] 153 pub fn tslp_tsk(tmout: TMO) -> ER; 154 #[link_name = "__asp3_wup_tsk"] 155 pub fn wup_tsk(tskid: ID) -> ER; 156 #[link_name = "__asp3_unl_cpu"] 157 pub fn unl_cpu() -> ER; 158 #[link_name = "__asp3_dis_dsp"] 159 pub fn dis_dsp() -> ER; 160 #[link_name = "__asp3_ena_dsp"] 161 pub fn ena_dsp() -> ER; 162 #[link_name = "__asp3_sns_dsp"] 163 pub fn sns_dsp() -> bool_t; 164 #[link_name = "__asp3_get_tim"] 165 pub fn get_tim(p_systim: *mut SYSTIM) -> ER; 166 #[link_name = "__asp3_acre_flg"] 167 pub fn acre_flg(pk_cflg: *const T_CFLG) -> ER_ID; 168 #[link_name = "__asp3_del_flg"] 169 pub fn del_flg(flgid: ID) -> ER; 170 #[link_name = "__asp3_set_flg"] 171 pub fn set_flg(flgid: ID, setptn: FLGPTN) -> ER; 172 #[link_name = "__asp3_clr_flg"] 173 pub fn clr_flg(flgid: ID, clrptn: FLGPTN) -> ER; 174 #[link_name = "__asp3_wai_flg"] 175 pub fn wai_flg(flgid: ID, waiptn: FLGPTN, wfmode: MODE, p_flgptn: *mut FLGPTN) -> ER; 176 #[link_name = "__asp3_twai_flg"] 177 pub fn twai_flg( 178 flgid: ID, 179 waiptn: FLGPTN, 180 wfmode: MODE, 181 p_flgptn: *mut FLGPTN, 182 tmout: TMO, 183 ) -> ER; 184 #[link_name = "__asp3_acre_mtx"] 185 pub fn acre_mtx(pk_cmtx: *const T_CMTX) -> ER_ID; 186 #[link_name = "__asp3_del_mtx"] 187 pub fn del_mtx(tskid: ID) -> ER; 188 #[link_name = "__asp3_loc_mtx"] 189 pub fn loc_mtx(mtxid: ID) -> ER; 190 #[link_name = "__asp3_ploc_mtx"] 191 pub fn ploc_mtx(mtxid: ID) -> ER; 192 #[link_name = "__asp3_tloc_mtx"] 193 pub fn tloc_mtx(mtxid: ID, tmout: TMO) -> ER; 194 #[link_name = "__asp3_unl_mtx"] 195 pub fn unl_mtx(mtxid: ID) -> ER; 196 pub fn exd_tsk() -> ER; 197 } 198