xref: /OK3568_Linux_fs/kernel/Documentation/sh/register-banks.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun.. SPDX-License-Identifier: GPL-2.0
2*4882a593Smuzhiyun
3*4882a593Smuzhiyun==========================================
4*4882a593SmuzhiyunNotes on register bank usage in the kernel
5*4882a593Smuzhiyun==========================================
6*4882a593Smuzhiyun
7*4882a593SmuzhiyunIntroduction
8*4882a593Smuzhiyun------------
9*4882a593Smuzhiyun
10*4882a593SmuzhiyunThe SH-3 and SH-4 CPU families traditionally include a single partial register
11*4882a593Smuzhiyunbank (selected by SR.RB, only r0 ... r7 are banked), whereas other families
12*4882a593Smuzhiyunmay have more full-featured banking or simply no such capabilities at all.
13*4882a593Smuzhiyun
14*4882a593SmuzhiyunSR.RB banking
15*4882a593Smuzhiyun-------------
16*4882a593Smuzhiyun
17*4882a593SmuzhiyunIn the case of this type of banking, banked registers are mapped directly to
18*4882a593Smuzhiyunr0 ... r7 if SR.RB is set to the bank we are interested in, otherwise ldc/stc
19*4882a593Smuzhiyuncan still be used to reference the banked registers (as r0_bank ... r7_bank)
20*4882a593Smuzhiyunwhen in the context of another bank. The developer must keep the SR.RB value
21*4882a593Smuzhiyunin mind when writing code that utilizes these banked registers, for obvious
22*4882a593Smuzhiyunreasons. Userspace is also not able to poke at the bank1 values, so these can
23*4882a593Smuzhiyunbe used rather effectively as scratch registers by the kernel.
24*4882a593Smuzhiyun
25*4882a593SmuzhiyunPresently the kernel uses several of these registers.
26*4882a593Smuzhiyun
27*4882a593Smuzhiyun	- r0_bank, r1_bank (referenced as k0 and k1, used for scratch
28*4882a593Smuzhiyun	  registers when doing exception handling).
29*4882a593Smuzhiyun
30*4882a593Smuzhiyun	- r2_bank (used to track the EXPEVT/INTEVT code)
31*4882a593Smuzhiyun
32*4882a593Smuzhiyun		- Used by do_IRQ() and friends for doing irq mapping based off
33*4882a593Smuzhiyun		  of the interrupt exception vector jump table offset
34*4882a593Smuzhiyun
35*4882a593Smuzhiyun	- r6_bank (global interrupt mask)
36*4882a593Smuzhiyun
37*4882a593Smuzhiyun		- The SR.IMASK interrupt handler makes use of this to set the
38*4882a593Smuzhiyun		  interrupt priority level (used by local_irq_enable())
39*4882a593Smuzhiyun
40*4882a593Smuzhiyun	- r7_bank (current)
41