⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 os_core.lis

📁 使用mega8和iccavr编译器的一段ucos操作系统程序
💻 LIS
📖 第 1 页 / 共 5 页
字号:
 03B2           ; *                                          START MULTITASKING
 03B2           ; *
 03B2           ; * Description: This function is used to start the multitasking process which lets uC/OS-II manages the
 03B2           ; *              task that you have created.  Before you can call OSStart(), you MUST have called OSInit()
 03B2           ; *              and you MUST have created at least one task.
 03B2           ; *
 03B2           ; * Arguments  : none
 03B2           ; *
 03B2           ; * Returns    : none
 03B2           ; *
 03B2           ; * Note       : OSStartHighRdy() MUST:
 03B2           ; *                 a) Call OSTaskSwHook() then,
 03B2           ; *                 b) Set OSRunning to TRUE.
 03B2           ; *********************************************************************************************************
 03B2           ; */
 03B2           ; 
 03B2           ; void OSStart (void)
 03B2           ; {
 03B2           ;     INT8U y;
 03B2           ;     INT8U x;
 03B2           ; 
 03B2           ; 
 03B2           ;     if (OSRunning == FALSE) {
 03B2           ;         y             = OSUnMapTbl[OSRdyGrp];        /* Find highest priority's task priority number   */
 03B2           ;         x             = OSUnMapTbl[OSRdyTbl[y]];
 03B2           ;         OSPrioHighRdy = (INT8U)((y << 3) + x);
 03B2           ;         OSPrioCur     = OSPrioHighRdy;
 03B2           ;         OSTCBHighRdy  = OSTCBPrioTbl[OSPrioHighRdy]; /* Point to highest priority task ready to run    */
 03B2           ;         OSTCBCur      = OSTCBHighRdy;
 03B2           ;         OSStartHighRdy();                            /* Execute target specific code to start task     */
 03B2           ;     }
 03B2           ; }
 03B2           ; /*$PAGE*/
 03B2           ; /*
 03B2           ; *********************************************************************************************************
 03B2           ; *                                              IDLE TASK
 03B2           ; *
 03B2           ; * Description: This task is internal to uC/OS-II and executes whenever no other higher priority tasks
 03B2           ; *              executes because they are waiting for event(s) to occur.
 03B2           ; *
 03B2           ; * Arguments  : none
 03B2           ; *
 03B2           ; * Returns    : none
 03B2           ; *********************************************************************************************************
 03B2           ; */
 03B2           ; 
 03B2           ; void OSTaskIdle (void *pdata)
 03B2           ; {
 03B2                   .dbline 245
 03B2           ;     pdata = pdata;                               /* Prevent compiler warning for not using 'pdata'     */
 03B2                   .dbline 246
 03B2           L38:
 03B2                   .dbline 246
 03B2                   .dbline 247
 03B2 0A93              st -y,r16
 03B4 0FB7              in r16,0x3F
 03B6 F894              cli
 03B8 0F93              push r16
 03BA 0991              ld r16,y+
 03BC                   .dbline 247
 03BC                   .dbline 248
 03BC 81E0              ldi R24,1
 03BE 90E0              ldi R25,0
 03C0 A0E0              ldi R26,0
 03C2 B0E0              ldi R27,0
 03C4 4090F000          lds R4,_OSIdleCtr+2
 03C8 5090F100          lds R5,_OSIdleCtr+2+1
 03CC 2090EE00          lds R2,_OSIdleCtr
 03D0 3090EF00          lds R3,_OSIdleCtr+1
 03D4 280E              add R2,R24
 03D6 391E              adc R3,R25
 03D8 4A1E              adc R4,R26
 03DA 5B1E              adc R5,R27
 03DC 3092EF00          sts _OSIdleCtr+1,R3
 03E0 2092EE00          sts _OSIdleCtr,R2
 03E4 5092F100          sts _OSIdleCtr+2+1,R5
 03E8 4092F000          sts _OSIdleCtr+2,R4
 03EC                   .dbline 249
 03EC 0A93              st -y,r16
 03EE 0F91              pop r16
 03F0 0FBF              out 0x3F,r16
 03F2 0991              ld r16,y+
 03F4                   .dbline 249
 03F4                   .dbline 250
 03F4                   .dbline 246
 03F4                   .dbline 246
 03F4 DECF              rjmp L38
 03F6           X3:
 03F6                   .dbline -2
 03F6           L37:
 03F6                   .dbline 0 ; func end
 03F6 0895              ret
 03F8                   .dbsym r pdata 16 pV
 03F8                   .dbend
 03F8                   .dbfunc e OSTCBInit _OSTCBInit fc
 03F8           ;           ptcb -> R10,R11
 03F8           ;            opt -> y+10
 03F8           ;           pext -> y+8
 03F8           ;       stk_size -> y+6
 03F8           ;             id -> y+4
 03F8           ;           pbos -> y+2
 03F8           ;           ptos -> R18,R19
 03F8           ;           prio -> R16
                        .even
 03F8           _OSTCBInit::
 03F8 00D0              rcall push_gset3x
 03FA                   .dbline -1
 03FA                   .dbline 297
 03FA           ;     for (;;) {
 03FA           ;         OS_ENTER_CRITICAL();
 03FA           ;         OSIdleCtr++;
 03FA           ;         OS_EXIT_CRITICAL();
 03FA           ;     }
 03FA           ; }
 03FA           ; /*$PAGE*/
 03FA           ; /*
 03FA           ; *********************************************************************************************************
 03FA           ; *                                            INITIALIZE TCB
 03FA           ; *
 03FA           ; * Description: This function is internal to uC/OS-II and is used to initialize a Task Control Block when
 03FA           ; *              a task is created (see OSTaskCreate() and OSTaskCreateExt()).
 03FA           ; *
 03FA           ; * Arguments  : prio          is the priority of the task being created
 03FA           ; *
 03FA           ; *              ptos          is a pointer to the task's top-of-stack assuming that the CPU registers
 03FA           ; *                            have been placed on the stack.  Note that the top-of-stack corresponds to a 
 03FA           ; *                            'high' memory location is OS_STK_GROWTH is set to 1 and a 'low' memory
 03FA           ; *                            location if OS_STK_GROWTH is set to 0.  Note that stack growth is CPU
 03FA           ; *                            specific.
 03FA           ; *
 03FA           ; *              pbos          is a pointer to the bottom of stack.  A NULL pointer is passed if called by
 03FA           ; *                            'OSTaskCreate()'.
 03FA           ; *
 03FA           ; *              id            is the task's ID (0..65535)
 03FA           ; *
 03FA           ; *              stk_size      is the size of the stack (in 'stack units').  If the stack units are INT8Us
 03FA           ; *                            then, 'stk_size' contains the number of bytes for the stack.  If the stack
 03FA           ; *                            units are INT32Us then, the stack contains '4 * stk_size' bytes.  The stack
 03FA           ; *                            units are established by the #define constant OS_STK which is CPU
 03FA           ; *                            specific.  'stk_size' is 0 if called by 'OSTaskCreate()'.
 03FA           ; *
 03FA           ; *              pext          is a pointer to a user supplied memory area that is used to extend the task
 03FA           ; *                            control block.  This allows you to store the contents of floating-point
 03FA           ; *                            registers, MMU registers or anything else you could find useful during a 
 03FA           ; *                            context switch.  You can even assign a name to each task and store this name
 03FA           ; *                            in this TCB extension.  A NULL pointer is passed if called by OSTaskCreate().
 03FA           ; *
 03FA           ; *              opt           options as passed to 'OSTaskCreateExt()' or, 
 03FA           ; *                            0 if called from 'OSTaskCreate()'.
 03FA           ; *
 03FA           ; * Returns    : OS_NO_ERR         if the call was successful
 03FA           ; *              OS_NO_MORE_TCB    if there are no more free TCBs to be allocated and thus, the task cannot
 03FA           ; *                                be created.
 03FA           ; *
 03FA           ; * Note       : This function is INTERNAL to uC/OS-II and your application should not call it.
 03FA           ; *********************************************************************************************************
 03FA           ; */
 03FA           ; 
 03FA           ; INT8U OSTCBInit (INT8U prio, OS_STK *ptos, OS_STK *pbos, INT16U id, INT16U stk_size, void *pext, INT16U opt)
 03FA           ; {
 03FA                   .dbline 301
 03FA           ;     OS_TCB *ptcb;
 03FA           ; 
 03FA           ; 
 03FA           ;     OS_ENTER_CRITICAL();
 03FA 0A93              st -y,r16
 03FC 0FB7              in r16,0x3F
 03FE F894              cli
 0400 0F93              push r16
 0402 0991              ld r16,y+
 0404                   .dbline 301
 0404                   .dbline 302
 0404           ;     ptcb = OSTCBFreeList;                                  /* Get a free TCB from the free TCB list    */
 0404 A090E100          lds R10,_OSTCBFreeList
 0408 B090E200          lds R11,_OSTCBFreeList+1
 040C                   .dbline 303
 040C           ;     if (ptcb != (OS_TCB *)0) {
 040C AA20              tst R10
 040E 19F4              brne X4
 0410 BB20              tst R11
 0412 09F4              brne X6
 0414 7CC0              rjmp L43
 0416           X6:
 0416           X4:
 0416                   .dbline 303
 0416                   .dbline 304
 0416           ;         OSTCBFreeList        = ptcb->OSTCBNext;            /* Update pointer to free TCB list          */
 0416 F501              movw R30,R10
 0418 2280              ldd R2,z+2
 041A 3380              ldd R3,z+3
 041C 3092E200          sts _OSTCBFreeList+1,R3
 0420 2092E100          sts _OSTCBFreeList,R2
 0424                   .dbline 305
 0424           ;         OS_EXIT_CRITICAL();
 0424 0A93              st -y,r16
 0426 0F91              pop r16
 0428 0FBF              out 0x3F,r16
 042A 0991              ld r16,y+
 042C                   .dbline 305
 042C                   .dbline 306
 042C           ;         ptcb->OSTCBStkPtr    = ptos;                       /* Load Stack pointer in TCB                */
 042C F501              movw R30,R10
 042E 3183              std z+1,R19
 0430 2083              std z+0,R18
 0432                   .dbline 307
 0432           ;         ptcb->OSTCBPrio      = (INT8U)prio;                /* Load task priority into TCB              */
 0432 0187              std z+9,R16
 0434                   .dbline 308
 0434           ;         ptcb->OSTCBStat      = OS_STAT_RDY;                /* Task is ready to run                     */
 0434 2224              clr R2
 0436 F501              movw R30,R10
 0438 2086              std z+8,R2
 043A                   .dbline 309
 043A           ;         ptcb->OSTCBDly       = 0;                          /* Task is not delayed                      */
 043A 3324              clr R3
 043C F501              movw R30,R10
 043E 3782              std z+7,R3
 0440 2682              std z+6,R2
 0442                   .dbline 311
 0442           ; 
 0442           ;         pext                 = pext;                       /* Prevent compiler warning if not used     */
 0442                   .dbline 312
 0442           ;         stk_size             = stk_size;
 0442                   .dbline 313
 0442           ;         pbos                 = pbos;
 0442                   .dbline 314
 0442           ;         opt                  = opt;
 0442                   .dbline 315
 0442           ;         id                   = id;
 0442                   .dbline 317
 0442           ; 
 0442           ;         ptcb->OSTCBY         = prio >> 3;                  /* Pre-compute X, Y, BitX and BitY          */
 0442 202E              mov R2,R16
 0444 2694              lsr R2
 0446 2694              lsr R2
 0448 2694              lsr R2
 044A F501              movw R30,R10
 044C 2386              std z+11,R2
 044E                   .dbline 318
 044E           ;         ptcb->OSTCBBitY      = OSMapTbl[ptcb->OSTCBY];
 044E 80E0              ldi R24,<_OSMapTbl
 0450 90E0              ldi R25,>_OSMapTbl
 0452 F501              movw R30,R10
 0454 E385              ldd R30,z+11
 0456 FF27              clr R31
 0458 E80F              add R30,R24
 045A F91F              adc R31,R25
 045C E491              lpm R30,Z
 045E D501              movw R26,R10
 0460 1D96              adiw R26,13
 0462 EC93              st x,R30
 0464                   .dbline 319
 0464           ;         ptcb->OSTCBX         = prio & 0x07;
 0464 802F              mov R24,R16
 0466 8770              andi R24,7
 0468 F501              movw R30,R10
 046A 8287              std z+10,R24
 046C                   .dbline 320
 046C           ;         ptcb->OSTCBBitX      = OSMapTbl[ptcb->OSTCBX];
 046C 80E0              ldi R24,<_OSMapTbl
 046E 90E0              ldi R25,>_OSMapTbl
 0470 F501              movw R30,R10
 0472 E285              ldd R30,z+10
 0474 FF27              clr R31
 0476 E80F              add R30,R24
 0478 F91F              adc R31,R25
 047A E491              lpm R30,Z
 047C D501              movw R26,R10
 047E 1C96              adiw R26,12
 0480 EC93              st x,R30
 0482                   .dbline 322
 0482           ; 
 0482           ;         OS_ENTER_CRITICAL();
 0482 0A93              st -y,r16
 0484 0FB7              in r16,0x3F
 0486 F894              cli
 0488 0F93              push r16
 048A 0991              ld r16,y+
 048C                   .dbline 322
 048C                   .dbline 323
 048C           ;         OSTCBPrioTbl[prio]   = ptcb;
 048C 82E0              ldi R24,2
 048E 809F              mul R24,R16
 0490 F001              movw R30,R0
 0492 80E0              ldi R24,<_OSTCBPrioTbl
 0494 90E0              ldi R25,>_OSTCBPrioTbl
 0496 E80F              add R30,R24
 0498 F91F              adc R31,R25
 049A B182              std z+1,R11
 049C A082              std z+0,R10
 049E                   .dbline 324
 049E           ;         ptcb->OSTCBNext      = OSTCBList;                  /* Link into TCB chain                      */
 049E 2090DD00          lds R2,_OSTCBList
 04A2 3090DE00          lds R3,_OSTCBList+1
 04A6 F501              movw R30,R10
 04A8 3382              std z+3,R3

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -