blob: e687bb2003ff0af93028c14de2c75ad9d37b2136 [file] [log] [blame]
Benjamin Herrenschmidt4c75a6f2006-11-11 17:24:53 +11001/*
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 Herrenschmidt6d2170b2008-12-18 19:13:22 +000014#include <asm/bug.h>
Al Viro9445aa12016-01-13 23:33:46 -050015#include <asm/export.h>
Benjamin Herrenschmidt4c75a6f2006-11-11 17:24:53 +110016
17#define DCR_ACCESS_PROLOG(table) \
Benjamin Herrenschmidt6d2170b2008-12-18 19:13:22 +000018 cmpli cr0,r3,1024; \
Benjamin Herrenschmidt4c75a6f2006-11-11 17:24:53 +110019 rlwinm r3,r3,4,18,27; \
20 lis r5,table@h; \
21 ori r5,r5,table@l; \
22 add r3,r3,r5; \
Benjamin Herrenschmidt6d2170b2008-12-18 19:13:22 +000023 bge- 1f; \
Benjamin Herrenschmidt4c75a6f2006-11-11 17:24:53 +110024 mtctr r3; \
Benjamin Herrenschmidt6d2170b2008-12-18 19:13:22 +000025 bctr; \
261: trap; \
27 EMIT_BUG_ENTRY 1b,__FILE__,__LINE__,0; \
28 blr
Benjamin Herrenschmidt4c75a6f2006-11-11 17:24:53 +110029
30_GLOBAL(__mfdcr)
31 DCR_ACCESS_PROLOG(__mfdcr_table)
Al Viro9445aa12016-01-13 23:33:46 -050032EXPORT_SYMBOL(__mfdcr)
Benjamin Herrenschmidt4c75a6f2006-11-11 17:24:53 +110033
34_GLOBAL(__mtdcr)
35 DCR_ACCESS_PROLOG(__mtdcr_table)
Al Viro9445aa12016-01-13 23:33:46 -050036EXPORT_SYMBOL(__mtdcr)
Benjamin Herrenschmidt4c75a6f2006-11-11 17:24:53 +110037
38__mfdcr_table:
39 mfdcr r3,0; blr
40__mtdcr_table:
41 mtdcr 0,r4; blr
42
43dcr = 1
44 .rept 1023
45 mfdcr r3,dcr; blr
46 mtdcr dcr,r4; blr
47 dcr = dcr + 1
48 .endr