embed_uish.s

来自「realview22.rar」· S 代码 · 共 69 行

S
69
字号
;;  Copyright ARM Ltd 2002. All rights reserved.
;;
;;  This implementation of __user_initial_stackheap places the
;;  heap at the location of the symbol bottom_of_heap.  
;;  This symbol is placed by the scatter file.  
;;
;;  It assumes that the application mode stack has been placed
;;  in the reset handler.  
;;
        PRESERVE8

        AREA   UISH, CODE, READONLY      ; name this block of code

                                IMPORT __use_two_region_memory


                IMPORT      ||Image$$STACKS$$ZI$$Base||
                IMPORT      ||Image$$STACKS$$ZI$$Limit||

stack_base      DCD         ||Image$$STACKS$$ZI$$Limit||
stack_limit     DCD         ||Image$$STACKS$$ZI$$Base||

                IMPORT      ||Image$$HEAP$$ZI$$Base||
                IMPORT      ||Image$$HEAP$$ZI$$Limit||

heap_base       DCD     ||Image$$HEAP$$ZI$$Base||
heap_limit      DCD     ||Image$$HEAP$$ZI$$Limit||


        EXPORT __user_initial_stackheap

__user_initial_stackheap FUNCTION
    LDR   r0,heap_base
;;                                              
;;                                                      SVC stack inherited from init.s
;;
;;                                                      The mode stacks are set up in init.s with
;;                                                      offsets from stack_base. The SVC mode stack 
;;                                                      is set up last so R13 holds the SVC mode SP.
;;                                                      Before __user_initial_stackheap is called the
;;                                                      current value of R13 (SP) is copied into R1
;;                                                      so R1 does not need changing.

        LDR   r2,heap_limit
        LDR   r3,stack_limit

    MOV   pc,lr
    ENDFUNC
    
        END
        

;; The following is the equivalent implementation of the above in C
;;
;; extern unsigned int bottom_of_heap;    //defined in heap.s
;;
;; __value_in_regs struct __initial_stackheap __user_initial_stackheap(
;;         unsigned R0, unsigned SP, unsigned R2, unsigned SL)
;; {
;;     struct __initial_stackheap config;
;;
;;     config.heap_base = (unsigned int)&bottom_of_heap; // defined in heap.s
;;                                                       // placed by scatterfile
;;     config.stack_base = SP;   // inherit SP from the execution environment
;;
;;     return config;
;; }

⌨️ 快捷键说明

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