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

📄 tct.s

📁 基于OMAP1510的Nucleus移植代码
💻 S
📖 第 1 页 / 共 5 页
字号:

;               (Lower Address) Stack Top ->    1       (Interrupt stack type)
;                                               CPSR    Saved CPSR
;                                               r0      Saved r0
;                                               r1      Saved r1
;                                               r2      Saved r2
;                                               r3      Saved r3
;                                               r4      Saved r4
;                                               r5      Saved r5
;                                               r6      Saved r6
;                                               r7      Saved r7
;                                               r8      Saved r8
;                                               r9/sb   Saved r9/sl
;                                               r10/sl   Saved r10/sl
;                                               fp      Saved fp
;                                               r12      Saved r12
;                                               r13      Saved r13
;                                               r14      Saved r14
;               (Higher Address) Stack Bottom-> r15      Saved r15
  

        LDR     r2, Task_Shell              ; Pickup address of shell entry
        .if THUMB
         
         BIC     r2,r2,#1                   ; Clear low bit
         
        .endif
        STR     r2,[r3], #-4                ; Store entry address on stack
        MOV     r2,#0                       ; Clear value for initial registers
        STR     r2,[r3], #-4                ; Store initial r14
        ADD     r2,r3,#8h                   ; Compute initial r13
        STR     r2,[r3], #-4                ; Store initial r13 (Stack Bottom)
        STR     r2,[r3], #-4                ; Store initial r12
        STR     r2,[r3], #-4                ; Store initial fp
        LDR     r2,[r0,#24h]                ; Pickup the stack starting address
        STR     r2,[r3], #-4                ; Store initial r10/sl
        MOV     r2,#0                       ; Clear value for initial registers
        STR     r2,[r3], #-4                ; Store initial r9/sb
        STR     r2,[r3], #-4                ; Store initial r8
        STR     r2,[r3], #-4                ; Store initial r7
        STR     r2,[r3], #-4                ; Store initial r6
        STR     r2,[r3], #-4                ; Store initial r5
        STR     r2,[r3], #-4                ; Store initial r4
        STR     r2,[r3], #-4                ; Store initial r3
        STR     r2,[r3], #-4                ; Store initial r2
        STR     r2,[r3], #-4                ; Store initial r1
        STR     r2,[r3], #-4                ; Store initial r0
        MSR     CPSR_FLG,r2                 ; Clear the flags
        MRS     r2,CPSR                     ; Pickup the CPSR
        BIC     r2,r2,#LOCK_MSK             ; Clear initial interrupt lockout
        .if THUMB
         
         ORR     r2,r2,#20h                 ; Set to THUMB state
         
        .endif
        STR     r2,[r3], #-4                ; Store CPSR on the initial stack
        MOV     r2,#1                       ; Build interrupt stack type (1)
        STR     r2,[r3, #0]                 ; Store stack type on the top 

    ; Save the minimum amount of remaining stack memory. 
;    task -> tc_stack_minimum =  REG_Stack_Size - 72;

        MOV     r2,#72                      ; Size of interrupt stack frame
        SUB     r1,r1,r2                    ; Compute minimum available bytes
        STR     r1,[r0, #34h]               ; Save in minimum stack area

    ; Save the new stack pointer into the task's control block. 
;    task -> tc_stack_pointer =  (VOID *) Stack_Top;

        STR     r3,[r0, #2Ch]               ; Save stack pointer

        BX      r14                         ; Return to caller

;}

;************************************************************************
;*                                                                       
;* FUNCTION                                                              
;*                                                                       
;*      TCT_Build_HISR_Stack                                             
;*                                                                       
;* DESCRIPTION                                                           
;*                                                                       
;*      This function builds an HISR stack frame that allows quick       
;*      scheduling of the HISR.                                          
;*                                                                       
;* CALLED BY                                                             
;*                                                                       
;*      TCC_Create_HISR                     Create HISR function         
;*                                                                       
;* CALLS                                                                 
;*                                                                       
;*      None                                                             
;*                                                                       
;* INPUTS                                                                
;*                                                                       
;*      hisr                                HISR control block pointer   
;*                                                                       
;* 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  TCT_Build_HISR_Stack(TC_HCB *hisr)
;{
    .def    $TCT_Build_HISR_Stack
$TCT_Build_HISR_Stack                       ; Dual-state interworking veneer
    .state16
    BX  r15
    NOP
    .state32
    B   _TCT_Build_HISR_Stack

        .def    _TCT_Build_HISR_Stack
_TCT_Build_HISR_Stack

    ; Pickup the stack base. 
;    REG_Stack_Base =  (BYTE_PTR) hisr -> tc_stack_start;

        LDR     r2,[r0,#24h]                ; Pickup the stack starting address

    ; Pickup the stack size. 
;    REG_Stack_Size =  hisr -> tc_stack_size;

        LDR     r1,[r0,#30h]                ; Pickup the stack size in bytes

    ; Calculate the stack ending address. 
;    REG_Stack_End =  REG_Stack_Base + REG_Stack_Size;

        ADD     r3,r1,r2                    ; Compute the beginning of stack
        BIC     r3,r3,#3                    ; Insure word alignment
        SUB     r3,r3,#4                    ; Reserve a word

    ; Save the stack ending address. 
;    hisr -> tc_stack_end =  REG_Stack_End;

        STR     r3,[r0,#28h]                ; Save the stack ending address

    ; Reference the HISR shell. 
;    REG_Function_Ptr =  (VOID *) TCT_HISR_Shell;

; Build an initial stack.  This initial stack frame facilitates an 
; solicited return to the TCT_HISR_Shell function, which in turn 
; invokes the appropriate HISR.  The initial HISR stack frame has the 
; following format:

;               (Lower Address) Stack Top ->    0       (Solicited stack type)
;                !!FOR THUMB ONLY!!             0/0x20  Saved state mask
;                                               r4      Saved r4
;                                               r5      Saved r5
;                                               r6      Saved r6
;                                               r7      Saved r7
;                                               r8      Saved r8
;                                               r9/sb   Saved r9/sl
;                                               r10/sl   Saved r10/sl
;                                               fp      Saved fp
;                                               r12      Saved r12
;               (Higher Address) Stack Bottom-> r15      Saved r15
   

        LDR     r2,HISR_Shell               ; Pickup address of shell entry
        STR     r2,[r3], #-4                ; Store entry address on stack
        ADD     r2,r3,#4h                   ; Compute initial r13
        STR     r2,[r3], #-4                ; Store initial r12
        STR     r2,[r3], #-4                ; Store initial fp
        LDR     r2,[r0,#24h]                ; Pickup the stack starting address
        STR     r2,[r3], #-4                ; Store initial r10/sl
        MOV     r2,#0                       ; Clear value for initial registers
        STR     r2,[r3], #-4                ; Store initial r9/sb
        STR     r2,[r3], #-4                ; Store initial r8
        STR     r2,[r3], #-4                ; Store initial r7
        STR     r2,[r3], #-4                ; Store initial r6
        STR     r2,[r3], #-4                ; Store initial r5
        STR     r2,[r3], #-4                ; Store initial r4
        .if THUMB
         
        STR     r2,[r3], #-4                ; Store initial state mask
         
        .endif
        STR     r2,[r3, #0]                 ; Store solicited stack type on the
                                            ; top of the stack 

    ; Save the minimum amount of remaining stack memory. 
;    hisr -> tc_stack_minimum =  REG_Stack_Size - (ARM)44 or (THUMB)48;

        .if THUMB
         
         MOV     r2,#48                     ; Size of solicited stack frame
        .else
         
         MOV     r2,#44                     ; Size of solicited stack frame
        .endif
        SUB     r1,r1,r2                    ; Compute minimum available bytes
        STR     r1,[r0, #34h]               ; Save in minimum stack area

    ; Save the new stack pointer into the task's control block. 
;    hisr -> tc_stack_pointer =  (VOID *) Stack_Top;

        STR     r3,[r0, #2Ch]               ; Save stack pointer

        BX      r14                         ; Return to caller

;}

;************************************************************************
;*                                                                       
;* FUNCTION                                                              
;*                                                                       
;*      TCT_Build_Signal_Frame                                           
;*                                                                       
;* DESCRIPTION                                                           
;*                                                                       
;*      This function builds a frame on top of the task's stack to       
;*      cause the task's signal handler to execute the next time         
;*      the task is executed.                                            
;*                                                                       
;* CALLED BY                                                             
;*                                                                       
;*      TCC_Send_Signals                    Send signals to a task       
;*                                                                       
;* CALLS                                                                 
;*                                                                       
;*      None                                                             
;*                                                                       
;* INPUTS                                                                
;*                                                                       
;*      task                                Task control block pointer   
;*                                                                       
;* 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  TCT_Build_Signal_Frame(TC_TCB *task)
;{
    .def    $TCT_Build_Signal_Frame
$TCT_Build_Signal_Frame                     ; Dual-state interworking veneer
    .state16
    BX  r15

⌨️ 快捷键说明

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