📄 os_task.s
字号:
adiw R24,1
movw R30,R24
ldd R4,z+0
or R4,R14
std z+0,R4
.dbline 96
; pevent->OSEventTbl[y] |= bitx;
movw R24,R20
adiw R24,6
ldd R2,y+1
clr R3
add R2,R24
adc R3,R25
movw R30,R2
ldd R4,z+0
or R4,R10
std z+0,R4
.dbline 97
; }
L14:
.dbline 99
; #endif
; }
L11:
.dbline 100
; OSTCBPrioTbl[newprio] = ptcb; /* Place pointer to TCB @ new priority */
ldi R24,2
ldd R0,y+12
mul R24,R0
movw R30,R0
ldi R24,<_OSTCBPrioTbl
ldi R25,>_OSTCBPrioTbl
add R30,R24
adc R31,R25
std z+1,R13
std z+0,R12
.dbline 101
; ptcb->OSTCBPrio = newprio; /* Set new task priority */
movw R30,R12
ldd R0,y+12
std z+11,R0
.dbline 102
; ptcb->OSTCBY = y;
movw R30,R12
ldd R0,y+1
std z+13,R0
.dbline 103
; ptcb->OSTCBX = x;
movw R30,R12
std z+12,R22
.dbline 104
; ptcb->OSTCBBitY = bity;
movw R30,R12
std z+15,R14
.dbline 105
; ptcb->OSTCBBitX = bitx;
movw R30,R12
std z+14,R10
.dbline 106
; OS_EXIT_CRITICAL();
ldd R16,y+0
rcall _OS_CPU_SR_Restore
.dbline 107
; OS_Sched(); /* Run highest priority task ready */
rcall _OS_Sched
.dbline 108
; return (OS_NO_ERR);
clr R16
rjmp L3
L8:
.dbline 109
; } else {
.dbline 110
; OSTCBPrioTbl[newprio] = (OS_TCB *)0; /* Release the reserved prio. */
ldi R24,2
ldd R0,y+12
mul R24,R0
movw R30,R0
ldi R24,<_OSTCBPrioTbl
ldi R25,>_OSTCBPrioTbl
add R30,R24
adc R31,R25
clr R2
clr R3
std z+1,R3
std z+0,R2
.dbline 111
; OS_EXIT_CRITICAL();
ldd R16,y+0
rcall _OS_CPU_SR_Restore
.dbline 112
; return (OS_PRIO_ERR); /* Task to change didn't exist */
ldi R16,41
.dbline -2
L3:
adiw R28,2
rcall pop_gset5
adiw R28,2
.dbline 0 ; func end
ret
.dbsym r pevent 20 pS[.1]
.dbsym r bity 14 c
.dbsym r bitx 10 c
.dbsym r x 22 c
.dbsym l y 1 c
.dbsym l cpu_sr 0 c
.dbsym r ptcb 12 pS[os_tcb]
.dbsym l newprio 12 c
.dbsym r oldprio 20 c
.dbend
.dbfunc e OSTaskCreate _OSTaskCreate fc
; psp -> R12,R13
; err -> R12
; cpu_sr -> R10
; prio -> R14
; ptos -> y+24
; pdata -> y+22
; task -> R12,R13
.even
_OSTaskCreate::
st -y,r19
st -y,r18
rcall push_gset5
movw R12,R16
sbiw R28,12
ldd R14,y+26
.dbline -1
.dbline 159
; }
; }
; }
; #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 > 0
; INT8U OSTaskCreate (void (*task)(void *pd), void *pdata, OS_STK *ptos, INT8U prio)
; {
.dbline 172
; #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
; OS_CPU_SR cpu_sr;
; #endif
; OS_STK *psp;
; INT8U err;
;
;
; #if OS_ARG_CHK_EN > 0
; if (prio > OS_LOWEST_PRIO) { /* Make sure priority is within allowable range */
; return (OS_PRIO_INVALID);
; }
; #endif
; OS_ENTER_CRITICAL();
rcall _OS_CPU_SR_Save
mov R10,R16
.dbline 173
; if (OSTCBPrioTbl[prio] == (OS_TCB *)0) { /* Make sure task doesn't already exist at this priority */
ldi R24,2
mul R24,R14
movw R30,R0
ldi R24,<_OSTCBPrioTbl
ldi R25,>_OSTCBPrioTbl
add R30,R24
adc R31,R25
ldd R2,z+0
ldd R3,z+1
tst R2
breq X7
rjmp L19
X7:
tst R3
breq X8
rjmp L19
X8:
X6:
.dbline 173
.dbline 174
; OSTCBPrioTbl[prio] = (OS_TCB *)1; /* Reserve the priority to prevent others from doing ... */
ldi R24,2
mul R24,R14
movw R30,R0
ldi R24,<_OSTCBPrioTbl
ldi R25,>_OSTCBPrioTbl
add R30,R24
adc R31,R25
ldi R24,1
ldi R25,0
std z+1,R25
std z+0,R24
.dbline 176
; /* ... the same thing until task is created. */
; OS_EXIT_CRITICAL();
mov R16,R10
rcall _OS_CPU_SR_Restore
.dbline 177
; psp = (OS_STK *)OSTaskStkInit(task, pdata, ptos, 0); /* Initialize the task's stack */
clr R2
clr R3
std y+3,R3
std y+2,R2
ldd R0,y+24
ldd R1,y+25
std y+1,R1
std y+0,R0
ldd R18,y+22
ldd R19,y+23
movw R16,R12
rcall _OSTaskStkInit
movw R12,R16
.dbline 178
; err = OS_TCBInit(prio, psp, (OS_STK *)0, 0, 0, (void *)0, 0);
clr R2
clr R3
std y+11,R3
std y+10,R2
std y+9,R3
std y+8,R2
ldi R20,0
ldi R21,0
ldi R22,0
ldi R23,0
std y+4,R20
std y+5,R21
std y+6,R22
std y+7,R23
std y+3,R3
std y+2,R2
std y+1,R3
std y+0,R2
movw R18,R12
mov R16,R14
rcall _OS_TCBInit
mov R12,R16
.dbline 179
; if (err == OS_NO_ERR) {
tst R16
brne L21
.dbline 179
.dbline 180
; OS_ENTER_CRITICAL();
rcall _OS_CPU_SR_Save
mov R10,R16
.dbline 181
; OSTaskCtr++; /* Increment the #tasks counter */
lds R24,_OSTaskCtr
subi R24,255 ; addi 1
sts _OSTaskCtr,R24
.dbline 182
; OS_EXIT_CRITICAL();
rcall _OS_CPU_SR_Restore
.dbline 183
; if (OSRunning == TRUE) { /* Find highest priority task if multitasking has started */
lds R24,_OSRunning
cpi R24,1
brne L22
.dbline 183
.dbline 184
; OS_Sched();
rcall _OS_Sched
.dbline 185
; }
.dbline 186
rjmp L22
L21:
.dbline 186
; } else {
.dbline 187
; OS_ENTER_CRITICAL();
rcall _OS_CPU_SR_Save
mov R10,R16
.dbline 188
; OSTCBPrioTbl[prio] = (OS_TCB *)0;/* Make this priority available to others */
ldi R24,2
mul R24,R14
movw R30,R0
ldi R24,<_OSTCBPrioTbl
ldi R25,>_OSTCBPrioTbl
add R30,R24
adc R31,R25
clr R2
clr R3
std z+1,R3
std z+0,R2
.dbline 189
; OS_EXIT_CRITICAL();
rcall _OS_CPU_SR_Restore
.dbline 190
; }
L22:
.dbline 191
; return (err);
mov R16,R12
rjmp L18
L19:
.dbline 193
; }
; OS_EXIT_CRITICAL();
mov R16,R10
rcall _OS_CPU_SR_Restore
.dbline 194
; return (OS_PRIO_EXIST);
ldi R16,40
.dbline -2
L18:
adiw R28,12
rcall pop_gset5
adiw R28,2
.dbline 0 ; func end
ret
.dbsym r psp 12 pc
.dbsym r err 12 c
.dbsym r cpu_sr 10 c
.dbsym r prio 14 c
.dbsym l ptos 24 pc
.dbsym l pdata 22 pV
.dbsym r task 12 pfV
.dbend
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -