/* Standard pretask hook. * * $Req: artf1224 $ */ void PreTaskHook(void) { TaskType task; TaskStateType state; StatusType rc; #ifdef USEPRETASKHOOK /* PreTaskHook() should be called with cat2 interrupts locked. * * $Req: artf1110 $ * * Following code will trigger the cat2 ISR here but it should not actually run. Dismiss it later. * Safe to do this because PreTaskHook() is never called from an ISR and so won't mess with the cat2 ISR in * the tests. * * In mosts tests the ISR running is logged, and this would cause the test to fail * because there should be no expect ISR log entries at this point. */ testing_trigger_isr(); SET_TESTEVENT("PreTaskHook"); /* Task should now be RUNNING when the hook is called * * $Req: artf1140 $ */ rc = GetTaskID(&task); /* $Req: artf1139 $ */ if(rc != E_OK) { test_failed(OS_HERE); } if(task == INVALID_TASK) { /* $Req: artf1119 $ */ test_failed(OS_HERE); } GetTaskState(task, &state); /* $Req: artf1141 $ */ if(rc != E_OK) { test_failed(OS_HERE); } if(state != RUNNING) { /* $Req: artf1119 $ */ test_failed(OS_HERE); } #ifdef INCLUDE_HANDLE_NAME_MAP GetTaskID(&task); SET_TESTEVENT(TaskType2string(task)); #else SET_TESTEVENT("A task"); #endif #ifdef USEPOSTTASKHOOK if(pretaskhook_task != 0) { test_failed(OS_HERE); } #endif GetTaskID(&pretaskhook_task); testing_dismiss_isr(); #else test_failed(OS_HERE); #endif }
/*test case:test the reaction of the system called with an activation of a task*/ static void test_pretask_instance2(void) { StatusType result_inst_1, result_inst_2, result_inst_3, result_inst_4, result_inst_5; TaskType task_id; TaskStateType task_state; EventMaskType event_mask; AlarmBaseType alarm_base; TickType tik; SCHEDULING_CHECK_INIT(15); result_inst_1 = GetTaskID(&task_id); SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(15,INVALID_TASK , task_id); SCHEDULING_CHECK_AND_EQUAL_INT(15,E_OK , result_inst_1); SCHEDULING_CHECK_INIT(16); result_inst_2 = GetTaskState(task_id, &task_state); SCHEDULING_CHECK_AND_EQUAL_INT(17,E_OS_ID , result_inst_2); SCHEDULING_CHECK_INIT(18); result_inst_3 = GetEvent(task_id,&event_mask); SCHEDULING_CHECK_AND_EQUAL_INT(19,E_OS_ID , result_inst_3); SCHEDULING_CHECK_INIT(20); result_inst_4 = GetAlarmBase(Alarm1, &alarm_base); SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(20,OSMAXALLOWEDVALUE_Counter1, (int)(alarm_base.maxallowedvalue)); SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(20,OSTICKSPERBASE_Counter1, (int)(alarm_base.ticksperbase)); SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(20,OSMINCYCLE_Counter1, (int)(alarm_base.mincycle)); SCHEDULING_CHECK_AND_EQUAL_INT(20,E_OK , result_inst_4); SCHEDULING_CHECK_INIT(21); result_inst_5 = GetAlarm(Alarm1,&tik); SCHEDULING_CHECK_AND_EQUAL_INT(21,E_OK , result_inst_5); }
extern ssize_t ciaaBlockDevices_write(ciaaDevices_deviceType const * const device, uint8_t const * buf, size_t const nbyte) { /* get block device */ ciaaBlockDevices_deviceType * blockDevice = (ciaaBlockDevices_deviceType*) device->layer; ssize_t ret = 0; /* trigger write data from lower layer */ ret = blockDevice->device->write(device->loLayer, buf, nbyte); /* if no bytes couldnt be written, wait to complete the write */ if (0 == ret) { /* get task id and function for waking up the task later */ GetTaskID(&blockDevice->blocked.taskID); blockDevice->blocked.fct = (void*) ciaaBlockDevices_read; /* if no data wait for it */ #ifdef POSIXE WaitEvent(POSIXE); ClearEvent(POSIXE); #else #endif /* TODO improve this */ /* for the first impl. the driver shall return as much bytes as requested */ ret = nbyte; } return ret; }
void ErrorHook(StatusType Error) { TaskType tskid; StatusType ercd; #ifdef IOC_E_NO_DATA /* IOC_E_NO_DATAはエラーではない */ if (Error == IOC_E_NO_DATA) { return; } #endif /* IOC_E_NO_DATA */ syslog(LOG_NOTICE, "## ErrorHook is called !! (%d)", Error); ercd = GetTaskID(&tskid); if (ercd == E_OK) { syslog(LOG_NOTICE, "GetTaskID: %d", (sintptr) tskid); } else { syslog(LOG_NOTICE, "GetTaskID is unavailable."); } syslog(LOG_NOTICE, "GetISRID: %d", (sintptr) GetISRID()); syslog(LOG_NOTICE, "OSErrorGetServiceId(): %d", OSErrorGetServiceId()); return; }
/** * * @param error */ void ErrorHook( StatusType error ) { TaskType task; static struct LogBad LogBad[ERROR_LOG_SIZE]; static uint8_t ErrorCount = 0; printf("ErrorHook: %d\r\n", error); GetTaskID(&task); OsServiceIdType service = OSErrorGetServiceId(); /* Grab the arguments to the functions * This is the standard way, see 11.2 in OSEK spec */ switch(service) { case OSServiceId_SetRelAlarm: { // Read the arguments to the faulty functions... AlarmType alarm_id = OSError_SetRelAlarm_AlarmId; TickType increment = OSError_SetRelAlarm_Increment; TickType cycle = OSError_SetRelAlarm_Cycle; (void)alarm_id; (void)increment; (void)cycle; // ... Handle this some way. break; } /* * The same pattern as above applies for all other OS functions. * See Os.h for names and definitions. */ default: break; } LDEBUG_PRINTF("## ErrorHook err=%u\n",Error); /* Log the errors in a buffer for later review */ LogBad[ErrorCount].param1 = os_error.param1; LogBad[ErrorCount].param2 = os_error.param2; LogBad[ErrorCount].param3 = os_error.param3; LogBad[ErrorCount].serviceId = service; LogBad[ErrorCount].taskId = task; LogBad[ErrorCount].error = error; ErrorCount++; /* Keep compiler silent */ (void)LogBad[ErrorCount].param1; // Stall if buffer is full. while(ErrorCount >= ERROR_LOG_SIZE) { }; }
LRESULT CTDCTaskListCtrl::WindowProc(HWND hRealWnd, UINT msg, WPARAM wp, LPARAM lp) { if (!IsResyncEnabled()) return CTDCTaskCtrlBase::WindowProc(hRealWnd, msg, wp, lp); ASSERT(hRealWnd == GetHwnd()); switch (msg) { case WM_NOTIFY: { LPNMHDR pNMHDR = (LPNMHDR)lp; HWND hwnd = pNMHDR->hwndFrom; if (hwnd == m_lcTasks) { switch (pNMHDR->code) { // case NM_CLICK: // case NM_DBLCLK: // { // NMITEMACTIVATE* pNMIA = (NMITEMACTIVATE*)pNMHDR; // // if (HandleClientColumnClick(pNMIA->ptAction, (pNMHDR->code == NM_DBLCLK))) // return 0L; // eat // } // break; case LVN_BEGINLABELEDIT: // always eat this because we handle it ourselves return 1L; case LVN_GETDISPINFO: return OnListGetDispInfo((NMLVDISPINFO*)pNMHDR); case LVN_GETINFOTIP: { NMLVGETINFOTIP* pLVGIT = (NMLVGETINFOTIP*)pNMHDR; DWORD dwTaskID = GetTaskID(pLVGIT->iItem); if (dwTaskID) { #if _MSC_VER >= 1400 _tcsncpy_s(pLVGIT->pszText, pLVGIT->cchTextMax, FormatInfoTip(dwTaskID), pLVGIT->cchTextMax); #else _tcsncpy(pLVGIT->pszText, FormatInfoTip(dwTaskID), pLVGIT->cchTextMax); #endif } } break; } } } break; } return CTDCTaskCtrlBase::WindowProc(hRealWnd, msg, wp, lp); }
/* Blocks the thread while waiting for the semaphore to be signaled. If the "timeout" argument is non-zero, the thread should only be blocked for the specified time (measured in milliseconds). If the timeout argument is non-zero, the return value is the number of milliseconds spent waiting for the semaphore to be signaled. If the semaphore wasn't signaled within the specified time, the return value is SYS_ARCH_TIMEOUT. If the thread didn't have to wait for the semaphore (i.e., it was already signaled), the function may return zero. */ uint32 usb_sem_wait(semaphore *sem, uint32 timeout) { TickType StartTime, EndTime, Elapsed; irqmask im; StartTime = GetOsTick(); if( timeout != 0) { while( UsbGetSem( *sem) != E_OK ) { // Sleep(1); EndTime = GetOsTick(); Elapsed = EndTime - StartTime; if(Elapsed > timeout) { return SEM_TIMEOUT; } } EndTime = GetOsTick(); Elapsed = EndTime - StartTime; if( Elapsed == 0 ) { Elapsed = 1; } return (Elapsed); // return time blocked TBD test } else // must block without a timeout { while( UsbGetSem(*sem) != E_OK ) { TaskType TaskID; im = disable(); // int intNestCnt = OS_SYS_PTR->intNestCnt; // if(intNestCnt > 0){ // OS_SYS_PTR->intNestCnt = 0; // } GetTaskID(&TaskID); semlist_usb[*sem].task[semlist_usb[*sem].taskIndex++] = TaskID; // if(intNestCnt > 0){ // OS_SYS_PTR->intNestCnt = intNestCnt; // } restore(im); WaitEvent(semlist_usb[*sem].event); ClearEvent(semlist_usb[*sem].event); } EndTime = GetOsTick(); Elapsed = EndTime - StartTime; if( Elapsed == 0 ) { Elapsed = 1; } return ( Elapsed ); // return time blocked } }
void clDownloadTask::Progress( double TotalToDownload, double NowDownloaded, double TotalToUpload, double NowUploaded ) { tthread::lock_guard<tthread::mutex> Lock( FExitingMutex ); if ( FCallback ) { FCallback->FTaskID = GetTaskID(); FCallback->Progress( TotalToDownload, NowDownloaded, TotalToUpload, NowUploaded ); } }
extern int32_t ciaaSerialDevices_write(ciaaDevices_deviceType const * const device, uint8_t const * buf, uint32_t nbyte) { /* get serial device */ ciaaSerialDevices_deviceType * serialDevice = (ciaaSerialDevices_deviceType*) device->layer; int32_t ret = 0; int32_t total = 0; ciaaLibs_CircBufType * cbuf = &serialDevice->txBuf; int32_t head; uint32_t space; do { /* read head and space */ head = cbuf->head; space = ciaaLibs_circBufSpace(cbuf, head); /* put bytes in the queue */ ret = ciaaLibs_circBufPut(cbuf, buf, ciaaLibs_min(nbyte-total, space)); /* update total of written bytes */ total += ret; /* starts the transmission if not already ongoing */ serialDevice->device->ioctl( device->loLayer, ciaaPOSIX_IOCTL_STARTTX, NULL); /* if not all bytes could be stored in the buffer */ if (total < nbyte) { /* increment buffer */ buf += ret; /* set the task to sleep until some data have been send */ /* TODO improve this: https://github.com/ciaa/Firmware/issues/88 */ serialDevice->device->ioctl(device->loLayer, ciaaPOSIX_IOCTL_SET_ENABLE_TX_INTERRUPT, (void*)false); /* get task id and function for waking up the task later */ GetTaskID(&serialDevice->blocked.taskID); serialDevice->blocked.fct = (void*) ciaaSerialDevices_write; /* TODO improve this: https://github.com/ciaa/Firmware/issues/88 */ serialDevice->device->ioctl(device->loLayer, ciaaPOSIX_IOCTL_SET_ENABLE_TX_INTERRUPT, (void*)true); /* wait to write all data or for the txConfirmation */ #ifdef POSIXE WaitEvent(POSIXE); ClearEvent(POSIXE); #endif } } while (total < nbyte); return total; }
extern int32_t ciaaSerialDevices_read(ciaaDevices_deviceType const * const device, uint8_t * const buf, uint32_t nbyte) { /* get serial device */ ciaaSerialDevices_deviceType * serialDevice = (ciaaSerialDevices_deviceType*) device->layer; int32_t ret = 0; /* if the rx buffer is not empty */ if (!ciaaLibs_circBufEmpty(&serialDevice->rxBuf)) { /* try to read nbyte from rxBuf and store it to the user buffer */ ret = ciaaLibs_circBufGet(&serialDevice->rxBuf, buf, nbyte); } else { /* There aren't data */ if(serialDevice->flags & ciaaSerialDevices_NONBLOCK_MODE) { /* We are in non blocking mode */ /* We should do a blocking call...*/ ciaaPOSIX_errno = EAGAIN; /* shall return -1 and set errno to [EAGAIN]. */ ret = -1; } else { /* We are in blocking mode */ /* TODO improve this: https://github.com/ciaa/Firmware/issues/88 */ serialDevice->device->ioctl(device->loLayer, ciaaPOSIX_IOCTL_SET_ENABLE_RX_INTERRUPT, (void*)false); /* get task id and function for waking up the task later */ GetTaskID(&serialDevice->blocked.taskID); serialDevice->blocked.fct = (void*) ciaaSerialDevices_read; /* TODO improve this: https://github.com/ciaa/Firmware/issues/88 */ serialDevice->device->ioctl(device->loLayer, ciaaPOSIX_IOCTL_SET_ENABLE_RX_INTERRUPT, (void*)true); /* if no data wait for it */ #ifdef POSIXE WaitEvent(POSIXE); ClearEvent(POSIXE); #endif /* after the wait is not needed to check if data is avaibale on the * buffer. The event will be set first after adding some data into it */ /* try to read nbyte from rxBuf and store it to the user buffer */ ret = ciaaLibs_circBufGet(&serialDevice->rxBuf, buf, nbyte); } } return ret; }
void PreTaskHook( void ) { StatusType rv; TaskType task; TaskStateType state; printf("prehook\r\n"); rv = GetTaskID(&task); assert( rv == E_OK ); LDEBUG_PRINTF("## PreTaskHook, taskid=%d\n",task); rv = GetTaskState(task,&state); assert( rv == E_OK ); assert( state == TASK_STATE_RUNNING ); }
DWORD CTDCTaskListCtrl::HitTestTasksTask(const CPoint& ptScreen) const { // see if we hit a task in the tree CPoint ptClient(ptScreen); m_lcTasks.ScreenToClient(&ptClient); int nItem = m_lcTasks.HitTest(ptClient); if (nItem != -1) return GetTaskID(nItem); // all else return 0; }
BOOL CTDCTaskListCtrl::SelectItem(int nItem) { m_lcTasks.SetSelectionMark(nItem); m_lcColumns.SetSelectionMark(nItem); // avoid unnecessary selections if ((GetSelectedCount() == 1) && (GetSelectedItem() == nItem)) return TRUE; CDWordArray aTaskIDs; aTaskIDs.Add(GetTaskID(nItem)); return SelectTasks(aTaskIDs); }
BOOL CTDCTaskListCtrl::IsTaskSelected(DWORD dwTaskID) const { POSITION pos = m_lcTasks.GetFirstSelectedItemPosition(); while (pos) { int nItem = m_lcTasks.GetNextSelectedItem(pos); DWORD dwItemID = GetTaskID(nItem); if (dwItemID == dwTaskID) return TRUE; } // else return FALSE; }
GM_ITEMSTATE CTDCTaskListCtrl::GetListItemState(int nItem) const { if (m_lcTasks.GetItemState(nItem, LVIS_DROPHILITED) & LVIS_DROPHILITED) { return GMIS_DROPHILITED; } else if (m_lcTasks.GetItemState(nItem, LVIS_SELECTED) & LVIS_SELECTED) { DWORD dwTaskID = GetTaskID(nItem); if (HasFocus() || (dwTaskID == m_dwEditTitleTaskID)) return GMIS_SELECTED; // else return GMIS_SELECTEDNOTFOCUSED; } return GMIS_NONE; }
/*test case:test the reaction of the system called with an activation of a task*/ static void test_error_instance(void) { StatusType result_inst_1, result_inst_2, result_inst_3, result_inst_4, result_inst_5, result_inst_6; TaskType task_id; TaskStateType task_state; EventMaskType event_mask; AlarmBaseType alarm_base; TickType tik; SCHEDULING_CHECK_INIT(4); result_inst_1 = GetActiveApplicationMode(); SCHEDULING_CHECK_AND_EQUAL_INT(4,OSDEFAULTAPPMODE , result_inst_1); SCHEDULING_CHECK_INIT(5); result_inst_2 = GetTaskID(&task_id); SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(5,E_OK , result_inst_2); SCHEDULING_CHECK_AND_EQUAL_INT(5,t1 , task_id); SCHEDULING_CHECK_INIT(6); result_inst_3 = GetTaskState(task_id, &task_state); SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(6,E_OK , result_inst_3); SCHEDULING_CHECK_AND_EQUAL_INT(6,RUNNING , task_state); SCHEDULING_CHECK_INIT(7); result_inst_4 = GetEvent(task_id,&event_mask); SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(7,E_OK , result_inst_2); SCHEDULING_CHECK_AND_EQUAL_INT(7,E_OK , result_inst_2); SCHEDULING_CHECK_INIT(8); result_inst_5 = GetAlarmBase(Alarm1, &alarm_base); SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(8,OSMAXALLOWEDVALUE_Counter1, (int)(alarm_base.maxallowedvalue)); SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(8,OSTICKSPERBASE_Counter1, (int)(alarm_base.ticksperbase)); SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(8,OSMINCYCLE_Counter1, (int)(alarm_base.mincycle)); SCHEDULING_CHECK_AND_EQUAL_INT(8,E_OK , result_inst_5); SCHEDULING_CHECK_INIT(9); result_inst_6 = GetAlarm(Alarm1,&tik); SCHEDULING_CHECK_AND_EQUAL_INT(9,E_OK , result_inst_6); }
void clDownloadTask::InvokeCallback() { tthread::lock_guard<tthread::mutex> Lock( FExitingMutex ); if ( !IsPendingExit() ) { if ( FCurlCode != 0 ) { FResult = nullptr; } if ( FCallback ) { FCallback->FTaskID = GetTaskID(); FCallback->FResult = FResult; FCallback->FTask = clPtr<clDownloadTask>( this ); FCallback->FCurlCode = FCurlCode; FCallback->Invoke(); FCallback = nullptr; } } }
/*test case:test the reaction of the system called with an activation of a task*/ static void test_posttask_instance3(void) { StatusType result_inst_1, result_inst_2, result_inst_3; TaskType task_id; TaskStateType task_state; EventMaskType event_mask; SCHEDULING_CHECK_INIT(33); result_inst_1 = GetTaskID(&task_id); SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(33,t1 , task_id); SCHEDULING_CHECK_AND_EQUAL_INT(33,E_OK , result_inst_1); SCHEDULING_CHECK_INIT(34); result_inst_2 = GetTaskState(task_id, &task_state); SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(34,RUNNING , task_state); SCHEDULING_CHECK_AND_EQUAL_INT(34,E_OK , result_inst_2); SCHEDULING_CHECK_INIT(35); result_inst_3 = GetEvent(task_id,&event_mask); SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(35,Event1 , event_mask); SCHEDULING_CHECK_AND_EQUAL_INT(35,E_OK , result_inst_3); }
/*test case:test the reaction of the system called with an activation of a isr*/ static void test_isr1_instance(void) { StatusType result_inst_1, result_inst_2, result_inst_3, result_inst_5; TaskType result_inst_4; SCHEDULING_CHECK_INIT(15); result_inst_1 = TerminateTask(); SCHEDULING_CHECK_AND_EQUAL_INT(15,E_OS_CALLEVEL , result_inst_1); SCHEDULING_CHECK_INIT(16); result_inst_2 = ChainTask(t2); SCHEDULING_CHECK_AND_EQUAL_INT(16,E_OS_CALLEVEL , result_inst_2); SCHEDULING_CHECK_INIT(17); result_inst_3 = Schedule(); SCHEDULING_CHECK_AND_EQUAL_INT(17,E_OS_CALLEVEL , result_inst_3); SCHEDULING_CHECK_INIT(18); result_inst_5 = GetTaskID(&result_inst_4); SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(18,INVALID_TASK , result_inst_4); SCHEDULING_CHECK_AND_EQUAL_INT(18,E_OK , result_inst_5); }
/*test case:test the reaction of the system called with an activation of a task*/ static void test_pretask_instance3(void) { StatusType result_inst_1, result_inst_2, result_inst_3, result_inst_4, result_inst_5; TaskType task_id; TaskStateType task_state; EventMaskType event_mask; AlarmBaseType alarm_base; TickType tik; SCHEDULING_CHECK_INIT(25); result_inst_1 = GetTaskID(&task_id); SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(25,t1 , task_id); SCHEDULING_CHECK_AND_EQUAL_INT(25,E_OK , result_inst_1); SCHEDULING_CHECK_INIT(26); result_inst_2 = GetTaskState(task_id, &task_state); SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(26,RUNNING , task_state); SCHEDULING_CHECK_AND_EQUAL_INT(26,E_OK , result_inst_2); SCHEDULING_CHECK_INIT(27); result_inst_3 = GetEvent(task_id,&event_mask); SCHEDULING_CHECK_AND_EQUAL_INT(27,E_OK , result_inst_3); SCHEDULING_CHECK_INIT(28); result_inst_4 = GetAlarmBase(Alarm1, &alarm_base); SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(28,OSMAXALLOWEDVALUE_Counter1, (int)(alarm_base.maxallowedvalue)); SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(28,OSTICKSPERBASE_Counter1, (int)(alarm_base.ticksperbase)); SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(28,OSMINCYCLE_Counter1, (int)(alarm_base.mincycle)); SCHEDULING_CHECK_AND_EQUAL_INT(28,E_OK , result_inst_4); SCHEDULING_CHECK_INIT(29); result_inst_5 = GetAlarm(Alarm1,&tik); SCHEDULING_CHECK_AND_EQUAL_INT(30,E_OS_NOFUNC , result_inst_5); }
void CTDCTaskListCtrl::CacheSelection(TDCSELECTIONCACHE& cache) const { if (GetSelectedTaskIDs(cache.aSelTaskIDs, cache.dwFocusedTaskID) == 0) return; cache.dwFirstVisibleTaskID = GetTaskID(m_lcTasks.GetTopIndex()); // breadcrumbs cache.aBreadcrumbs.RemoveAll(); // cache the preceding and following 10 tasks int nFocus = GetFocusedListItem(), nItem; int nMin = 0, nMax = m_lcTasks.GetItemCount() - 1; nMin = max(nMin, nFocus - 11); nMax = min(nMax, nFocus + 11); // following tasks first for (nItem = (nFocus + 1); nItem <= nMax; nItem++) cache.aBreadcrumbs.InsertAt(0, m_lcTasks.GetItemData(nItem)); for (nItem = (nFocus - 1); nItem >= nMin; nItem--) cache.aBreadcrumbs.InsertAt(0, m_lcTasks.GetItemData(nItem)); }
void ErrorHook ( StatusType Error ) { TaskType task; static struct LogBad_s LogBad[ERROR_LOG_SIZE]; static uint8_t ErrorCount = 0; GetTaskID(&task); OsServiceIdType service = OSErrorGetServiceId(); LDEBUG_PRINTF("## ErrorHook err=%d\n",Error); /* Log the errors in a buffer for later review */ LogBad[ErrorCount].param1 = os_error.param1; LogBad[ErrorCount].param2 = os_error.param2; LogBad[ErrorCount].param3 = os_error.param3; LogBad[ErrorCount].serviceId = service; LogBad[ErrorCount].taskId = task; LogBad[ErrorCount].error = Error; ErrorCount++; // Stall if buffer is full. while(ErrorCount >= ERROR_LOG_SIZE); }
void PreTaskHook() { TaskType tid; GetTaskID(&tid); }
LRESULT CTDCTaskListCtrl::ScWindowProc(HWND hRealWnd, UINT msg, WPARAM wp, LPARAM lp) { if (!IsResyncEnabled()) return CTDCTaskCtrlBase::ScWindowProc(hRealWnd, msg, wp, lp); switch (msg) { case WM_NOTIFY: { LPNMHDR pNMHDR = (LPNMHDR)lp; HWND hwnd = pNMHDR->hwndFrom; switch (pNMHDR->code) { case HDN_ITEMCLICK: if (hwnd == m_hdrTasks) { NMHEADER* pNMH = (NMHEADER*)pNMHDR; // forward on to our parent if ((pNMH->iButton == 0) && m_hdrColumns.IsItemVisible(pNMH->iItem)) { HDITEM hdi = { HDI_LPARAM, 0 }; pNMH->pitem = &hdi; pNMH->pitem->lParam = TDCC_CLIENT; RepackageAndSendToParent(msg, wp, lp); } return 0L; } break; case TTN_NEEDTEXT: { // this has a nasty habit of redrawing the current item label // even when a tooltip is not displayed which caused any // trailing comment text to disappear, so we always invalidate // the entire item if it has comments CPoint pt(GetMessagePos()); m_lcTasks.ScreenToClient(&pt); int nItem = m_lcTasks.HitTest(pt); if (nItem != -1) { const TODOITEM* pTDI = GetTask(nItem); ASSERT(pTDI); if (!pTDI->sComments.IsEmpty()) { CRect rItem; VERIFY (m_lcTasks.GetItemRect(nItem, rItem, LVIR_BOUNDS)); m_lcTasks.InvalidateRect(rItem, FALSE); } } } break; } } break; case WM_LBUTTONDBLCLK: case WM_RBUTTONDBLCLK: case WM_RBUTTONDOWN: if (hRealWnd == m_lcTasks) { // let parent handle any focus changes first m_lcTasks.SetFocus(); // don't let the selection to be set to -1 // when clicking below the last item if (m_lcTasks.HitTest(lp) == -1) { CPoint pt(lp); ::ClientToScreen(hRealWnd, &pt); if (!::DragDetect(m_lcColumns, pt)) // we don't want to disable drag selecting { TRACE(_T("Ate Listview ButtonDown\n")); return 0; // eat it } } } break; case WM_LBUTTONDOWN: if (hRealWnd == m_lcTasks) { // let parent handle any focus changes first m_lcTasks.SetFocus(); UINT nFlags = 0; int nHit = m_lcTasks.HitTest(lp, &nFlags); if (nHit != -1) { if (Misc::ModKeysArePressed(0)) { // if the item is not selected we must first deal // with that before processing the click BOOL bHitSelected = IsListItemSelected(m_lcTasks, nHit); BOOL bSelChange = FALSE; if (!bHitSelected) bSelChange = SelectItem(nHit); // If multiple items are selected and no edit took place // Clear the selection to just the hit item if (!HandleClientColumnClick(lp, FALSE) && (GetSelectedCount() > 1)) bSelChange |= SelectItem(nHit); // Eat the msg to prevent a label edit if we changed the selection if (bSelChange) { NotifyParentSelChange(SC_BYMOUSE); return 0L; } } else if (Misc::IsKeyPressed(VK_SHIFT)) // bulk-selection { int nAnchor = m_lcTasks.GetSelectionMark(); m_lcColumns.SetSelectionMark(nAnchor); if (!Misc::IsKeyPressed(VK_CONTROL)) { DeselectAll(); } // prevent resyncing CTLSHoldResync hr(*this); // Add new items to tree and list int nHit = m_lcTasks.HitTest(lp); int nFrom = (nAnchor < nHit) ? nAnchor : nHit; int nTo = (nAnchor < nHit) ? nHit : nAnchor; for (int nItem = nFrom; nItem <= nTo; nItem++) { m_lcTasks.SetItemState(nItem, LVIS_SELECTED, LVIS_SELECTED); m_lcColumns.SetItemState(nItem, LVIS_SELECTED, LVIS_SELECTED); } NotifyParentSelChange(SC_BYMOUSE); return 0; // eat it } else if (CTDCTaskCtrlBase::HandleListLBtnDown(m_lcTasks, lp)) { return 0L; } } else if (CTDCTaskCtrlBase::HandleListLBtnDown(m_lcTasks, lp)) { return 0L; } } else { ASSERT(hRealWnd == m_lcColumns); // Selecting or de-selecting a lot of items can be slow // because OnListSelectionChange is called once for each. // Base class handles simple click de-selection so we // handle bulk selection here if (Misc::IsKeyPressed(VK_SHIFT)) // bulk-selection { int nAnchor = m_lcColumns.GetSelectionMark(); m_lcTasks.SetSelectionMark(nAnchor); if (!Misc::IsKeyPressed(VK_CONTROL)) { DeselectAll(); } // prevent resyncing CTLSHoldResync hr(*this); // Add new items to tree and list TDC_COLUMN nColID = TDCC_NONE; int nHit = HitTestColumnsItem(lp, TRUE, nColID); int nFrom = (nAnchor < nHit) ? nAnchor : nHit; int nTo = (nAnchor < nHit) ? nHit : nAnchor; for (int nItem = nFrom; nItem <= nTo; nItem++) { m_lcTasks.SetItemState(nItem, LVIS_SELECTED, LVIS_SELECTED); m_lcColumns.SetItemState(nItem, LVIS_SELECTED, LVIS_SELECTED); } NotifyParentSelChange(SC_BYMOUSE); return 0; // eat it } if (CTDCTaskCtrlBase::HandleListLBtnDown(m_lcColumns, lp)) return 0L; } break; case WM_KEYDOWN: if (Misc::IsKeyPressed(VK_SHIFT)) // bulk-selection { int nAnchor = ::SendMessage(hRealWnd, LVM_GETSELECTIONMARK, 0, 0); ::SendMessage(OtherWnd(hRealWnd), LVM_SETSELECTIONMARK, 0, nAnchor); int nFrom = -1, nTo = -1; switch (wp) { case VK_NEXT: nFrom = nAnchor; nTo = (m_lcTasks.GetTopIndex() + m_lcTasks.GetCountPerPage()); break; case VK_PRIOR: nFrom = m_lcTasks.GetTopIndex(); nTo = nAnchor; break; case VK_HOME: nFrom = 0; nTo = nAnchor; break; case VK_END: nFrom = nAnchor; nTo = (m_lcTasks.GetItemCount() - 1); break; } if ((nFrom != -1) && (nTo != -1)) { if (!Misc::IsKeyPressed(VK_CONTROL)) DeselectAll(); CTLSHoldResync hr(*this); for (int nItem = nFrom; nItem <= nTo; nItem++) { m_lcTasks.SetItemState(nItem, LVIS_SELECTED, LVIS_SELECTED); m_lcColumns.SetItemState(nItem, LVIS_SELECTED, LVIS_SELECTED); } NotifyParentSelChange(SC_BYKEYBOARD); } } break; case WM_KEYUP: { switch (wp) { case VK_NEXT: case VK_DOWN: case VK_UP: case VK_PRIOR: case VK_HOME: case VK_END: if (hRealWnd == m_lcTasks) NotifyParentSelChange(SC_BYKEYBOARD); break; case VK_LEFT: case VK_RIGHT: if (hRealWnd == m_lcTasks) { // see WM_MOUSEWHEEL comment below m_lcTasks.Invalidate(FALSE); } break; } } break; case WM_MOUSEWHEEL: // if horizontal scrolling with right-side tree we have to redraw // the full client width because Window's own optimised // scrolling creates artifacts otherwise. if (!HasVScrollBar() && HasHScrollBar(hRealWnd) && !HasStyle(TDCS_RIGHTSIDECOLUMNS)) { m_lcTasks.Invalidate(FALSE); } break; case WM_TIMER: // make sure the mouse is still over the item label because // with LVS_EX_FULLROWSELECT turned on the whole if (wp == TIMER_EDITLABEL) { if (CTreeListSyncer::HasStyle(hRealWnd, LVS_EDITLABELS, FALSE)) { const TODOITEM* pTDI = NULL; const TODOSTRUCTURE* pTDS = NULL; int nItem = GetSelectedItem(); DWORD dwTaskID = GetTaskID(nItem); if (m_data.GetTask(dwTaskID, pTDI, pTDS)) { CClientDC dc(&m_lcTasks); CFont* pOldFont = dc.SelectObject(GetTaskFont(pTDI, pTDS, FALSE)); CRect rLabel; if (GetItemTitleRect(nItem, TDCTR_LABEL, rLabel, &dc, pTDI->sTitle)) { CPoint pt(GetMessagePos()); m_lcTasks.ScreenToClient(&pt); if (rLabel.PtInRect(pt)) NotifyParentOfColumnEditClick(TDCC_CLIENT, GetSelectedTaskID()); } // cleanup dc.SelectObject(pOldFont); } } ::KillTimer(hRealWnd, wp); return 0L; // eat } break; } return CTDCTaskCtrlBase::ScWindowProc(hRealWnd, msg, wp, lp); }
void PreTaskHook ( void ) { TaskType task; GetTaskID(&task); LDEBUG_PRINTF("## PreTaskHook, taskid=%d\n",task); }
/*test case:test the reaction of the system called with an activation of a task*/ static void test_t1_instance(void) { AlarmBaseType AlarmBaseType_inst_1; EventMaskType EventMaskType_inst_1; StatusType result_inst_2, result_inst_3, result_inst_4, result_inst_5, result_inst_6, result_inst_7, result_inst_8, result_inst_9, result_inst_10, result_inst_11, result_inst_12, result_inst_13, result_inst_14, result_inst_15, result_inst_16, result_inst_17, result_inst_18, result_inst_19; TaskStateType TaskStateType_inst_1; TaskType TaskType_inst_1; TickType TickType_inst_1; SCHEDULING_CHECK_STEP(1); SCHEDULING_CHECK_STEP(2); SuspendAllInterrupts(); SCHEDULING_CHECK_INIT(3); result_inst_2 = ActivateTask(t2); SCHEDULING_CHECK_AND_EQUAL_INT(4,E_OS_DISABLEDINT, result_inst_2); SCHEDULING_CHECK_INIT(5); result_inst_3 = TerminateTask(); SCHEDULING_CHECK_AND_EQUAL_INT(6,E_OS_DISABLEDINT, result_inst_3); SCHEDULING_CHECK_INIT(7); result_inst_4 = ChainTask(t2); SCHEDULING_CHECK_AND_EQUAL_INT(8,E_OS_DISABLEDINT, result_inst_4); SCHEDULING_CHECK_INIT(9); result_inst_5 = Schedule(); SCHEDULING_CHECK_AND_EQUAL_INT(10,E_OS_DISABLEDINT, result_inst_5); SCHEDULING_CHECK_INIT(11); result_inst_6 = GetTaskID(&TaskType_inst_1); SCHEDULING_CHECK_AND_EQUAL_INT(12,E_OS_DISABLEDINT, result_inst_6); SCHEDULING_CHECK_INIT(13); result_inst_7 = GetTaskState(t2, &TaskStateType_inst_1); SCHEDULING_CHECK_AND_EQUAL_INT(14,E_OS_DISABLEDINT, result_inst_7); SCHEDULING_CHECK_INIT(15); result_inst_8 = GetResource(Resource1); SCHEDULING_CHECK_AND_EQUAL_INT(16,E_OS_DISABLEDINT, result_inst_8); SCHEDULING_CHECK_INIT(17); result_inst_9 = ReleaseResource(Resource1); SCHEDULING_CHECK_AND_EQUAL_INT(18,E_OS_DISABLEDINT, result_inst_9); SCHEDULING_CHECK_INIT(19); result_inst_10 = SetEvent(t2, Event1); SCHEDULING_CHECK_AND_EQUAL_INT(20,E_OS_DISABLEDINT, result_inst_10); SCHEDULING_CHECK_INIT(21); result_inst_11 = ClearEvent(Event1); SCHEDULING_CHECK_AND_EQUAL_INT(22,E_OS_DISABLEDINT, result_inst_11); SCHEDULING_CHECK_INIT(23); result_inst_12 = GetEvent(t2, &EventMaskType_inst_1); SCHEDULING_CHECK_AND_EQUAL_INT(24,E_OS_DISABLEDINT, result_inst_12); SCHEDULING_CHECK_INIT(25); result_inst_13 = WaitEvent(Event1); SCHEDULING_CHECK_AND_EQUAL_INT(26,E_OS_DISABLEDINT, result_inst_13); SCHEDULING_CHECK_INIT(27); result_inst_14 = GetAlarmBase(Alarm1, &AlarmBaseType_inst_1); SCHEDULING_CHECK_AND_EQUAL_INT(28,E_OS_DISABLEDINT, result_inst_14); SCHEDULING_CHECK_INIT(29); result_inst_15 = GetAlarm(Alarm1, &TickType_inst_1); SCHEDULING_CHECK_AND_EQUAL_INT(30,E_OS_DISABLEDINT, result_inst_15); SCHEDULING_CHECK_INIT(31); result_inst_16 = SetRelAlarm(Alarm1, 1, 0); SCHEDULING_CHECK_AND_EQUAL_INT(32,E_OS_DISABLEDINT, result_inst_16); SCHEDULING_CHECK_INIT(33); result_inst_17 = SetAbsAlarm(Alarm1, 1, 0); SCHEDULING_CHECK_AND_EQUAL_INT(34,E_OS_DISABLEDINT, result_inst_17); SCHEDULING_CHECK_INIT(35); result_inst_18 = CancelAlarm(Alarm1); SCHEDULING_CHECK_AND_EQUAL_INT(36,E_OS_DISABLEDINT, result_inst_18); SCHEDULING_CHECK_INIT(37); result_inst_19 = GetActiveApplicationMode(); SCHEDULING_CHECK_AND_EQUAL_INT(38,OSDEFAULTAPPMODE, result_inst_19); SCHEDULING_CHECK_STEP(39); ResumeAllInterrupts(); }
ErrorHook(StatusType Error) { ISRType ISRInError; TaskType TaskInError; /* * This code sample shows how to determine which Task or * ISR was running when the error occurred. */ ISRInError = GetISRID(); if (ISRInError != INVALID_ISR) { /* The error occurred when ISR 'ISRInError' was running */ } else { GetTaskID(&TaskInError); if (TaskInError != INVALID_TASK) { /* The error occurred when Task 'TaskInError' was running */ } else { /* The error occurred during StartOS, Os_Cbk_Idle or ShutdownOS */ } } /* * This code sample shows how to determine which error * was detected. */ switch (Error) { case E_OS_ACCESS: /* Handle E_OS_ACCESS */ break; case E_OS_CALLEVEL: /* Handle E_OS_CALLEVEL */ break; case E_OS_ID: /* Handle E_OS_ID */ break; case E_OS_LIMIT: /* Handle E_OS_LIMIT */ break; case E_OS_NOFUNC: /* Handle E_OS_NOFUNC */ break; case E_OS_RESOURCE: /* Handle E_OS_RESOURCE */ break; case E_OS_STATE: /* Handle E_OS_STATE */ break; case E_OS_VALUE: /* Handle E_OS_VALUE */ break; case E_OS_SERVICEID: /* Handle E_OS_SERVICEID */ break; case E_OS_ILLEGAL_ADDRESS: /* Handle E_OS_ILLEGAL_ADDRESS */ break; case E_OS_MISSINGEND: /* Handle E_OS_MISSINGEND */ break; case E_OS_DISABLEDINT: /* Handle E_OS_DISABLEDINT */ break; case E_OS_STACKFAULT: /* Handle E_OS_STACKFAULT */ break; case E_OS_SYS_NO_RESTART: /* Handle E_OS_SYS_NO_RESTART */ break; case E_OS_SYS_RESTART: /* Handle E_OS_SYS_RESTART */ break; case E_OS_SYS_OVERRUN: /* Handle E_OS_SYS_OVERRUN */ break; } #ifdef OSErrorGetServiceId /* * With Service ID logging enabled, it is possible to * determine which API was running when the error was * detected through OSErrorGetServiceId(). * If Parameter logging is enabled, it is also possible * to use the OSError_ macros to see the parameter * values passed to the API. */ switch (OSErrorGetServiceId()) { case OSServiceId_None: /* Handle ISR termination errors */ break; case OSServiceId_ActivateTask: /* Handle error from ActivateTask */ /* OSError_ActivateTask_TaskID() contains the TaskType 'TaskID' passed to ActivateTask */ break; case OSServiceId_Os_AdvanceCounter: /* Handle error from Os_AdvanceCounter */ /* OSError_Os_AdvanceCounter_CounterID() contains the CounterType 'CounterID' passed to Os_AdvanceCounter */ break; case OSServiceId_CancelAlarm: /* Handle error from CancelAlarm */ /* OSError_CancelAlarm_AlarmID() contains the AlarmType 'AlarmID' passed to CancelAlarm */ break; case OSServiceId_CallTrustedFunction: /* Handle error from CallTrustedFunction */ /* OSError_CallTrustedFunction_FunctionIndex() contains the TrustedFunctionIndexType 'FunctionIndex' passed to CallTrustedFunction */ /* OSError_CallTrustedFunction_FunctionParams() contains the TrustedFunctionParameterRefType 'FunctionParams' passed to CallTrustedFunction */ break; case OSServiceId_CheckISRMemoryAccess: /* Handle error from CheckISRMemoryAccess */ break; case OSServiceId_CheckObjectAccess: /* Handle error from CheckObjectAccess */ break; case OSServiceId_CheckObjectOwnership: /* Handle error from CheckObjectOwnership */ break; case OSServiceId_CheckTaskMemoryAccess: /* Handle error from CheckTaskMemoryAccess */ break; case OSServiceId_ChainTask: /* Handle error from ChainTask */ /* OSError_ChainTask_TaskID() contains the TaskType 'TaskID' passed to ChainTask */ break; case OSServiceId_ClearEvent: /* Handle error from ClearEvent */ /* OSError_ClearEvent_Mask() contains the EventMaskType 'Mask' passed to ClearEvent */ break; case OSServiceId_DisableAllInterrupts: /* Handle error from DisableAllInterrupts */ break; case OSServiceId_EnableAllInterrupts: /* Handle error from EnableAllInterrupts */ break; case OSServiceId_GetActiveApplicationMode: /* Handle error from GetActiveApplicationMode */ break; case OSServiceId_GetAlarm: /* Handle error from GetAlarm */ /* OSError_GetAlarm_AlarmID() contains the AlarmType 'AlarmID' passed to GetAlarm */ /* OSError_GetAlarm_Tick() contains the TickRefType 'Tick' passed to GetAlarm */ break; case OSServiceId_GetAlarmBase: /* Handle error from GetAlarmBase */ /* OSError_GetAlarmBase_AlarmID() contains the AlarmType 'AlarmID' passed to GetAlarmBase */ /* OSError_GetAlarmBase_Info() contains the AlarmBaseRefType 'Info' passed to GetAlarmBase */ break; case OSServiceId_GetApplicationID: /* Handle error from GetApplicationID */ break; case OSServiceId_GetCounterValue: /* Handle error from GetCounterValue */ /* OSError_GetCounterValue_CounterID() contains the CounterType 'CounterID' passed to GetCounterValue */ /* OSError_GetCounterValue_Value() contains the TickRefType 'Value' passed to GetCounterValue */ break; case OSServiceId_GetElapsedCounterValue: /* Handle error from GetElapsedCounterValue */ /* OSError_GetElapsedCounterValue_CounterID() contains the CounterType 'CounterID' passed to GetElapsedCounterValue */ /* OSError_GetElapsedCounterValue_Value() contains the TickRefType 'Value' passed to GetElapsedCounterValue */ /* OSError_GetElapsedCounterValue_ElapsedValue() contains the TickRefType 'ElapsedValue' passed to GetElapsedCounterValue */ break; case OSServiceId_GetEvent: /* Handle error from GetEvent */ /* OSError_GetEvent_TaskID() contains the TaskType 'TaskID' passed to GetEvent */ /* OSError_GetEvent_Event() contains the EventMaskRefType 'Event' passed to GetEvent */ break; case OSServiceId_GetISRID: /* Handle error from GetISRID */ break; case OSServiceId_GetResource: /* Handle error from GetResource */ /* OSError_GetResource_ResID() contains the ResourceType 'ResID' passed to GetResource */ break; case OSServiceId_GetScheduleTableStatus: /* Handle error from GetScheduleTableStatus */ /* OSError_GetScheduleTableStatus_ScheduleTableID() contains the ScheduleTableType 'ScheduleTableID' passed to GetScheduleTableStatus */ /* OSError_GetScheduleTableStatus_ScheduleStatus() contains the ScheduleTableStatusRefType 'ScheduleStatus' passed to GetScheduleTableStatus */ break; case OSServiceId_GetTaskID: /* Handle error from GetTaskID */ /* OSError_GetTaskID_TaskID() contains the TaskRefType 'TaskID' passed to GetTaskID */ break; case OSServiceId_GetTaskState: /* Handle error from GetTaskState */ /* OSError_GetTaskState_TaskID() contains the TaskType 'TaskID' passed to GetTaskState */ /* OSError_GetTaskState_State() contains the TaskStateRefType 'State' passed to GetTaskState */ break; case OSServiceId_GetVersionInfo: /* Handle error from GetVersionInfo */ break; case OSServiceId_IncrementCounter: /* Handle error from IncrementCounter */ /* OSError_IncrementCounter_CounterID() contains the CounterType 'CounterID' passed to IncrementCounter */ break; case OSServiceId_NextScheduleTable: /* Handle error from NextScheduleTable */ /* OSError_NextScheduleTable_ScheduleTableID_From() contains the ScheduleTableType 'ScheduleTableID_From' passed to NextScheduleTable */ /* OSError_NextScheduleTable_ScheduleTableID_To() contains the ScheduleTableType 'ScheduleTableID_To' passed to NextScheduleTable */ break; case OSServiceId_Os_GetExecutionTime: /* Handle error from Os_GetExecutionTime */ break; case OSServiceId_Os_GetISRMaxExecutionTime: /* Handle error from Os_GetISRMaxExecutionTime */ /* OSError_Os_GetISRMaxExecutionTime_ISRID() contains the ISRType 'ISRID' passed to Os_GetISRMaxExecutionTime */ break; case OSServiceId_Os_GetTaskMaxExecutionTime: /* Handle error from Os_GetTaskMaxExecutionTime */ /* OSError_Os_GetTaskMaxExecutionTime_TaskID() contains the TaskType 'TaskID' passed to Os_GetTaskMaxExecutionTime */ break; case OSServiceId_Os_ResetISRMaxExecutionTime: /* Handle error from Os_ResetISRMaxExecutionTime */ /* OSError_Os_ResetISRMaxExecutionTime_ISRID() contains the ISRType 'ISRID' passed to Os_ResetISRMaxExecutionTime */ break; case OSServiceId_Os_ResetTaskMaxExecutionTime: /* Handle error from Os_ResetTaskMaxExecutionTime */ /* OSError_Os_ResetTaskMaxExecutionTime_TaskID() contains the TaskType 'TaskID' passed to Os_ResetTaskMaxExecutionTime */ break; case OSServiceId_Os_GetStackUsage: /* Handle error from Os_GetStackUsage */ break; case OSServiceId_Os_GetISRMaxStackUsage: /* Handle error from Os_GetISRMaxStackUsage */ /* OSError_Os_GetISRMaxStackUsage_ISRID() contains the ISRType 'ISRID' passed to Os_GetISRMaxStackUsage */ break; case OSServiceId_Os_GetTaskMaxStackUsage: /* Handle error from Os_GetTaskMaxStackUsage */ /* OSError_Os_GetTaskMaxStackUsage_TaskID() contains the TaskType 'TaskID' passed to Os_GetTaskMaxStackUsage */ break; case OSServiceId_Os_ResetISRMaxStackUsage: /* Handle error from Os_ResetISRMaxStackUsage */ /* OSError_Os_ResetISRMaxStackUsage_ISRID() contains the ISRType 'ISRID' passed to Os_ResetISRMaxStackUsage */ break; case OSServiceId_Os_ResetTaskMaxStackUsage: /* Handle error from Os_ResetTaskMaxStackUsage */ /* OSError_Os_ResetTaskMaxStackUsage_TaskID() contains the TaskType 'TaskID' passed to Os_ResetTaskMaxStackUsage */ break; case OSServiceId_ReleaseResource: /* Handle error from ReleaseResource */ /* OSError_ReleaseResource_ResID() contains the ResourceType 'ResID' passed to ReleaseResource */ break; case OSServiceId_Restart: /* Handle error from Restart */ break; case OSServiceId_ResumeAllInterrupts: /* Handle error from ResumeAllInterrupts */ break; case OSServiceId_ResumeOSInterrupts: /* Handle error from ResumeOSInterrupts */ break; case OSServiceId_Schedule: /* Handle error from Schedule */ break; case OSServiceId_SetEvent: /* Handle error from SetEvent */ /* OSError_SetEvent_TaskID() contains the TaskType 'TaskID' passed to SetEvent */ /* OSError_SetEvent_Mask() contains the EventMaskType 'Mask' passed to SetEvent */ break; case OSServiceId_SetAbsAlarm: /* Handle error from SetAbsAlarm */ /* OSError_SetAbsAlarm_AlarmID() contains the AlarmType 'AlarmID' passed to SetAbsAlarm */ /* OSError_SetAbsAlarm_start() contains the TickType 'start' passed to SetAbsAlarm */ /* OSError_SetAbsAlarm_cycle() contains the TickType 'cycle' passed to SetAbsAlarm */ break; case OSServiceId_SetRelAlarm: /* Handle error from SetRelAlarm */ /* OSError_SetRelAlarm_AlarmID() contains the AlarmType 'AlarmID' passed to SetRelAlarm */ /* OSError_SetRelAlarm_increment() contains the TickType 'increment' passed to SetRelAlarm */ /* OSError_SetRelAlarm_cycle() contains the TickType 'cycle' passed to SetRelAlarm */ break; case OSServiceId_SetRestartPoint: /* Handle error from SetRestartPoint */ break; case OSServiceId_ShutdownOS: /* Handle error from ShutdownOS */ break; case OSServiceId_StartOS: /* Handle error from StartOS */ break; case OSServiceId_StartScheduleTableAbs: /* Handle error from StartScheduleTableAbs */ /* OSError_StartScheduleTableAbs_ScheduleTableID() contains the ScheduleTableType 'ScheduleTableID' passed to StartScheduleTableAbs */ /* OSError_StartScheduleTableAbs_Start() contains the TickType 'Start' passed to StartScheduleTableAbs */ break; case OSServiceId_StartScheduleTableRel: /* Handle error from StartScheduleTableRel */ /* OSError_StartScheduleTableRel_ScheduleTableID() contains the ScheduleTableType 'ScheduleTableID' passed to StartScheduleTableRel */ /* OSError_StartScheduleTableRel_Offset() contains the TickType 'Offset' passed to StartScheduleTableRel */ break; case OSServiceId_StartScheduleTableSynchron: /* Handle error from StartScheduleTableSynchron */ /* OSError_StartScheduleTableSynchron_ScheduleTableID() contains the ScheduleTableType 'ScheduleTableID' passed to StartScheduleTableSynchron */ break; case OSServiceId_SyncScheduleTable: /* Handle error from SyncScheduleTable */ /* OSError_SyncScheduleTable_ScheduleTableID() contains the ScheduleTableType 'ScheduleTableID' passed to SyncScheduleTable */ /* OSError_SyncScheduleTable_Value() contains the TickType 'Value' passed to SyncScheduleTable */ break; case OSServiceId_SetScheduleTableAsync: /* Handle error from SetScheduleTableAsync */ /* OSError_SetScheduleTableAsync_ScheduleTableID() contains the ScheduleTableType 'ScheduleTableID' passed to SetScheduleTableAsync */ break; case OSServiceId_StopScheduleTable: /* Handle error from StopScheduleTable */ /* OSError_StopScheduleTable_ScheduleTableID() contains the ScheduleTableType 'ScheduleTableID' passed to StopScheduleTable */ break; case OSServiceId_SuspendAllInterrupts: /* Handle error from SuspendAllInterrupts */ break; case OSServiceId_SuspendOSInterrupts: /* Handle error from SuspendOSInterrupts */ break; case OSServiceId_TerminateApplication: /* Handle error from TerminateApplication */ /* OSError_TerminateApplication_RestartOption() contains the RestartType 'RestartOption' passed to TerminateApplication */ break; case OSServiceId_TerminateTask: /* Handle error from TerminateTask */ break; case OSServiceId_WaitEvent: /* Handle error from WaitEvent */ /* OSError_WaitEvent_Mask() contains the EventMaskType 'Mask' passed to WaitEvent */ break; } #endif /* OSErrorGetServiceId */ }
void PostTaskHook(void) { static uint8 count = 0; StatusType ret; TaskType TaskID; TaskStateType TaskState; switch (count) { case 0: /* increment post task hook call count */ count++; Sequence(5); /* \treq EH_04 nmf B1B2E1E2 se Check PreTaskHook/PostTaskHook: * Force rescheduling * * \result PreTaskHook is called before executing the new task, * but after the transition to running state. PostTaskHook is called * after existing the current task but before leaving the task's * running state. */ ret = GetTaskID(&TaskID); ASSERT(EH_04, ret != E_OK); ASSERT(EH_04, TaskID != Task1); Sequence(6); ret = GetTaskState(Task1, &TaskState); ASSERT(OTHER, ret != E_OK); ASSERT(OTHER, TaskState != RUNNING); Sequence(7); ret = GetTaskState(Task2, &TaskState); ASSERT(OTHER, ret != E_OK); ASSERT(OTHER, TaskState != READY); break; case 1: /* increment post task hook call count */ count++; Sequence(14); /* \treq EH_04 nmf B1B2E1E2 se Check PreTaskHook/PostTaskHook: * Force rescheduling * * \result PreTaskHook is called before executing the new task, * but after the transition to running state. PostTaskHook is called * after existing the current task but before leaving the task's * running state. */ ret = GetTaskID(&TaskID); ASSERT(EH_04, ret != E_OK); ASSERT(EH_04, TaskID != Task2); Sequence(15); ret = GetTaskState(Task1, &TaskState); ASSERT(OTHER, ret != E_OK); ASSERT(OTHER, TaskState != READY); Sequence(16); ret = GetTaskState(Task2, &TaskState); ASSERT(OTHER, ret != E_OK); ASSERT(OTHER, TaskState != RUNNING); break; case 2: /* increment post task hook call count */ count++; Sequence(21); /* \treq EH_04 nmf B1B2E1E2 se Check PreTaskHook/PostTaskHook: * Force rescheduling * * \result PreTaskHook is called before executing the new task, * but after the transition to running state. PostTaskHook is called * after existing the current task but before leaving the task's * running state. */ ret = GetTaskID(&TaskID); ASSERT(EH_04, ret != E_OK); ASSERT(EH_04, TaskID != Task1); Sequence(22); ret = GetTaskState(Task1, &TaskState); ASSERT(OTHER, ret != E_OK); ASSERT(OTHER, TaskState != RUNNING); Sequence(23); ret = GetTaskState(Task2, &TaskState); ASSERT(OTHER, ret != E_OK); ASSERT(OTHER, TaskState != SUSPENDED); Sequence(24); /* evaluate conformance tests */ ConfTestEvaluation(); /* finish the conformance test */ ConfTestFinish(); break; default: while(1); break; } }
FUNC(void, OS_CODE) PreTaskHook(void) { switch_count++; GetTaskID(&new_task); }
/* Error hook for all tests * * $Req: artf1222 $ */ void ErrorHook(StatusType rc) { #ifdef USEERRORHOOK #ifdef EXPECTSERRORS TaskType from_task; ISRType from_isr; TaskStateType state; if(in_error_hook) { test_failed(OS_HERE); /* Error hook not permitted to be called recursively $Req: artf1112 $ */ } in_error_hook = 1U; SET_TESTEVENT("ErrorHook"); #ifdef OS_EXTENDED_STATUS /* Test for recursive error hook call by making a legal call which generates an error */ GetTaskState(0, &state); #endif /* $Req: artf1140 $ */ GetTaskID(&from_task); from_isr = GetISRID(); if(from_isr == INVALID_ISR) { if(from_task == INVALID_TASK) { SET_TESTEVENT("<No runnable>"); /* Not sure how to get an error hook called if no task or ISR running.. */ } else { /* Must be a task that caused the error hook to run since there is no ISR running */ #ifdef INCLUDE_HANDLE_NAME_MAP SET_TESTEVENT(TaskType2string(from_task)); #else SET_TESTEVENT("<A task>"); #endif /* ErrorHook() should be called with cat2 interrupts locked. * * $Req: artf1110 $ * * Following code will trigger the cat2 ISR here but it should not actually run. Dismiss it immediately. * * Only do this if the error hook is called from outside an ISR because otherwise this would mess up * the only cat2 ISR. In mosts tests the ISR running is logged, and this would cause the test to fail * because there should be no expect ISR log entries at this point. */ testing_trigger_isr(); testing_dismiss_isr(); } } else { /* An ISR must be running; this takes precedence over a task: the error must have * been raised in the ISR since the task can't be running (all ISRs have higher priorities * than all tasks) */ #ifdef INCLUDE_HANDLE_NAME_MAP SET_TESTEVENT(ISRType2string(from_isr)); #else SET_TESTEVENT("<An ISR>"); #endif } /* If E_OS_MISSING end called then the task is still valid and still RUNNING when the error hook called */ if(rc == E_OS_MISSINGEND) { /* $Req: artf1041 $ */ if(from_task == INVALID_TASK) { test_failed(OS_HERE); } else { GetTaskState(from_task, &state); if(state != RUNNING) { test_failed(OS_HERE); } } } /* OSErrorGetServiceId() callable from ErrorHook() * * $Req: artf1114 $ * $Req: artf1228 $ */ SET_TESTEVENT(OSServiceIdType2string(OSErrorGetServiceId(), "<Unknown service ID>")); SET_TESTEVENT(StatusType2string(rc, "<Unknown StatusType code>")); set_error_hook_parameters(OSErrorGetServiceId()); in_error_hook = 0U; #else /* don't expect errors */ test_failed(OS_HERE); #endif #else /* don't use error hook * * $Req: artf1223 $ */ test_failed(OS_HERE); #endif }