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