📄 os_task.src
字号:
; .\OS_TASK.SRC generated from: OS_TASK.C
; COMPILER INVOKED BY:
; D:\Keil\C51\BIN\C51.EXE OS_TASK.C LARGE BROWSE DEBUG OBJECTEXTEND SRC(.\OS_TASK.SRC)
$NOMOD51
NAME OS_TASK
P0 DATA 080H
P1 DATA 090H
P2 DATA 0A0H
P3 DATA 0B0H
T0 BIT 0B0H.4
AC BIT 0D0H.6
T1 BIT 0B0H.5
EA BIT 0A8H.7
IE DATA 0A8H
RD BIT 0B0H.7
ES BIT 0A8H.4
IP DATA 0B8H
RI BIT 098H.0
INT0 BIT 0B0H.2
CY BIT 0D0H.7
TI BIT 098H.1
INT1 BIT 0B0H.3
PS BIT 0B8H.4
SP DATA 081H
OV BIT 0D0H.2
WR BIT 0B0H.6
SBUF DATA 099H
PCON DATA 087H
SCON DATA 098H
TMOD DATA 089H
TCON DATA 088H
IE0 BIT 088H.1
IE1 BIT 088H.3
B DATA 0F0H
ACC DATA 0E0H
ET0 BIT 0A8H.1
ET1 BIT 0A8H.3
TF0 BIT 088H.5
TF1 BIT 088H.7
RB8 BIT 098H.2
TH0 DATA 08CH
EX0 BIT 0A8H.0
IT0 BIT 088H.0
TH1 DATA 08DH
TB8 BIT 098H.3
EX1 BIT 0A8H.2
IT1 BIT 088H.2
P BIT 0D0H.0
SM0 BIT 098H.7
TL0 DATA 08AH
SM1 BIT 098H.6
TL1 DATA 08BH
SM2 BIT 098H.5
PT0 BIT 0B8H.1
PT1 BIT 0B8H.3
RS0 BIT 0D0H.3
TR0 BIT 088H.4
RS1 BIT 0D0H.4
TR1 BIT 088H.6
PX0 BIT 0B8H.0
PX1 BIT 0B8H.2
DPH DATA 083H
DPL DATA 082H
REN BIT 098H.4
RXD BIT 0B0H.0
TXD BIT 0B0H.1
F0 BIT 0D0H.5
PSW DATA 0D0H
?PR?_?OSDummy?OS_TASK SEGMENT CODE
?PR?_?OSTaskCreate?OS_TASK SEGMENT CODE
?PR?_?OSTaskQuery?OS_TASK SEGMENT CODE
EXTRN IDATA (OSRunning)
EXTRN CODE (_?OSTaskStkInit)
EXTRN IDATA (OSTCBCur)
EXTRN CODE (_?OSSched)
EXTRN CODE (_?OSTCBInit)
EXTRN XDATA (OSTCBPrioTbl)
EXTRN CODE (_?OSTaskCreateHook)
EXTRN XDATA (OSTaskCtr)
EXTRN CODE (?C?ADDXBP)
EXTRN CODE (?C?XBPOFF)
EXTRN DATA (?C_XBP)
EXTRN CODE (?C?CLDOPTR)
EXTRN CODE (?C?COPY)
PUBLIC _?OSTaskQuery
PUBLIC _?OSTaskCreate
; /*
; *********************************************************************************************************
; * uC/OS-II
; * The Real-Time Kernel
; * TASK MANAGEMENT
; *
; * (c) Copyright 1992-1998, Jean J. Labrosse, Plantation, FL
; * All Rights Reserved
; *
; * V2.00
; *
; * File : OS_TASK.C
; * By : Jean J. Labrosse
; *********************************************************************************************************
; */
;
; #ifndef OS_MASTER_FILE
; #include "includes.h"
; #endif
;
; /*
; *********************************************************************************************************
; * LOCAL FUNCTION PROTOTYPES
; *********************************************************************************************************
; */
;
;
; static void OSDummy(void) reentrant;
;
; /*
; *********************************************************************************************************
; * DUMMY FUNCTION
; *
; * Description: This function doesn't do anything. It is called by OSTaskDel() to ensure that interrupts
; * are disabled immediately after they are enabled.
; *
; * Arguments : none
; *
; * Returns : none
; *********************************************************************************************************
; */
;
; static void OSDummy (void) reentrant
RSEG ?PR?_?OSDummy?OS_TASK
_?OSDummy:
; SOURCE LINE # 43
; {
; }
; SOURCE LINE # 45
RET
; END OF _?OSDummy
;
; /*$PAGE*/
; /*
; *********************************************************************************************************
; * CHANGE PRIORITY OF A TASK
; *
; * Description: This function allows you to change the priority of a task dynamically. Note that the new
; * priority MUST be available.
; *
; * Arguments : oldp is the old priority
; *
; * newp is the new priority
; *
; * Returns : OS_NO_ERR is the call was successful
; * OS_PRIO_INVALID if the priority you specify is higher that the maximum allowed
; * (i.e. >= OS_LOWEST_PRIO)
; * OS_PRIO_EXIST if the new priority already exist.
; * OS_PRIO_ERR there is no task with the specified OLD priority (i.e. the OLD task does
; * not exist.
; *********************************************************************************************************
; */
;
; #if OS_TASK_CHANGE_PRIO_EN
; INT8U OSTaskChangePrio (INT8U oldprio, INT8U newprio) reentrant
; {
; OS_TCB *ptcb;
; OS_EVENT *pevent;
; INT8U x;
; INT8U y;
; INT8U bitx;
; INT8U bity;
;
;
; if ((oldprio >= OS_LOWEST_PRIO && oldprio != OS_PRIO_SELF) ||
; newprio >= OS_LOWEST_PRIO) {
; return (OS_PRIO_INVALID);
; }
; OS_ENTER_CRITICAL();
; if (OSTCBPrioTbl[newprio] != (OS_TCB *)0) { /* New priority must not already exist */
; OS_EXIT_CRITICAL();
; return (OS_PRIO_EXIST);
; } else {
; OSTCBPrioTbl[newprio] = (OS_TCB *)1; /* Reserve the entry to prevent others */
; OS_EXIT_CRITICAL();
; y = newprio >> 3; /* Precompute to reduce INT. latency */
; bity = OSMapTbl[y];
; x = newprio & 0x07;
; bitx = OSMapTbl[x];
; OS_ENTER_CRITICAL();
; if (oldprio == OS_PRIO_SELF) { /* See if changing self */
; oldprio = OSTCBCur->OSTCBPrio; /* Yes, get priority */
; }
; if ((ptcb = OSTCBPrioTbl[oldprio]) != (OS_TCB *)0) { /* Task to change must exist */
; OSTCBPrioTbl[oldprio] = (OS_TCB *)0; /* Remove TCB from old priority */
; if (OSRdyTbl[ptcb->OSTCBY] & ptcb->OSTCBBitX) { /* If task is ready make it not ready */
; if ((OSRdyTbl[ptcb->OSTCBY] &= ~ptcb->OSTCBBitX) == 0) {
; OSRdyGrp &= ~ptcb->OSTCBBitY;
; }
; OSRdyGrp |= bity; /* Make new priority ready to run */
; OSRdyTbl[y] |= bitx;
; } else {
; if ((pevent = ptcb->OSTCBEventPtr) != (OS_EVENT *)0) { /* Remove from event wait list */
; if ((pevent->OSEventTbl[ptcb->OSTCBY] &= ~ptcb->OSTCBBitX) == 0) {
; pevent->OSEventGrp &= ~ptcb->OSTCBBitY;
; }
; pevent->OSEventGrp |= bity; /* Add new priority to wait list */
; pevent->OSEventTbl[y] |= bitx;
; }
; }
; OSTCBPrioTbl[newprio] = ptcb; /* Place pointer to TCB @ new priority */
; ptcb->OSTCBPrio = newprio; /* Set new task priority */
; ptcb->OSTCBY = y;
; ptcb->OSTCBX = x;
; ptcb->OSTCBBitY = bity;
; ptcb->OSTCBBitX = bitx;
; OS_EXIT_CRITICAL();
; OSSched(); /* Run highest priority task ready */
; return (OS_NO_ERR);
; } else {
; OSTCBPrioTbl[newprio] = (OS_TCB *)0; /* Release the reserved prio. */
; OS_EXIT_CRITICAL();
; return (OS_PRIO_ERR); /* Task to change didn't exist */
; }
; }
; }
; #endif
; /*$PAGE*/
; /*
; *********************************************************************************************************
; * CREATE A TASK
; *
; * Description: This function is used to have uC/OS-II manage the execution of a task. Tasks can either
; * be created prior to the start of multitasking or by a running task. A task cannot be
; * created by an ISR.
; *
; * Arguments : task is a pointer to the task's code
; *
; * pdata is a pointer to an optional data area which can be used to pass parameters to
; * the task when the task first executes. Where the task is concerned it thinks
; * it was invoked and passed the argument 'pdata' as follows:
; *
; * void Task (void *pdata)
; * {
; * for (;;) {
; * Task code;
; * }
; * }
; *
; * ptos is a pointer to the task's top of stack. If the configuration constant
; * OS_STK_GROWTH is set to 1, the stack is assumed to grow downward (i.e. from high
; * memory to low memory). 'pstk' will thus point to the highest (valid) memory
; * location of the stack. If OS_STK_GROWTH is set to 0, 'pstk' will point to the
; * lowest memory location of the stack and the stack will grow with increasing
; * memory locations.
; *
; * prio is the task's priority. A unique priority MUST be assigned to each task and the
; * lower the number, the higher the priority.
; *
; * Returns : OS_NO_ERR if the function was successful.
; * OS_PRIO_EXIT if the task priority already exist
; * (each task MUST have a unique priority).
; * OS_PRIO_INVALID if the priority you specify is higher that the maximum allowed
; * (i.e. >= OS_LOWEST_PRIO)
; *********************************************************************************************************
; */
;
; #if OS_TASK_CREATE_EN
; INT8U OSTaskCreate (void (*task)(void *pd), void *ppdata, OS_STK *ptos, INT8U prio) reentrant
RSEG ?PR?_?OSTaskCreate?OS_TASK
_?OSTaskCreate:
USING 0
; SOURCE LINE # 173
MOV DPTR,#0FFFDH
LCALL ?C?ADDXBP
MOV A,R3
MOVX @DPTR,A
INC DPTR
MOV A,R2
MOVX @DPTR,A
INC DPTR
MOV A,R1
MOVX @DPTR,A
MOV DPTR,#0FFFCH
LCALL ?C?ADDXBP
; {
; void *psp;
; INT8U err;
;
;
; if (prio > OS_LOWEST_PRIO) { /* Make sure priority is within allowable range */
; SOURCE LINE # 179
MOV DPTR,#0DH
LCALL ?C?XBPOFF
MOVX A,@DPTR
MOV R6,A
SETB C
SUBB A,#01CH
JC ?C0002
; return (OS_PRIO_INVALID);
; SOURCE LINE # 180
MOV R7,#02AH
LJMP ?C0003
; }
; SOURCE LINE # 181
?C0002:
; OS_ENTER_CRITICAL();
; SOURCE LINE # 182
CLR EA
; if (OSTCBPrioTbl[prio] == (OS_TCB *)0) { /* Make sure task doesn't already exist at this priority */
; SOURCE LINE # 183
MOV A,R6
MOV B,#03H
MUL AB
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -