1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Port on Texas Instruments TMS320C6x architecture
5 * Copyright (C) 2004, 2009, 2010, 2011 Texas Instruments Incorporated
6 * Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com)
8 #ifndef _ASM_C6X_SPECIAL_INSNS_H
9 #define _ASM_C6X_SPECIAL_INSNS_H
12 #define get_creg(reg) \
13 ({ unsigned int __x; \
14 asm volatile ("mvc .s2 " #reg ",%0\n" : "=b"(__x)); __x; })
16 #define set_creg(reg, v) \
17 do { unsigned int __x = (unsigned int)(v); \
18 asm volatile ("mvc .s2 %0," #reg "\n" : : "b"(__x)); \
21 #define or_creg(reg, n) \
22 do { unsigned __x, __n = (unsigned)(n); \
23 asm volatile ("mvc .s2 " #reg ",%0\n" \
25 "mvc .s2 %0," #reg "\n" \
27 : "=&b"(__x) : "b"(__n)); \
30 #define and_creg(reg, n) \
31 do { unsigned __x, __n = (unsigned)(n); \
32 asm volatile ("mvc .s2 " #reg ",%0\n" \
33 "and .l2 %1,%0,%0\n" \
34 "mvc .s2 %0," #reg "\n" \
36 : "=&b"(__x) : "b"(__n)); \
39 #define get_coreid() (get_creg(DNUM) & 0xff)
42 #define set_ist(x) set_creg(ISTP, x)
43 #define get_ist() get_creg(ISTP)
46 * Exception management
48 #define disable_exception()
49 #define get_except_type() get_creg(EFR)
50 #define ack_exception(type) set_creg(ECR, 1 << (type))
51 #define get_iexcept() get_creg(IERR)
52 #define set_iexcept(mask) set_creg(IERR, (mask))
54 #define _extu(x, s, e) \
55 ({ unsigned int __x; \
56 asm volatile ("extu .S2 %3,%1,%2,%0\n" : \
57 "=b"(__x) : "n"(s), "n"(e), "b"(x)); \
60 #endif /* _ASM_C6X_SPECIAL_INSNS_H */