Lines Matching refs:instance

447 static void ticker_by_next_slot_get(struct ticker_instance *instance,  argument
460 node = instance->nodes;
465 (*ticks_current != instance->ticks_current)) {
467 _ticker_id_head = instance->ticker_id_head;
468 *ticks_current = instance->ticks_current;
549 static uint8_t ticker_enqueue(struct ticker_instance *instance, uint8_t id) argument
559 node = &instance->nodes[0];
562 current = instance->ticker_id_head;
594 instance->ticker_id_head = id;
622 static uint8_t ticker_enqueue(struct ticker_instance *instance, uint8_t id) argument
635 node = &instance->nodes[0];
640 current = instance->ticker_id_head;
642 ticks_slot_previous = instance->ticks_slot_previous;
681 instance->ticker_id_head = id;
718 static uint32_t ticker_dequeue(struct ticker_instance *instance, uint8_t id) argument
730 node = &instance->nodes[0];
731 previous = instance->ticker_id_head;
754 instance->ticker_id_head = ticker_current->next;
1006 static void ticker_get_expire_info(struct ticker_instance *instance, uint8_t to_ticker_id,
1018 current_ticker_id = instance->ticker_id_head;
1019 current_node = &instance->nodes[instance->ticker_id_head];
1033 current_node = &instance->nodes[current_ticker_id];
1037 struct ticker_node *to_ticker = &instance->nodes[to_ticker_id];
1076 static uint32_t ticker_alloc_expire_info(struct ticker_instance *instance, uint8_t ticker_id)
1082 if (instance->expire_infos[i].ticker_id == TICKER_NULL) {
1083 struct ticker_node *ticker = &instance->nodes[ticker_id];
1085 instance->expire_infos[i].ticker_id = ticker_id;
1086 instance->expire_infos[i].outdated = true;
1087 instance->expire_infos[i].last = is_last;
1088 ticker->ext_data->other_expire_info = &instance->expire_infos[i];
1089 instance->expire_infos_outdated = true;
1092 } else if (instance->expire_infos[i].last && i < TICKER_EXPIRE_INFO_MAX - 1) {
1093 instance->expire_infos[i].last = 0;
1109 static void ticker_free_expire_info(struct ticker_instance *instance, uint8_t ticker_id)
1115 if (instance->expire_infos[index].ticker_id == ticker_id) {
1116 instance->expire_infos[index].ticker_id = TICKER_NULL;
1117 is_last = instance->expire_infos[index].last;
1118 instance->expire_infos[index].last = 0;
1126 if (instance->expire_infos[index].ticker_id != TICKER_NULL || index == 0) {
1127 instance->expire_infos[index].last = 1;
1147 static void ticker_mark_expire_info_outdated(struct ticker_instance *instance, uint8_t ticker_id)
1150 if (instance->expire_infos[i].ticker_id != TICKER_NULL) {
1151 uint8_t current_id = instance->expire_infos[i].ticker_id;
1152 struct ticker_node *ticker = &instance->nodes[current_id];
1156 instance->expire_infos[i].outdated = true;
1157 instance->expire_infos_outdated = true;
1160 if (instance->expire_infos[i].last) {
1177 static void ticker_job_update_expire_infos(struct ticker_instance *instance)
1180 struct ticker_expire_info_internal *info = &instance->expire_infos[i];
1183 struct ticker_node *ticker = &instance->nodes[info->ticker_id];
1185 ticker_get_expire_info(instance, ticker->ext_data->expire_info_id,
1195 instance->expire_infos_outdated = false;
1215 struct ticker_instance *instance = param;
1222 instance->worker_trigger = 1U;
1223 if (instance->job_guard) {
1228 if (instance->ticker_id_head == TICKER_NULL) {
1229 instance->worker_trigger = 0U;
1235 instance->ticks_current);
1241 ticker_id_head = instance->ticker_id_head;
1250 if (instance->ticks_slot_previous > ticks_elapsed) {
1259 node = &instance->nodes[0];
1296 (instance->ticks_slot_previous > ticks_expired) ||
1365 ticks_at_expire = (instance->ticks_current +
1439 if (instance->ticks_elapsed_first == instance->ticks_elapsed_last) {
1440 ticker_next_elapsed(&instance->ticks_elapsed_last);
1442 instance->ticks_elapsed[instance->ticks_elapsed_last] = ticks_expired;
1444 instance->worker_trigger = 0U;
1447 instance->sched_cb(TICKER_CALL_ID_WORKER, TICKER_CALL_ID_JOB, 1,
1448 instance);
1624 static inline uint32_t ticker_job_node_update(struct ticker_instance *instance,
1715 status = ticker_alloc_expire_info(instance, user_op->id);
1721 ticker_free_expire_info(instance, user_op->id);
1727 ticker_mark_expire_info_outdated(instance, user_op->id);
1753 static inline void ticker_job_node_manage(struct ticker_instance *instance,
1764 ticker->ticks_to_expire = ticker_dequeue(instance, user_op->id);
1767 ticker_job_node_update(instance, ticker, user_op, ticks_now,
1768 instance->ticks_current, ticks_elapsed,
1772 ticker_mark_expire_info_outdated(instance, user_op->id);
1783 ticker->ticks_to_expire = ticker_dequeue(instance,
1788 ticker_free_expire_info(instance, user_op->id);
1792 ticker_mark_expire_info_outdated(instance, user_op->id);
1801 if (instance->ticker_id_slot_previous == user_op->id) {
1807 instance->ticker_id_slot_previous = TICKER_NULL;
1818 ticks_current = instance->ticks_current;
1836 if (instance->ticks_slot_previous > ticks_used) {
1837 instance->ticks_slot_previous = ticks_used;
1865 static inline uint8_t ticker_job_list_manage(struct ticker_instance *instance,
1876 node = &instance->nodes[0];
1877 users = &instance->users[0];
1878 count_user = instance->count_user;
1957 ticker_job_node_manage(instance, ticker,
1967 instance->sched_cb(TICKER_CALL_ID_JOB,
1969 instance);
1998 static inline void ticker_job_worker_bh(struct ticker_instance *instance,
2013 node = &instance->nodes[0];
2015 while (instance->ticker_id_head != TICKER_NULL) {
2023 id_expired = instance->ticker_id_head;
2051 if (instance->ticks_slot_previous > ticks_to_expire) {
2052 instance->ticks_slot_previous -= ticks_to_expire;
2054 instance->ticker_id_slot_previous = TICKER_NULL;
2055 instance->ticks_slot_previous = 0U;
2063 instance->ticker_id_slot_previous = id_expired;
2064 instance->ticks_slot_previous = ticker->ticks_slot;
2072 ticker_mark_expire_info_outdated(instance, instance->ticker_id_head);
2076 instance->ticker_id_head = ticker->next;
2152 ticks_to_expire_prep(ticker, instance->ticks_current,
2166 ticks_to_expire_prep(ticker, instance->ticks_current,
2209 static inline uint32_t ticker_job_op_start(struct ticker_instance *instance,
2238 status = ticker_alloc_expire_info(instance, user_op->id);
2245 ticker_mark_expire_info_outdated(instance, user_op->id);
2289 static inline uint8_t ticker_job_insert(struct ticker_instance *instance,
2300 (void)ticker_enqueue(instance, id_insert);
2325 static uint8_t ticker_job_reschedule_in_window(struct ticker_instance *instance,
2332 nodes = &instance->nodes[0];
2355 ticker_id_resched = instance->ticker_id_head;
2373 if (instance->ticks_slot_previous > ticks_elapsed) {
2377 window_start_ticks = instance->ticks_slot_previous -
2550 instance->ticker_id_head = ticker_resched->next;
2566 ticker_mark_expire_info_outdated(instance, ticker_id_resched);
2594 static inline uint8_t ticker_job_insert(struct ticker_instance *instance,
2599 struct ticker_node *node = &instance->nodes[0];
2616 (id_collide = ticker_enqueue(instance, id_insert))) {
2641 ticker_dequeue(instance, id_collide);
2704 static inline void ticker_job_list_insert(struct ticker_instance *instance,
2711 node = &instance->nodes[0];
2712 users = &instance->users[0];
2713 count_user = instance->count_user;
2775 status = ticker_job_op_start(instance, ticker, user_op,
2776 instance->ticks_current);
2781 status = ticker_job_insert(instance, id_insert, ticker,
2822 static inline void ticker_job_op_inquire(struct ticker_instance *instance,
2831 ticker_by_next_slot_get(instance,
2868 if (uop->id < instance->count_node) {
2869 struct ticker_node *node = instance->nodes;
2908 static inline void ticker_job_list_inquire(struct ticker_instance *instance)
2913 users = &instance->users[0];
2914 count_user = instance->count_user;
2925 ticker_job_op_inquire(instance, &user_op[user->first]);
2954 ticker_job_compare_update(struct ticker_instance *instance,
2964 if (instance->ticker_id_head == TICKER_NULL) {
2967 instance->ticks_slot_previous = 0U;
2970 instance->ticks_current = cntr_cnt_get();
2983 instance->ticks_current = ticks_current;
2987 ticker = &instance->nodes[instance->ticker_id_head];
3012 cc = instance->ticks_current;
3027 instance->trigger_set_cb(cc);
3054 struct ticker_instance *instance = param;
3068 if (instance->worker_trigger) {
3074 if (instance->job_guard) {
3075 instance->sched_cb(TICKER_CALL_ID_JOB, TICKER_CALL_ID_JOB, 1,
3076 instance);
3079 instance->job_guard = 1U;
3082 ticks_previous = instance->ticks_current;
3085 if (instance->ticks_elapsed_first != instance->ticks_elapsed_last) {
3086 ticker_next_elapsed(&instance->ticks_elapsed_first);
3089 instance->ticks_elapsed[instance->ticks_elapsed_first];
3091 instance->ticks_current += ticks_elapsed;
3092 instance->ticks_current &= HAL_TICKER_CNTR_MASK;
3110 ticker_id_old_head = instance->ticker_id_head;
3114 pending = ticker_job_list_manage(instance, ticks_now, ticks_elapsed,
3118 if (instance->ticker_id_head != ticker_id_old_head) {
3124 ticker_job_worker_bh(instance, ticks_now, ticks_previous,
3128 if (instance->ticker_id_head != ticker_id_old_head) {
3133 ticker_job_list_insert(instance, insert_head);
3138 if (ticker_job_reschedule_in_window(instance, ticks_elapsed)) {
3144 ticker_job_list_insert(instance, insert_head);
3148 if (instance->ticker_id_head != ticker_id_old_head) {
3158 ticker_job_list_inquire(instance);
3166 if (instance->expire_infos_outdated) {
3167 ticker_job_update_expire_infos(instance);
3173 compare_trigger = ticker_job_compare_update(instance,
3180 instance->job_guard = 0U;
3184 if (instance->worker_trigger || compare_trigger) {
3185 instance->sched_cb(TICKER_CALL_ID_JOB, TICKER_CALL_ID_WORKER, 1,
3186 instance);
3224 struct ticker_instance *instance = &_instance[instance_index];
3232 instance->count_node = count_node;
3233 instance->nodes = node;
3239 instance->nodes[count_node].priority = 0;
3246 instance->count_user = count_user;
3247 instance->users = user;
3251 users = &instance->users[0];
3262 instance->caller_id_get_cb = caller_id_get_cb;
3263 instance->sched_cb = sched_cb;
3264 instance->trigger_set_cb = trigger_set_cb;
3266 instance->ticker_id_head = TICKER_NULL;
3267 instance->ticks_current = cntr_cnt_get();
3268 instance->ticks_elapsed_first = 0U;
3269 instance->ticks_elapsed_last = 0U;
3272 instance->ticker_id_slot_previous = TICKER_NULL;
3273 instance->ticks_slot_previous = 0U;
3278 instance->expire_infos[i].ticker_id = TICKER_NULL;
3279 instance->expire_infos[i].last = 1;
3308 struct ticker_instance *instance;
3312 instance = &_instance[instance_index];
3313 if (instance->sched_cb) {
3314 instance->sched_cb(TICKER_CALL_ID_TRIGGER,
3315 TICKER_CALL_ID_WORKER, 1, instance);
3446 struct ticker_instance *instance = &_instance[instance_index];
3451 user = &instance->users[user_id];
3489 instance->sched_cb(instance->caller_id_get_cb(user_id),
3490 TICKER_CALL_ID_JOB, 0, instance);
3568 struct ticker_instance *instance = &_instance[instance_index];
3573 user = &instance->users[user_id];
3611 instance->sched_cb(instance->caller_id_get_cb(user_id),
3612 TICKER_CALL_ID_JOB, 0, instance);
3641 struct ticker_instance *instance = &_instance[instance_index];
3646 user = &instance->users[user_id];
3669 instance->sched_cb(instance->caller_id_get_cb(user_id),
3670 TICKER_CALL_ID_JOB, 0, instance);
3696 struct ticker_instance *instance = &_instance[instance_index];
3701 user = &instance->users[user_id];
3723 instance->sched_cb(instance->caller_id_get_cb(user_id),
3724 TICKER_CALL_ID_JOB, 0, instance);
3752 struct ticker_instance *instance = &_instance[instance_index];
3757 user = &instance->users[user_id];
3780 instance->sched_cb(instance->caller_id_get_cb(user_id),
3781 TICKER_CALL_ID_JOB, 0, instance);
3836 struct ticker_instance *instance = &_instance[instance_index];
3841 user = &instance->users[user_id];
3876 instance->sched_cb(instance->caller_id_get_cb(user_id),
3877 TICKER_CALL_ID_JOB, 0, instance);
3905 struct ticker_instance *instance = &_instance[instance_index];
3910 user = &instance->users[user_id];
3932 instance->sched_cb(instance->caller_id_get_cb(user_id),
3933 TICKER_CALL_ID_JOB, 0, instance);
3967 struct ticker_instance *instance = &_instance[instance_index];
3972 user = &instance->users[user_id];
3995 instance->sched_cb(instance->caller_id_get_cb(user_id),
3996 TICKER_CALL_ID_JOB, 0, instance);
4013 struct ticker_instance *instance = &_instance[instance_index];
4015 instance->sched_cb(instance->caller_id_get_cb(user_id),
4016 TICKER_CALL_ID_JOB, 0, instance);