arch.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /****************************************************************************
  2. * arch/risc-v/include/arch.h
  3. *
  4. * Licensed to the Apache Software Foundation (ASF) under one or more
  5. * contributor license agreements. See the NOTICE file distributed with
  6. * this work for additional information regarding copyright ownership. The
  7. * ASF licenses this file to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance with the
  9. * License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  15. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  16. * License for the specific language governing permissions and limitations
  17. * under the License.
  18. *
  19. ****************************************************************************/
  20. /* This file should never be included directly but, rather,
  21. * only indirectly through nuttx/arch.h
  22. */
  23. #ifndef __ARCH_RISCV_INCLUDE_ARCH_H
  24. #define __ARCH_RISCV_INCLUDE_ARCH_H
  25. /****************************************************************************
  26. * Included Files
  27. ****************************************************************************/
  28. #include <nuttx/config.h>
  29. #ifndef __ASSEMBLY__
  30. # include <stdint.h>
  31. #endif
  32. #include <arch/csr.h>
  33. #ifdef CONFIG_ARCH_RV32IM
  34. # include <arch/rv32im/arch.h>
  35. #endif
  36. #ifdef CONFIG_ARCH_RV64GC
  37. # include <arch/rv64gc/arch.h>
  38. #endif
  39. /****************************************************************************
  40. * Pre-processor Definitions
  41. ****************************************************************************/
  42. /* Macros to get the core and vendor ID, HART, arch and ISA codes, etc.
  43. */
  44. #ifdef CONFIG_RV32IM_SYSTEM_CSRRS_SUPPORT
  45. uint32_t up_getmisa(void);
  46. uint32_t up_getarchid(void);
  47. uint32_t up_getimpid(void);
  48. uint32_t up_getvendorid(void);
  49. uint32_t up_gethartid(void);
  50. #else
  51. #define up_getmisa() 0
  52. #define up_getarchid() 0
  53. #define up_getimpid() 0
  54. #define up_getvendorid() 0
  55. #define up_gethartid() 0
  56. #endif
  57. /****************************************************************************
  58. * Inline functions
  59. ****************************************************************************/
  60. /****************************************************************************
  61. * Public Types
  62. ****************************************************************************/
  63. /****************************************************************************
  64. * Public Function Prototypes
  65. ****************************************************************************/
  66. #ifdef CONFIG_RV32IM_HW_MULDIV
  67. uint32_t up_hard_mul(uint32_t a, uint32_t b);
  68. uint32_t up_hard_mulh(uint32_t a, uint32_t b);
  69. uint32_t up_hard_mulhsu(uint32_t a, uint32_t b);
  70. uint32_t up_hard_mulhu(uint32_t a, uint32_t b);
  71. uint32_t up_hard_div(uint32_t a, uint32_t b);
  72. uint32_t up_hard_rem(uint32_t a, uint32_t b);
  73. uint32_t up_hard_divu(uint32_t a, uint32_t b);
  74. uint32_t up_hard_remu(uint32_t a, uint32_t b);
  75. uint32_t time_hard_mul(uint32_t a, uint32_t b, uint32_t *t);
  76. #endif
  77. #ifdef __cplusplus
  78. #define EXTERN extern "C"
  79. extern "C"
  80. {
  81. #else
  82. #define EXTERN extern
  83. #endif
  84. #undef EXTERN
  85. #ifdef __cplusplus
  86. }
  87. #endif
  88. #endif /* __ARCH_RISCV_INCLUDE_ARCH_H */