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

📄 os_core.ls1

📁 UCOS在51上的移植,绝对经典!可以较少开发人员的工作量
💻 LS1
📖 第 1 页 / 共 5 页
字号:
                     605     ;     OS_InitTCBList();                                            /* Initialize the free l
                             ist of OS_TCBs      */
                     606                             ; SOURCE LINE # 94
0009 120000   F      607             LCALL   _?OS_InitTCBList
                     608     ;     OS_InitEventList();                                          /* Initialize the free l
                             ist of OS_EVENTs    */
                     609                             ; SOURCE LINE # 95
000C 120000   F      610             LCALL   _?OS_InitEventList
                     611     ; 
                     612     ; #if (OS_VERSION >= 251) && (OS_FLAG_EN > 0) && (OS_MAX_FLAGS > 0)
                     613     ;     OS_FlagInit();                                               /* Initialize the event 
                             flag structures     */
                     614     ; #endif
                     615     ; 
                     616     ; #if (OS_MEM_EN > 0) && (OS_MAX_MEM_PART > 0)
                     617     ;     OS_MemInit();                                                /* Initialize the memory
A51 MACRO ASSEMBLER  OS_CORE                                                              05/17/2005 11:19:50 PAGE    11

                              manager            */
                     618     ; #endif
                     619     ; 
                     620     ; #if (OS_Q_EN > 0) && (OS_MAX_QS > 0)
                     621     ;     OS_QInit();                                                  /* Initialize the messag
                             e queue structures  */
                     622     ; #endif
                     623     ; 
                     624     ;     OS_InitTaskIdle();                                           /* Create the Idle Task 
                                                 */
                     625                             ; SOURCE LINE # 109
000F 120000   F      626             LCALL   _?OS_InitTaskIdle
                     627     ; #if OS_TASK_STAT_EN > 0
                     628     ;     OS_InitTaskStat();                                           /* Create the Statistic 
                             Task                */
                     629     ; #endif
                     630     ; 
                     631     ; #if OS_VERSION >= 204
                     632     ;     OSInitHookEnd();                                             /* Call port specific in
                             it. code            */
                     633                             ; SOURCE LINE # 115
0012 020000   F      634             LJMP    _?OSInitHookEnd
                     635     ; END OF _?OSInit
                     636     
                     637     ; #endif
                     638     ; }
                     639     ; /*$PAGE*/
                     640     ; /*
                     641     ; *****************************************************************************************
                             ****************
                     642     ; *                                              ENTER ISR
                     643     ; *
                     644     ; * Description: This function is used to notify uC/OS-II that you are about to service an 
                             interrupt
                     645     ; *              service routine (ISR).  This allows uC/OS-II to keep track of interrupt ne
                             sting and thus
                     646     ; *              only perform rescheduling at the last nested ISR.
                     647     ; *
                     648     ; * Arguments  : none
                     649     ; *
                     650     ; * Returns    : none
                     651     ; *
                     652     ; * Notes      : 1) This function should be called ith interrupts already disabled
                     653     ; *              2) Your ISR can directly increment OSIntNesting without calling this funct
                             ion because
                     654     ; *                 OSIntNesting has been declared 'global'.  
                     655     ; *              3) You MUST still call OSIntExit() even though you increment OSIntNesting 
                             directly.
                     656     ; *              4) You MUST invoke OSIntEnter() and OSIntExit() in pair.  In other words, 
                             for every call
                     657     ; *                 to OSIntEnter() at the beginning of the ISR you MUST have a call to OSI
                             ntExit() at the
                     658     ; *                 end of the ISR.
                     659     ; *              5) You are allowed to nest interrupts up to 255 levels deep.
                     660     ; *              6) I removed the OS_ENTER_CRITICAL() and OS_EXIT_CRITICAL() around the inc
                             rement because
                     661     ; *                 OSIntEnter() is always called with interrupts disabled.
                     662     ; *****************************************************************************************
                             ****************
                     663     ; */
                     664     ; 
                     665     ; void  OSIntEnter (void) LG_REENTRANT
                     666     
----                 667             RSEG  ?PR?_?OSIntEnter?OS_CORE
0000                 668     _?OSIntEnter:
                     669                             ; SOURCE LINE # 144
A51 MACRO ASSEMBLER  OS_CORE                                                              05/17/2005 11:19:50 PAGE    12

                     670     ; {
                     671     ;     if (OSRunning == TRUE) {
                     672                             ; SOURCE LINE # 146
0000 30000C   F      673             JNB     OSRunning,?C0004
                     674     ;         if (OSIntNesting < 255) {
                     675                             ; SOURCE LINE # 147
0003 900000   F      676             MOV     DPTR,#OSIntNesting
0006 E0              677             MOVX    A,@DPTR
0007 C3              678             CLR     C
0008 94FF            679             SUBB    A,#0FFH
000A 5003            680             JNC     ?C0004
                     681     ;             OSIntNesting++;                      /* Increment ISR nesting level          
                                           */
                     682                             ; SOURCE LINE # 148
000C E0              683             MOVX    A,@DPTR
000D 04              684             INC     A
000E F0              685             MOVX    @DPTR,A
                     686     ;         }
                     687                             ; SOURCE LINE # 149
                     688     ;     }
                     689                             ; SOURCE LINE # 150
                     690     ; }
                     691                             ; SOURCE LINE # 151
