📄 os_cpu_a.asm
字号:
;********************************************************************************************************
; uC/OS-II
; The Real-Time Kernel
;
; (c) Copyright 1992-1999, Jean J. Labrosse, Weston, FL
; All Rights Reserved
;
;
; Fujitsu F2MC-16LX Specific code
; ALL MEMORY MODELS
;
; FFMC-16 Family Softune Assembler V30L05
;
; File : OS_CPU_A.ASM
; By : Andrey Mozzhevilov. Yekaterinburg. Russia. andy@svrw.ru
; www.geocities.com/andy_moz
; Port Version : 1.00
; Date : 07-December-2001
;
;
; Sub Version : 1.02
;
; Updated : 10-Match-2002
; By : Sergey Pinigin.
;
; Description : CTXSWVECT declaration was removed, because now port uses INTP instruction
; instead INT #0 for context switch call.
;
; Sub Version : 1.05
;
; Updated : 20-Match-2002
; By : Sergey Pinigin.
;
; Description : The User Stack support was added.
; For small and medium memory models now possibly to use User Stack (USP)
;
; The functions OSStartHighRdy, OSCtxSw and OSIntCtxSw was corrected.
;
;
; Sub Version : 1.10
;
; Updated : 16-October-2002
; By : Andrey Mozzhevilov
;
; Description : 1) The code of OSIntCtxSw now is more clear. For adjusting SP
; the TOTAL_STK_CORR_VALUE macro value is used.
;
; 2) The support for the compilation with compiler's optimization level #0 is added.
;
; 3) Now port is compatible with uCOS-II versions before 2.04
; _iDIRR_ISR was corrected
;
; Sub Version : 1.20
;
; Updated : 21-February-2004
; By : Andrey Mozzhevilov
;
; Description : 1) Add register banks reserving for tasks and OS ISR
;
; 2) Add uCOS-II v2.75 support (see also parameter OS_VER_IS_275_OR_LATER in os_cfg.h)
;
;
;********************************************************************************************************
;********************************************************************************************************
; GLOBAL REFERENCES
;********************************************************************************************************
.PROGRAM OS_CPU_A
.GLOBAL _OSTickISR
.GLOBAL _iDIRR_ISR
.GLOBAL __dirr
.GLOBAL _OSStartHighRdy
.GLOBAL _OSCtxSw
.GLOBAL _OSIntCtxSw
.GLOBAL _OSIntExit
.GLOBAL _OSTimeTick
.GLOBAL _OSTaskSwHook
.GLOBAL _OSIntNesting
.GLOBAL _OSTickDOSCtr
.GLOBAL _OSPrioHighRdy
.GLOBAL _OSPrioCur
.GLOBAL _OSRunning
.GLOBAL _OSTCBCur
.GLOBAL _OSTCBHighRdy
; removed since V1.02
; .SECTION CTXSWVECT, CONST, LOCATE=H'FFFFFC
; .DATA.L _OSCtxSw
;********************************************************************************************************
; Include OS config
;********************************************************************************************************
#include "os_cpu.h"
#include "os_cfg.h"
#if (OS_CRITICAL_METHOD != 1) && (OS_CRITICAL_METHOD != 2) && (OS_CRITICAL_METHOD != 12)
#error OS CRITICAL METHOD must be set as 1, 2 or 12, see os_cpu.h
#endif
#ifndef TASKS_CAN_USE_BANK0
#error TASKS CAN USE BANK0 must be set as 1 or 0, see os_cfg.h
#endif
#ifndef OS_VER_IS_275_OR_LATER
#error OS_VER_IS_275_OR_LATER must be set as 1 or 0, see os_cfg.h
#endif
; ------- Memory models --------- default address size
; data code
#set SMALL 0 ; 16 Bit 16 Bit
#set MEDIUM 1 ; 16 Bit 24 Bit
#set COMPACT 2 ; 24 Bit 16 Bit
#set LARGE 3 ; 24 Bit 24 Bit
; You should use one of the these lines or define MEMMODEL_xxx by option "-D" assembler */
;#define MEMMODEL_SMALL
;#define MEMMODEL_COMPACT
;#define MEMMODEL_MEDIUM
;#define MEMMODEL_LARGE
#ifndef MEMMODEL_SMALL
#ifndef MEMMODEL_COMPACT
#ifndef MEMMODEL_MEDIUM
#ifndef MEMMODEL_LARGE
#error MEMMODEL_???... must be specify
#endif
#endif
#endif
#endif
; Set memory model and define stack correction value, depending on this model
#ifdef MEMMODEL_SMALL
#set MEMMODEL SMALL
#define MM_STK_CORR_VALUE 6 ; Ignore calls to OSIntExit(+2), OSIntCtxSw(+2), saved RW0(+2)
#define CALLX CALL
#endif
#ifdef MEMMODEL_COMPACT
#if TASKS_USE_USP == 1
#error The usage of USP is not supported for compact and large memory models
#endif
#set MEMMODEL COMPACT
#define MM_STK_CORR_VALUE 8 ; Ignore calls to OSIntExit(+2), OSIntCtxSw(+2), saved RW0(+2), RW1(+2)
#define CALLX CALL
#endif
#ifdef MEMMODEL_MEDIUM
#set MEMMODEL MEDIUM
#define MM_STK_CORR_VALUE 10 ; Ignore calls to OSIntExit(+4), OSIntCtxSw(+4), saved RW0(+2)
#define CALLX CALLP
#endif
#ifdef MEMMODEL_LARGE
#if TASKS_USE_USP == 1
#error The usage of USP is not supported for compact and large memory models
#endif
#set MEMMODEL LARGE
#define MM_STK_CORR_VALUE 12 ; Ignore calls to OSIntExit(+4), OSIntCtxSw(+4), saved RW0(+2), RW1(+2)
#define CALLX CALLP
#endif
; Define stack correction value, depending on OS_CRITICAL_METHOD
#if OS_CRITICAL_METHOD == 1
#define OCM_STK_CORR_VALUE 0
#elif (OS_CRITICAL_METHOD == 2) || (OS_CRITICAL_METHOD == 12)
#define OCM_STK_CORR_VALUE 2
#endif
; Define stack correction value, depending on optimization level
#if OPTIMIZATION_LEVEL_0_EN == 1
#define OPT_STK_CORR_VALUE 2
#else
#define OPT_STK_CORR_VALUE 0
#endif
; Define stack correction value, depending on OS version
#if OS_VER_IS_275_OR_LATER > 0
#define OS_275_CORR_VALUE 2
#else
#define OS_275_CORR_VALUE 0
#endif
; Define total stack correction value for OSIntCtxSw
#define TOTAL_STK_CORR_VALUE (MM_STK_CORR_VALUE + OCM_STK_CORR_VALUE + OPT_STK_CORR_VALUE + OS_275_CORR_VALUE)
;********************************************************************************************************
; Reserving register from for OS and Tasks
;********************************************************************************************************
#if OS_SCAN_FREE_BANK > 0
; The banks of registers from FIRST_TASK_BANK before LAST_TASK_BANK are used for contexts of tasks.
.SECTION SEPARATE_TASK_REG_BANKS, DATA, LOCATE=0x180+FIRST_TASK_BANK*16
.RES.B (LAST_TASK_BANK-FIRST_TASK_BANK+1)*16
#endif
; The Bank of registers 0 is used for contexts of tasks, which came short separate bank.
; The bank of registers #1 is used in interrupts OSTickISR and Delayed Interrupt.
.SECTION OS_ISR_REG_BANKS, DATA, LOCATE=0x180
.RES.B 16*2
;********************************************************************************************************
; Include interrupt enter macro
;********************************************************************************************************
#include "isr_mac.inc"
.SECTION CODE, CODE, ALIGN=1
;*********************************************************************************************************
; Macro SAVE_REGISTERS_CONTEXT
; It Is Used in _OSCtxSw and _iDIR_ISR for save bank of registers in the task stack.
;
; Loads the word with tops of stack and defines, what bank of registers uses task to suspend.
; If this bank of registers #0, that is in addition produced the save in stack of task to suspend
; bank of registers #0. And place PS on top of stack again.
;
;*********************************************************************************************************
#macro SAVE_REGISTERS_CONTEXT
#local skip
#if TASKS_CAN_USE_BANK0 == 1
POPW A ; Get PS at top of stack
PUSHW A ;
ANDW A,#1F00H ;
BNZ skip ;
MOVW A,SP ;
MOVW A,@A ;
MOV RP,#00H ;
PUSHW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) ; Save interrupted task's context
PUSHW A ; Save PS at top of stack
#endif
skip:
#endm
;*********************************************************************************************************
; Macro RESTORE_REGISTERS_CONTEXT
; It Is Used in _OSStartHighRdy, _OSCtxSw
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -