Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
ashKail
Level 1
Level 1
10 sign-ins 5 questions asked 5 sign-ins

Hi, I am working on testing trap handlers on TC39x board. Could you please help me to generate the following traps from software?

Background info:

I am using a tasking compiler and a AUTOSAR based RTOS. I am pretty new to Aurix TC39x too.

These are the following traps that I need some assistance:

-->Free Context List Depletion

--->Free Context List Underflow

--->Call Stack Underflow

--->Context Type

@cwunder  your answers providing some code snippets to test traps have helped me greatly. Requesting you if you can provide some for this. Thank you!.

0 Likes
1 Solution
Meet_T
Moderator
Moderator
Moderator
25 likes received 50 solutions authored 100 replies posted

Hi,

You can refer to these code snippets to trigger these traps using the software:

Free Context List Depletion Trap triggers when we perform a context save operation when FCX = LCX.

 

 

//write both LCX and FCX registers with the same value that will trigger fcd trap
    __mtcr(CPU_LCX,0x70eed);    
    __mtcr(CPU_FCX,0x70eed);
    __asm("svlcx");

 

 

 Free Context List Underflow Trap triggers when we try to restore the context when FCX is pointing to null 

 

 

//write FCX with all 0s so it points to null causing fcu trap
__mtcr(CPU_FCX,0x0);        
__asm("rslcx");

 

 

Call Stack Underflow Triggers when we try to restore a context when PCX = 0 (null).

 

 

__mtcr(CPU_PCXI,0x0);
__asm("rslcx");

 

 

 Context Type Trap Triggers when PCXI.UL = 1 and you try to restore the lower context.

For this you can call a function, so that it stores the upper context making PCXI.UL = 1 and then inside that function you use the instruction to restore the lower context which will trigger the trap. Please make sure that the function you call is not optimized.

 

 

void contextTypeFunction(){

    //calling the function saves the upper context making PCXI.UL == 1
    __asm("rslcx"); //then we restore the lower context causing a context type trap

}

contextTypeFunction();   //call the function

 

 

 

For more information on these traps and how they are generated you can refer to section 6.3.4 Context Management (Trap Class 3)  of the Tricore Architecture Manual Part-1.

 

Best Regards,

Meet.

View solution in original post

0 Likes
2 Replies
Meet_T
Moderator
Moderator
Moderator
25 likes received 50 solutions authored 100 replies posted

Hi,

You can refer to these code snippets to trigger these traps using the software:

Free Context List Depletion Trap triggers when we perform a context save operation when FCX = LCX.

 

 

//write both LCX and FCX registers with the same value that will trigger fcd trap
    __mtcr(CPU_LCX,0x70eed);    
    __mtcr(CPU_FCX,0x70eed);
    __asm("svlcx");

 

 

 Free Context List Underflow Trap triggers when we try to restore the context when FCX is pointing to null 

 

 

//write FCX with all 0s so it points to null causing fcu trap
__mtcr(CPU_FCX,0x0);        
__asm("rslcx");

 

 

Call Stack Underflow Triggers when we try to restore a context when PCX = 0 (null).

 

 

__mtcr(CPU_PCXI,0x0);
__asm("rslcx");

 

 

 Context Type Trap Triggers when PCXI.UL = 1 and you try to restore the lower context.

For this you can call a function, so that it stores the upper context making PCXI.UL = 1 and then inside that function you use the instruction to restore the lower context which will trigger the trap. Please make sure that the function you call is not optimized.

 

 

void contextTypeFunction(){

    //calling the function saves the upper context making PCXI.UL == 1
    __asm("rslcx"); //then we restore the lower context causing a context type trap

}

contextTypeFunction();   //call the function

 

 

 

For more information on these traps and how they are generated you can refer to section 6.3.4 Context Management (Trap Class 3)  of the Tricore Architecture Manual Part-1.

 

Best Regards,

Meet.

0 Likes
ashKail
Level 1
Level 1
10 sign-ins 5 questions asked 5 sign-ins

Thank you for the info 

0 Likes