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

📄 tmt.s

📁 文件内包含了nuclues的内核代码和针对Power PC的编译器。需要用VirtNet生成一个虚拟网卡才可使用
💻 S
📖 第 1 页 / 共 3 页
字号:
#/*                                                                       */
#/* CALLED BY                                                             */
#/*                                                                       */
#/*      TMC_Timer_HISR                      Timer HISR                   */
#/*                                                                       */
#/* CALLS                                                                 */
#/*                                                                       */
#/*      None                                                             */
#/*                                                                       */
#/* INPUTS                                                                */
#/*                                                                       */
#/*      None                                                             */
#/*                                                                       */
#/* OUTPUTS                                                               */
#/*                                                                       */
#/*      TMD_Time_Slice_Task (return in r3)  Time sliced task pointer     */
#/*                                                                       */
#/* HISTORY                                                               */
#/*                                                                       */
#/*         NAME            DATE                    REMARKS               */
#/*                                                                       */
#/*      Barry Sellew    06-24-1996       Created initial version 1.0     */
#/*                                                                       */
#/*************************************************************************/
#NU_TASK  *TMT_Retrieve_TS_Task(VOID)
#{
    .text
    .align      2
    .globl      TMT_Retrieve_TS_Task
TMT_Retrieve_TS_Task:
#
#   /*  Save SP and LR for return */
#
    stwu        r1,-8(r1)
    mfspr       r0,LR
    stw         r0,12(r1)
#
#   /* Return time-sliced task pointer.  */
#   return((NU_TASK *) TMD_Time_Slice_Task);
#
    addis       r3,0,TMD_Time_Slice_Task@ha
    lwz         r3,TMD_Time_Slice_Task@l(r3)
#
#   /*  restore the SP and LR for the return */
#
    lwz         r0,12(r1)
    mtspr       LR,r0
    addi        r1,r1,8
    blr
#
#}
#
#/*************************************************************************/
#/*                                                                       */
#/* FUNCTION                                                              */
#/*                                                                       */
#/*      TMT_Timer_Interrupt                                              */
#/*                                                                       */
#/* DESCRIPTION                                                           */
#/*                                                                       */
#/*      This function processes the actual timer hardware interrupt.     */
#/*      Processing includes updating the system clock, the countdown     */
#/*      imer and the time-slice timer.  If one or both of the            */
#/*      timers expire, the timer HISR is activated.                      */
#/*                                                                       */
#/* AUTHOR                                                                */
#/*                                                                       */
#/*      Barry Sellew, Accelerated Technology, Inc.                       */
#/*                                                                       */
#/* CALLED BY                                                             */
#/*                                                                       */
#/*      INT_Ext_Intr                        Timer interrupt routine.     */
#/*                                                                       */
#/* 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               */
#/*                                                                       */
#/*      Barry Sellew    06-24-1996       Created initial version 1.0     */
#/*                                                                       */
#/*************************************************************************/
#VOID  TMT_Timer_Interrupt(VOID)
#{
    .text
    .align      2
    .globl      TMT_Timer_Interrupt
TMT_Timer_Interrupt:
#
#   /*  It is assumed that interrupts are locked out by the caller of this
#       function */
#
#   /*  Increment the system clock.  */
#   TMD_System_Clock++;
#
    addis       r12,0,TMD_System_Clock@ha
    lwz         r11,TMD_System_Clock@l(r12)
    addi        r11,r11,1
    stw         r11,TMD_System_Clock@l(r12)
#
#   /* Determine if the count-down timer is active.  */
#   if (TMD_Timer_State == TM_ACTIVE)
#   {
#
    addis       r12,0,TMD_Timer_State@ha
    lwz         r12,TMD_Timer_State@l(r12)
    cmpi        0,r12,0
    bne         TMT_Timer_Not_Active
#
#       /* Decrement the count-down timer.  */
#       TMD_Timer--;
#
    addis       r12,0,TMD_Timer@ha
    lwz         r11,TMD_Timer@l(r12)
    subi        r11,r11,1
    stw         r11,TMD_Timer@l(r12)
#
#       /* Determine if the timer has expired. If so, modify the state 
#          to indicate that it has expired.  */
#       if (TMD_Timer == 0)
#
    cmpli       0,r11,0
    bne         TMT_No_Timer_Expired
