Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Paul Mackerras | 31cdd0c | 2016-04-13 21:31:24 +1000 | [diff] [blame] | 2 | #include <asm/ppc_asm.h> |
Christophe Leroy | ec0c464 | 2018-07-05 16:24:57 +0000 | [diff] [blame] | 3 | #include <asm/asm-compat.h> |
Paul Mackerras | 31cdd0c | 2016-04-13 21:31:24 +1000 | [diff] [blame] | 4 | |
| 5 | /* unsigned long xmon_mfspr(sprn, default_value) */ |
| 6 | _GLOBAL(xmon_mfspr) |
Michael Ellerman | b42d902 | 2016-09-09 14:01:07 +1000 | [diff] [blame] | 7 | PPC_LL r5, .Lmfspr_table@got(r2) |
Paul Mackerras | 31cdd0c | 2016-04-13 21:31:24 +1000 | [diff] [blame] | 8 | b xmon_mxspr |
| 9 | |
| 10 | /* void xmon_mtspr(sprn, new_value) */ |
| 11 | _GLOBAL(xmon_mtspr) |
Michael Ellerman | b42d902 | 2016-09-09 14:01:07 +1000 | [diff] [blame] | 12 | PPC_LL r5, .Lmtspr_table@got(r2) |
Paul Mackerras | 31cdd0c | 2016-04-13 21:31:24 +1000 | [diff] [blame] | 13 | b xmon_mxspr |
| 14 | |
| 15 | /* |
| 16 | * r3 = sprn |
| 17 | * r4 = default or new value |
| 18 | * r5 = table base |
| 19 | */ |
| 20 | xmon_mxspr: |
| 21 | /* |
| 22 | * To index into the table of mxsprs we need: |
| 23 | * i = (sprn & 0x3ff) * 8 |
| 24 | * or using rwlinm: |
| 25 | * i = (sprn << 3) & (0x3ff << 3) |
| 26 | */ |
| 27 | rlwinm r3, r3, 3, 0x3ff << 3 |
| 28 | add r5, r5, r3 |
| 29 | mtctr r5 |
| 30 | mr r3, r4 /* put default_value in r3 for mfspr */ |
| 31 | bctr |
| 32 | |
| 33 | .Lmfspr_table: |
| 34 | spr = 0 |
| 35 | .rept 1024 |
| 36 | mfspr r3, spr |
| 37 | blr |
| 38 | spr = spr + 1 |
| 39 | .endr |
| 40 | |
| 41 | .Lmtspr_table: |
| 42 | spr = 0 |
| 43 | .rept 1024 |
| 44 | mtspr spr, r4 |
| 45 | blr |
| 46 | spr = spr + 1 |
| 47 | .endr |