Paul Mackerras | 31cdd0c | 2016-04-13 21:31:24 +1000 | [diff] [blame] | 1 | #include <asm/ppc_asm.h> |
| 2 | |
| 3 | /* unsigned long xmon_mfspr(sprn, default_value) */ |
| 4 | _GLOBAL(xmon_mfspr) |
Michael Ellerman | b42d902 | 2016-09-09 14:01:07 +1000 | [diff] [blame] | 5 | PPC_LL r5, .Lmfspr_table@got(r2) |
Paul Mackerras | 31cdd0c | 2016-04-13 21:31:24 +1000 | [diff] [blame] | 6 | b xmon_mxspr |
| 7 | |
| 8 | /* void xmon_mtspr(sprn, new_value) */ |
| 9 | _GLOBAL(xmon_mtspr) |
Michael Ellerman | b42d902 | 2016-09-09 14:01:07 +1000 | [diff] [blame] | 10 | PPC_LL r5, .Lmtspr_table@got(r2) |
Paul Mackerras | 31cdd0c | 2016-04-13 21:31:24 +1000 | [diff] [blame] | 11 | b xmon_mxspr |
| 12 | |
| 13 | /* |
| 14 | * r3 = sprn |
| 15 | * r4 = default or new value |
| 16 | * r5 = table base |
| 17 | */ |
| 18 | xmon_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 |