\r
typedef uint8 StatusType;\r
\r
+#if (OS_ISR_CNT > OS_ISR_MAX_CNT)\r
+#error OS configuration error. OS_ISR_MAX_CNT must be bigger or equal to OS_ISR_CNT\r
+#endif\r
+\r
#define E_OS_ACCESS (StatusType)1 /**< STD OSEK */\r
#define E_OS_CALLEVEL (StatusType)2 /**< STD OSEK */\r
#define E_OS_ID (StatusType)3 /**< STD OSEK */\r
#include "isr.h"\r
#include "irq.h"\r
\r
+#define ILL_VECTOR 0xff\r
\r
extern uint8_t Os_VectorToIsr[NUMBER_OF_INTERRUPTS_AND_EXCEPTIONS];\r
#if OS_ISR_CNT!=0\r
\r
Irq_Init();\r
\r
+ /* Probably something smarter, but I cant figure out what */\r
+ memset(&Os_VectorToIsr[OS_ISR_CNT],ILL_VECTOR,OS_ISR_MAX_CNT-OS_ISR_CNT);\r
+\r
#if OS_ISR_CNT != 0\r
/* Attach the interrupts */\r
for (int i = 0; i < Os_Sys.isrCnt; i++) {\r
#endif\r
}\r
\r
-\r
/**\r
* Adds an ISR to a list of Isr's. The ISRType (id) is returned\r
* for the "created" ISR.\r
*/\r
ISRType Os_IsrAdd( const OsIsrConstType * restrict isrPtr ) {\r
ISRType id;\r
+ ISRType installedId;\r
\r
assert( isrPtr != NULL );\r
+ assert( (isrPtr->vector + IRQ_INTERRUPT_OFFSET) < NUMBER_OF_INTERRUPTS_AND_EXCEPTIONS );\r
\r
- id = Os_Sys.isrCnt++;\r
- Os_IsrVarList[id].constPtr = isrPtr;\r
- Os_VectorToIsr[isrPtr->vector + IRQ_INTERRUPT_OFFSET ] = id;\r
- Irq_EnableVector( isrPtr->vector, isrPtr->priority, Os_ApplGetCore(isrPtr->appOwner ) );\r
+ /* Check if we already have installed it */\r
+ installedId = Os_VectorToIsr[isrPtr->vector + IRQ_INTERRUPT_OFFSET ];\r
+\r
+ if( installedId != ILL_VECTOR ) {\r
+ /* The vector is already installed */\r
+ id = installedId;\r
+ } else {\r
+ /* It a new vector */\r
+ id = Os_Sys.isrCnt++;\r
+ /* Since OS_ISR_MAX_CNT defines the allocation limit for Os_IsrVarList,\r
+ * we must not allocate more IDs than that */\r
+ assert(id<OS_ISR_MAX_CNT);\r
+\r
+ Os_IsrVarList[id].constPtr = isrPtr;\r
+ Os_VectorToIsr[isrPtr->vector + IRQ_INTERRUPT_OFFSET ] = id;\r
+ Irq_EnableVector( isrPtr->vector, isrPtr->priority, Os_ApplGetCore(isrPtr->appOwner ) );\r
+ }\r
\r
return id;\r
}\r