os_cpu_port.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #ifndef _OS_CPU_PORT_H_
  2. #define _OS_CPU_PORT_H_
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #include "nuclei_sdk_soc.h"
  7. /*-----------------------------------------------------------
  8. * Port specific definitions.
  9. *
  10. * The settings in this file configure RTOS correctly for the
  11. * given hardware and compiler.
  12. *
  13. * These settings should not be altered.
  14. *-----------------------------------------------------------
  15. */
  16. /* Type definitions. */
  17. #define portCHAR char
  18. #define portFLOAT float
  19. #define portDOUBLE double
  20. #define portLONG long
  21. #define portSHORT short
  22. #define portSTACK_TYPE unsigned long
  23. #define portBASE_TYPE long
  24. #define portPOINTER_SIZE_TYPE unsigned long
  25. typedef portSTACK_TYPE StackType_t;
  26. typedef long BaseType_t;
  27. typedef unsigned long UBaseType_t;
  28. /* RISC-V TIMER is 64-bit long */
  29. typedef uint64_t TickType_t;
  30. #define portMAX_DELAY ( TickType_t )0xFFFFFFFFFFFFFFFFULL
  31. /*-----------------------------------------------------------*/
  32. /* Architecture specifics. */
  33. #define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
  34. #ifndef __riscv_32e
  35. /* The stack grows downwards (towards lower addresses) and the stack pointer shall be aligned to a 128-bit boundary upon procedure entry. */
  36. #define portBYTE_ALIGNMENT 16
  37. #else
  38. /* ILP32E calling convention The stack pointer need only be aligned to a 32-bit boundary */
  39. #define portBYTE_ALIGNMENT 4
  40. #endif
  41. /*-----------------------------------------------------------*/
  42. /* Scheduler utilities. */
  43. #define portYIELD() \
  44. { \
  45. /* Set a software interrupt(SWI) request to request a context switch. */ \
  46. SysTimer_SetSWIRQ(); \
  47. /* Barriers are normally not required but do ensure the code is completely \
  48. within the specified behaviour for the architecture. */ \
  49. __RWMB(); \
  50. }
  51. #define portDISABLE_INTERRUPTS() __RV_CSR_CLEAR(CSR_MSTATUS, MSTATUS_MIE)
  52. #define portENABLE_INTERRUPTS() __RV_CSR_SET(CSR_MSTATUS, MSTATUS_MIE)
  53. #define portENTER_CRITICAL() portDISABLE_INTERRUPTS()
  54. #define portEXIT_CRITICAL() portENABLE_INTERRUPTS()
  55. /*-----------------------------------------------------------*/
  56. /* portNOP() is not required by this port. */
  57. #define portNOP() __NOP()
  58. #define portINLINE __inline
  59. #ifndef portFORCE_INLINE
  60. #define portFORCE_INLINE inline __attribute__(( always_inline))
  61. #endif
  62. #define portMEMORY_BARRIER() __asm volatile( "" ::: "memory" )
  63. #ifdef __cplusplus
  64. }
  65. #endif
  66. #endif