mips_fpu.h 1002 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2019-12-04 Jiaxun Yang Initial version
  9. */
  10. #ifndef _MIPS_FPU_H_
  11. #define _MIPS_FPU_H_
  12. #ifndef __ASSEMBLY__
  13. #include <mips_regs.h>
  14. /**
  15. * init hardware FPU
  16. */
  17. #ifdef RT_USING_FPU
  18. rt_inline void rt_hw_fpu_init(void)
  19. {
  20. rt_uint32_t c0_status = 0;
  21. rt_uint32_t c1_status = 0;
  22. /* Enable CU1 */
  23. c0_status = read_c0_status();
  24. c0_status |= (ST0_CU1 | ST0_FR);
  25. write_c0_status(c0_status);
  26. /* FCSR Configs */
  27. c1_status = read_c1_status();
  28. c1_status |= (FPU_CSR_FS | FPU_CSR_FO | FPU_CSR_FN); /* Set FS, FO, FN */
  29. c1_status &= ~(FPU_CSR_ALL_E); /* Disable exception */
  30. c1_status = (c1_status & (~FPU_CSR_RM)) | FPU_CSR_RN; /* Set RN */
  31. write_c1_status(c1_status);
  32. return ;
  33. }
  34. #else
  35. rt_inline void rt_hw_fpu_init(void){} /* Do nothing */
  36. #endif
  37. #endif
  38. #endif