2005-04-16 18:20:36 -04:00
|
|
|
/* system.h: FR-V CPU control definitions
|
|
|
|
*
|
|
|
|
* Copyright (C) 2003 Red Hat, Inc. All Rights Reserved.
|
|
|
|
* Written by David Howells (dhowells@redhat.com)
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version
|
|
|
|
* 2 of the License, or (at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _ASM_SYSTEM_H
|
|
|
|
#define _ASM_SYSTEM_H
|
|
|
|
|
2007-06-06 05:39:40 -04:00
|
|
|
#include <linux/types.h>
|
2005-04-16 18:20:36 -04:00
|
|
|
#include <linux/linkage.h>
|
2008-02-08 18:00:45 -05:00
|
|
|
#include <linux/kernel.h>
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
struct thread_struct;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* switch_to(prev, next) should switch from task `prev' to `next'
|
|
|
|
* `prev' will never be the same as `next'.
|
|
|
|
* The `mb' is to tell GCC not to cache `current' across this call.
|
|
|
|
*/
|
|
|
|
extern asmlinkage
|
|
|
|
struct task_struct *__switch_to(struct thread_struct *prev_thread,
|
|
|
|
struct thread_struct *next_thread,
|
|
|
|
struct task_struct *prev);
|
|
|
|
|
|
|
|
#define switch_to(prev, next, last) \
|
|
|
|
do { \
|
|
|
|
(prev)->thread.sched_lr = \
|
|
|
|
(unsigned long) __builtin_return_address(0); \
|
|
|
|
(last) = __switch_to(&(prev)->thread, &(next)->thread, (prev)); \
|
|
|
|
mb(); \
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* interrupt flag manipulation
|
[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:53:20 -05:00
|
|
|
* - use virtual interrupt management since touching the PSR is slow
|
|
|
|
* - ICC2.Z: T if interrupts virtually disabled
|
|
|
|
* - ICC2.C: F if interrupts really disabled
|
|
|
|
* - if Z==1 upon interrupt:
|
|
|
|
* - C is set to 0
|
|
|
|
* - interrupts are really disabled
|
|
|
|
* - entry.S returns immediately
|
|
|
|
* - uses TIHI (TRAP if Z==0 && C==0) #2 to really reenable interrupts
|
|
|
|
* - if taken, the trap:
|
|
|
|
* - sets ICC2.C
|
|
|
|
* - enables interrupts
|
2005-04-16 18:20:36 -04:00
|
|
|
*/
|
[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:53:20 -05:00
|
|
|
#define local_irq_disable() \
|
|
|
|
do { \
|
|
|
|
/* set Z flag, but don't change the C flag */ \
|
|
|
|
asm volatile(" andcc gr0,gr0,gr0,icc2 \n" \
|
|
|
|
: \
|
|
|
|
: \
|
|
|
|
: "memory", "icc2" \
|
|
|
|
); \
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
#define local_irq_enable() \
|
|
|
|
do { \
|
|
|
|
/* clear Z flag and then test the C flag */ \
|
|
|
|
asm volatile(" oricc gr0,#1,gr0,icc2 \n" \
|
|
|
|
" tihi icc2,gr0,#2 \n" \
|
|
|
|
: \
|
|
|
|
: \
|
|
|
|
: "memory", "icc2" \
|
|
|
|
); \
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
#define local_save_flags(flags) \
|
|
|
|
do { \
|
|
|
|
typecheck(unsigned long, flags); \
|
|
|
|
asm volatile("movsg ccr,%0" \
|
|
|
|
: "=r"(flags) \
|
|
|
|
: \
|
|
|
|
: "memory"); \
|
|
|
|
\
|
|
|
|
/* shift ICC2.Z to bit 0 */ \
|
|
|
|
flags >>= 26; \
|
|
|
|
\
|
|
|
|
/* make flags 1 if interrupts disabled, 0 otherwise */ \
|
|
|
|
flags &= 1UL; \
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
#define irqs_disabled() \
|
|
|
|
({unsigned long flags; local_save_flags(flags); flags; })
|
|
|
|
|
|
|
|
#define local_irq_save(flags) \
|
|
|
|
do { \
|
|
|
|
typecheck(unsigned long, flags); \
|
|
|
|
local_save_flags(flags); \
|
|
|
|
local_irq_disable(); \
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
#define local_irq_restore(flags) \
|
|
|
|
do { \
|
|
|
|
typecheck(unsigned long, flags); \
|
|
|
|
\
|
|
|
|
/* load the Z flag by turning 1 if disabled into 0 if disabled \
|
|
|
|
* and thus setting the Z flag but not the C flag */ \
|
|
|
|
asm volatile(" xoricc %0,#1,gr0,icc2 \n" \
|
|
|
|
/* then test Z=0 and C=0 */ \
|
|
|
|
" tihi icc2,gr0,#2 \n" \
|
|
|
|
: \
|
|
|
|
: "r"(flags) \
|
|
|
|
: "memory", "icc2" \
|
|
|
|
); \
|
|
|
|
\
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* real interrupt flag manipulation
|
|
|
|
*/
|
|
|
|
#define __local_irq_disable() \
|
2005-04-16 18:20:36 -04:00
|
|
|
do { \
|
|
|
|
unsigned long psr; \
|
|
|
|
asm volatile(" movsg psr,%0 \n" \
|
|
|
|
" andi %0,%2,%0 \n" \
|
|
|
|
" ori %0,%1,%0 \n" \
|
|
|
|
" movgs %0,psr \n" \
|
|
|
|
: "=r"(psr) \
|
|
|
|
: "i" (PSR_PIL_14), "i" (~PSR_PIL) \
|
|
|
|
: "memory"); \
|
|
|
|
} while(0)
|
|
|
|
|
[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:53:20 -05:00
|
|
|
#define __local_irq_enable() \
|
2005-04-16 18:20:36 -04:00
|
|
|
do { \
|
|
|
|
unsigned long psr; \
|
|
|
|
asm volatile(" movsg psr,%0 \n" \
|
|
|
|
" andi %0,%1,%0 \n" \
|
|
|
|
" movgs %0,psr \n" \
|
|
|
|
: "=r"(psr) \
|
|
|
|
: "i" (~PSR_PIL) \
|
|
|
|
: "memory"); \
|
|
|
|
} while(0)
|
|
|
|
|
[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:53:20 -05:00
|
|
|
#define __local_save_flags(flags) \
|
2005-04-16 18:20:36 -04:00
|
|
|
do { \
|
|
|
|
typecheck(unsigned long, flags); \
|
|
|
|
asm("movsg psr,%0" \
|
|
|
|
: "=r"(flags) \
|
|
|
|
: \
|
|
|
|
: "memory"); \
|
|
|
|
} while(0)
|
|
|
|
|
[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:53:20 -05:00
|
|
|
#define __local_irq_save(flags) \
|
2005-04-16 18:20:36 -04:00
|
|
|
do { \
|
|
|
|
unsigned long npsr; \
|
|
|
|
typecheck(unsigned long, flags); \
|
|
|
|
asm volatile(" movsg psr,%0 \n" \
|
|
|
|
" andi %0,%3,%1 \n" \
|
|
|
|
" ori %1,%2,%1 \n" \
|
|
|
|
" movgs %1,psr \n" \
|
|
|
|
: "=r"(flags), "=r"(npsr) \
|
|
|
|
: "i" (PSR_PIL_14), "i" (~PSR_PIL) \
|
|
|
|
: "memory"); \
|
|
|
|
} while(0)
|
|
|
|
|
[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:53:20 -05:00
|
|
|
#define __local_irq_restore(flags) \
|
2005-04-16 18:20:36 -04:00
|
|
|
do { \
|
|
|
|
typecheck(unsigned long, flags); \
|
|
|
|
asm volatile(" movgs %0,psr \n" \
|
|
|
|
: \
|
|
|
|
: "r" (flags) \
|
|
|
|
: "memory"); \
|
|
|
|
} while(0)
|
|
|
|
|
[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:53:20 -05:00
|
|
|
#define __irqs_disabled() \
|
2005-04-16 18:20:36 -04:00
|
|
|
((__get_PSR() & PSR_PIL) >= PSR_PIL_14)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Force strict CPU ordering.
|
|
|
|
*/
|
|
|
|
#define nop() asm volatile ("nop"::)
|
|
|
|
#define mb() asm volatile ("membar" : : :"memory")
|
|
|
|
#define rmb() asm volatile ("membar" : : :"memory")
|
|
|
|
#define wmb() asm volatile ("membar" : : :"memory")
|
|
|
|
#define set_mb(var, value) do { var = value; mb(); } while (0)
|
|
|
|
|
|
|
|
#define smp_mb() mb()
|
|
|
|
#define smp_rmb() rmb()
|
|
|
|
#define smp_wmb() wmb()
|
|
|
|
|
|
|
|
#define read_barrier_depends() do {} while(0)
|
|
|
|
#define smp_read_barrier_depends() read_barrier_depends()
|
|
|
|
|
|
|
|
#define HARD_RESET_NOW() \
|
|
|
|
do { \
|
|
|
|
cli(); \
|
|
|
|
} while(1)
|
|
|
|
|
|
|
|
extern void die_if_kernel(const char *, ...) __attribute__((format(printf, 1, 2)));
|
|
|
|
extern void free_initmem(void);
|
|
|
|
|
|
|
|
#define arch_align_stack(x) (x)
|
|
|
|
|
2007-05-08 03:34:38 -04:00
|
|
|
/*****************************************************************************/
|
|
|
|
/*
|
|
|
|
* compare and conditionally exchange value with memory
|
|
|
|
* - if (*ptr == test) then orig = *ptr; *ptr = test;
|
|
|
|
* - if (*ptr != test) then orig = *ptr;
|
|
|
|
*/
|
|
|
|
#ifndef CONFIG_FRV_OUTOFLINE_ATOMIC_OPS
|
|
|
|
|
|
|
|
#define cmpxchg(ptr, test, new) \
|
|
|
|
({ \
|
|
|
|
__typeof__(ptr) __xg_ptr = (ptr); \
|
|
|
|
__typeof__(*(ptr)) __xg_orig, __xg_tmp; \
|
|
|
|
__typeof__(*(ptr)) __xg_test = (test); \
|
|
|
|
__typeof__(*(ptr)) __xg_new = (new); \
|
|
|
|
\
|
|
|
|
switch (sizeof(__xg_orig)) { \
|
|
|
|
case 4: \
|
|
|
|
asm volatile( \
|
|
|
|
"0: \n" \
|
|
|
|
" orcc gr0,gr0,gr0,icc3 \n" \
|
|
|
|
" ckeq icc3,cc7 \n" \
|
|
|
|
" ld.p %M0,%1 \n" \
|
|
|
|
" orcr cc7,cc7,cc3 \n" \
|
|
|
|
" sub%I4cc %1,%4,%2,icc0 \n" \
|
|
|
|
" bne icc0,#0,1f \n" \
|
|
|
|
" cst.p %3,%M0 ,cc3,#1 \n" \
|
|
|
|
" corcc gr29,gr29,gr0 ,cc3,#1 \n" \
|
|
|
|
" beq icc3,#0,0b \n" \
|
|
|
|
"1: \n" \
|
|
|
|
: "+U"(*__xg_ptr), "=&r"(__xg_orig), "=&r"(__xg_tmp) \
|
|
|
|
: "r"(__xg_new), "NPr"(__xg_test) \
|
|
|
|
: "memory", "cc7", "cc3", "icc3", "icc0" \
|
|
|
|
); \
|
|
|
|
break; \
|
|
|
|
\
|
|
|
|
default: \
|
|
|
|
__xg_orig = 0; \
|
|
|
|
asm volatile("break"); \
|
|
|
|
break; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
__xg_orig; \
|
|
|
|
})
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
extern uint32_t __cmpxchg_32(uint32_t *v, uint32_t test, uint32_t new);
|
|
|
|
|
|
|
|
#define cmpxchg(ptr, test, new) \
|
|
|
|
({ \
|
|
|
|
__typeof__(ptr) __xg_ptr = (ptr); \
|
|
|
|
__typeof__(*(ptr)) __xg_orig; \
|
|
|
|
__typeof__(*(ptr)) __xg_test = (test); \
|
|
|
|
__typeof__(*(ptr)) __xg_new = (new); \
|
|
|
|
\
|
|
|
|
switch (sizeof(__xg_orig)) { \
|
2007-10-14 14:35:10 -04:00
|
|
|
case 4: __xg_orig = (__force __typeof__(*ptr)) \
|
|
|
|
__cmpxchg_32((__force uint32_t *)__xg_ptr, \
|
|
|
|
(__force uint32_t)__xg_test, \
|
|
|
|
(__force uint32_t)__xg_new); break; \
|
2007-05-08 03:34:38 -04:00
|
|
|
default: \
|
|
|
|
__xg_orig = 0; \
|
|
|
|
asm volatile("break"); \
|
|
|
|
break; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
__xg_orig; \
|
|
|
|
})
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2008-02-07 03:16:14 -05:00
|
|
|
#include <asm-generic/cmpxchg-local.h>
|
|
|
|
|
|
|
|
static inline unsigned long __cmpxchg_local(volatile void *ptr,
|
|
|
|
unsigned long old,
|
|
|
|
unsigned long new, int size)
|
|
|
|
{
|
|
|
|
switch (size) {
|
|
|
|
case 4:
|
2008-02-08 18:00:45 -05:00
|
|
|
return cmpxchg((unsigned long *)ptr, old, new);
|
2008-02-07 03:16:14 -05:00
|
|
|
default:
|
|
|
|
return __cmpxchg_local_generic(ptr, old, new, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
return old;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* cmpxchg_local and cmpxchg64_local are atomic wrt current CPU. Always make
|
|
|
|
* them available.
|
|
|
|
*/
|
|
|
|
#define cmpxchg_local(ptr, o, n) \
|
|
|
|
((__typeof__(*(ptr)))__cmpxchg_local((ptr), (unsigned long)(o), \
|
|
|
|
(unsigned long)(n), sizeof(*(ptr))))
|
|
|
|
#define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n))
|
2007-05-08 03:34:38 -04:00
|
|
|
|
2005-04-16 18:20:36 -04:00
|
|
|
#endif /* _ASM_SYSTEM_H */
|