📄 ucos_ii.lst
字号:
(0316) ;
(0317) ; LDS R16,_OSPrioHighRdy ; OSPrioCur = OSPrioHighRdy
(0318) ; STS _OSPrioCur,R16 ;
(0319) ;
(0320) ; LDS R30,_OSTCBHighRdy ; Z = OSTCBHighRdy->OSTCBStkPtr
(0321) ; LDS R31,_OSTCBHighRdy+1 ;
(0322) ; STS _OSTCBCur,R30 ; OSTCBCur = OSTCBHighRdy
(0323) ; STS _OSTCBCur+1,R31 ;
(0324) ;
(0325) ; LD R28,Z+ ; Restore Y pointer
(0326) ; LD R29,Z+ ;
(0327) ; POPSP ; restore stack pointer
(0328) ; POPSREG ; restore SREG
(0329) ; POPRS ; restore registers
(0330) ; RET
(0331) ;
(0332) ;******************************************************************************
(0333) ; SYSTEM TICK ISR
(0334) ;
(0335) ; Description: This function is the ISR used to notify uC/OS-II that a system
(0336) ; tick has occurred.
(0337) ;
(0338) ;
(0339) ;*******************************************************************************
(0340) ;
(0341) _Before_OSTickIS::
(0342) nop
(0343) ret
_Before_OSTickIS:
0319 9508 RET
_OSTickISR:
031A D75E RCALL 0x0A79
(0344) _OSTickISR::
(0345) PUSHRS ; Save interrupted task's context
(0346) IN R16,SREG
(0347) SBR R16,0x80 ; Set interrupt bit in status reg and save
031B 6800 ORI R16,0x80
(0348) ST -Y,R16
031C 930A ST R16,-Y
(0349) ;can not do this,or uc-os-ii will die
(0350) ; PUSHSP
(0351) ;avr-gcc ->11059200
(0352) LDI R16,256-(8000000/50/1024) ; Reload timer to overflow at a rate of 50Hz
031D E604 LDI R16,0x64
(0353) OUT TCNT0,R16 ; at a prescaler of 1024 and 7.3728 MHz AVR clock
031E BF02 OUT P32,R16
(0354)
(0355) LDS R16,_OSIntNesting ; Notify uC/OS-II of ISR
031F 9100020B LDS R16,_OSIntNesting
(0356) INC R16 ;
0321 9503 INC R16
(0357) STS _OSIntNesting,R16 ;
0322 9300020B STS R16,_OSIntNesting
(0358)
(0359) SEI ; Enable interrupts
0324 9478 BSET 7
(0360) RCALL _OSTimeTick ; RCALL uC/OS-II's tick updating function
0325 D2CF RCALL _OSTimeTick
(0361) RCALL _OSIntExit ; Notify uC/OS-II about end of ISR
0326 D194 RCALL _OSIntExit
0327 9109 LD R16,Y+
0328 BF0F OUT P3F,R16
0329 91F9 LD R31,Y+
032A 91E9 LD R30,Y+
032B D7E5 RCALL 0x0B11
032C 9179 LD R23,Y+
032D 9169 LD R22,Y+
032E 9159 LD R21,Y+
032F 9149 LD R20,Y+
0330 9139 LD R19,Y+
0331 9129 LD R18,Y+
0332 9119 LD R17,Y+
0333 9109 LD R16,Y+
0334 90F9 LD R15,Y+
0335 90E9 LD R14,Y+
0336 90D9 LD R13,Y+
0337 90C9 LD R12,Y+
0338 D7DD RCALL 0x0B16
0339 9079 LD R7,Y+
033A 9069 LD R6,Y+
033B 9059 LD R5,Y+
033C 9049 LD R4,Y+
033D 9039 LD R3,Y+
033E 9029 LD R2,Y+
033F 9019 LD R1,Y+
0340 9009 LD R0,Y+
(0362)
(0363) ; POPSP
(0364) POPSREG ; Restore status register
(0365) POPRS ; Restore all registers
(0366) RET ; Note: RET instead of RETI
0341 9508 RET
_OSEventTaskRdy:
prio --> R12
bity --> R10
bitx --> R20
x --> R12
ptcb --> R12
y --> R22
msk --> Y+8
msg --> R18
pevent --> R16
0342 D650 RCALL push_gset4
FILE: G:\编程2002-10-15-HOME\做过的项目\2002-10-22\home-c\software\ucos-ii-at90S-icc-avr\ucos-ii-source\os_core.c
(0001) /*
(0002) *********************************************************************************************************
(0003) * uC/OS-II
(0004) * The Real-Time Kernel
(0005) * CORE FUNCTIONS
(0006) *
(0007) * (c) Copyright 1992-1998, Jean J. Labrosse, Plantation, FL
(0008) * All Rights Reserved
(0009) *
(0010) * V2.00
(0011) *
(0012) * File : OS_CORE.C
(0013) * By : Jean J. Labrosse
(0014) *********************************************************************************************************
(0015) */
(0016)
(0017) #ifndef OS_MASTER_FILE
(0018) #define OS_GLOBALS
(0019) #include "includes.h"
(0020) #endif
(0021)
(0022) /*
(0023) *********************************************************************************************************
(0024) * LOCAL GLOBAL VARIABLES
(0025) *********************************************************************************************************
(0026) */
(0027)
(0028) OS_CORE_STATI0C INT8U OSIntExitY=0; /* Variable used by 'OSIntExit' to prevent using locals */
(0029)
(0030) OS_CORE_STATI0C OS_STK OSTaskIdleStk[OS_TASK_IDLE_STK_SIZE]; /* Idle task stack */
(0031)
(0032) #if OS_TASK_STAT_EN
(0033) OS_CORE_STATI0C OS_STK OSTaskStatStk[OS_TASK_STAT_STK_SIZE]={0}; /* Statistics task stack */
(0034) #endif
(0035)
(0036) OS_CORE_STATI0C OS_TCB OSTCBTbl[OS_MAX_TASKS + OS_N_SYS_TASKS]={0}; /* Table of TCBs */
(0037)
(0038) /*$PAGE*/
(0039) /*
(0040) *********************************************************************************************************
(0041) * MAPPING TABLE TO MAP BIT POSITION TO BIT MASK
(0042) *
(0043) * Note: Index into table is desired bit position, 0..7
(0044) * Indexed value corresponds to bit mask
(0045) *********************************************************************************************************
(0046) */
(0047) //INT8U const
(0048) INT8U const OSMapTbl[] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};
(0049)
(0050) /*
(0051) *********************************************************************************************************
(0052) * PRIORITY RESOLUTION TABLE
(0053) *
(0054) * Note: Index into table is bit pattern to resolve highest priority
(0055) * Indexed value corresponds to highest priority bit position (i.e. 0..7)
(0056) *********************************************************************************************************
(0057) */
(0058) //INT8U const
(0059) INT8U const OSUnMapTbl[] = {
(0060) 0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
(0061) 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
(0062) 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
(0063) 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
(0064) 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
(0065) 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
(0066) 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
(0067) 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
(0068) 7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
(0069) 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
(0070) 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
(0071) 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
(0072) 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
(0073) 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
(0074) 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
(0075) 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0
(0076) };
(0077)
(0078) /*$PAGE*/
(0079) /*
(0080) *********************************************************************************************************
(0081) * MAKE TASK READY TO RUN BASED ON EVENT OCCURING
(0082) *
(0083) * Description: This function is called by other uC/OS-II services and is used to ready a task that was
(0084) * waiting for an event to occur.
(0085) *
(0086) * Arguments : pevent is a pointer to the event control block corresponding to the event.
(0087) *
(0088) * msg is a pointer to a message. This pointer is used by message oriented services
(0089) * such as MAILBOXEs and QUEUEs. The pointer is not used when called by other
(0090) * service functions.
(0091) *
(0092) * msk is a mask that is used to clear the status byte of the TCB. For example,
(0093) * OSSemPost() will pass OS_STAT_SEM, OSMboxPost() will pass OS_STAT_MBOX etc.
(0094) *
(0095) * Returns : none
(0096) *
(0097) * Note : This function is INTERNAL to uC/OS-II and your application should not call it.
(0098) *********************************************************************************************************
(0099) */
(0100) #if (OS_Q_EN && (OS_MAX_QS >= 2)) || OS_MBOX_EN || OS_SEM_EN
(0101) void OSEventTaskRdy (OS_EVENT *pevent, void *msg, INT8U msk)
(0102) {
(0103) OS_TCB *ptcb;
(0104) INT8U x;
(0105) INT8U y;
(0106) INT8U bitx;
(0107) INT8U bity;
(0108) INT8U prio;
(0109)
(0110)
(0111) y = OSUnMapTbl[pevent->OSEventGrp]; /* Find highest prio. task waiting for message */
0343 E288 LDI R24,0x28
0344 E090 LDI R25,0
0345 2FE0 MOV R30,R16
0346 2FF1 MOV R31,R17
0347 8027 LDD R2,7+Z
0348 2433 CLR R3
0349 D782 RCALL 0x0ACC
034A 2D60 MOV R22,R0
(0112) bity = OSMapTbl[y];
034B E280 LDI R24,0x20
034C E090 LDI R25,0
034D 2E26 MOV R2,R22
034E 2433 CLR R3
034F D77C RCALL 0x0ACC
0350 2CA0 MOV R10,R0
(0113) x = OSUnMapTbl[pevent->OSEventTbl[y]];
0351 2F80 MOV R24,R16
0352 2F91 MOV R25,R17
0353 9602 ADIW R24,2
0354 2FE6 MOV R30,R22
0355 27FF CLR R31
0356 0FE8 ADD R30,R24
0357 1FF9 ADC R31,R25
0358 8020 LDD R2,0+Z
0359 2433 CLR R3
035A E288 LDI R24,0x28
035B E090 LDI R25,0
035C D76F RCALL 0x0ACC
035D 2CC0 MOV R12,R0
(0114) bitx = OSMapTbl[x];
035E E280 LDI R24,0x20
035F E090 LDI R25,0
0360 2C2C MOV R2,R12
0361 2433 CLR R3
0362 D769 RCALL 0x0ACC
0363 2D40 MOV R20,R0
(0115) prio = (INT8U)((y << 3) + x); /* Find priority of task getting the msg */
0364 2C2C MOV R2,R12
0365 2433 CLR R3
0366 2EC6 MOV R12,R22
0367 24DD CLR R13
0368 0CCC LSL R12
0369 1CDD ROL R13
036A 0CCC LSL R12
036B 1CDD ROL R13
036C 0CCC LSL R12
036D 1CDD ROL R13
036E 0CC2 ADD R12,R2
036F 1CD3 ADC R13,R3
(0116) if ((pevent->OSEventTbl[y] &= ~bitx) == 0) { /* Remove this task from the waiting list */
0370 2F80 MOV R24,R16
0371 2F91 MOV R25,R17
0372 9602 ADIW R24,2
0373 2E26 MOV R2,R22
0374 2433 CLR R3
0375 0E28 ADD R2,R24
0376 1E39 ADC R3,R25
0377 2E44 MOV R4,R20
0378 9440 COM R4
0379 2DE2 MOV R30,R2
037A 2DF3 MOV R31,R3
037B 8050 LDD R5,0+Z
037C 2054 AND R5,R4
037D 2C45 MOV R4,R5
037E 8240 STD R4,0+Z
037F 2055 TST R5
0380 F429 BNE 0x0386
(0117) pevent->OSEventGrp &= ~bity;
0381 2F80 MOV R24,R16
0382 2F91 MOV R25,R17
0383 9607 ADIW R24,7
0384 2C4A MOV R4,R10
0385 D7A0 RCALL 0x0B26
(0118) }
(0119) ptcb = OSTCBPrioTbl[prio]; /* Point to this task's OS_TCB */
0386 EE85 LDI R24,0xE5
0387 E091 LDI R25,1
0388 2DEC MOV R30,R12
0389 27FF CLR R31
038A D70E RCALL 0x0A99
038B 80C0 LDD R12,0+Z
038C 80D1 LDD R13,1+Z
(0120) ptcb->OSTCBDly = 0; /* Prevent OSTimeTick() from readying task */
038D 2422 CLR R2
038E 2433 CLR R3
038F 2DEC MOV R30,R12
0390 2DFD MOV R31,R13
0391 8620 STD R2,8+Z
0392 8631 STD R3,9+Z
(0121) ptcb->OSTCBEventPtr = (OS_EVENT *)0; /* Unlink ECB from this task */
0393 8226 STD R2,6+Z
0394 8237 STD R3,7+Z
(0122) #if (OS_Q_EN && (OS_MAX_QS >= 2)) || OS_MBOX_EN
(0123) ptcb->OSTCBMsg = msg; /* Send message directly to waiting task */
(0124) #else
(0125) msg = msg; /* Prevent compiler warning if not used */
(0126) #endif
(0127) ptcb->OSTCBStat &= ~msk; /* Clear bit associated with event type */
0395 2D8C MOV R24,R12
0396 2D9D MOV R25,R13
0397 960A ADIW R24,0xA
0398 8448 LDD R4,8+Y
0399 D78C RCALL 0x0B26
(0128) if (ptcb->OSTCBStat == OS_STAT_RDY) { /* See if task is ready (could be susp'd) */
039A 2DEC MOV R30,R12
039B 2DFD MOV R31,R13
039C 8422 LDD R2,10+Z
039D 2022 TST R2
039E F481 BNE 0x03AF
(0129) OSRdyGrp |= bity; /* Put task in the ready to run list */
039F 90200207 LDS R2,_OSRdyGrp
03A1 282A OR R2,R10
03A2 92200207 STS R2,_OSRdyGrp
(0130) OSRdyTbl[y] |= bitx;
03A4 E085 LDI R24,5
03A5 E092 LDI R25,2
03A6 2E26 MOV R2,R22
03A7 2433 CLR R3
03A8 0E28 ADD R2,R24
03A9 1E39 ADC R3,R25
03AA 2DE2 MOV R30,R2
03AB 2DF3 MOV R31,R3
03AC 8040 LDD R4,0+Z
03AD 2A44 OR R4,R20
03AE 8240 STD R4,0+Z
(0131) }
(0132) }
03AF D5EA RCALL pop_gset4
03B0 9508 RET
(0133) #endif
(0134) /*$PAGE*/
(0135) /*
(0136) *********************************************************************************************************
(0137) * MAKE TASK WAIT FOR EVENT TO OCCUR
(0138) *
(0139) * Description: This function is called by other uC/OS-II services to suspend a task because an event has
(0140) * not occurred.
(0141) *
(0142) * Arguments : pevent is a pointer to the event control block for which the task will be waiting for.
(0143) *
(0144) * Returns : none
(0145) *
(0146) * Note : This function is INTERNAL to uC/OS-II and your application should not call it.
(0147) **********************************************************************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -