This repository has been archived on 2023-11-05. You can view files and clone it, but cannot push or open issues or pull requests.
FreeRTOS-Kernel/portable/IAR/78K0R/ISR_Support.h

83 lines
3.6 KiB
C
Raw Normal View History

2009-03-15 03:20:12 +08:00
;/*
; * FreeRTOS Kernel V10.3.1
; * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
; *
; * Permission is hereby granted, free of charge, to any person obtaining a copy of
; * this software and associated documentation files (the "Software"), to deal in
; * the Software without restriction, including without limitation the rights to
; * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
; * the Software, and to permit persons to whom the Software is furnished to do so,
; * subject to the following conditions:
; *
; * The above copyright notice and this permission notice shall be included in all
; * copies or substantial portions of the Software.
; *
; * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
; * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
; * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
; * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
; * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
; * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
; *
; * http://www.FreeRTOS.org
; * http://aws.amazon.com/freertos
; *
; * 1 tab == 4 spaces!
; */
2009-02-04 21:08:12 +08:00
#include "FreeRTOSConfig.h"
; Variables used by scheduler
;------------------------------------------------------------------------------
EXTERN pxCurrentTCB
EXTERN usCriticalNesting
;------------------------------------------------------------------------------
; portSAVE_CONTEXT MACRO
; Saves the context of the general purpose registers, CS and ES (only in far
2009-02-05 00:53:52 +08:00
; memory mode) registers the usCriticalNesting Value and the Stack Pointer
2009-02-04 21:08:12 +08:00
; of the active Task onto the task stack
;------------------------------------------------------------------------------
portSAVE_CONTEXT MACRO
2009-02-05 00:53:52 +08:00
PUSH AX ; Save AX Register to stack.
2009-02-04 21:08:12 +08:00
PUSH HL
2009-02-05 00:53:52 +08:00
MOV A, CS ; Save CS register.
2009-02-04 21:08:12 +08:00
XCH A, X
2009-02-05 00:53:52 +08:00
MOV A, ES ; Save ES register.
2009-02-04 21:08:12 +08:00
PUSH AX
2009-02-05 00:53:52 +08:00
PUSH DE ; Save the remaining general purpose registers.
2009-02-04 21:08:12 +08:00
PUSH BC
2009-02-05 00:53:52 +08:00
MOVW AX, usCriticalNesting ; Save the usCriticalNesting value.
PUSH AX
2009-02-05 00:53:52 +08:00
MOVW AX, pxCurrentTCB ; Save the Stack pointer.
MOVW HL, AX
MOVW AX, SP
MOVW [HL], AX
2009-02-04 21:08:12 +08:00
ENDM
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
; portRESTORE_CONTEXT MACRO
2009-02-05 00:53:52 +08:00
; Restores the task Stack Pointer then use this to restore usCriticalNesting,
; general purpose registers and the CS and ES (only in far memory mode)
2009-02-04 21:08:12 +08:00
; of the selected task from the task stack
;------------------------------------------------------------------------------
portRESTORE_CONTEXT MACRO
2009-02-05 00:53:52 +08:00
MOVW AX, pxCurrentTCB ; Restore the Stack pointer.
2009-02-04 21:08:12 +08:00
MOVW HL, AX
MOVW AX, [HL]
MOVW SP, AX
2009-02-05 00:53:52 +08:00
POP AX ; Restore usCriticalNesting value.
2009-02-04 21:08:12 +08:00
MOVW usCriticalNesting, AX
2009-02-05 00:53:52 +08:00
POP BC ; Restore the necessary general purpose registers.
2009-02-04 21:08:12 +08:00
POP DE
2009-02-05 00:53:52 +08:00
POP AX ; Restore the ES register.
2009-02-04 21:08:12 +08:00
MOV ES, A
2009-02-05 00:53:52 +08:00
XCH A, X ; Restore the CS register.
2009-02-04 21:08:12 +08:00
MOV CS, A
2009-02-05 00:53:52 +08:00
POP HL ; Restore general purpose register HL.
POP AX ; Restore AX.
2009-02-04 21:08:12 +08:00
ENDM
;------------------------------------------------------------------------------