diff --git a/miosix/kernel/error.cpp b/miosix/kernel/error.cpp index 0b55433e3a77617a422db49fe4fb94104cc78262..173c322933cf22947d4e11321ad9fbd7a5fd12db 100644 --- a/miosix/kernel/error.cpp +++ b/miosix/kernel/error.cpp @@ -41,21 +41,8 @@ void errorHandler(Error e) bool interrupts=areInterruptsEnabled(); if(interrupts) disableInterrupts(); - bool isUnrecoverable=false; - //Recoverable errors - switch(e) - { - case INVALID_PARAMETERS: - IRQerrorLog("\r\n***Invalid parameter\r\n"); - break; - case PROPAGATED_EXCEPTION: - IRQerrorLog("\r\n***An exception propagated through a thread\r\n"); - break; - case MUTEX_UNLOCK_NOT_OWNER: - IRQerrorLog("\r\n***unlock() called on a non locked mutex\r\n"); - default: - isUnrecoverable=true; - } + //Recoverable errors: None + //Unrecoverable errors switch(e) { @@ -87,15 +74,9 @@ void errorHandler(Error e) default: break; } - if(isUnrecoverable) - { - #if _BOARD_SONY_NEWMAN - IRQerrorMarker(e+1); - #endif //_BOARD_SONY_NEWMAN - miosix_private::IRQsystemReboot(); - } + miosix_private::IRQsystemReboot(); - if(interrupts) enableInterrupts(); + //if(interrupts) enableInterrupts(); // Not needed since no recoverable errors } } //namespace miosix diff --git a/miosix/kernel/error.h b/miosix/kernel/error.h index 1d61022cf7c1388a29689ed90528b812c3c2db23..2273e78c6b57eb4be623f312188f55401840f503 100644 --- a/miosix/kernel/error.h +++ b/miosix/kernel/error.h @@ -37,12 +37,7 @@ namespace miosix { */ enum Error { - /// A function/method was called with invalid parameters.<br> - /// Error is recoverable. - INVALID_PARAMETERS, - - /// The heap is full, malloc/new returned NULL.<br> - /// Whether error is recoverable is architecture specific. + /// The heap is full, malloc/new returned NULL.<br>Error is UNRECOVERABLE OUT_OF_MEMORY, /// The stack of a thread overflowed.<br>Error is UNRECOVERABLE @@ -63,20 +58,12 @@ enum Error /// Error is UNRECOVERABLE MUTEX_DEADLOCK, - /// An attempt to call unlock() on a mutex without first calling lock - /// has been detected. - MUTEX_UNLOCK_NOT_OWNER, - /// The calls to pauseKernel or disableInterrupts were nested too ///much. Error is UNRECOVERABLE NESTING_OVERFLOW, - /// An uncaught exception propagated throug a thread's entry point. - /// Error is recoverable. - PROPAGATED_EXCEPTION, - /// Interrupts are wrongly enabled during boot - /// Error is unrecoverable + /// Error is UNRECOVERABLE INTERRUPTS_ENABLED_AT_BOOT }; diff --git a/miosix/kernel/kernel.cpp b/miosix/kernel/kernel.cpp index 0e01cebcce6c42abc4e6e0f244b26fbcb2927096..cdaf29bd3671dcf542812be7c50cfec4e07b6bd4 100644 --- a/miosix/kernel/kernel.cpp +++ b/miosix/kernel/kernel.cpp @@ -294,11 +294,7 @@ Thread *Thread::create(void *(*startfunc)(void *), unsigned int stacksize, Priority priority, void *argv, unsigned short options) { //Check to see if input parameters are valid - if(priority.validate()==false || stacksize<STACK_MIN) - { - errorHandler(INVALID_PARAMETERS); - return NULL; - } + if(priority.validate()==false || stacksize<STACK_MIN) return NULL; Thread *thread=doCreate(startfunc,stacksize,argv,options,false); if(thread==NULL) return NULL; @@ -399,7 +395,7 @@ Priority Thread::getPriority() void Thread::setPriority(Priority pr) { - if(pr.validate()==false) errorHandler(INVALID_PARAMETERS); + if(pr.validate()==false) return; PauseKernelLock lock; Thread *current=getCurrentThread(); @@ -657,13 +653,11 @@ void Thread::threadLauncher(void *(*threadfunc)(void*), void *argv) #else //__NO_EXCEPTIONS try { result=threadfunc(argv); - } catch(std::exception& e) - { - errorHandler(PROPAGATED_EXCEPTION); + } catch(std::exception& e) { + errorLog("***An exception propagated through a thread\n"); errorLog("what():%s\n",e.what()); - } catch(...) - { - errorHandler(PROPAGATED_EXCEPTION); + } catch(...) { + errorLog("***An exception propagated through a thread\n"); } #endif //__NO_EXCEPTIONS //Thread returned from its entry point, so delete it diff --git a/miosix/kernel/kernel.h b/miosix/kernel/kernel.h index d7d258efaf349a0f5b81eb2e11fcf4c926c99b27..41b7990562715152f01d60833992b4eacc887dd3 100644 --- a/miosix/kernel/kernel.h +++ b/miosix/kernel/kernel.h @@ -440,8 +440,7 @@ public: * \return a reference to the thread created, that can be used, for example, * to delete it, or NULL in case of errors. * - * Calls errorHandler(INVALID_PARAMETERS) if stacksize or priority are - * invalid. Can be called when the kernel is paused. + * Can be called when the kernel is paused. */ static Thread *create(void *(*startfunc)(void *), unsigned int stacksize, Priority priority=Priority(), void *argv=NULL, @@ -564,8 +563,6 @@ public: * another thread. * \param pr desired priority. Must be 0<=pr<PRIORITY_MAX * - * Calls errorHandler(INVALID_PARAMETERS) if pr is not within bounds. - * * Can be called when the kernel is paused. */ static void setPriority(Priority pr); diff --git a/miosix/kernel/pthread_private.h b/miosix/kernel/pthread_private.h index 6a1d1cee44e8ab8fa5a8f7102947e7b75fdc1e33..54c47156eb090230f1d396df94b43da947d00520 100644 --- a/miosix/kernel/pthread_private.h +++ b/miosix/kernel/pthread_private.h @@ -158,10 +158,7 @@ static inline bool IRQdoMutexUnlock(pthread_mutex_t *mutex) { // Safety check removed for speed reasons // if(mutex->owner!=reinterpret_cast<void*>(Thread::IRQgetCurrentThread())) -// { -// errorHandler(MUTEX_UNLOCK_NOT_OWNER); // return false; -// } if(mutex->recursive>0) { mutex->recursive--; @@ -197,10 +194,7 @@ static inline unsigned int IRQdoMutexUnlockAllDepthLevels(pthread_mutex_t *mutex { // Safety check removed for speed reasons // if(mutex->owner!=reinterpret_cast<void*>(Thread::IRQgetCurrentThread())) -// { -// errorHandler(MUTEX_UNLOCK_NOT_OWNER); // return false; -// } if(mutex->first!=0) { Thread *t=reinterpret_cast<Thread*>(mutex->first->thread); diff --git a/miosix/kernel/stage_2_boot.cpp b/miosix/kernel/stage_2_boot.cpp index 7ec0676e8a04396c05aa49bb3f6cec7ab55335e4..bd9b070b1f9c88126334583f524ed8ff10f49574 100644 --- a/miosix/kernel/stage_2_boot.cpp +++ b/miosix/kernel/stage_2_boot.cpp @@ -98,13 +98,11 @@ void *mainLoader(void *argv) #else //__NO_EXCEPTIONS try { main(0,NULL); - } catch(std::exception& e) - { - errorHandler(PROPAGATED_EXCEPTION); + } catch(std::exception& e) { + errorLog("***An exception propagated through a thread\n"); errorLog("what():%s\n",e.what()); - } catch(...) - { - errorHandler(PROPAGATED_EXCEPTION); + } catch(...) { + errorLog("***An exception propagated through a thread\n"); } #endif //__NO_EXCEPTIONS diff --git a/miosix/kernel/sync.cpp b/miosix/kernel/sync.cpp index 42e6302dce206feb5d51e3872882a0afa45a236f..4f076a741b3d5be416fdb704fac8c25480effbca 100644 --- a/miosix/kernel/sync.cpp +++ b/miosix/kernel/sync.cpp @@ -209,11 +209,7 @@ bool Mutex::PKtryLock(PauseKernelLock& dLock) bool Mutex::PKunlock(PauseKernelLock& dLock) { Thread *p=Thread::getCurrentThread(); - if(owner!=p) - { - errorHandler(MUTEX_UNLOCK_NOT_OWNER); - return false; - } + if(owner!=p) return false; if(recursiveDepth>0) { @@ -290,11 +286,7 @@ bool Mutex::PKunlock(PauseKernelLock& dLock) unsigned int Mutex::PKunlockAllDepthLevels(PauseKernelLock& dLock) { Thread *p=Thread::getCurrentThread(); - if(owner!=p) - { - errorHandler(MUTEX_UNLOCK_NOT_OWNER); - return 0; - } + if(owner!=p) return 0; //Remove this mutex from the list of mutexes locked by the owner if(owner->mutexLocked==this)