18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * arch/alpha/lib/fpreg.c 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * (C) Copyright 1998 Linus Torvalds 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#include <linux/compiler.h> 98c2ecf20Sopenharmony_ci#include <linux/export.h> 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#if defined(CONFIG_ALPHA_EV6) || defined(CONFIG_ALPHA_EV67) 128c2ecf20Sopenharmony_ci#define STT(reg,val) asm volatile ("ftoit $f"#reg",%0" : "=r"(val)); 138c2ecf20Sopenharmony_ci#else 148c2ecf20Sopenharmony_ci#define STT(reg,val) asm volatile ("stt $f"#reg",%0" : "=m"(val)); 158c2ecf20Sopenharmony_ci#endif 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ciunsigned long 188c2ecf20Sopenharmony_cialpha_read_fp_reg (unsigned long reg) 198c2ecf20Sopenharmony_ci{ 208c2ecf20Sopenharmony_ci unsigned long val; 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci switch (reg) { 238c2ecf20Sopenharmony_ci case 0: STT( 0, val); break; 248c2ecf20Sopenharmony_ci case 1: STT( 1, val); break; 258c2ecf20Sopenharmony_ci case 2: STT( 2, val); break; 268c2ecf20Sopenharmony_ci case 3: STT( 3, val); break; 278c2ecf20Sopenharmony_ci case 4: STT( 4, val); break; 288c2ecf20Sopenharmony_ci case 5: STT( 5, val); break; 298c2ecf20Sopenharmony_ci case 6: STT( 6, val); break; 308c2ecf20Sopenharmony_ci case 7: STT( 7, val); break; 318c2ecf20Sopenharmony_ci case 8: STT( 8, val); break; 328c2ecf20Sopenharmony_ci case 9: STT( 9, val); break; 338c2ecf20Sopenharmony_ci case 10: STT(10, val); break; 348c2ecf20Sopenharmony_ci case 11: STT(11, val); break; 358c2ecf20Sopenharmony_ci case 12: STT(12, val); break; 368c2ecf20Sopenharmony_ci case 13: STT(13, val); break; 378c2ecf20Sopenharmony_ci case 14: STT(14, val); break; 388c2ecf20Sopenharmony_ci case 15: STT(15, val); break; 398c2ecf20Sopenharmony_ci case 16: STT(16, val); break; 408c2ecf20Sopenharmony_ci case 17: STT(17, val); break; 418c2ecf20Sopenharmony_ci case 18: STT(18, val); break; 428c2ecf20Sopenharmony_ci case 19: STT(19, val); break; 438c2ecf20Sopenharmony_ci case 20: STT(20, val); break; 448c2ecf20Sopenharmony_ci case 21: STT(21, val); break; 458c2ecf20Sopenharmony_ci case 22: STT(22, val); break; 468c2ecf20Sopenharmony_ci case 23: STT(23, val); break; 478c2ecf20Sopenharmony_ci case 24: STT(24, val); break; 488c2ecf20Sopenharmony_ci case 25: STT(25, val); break; 498c2ecf20Sopenharmony_ci case 26: STT(26, val); break; 508c2ecf20Sopenharmony_ci case 27: STT(27, val); break; 518c2ecf20Sopenharmony_ci case 28: STT(28, val); break; 528c2ecf20Sopenharmony_ci case 29: STT(29, val); break; 538c2ecf20Sopenharmony_ci case 30: STT(30, val); break; 548c2ecf20Sopenharmony_ci case 31: STT(31, val); break; 558c2ecf20Sopenharmony_ci default: return 0; 568c2ecf20Sopenharmony_ci } 578c2ecf20Sopenharmony_ci return val; 588c2ecf20Sopenharmony_ci} 598c2ecf20Sopenharmony_ciEXPORT_SYMBOL(alpha_read_fp_reg); 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ci#if defined(CONFIG_ALPHA_EV6) || defined(CONFIG_ALPHA_EV67) 628c2ecf20Sopenharmony_ci#define LDT(reg,val) asm volatile ("itoft %0,$f"#reg : : "r"(val)); 638c2ecf20Sopenharmony_ci#else 648c2ecf20Sopenharmony_ci#define LDT(reg,val) asm volatile ("ldt $f"#reg",%0" : : "m"(val)); 658c2ecf20Sopenharmony_ci#endif 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_civoid 688c2ecf20Sopenharmony_cialpha_write_fp_reg (unsigned long reg, unsigned long val) 698c2ecf20Sopenharmony_ci{ 708c2ecf20Sopenharmony_ci switch (reg) { 718c2ecf20Sopenharmony_ci case 0: LDT( 0, val); break; 728c2ecf20Sopenharmony_ci case 1: LDT( 1, val); break; 738c2ecf20Sopenharmony_ci case 2: LDT( 2, val); break; 748c2ecf20Sopenharmony_ci case 3: LDT( 3, val); break; 758c2ecf20Sopenharmony_ci case 4: LDT( 4, val); break; 768c2ecf20Sopenharmony_ci case 5: LDT( 5, val); break; 778c2ecf20Sopenharmony_ci case 6: LDT( 6, val); break; 788c2ecf20Sopenharmony_ci case 7: LDT( 7, val); break; 798c2ecf20Sopenharmony_ci case 8: LDT( 8, val); break; 808c2ecf20Sopenharmony_ci case 9: LDT( 9, val); break; 818c2ecf20Sopenharmony_ci case 10: LDT(10, val); break; 828c2ecf20Sopenharmony_ci case 11: LDT(11, val); break; 838c2ecf20Sopenharmony_ci case 12: LDT(12, val); break; 848c2ecf20Sopenharmony_ci case 13: LDT(13, val); break; 858c2ecf20Sopenharmony_ci case 14: LDT(14, val); break; 868c2ecf20Sopenharmony_ci case 15: LDT(15, val); break; 878c2ecf20Sopenharmony_ci case 16: LDT(16, val); break; 888c2ecf20Sopenharmony_ci case 17: LDT(17, val); break; 898c2ecf20Sopenharmony_ci case 18: LDT(18, val); break; 908c2ecf20Sopenharmony_ci case 19: LDT(19, val); break; 918c2ecf20Sopenharmony_ci case 20: LDT(20, val); break; 928c2ecf20Sopenharmony_ci case 21: LDT(21, val); break; 938c2ecf20Sopenharmony_ci case 22: LDT(22, val); break; 948c2ecf20Sopenharmony_ci case 23: LDT(23, val); break; 958c2ecf20Sopenharmony_ci case 24: LDT(24, val); break; 968c2ecf20Sopenharmony_ci case 25: LDT(25, val); break; 978c2ecf20Sopenharmony_ci case 26: LDT(26, val); break; 988c2ecf20Sopenharmony_ci case 27: LDT(27, val); break; 998c2ecf20Sopenharmony_ci case 28: LDT(28, val); break; 1008c2ecf20Sopenharmony_ci case 29: LDT(29, val); break; 1018c2ecf20Sopenharmony_ci case 30: LDT(30, val); break; 1028c2ecf20Sopenharmony_ci case 31: LDT(31, val); break; 1038c2ecf20Sopenharmony_ci } 1048c2ecf20Sopenharmony_ci} 1058c2ecf20Sopenharmony_ciEXPORT_SYMBOL(alpha_write_fp_reg); 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_ci#if defined(CONFIG_ALPHA_EV6) || defined(CONFIG_ALPHA_EV67) 1088c2ecf20Sopenharmony_ci#define STS(reg,val) asm volatile ("ftois $f"#reg",%0" : "=r"(val)); 1098c2ecf20Sopenharmony_ci#else 1108c2ecf20Sopenharmony_ci#define STS(reg,val) asm volatile ("sts $f"#reg",%0" : "=m"(val)); 1118c2ecf20Sopenharmony_ci#endif 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ciunsigned long 1148c2ecf20Sopenharmony_cialpha_read_fp_reg_s (unsigned long reg) 1158c2ecf20Sopenharmony_ci{ 1168c2ecf20Sopenharmony_ci unsigned long val; 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_ci switch (reg) { 1198c2ecf20Sopenharmony_ci case 0: STS( 0, val); break; 1208c2ecf20Sopenharmony_ci case 1: STS( 1, val); break; 1218c2ecf20Sopenharmony_ci case 2: STS( 2, val); break; 1228c2ecf20Sopenharmony_ci case 3: STS( 3, val); break; 1238c2ecf20Sopenharmony_ci case 4: STS( 4, val); break; 1248c2ecf20Sopenharmony_ci case 5: STS( 5, val); break; 1258c2ecf20Sopenharmony_ci case 6: STS( 6, val); break; 1268c2ecf20Sopenharmony_ci case 7: STS( 7, val); break; 1278c2ecf20Sopenharmony_ci case 8: STS( 8, val); break; 1288c2ecf20Sopenharmony_ci case 9: STS( 9, val); break; 1298c2ecf20Sopenharmony_ci case 10: STS(10, val); break; 1308c2ecf20Sopenharmony_ci case 11: STS(11, val); break; 1318c2ecf20Sopenharmony_ci case 12: STS(12, val); break; 1328c2ecf20Sopenharmony_ci case 13: STS(13, val); break; 1338c2ecf20Sopenharmony_ci case 14: STS(14, val); break; 1348c2ecf20Sopenharmony_ci case 15: STS(15, val); break; 1358c2ecf20Sopenharmony_ci case 16: STS(16, val); break; 1368c2ecf20Sopenharmony_ci case 17: STS(17, val); break; 1378c2ecf20Sopenharmony_ci case 18: STS(18, val); break; 1388c2ecf20Sopenharmony_ci case 19: STS(19, val); break; 1398c2ecf20Sopenharmony_ci case 20: STS(20, val); break; 1408c2ecf20Sopenharmony_ci case 21: STS(21, val); break; 1418c2ecf20Sopenharmony_ci case 22: STS(22, val); break; 1428c2ecf20Sopenharmony_ci case 23: STS(23, val); break; 1438c2ecf20Sopenharmony_ci case 24: STS(24, val); break; 1448c2ecf20Sopenharmony_ci case 25: STS(25, val); break; 1458c2ecf20Sopenharmony_ci case 26: STS(26, val); break; 1468c2ecf20Sopenharmony_ci case 27: STS(27, val); break; 1478c2ecf20Sopenharmony_ci case 28: STS(28, val); break; 1488c2ecf20Sopenharmony_ci case 29: STS(29, val); break; 1498c2ecf20Sopenharmony_ci case 30: STS(30, val); break; 1508c2ecf20Sopenharmony_ci case 31: STS(31, val); break; 1518c2ecf20Sopenharmony_ci default: return 0; 1528c2ecf20Sopenharmony_ci } 1538c2ecf20Sopenharmony_ci return val; 1548c2ecf20Sopenharmony_ci} 1558c2ecf20Sopenharmony_ciEXPORT_SYMBOL(alpha_read_fp_reg_s); 1568c2ecf20Sopenharmony_ci 1578c2ecf20Sopenharmony_ci#if defined(CONFIG_ALPHA_EV6) || defined(CONFIG_ALPHA_EV67) 1588c2ecf20Sopenharmony_ci#define LDS(reg,val) asm volatile ("itofs %0,$f"#reg : : "r"(val)); 1598c2ecf20Sopenharmony_ci#else 1608c2ecf20Sopenharmony_ci#define LDS(reg,val) asm volatile ("lds $f"#reg",%0" : : "m"(val)); 1618c2ecf20Sopenharmony_ci#endif 1628c2ecf20Sopenharmony_ci 1638c2ecf20Sopenharmony_civoid 1648c2ecf20Sopenharmony_cialpha_write_fp_reg_s (unsigned long reg, unsigned long val) 1658c2ecf20Sopenharmony_ci{ 1668c2ecf20Sopenharmony_ci switch (reg) { 1678c2ecf20Sopenharmony_ci case 0: LDS( 0, val); break; 1688c2ecf20Sopenharmony_ci case 1: LDS( 1, val); break; 1698c2ecf20Sopenharmony_ci case 2: LDS( 2, val); break; 1708c2ecf20Sopenharmony_ci case 3: LDS( 3, val); break; 1718c2ecf20Sopenharmony_ci case 4: LDS( 4, val); break; 1728c2ecf20Sopenharmony_ci case 5: LDS( 5, val); break; 1738c2ecf20Sopenharmony_ci case 6: LDS( 6, val); break; 1748c2ecf20Sopenharmony_ci case 7: LDS( 7, val); break; 1758c2ecf20Sopenharmony_ci case 8: LDS( 8, val); break; 1768c2ecf20Sopenharmony_ci case 9: LDS( 9, val); break; 1778c2ecf20Sopenharmony_ci case 10: LDS(10, val); break; 1788c2ecf20Sopenharmony_ci case 11: LDS(11, val); break; 1798c2ecf20Sopenharmony_ci case 12: LDS(12, val); break; 1808c2ecf20Sopenharmony_ci case 13: LDS(13, val); break; 1818c2ecf20Sopenharmony_ci case 14: LDS(14, val); break; 1828c2ecf20Sopenharmony_ci case 15: LDS(15, val); break; 1838c2ecf20Sopenharmony_ci case 16: LDS(16, val); break; 1848c2ecf20Sopenharmony_ci case 17: LDS(17, val); break; 1858c2ecf20Sopenharmony_ci case 18: LDS(18, val); break; 1868c2ecf20Sopenharmony_ci case 19: LDS(19, val); break; 1878c2ecf20Sopenharmony_ci case 20: LDS(20, val); break; 1888c2ecf20Sopenharmony_ci case 21: LDS(21, val); break; 1898c2ecf20Sopenharmony_ci case 22: LDS(22, val); break; 1908c2ecf20Sopenharmony_ci case 23: LDS(23, val); break; 1918c2ecf20Sopenharmony_ci case 24: LDS(24, val); break; 1928c2ecf20Sopenharmony_ci case 25: LDS(25, val); break; 1938c2ecf20Sopenharmony_ci case 26: LDS(26, val); break; 1948c2ecf20Sopenharmony_ci case 27: LDS(27, val); break; 1958c2ecf20Sopenharmony_ci case 28: LDS(28, val); break; 1968c2ecf20Sopenharmony_ci case 29: LDS(29, val); break; 1978c2ecf20Sopenharmony_ci case 30: LDS(30, val); break; 1988c2ecf20Sopenharmony_ci case 31: LDS(31, val); break; 1998c2ecf20Sopenharmony_ci } 2008c2ecf20Sopenharmony_ci} 2018c2ecf20Sopenharmony_ciEXPORT_SYMBOL(alpha_write_fp_reg_s); 202