WSL2-Linux-Kernel/arch/frv/kernel
David Howells 28baebae73 [PATCH] FRV: Use virtual interrupt disablement
Make the FRV arch use virtual interrupt disablement because accesses to the
processor status register (PSR) are relatively slow and because we will
soon have the need to deal with multiple interrupt controls at the same
time (separate h/w and inter-core interrupts).

The way this is done is to dedicate one of the four integer condition code
registers (ICC2) to maintaining a virtual interrupt disablement state
whilst inside the kernel.  This uses the ICC2.Z flag (Zero) to indicate
whether the interrupts are virtually disabled and the ICC2.C flag (Carry)
to indicate whether the interrupts are physically disabled.

ICC2.Z is set to indicate interrupts are virtually disabled.  ICC2.C is set
to indicate interrupts are physically enabled.  Under normal running
conditions Z==0 and C==1.

Disabling interrupts with local_irq_disable() doesn't then actually
physically disable interrupts - it merely sets ICC2.Z to 1.  Should an
interrupt then happen, the exception prologue will note ICC2.Z is set and
branch out of line using one instruction (an unlikely BEQ).  Here it will
physically disable interrupts and clear ICC2.C.

When it comes time to enable interrupts (local_irq_enable()), this simply
clears the ICC2.Z flag and invokes a trap #2 if both Z and C flags are
clear (the HI integer condition).  This can be done with the TIHI
conditional trap instruction.

The trap then physically reenables interrupts and sets ICC2.C again.  Upon
returning the interrupt will be taken as interrupts will then be enabled.
Note that whilst processing the trap, the whole exceptions system is
disabled, and so an interrupt can't happen till it returns.

If no pending interrupt had happened, ICC2.C would still be set, the HI
condition would not be fulfilled, and no trap will happen.

Saving interrupts (local_irq_save) is simply a matter of pulling the ICC2.Z
flag out of the CCR register, shifting it down and masking it off.  This
gives a result of 0 if interrupts were enabled and 1 if they weren't.

Restoring interrupts (local_irq_restore) is then a matter of taking the
saved value mentioned previously and XOR'ing it against 1.  If it was one,
the result will be zero, and if it was zero the result will be non-zero.
This result is then used to affect the ICC2.Z flag directly (it is a
condition code flag after all).  An XOR instruction does not affect the
Carry flag, and so that bit of state is unchanged.  The two flags can then
be sampled to see if they're both zero using the trap (TIHI) as for the
unconditional reenablement (local_irq_enable).

This patch also:

 (1) Modifies the debugging stub (break.S) to handle single-stepping crossing
     into the trap #2 handler and into virtually disabled interrupts.

 (2) Removes superseded fixup pointers from the second instructions in the trap
     tables (there's no a separate fixup table for this).

 (3) Declares the trap #3 vector for use in .org directives in the trap table.

 (4) Moves irq_enter() and irq_exit() in do_IRQ() to avoid problems with
     virtual interrupt handling, and removes the duplicate code that has now
     been folded into irq_exit() (softirq and preemption handling).

 (5) Tells the compiler in the arch Makefile that ICC2 is now reserved.

 (6) Documents the in-kernel ABI, including the virtual interrupts.

 (7) Renames the old irq management functions to different names.

Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-02-14 16:09:35 -08:00
..
Makefile [PATCH] frv: add module support stubs 2006-01-08 20:13:37 -08:00
asm-offsets.c kbuild: frv,m32r,sparc64 introduce fake asm-offsets.h file 2005-09-09 22:47:53 +02:00
break.S [PATCH] FRV: Use virtual interrupt disablement 2006-02-14 16:09:35 -08:00
cmode.S Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
debug-stub.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
dma.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
entry-table.S [PATCH] FRV: Use virtual interrupt disablement 2006-02-14 16:09:35 -08:00
entry.S [PATCH] FRV: Use virtual interrupt disablement 2006-02-14 16:09:35 -08:00
frv_ksyms.c [PATCH] dump_thread() cleanup 2006-01-10 08:01:25 -08:00
futex.c [PATCH] FRV: Implement futex operations for FRV 2006-01-06 08:33:33 -08:00
gdb-io.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
gdb-io.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
gdb-stub.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
head-mmu-fr451.S Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
head-uc-fr401.S Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
head-uc-fr451.S Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
head-uc-fr555.S Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
head.S [PATCH] FRV: Use virtual interrupt disablement 2006-02-14 16:09:35 -08:00
head.inc Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
init_task.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
irq-mb93091.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
irq-mb93093.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
irq-mb93493.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
irq-routing.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
irq.c [PATCH] FRV: Use virtual interrupt disablement 2006-02-14 16:09:35 -08:00
kernel_thread.S Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
local.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
module.c [PATCH] frv: add module support stubs 2006-01-08 20:13:37 -08:00
pm-mb93093.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
pm.c [PATCH] frv: implement and export various things required by modules 2006-01-08 20:13:36 -08:00
process.c [PATCH] frv: task_thread_info(), task_stack_page() 2006-01-12 09:08:54 -08:00
ptrace.c [PATCH] consolidate sys_ptrace() 2005-11-07 07:53:42 -08:00
semaphore.c [PATCH] FRV: Make the FRV arch work again 2005-11-28 14:42:23 -08:00
setup.c [PATCH] frv: force serial driver inclusion 2006-01-08 20:13:38 -08:00
signal.c [PATCH] Handle TIF_RESTORE_SIGMASK for FRV 2006-01-18 19:20:29 -08:00
sleep.S Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
switch_to.S Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
sys_frv.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
sysctl.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
time.c [PATCH] frv: implement and export various things required by modules 2006-01-08 20:13:36 -08:00
traps.c [PATCH] frv: implement and export various things required by modules 2006-01-08 20:13:36 -08:00
uaccess.c [PATCH] frv: implement and export various things required by modules 2006-01-08 20:13:36 -08:00
vmlinux.lds.S [PATCH] frv: miscellaneous changes 2006-01-08 20:13:38 -08:00