cleanup
[linux-2.4.21-pre4.git] / arch / ppc64 / kdb / privinst.h
1 /*
2  * Copyright (C) 1996 Paul Mackerras.
3  *
4  *      This program is free software; you can redistribute it and/or
5  *      modify it under the terms of the GNU General Public License
6  *      as published by the Free Software Foundation; either version
7  *      2 of the License, or (at your option) any later version.
8  */
9 #include <linux/config.h>
10
11 #define GETREG(reg)             \
12     static inline unsigned long get_ ## reg (void)      \
13         { unsigned long ret; asm volatile ("mf" #reg " %0" : "=r" (ret) :); return ret; }
14
15 #define SETREG(reg)             \
16     static inline void set_ ## reg (unsigned long val)  \
17         { asm volatile ("mt" #reg " %0" : : "r" (val)); }
18
19 GETREG(msr)
20 SETREG(msr)
21 SETREG(msrd)
22 GETREG(cr)
23
24 #define GSETSPR(n, name)        \
25     static inline long get_ ## name (void) \
26         { long ret; asm volatile ("mfspr %0," #n : "=r" (ret) : ); return ret; } \
27     static inline void set_ ## name (long val) \
28         { asm volatile ("mtspr " #n ",%0" : : "r" (val)); }
29
30 GSETSPR(0, mq)
31 GSETSPR(1, xer)
32 GSETSPR(4, rtcu)
33 GSETSPR(5, rtcl)
34 GSETSPR(8, lr)
35 GSETSPR(9, ctr)
36 GSETSPR(18, dsisr)
37 GSETSPR(19, dar)
38 GSETSPR(22, dec)
39 GSETSPR(25, sdr1)
40 GSETSPR(26, srr0)
41 GSETSPR(27, srr1)
42 GSETSPR(272, sprg0)
43 GSETSPR(273, sprg1)
44 GSETSPR(274, sprg2)
45 GSETSPR(275, sprg3)
46 GSETSPR(282, ear)
47 GSETSPR(287, pvr)
48 GSETSPR(528, bat0u)
49 GSETSPR(529, bat0l)
50 GSETSPR(530, bat1u)
51 GSETSPR(531, bat1l)
52 GSETSPR(532, bat2u)
53 GSETSPR(533, bat2l)
54 GSETSPR(534, bat3u)
55 GSETSPR(535, bat3l)
56 GSETSPR(1008, hid0)
57 GSETSPR(1009, hid1)
58 GSETSPR(1010, iabr)
59 GSETSPR(1013, dabr)
60 GSETSPR(1023, pir)
61
62 static inline int get_sr(int n)
63 {
64     int ret;
65
66 #if 0
67 // DRENG does not assemble 
68     asm (" mfsrin %0,%1" : "=r" (ret) : "r" (n << 28));
69 #endif
70     return ret;
71 }
72
73 static inline void set_sr(int n, int val)
74 {
75 #if 0
76 // DRENG does not assemble 
77     asm ("mtsrin %0,%1" : : "r" (val), "r" (n << 28));
78 #endif
79 }
80
81 static inline void store_inst(void *p)
82 {
83     asm volatile ("dcbst 0,%0; sync; icbi 0,%0; isync" : : "r" (p));
84 }
85
86 static inline void cflush(void *p)
87 {
88     asm volatile ("dcbf 0,%0; icbi 0,%0" : : "r" (p));
89 }
90
91 static inline void cinval(void *p)
92 {
93     asm volatile ("dcbi 0,%0; icbi 0,%0" : : "r" (p));
94 }
95