blob: 7d8b0e8ed6d9e07df3a8394907881cbaf9858fd0 [file] [log] [blame]
Paul Mackerras31cdd0c2016-04-13 21:31:24 +10001#include <asm/ppc_asm.h>
2
3/* unsigned long xmon_mfspr(sprn, default_value) */
4_GLOBAL(xmon_mfspr)
Michael Ellermanb42d9022016-09-09 14:01:07 +10005 PPC_LL r5, .Lmfspr_table@got(r2)
Paul Mackerras31cdd0c2016-04-13 21:31:24 +10006 b xmon_mxspr
7
8/* void xmon_mtspr(sprn, new_value) */
9_GLOBAL(xmon_mtspr)
Michael Ellermanb42d9022016-09-09 14:01:07 +100010 PPC_LL r5, .Lmtspr_table@got(r2)
Paul Mackerras31cdd0c2016-04-13 21:31:24 +100011 b xmon_mxspr
12
13/*
14 * r3 = sprn
15 * r4 = default or new value
16 * r5 = table base
17 */
18xmon_mxspr:
19 /*
20 * To index into the table of mxsprs we need:
21 * i = (sprn & 0x3ff) * 8
22 * or using rwlinm:
23 * i = (sprn << 3) & (0x3ff << 3)
24 */
25 rlwinm r3, r3, 3, 0x3ff << 3
26 add r5, r5, r3
27 mtctr r5
28 mr r3, r4 /* put default_value in r3 for mfspr */
29 bctr
30
31.Lmfspr_table:
32 spr = 0
33 .rept 1024
34 mfspr r3, spr
35 blr
36 spr = spr + 1
37 .endr
38
39.Lmtspr_table:
40 spr = 0
41 .rept 1024
42 mtspr spr, r4
43 blr
44 spr = spr + 1
45 .endr