• 在Main函数之前发生的事 ZEDBOARD,ZYNQ7000


    What happened before running into main function on zedboard?

    Use the zedboard hardware platform to create a Xilinx project and named it print_demo as shown following:

    Look into the main function, nothing has been done in the init_platform() function.

    Where is the uart init invoking in such a complexing hardware driver files?

    Under the project explorer view, select the print_demo_bsp>ps7_cortexa9_0>libsrc>standalone_v3_08_a>src>asm_vectors.s

    Double click to read the contents of asm_vectors.s:

    .section .vectors

    _vector_table:

    B    _boot

    B    Undefined

    B    SVCHandler

    B    PrefetchAbortHandler

    B    DataAbortHandler

    NOP    /* Placeholder for address exception vector*/

    B    IRQHandler

    B    FIQHandler

    _vector_table locates the exception entry point, and the cortex a9 processor execute the first sentence B    _boot

    New we go to the definition of _boot (boot.S):

    /* this initializes the various processor modes */

     

    _prestart:

    _boot:

    #if XPAR_CPU_ID==0

    /* only allow cpu0 through */

        mrc    p15,0,r1,c0,c0,5

        and    r1, r1, #0xf

        cmp    r1, #0

        beq    OKToRun

    EndlessLoop0:

        wfe

        b    EndlessLoop0

     

    #elif XPAR_CPU_ID==1

    /* only allow cpu1 through */

        mrc    p15,0,r1,c0,c0,5

        and    r1, r1, #0xf

        cmp    r1, #1

        beq    OKToRun

    EndlessLoop1:

        wfe

        b    EndlessLoop1

    #endif

     

    The label OKToRun located in the same file:

    OKToRun:

        /* set VBAR to the _vector_table address in linker script */

        ldr    r0, =vector_base

        mcr    p15, 0, r0, c12, c0, 0

        …    …

        b    _start                /* jump to C startup code */

        and    r0, r0, r0                /* no op */

     

    _start label located in the xil_crt0.S :

    start:

        bl __cpu_init        /* Initialize the CPU first (BSP provides this) */

        mov    r0, #0

        …    …

        /* Initialize STDOUT */

        bl    Init_Uart

        …    …

        /* Let her rip */

        bl    main

    We have noticed that the bsp program run the Init_Uart before going into main function.

    The Init_Uart function locates in the uart.c file:

    #define UART_BAUDRATE    115200

    Buadrate is determined by the macro. Change it to 9600 if 9600 baudrate is desired.

    NOTICE: ANY change in those files locate in the bsp project>ps7_cortexa9_0 will be ignored as the contents will regenerate once building the project. If need to re-invode the init_uart function again in the main function to make a change.

  • 相关阅读:
    HDU 4686
    二叉索引树——树状数组
    poj 3548 Restoring the digits(DFS)
    poj 2062 Card Game Cheater(排序+模拟)
    poj 2570 Fiber Network(floyd)
    hdu 1080 Human Gene Functions
    hdu 4512 吉哥系列故事——完美队形I(最长公共上升自序加强版)
    2015 Multi-University Training Contest 2
    poj 1258 Agri-Net(最小生成树)
    2015 Multi-University Training Contest 1记录
  • 原文地址:https://www.cnblogs.com/dragen/p/3116742.html
Copyright © 2020-2023  润新知