aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/include/asm/reg.h
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2009-07-14 16:52:54 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2009-08-19 20:12:27 -0400
commitee43eb788b3a06425fffb912677e2e1c8b00dd3b (patch)
tree7233cb47647837ab00af81270b3a16555d88a1f1 /arch/powerpc/include/asm/reg.h
parent8aa34ab8b2dc96ca6c4feecfb87ed13f0d40ef98 (diff)
powerpc: Use names rather than numbers for SPRGs (v2)
The kernel uses SPRG registers for various purposes, typically in low level assembly code as scratch registers or to hold per-cpu global infos such as the PACA or the current thread_info pointer. We want to be able to easily shuffle the usage of those registers as some implementations have specific constraints realted to some of them, for example, some have userspace readable aliases, etc.. and the current choice isn't always the best. This patch should not change any code generation, and replaces the usage of SPRN_SPRGn everywhere in the kernel with a named replacement and adds documentation next to the definition of the names as to what those are used for on each processor family. The only parts that still use the original numbers are bits of KVM or suspend/resume code that just blindly needs to save/restore all the SPRGs. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/include/asm/reg.h')
-rw-r--r--arch/powerpc/include/asm/reg.h113
1 files changed, 113 insertions, 0 deletions
diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
index 1170267736d..a8179cc99ac 100644
--- a/arch/powerpc/include/asm/reg.h
+++ b/arch/powerpc/include/asm/reg.h
@@ -646,6 +646,119 @@
646#endif 646#endif
647 647
648/* 648/*
649 * SPRG usage:
650 *
651 * All 64-bit:
652 * - SPRG3 stores PACA pointer
653 *
654 * 64-bit server:
655 * - SPRG0 unused (reserved for HV on Power4)
656 * - SPRG1 scratch for exception vectors
657 * - SPRG2 scratch for exception vectors
658 *
659 * All 32-bit:
660 * - SPRG3 current thread_info pointer
661 * (virtual on BookE, physical on others)
662 *
663 * 32-bit classic:
664 * - SPRG0 scratch for exception vectors
665 * - SPRG1 scratch for exception vectors
666 * - SPRG2 indicator that we are in RTAS
667 * - SPRG4 (603 only) pseudo TLB LRU data
668 *
669 * 32-bit 40x:
670 * - SPRG0 scratch for exception vectors
671 * - SPRG1 scratch for exception vectors
672 * - SPRG2 scratch for exception vectors
673 * - SPRG4 scratch for exception vectors (not 403)
674 * - SPRG5 scratch for exception vectors (not 403)
675 * - SPRG6 scratch for exception vectors (not 403)
676 * - SPRG7 scratch for exception vectors (not 403)
677 *
678 * 32-bit 440 and FSL BookE:
679 * - SPRG0 scratch for exception vectors
680 * - SPRG1 scratch for exception vectors (*)
681 * - SPRG2 scratch for crit interrupts handler
682 * - SPRG4 scratch for exception vectors
683 * - SPRG5 scratch for exception vectors
684 * - SPRG6 scratch for machine check handler
685 * - SPRG7 scratch for exception vectors
686 * - SPRG9 scratch for debug vectors (e500 only)
687 *
688 * Additionally, BookE separates "read" and "write"
689 * of those registers. That allows to use the userspace
690 * readable variant for reads, which can avoid a fault
691 * with KVM type virtualization.
692 *
693 * (*) Under KVM, the host SPRG1 is used to point to
694 * the current VCPU data structure
695 *
696 * 32-bit 8xx:
697 * - SPRG0 scratch for exception vectors
698 * - SPRG1 scratch for exception vectors
699 * - SPRG2 apparently unused but initialized
700 *
701 */
702#ifdef CONFIG_PPC64
703#define SPRN_SPRG_PACA SPRN_SPRG3
704#else
705#define SPRN_SPRG_THREAD SPRN_SPRG3
706#endif
707
708#ifdef CONFIG_PPC_BOOK3S_64
709#define SPRN_SPRG_SCRATCH0 SPRN_SPRG1
710#define SPRN_SPRG_SCRATCH1 SPRN_SPRG2
711#endif
712
713#ifdef CONFIG_PPC_BOOK3S_32
714#define SPRN_SPRG_SCRATCH0 SPRN_SPRG0
715#define SPRN_SPRG_SCRATCH1 SPRN_SPRG1
716#define SPRN_SPRG_RTAS SPRN_SPRG2
717#define SPRN_SPRG_603_LRU SPRN_SPRG4
718#endif
719
720#ifdef CONFIG_40x
721#define SPRN_SPRG_SCRATCH0 SPRN_SPRG0
722#define SPRN_SPRG_SCRATCH1 SPRN_SPRG1
723#define SPRN_SPRG_SCRATCH2 SPRN_SPRG2
724#define SPRN_SPRG_SCRATCH3 SPRN_SPRG4
725#define SPRN_SPRG_SCRATCH4 SPRN_SPRG5
726#define SPRN_SPRG_SCRATCH5 SPRN_SPRG6
727#define SPRN_SPRG_SCRATCH6 SPRN_SPRG7
728#endif
729
730#ifdef CONFIG_BOOKE
731#define SPRN_SPRG_RSCRATCH0 SPRN_SPRG0
732#define SPRN_SPRG_WSCRATCH0 SPRN_SPRG0
733#define SPRN_SPRG_RSCRATCH1 SPRN_SPRG1
734#define SPRN_SPRG_WSCRATCH1 SPRN_SPRG1
735#define SPRN_SPRG_RSCRATCH_CRIT SPRN_SPRG2
736#define SPRN_SPRG_WSCRATCH_CRIT SPRN_SPRG2
737#define SPRN_SPRG_RSCRATCH2 SPRN_SPRG4R
738#define SPRN_SPRG_WSCRATCH2 SPRN_SPRG4W
739#define SPRN_SPRG_RSCRATCH3 SPRN_SPRG5R
740#define SPRN_SPRG_WSCRATCH3 SPRN_SPRG5W
741#define SPRN_SPRG_RSCRATCH_MC SPRN_SPRG6R
742#define SPRN_SPRG_WSCRATCH_MC SPRN_SPRG6W
743#define SPRN_SPRG_RSCRATCH4 SPRN_SPRG7R
744#define SPRN_SPRG_WSCRATCH4 SPRN_SPRG7W
745#ifdef CONFIG_E200
746#define SPRN_SPRG_RSCRATCH_DBG SPRN_SPRG6R
747#define SPRN_SPRG_WSCRATCH_DBG SPRN_SPRG6W
748#else
749#define SPRN_SPRG_RSCRATCH_DBG SPRN_SPRG9
750#define SPRN_SPRG_WSCRATCH_DBG SPRN_SPRG9
751#endif
752#define SPRN_SPRG_RVCPU SPRN_SPRG1
753#define SPRN_SPRG_WVCPU SPRN_SPRG1
754#endif
755
756#ifdef CONFIG_8xx
757#define SPRN_SPRG_SCRATCH0 SPRN_SPRG0
758#define SPRN_SPRG_SCRATCH1 SPRN_SPRG1
759#endif
760
761/*
649 * An mtfsf instruction with the L bit set. On CPUs that support this a 762 * An mtfsf instruction with the L bit set. On CPUs that support this a
650 * full 64bits of FPSCR is restored and on other CPUs the L bit is ignored. 763 * full 64bits of FPSCR is restored and on other CPUs the L bit is ignored.
651 * 764 *