| 3a4 |
| > #include <stdlib.h>
|
| 5c6 |
| < #define CyclesForTick (configCPU_CLOCK_HZ/configTICK_RATE_HZ - 50)
|
| --- |
| > #include "debugFlags.h"
|
| 6a8,10 |
| > #define CyclesForTick (configCPU_CLOCK_HZ/configTICK_RATE_HZ - 50)
|
| > //debugging
|
| > //TODO core to core comms will use this
|
| 8,10c12,14 |
| <
|
| < /*-----------------------------------------------------------*/
|
| <
|
| --- |
| > //---------------------------------------------------
|
| > int globalDelta;
|
| > //---------------------------------------------------
|
| 16d19 |
| <
|
| 18d20 |
| <
|
| 32c34,35 |
| < StackType_t *pxStackStart;
|
| --- |
| > StackType_t *pxStackStart;
|
| >
|
| 34,38c37,40 |
| <
|
| < //align to double-word boundary
|
| < pxStackStart = (StackType_t *)(( StackType_t ) pxTopOfStack & ~(0x4));
|
| <
|
| < /* To ensure asserts in tasks.c don't fail, although in this case the assert
|
| --- |
| > //align to double-word boundary
|
| > pxStackStart = (StackType_t *)(( StackType_t ) pxTopOfStack & ~(0x4));
|
| >
|
| > /* To ensure asserts in tasks.c don't fail, although in this case the assert
|
| 40c42 |
| < pxTopOfStack--;
|
| --- |
| > pxTopOfStack--;
|
| 42,43c44,45 |
| < /* for alignment */
|
| < pxTopOfStack--;
|
| --- |
| > /* for alignment */
|
| > pxTopOfStack--;
|
| 45c47 |
| < /* Setup the initial stack of the task. The stack is set exactly as
|
| --- |
| > /* Setup the initial stack of the task. The stack is set exactly as
|
| 48c50 |
| < /* First on the stack is the return address - which in this case is the
|
| --- |
| > /* First on the stack is the return address - which in this case is the
|
| 51,94c53,96 |
| < *pxTopOfStack = ( StackType_t ) 0xdeadaffe;
|
| < pxTopOfStack--;
|
| < pxTopOfStack--;
|
| < pxTopOfStack--;
|
| <
|
| <
|
| < int i;
|
| <
|
| < for(i=63;i>14;i--) {
|
| < *pxTopOfStack = ( StackType_t ) i<<8; /* higher registers */
|
| < pxTopOfStack--;
|
| < }
|
| <
|
| <
|
| < *pxTopOfStack = ( StackType_t ) 0xaaaaaaaa; /* R14 */
|
| < pxTopOfStack--;
|
| < *pxTopOfStack = ( StackType_t ) 0x51aac4de; /* Stack used when task starts goes in R13. */
|
| < pxStackStart = pxTopOfStack;
|
| < pxTopOfStack--;
|
| < *pxTopOfStack = ( StackType_t ) 0x12121212; /* R12 */
|
| < pxTopOfStack--;
|
| < *pxTopOfStack = ( StackType_t ) 0x11111111; /* R11 */
|
| < //*pxTopOfStack = ( StackType_t ) pxOriginalTOS; /* frame pointer to stack address. */
|
| < pxTopOfStack--;
|
| < *pxTopOfStack = ( StackType_t ) 0x10101010; /* R10 */
|
| < pxTopOfStack--;
|
| < *pxTopOfStack = ( StackType_t ) 0x09090909; /* R9 */
|
| < pxTopOfStack--;
|
| < *pxTopOfStack = ( StackType_t ) 0x08080808; /* R8 */
|
| < pxTopOfStack--;
|
| < *pxTopOfStack = ( StackType_t ) 0x07070707; /* R7 */
|
| < pxTopOfStack--;
|
| < *pxTopOfStack = ( StackType_t ) 0x06060606; /* R6 */
|
| < pxTopOfStack--;
|
| < *pxTopOfStack = ( StackType_t ) 0x05050505; /* R5 */
|
| < pxTopOfStack--;
|
| < *pxTopOfStack = ( StackType_t ) 0x04040404; /* R4 */
|
| < pxTopOfStack--;
|
| < *pxTopOfStack = ( StackType_t ) 0x03030303; /* R3 */
|
| < pxTopOfStack--;
|
| < *pxTopOfStack = ( StackType_t ) 0x02020202; /* R2 */
|
| < pxTopOfStack--;
|
| < *pxTopOfStack = ( StackType_t ) 0x01010101; /* R1 */
|
| < pxTopOfStack--;
|
| --- |
| > *pxTopOfStack = ( StackType_t ) 0xdeadaffe;
|
| > pxTopOfStack--;
|
| > pxTopOfStack--;
|
| > pxTopOfStack--;
|
| >
|
| >
|
| > int i;
|
| >
|
| > for(i=63;i>14;i--) {
|
| > *pxTopOfStack = ( StackType_t ) i<<8; /* higher registers */
|
| > pxTopOfStack--;
|
| > }
|
| >
|
| >
|
| > *pxTopOfStack = ( StackType_t ) 0xaaaaaaaa; /* R14 */
|
| > pxTopOfStack--;
|
| > *pxTopOfStack = ( StackType_t ) 0x51aac4de; /* Stack used when task starts goes in R13. */
|
| > pxStackStart = pxTopOfStack;
|
| > pxTopOfStack--;
|
| > *pxTopOfStack = ( StackType_t ) 0x12121212; /* R12 */
|
| > pxTopOfStack--;
|
| > *pxTopOfStack = ( StackType_t ) 0x11111111; /* R11 */
|
| > //*pxTopOfStack = ( StackType_t ) pxOriginalTOS; /* frame pointer to stack address. */
|
| > pxTopOfStack--;
|
| > *pxTopOfStack = ( StackType_t ) 0x10101010; /* R10 */
|
| > pxTopOfStack--;
|
| > *pxTopOfStack = ( StackType_t ) 0x09090909; /* R9 */
|
| > pxTopOfStack--;
|
| > *pxTopOfStack = ( StackType_t ) 0x08080808; /* R8 */
|
| > pxTopOfStack--;
|
| > *pxTopOfStack = ( StackType_t ) 0x07070707; /* R7 */
|
| > pxTopOfStack--;
|
| > *pxTopOfStack = ( StackType_t ) 0x06060606; /* R6 */
|
| > pxTopOfStack--;
|
| > *pxTopOfStack = ( StackType_t ) 0x05050505; /* R5 */
|
| > pxTopOfStack--;
|
| > *pxTopOfStack = ( StackType_t ) 0x04040404; /* R4 */
|
| > pxTopOfStack--;
|
| > *pxTopOfStack = ( StackType_t ) 0x03030303; /* R3 */
|
| > pxTopOfStack--;
|
| > *pxTopOfStack = ( StackType_t ) 0x02020202; /* R2 */
|
| > pxTopOfStack--;
|
| > *pxTopOfStack = ( StackType_t ) 0x01010101; /* R1 */
|
| > pxTopOfStack--;
|
| 96c98 |
| < /* When the task starts is will expect to find the function parameter in
|
| --- |
| > /* When the task starts is will expect to find the function parameter in
|
| 98,103c100,103 |
| < *pxTopOfStack-- = ( StackType_t ) pvParameters; /* R0 */
|
| <
|
| < // second last thing: program counter, no normal register on epiphany!
|
| < *pxTopOfStack-- = ( StackType_t ) pxCode; /* Stack used when task starts goes in R13. */
|
| <
|
| <
|
| --- |
| > *pxTopOfStack-- = ( StackType_t ) pvParameters; /* R0 */
|
| >
|
| > // second last thing: program counter, no normal register on epiphany!
|
| > *pxTopOfStack-- = ( StackType_t ) pxCode; /* Stack used when task starts goes in R13. */
|
| 105c105,107 |
| < /* The last thing onto the stack is the status register, which is set for
|
| --- |
| >
|
| >
|
| > /* The last thing onto the stack is the status register, which is set for
|
| 107c109,110 |
| < *pxTopOfStack = ( StackType_t ) 0x03;
|
| --- |
| > *pxTopOfStack = ( StackType_t ) 0x03;
|
| >
|
| 109d111 |
| <
|
| 111c113 |
| < /* Some optimisation levels use the stack differently to others. This
|
| --- |
| > /* Some optimisation levels use the stack differently to others. This
|
| 115,117c117,119 |
| < //*pxTopOfStack = 0;
|
| < //return pxOriginalTOS;
|
| < return pxTopOfStack;
|
| --- |
| > //*pxTopOfStack = 0;
|
| > //return pxOriginalTOS;
|
| > return pxTopOfStack;
|
| 120c122 |
| <
|
| --- |
| > /*-----THE PROBLEM FUNCTION---------------*/
|
| 122c124 |
| < unsigned memprotectregister = e_reg_read(E_REG_MEMPROTECT);
|
| --- |
| > unsigned memprotectregister = e_reg_read(E_REG_MEMPROTECT);
|
| 124,127c126,129 |
| < //clear last 8 bits
|
| < memprotectregister &= 0xffffff00;
|
| < //sets it to the specified value
|
| < memprotectregister |= mask;
|
| --- |
| > //clear last 8 bits
|
| > memprotectregister &= 0xffffff00;
|
| > //sets it to the specified value
|
| > memprotectregister |= mask;
|
| 129c131 |
| < e_reg_write(E_REG_MEMPROTECT, memprotectregister);
|
| --- |
| > e_reg_write(E_REG_MEMPROTECT, memprotectregister);
|
| 131c133 |
| <
|
| --- |
| > /*-----------------------------------------------------------*/
|
| 140,141c142,143 |
| < e_irq_attach(E_USER_INT, handlers[E_USER_INT]);
|
| < e_irq_mask(E_USER_INT, E_FALSE);
|
| --- |
| > e_irq_attach(E_USER_INT, handlers[E_USER_INT]);
|
| > e_irq_mask(E_USER_INT, E_FALSE);
|
| 143,144c145,146 |
| < e_irq_attach(E_TIMER0_INT, handlers[E_TIMER0_INT]);
|
| < e_irq_mask(E_TIMER0_INT, E_FALSE);
|
| --- |
| > e_irq_attach(E_TIMER0_INT, handlers[E_TIMER0_INT]);
|
| > e_irq_mask(E_TIMER0_INT, E_FALSE);
|
| 146,147c148,149 |
| < e_irq_attach(E_MEM_FAULT, handlers[E_MEM_FAULT]);
|
| < e_irq_mask(E_MEM_FAULT, E_FALSE);
|
| --- |
| > e_irq_attach(E_MEM_FAULT, handlers[E_MEM_FAULT]);
|
| > e_irq_mask(E_MEM_FAULT, E_FALSE);
|
| 149,150c151,152 |
| < e_irq_attach(E_SW_EXCEPTION, handlers[E_SW_EXCEPTION]);
|
| < e_irq_mask(E_SW_EXCEPTION, E_FALSE);
|
| --- |
| > e_irq_attach(E_SW_EXCEPTION, handlers[E_SW_EXCEPTION]);
|
| > e_irq_mask(E_SW_EXCEPTION, E_FALSE);
|
| 152,153c154,155 |
| < e_irq_attach(E_MESSAGE_INT, handlers[E_MESSAGE_INT]);
|
| < e_irq_mask(E_MESSAGE_INT, E_FALSE);
|
| --- |
| > e_irq_attach(E_MESSAGE_INT, handlers[E_MESSAGE_INT]);
|
| > e_irq_mask(E_MESSAGE_INT, E_FALSE);
|
| 155c157,159 |
| < setMemprotectMask(0x0f);
|
| --- |
| > vSetupTimer();
|
| > //condition left for debugging
|
| > if(globalDelta == 0){
|
| 157c161 |
| < vSetupTimer();
|
| --- |
| > }else{
|
| 158a163 |
| > }
|
| 161d165 |
| <
|
| 170c174 |
| < e_irq_mask(E_TIMER1_INT, E_TRUE);
|
| --- |
| > e_irq_mask(E_TIMER1_INT, E_TRUE);
|
| 180,184c184,188 |
| < // There seems to be no working software interrupt, so we send a user-interrupt to ourself
|
| < e_coreid_t thiscore = e_get_coreid();
|
| < unsigned row, col;
|
| < e_coords_from_coreid(thiscore, &row, &col);
|
| < e_irq_set(row,col,E_USER_INT);
|
| --- |
| > // There seems to be no working software interrupt, so we send a user-interrupt to ourself
|
| > e_coreid_t thiscore = e_get_coreid();
|
| > unsigned row, col;
|
| > e_coords_from_coreid(thiscore, &row, &col);
|
| > e_irq_set(row,col,E_USER_INT);
|
| 193,199c197,208 |
| < unsigned int cyclesForTick = CyclesForTick;
|
| < int delta = E_CTIMER_MAX - e_ctimer_get(E_CTIMER_1) - cyclesForTick; //How much off are we this time?
|
| < e_ctimer_set(E_CTIMER_1, E_CTIMER_MAX);
|
| <
|
| < //We are never to early, case is taken on startup
|
| < if(delta < 0)
|
| < delta=0;
|
| --- |
| > unsigned int cyclesForTick = CyclesForTick;
|
| > int delta = E_CTIMER_MAX - e_ctimer_get(E_CTIMER_1) - cyclesForTick; //How much off are we this time?
|
| > e_ctimer_set(E_CTIMER_1, E_CTIMER_MAX);
|
| >
|
| > //We are never to early, case is taken on startup
|
| >
|
| > //debugging
|
| > if(delta < 0){
|
| >
|
| > delta=0;
|
| > }
|
| > globalDelta = delta;
|
| 201,202c210,211 |
| < e_ctimer_set(E_CTIMER_0, cyclesForTick-delta);
|
| < e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
|
| --- |
| > e_ctimer_set(E_CTIMER_0, cyclesForTick-delta);
|
| > e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
|
| 208,210c217,219 |
| < volatile int status;
|
| < volatile int pc;
|
| < volatile int no[64]; //collection of all the registers as stored onto the stack
|
| --- |
| > volatile int status;
|
| > volatile int pc;
|
| > volatile int no[64]; //collection of all the registers as stored onto the stack
|
| 217,224c226,233 |
| < TaskHandle_t runningTask = xTaskGetCurrentTaskHandle();
|
| < TCB_t **tcb = runningTask;
|
| < struct layout* reg = *tcb;
|
| <
|
| < int bitmask = 1 << (rand()%32);
|
| < int failreg = rand()%64;
|
| < reg->no[failreg] ^= bitmask;
|
| < M[4]++;
|
| --- |
| > TaskHandle_t runningTask = xTaskGetCurrentTaskHandle();
|
| > TCB_t **tcb = runningTask;
|
| > struct layout* reg = *tcb;
|
| >
|
| > int bitmask = 1 << (rand()%32);
|
| > int failreg = rand()%64;
|
| > reg->no[failreg] ^= bitmask;
|
| > M[4]++;
|
| 230,251c239,263 |
| < switch (interrupt_mode) {
|
| < case E_TIMER0_INT:
|
| < vSetupTimer();
|
| < if( xTaskIncrementTick() != pdFALSE ) {
|
| < vTaskSwitchContext();
|
| < }
|
| < break;
|
| < case E_SW_EXCEPTION: //triggered extrenally for error injection. Must be that high prority
|
| < injectErrors();
|
| < break;
|
| < case E_USER_INT:
|
| < vTaskSwitchContext();
|
| < break;
|
| < case E_MESSAGE_INT: //message, triggered externally for message transmission
|
| < irqMsg();
|
| < break;
|
| < case E_MEM_FAULT: // written to read-only memory
|
| < while(1);
|
| < break;
|
| < default:
|
| < break;
|
| < }
|
| --- |
| > switch (interrupt_mode) {
|
| > case E_TIMER0_INT:
|
| > vSetupTimer();
|
| > updateTick();
|
| > xTaskIncrementTick();
|
| > vTaskSwitchContext();
|
| > break;
|
| > case E_SW_EXCEPTION: //triggered extrenally for error injection. Must be that high prority
|
| > injectErrors();
|
| > break;
|
| > case E_USER_INT:
|
| > vTaskSwitchContext();
|
| > break;
|
| > case E_MESSAGE_INT: //message, triggered externally for message transmission
|
| > //a message received
|
| > updateDebugFlag(404);
|
| > //irqMsg();
|
| > break;
|
| > case E_MEM_FAULT: // written to read-only memory
|
| > updateDebugFlag(2222);
|
| > //while(1);
|
| > break;
|
| > default:
|
| > break;
|
| > }
|