xref: /linux/arch/powerpc/sysdev/dcr-low.S (revision a1c613ae4c322ddd58d5a8539dbfba2a0380a8c0)
12874c5fdSThomas Gleixner/* SPDX-License-Identifier: GPL-2.0-or-later */
24c75a6f4SBenjamin Herrenschmidt/*
34c75a6f4SBenjamin Herrenschmidt * "Indirect" DCR access
44c75a6f4SBenjamin Herrenschmidt *
54c75a6f4SBenjamin Herrenschmidt * Copyright (c) 2004 Eugene Surovegin <ebs@ebshome.net>
64c75a6f4SBenjamin Herrenschmidt */
74c75a6f4SBenjamin Herrenschmidt
8*39326182SMasahiro Yamada#include <linux/export.h>
94c75a6f4SBenjamin Herrenschmidt#include <asm/ppc_asm.h>
104c75a6f4SBenjamin Herrenschmidt#include <asm/processor.h>
116d2170beSBenjamin Herrenschmidt#include <asm/bug.h>
124c75a6f4SBenjamin Herrenschmidt
134c75a6f4SBenjamin Herrenschmidt#define DCR_ACCESS_PROLOG(table) \
14fef071beSMichael Ellerman	cmplwi	cr0,r3,1024;	 \
154c75a6f4SBenjamin Herrenschmidt	rlwinm  r3,r3,4,18,27;   \
164c75a6f4SBenjamin Herrenschmidt	lis     r5,table@h;      \
174c75a6f4SBenjamin Herrenschmidt	ori     r5,r5,table@l;   \
184c75a6f4SBenjamin Herrenschmidt	add     r3,r3,r5;        \
196d2170beSBenjamin Herrenschmidt	bge-	1f;		 \
204c75a6f4SBenjamin Herrenschmidt	mtctr   r3;              \
216d2170beSBenjamin Herrenschmidt	bctr;			 \
226d2170beSBenjamin Herrenschmidt1:	trap;			 \
236d2170beSBenjamin Herrenschmidt	EMIT_BUG_ENTRY 1b,__FILE__,__LINE__,0;	\
246d2170beSBenjamin Herrenschmidt	blr
254c75a6f4SBenjamin Herrenschmidt
264c75a6f4SBenjamin Herrenschmidt_GLOBAL(__mfdcr)
274c75a6f4SBenjamin Herrenschmidt	DCR_ACCESS_PROLOG(__mfdcr_table)
289445aa1aSAl ViroEXPORT_SYMBOL(__mfdcr)
294c75a6f4SBenjamin Herrenschmidt
304c75a6f4SBenjamin Herrenschmidt_GLOBAL(__mtdcr)
314c75a6f4SBenjamin Herrenschmidt	DCR_ACCESS_PROLOG(__mtdcr_table)
329445aa1aSAl ViroEXPORT_SYMBOL(__mtdcr)
334c75a6f4SBenjamin Herrenschmidt
344c75a6f4SBenjamin Herrenschmidt__mfdcr_table:
354c75a6f4SBenjamin Herrenschmidt	mfdcr  r3,0; blr
364c75a6f4SBenjamin Herrenschmidt__mtdcr_table:
374c75a6f4SBenjamin Herrenschmidt	mtdcr  0,r4; blr
384c75a6f4SBenjamin Herrenschmidt
394c75a6f4SBenjamin Herrenschmidtdcr     = 1
404c75a6f4SBenjamin Herrenschmidt        .rept   1023
414c75a6f4SBenjamin Herrenschmidt	mfdcr   r3,dcr; blr
424c75a6f4SBenjamin Herrenschmidt	mtdcr   dcr,r4; blr
434c75a6f4SBenjamin Herrenschmidt	dcr     = dcr + 1
444c75a6f4SBenjamin Herrenschmidt	.endr
45