#
#           TMD_Timer_State =  TM_EXPIRED;
#
    addis       r12,0,TMD_Timer_State@ha
    li          r11,2
    stw         r11,TMD_Timer_State@l(r12)
TMT_No_Timer_Expired:
#
#   }
#
TMT_Timer_Not_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)
#   {
#
    addis       r12,0,TMD_Time_Slice_State@ha
    lwz         r12,TMD_Time_Slice_State@l(r12)
    cmpi        0,r12,0
    bne         TMT_Time_Slice_Not_Active
#
#       /* Decrement the time slice counter.  */
#       TMD_Time_Slice--;
#
    addis       r12,0,TMD_Time_Slice@ha
    lwz         r11,TMD_Time_Slice@l(r12)
    subi        r11,r11,1
    stw         r11,TMD_Time_Slice@l(r12)
#
#       /* 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)
#       {
#
    cmpli       0,r11,0
    bne         TMT_No_Slice_Expired
#
#           TMD_Time_Slice_State =  TM_EXPIRED;
#
    addis       r12,0,TMD_Time_Slice_State@ha
    li          r11,2
    stw         r11,TMD_Time_Slice_State@l(r12)
#
#           /* Copy the current thread into the time-slice task pointer.  */
#           TMD_Time_Slice_Task =  TCD_Current_Thread;
#
    addis       r11,0,TMD_Time_Slice_Task@ha
    addis       r12,0,TCD_Current_Thread@ha
    lwz         r12,TCD_Current_Thread@l(r12)
    stw         r12,TMD_Time_Slice_Task@l(r11)
#
#           ((TC_TCB *) TCD_Current_Thread) -> tc_cur_time_slice =  1;
#
    li          r11,1
    stw         r11,44(r12)
#       
#       }
TMT_No_Slice_Expired:
#   }
#
TMT_Time_Slice_Not_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))
#   {
    addis       r12,0,TMD_Timer_State@ha
    lwz         r12,TMD_Timer_State@l(r12)
    cmpi        0,r12,2
    beq         TMT_Expiration
    addis       r12,0,TMD_Time_Slice_State@ha
    lwz         r12,TMD_Time_Slice_State@l(r12)
    cmpi        0,r12,2
    bne         TMT_No_Expiration
TMT_Expiration:
#
#       /* Call the interrupt context save routine */
#
    bl          TCT_Interrupt_Context_Save

#       /* Activate the HISR timer function.  */
#       TCT_Activate_HISR((NU_HISR *) &TMD_HISR);
#
    addis       r3,0,TMD_HISR@ha
    addi        r3,r3,TMD_HISR@l
    bl          TCT_Activate_HISR

#       /* Call the context restore code, note will not return to this
#          location. */
#
    b           TCT_Interrupt_Context_Restore
#
#   }
#
TMT_No_Expiration:
#
#   /* Restore the CTR, XER, CR, LR, SRR1 (MSR), SRR0 (PC), and r9-r12 from 
#      the actual timer interrupt handler.  This will then do the rfi back to 
#      the point of interrupt. */
#
    lwz         r12,0(r1)                   # read in the old CTR value
    mtspr       CTR,r12                     # write it out
    lwzu        r12,4(r1)                   # read in the old XER value
    mtspr       XER,r12                     # write it out
    lwzu        r12,4(r1)                   # read in the old CR value
    mtcrf       0xff,r12                    # load back to CR all bits
    lwzu        r12,4(r1)                   # read in the old LR value
    mtspr       LR,r12                      # write it out
    mtspr       NRI,0                       # clear MSR[RI] bit
    lwzu        r12,4(r1)                   # read in the old SRR1 (MSR) value
    mtspr       SRR1,r12                    # write it out
    lwzu        r12,4(r1)                   # read in the old SRR0 (PC) value
    mtspr       SRR0,r12                    # write it out
    lwzu        r9,4(r1)                    # read in old r9 value
    lwzu        r10,4(r1)                   # read in old r10 value
    lwzu        r11,4(r1)                   # read in old r11 value
    lwzu        r12,4(r1)                   # read in old r12 value
    addi        r1,r1,8                     # remove DIAB/DATA space
    rfi
#}
#

⌨️ 快捷键说明

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