portmacro.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /*
  2. * FreeRTOS Kernel V10.3.1
  3. * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  6. * this software and associated documentation files (the "Software"), to deal in
  7. * the Software without restriction, including without limitation the rights to
  8. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  9. * the Software, and to permit persons to whom the Software is furnished to do so,
  10. * subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be included in all
  13. * copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  17. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  18. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  19. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  20. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. * http://www.FreeRTOS.org
  23. * http://aws.amazon.com/freertos
  24. *
  25. * 1 tab == 4 spaces!
  26. */
  27. #ifndef PORTMACRO_H
  28. #define PORTMACRO_H
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. #include "nuclei_sdk_soc.h"
  33. /*-----------------------------------------------------------
  34. * Port specific definitions.
  35. *
  36. * The settings in this file configure FreeRTOS correctly for the
  37. * given hardware and compiler.
  38. *
  39. * These settings should not be altered.
  40. *-----------------------------------------------------------
  41. */
  42. /* Type definitions. */
  43. #define portCHAR char
  44. #define portFLOAT float
  45. #define portDOUBLE double
  46. #define portLONG long
  47. #define portSHORT short
  48. #define portSTACK_TYPE unsigned long
  49. #define portBASE_TYPE long
  50. #define portPOINTER_SIZE_TYPE unsigned long
  51. typedef portSTACK_TYPE StackType_t;
  52. typedef long BaseType_t;
  53. typedef unsigned long UBaseType_t;
  54. #if( configUSE_16_BIT_TICKS == 1 )
  55. typedef uint16_t TickType_t;
  56. #define portMAX_DELAY ( TickType_t )0xffff
  57. #else
  58. /* RISC-V TIMER is 64-bit long */
  59. typedef uint32_t TickType_t;
  60. #define portMAX_DELAY ( TickType_t )0x00FFFFFF
  61. #endif
  62. /*-----------------------------------------------------------*/
  63. /* Architecture specifics. */
  64. #define portSTACK_GROWTH ( -1 )
  65. #define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
  66. #ifndef __riscv_32e
  67. #define portBYTE_ALIGNMENT 16
  68. #else
  69. #define portBYTE_ALIGNMENT 4
  70. #endif
  71. /*-----------------------------------------------------------*/
  72. /* Scheduler utilities. */
  73. #define portYIELD() \
  74. { \
  75. /* Set a software interrupt(SWI) request to request a context switch. */ \
  76. SysTimer_SetSWIRQ(); \
  77. /* Barriers are normally not required but do ensure the code is completely \
  78. within the specified behaviour for the architecture. */ \
  79. __RWMB(); \
  80. }
  81. #define portEND_SWITCHING_ISR( xSwitchRequired ) if ( xSwitchRequired != pdFALSE ) portYIELD()
  82. #define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )
  83. /*-----------------------------------------------------------*/
  84. /* Critical section management. */
  85. extern void vPortEnterCritical(void);
  86. extern void vPortExitCritical(void);
  87. #define portSET_INTERRUPT_MASK_FROM_ISR() 0x0
  88. #define portCLEAR_INTERRUPT_MASK_FROM_ISR(x)
  89. #define portDISABLE_INTERRUPTS() __disable_irq()
  90. #define portENABLE_INTERRUPTS() __enable_irq()
  91. #define portENTER_CRITICAL() vPortEnterCritical()
  92. #define portEXIT_CRITICAL() vPortExitCritical()
  93. /*-----------------------------------------------------------*/
  94. /* Task function macros as described on the FreeRTOS.org WEB site. These are
  95. not necessary for to use this port. They are defined so the common demo files
  96. (which build with all the ports) will build. */
  97. #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )
  98. #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
  99. /*-----------------------------------------------------------*/
  100. /* Tickless idle/low power functionality. */
  101. #ifndef portSUPPRESS_TICKS_AND_SLEEP
  102. extern void vPortSuppressTicksAndSleep(TickType_t xExpectedIdleTime);
  103. #define portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime ) vPortSuppressTicksAndSleep( xExpectedIdleTime )
  104. #endif
  105. /*-----------------------------------------------------------*/
  106. /*-----------------------------------------------------------*/
  107. #ifdef configASSERT
  108. extern void vPortValidateInterruptPriority(void);
  109. #define portASSERT_IF_INTERRUPT_PRIORITY_INVALID() vPortValidateInterruptPriority()
  110. #endif
  111. /* portNOP() is not required by this port. */
  112. #define portNOP() __NOP()
  113. #define portINLINE __inline
  114. #ifndef portFORCE_INLINE
  115. #define portFORCE_INLINE inline __attribute__(( always_inline))
  116. #endif
  117. #define portMEMORY_BARRIER() __asm volatile( "" ::: "memory" )
  118. #ifdef __cplusplus
  119. }
  120. #endif
  121. #endif /* PORTMACRO_H */