1/*
2 * BK Id: SCCS/s.privinst.h 1.5 05/17/01 18:14:23 cort
3 */
4/*
5 * Copyright (C) 1996 Paul Mackerras.
6 */
7#include <linux/config.h>
8
9#define GETREG(reg)		\
10    static inline int get_ ## reg (void)	\
11	{ int ret; asm volatile ("mf" #reg " %0" : "=r" (ret) :); return ret; }
12
13#define SETREG(reg)		\
14    static inline void set_ ## reg (int val)	\
15	{ asm volatile ("mt" #reg " %0" : : "r" (val)); }
16
17GETREG(msr)
18SETREG(msr)
19GETREG(cr)
20
21#define GSETSPR(n, name)	\
22    static inline int get_ ## name (void) \
23	{ int ret; asm volatile ("mfspr %0," #n : "=r" (ret) : ); return ret; } \
24    static inline void set_ ## name (int val) \
25	{ asm volatile ("mtspr " #n ",%0" : : "r" (val)); }
26
27GSETSPR(0, mq)
28GSETSPR(1, xer)
29GSETSPR(4, rtcu)
30GSETSPR(5, rtcl)
31GSETSPR(8, lr)
32GSETSPR(9, ctr)
33GSETSPR(18, dsisr)
34GSETSPR(19, dar)
35GSETSPR(22, dec)
36GSETSPR(25, sdr1)
37GSETSPR(26, srr0)
38GSETSPR(27, srr1)
39GSETSPR(272, sprg0)
40GSETSPR(273, sprg1)
41GSETSPR(274, sprg2)
42GSETSPR(275, sprg3)
43GSETSPR(282, ear)
44GSETSPR(287, pvr)
45#ifndef CONFIG_8xx
46GSETSPR(528, bat0u)
47GSETSPR(529, bat0l)
48GSETSPR(530, bat1u)
49GSETSPR(531, bat1l)
50GSETSPR(532, bat2u)
51GSETSPR(533, bat2l)
52GSETSPR(534, bat3u)
53GSETSPR(535, bat3l)
54GSETSPR(1008, hid0)
55GSETSPR(1009, hid1)
56GSETSPR(1010, iabr)
57GSETSPR(1013, dabr)
58GSETSPR(1023, pir)
59#else
60GSETSPR(144, cmpa)
61GSETSPR(145, cmpb)
62GSETSPR(146, cmpc)
63GSETSPR(147, cmpd)
64GSETSPR(158, ictrl)
65#endif
66
67static inline int get_sr(int n)
68{
69    int ret;
70
71    asm (" mfsrin %0,%1" : "=r" (ret) : "r" (n << 28));
72    return ret;
73}
74
75static inline void set_sr(int n, int val)
76{
77    asm ("mtsrin %0,%1" : : "r" (val), "r" (n << 28));
78}
79
80static inline void store_inst(void *p)
81{
82    asm volatile ("dcbst 0,%0; sync; icbi 0,%0; isync" : : "r" (p));
83}
84
85static inline void cflush(void *p)
86{
87    asm volatile ("dcbf 0,%0; icbi 0,%0" : : "r" (p));
88}
89
90static inline void cinval(void *p)
91{
92    asm volatile ("dcbi 0,%0; icbi 0,%0" : : "r" (p));
93}
94
95