portasm.s26 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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. #include "ISR_Support.h"
  29. ;------------------------------------------------------------------------------
  30. #if __CORE__ != __78K0R__
  31. #error "This file is only for 78K0R Devices"
  32. #endif
  33. #define CS 0xFFFFC
  34. #define ES 0xFFFFD
  35. ; Functions implemented in this file
  36. ;------------------------------------------------------------------------------
  37. PUBLIC vPortYield
  38. PUBLIC vPortStart
  39. ; Functions used by scheduler
  40. ;------------------------------------------------------------------------------
  41. EXTERN vTaskSwitchContext
  42. EXTERN xTaskIncrementTick
  43. ; Tick ISR Prototype
  44. ;------------------------------------------------------------------------------
  45. ; EXTERN ?CL78K0R_V2_L00
  46. PUBWEAK `??MD_INTTM05??INTVEC 68`
  47. PUBLIC MD_INTTM05
  48. MD_INTTM05 SYMBOL "MD_INTTM05"
  49. `??MD_INTTM05??INTVEC 68` SYMBOL "??INTVEC 68", MD_INTTM05
  50. ;------------------------------------------------------------------------------
  51. ; Yield to another task. Implemented as a software interrupt. The return
  52. ; address and PSW will have been saved to the stack automatically before
  53. ; this code runs.
  54. ;
  55. ; Input: NONE
  56. ;
  57. ; Call: CALL vPortYield
  58. ;
  59. ; Output: NONE
  60. ;
  61. ;------------------------------------------------------------------------------
  62. RSEG CODE:CODE
  63. vPortYield:
  64. portSAVE_CONTEXT ; Save the context of the current task.
  65. call vTaskSwitchContext ; Call the scheduler to select the next task.
  66. portRESTORE_CONTEXT ; Restore the context of the next task to run.
  67. retb
  68. ;------------------------------------------------------------------------------
  69. ; Restore the context of the first task that is going to run.
  70. ;
  71. ; Input: NONE
  72. ;
  73. ; Call: CALL vPortStart
  74. ;
  75. ; Output: NONE
  76. ;
  77. ;------------------------------------------------------------------------------
  78. RSEG CODE:CODE
  79. vPortStart:
  80. portRESTORE_CONTEXT ; Restore the context of whichever task the ...
  81. reti ; An interrupt stack frame is used so the task
  82. ; is started using a RETI instruction.
  83. ;------------------------------------------------------------------------------
  84. ; Perform the necessary steps of the Tick Count Increment and Task Switch
  85. ; depending on the chosen kernel configuration
  86. ;
  87. ; Input: NONE
  88. ;
  89. ; Call: ISR
  90. ;
  91. ; Output: NONE
  92. ;
  93. ;------------------------------------------------------------------------------
  94. MD_INTTM05:
  95. portSAVE_CONTEXT ; Save the context of the current task.
  96. call xTaskIncrementTick ; Call the timer tick function.
  97. #if configUSE_PREEMPTION == 1
  98. call vTaskSwitchContext ; Call the scheduler to select the next task.
  99. #endif
  100. portRESTORE_CONTEXT ; Restore the context of the next task to run.
  101. reti
  102. ; REQUIRE ?CL78K0R_V2_L00
  103. COMMON INTVEC:CODE:ROOT(1) ; Set ISR location to the Interrupt vector table.
  104. ORG 68
  105. `??MD_INTTM05??INTVEC 68`:
  106. DW MD_INTTM05
  107. COMMON INTVEC:CODE:ROOT(1) ; Set ISR location to the Interrupt vector table.
  108. ORG 126
  109. `??vPortYield??INTVEC 126`:
  110. DW vPortYield
  111. ; Set value for the usCriticalNesting.
  112. RSEG NEAR_ID:CONST:SORT:NOROOT(1)
  113. `?<Initializer for usCriticalNesting>`:
  114. DW 10
  115. ;#endif
  116. END