📄 os_cpu_a.s79
字号:
//////////////////////////////////////////////////////////////////////////////
// /
// IAR ARM ANSI C/C++ Compiler V4.10A/W32 21/Feb/2006 15:50:17 /
// Copyright 1999-2004 IAR Systems. All rights reserved. /
// /
// Cpu mode = interwork /
// Endian = little /
// Stack alignment = 4 /
// Source file = D:\proj\ST\lowcost\os\ucOSIIV280\os_cpu_a.c /
// Command line = -I "C:\Program Files\IAR Systems\Embedded /
// Workbench 4.0\ARM\INC\" -I D:\proj\ST\lowcost\ -I /
// D:\proj\ST\lowcost\main\ -I /
// D:\proj\ST\lowcost\os\200c\ -I /
// D:\proj\ST\lowcost\os\ucOSIIV280\ -I /
// D:\proj\ST\lowcost\STR73xLibrary\include\ -lB /
// D:\proj\ST\lowcost\Debug\List\ -o /
// D:\proj\ST\lowcost\Debug\Obj\ -z3 --no_cse /
// --no_unroll --no_inline --no_code_motion --no_tbaa /
// --no_clustering --no_scheduling --debug --cpu_mode /
// arm --endian little --cpu ARM7TDMI --stack_align 4 /
// --interwork -e --fpu None /
// "-D_DLIB_CONFIG_FILE=C:\Program Files\IAR /
// Systems\Embedded Workbench /
// 4.0\ARM\LIB\dl4tpainl8n.h" /
// D:\proj\ST\lowcost\os\ucOSIIV280\os_cpu_a.c /
// List file = D:\proj\ST\lowcost\Debug\List\os_cpu_a.s79 /
// /
// /
//////////////////////////////////////////////////////////////////////////////
NAME os_cpu_a
RSEG CSTACK:DATA:NOROOT(2)
PUBLIC ARMDisableInt
MULTWEAK ARMDisableInt??rT
PUBLIC ARMEnableInt
MULTWEAK ARMEnableInt??rT
PUBLIC OSCtxSw
MULTWEAK OSCtxSw??rT
PUBLIC OSIntCtxSw
MULTWEAK OSIntCtxSw??rT
PUBLIC OSStartHighRdy
MULTWEAK OSStartHighRdy??rT
MULTWEAK OSTaskSwHook??rA
MULTWEAK OSIntEnter??rA
MULTWEAK OSTimeTick??rA
MULTWEAK OSIntExit??rA
PUBLIC OSTickISR
MULTWEAK OSTickISR??rT
OSTaskSwHook SYMBOL "OSTaskSwHook"
OSIntEnter SYMBOL "OSIntEnter"
OSTimeTick SYMBOL "OSTimeTick"
OSIntExit SYMBOL "OSIntExit"
ARMDisableInt SYMBOL "ARMDisableInt"
ARMDisableInt??rT SYMBOL "??rT", ARMDisableInt
ARMEnableInt SYMBOL "ARMEnableInt"
ARMEnableInt??rT SYMBOL "??rT", ARMEnableInt
OSCtxSw SYMBOL "OSCtxSw"
OSCtxSw??rT SYMBOL "??rT", OSCtxSw
OSIntCtxSw SYMBOL "OSIntCtxSw"
OSIntCtxSw??rT SYMBOL "??rT", OSIntCtxSw
OSStartHighRdy SYMBOL "OSStartHighRdy"
OSStartHighRdy??rT SYMBOL "??rT", OSStartHighRdy
OSTaskSwHook??rA SYMBOL "??rA", OSTaskSwHook
OSIntEnter??rA SYMBOL "??rA", OSIntEnter
OSTimeTick??rA SYMBOL "??rA", OSTimeTick
OSIntExit??rA SYMBOL "??rA", OSIntExit
OSTickISR SYMBOL "OSTickISR"
OSTickISR??rT SYMBOL "??rT", OSTickISR
EXTERN OSRunning
EXTERN OSTCBHighRdy
EXTERN OSTaskSwHook
EXTERN OSIntEnter
EXTERN OSTimeTick
EXTERN OSIntExit
EXTERN OSTCBCur
EXTERN OSPrioCur
EXTERN OSPrioHighRdy
RSEG CODE:CODE:NOROOT(2)
CODE16
ARMDisableInt??rT:
BX PC
NOP
REQUIRE ARMDisableInt
// D:\proj\ST\lowcost\os\ucOSIIV280\os_cpu_a.c
// 1 #include "ucos_ii.h"
// 2
RSEG CODE:CODE:NOROOT(2)
CODE32
// 3 void ARMDisableInt(void)
// 4 {
// 5
// 6 }
ARMDisableInt:
STMDB sp!, {r0}
MRS r0, CPSR
ORR r0, r0, #0xC0
MSR CPSR_cxsf, r0
LDMIA sp!, {r0}
// MOV pc, lr
BX LR ;; return
RSEG CODE:CODE:NOROOT(2)
CODE16
ARMEnableInt??rT:
BX PC
NOP
REQUIRE ARMEnableInt
// 7
RSEG CODE:CODE:NOROOT(2)
CODE32
// 8 void ARMEnableInt(void)
// 9 {
// 10
// 11 }
ARMEnableInt:
STMDB sp!, {r0}
MRS r0, CPSR
BIC r0, r0, #0xC0
MSR CPSR_cxsf, r0
LDMIA sp!, {r0}
// MOV pc, lr
BX LR ;; return
RSEG CODE:CODE:NOROOT(2)
CODE16
OSStartHighRdy??rT:
BX PC
NOP
REQUIRE OSStartHighRdy
// 12
// 13 #if 0
// 14 void OS_TASK_SW(void)
// 15 {
// 16
// 17 }
// 18 #endif
// 19
RSEG CODE:CODE:NOROOT(2)
CODE32
// 20 void OSStartHighRdy (void)
// 21 {
OSStartHighRdy:
STMDB SP!,{LR} ;; Push
// 22 OS_STK* pstk; //R4
// 23 OSTaskSwHook();
_BLF OSTaskSwHook,OSTaskSwHook??rA
LDMIA SP!,{LR} ;; Pop restore the lr
// 24 pstk=OSTCBHighRdy->OSTCBStkPtr;
LDR R1,??OSStartHighRdy_0 ;; OSTCBHighRdy
LDR R2,[R1, #+0]
// LDR R0,[R2, #+0]
LDR SP,[R2, #+0] ;;get the new sp
// 25 OSRunning = TRUE;
LDR R3,??OSStartHighRdy_0+4 ;; OSRunning
MOV R12,#+0x1
STRB R12,[R3, #+0]
// 26
// 27 //Restore all processor registers from the task's stack;
// 28
// 29 //Execute a return from interrupt instruction;
// 30
// 31 }
LDR R3,??OSStartHighRdy_0+8 ;; OSTCBCur
STR R2,[R3, #+0] ;;set new current task TCB
// LDMFD sp!, {R3} ; YYY
// MSR SPSR_cxsf, R3
LDMFD sp!, {R3} ; get new state from top of the stack
MSR CPSR_cxsf, R3 ; CPSR should be SVC32Mode
LDMFD sp!, {r0-r12, lr, pc } ; start the new task
// LDMFD sp!, {lr}
// LDMFD sp!, {r0-r12,pc} ; start the new task
BX LR ;; return
DATA
??OSStartHighRdy_0:
DC32 OSTCBHighRdy
DC32 OSRunning
DC32 OSTCBCur
RSEG CODE:CODE:NOROOT(2)
CODE16
OSCtxSw??rT:
BX PC
NOP
REQUIRE OSCtxSw
// 32
RSEG CODE:CODE:NOROOT(2)
CODE32
// 33 void OSCtxSw(void)
// 34 {
// 35
// 36 #if 0
// 37 保存处理器寄存器;
// 38
// 39 将当前任务的堆栈指针保存到当前任务的OS_TCB中:
// 40
// 41 OSTCBCur->OSTCBStkPtr = Stack pointer;
// 42
// 43 调用用户定义的OSTaskSwHook();
// 44
// 45 OSTCBCur = OSTCBHighRdy;
// 46
// 47 OSPrioCur = OSPrioHighRdy;
// 48
// 49 得到需要恢复的任务的堆栈指针:
// 50
// 51 Stack pointer = OSTCBHighRdy->OSTCBStkPtr;
// 52
// 53 将所有处理器寄存器从新任务的堆栈中恢复出来;
// 54
// 55 执行中断返回指令;
// 56 #endif
// 57
// 58 }
OSCtxSw:
STMFD sp!, {lr} ; save pc
STMFD sp!, {r0-r12,lr} ; save register file and ret address
// STMFD sp!, {lr} ; save lr
MRS r4, CPSR
STMFD sp!, {r4} ; save current PSR
// MRS r4, SPSR ; YYY+
// STMFD sp!, {r4} ; YYY+ save SPSR
OSCtxSwNOSave:
; Get current task TCB address
LDR r4, addr_OSTCBCur
LDR r5, [r4]
STR sp, [r5] ; store sp in preempted tasks's TCB
;call task hook
_BLF OSTaskSwHook,OSTaskSwHook??rA
; OSPrioCur = OSPrioHighRdy
LDR r4, addr_OSPrioCur
LDR r5, addr_OSPrioHighRdy
LDRB r6, [r5]
STRB r6, [r4]
; Get highest priority task TCB address
LDR r6, addr_OSTCBHighRdy
LDR r6, [r6]
LDR sp, [r6] ; get new task's stack pointer
LDR r4, addr_OSTCBCur
; OSTCBCur = OSTCBHighRdy
STR r6, [r4] ; set new current task TCB address
// LDMFD sp!, {r4} ; YYY+
// MSR SPSR_cxsf, r4 ; YYY+
LDMFD sp!, {r4} ; YYY+
MSR CPSR_cxsf, r4 ; YYY+
LDMFD sp!, {r0-r12, lr, pc} ; YYY+
// LDMFD sp!, {lr}
// LDMFD sp!, {r0-r12,pc} ; YYY+
BX LR ;; return
DATA
addr_OSTCBCur:
DC32 OSTCBCur
addr_OSTCBHighRdy:
DC32 OSTCBHighRdy
addr_OSPrioCur:
DC32 OSPrioCur
addr_OSPrioHighRdy:
DC32 OSPrioHighRdy
RSEG CODE:CODE:NOROOT(2)
CODE16
OSIntCtxSw??rT:
BX PC
NOP
REQUIRE OSIntCtxSw
// 59
// 60
// 61
RSEG CODE:CODE:NOROOT(2)
CODE32
// 62 void OSIntCtxSw(void)
// 63 {
// 64 #if 0
// 65 OSIntExit();
// 66
// 67 OSIntCtxSw()过程中压入堆栈的多余内容;
// 68
// 69 将当前任务堆栈指针保存到当前任务的OS_TCB中:
// 70
// 71 OSTCBCur->OSTCBStkPtr = 堆栈指针;
// 72
// 73 调用用户定义的OSTaskSwHook();
// 74
// 75 OSTCBCur = OSTCBHighRdy;
// 76
// 77 OSPrioCur = OSPrioHighRdy;
// 78
// 79 得到需要恢复的任务的堆栈指针:
// 80
// 81 堆栈指针 = OSTCBHighRdy->OSTCBStkPtr;
// 82
// 83 将所有处理器寄存器从新任务的堆栈中恢复出来;
// 84
// 85 执行中断返回指令;
// 86 #endif
// 87 }
OSIntCtxSw:
ADD sp,sp,#4
LDMFD sp!, {R1}
ADD SP,SP,#24
MSR CPSR,R1
B OSCtxSwNOSave
BX LR ;; return
RSEG CODE:CODE:NOROOT(2)
CODE16
OSTickISR??rT:
BX PC
NOP
REQUIRE OSTickISR
// 88
RSEG CODE:CODE:NOROOT(2)
CODE32
// 89 void OSTickISR(void)
// 90 {
// 91 #if 0
// 92 保存处理器寄存器;
// 93
// 94 调用OSIntEnter()或者直接将 OSIntNesting加1;
// 95
// 96
// 97
// 98 调用OSTimeTick();
// 99
// 100
// 101
// 102 调用OSIntExit();
// 103
// 104 恢复处理器寄存器;
// 105
// 106 执行中断返回指令;
// 107 #endif
// 108 }
OSTickISR:
//R0-LR, R1-SPSR,R2-current cpsr,
//we should save the cpu register to the user or sys stack
//the interrupted function should use STMFD sp!, {r0-r3,r12,lr}
LDR R0,[SP,#+20] ;save lr-pc
// MOV R0,LR ;save lr
MRS R1,SPSR ;save spsr
MRS R2,CPSR ;save current CPSR
MSR CPSR,R1 ;switch to user or sys
STMFD sp!, {R0} ;lr-pc to stack
STMFD sp!, {lr} ;lr to stack
STMFD sp!, {r4-r12} ;r4-r12 and lr to stack
MSR CPSR,R2 ;return to IRQ or FIQ mode
LDMFD sp, {R4-R9} ;restore the R0-R3 to R4-R7, pop the R12 and lr pushed when interrupted
MSR CPSR,R1 ;switch to the user or sys mode
STMFD sp!, {R1,R4-R7} ;R0-R3 to stack, spsr to statck ;low<-spsr,r0-r12,lr->high;
MSR CPSR,R2 ;return to interrrupt mode
STMFD sp!, {R1} ;lr and spsr to the irq or fiq stack
// STMFD sp!, {lr} ; save pc
// STMFD sp!, {lr} ; save lr
// STMFD sp!, {r0-r12} ; save register file and ret address
// MRS r4, CPSR
// STMFD sp!, {r4} ; save current PSR
// STMFD sp!, {r4} ; YYY+ save SPSR
_BLF OSIntEnter,OSIntEnter??rA
_BLF OSTimeTick,OSTimeTick??rA
_BLF OSIntExit,OSIntExit??rA
LDMFD sp!, {R1} ;restore the spsr
ADD sp,sp,#24 ;adjust irq or fiq stack
MSR CPSR,R1 ;switch to the user or sys mode
LDMFD sp!, {R1} ;pop the spsr from the stack
LDMFD sp!, {r0-r12,lr,pc} ;return
// LDMFD sp!, {r4} ; YYY+
// MSR SPSR_cxsf, r4 ; YYY+
// LDMFD sp!, {r4} ; YYY+
// MSR CPSR_cxsf, r4 ; YYY+
// LDMFD sp!, {r0-r12, lr, pc} ; YYY+
BX LR ;; return
RSEG CODE:CODE:NOROOT(2)
CODE32
OSTaskSwHook??rA:
LDR R12,??Subroutine6_0 ;; OSTaskSwHook
BX R12
DATA
??Subroutine6_0:
DC32 OSTaskSwHook
RSEG CODE:CODE:NOROOT(2)
CODE32
OSIntEnter??rA:
LDR R12,??Subroutine6_1 ;; OSIntEnter
BX R12
DATA
??Subroutine6_1:
DC32 OSIntEnter
RSEG CODE:CODE:NOROOT(2)
CODE32
OSTimeTick??rA:
LDR R12,??Subroutine6_2 ;; OSTimeTick
BX R12
DATA
??Subroutine6_2:
DC32 OSTimeTick
RSEG CODE:CODE:NOROOT(2)
CODE32
OSIntExit??rA:
LDR R12,??Subroutine6_3 ;; OSIntExit
BX R12
DATA
??Subroutine6_3:
DC32 OSIntExit
END
// 109
//
// 104 bytes in segment CODE
//
// 68 bytes of CODE memory (+ 36 bytes shared)
//
//Errors: none
//Warnings: 1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -