diff options
author | Horms <horms@verge.net.au> | 2006-03-31 18:38:15 -0500 |
---|---|---|
committer | Adrian Bunk <bunk@stusta.de> | 2006-03-31 18:38:15 -0500 |
commit | 08039264d55b1e4c481309d841b245b0bb5e9c68 (patch) | |
tree | 7a1e0440686fc7cdbb478fdce8de86981fc85c02 | |
parent | abe37e5a13c4055bdf8ea1d2e781d757285e1908 (diff) |
Documentation: Make fujitsu/frv/kernel-ABI.txt 80 columns wide
Documentation: Make kernel-ABI.txt 80 columns wide
Note that this only has line-wrapping and white-space changes.
No text was changed at all.
Signed-Off-By: Horms <horms@verge.net.au>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
-rw-r--r-- | Documentation/fujitsu/frv/kernel-ABI.txt | 192 |
1 files changed, 110 insertions, 82 deletions
diff --git a/Documentation/fujitsu/frv/kernel-ABI.txt b/Documentation/fujitsu/frv/kernel-ABI.txt index 0ed9b0a779bc..8b0a5fc8bfd9 100644 --- a/Documentation/fujitsu/frv/kernel-ABI.txt +++ b/Documentation/fujitsu/frv/kernel-ABI.txt | |||
@@ -1,17 +1,19 @@ | |||
1 | ================================= | 1 | ================================= |
2 | INTERNAL KERNEL ABI FOR FR-V ARCH | 2 | INTERNAL KERNEL ABI FOR FR-V ARCH |
3 | ================================= | 3 | ================================= |
4 | 4 | ||
5 | The internal FRV kernel ABI is not quite the same as the userspace ABI. A number of the registers | 5 | The internal FRV kernel ABI is not quite the same as the userspace ABI. A |
6 | are used for special purposed, and the ABI is not consistent between modules vs core, and MMU vs | 6 | number of the registers are used for special purposed, and the ABI is not |
7 | no-MMU. | 7 | consistent between modules vs core, and MMU vs no-MMU. |
8 | 8 | ||
9 | This partly stems from the fact that FRV CPUs do not have a separate supervisor stack pointer, and | 9 | This partly stems from the fact that FRV CPUs do not have a separate |
10 | most of them do not have any scratch registers, thus requiring at least one general purpose | 10 | supervisor stack pointer, and most of them do not have any scratch |
11 | register to be clobbered in such an event. Also, within the kernel core, it is possible to simply | 11 | registers, thus requiring at least one general purpose register to be |
12 | jump or call directly between functions using a relative offset. This cannot be extended to modules | 12 | clobbered in such an event. Also, within the kernel core, it is possible to |
13 | for the displacement is likely to be too far. Thus in modules the address of a function to call | 13 | simply jump or call directly between functions using a relative offset. |
14 | must be calculated in a register and then used, requiring two extra instructions. | 14 | This cannot be extended to modules for the displacement is likely to be too |
15 | far. Thus in modules the address of a function to call must be calculated | ||
16 | in a register and then used, requiring two extra instructions. | ||
15 | 17 | ||
16 | This document has the following sections: | 18 | This document has the following sections: |
17 | 19 | ||
@@ -39,7 +41,8 @@ When a system call is made, the following registers are effective: | |||
39 | CPU OPERATING MODES | 41 | CPU OPERATING MODES |
40 | =================== | 42 | =================== |
41 | 43 | ||
42 | The FR-V CPU has three basic operating modes. In order of increasing capability: | 44 | The FR-V CPU has three basic operating modes. In order of increasing |
45 | capability: | ||
43 | 46 | ||
44 | (1) User mode. | 47 | (1) User mode. |
45 | 48 | ||
@@ -47,42 +50,46 @@ The FR-V CPU has three basic operating modes. In order of increasing capability: | |||
47 | 50 | ||
48 | (2) Kernel mode. | 51 | (2) Kernel mode. |
49 | 52 | ||
50 | Normal kernel mode. There are many additional control registers available that may be | 53 | Normal kernel mode. There are many additional control registers |
51 | accessed in this mode, in addition to all the stuff available to user mode. This has two | 54 | available that may be accessed in this mode, in addition to all the |
52 | submodes: | 55 | stuff available to user mode. This has two submodes: |
53 | 56 | ||
54 | (a) Exceptions enabled (PSR.T == 1). | 57 | (a) Exceptions enabled (PSR.T == 1). |
55 | 58 | ||
56 | Exceptions will invoke the appropriate normal kernel mode handler. On entry to the | 59 | Exceptions will invoke the appropriate normal kernel mode |
57 | handler, the PSR.T bit will be cleared. | 60 | handler. On entry to the handler, the PSR.T bit will be cleared. |
58 | 61 | ||
59 | (b) Exceptions disabled (PSR.T == 0). | 62 | (b) Exceptions disabled (PSR.T == 0). |
60 | 63 | ||
61 | No exceptions or interrupts may happen. Any mandatory exceptions will cause the CPU to | 64 | No exceptions or interrupts may happen. Any mandatory exceptions |
62 | halt unless the CPU is told to jump into debug mode instead. | 65 | will cause the CPU to halt unless the CPU is told to jump into |
66 | debug mode instead. | ||
63 | 67 | ||
64 | (3) Debug mode. | 68 | (3) Debug mode. |
65 | 69 | ||
66 | No exceptions may happen in this mode. Memory protection and management exceptions will be | 70 | No exceptions may happen in this mode. Memory protection and |
67 | flagged for later consideration, but the exception handler won't be invoked. Debugging traps | 71 | management exceptions will be flagged for later consideration, but |
68 | such as hardware breakpoints and watchpoints will be ignored. This mode is entered only by | 72 | the exception handler won't be invoked. Debugging traps such as |
69 | debugging events obtained from the other two modes. | 73 | hardware breakpoints and watchpoints will be ignored. This mode is |
74 | entered only by debugging events obtained from the other two modes. | ||
70 | 75 | ||
71 | All kernel mode registers may be accessed, plus a few extra debugging specific registers. | 76 | All kernel mode registers may be accessed, plus a few extra debugging |
77 | specific registers. | ||
72 | 78 | ||
73 | 79 | ||
74 | ================================= | 80 | ================================= |
75 | INTERNAL KERNEL-MODE REGISTER ABI | 81 | INTERNAL KERNEL-MODE REGISTER ABI |
76 | ================================= | 82 | ================================= |
77 | 83 | ||
78 | There are a number of permanent register assignments that are set up by entry.S in the exception | 84 | There are a number of permanent register assignments that are set up by |
79 | prologue. Note that there is a complete set of exception prologues for each of user->kernel | 85 | entry.S in the exception prologue. Note that there is a complete set of |
80 | transition and kernel->kernel transition. There are also user->debug and kernel->debug mode | 86 | exception prologues for each of user->kernel transition and kernel->kernel |
81 | transition prologues. | 87 | transition. There are also user->debug and kernel->debug mode transition |
88 | prologues. | ||
82 | 89 | ||
83 | 90 | ||
84 | REGISTER FLAVOUR USE | 91 | REGISTER FLAVOUR USE |
85 | =============== ======= ==================================================== | 92 | =============== ======= ============================================== |
86 | GR1 Supervisor stack pointer | 93 | GR1 Supervisor stack pointer |
87 | GR15 Current thread info pointer | 94 | GR15 Current thread info pointer |
88 | GR16 GP-Rel base register for small data | 95 | GR16 GP-Rel base register for small data |
@@ -92,10 +99,12 @@ transition prologues. | |||
92 | GR31 NOMMU Destroyed by debug mode entry | 99 | GR31 NOMMU Destroyed by debug mode entry |
93 | GR31 MMU Destroyed by TLB miss kernel mode entry | 100 | GR31 MMU Destroyed by TLB miss kernel mode entry |
94 | CCR.ICC2 Virtual interrupt disablement tracking | 101 | CCR.ICC2 Virtual interrupt disablement tracking |
95 | CCCR.CC3 Cleared by exception prologue (atomic op emulation) | 102 | CCCR.CC3 Cleared by exception prologue |
103 | (atomic op emulation) | ||
96 | SCR0 MMU See mmu-layout.txt. | 104 | SCR0 MMU See mmu-layout.txt. |
97 | SCR1 MMU See mmu-layout.txt. | 105 | SCR1 MMU See mmu-layout.txt. |
98 | SCR2 MMU Save for EAR0 (destroyed by icache insns in debug mode) | 106 | SCR2 MMU Save for EAR0 (destroyed by icache insns |
107 | in debug mode) | ||
99 | SCR3 MMU Save for GR31 during debug exceptions | 108 | SCR3 MMU Save for GR31 during debug exceptions |
100 | DAMR/IAMR NOMMU Fixed memory protection layout. | 109 | DAMR/IAMR NOMMU Fixed memory protection layout. |
101 | DAMR/IAMR MMU See mmu-layout.txt. | 110 | DAMR/IAMR MMU See mmu-layout.txt. |
@@ -104,18 +113,21 @@ transition prologues. | |||
104 | Certain registers are also used or modified across function calls: | 113 | Certain registers are also used or modified across function calls: |
105 | 114 | ||
106 | REGISTER CALL RETURN | 115 | REGISTER CALL RETURN |
107 | =============== =============================== =============================== | 116 | =============== =============================== ====================== |
108 | GR0 Fixed Zero - | 117 | GR0 Fixed Zero - |
109 | GR2 Function call frame pointer | 118 | GR2 Function call frame pointer |
110 | GR3 Special Preserved | 119 | GR3 Special Preserved |
111 | GR3-GR7 - Clobbered | 120 | GR3-GR7 - Clobbered |
112 | GR8 Function call arg #1 Return value (or clobbered) | 121 | GR8 Function call arg #1 Return value |
113 | GR9 Function call arg #2 Return value MSW (or clobbered) | 122 | (or clobbered) |
123 | GR9 Function call arg #2 Return value MSW | ||
124 | (or clobbered) | ||
114 | GR10-GR13 Function call arg #3-#6 Clobbered | 125 | GR10-GR13 Function call arg #3-#6 Clobbered |
115 | GR14 - Clobbered | 126 | GR14 - Clobbered |
116 | GR15-GR16 Special Preserved | 127 | GR15-GR16 Special Preserved |
117 | GR17-GR27 - Preserved | 128 | GR17-GR27 - Preserved |
118 | GR28-GR31 Special Only accessed explicitly | 129 | GR28-GR31 Special Only accessed |
130 | explicitly | ||
119 | LR Return address after CALL Clobbered | 131 | LR Return address after CALL Clobbered |
120 | CCR/CCCR - Mostly Clobbered | 132 | CCR/CCCR - Mostly Clobbered |
121 | 133 | ||
@@ -124,46 +136,53 @@ Certain registers are also used or modified across function calls: | |||
124 | INTERNAL DEBUG-MODE REGISTER ABI | 136 | INTERNAL DEBUG-MODE REGISTER ABI |
125 | ================================ | 137 | ================================ |
126 | 138 | ||
127 | This is the same as the kernel-mode register ABI for functions calls. The difference is that in | 139 | This is the same as the kernel-mode register ABI for functions calls. The |
128 | debug-mode there's a different stack and a different exception frame. Almost all the global | 140 | difference is that in debug-mode there's a different stack and a different |
129 | registers from kernel-mode (including the stack pointer) may be changed. | 141 | exception frame. Almost all the global registers from kernel-mode |
142 | (including the stack pointer) may be changed. | ||
130 | 143 | ||
131 | REGISTER FLAVOUR USE | 144 | REGISTER FLAVOUR USE |
132 | =============== ======= ==================================================== | 145 | =============== ======= ============================================== |
133 | GR1 Debug stack pointer | 146 | GR1 Debug stack pointer |
134 | GR16 GP-Rel base register for small data | 147 | GR16 GP-Rel base register for small data |
135 | GR31 Current debug exception frame pointer (__debug_frame) | 148 | GR31 Current debug exception frame pointer |
149 | (__debug_frame) | ||
136 | SCR3 MMU Saved value of GR31 | 150 | SCR3 MMU Saved value of GR31 |
137 | 151 | ||
138 | 152 | ||
139 | Note that debug mode is able to interfere with the kernel's emulated atomic ops, so it must be | 153 | Note that debug mode is able to interfere with the kernel's emulated atomic |
140 | exceedingly careful not to do any that would interact with the main kernel in this regard. Hence | 154 | ops, so it must be exceedingly careful not to do any that would interact |
141 | the debug mode code (gdbstub) is almost completely self-contained. The only external code used is | 155 | with the main kernel in this regard. Hence the debug mode code (gdbstub) is |
142 | the sprintf family of functions. | 156 | almost completely self-contained. The only external code used is the |
157 | sprintf family of functions. | ||
143 | 158 | ||
144 | Futhermore, break.S is so complicated because single-step mode does not switch off on entry to an | 159 | Futhermore, break.S is so complicated because single-step mode does not |
145 | exception. That means unless manually disabled, single-stepping will blithely go on stepping into | 160 | switch off on entry to an exception. That means unless manually disabled, |
146 | things like interrupts. See gdbstub.txt for more information. | 161 | single-stepping will blithely go on stepping into things like interrupts. |
162 | See gdbstub.txt for more information. | ||
147 | 163 | ||
148 | 164 | ||
149 | ========================== | 165 | ========================== |
150 | VIRTUAL INTERRUPT HANDLING | 166 | VIRTUAL INTERRUPT HANDLING |
151 | ========================== | 167 | ========================== |
152 | 168 | ||
153 | Because accesses to the PSR is so slow, and to disable interrupts we have to access it twice (once | 169 | Because accesses to the PSR is so slow, and to disable interrupts we have |
154 | to read and once to write), we don't actually disable interrupts at all if we don't have to. What | 170 | to access it twice (once to read and once to write), we don't actually |
155 | we do instead is use the ICC2 condition code flags to note virtual disablement, such that if we | 171 | disable interrupts at all if we don't have to. What we do instead is use |
156 | then do take an interrupt, we note the flag, really disable interrupts, set another flag and resume | 172 | the ICC2 condition code flags to note virtual disablement, such that if we |
157 | execution at the point the interrupt happened. Setting condition flags as a side effect of an | 173 | then do take an interrupt, we note the flag, really disable interrupts, set |
158 | arithmetic or logical instruction is really fast. This use of the ICC2 only occurs within the | 174 | another flag and resume execution at the point the interrupt happened. |
175 | Setting condition flags as a side effect of an arithmetic or logical | ||
176 | instruction is really fast. This use of the ICC2 only occurs within the | ||
159 | kernel - it does not affect userspace. | 177 | kernel - it does not affect userspace. |
160 | 178 | ||
161 | The flags we use are: | 179 | The flags we use are: |
162 | 180 | ||
163 | (*) CCR.ICC2.Z [Zero flag] | 181 | (*) CCR.ICC2.Z [Zero flag] |
164 | 182 | ||
165 | Set to virtually disable interrupts, clear when interrupts are virtually enabled. Can be | 183 | Set to virtually disable interrupts, clear when interrupts are |
166 | modified by logical instructions without affecting the Carry flag. | 184 | virtually enabled. Can be modified by logical instructions without |
185 | affecting the Carry flag. | ||
167 | 186 | ||
168 | (*) CCR.ICC2.C [Carry flag] | 187 | (*) CCR.ICC2.C [Carry flag] |
169 | 188 | ||
@@ -176,8 +195,9 @@ What happens is this: | |||
176 | 195 | ||
177 | ICC2.Z is 0, ICC2.C is 1. | 196 | ICC2.Z is 0, ICC2.C is 1. |
178 | 197 | ||
179 | (2) An interrupt occurs. The exception prologue examines ICC2.Z and determines that nothing needs | 198 | (2) An interrupt occurs. The exception prologue examines ICC2.Z and |
180 | doing. This is done simply with an unlikely BEQ instruction. | 199 | determines that nothing needs doing. This is done simply with an |
200 | unlikely BEQ instruction. | ||
181 | 201 | ||
182 | (3) The interrupts are disabled (local_irq_disable) | 202 | (3) The interrupts are disabled (local_irq_disable) |
183 | 203 | ||
@@ -187,48 +207,56 @@ What happens is this: | |||
187 | 207 | ||
188 | ICC2.Z would be set to 0. | 208 | ICC2.Z would be set to 0. |
189 | 209 | ||
190 | A TIHI #2 instruction (trap #2 if condition HI - Z==0 && C==0) would be used to trap if | 210 | A TIHI #2 instruction (trap #2 if condition HI - Z==0 && C==0) would |
191 | interrupts were now virtually enabled, but physically disabled - which they're not, so the | 211 | be used to trap if interrupts were now virtually enabled, but |
192 | trap isn't taken. The kernel would then be back to state (1). | 212 | physically disabled - which they're not, so the trap isn't taken. The |
213 | kernel would then be back to state (1). | ||
193 | 214 | ||
194 | (5) An interrupt occurs. The exception prologue examines ICC2.Z and determines that the interrupt | 215 | (5) An interrupt occurs. The exception prologue examines ICC2.Z and |
195 | shouldn't actually have happened. It jumps aside, and there disabled interrupts by setting | 216 | determines that the interrupt shouldn't actually have happened. It |
196 | PSR.PIL to 14 and then it clears ICC2.C. | 217 | jumps aside, and there disabled interrupts by setting PSR.PIL to 14 |
218 | and then it clears ICC2.C. | ||
197 | 219 | ||
198 | (6) If interrupts were then saved and disabled again (local_irq_save): | 220 | (6) If interrupts were then saved and disabled again (local_irq_save): |
199 | 221 | ||
200 | ICC2.Z would be shifted into the save variable and masked off (giving a 1). | 222 | ICC2.Z would be shifted into the save variable and masked off |
223 | (giving a 1). | ||
201 | 224 | ||
202 | ICC2.Z would then be set to 1 (thus unchanged), and ICC2.C would be unaffected (ie: 0). | 225 | ICC2.Z would then be set to 1 (thus unchanged), and ICC2.C would be |
226 | unaffected (ie: 0). | ||
203 | 227 | ||
204 | (7) If interrupts were then restored from state (6) (local_irq_restore): | 228 | (7) If interrupts were then restored from state (6) (local_irq_restore): |
205 | 229 | ||
206 | ICC2.Z would be set to indicate the result of XOR'ing the saved value (ie: 1) with 1, which | 230 | ICC2.Z would be set to indicate the result of XOR'ing the saved |
207 | gives a result of 0 - thus leaving ICC2.Z set. | 231 | value (ie: 1) with 1, which gives a result of 0 - thus leaving |
232 | ICC2.Z set. | ||
208 | 233 | ||
209 | ICC2.C would remain unaffected (ie: 0). | 234 | ICC2.C would remain unaffected (ie: 0). |
210 | 235 | ||
211 | A TIHI #2 instruction would be used to again assay the current state, but this would do | 236 | A TIHI #2 instruction would be used to again assay the current state, |
212 | nothing as Z==1. | 237 | but this would do nothing as Z==1. |
213 | 238 | ||
214 | (8) If interrupts were then enabled (local_irq_enable): | 239 | (8) If interrupts were then enabled (local_irq_enable): |
215 | 240 | ||
216 | ICC2.Z would be cleared. ICC2.C would be left unaffected. Both flags would now be 0. | 241 | ICC2.Z would be cleared. ICC2.C would be left unaffected. Both |
242 | flags would now be 0. | ||
217 | 243 | ||
218 | A TIHI #2 instruction again issued to assay the current state would then trap as both Z==0 | 244 | A TIHI #2 instruction again issued to assay the current state would |
219 | [interrupts virtually enabled] and C==0 [interrupts really disabled] would then be true. | 245 | then trap as both Z==0 [interrupts virtually enabled] and C==0 |
246 | [interrupts really disabled] would then be true. | ||
220 | 247 | ||
221 | (9) The trap #2 handler would simply enable hardware interrupts (set PSR.PIL to 0), set ICC2.C to | 248 | (9) The trap #2 handler would simply enable hardware interrupts |
222 | 1 and return. | 249 | (set PSR.PIL to 0), set ICC2.C to 1 and return. |
223 | 250 | ||
224 | (10) Immediately upon returning, the pending interrupt would be taken. | 251 | (10) Immediately upon returning, the pending interrupt would be taken. |
225 | 252 | ||
226 | (11) The interrupt handler would take the path of actually processing the interrupt (ICC2.Z is | 253 | (11) The interrupt handler would take the path of actually processing the |
227 | clear, BEQ fails as per step (2)). | 254 | interrupt (ICC2.Z is clear, BEQ fails as per step (2)). |
228 | 255 | ||
229 | (12) The interrupt handler would then set ICC2.C to 1 since hardware interrupts are definitely | 256 | (12) The interrupt handler would then set ICC2.C to 1 since hardware |
230 | enabled - or else the kernel wouldn't be here. | 257 | interrupts are definitely enabled - or else the kernel wouldn't be here. |
231 | 258 | ||
232 | (13) On return from the interrupt handler, things would be back to state (1). | 259 | (13) On return from the interrupt handler, things would be back to state (1). |
233 | 260 | ||
234 | This trap (#2) is only available in kernel mode. In user mode it will result in SIGILL. | 261 | This trap (#2) is only available in kernel mode. In user mode it will |
262 | result in SIGILL. | ||