Benjamin Herrenschmidt | 4c75a6f | 2006-11-11 17:24:53 +1100 | [diff] [blame] | 1 | /* |
| 2 | * "Indirect" DCR access |
| 3 | * |
| 4 | * Copyright (c) 2004 Eugene Surovegin <ebs@ebshome.net> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify it |
| 7 | * under the terms of the GNU General Public License as published by the |
| 8 | * Free Software Foundation; either version 2 of the License, or (at your |
| 9 | * option) any later version. |
| 10 | */ |
| 11 | |
| 12 | #include <asm/ppc_asm.h> |
| 13 | #include <asm/processor.h> |
Benjamin Herrenschmidt | 6d2170b | 2008-12-18 19:13:22 +0000 | [diff] [blame] | 14 | #include <asm/bug.h> |
Benjamin Herrenschmidt | 4c75a6f | 2006-11-11 17:24:53 +1100 | [diff] [blame] | 15 | |
| 16 | #define DCR_ACCESS_PROLOG(table) \ |
Benjamin Herrenschmidt | 6d2170b | 2008-12-18 19:13:22 +0000 | [diff] [blame] | 17 | cmpli cr0,r3,1024; \ |
Benjamin Herrenschmidt | 4c75a6f | 2006-11-11 17:24:53 +1100 | [diff] [blame] | 18 | rlwinm r3,r3,4,18,27; \ |
| 19 | lis r5,table@h; \ |
| 20 | ori r5,r5,table@l; \ |
| 21 | add r3,r3,r5; \ |
Benjamin Herrenschmidt | 6d2170b | 2008-12-18 19:13:22 +0000 | [diff] [blame] | 22 | bge- 1f; \ |
Benjamin Herrenschmidt | 4c75a6f | 2006-11-11 17:24:53 +1100 | [diff] [blame] | 23 | mtctr r3; \ |
Benjamin Herrenschmidt | 6d2170b | 2008-12-18 19:13:22 +0000 | [diff] [blame] | 24 | bctr; \ |
| 25 | 1: trap; \ |
| 26 | EMIT_BUG_ENTRY 1b,__FILE__,__LINE__,0; \ |
| 27 | blr |
Benjamin Herrenschmidt | 4c75a6f | 2006-11-11 17:24:53 +1100 | [diff] [blame] | 28 | |
| 29 | _GLOBAL(__mfdcr) |
| 30 | DCR_ACCESS_PROLOG(__mfdcr_table) |
| 31 | |
| 32 | _GLOBAL(__mtdcr) |
| 33 | DCR_ACCESS_PROLOG(__mtdcr_table) |
| 34 | |
| 35 | __mfdcr_table: |
| 36 | mfdcr r3,0; blr |
| 37 | __mtdcr_table: |
| 38 | mtdcr 0,r4; blr |
| 39 | |
| 40 | dcr = 1 |
| 41 | .rept 1023 |
| 42 | mfdcr r3,dcr; blr |
| 43 | mtdcr dcr,r4; blr |
| 44 | dcr = dcr + 1 |
| 45 | .endr |