portasm.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * FreeRTOS Kernel V10.4.6
  3. * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  4. *
  5. * SPDX-License-Identifier: MIT
  6. *
  7. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  8. * this software and associated documentation files (the "Software"), to deal in
  9. * the Software without restriction, including without limitation the rights to
  10. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  11. * the Software, and to permit persons to whom the Software is furnished to do so,
  12. * subject to the following conditions:
  13. *
  14. * The above copyright notice and this permission notice shall be included in all
  15. * copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  19. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  20. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  21. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  22. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  23. *
  24. * https://www.FreeRTOS.org
  25. * https://github.com/FreeRTOS
  26. *
  27. */
  28. #ifndef __PORT_ASM_H__
  29. #define __PORT_ASM_H__
  30. /* Scheduler includes. */
  31. #include "FreeRTOS.h"
  32. /* MPU wrappers includes. */
  33. #include "mpu_wrappers.h"
  34. /**
  35. * @brief Restore the context of the first task so that the first task starts
  36. * executing.
  37. */
  38. void vRestoreContextOfFirstTask( void ) __attribute__( ( naked ) ) PRIVILEGED_FUNCTION;
  39. /**
  40. * @brief Checks whether or not the processor is privileged.
  41. *
  42. * @return 1 if the processor is already privileged, 0 otherwise.
  43. */
  44. BaseType_t xIsPrivileged( void ) __attribute__( ( naked ) );
  45. /**
  46. * @brief Raises the privilege level by clearing the bit 0 of the CONTROL
  47. * register.
  48. *
  49. * @note This is a privileged function and should only be called from the kenrel
  50. * code.
  51. *
  52. * Bit 0 of the CONTROL register defines the privilege level of Thread Mode.
  53. * Bit[0] = 0 --> The processor is running privileged
  54. * Bit[0] = 1 --> The processor is running unprivileged.
  55. */
  56. void vRaisePrivilege( void ) __attribute__( ( naked ) ) PRIVILEGED_FUNCTION;
  57. /**
  58. * @brief Lowers the privilege level by setting the bit 0 of the CONTROL
  59. * register.
  60. *
  61. * Bit 0 of the CONTROL register defines the privilege level of Thread Mode.
  62. * Bit[0] = 0 --> The processor is running privileged
  63. * Bit[0] = 1 --> The processor is running unprivileged.
  64. */
  65. void vResetPrivilege( void ) __attribute__( ( naked ) );
  66. /**
  67. * @brief Starts the first task.
  68. */
  69. void vStartFirstTask( void ) __attribute__( ( naked ) ) PRIVILEGED_FUNCTION;
  70. /**
  71. * @brief Disables interrupts.
  72. */
  73. uint32_t ulSetInterruptMask( void ) __attribute__( ( naked ) ) PRIVILEGED_FUNCTION;
  74. /**
  75. * @brief Enables interrupts.
  76. */
  77. void vClearInterruptMask( uint32_t ulMask ) __attribute__( ( naked ) ) PRIVILEGED_FUNCTION;
  78. /**
  79. * @brief PendSV Exception handler.
  80. */
  81. void PendSV_Handler( void ) __attribute__( ( naked ) ) PRIVILEGED_FUNCTION;
  82. /**
  83. * @brief SVC Handler.
  84. */
  85. void SVC_Handler( void ) __attribute__( ( naked ) ) PRIVILEGED_FUNCTION;
  86. /**
  87. * @brief Allocate a Secure context for the calling task.
  88. *
  89. * @param[in] ulSecureStackSize The size of the stack to be allocated on the
  90. * secure side for the calling task.
  91. */
  92. void vPortAllocateSecureContext( uint32_t ulSecureStackSize ) __attribute__( ( naked ) );
  93. /**
  94. * @brief Free the task's secure context.
  95. *
  96. * @param[in] pulTCB Pointer to the Task Control Block (TCB) of the task.
  97. */
  98. void vPortFreeSecureContext( uint32_t * pulTCB ) __attribute__( ( naked ) ) PRIVILEGED_FUNCTION;
  99. #endif /* __PORT_ASM_H__ */