ContextSaveAreasTC387

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

cross mob
User22023
Level 1
Level 1
5 questions asked First reply posted First question asked
Hello all,

i´m a beginner and i work with the TC387 and the Aurix Development Studio with the Free Tasking Toolchain.

Could you please help me with the following questions:

1.
Is there some extra Hardware on the TC387 which saves the upper context of a suspended Function/Interrupt?
Because i have read in the "TriCore TC1.6.2 core Architecture Manual chapter 4.5" that by a call instruction the upper context is saved parallel to call jump instruction and in my opinion a CPU can´t do parallel instructions.
And also in the Disassembly view in the debugger i don´t see any instruction for saving the context.

2.
What´s the difference between save and store of an context? I know about the save instruction it´s clearly described in the manual, but i have problems to understand the store instruction?

3.
What is an use case for save/store the lower context?

Thanks in advance and best regards Hennessy
0 Likes
4 Replies
NeMa_4793301
Level 6
Level 6
10 likes received 10 solutions authored 5 solutions authored
Hennessy wrote:
1. Is there some extra Hardware on the TC387 which saves the upper context of a suspended Function/Interrupt?
Because i have read in the "TriCore TC1.6.2 core Architecture Manual chapter 4.5" that by a call instruction the upper context is saved parallel to call jump instruction and in my opinion a CPU can´t do parallel instructions.
And also in the Disassembly view in the debugger i don´t see any instruction for saving the context.

The TC1.6.2 core has 3 separate pipelines, and can execute up to 3 instructions per clock cycle (load/store, loop, and integer). So it can do parallel instructions, and the compilers are pretty smart about arranging instructions to take advantage of the pipelines.

The Architecture manual Volume 2 shows the guts of how the CALL instruction actually works on page 109:
EA = {FCX.FCXS, 6'b0, FCX.FCXO, 6'b0};
new_FCX = M(EA, word);
M(EA,16 * word) = {PCXI, PSW, A[10], A[11], D[8], D[9], D[10], D[11], A[12], A[13], A[14], A[15], D[12], D[13], D[14],
D[15]};

In other words, it saves an Upper Context automatically.

2. What´s the difference between save and store of an context? I know about the save instruction it´s clearly described in the manual, but i have problems to understand the store instruction?

Saving upper context is automatic with CALL/RET, and lower contexts with interrupts or traps and RFE. You can also store/load a context manually if you use STLCX/LDLCX or STUCX/LDUCX.

3. What is an use case for save/store the lower context?

Applications generally don't have to worry about saving and restoring contexts. But switching contexts is a vital part of an operating system, since each task has its own context. Peeking into lower contexts helps you debug what went wrong if your application gets an unexpected trap or interrupt. Debuggers are smart about decoding the context chain when you view the call tree.
0 Likes
cwunder
Employee
Employee
5 likes given 50 likes received 50 solutions authored
Hennessy wrote:
3.
What is an use case for save/store the lower context?


Just to add...
The lower context is usually stored in an ISR using the BISR instruction. The BISR instruction (Begin Interrupt Service Routine) enables the interrupt system (ICR.IE = 1), allows the modification of the CPU priority number (CCPN), and saves the lower context in the same manner as the SVLCX instruction.
0 Likes
User22023
Level 1
Level 1
5 questions asked First reply posted First question asked
Hi

Thanks for the quick answer and the great hint to the volume2 manual.

Can you describe me what exactly happens when an interrupt occurs. Here´s some code from the disassembly:
106 void interruptGpt12(void)
00000000800000e2: svlcx
111 }
00000000800000e6: rslcx
00000000800000ea: rfe

Am i right that first the upper context is saved by the interrupt then the lower is saved by svlcx and after the ISR the lower is restored and after that by the rfe the upper is restored? Why is both upper and lower saved?
0 Likes
NeMa_4793301
Level 6
Level 6
10 likes received 10 solutions authored 5 solutions authored
All correct. The lower context is saved because compilers generally don't want to fuss about avoiding the use of lower context registers in an ISR (A2...A7 / D0...D7 / PCXI / A11).
0 Likes