Lines Matching full:this

54  * That pointer should be passed to all subsequent calls to this module.
58 struct nce_status_t *this; in nce_init() local
60 this = calloc(1, sizeof(struct nce_status_t)); in nce_init()
62 if (this == NULL) { /* LCOV_EXCL_BR_LINE */ in nce_init()
65 this->cpu_halted = true; in nce_init()
66 this->terminate = false; in nce_init()
68 NSI_SAFE_CALL(pthread_cond_init(&this->cond_cpu, NULL)); in nce_init()
69 NSI_SAFE_CALL(pthread_mutex_init(&this->mtx_cpu, NULL)); in nce_init()
71 return (void *)this; in nce_init()
75 * This function will:
80 * If called from a HW thread, do the necessary clean up of this nce instance
85 struct nce_status_t *this = (struct nce_status_t *)this_arg; in nce_terminate() local
94 if (this == NULL || this->cpu_halted) { in nce_terminate()
104 } else if (this->terminate == false) { in nce_terminate()
106 this->terminate = true; in nce_terminate()
108 NSI_SAFE_CALL(pthread_mutex_lock(&this->mtx_cpu)); in nce_terminate()
110 this->cpu_halted = true; in nce_terminate()
112 NSI_SAFE_CALL(pthread_cond_broadcast(&this->cond_cpu)); in nce_terminate()
113 NSI_SAFE_CALL(pthread_mutex_unlock(&this->mtx_cpu)); in nce_terminate()
117 /* This SW thread will wait until being cancelled from in nce_terminate()
130 * Both HW and SW threads will use this function to transfer control to the
133 * This is how the idle thread halts the CPU and gets halted until the HW models
137 static void change_cpu_state_and_wait(struct nce_status_t *this, bool halted) in change_cpu_state_and_wait() argument
139 NSI_SAFE_CALL(pthread_mutex_lock(&this->mtx_cpu)); in change_cpu_state_and_wait()
143 this->cpu_halted = halted; in change_cpu_state_and_wait()
146 NSI_SAFE_CALL(pthread_cond_broadcast(&this->cond_cpu)); in change_cpu_state_and_wait()
156 while (this->cpu_halted == halted) { in change_cpu_state_and_wait()
158 pthread_cond_wait(&this->cond_cpu, &this->mtx_cpu); in change_cpu_state_and_wait()
163 NSI_SAFE_CALL(pthread_mutex_unlock(&this->mtx_cpu)); in change_cpu_state_and_wait()
171 struct nce_status_t *this = (struct nce_status_t *)this_arg; in sw_wrapper() local
174 NSI_SAFE_CALL(pthread_mutex_lock(&this->mtx_cpu)); in sw_wrapper()
175 NSI_SAFE_CALL(pthread_mutex_unlock(&this->mtx_cpu)); in sw_wrapper()
184 this->start_routine(); in sw_wrapper()
194 * Note that during this, an embedded SW thread may call nsi_exit(), which would result
195 * in this function never returning.
199 struct nce_status_t *this = (struct nce_status_t *)this_arg; in nce_boot_cpu() local
201 NSI_SAFE_CALL(pthread_mutex_lock(&this->mtx_cpu)); in nce_boot_cpu()
203 this->cpu_halted = false; in nce_boot_cpu()
204 this->start_routine = start_routine; in nce_boot_cpu()
212 while (this->cpu_halted == false) { in nce_boot_cpu()
213 pthread_cond_wait(&this->cond_cpu, &this->mtx_cpu); in nce_boot_cpu()
215 NSI_SAFE_CALL(pthread_mutex_unlock(&this->mtx_cpu)); in nce_boot_cpu()
217 if (this->terminate) { in nce_boot_cpu()
224 * * Hold this embedded SW thread until the CPU is awaken again,
233 struct nce_status_t *this = (struct nce_status_t *)this_arg; in nce_halt_cpu() local
235 if (this->cpu_halted == true) { in nce_halt_cpu()
237 "This CPU was already halted\n"); in nce_halt_cpu()
239 change_cpu_state_and_wait(this, true); in nce_halt_cpu()
244 * * Hold this HW thread until the CPU is set to idle again
252 struct nce_status_t *this = (struct nce_status_t *)this_arg; in nce_wake_cpu() local
254 if (this->cpu_halted == false) { in nce_wake_cpu()
256 "This CPU was already awake\n"); in nce_wake_cpu()
258 change_cpu_state_and_wait(this, false); in nce_wake_cpu()
264 if (this->terminate) { in nce_wake_cpu()
275 struct nce_status_t *this = (struct nce_status_t *)this_arg; in nce_is_cpu_running() local
277 if (this != NULL) { in nce_is_cpu_running()
278 return !this->cpu_halted; in nce_is_cpu_running()
287 * Note1: When the application is closed due to a SIGTERM, the path in this
291 * we exclude this function from the coverage check