000F                 692     ?C0004:
000F 22              693             RET     
                     694     ; END OF _?OSIntEnter
                     695     
                     696     ; /*$PAGE*/
                     697     ; /*
                     698     ; *****************************************************************************************
                             ****************
                     699     ; *                                               EXIT ISR
                     700     ; *
                     701     ; * Description: This function is used to notify uC/OS-II that you have completed serviving
                              an ISR.  When
                     702     ; *              the last nested ISR has completed, uC/OS-II will call the scheduler to det
                             ermine whether
                     703     ; *              a new, high-priority task, is ready to run.
                     704     ; *
                     705     ; * Arguments  : none
                     706     ; *
                     707     ; * Returns    : none
                     708     ; *
                     709     ; * Notes      : 1) You MUST invoke OSIntEnter() and OSIntExit() in pair.  In other words, 
                             for every call
                     710     ; *                 to OSIntEnter() at the beginning of the ISR you MUST have a call to OSI
                             ntExit() at the
                     711     ; *                 end of the ISR.
                     712     ; *              2) Rescheduling is prevented when the scheduler is locked (see OS_SchedLoc
                             k())
                     713     ; *****************************************************************************************
                             ****************
                     714     ; */
                     715     ; 
                     716     ; void  OSIntExit (void) LG_REENTRANT
                     717     
----                 718             RSEG  ?PR?_?OSIntExit?OS_CORE
0000                 719     _?OSIntExit:
                     720             USING   0
                     721                             ; SOURCE LINE # 172
                     722     ; {
                     723     ; #if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU st
                             atus register */
                     724     ;     OS_CPU_SR  cpu_sr;
                     725     ; #endif
                     726     ;     
A51 MACRO ASSEMBLER  OS_CORE                                                              05/17/2005 11:19:50 PAGE    13

                     727     ;     
                     728     ;     if (OSRunning == TRUE) {
                     729                             ; SOURCE LINE # 179
0000 200003   F      730             JB      OSRunning,$ + 6H
0003 020000   F      731             LJMP    ?C0009
                     732     ;         OS_ENTER_CRITICAL();
                     733                             ; SOURCE LINE # 180
0006 C2AF            734             CLR     EA
                     735     ;         if (OSIntNesting > 0) {                            /* Prevent OSIntNesting from w
                             rapping       */
                     736                             ; SOURCE LINE # 181
0008 900000   F      737             MOV     DPTR,#OSIntNesting
000B E0              738             MOVX    A,@DPTR
000C D3              739             SETB    C
000D 9400            740             SUBB    A,#00H
000F 4003            741             JC      ?C0006
                     742     ;             OSIntNesting--;
                     743                             ; SOURCE LINE # 182
0011 E0              744             MOVX    A,@DPTR
0012 14              745             DEC     A
0013 F0              746             MOVX    @DPTR,A
                     747     ;         }
                     748                             ; SOURCE LINE # 183
0014                 749     ?C0006:
                     750     ;         if ((OSIntNesting == 0) && (OSLockNesting == 0)) { /* Reschedule only if all ISRs
                              complete ... */
                     751                             ; SOURCE LINE # 184
0014 900000   F      752             MOV     DPTR,#OSIntNesting
0017 E0              753             MOVX    A,@DPTR
0018 707A            754             JNZ     ?C0007
001A 900000   F      755             MOV     DPTR,#OSLockNesting
001D E0              756             MOVX    A,@DPTR
001E 7074            757             JNZ     ?C0007
                     758     ;             OSIntExitY    = OSUnMapTbl[OSRdyGrp];          /* ... and not locked.        
                                           */
                     759                             ; SOURCE LINE # 185
0020 900000   F      760             MOV     DPTR,#OSRdyGrp
0023 E0              761             MOVX    A,@DPTR
0024 2400     F      762             ADD     A,#LOW (OSUnMapTbl)
0026 F582            763             MOV     DPL,A
0028 E4              764             CLR     A
0029 3400     F      765             ADDC    A,#HIGH (OSUnMapTbl)
002B F583            766             MOV     DPH,A
002D E0              767             MOVX    A,@DPTR
002E 900000   F      768             MOV     DPTR,#OSIntExitY
0031 F0              769             MOVX    @DPTR,A
                     770     ;             OSPrioHighRdy = (INT8U)((OSIntExitY << 3) + OSUnMapTbl[OSRdyTbl[OSIntExitY]])
                             ;
                     771                             ; SOURCE LINE # 186
0032 E0              772             MOVX    A,@DPTR
0033 FF              773             MOV     R7,A
0034 2400     F      774             ADD     A,#LOW (OSRdyTbl)
0036 F582            775             MOV     DPL,A
0038 E4              776             CLR     A
0039 3400     F      777             ADDC    A,#HIGH (OSRdyTbl)
003B F583            778             MOV     DPH,A
003D E0              779             MOVX    A,@DPTR
003E 2400     F      780             ADD     A,#LOW (OSUnMapTbl)
0040 F582            781             MOV     DPL,A
0042 E4              782             CLR     A
0043 3400     F      783             ADDC    A,#HIGH (OSUnMapTbl)
0045 F583            784             MOV     DPH,A
0047 E0              785             MOVX    A,@DPTR
0048 FE              786             MOV     R6,A
0049 EF              787             MOV     A,R7
004A 33              788             RLC     A
A51 MACRO ASSEMBLER  OS_CORE                                                              05/17/2005 11:19:50 PAGE    14

⌨️ 快捷键说明

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