/** * \brief Creates the stack to access to the bus * * Stores the function identifier and creates the stack for arguments. The cpu checks that * the identifier is not -1 and execute the HAL function. \n * This function is executed by the user code in a transparent way for the user. * \param cpu The current processor * \param ... The parameters of the HAL's function * \return */ int HAL_stack_creation(int function_id, ...) { // UC_rtos_class *foo_rtos = qt_parent_rtos; // UC_process_class *foo_process = qt_parent_process; // UC_thread_class *thread = (*qt_parent_rtos)[qt_parent_process->m_cpu]->m_current_task->m_current_thread; // thread->set_next_state(USER, SUPER_USER); // thread->update_state(); // stp_yield(); uc_cpu_bus_transfer_info_t *info = new uc_cpu_bus_transfer_info_t; int i; int *local_stack; UC_cpu_class *cpu = qt_parent_rtos->get_current_cpu(); UC_thread_class *thread = cpu->m_current_task->m_current_thread; va_list arg_list; va_start(arg_list, function_id); thread->m_bus_transfer_info.m_HAL_function_id = function_id; thread->m_bus_transfer_info.m_HAL_done = 0; local_stack = (int*)thread->m_bus_transfer_info.m_HAL_arg_stack; // local_stack[0] = (int)thread; local_stack[0] = (long int)thread; for (int arg_cont = 1; arg_cont < 6; arg_cont++) { local_stack[arg_cont] = va_arg(arg_list, int); } va_end(arg_list); thread->annotate_user_time(uc_segment_time, uc_segment_instr); uc_segment_time = 0; uc_segment_instr = 0; while(thread->m_bus_transfer_info.m_HAL_done==0){ thread->m_bus_transfer_list.push_back(&thread->m_bus_transfer_info); stp_yield(); /* Element removed from the list in uc_cpu_class:bus_access. for( i=0; i < thread->m_bus_transfer_list.size(); i++ ) { if(thread->m_bus_transfer_list[i]==(&thread->m_bus_transfer_info)){ thread->m_bus_transfer_list.erase( thread->m_bus_transfer_list.begin()+i ); } }*/ } thread->m_bus_transfer_info.m_HAL_done = 0; return thread->m_bus_transfer_info.m_HAL_return; }
/** * \brief Change the thread state from USER to SUPER_USER */ void posix_user_to_superuser(UC_thread_class *thread, bool &change_state){ if (thread->m_state == USER) { change_state = true; /* if(qt_parent_rtos->get_current_cpu()->m_icache != NULL){ qt_parent_rtos->get_current_cpu()->m_icache->flush(); } if(qt_parent_rtos->get_current_cpu()->m_dcache != NULL){ qt_parent_rtos->get_current_cpu()->m_dcache->flush(); }*/ thread->set_next_state(USER, SUPER_USER); stp_yield(); } }
void UC_eat_time(unsigned long long time) { USER_TO_SUPER_USER(); POSIX->eat_time(time); // By default, the USER_TO_SUPER_USER is only executed from USER state. // This function needs to wait the annotated time no matter what. if (change_state == false) { thread->set_next_state(SUPER_USER, WAITING); stp_yield(); thread->set_next_state(USER, SUPER_USER); thread->update_state(); } SUPER_USER_TO_WAITING(); }
static void test05_aux (void *null) { stp_yield(); stp_yield(); }
/** * \brief Change the thread state from SUPER_USER to USER */ void posix_super_user_to_waiting(UC_thread_class *thread, bool change_state){ if (change_state == true) { thread->set_next_state(SUPER_USER, WAITING); stp_yield(); } }