portasm.S 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. /*
  29. * Purpose: Lowest level routines for all ColdFire processors.
  30. *
  31. * Notes:
  32. *
  33. * ulPortSetIPL() and mcf5xxx_wr_cacr() copied with permission from FreeScale
  34. * supplied source files.
  35. */
  36. .global ulPortSetIPL
  37. .global mcf5xxx_wr_cacr
  38. .global __cs3_isr_interrupt_80
  39. .global vPortStartFirstTask
  40. .text
  41. .macro portSAVE_CONTEXT
  42. lea.l (-60, %sp), %sp
  43. movem.l %d0-%fp, (%sp)
  44. move.l pxCurrentTCB, %a0
  45. move.l %sp, (%a0)
  46. .endm
  47. .macro portRESTORE_CONTEXT
  48. move.l pxCurrentTCB, %a0
  49. move.l (%a0), %sp
  50. movem.l (%sp), %d0-%fp
  51. lea.l %sp@(60), %sp
  52. rte
  53. .endm
  54. /********************************************************************/
  55. /*
  56. * This routines changes the IPL to the value passed into the routine.
  57. * It also returns the old IPL value back.
  58. * Calling convention from C:
  59. * old_ipl = asm_set_ipl(new_ipl);
  60. * For the Diab Data C compiler, it passes return value thru D0.
  61. * Note that only the least significant three bits of the passed
  62. * value are used.
  63. */
  64. ulPortSetIPL:
  65. link A6,#-8
  66. movem.l D6-D7,(SP)
  67. move.w SR,D7 /* current sr */
  68. move.l D7,D0 /* prepare return value */
  69. andi.l #0x0700,D0 /* mask out IPL */
  70. lsr.l #8,D0 /* IPL */
  71. move.l 8(A6),D6 /* get argument */
  72. andi.l #0x07,D6 /* least significant three bits */
  73. lsl.l #8,D6 /* move over to make mask */
  74. andi.l #0x0000F8FF,D7 /* zero out current IPL */
  75. or.l D6,D7 /* place new IPL in sr */
  76. move.w D7,SR
  77. movem.l (SP),D6-D7
  78. lea 8(SP),SP
  79. unlk A6
  80. rts
  81. /********************************************************************/
  82. mcf5xxx_wr_cacr:
  83. move.l 4(sp),d0
  84. .long 0x4e7b0002 /* movec d0,cacr */
  85. nop
  86. rts
  87. /********************************************************************/
  88. /* Yield interrupt. */
  89. __cs3_isr_interrupt_80:
  90. portSAVE_CONTEXT
  91. jsr vPortYieldHandler
  92. portRESTORE_CONTEXT
  93. /********************************************************************/
  94. vPortStartFirstTask:
  95. portRESTORE_CONTEXT
  96. .end