1/* 2 * Copyright (C) 2017 C-SKY Microsystems Co., Ltd. All rights reserved. 3 * 4 * SPDX-License-Identifier: MIT 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy of 7 * this software and associated documentation files (the "Software"), to deal in 8 * the Software without restriction, including without limitation the rights to 9 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 * the Software, and to permit persons to whom the Software is furnished to do so, 11 * subject to the following conditions: 12 * 13 * The above copyright notice and this permission notice shall be included in all 14 * copies or substantial portions of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 * 23 */ 24 25//#include <csi_config.h> 26 27/******************************************************************** 28 * Functions: vPortStartTask 29 * 30 ********************************************************************/ 31.global vPortStartTask 32.type vPortStartTask, %function 33vPortStartTask: 34 psrclr ie 35 lrw r4, pxCurrentTCB 36 ld.w r4, (r4) // the current task stack pointer is the first member 37 ld.w sp, (r4) 38 39 ldw r0, (sp, 64) 40 mtcr r0, epc 41 ldw r0, (sp, 60) 42 mtcr r0, epsr 43 ldw r15, (sp, 56) 44 ldm r0-r13, (sp) 45 addi sp, 68 46 rte 47 48/******************************************************************** 49 * Functions: vPortYield 50 * 51 ********************************************************************/ 52.global vPortYield 53.type vPortYield, %function 54vPortYield: 55 psrclr ee 56 subi sp, 68 57 stm r0-r13, (sp) 58 stw r15, (sp, 56) 59 mfcr r0, psr 60 bseti r0, 8 61 stw r0, (sp, 60) 62 stw r15, (sp, 64) 63 64 lrw r2, pxCurrentTCB 65 ld.w r3, (r2) 66 st.w sp, (r3) 67 68 jbsr vTaskSwitchContext 69 lrw r4, pxCurrentTCB 70 ld.w r4, (r4) 71 ld.w sp, (r4) 72 73 ldw r0, (sp, 64) 74 mtcr r0, epc 75 ldw r0, (sp, 60) 76 mtcr r0, epsr 77 ldw r15, (sp, 56) 78 ldm r0-r13, (sp) 79 addi sp, 68 80 81 rte 82 83/******************************************************************** 84 * Functions: NOVIC_IRQ_Default_Handler 85 * 86 ********************************************************************/ 87.global NOVIC_IRQ_Default_Handler 88.type NOVIC_IRQ_Default_Handler, %function 89NOVIC_IRQ_Default_Handler: 90 psrset ee 91 subi sp, 68 92 stm r0-r13, (sp) 93 stw r15, (sp, 56) 94 mfcr r0, epsr 95 stw r0, (sp, 60) 96 mfcr r0, epc 97 stw r0, (sp, 64) 98 99 lrw r7, pxCurrentTCB 100 ldw r7, (r7) 101 stw sp, (r7) 102 103 lrw sp, g_top_irqstack 104 105 lrw r1, g_irqvector 106 mfcr r0, psr 107 lsri r0, 16 108 sextb r0 109 subi r0, 32 110 lsli r0, 2 111 add r1, r0 112 ldw r1, (r1) 113 lsri r0, 2 114 jsr r1 115 116 lrw r7, pxCurrentTCB 117 ldw r7, (r7) 118 ldw sp, (r7) 119 120 ldw r0, (sp, 64) 121 mtcr r0, epc 122 ldw r0, (sp, 60) 123 mtcr r0, epsr 124 ldm r0-r13, (sp) 125 ldw r15, (sp, 56) 126 addi sp, 68 127 rte 128