paca.h 4.9 KB
Newer Older
L
Linus Torvalds 已提交
1
/*
2 3
 * This control block defines the PACA which defines the processor
 * specific data for each logical processor on the system.
L
Linus Torvalds 已提交
4 5 6 7 8 9 10 11
 * There are some pointers defined that are utilized by PLIC.
 *
 * C 2001 PPC 64 Team, IBM Corp
 *
 * 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.
12 13 14
 */
#ifndef _ASM_POWERPC_PACA_H
#define _ASM_POWERPC_PACA_H
15
#ifdef __KERNEL__
L
Linus Torvalds 已提交
16

17 18 19 20 21
#include <asm/types.h>
#include <asm/lppaca.h>
#include <asm/mmu.h>
#include <asm/page.h>
#include <asm/exception-64e.h>
22 23 24
#ifdef CONFIG_KVM_BOOK3S_64_HANDLER
#include <asm/kvm_book3s_64_asm.h>
#endif
L
Linus Torvalds 已提交
25 26

register struct paca_struct *local_paca asm("r13");
27 28 29 30 31 32 33 34 35

#if defined(CONFIG_DEBUG_PREEMPT) && defined(CONFIG_SMP)
extern unsigned int debug_smp_processor_id(void); /* from linux/smp.h */
/*
 * Add standard checks that preemption cannot occur when using get_paca():
 * otherwise the paca_struct it points to may be the wrong one just after.
 */
#define get_paca()	((void) debug_smp_processor_id(), local_paca)
#else
L
Linus Torvalds 已提交
36
#define get_paca()	local_paca
37 38
#endif

39
#define get_lppaca()	(get_paca()->lppaca_ptr)
40
#define get_slb_shadow()	(get_paca()->slb_shadow_ptr)
L
Linus Torvalds 已提交
41 42 43 44 45 46 47

struct task_struct;

/*
 * Defines the layout of the paca.
 *
 * This structure is not directly accessed by firmware or the service
48
 * processor.
L
Linus Torvalds 已提交
49 50
 */
struct paca_struct {
51
#ifdef CONFIG_PPC_BOOK3S
L
Linus Torvalds 已提交
52 53 54 55 56 57 58 59
	/*
	 * Because hw_cpu_id, unlike other paca fields, is accessed
	 * routinely from other CPUs (from the IRQ code), we stick to
	 * read-only (after boot) fields in the first cacheline to
	 * avoid cacheline bouncing.
	 */

	struct lppaca *lppaca_ptr;	/* Pointer to LpPaca for PLIC */
60
#endif /* CONFIG_PPC_BOOK3S */
L
Linus Torvalds 已提交
61
	/*
62
	 * MAGIC: the spinlock functions in arch/powerpc/lib/locks.c 
L
Linus Torvalds 已提交
63 64 65 66 67 68 69 70
	 * load lock_token and paca_index with a single lwz
	 * instruction.  They must travel together and be properly
	 * aligned.
	 */
	u16 lock_token;			/* Constant 0x8000, used in locks */
	u16 paca_index;			/* Logical processor number */

	u64 kernel_toc;			/* Kernel TOC address */
71 72
	u64 kernelbase;			/* Base address of kernel */
	u64 kernel_msr;			/* MSR while running in kernel */
73
#ifdef CONFIG_PPC_STD_MMU_64
L
Linus Torvalds 已提交
74 75
	u64 stab_real;			/* Absolute address of segment table */
	u64 stab_addr;			/* Virtual address of segment table */
76
#endif /* CONFIG_PPC_STD_MMU_64 */
L
Linus Torvalds 已提交
77
	void *emergency_sp;		/* pointer to emergency stack */
78
	u64 data_offset;		/* per cpu data offset */
L
Linus Torvalds 已提交
79 80 81
	s16 hw_cpu_id;			/* Physical processor number */
	u8 cpu_start;			/* At startup, processor spins until */
					/* this becomes non-zero. */
82
#ifdef CONFIG_PPC_STD_MMU_64
83
	struct slb_shadow *slb_shadow_ptr;
L
Linus Torvalds 已提交
84 85 86 87

	/*
	 * Now, starting in cacheline 2, the exception save areas
	 */
88 89 90 91 92
	/* used for most interrupts/exceptions */
	u64 exgen[10] __attribute__((aligned(0x80)));
	u64 exmc[10];		/* used for machine checks */
	u64 exslb[10];		/* used for SLB/segment table misses
 				 * on the linear mapping */
93
	/* SLB related definitions */
94
	u16 vmalloc_sllp;
L
Linus Torvalds 已提交
95
	u16 slb_cache_ptr;
96
	u16 slb_cache[SLB_CACHE_ENTRIES];
97 98
#endif /* CONFIG_PPC_STD_MMU_64 */

99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
#ifdef CONFIG_PPC_BOOK3E
	pgd_t *pgd;			/* Current PGD */
	pgd_t *kernel_pgd;		/* Kernel PGD */
	u64 exgen[8] __attribute__((aligned(0x80)));
	u64 extlb[EX_TLB_SIZE*3] __attribute__((aligned(0x80)));
	u64 exmc[8];		/* used for machine checks */
	u64 excrit[8];		/* used for crit interrupts */
	u64 exdbg[8];		/* used for debug interrupts */

	/* Kernel stack pointers for use by special exceptions */
	void *mc_kstack;
	void *crit_kstack;
	void *dbg_kstack;
#endif /* CONFIG_PPC_BOOK3E */

114
	mm_context_t context;
L
Linus Torvalds 已提交
115 116 117 118 119 120 121 122 123

	/*
	 * then miscellaneous read-write fields
	 */
	struct task_struct *__current;	/* Pointer to current */
	u64 kstack;			/* Saved Kernel stack addr */
	u64 stab_rr;			/* stab/slb round-robin counter */
	u64 saved_r1;			/* r1 save for RTAS calls */
	u64 saved_msr;			/* MSR saved here by enter_rtas */
124
	u16 trap_save;			/* Used when bad stack is encountered */
125 126
	u8 soft_enabled;		/* irq soft-enable flag */
	u8 hard_enabled;		/* set if irqs are enabled in MSR */
127
	u8 io_sync;			/* writel() needs spin_unlock sync */
I
Ingo Molnar 已提交
128
	u8 perf_event_pending;		/* PM interrupt while soft-disabled */
129 130 131 132 133

	/* Stuff for accurate time accounting */
	u64 user_time;			/* accumulated usermode TB ticks */
	u64 system_time;		/* accumulated system TB ticks */
	u64 startpurr;			/* PURR/TB value snapshot */
134
	u64 startspurr;			/* SPURR value snapshot */
A
Alexander Graf 已提交
135 136 137 138 139 140

#ifdef CONFIG_KVM_BOOK3S_64_HANDLER
	struct  {
		u64     esid;
		u64     vsid;
	} kvm_slb[64];			/* guest SLB */
141 142
	/* We use this to store guest state in */
	struct kvmppc_book3s_shadow_vcpu shadow_vcpu;
A
Alexander Graf 已提交
143 144 145
	u8 kvm_slb_max;			/* highest used guest slb entry */
	u8 kvm_in_guest;		/* are we inside the guest? */
#endif
L
Linus Torvalds 已提交
146 147 148
};

extern struct paca_struct paca[];
149
extern void initialise_pacas(void);
L
Linus Torvalds 已提交
150

151
#endif /* __KERNEL__ */
152
#endif /* _ASM_POWERPC_PACA_H */