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

📄 tmt.s

📁 NucleusPLUS嵌入式操作系统是目前最受欢迎的操作系统NucleusPLUS是为实时嵌入式应用而设计的一个抢先式多任务操作系统内核
💻 S
📖 第 1 页 / 共 3 页
字号:
_TMT_Disable_Timer

; Disable the count-down timer.
;    TMD_Timer_State =  TM_NOT_ACTIVE;

        MOV     r1,#1                       ; Build TM_NOT_ACTIVE value
        LDR     r0,Timer_State              ; Build address to timer state var
        STR     r1,[r0,#0]                  ; Change timer state to not active

        BX      r14                         ; Return to caller
;}

;************************************************************************
;*                                                                       
;* FUNCTION                                                              
;*                                                                       
;*      TMT_Retreive_TS_Timer                                            
;*                                                                       
;* DESCRIPTION                                                           
;*                                                                       
;*      This function returns the time-sliced task pointer.              
;*                                                                       
;* CALLED BY                                                             
;*                                                                       
;*      TMC_Timer_HISR                      Timer HISR                   
;*                                                                       
;* CALLS                                                                 
;*                                                                       
;*      None                                                             
;*                                                                       
;* INPUTS                                                                
;*                                                                       
;*      None                                                             
;*                                                                       
;* OUTPUTS                                                               
;*                                                                       
;*      TMD_Time_Slice_Task                 Time sliced task pointer     
;*                                                                       
;* HISTORY                                                               
;*                                                                       
;*         NAME            DATE                    REMARKS               
;*                                                                       
;*      C. Meredith     03-01-1994      Created initial version 1.1      
;*      D. Lamie        03-18-1994      Verified version 1.1             
;*                                                                       
;************************************************************************
;NU_TASK TMT_Retrieve_TS_Task (VOID)
;{
    .def    $TMT_Retrieve_TS_Task
$TMT_Retrieve_TS_Task                        ; Dual-state interworking veneer
    .state16
    BX  r15
    NOP
    .state32
    B   _TMT_Retrieve_TS_Task

        .def    _TMT_Retrieve_TS_Task
_TMT_Retrieve_TS_Task

; Read the current TMD_Time_Slice_Task variable and load for
; return to caller.

        LDR     r1,Slice_Task                ; Build address to timer slice var
        LDR     r0,[r1,#0]                   ; Get task pointer to be returned

; Return to caller time slice value back to caller

        BX      r14                          ; Return to caller

;}

;************************************************************************
;*                                                                       
;* FUNCTION                                                              
;*                                                                       
;*      TMT_Timer_Interrupt                                              
;*                                                                       
;* DESCRIPTION                                                           
;*                                                                       
;*      This function processes the actual hardware interrupt.           
;*      Processing includes updating the system clock and the count-     
;*      down timer and the time-slice timer.  If one or both of the      
;*      timers expire, the timer HISR is activated.                      
;*                                                                       
;* CALLED BY                                                             
;*                                                                       
;*      Interrupt Vector                                                 
;*                                                                       
;* CALLS                                                                 
;*                                                                       
;*      TCT_Activate_HISR                   Activate timer HISR          
;*      TCT_Interrupt_Context_Save          Save interrupted context     
;*      TCT_Interrupt_Context_Restore       Restore interrupted context  
;*                                                                       
;* INPUTS                                                                
;*                                                                       
;*      None                                                             
;*                                                                       
;* OUTPUTS                                                               
;*                                                                       
;*      None                                                             
;*                                                                       
;* HISTORY                                                               
;*                                                                       
;*         NAME            DATE                    REMARKS               
;*                                                                       
;*      W. Lamie        02-15-1994      Created initial version 1.0      
;*      D. Lamie        02-15-1994      Verified version 1.0             
;*                                                                       
;************************************************************************
;VOID  TMT_Timer_Interrupt(void)
;{
        .def  _TMT_Timer_Interrupt
_TMT_Timer_Interrupt

        MRS     r1,CPSR                         ; Pickup current CPSR
        ORR     r1,r1,#LOCKOUT                  ; Set the interrupt lockout bits
        MSR     CPSR,r1                         ; Lockout interrupts

; Increment the system clock.
;    TMD_System_Clock++;

        LDR     r0,System_Clock                 ; Pickup system clock address
        LDR     r1,[r0,#0]                      ; Pickup system clock contents
        ADD     r1,r1,#1                        ; Increment system clock
        STR     r1,[r0,#0]                      ; Store new system clock value

; Determine if the count-down timer is active.
;    if (TMD_Timer_State == TM_ACTIVE)
;    {

        LDR     r1,Timer_State                  ; Build address to timer state flag
        LDR     r0,[r1,#0]                      ; Pickup timer state
        MOV     r3,#2                           ; Build expired value
        CMP     r0,#0                           ; Is there a timer active?
        BNE     TMT_No_Timer_Active             ; No, skip timer processing

; Decrement the count-down timer.
;        TMD_Timer--;

        LDR     r0,Timer                        ; Build timer address
        LDR     r2,[r0,#0]                      ; Pickup the current timer value

; Test if the Timer is at 0 and if so skip the decrement 
        cmp     r2,#1
        beq     EXPIRED

        SUBS    r2,r2,#1                        ; Decrement the timer value
        STR     r2,[r0,#0]                      ; Store the new timer value

        bne     TMT_No_Timer_Active             ; Skip over the Set Timer State

; Determine if the timer has expired. If so, modify the state 
; to indicate that it has expired.
;        if (TMD_Timer == 0)

;            TMD_Timer_State =  TM_EXPIRED;

EXPIRED:
        STREQ   r3,[r1,#0]                      ; Change the timer state to 
                                                ; expired

;    }
TMT_No_Timer_Active:

; Determine if the time-slice timer is active.  Note that the parameters
; for the time-slice are controlled by the Thread Control (TC) 
; component.
;    if (TMD_Time_Slice_State == TM_ACTIVE)
;    {
        LDR     r0,Slice_State                  ; Build time slice state address
        LDR     r2,[r0,#0]                      ; Pickup time slice state
        CMP     r2,#0                           ; Is there a time slice active?
        BNE     TMT_No_Time_Slice_Active        ; No, skip time slice processing

; Decrement the time slice counter.
;        TMD_Time_Slice--;

        LDR     r2,Time_Slice                   ; Build time slice address
        LDR     r3,[r2,#0]                      ; Pickup the time slice value
        SUBS    r3,r3,#1                        ; Decrement the time slice
        STR     r3,[r2,#0]                      ; Store the new time slice value

        ; Determine if the time-slice timer has expired. If so, modify the
        ; time-slice state to indicate that it has.
;        if (TMD_Time_Slice == 0)
;        {

        BNE     TMT_No_Time_Slice_Active        ; Has time slice expired?

;            TMD_Time_Slice_State =  TM_EXPIRED;

        MOV     r3,#2                           ; Build TM_EXPIRED value
        STR     r3,[r0,#0]                      ; Indicate time slice is expired

        ; Copy the current thread into the time-slice task pointer.
;            TMD_Time_Slice_Task =  TCD_Current_Thread;

        LDR     r2,Current_Thread               ; Pickup current thread pointer adr
        LDR     r2,[r2,#0]                      ; Pickup current thread pointer
        LDR     r3,Slice_Task                   ; Pickup time slice task pointer ad
        STR     r2,[r3,#0]                      ; Store current thread pointer

;            ((TC_TCB *) TCD_Current_Thread) -> tc_cur_time_slice =  1;

        MOV     r3,#1                           ; For safety, place a minimal time-
        STR     a4,[a3,#20h]!                   ; slice into the task's control
                                                ; block

;        }
;    }
TMT_No_Time_Slice_Active:

    ; Determine if either of the basic timers have expired.  If so, 
    ; activate the timer HISR.
;    if ((TMD_Timer_State == TM_EXPIRED) ||
;        (TMD_Time_Slice_State == TM_EXPIRED))
;    {

        LDR     r1,[r1,#0]                      ; Pickup timer state 
        CMP     r1,#2                           ; Does it indicate expiration?
        LDRNE   r0,[r0,#0]                      ; Pickup time slice state
        CMPNE   r0,#2                           ; Does it indicate expiration?
         
        BXNE    r14                             ; Return if no expiration

        ; Activate the HISR timer function.
;        TCT_Activate_HISR(&TMD_HISR);

        STR     r14,[r13, #-4]!                 ; Save r14 on the stack
        LDR     r0,HISR                         ; Build address of timer HISR
        BL      _TCT_Activate_HISR              ; Activate timer HISR
        LDR     r14,[r13], #4                   ; Recover return address
;    }

        BX      r14                             ; Return to caller

;}
        .end


⌨️ 快捷键说明

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