xref: /openbmc/linux/arch/powerpc/xmon/spr_access.S (revision b78412b8)
1#include <asm/ppc_asm.h>
2
3/* unsigned long xmon_mfspr(sprn, default_value) */
4_GLOBAL(xmon_mfspr)
5	PPC_LL	r5, .Lmfspr_table@got(r2)
6	b	xmon_mxspr
7
8/* void xmon_mtspr(sprn, new_value) */
9_GLOBAL(xmon_mtspr)
10	PPC_LL	r5, .Lmtspr_table@got(r2)
11	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
46