zoukankan      html  css  js  c++  java
  • init_sequence所对应的函数

    一、init_sequence内容

    init_fnc_t *init_sequence[] = {
        cpu_init,        /* basic cpu dependent setup */
        board_init,        /* basic board dependent setup */
        interrupt_init,        /* set up exceptions */
        env_init,        /* initialize environment */
        init_baudrate,        /* initialze baudrate settings */
        serial_init,        /* serial communications setup */
        console_init_f,        /* stage 1 init of console */
        display_banner,        /* say that we are here */
    #if defined(CONFIG_DISPLAY_CPUINFO)
        print_cpuinfo,        /* display cpu info (and speed) */
    #endif
    #if defined(CONFIG_DISPLAY_BOARDINFO)
        checkboard,        /* display board info */
    #endif
        dram_init,        /* configure available RAM banks */
        display_dram_config,
        NULL,
    };

    二、cpu_init(cpu/arm920t/cpu.c)

    int cpu_init (void)
    {
        /*
         * setup up stacks if necessary
         */
    #ifdef CONFIG_USE_IRQ
        IRQ_STACK_START = _armboot_start - CFG_MALLOC_LEN - CFG_GBL_DATA_SIZE - 4;
        FIQ_STACK_START = IRQ_STACK_START - CONFIG_STACKSIZE_IRQ;
    #endif
        return 0;
    } 

    三、board_init(board/smdk2410/smdk2410.c)

    int board_init (void)
    {
        S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();
        S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
    
        /* to reduce PLL lock time, adjust the LOCKTIME register */
        clk_power->LOCKTIME = 0xFFFFFF;
    
        /* configure MPLL */
        clk_power->MPLLCON = ((M_MDIV << 12) + (M_PDIV << 4) + M_SDIV);
    
        /* some delay between MPLL and UPLL */
        delay (4000);
    
        /* configure UPLL */
        clk_power->UPLLCON = ((U_M_MDIV << 12) + (U_M_PDIV << 4) + U_M_SDIV);
    
        /* some delay between MPLL and UPLL */
        delay (8000);
    
        /* set up the I/O ports */
        gpio->GPACON = 0x007FFFFF;
        gpio->GPBCON = 0x00044555;
        gpio->GPBUP = 0x000007FF;
        gpio->GPCCON = 0xAAAAAAAA;
        gpio->GPCUP = 0x0000FFFF;
        gpio->GPDCON = 0xAAAAAAAA;
        gpio->GPDUP = 0x0000FFFF;
        gpio->GPECON = 0xAAAAAAAA;
        gpio->GPEUP = 0x0000FFFF;
        gpio->GPFCON = 0x000055AA;
        gpio->GPFUP = 0x000000FF;
        gpio->GPGCON = 0xFF95FFBA;
        gpio->GPGUP = 0x0000FFFF;
        gpio->GPHCON = 0x002AFAAA;
        gpio->GPHUP = 0x000007FF;
    
        /* arch number of SMDK2410-Board */
        gd->bd->bi_arch_number = MACH_TYPE_SMDK2410;
    
        /* adress of boot parameters */
        gd->bd->bi_boot_params = 0x30000100;
    
        icache_enable();
        dcache_enable();
    
        return 0;
    }

    四、interrupt_init(cpu/arm920t/s3c24x0.c)

    int interrupt_init (void)
    {
        S3C24X0_TIMERS * const timers = S3C24X0_GetBase_TIMERS();
    
        /* use PWM Timer 4 because it has no output */
        /* prescaler for Timer 4 is 16 */
        timers->TCFG0 = 0x0f00;
        if (timer_load_val == 0)
        {
            /*
             * for 10 ms clock period @ PCLK with 4 bit divider = 1/2
             * (default) and prescaler = 16. Should be 10390
             * @33.25MHz and 15625 @ 50 MHz
             */
            timer_load_val = get_PCLK()/(2 * 16 * 100);
        }
        /* load value for 10 ms timeout */
        lastdec = timers->TCNTB4 = timer_load_val;
        /* auto load, manual update of Timer 4 */
        timers->TCON = (timers->TCON & ~0x0700000) | 0x600000;
        /* auto load, start Timer 4 */
        timers->TCON = (timers->TCON & ~0x0700000) | 0x500000;
        timestamp = 0;
    
        return (0);
    }

    五、env_init

        uboot支持把环境变量放在很多存储器上,例如norflash、nandflash、eeprom等等,不同的方式env_init函数的实现也是不同的,但是env_init函数最终会被start_amboot调用,屏蔽了这些差异。

    smdk2410.h中默认选择的是norflash:
    include/configs/smdk2410.h #define CFG_ENV_IS_IN_FLASH 1

    (common/Env_flash.c)

    #ifdef CFG_ENV_ADDR_REDUND //未被定义
    
    int  env_init(void)
    {
    #ifdef CONFIG_OMAP2420H4
        int flash_probe(void);
    
        if(flash_probe() == 0)
            goto bad_flash;
    #endif
        if (crc32(0, env_ptr->data, ENV_SIZE) == env_ptr->crc) {
            gd->env_addr  = (ulong)&(env_ptr->data);
            gd->env_valid = 1;
            return(0);
        }
    #ifdef CONFIG_OMAP2420H4
    bad_flash:
    #endif
        gd->env_addr  = (ulong)&default_environment[0];
        gd->env_valid = 0;
        return (0);
    }

    六、init_baudrate(lib_arm/board.c)

    static int init_baudrate (void)
    {
        char tmp[64];    /* long enough for environment variables */
        int i = getenv_r ("baudrate", tmp, sizeof (tmp));
        gd->bd->bi_baudrate = gd->baudrate = (i > 0)
                ? (int) simple_strtoul (tmp, NULL, 10)
                : CONFIG_BAUDRATE;
    
        return (0);
    }

    七、serial_init(cpu/arm920t/s3c24x0/serial.c)

    int serial_init (void)
    {
        serial_setbrg ();
    
        return (0);
    }
    void serial_setbrg (void)
    {
        S3C24X0_UART * const uart = S3C24X0_GetBase_UART(UART_NR);
        int i;
        unsigned int reg = 0;
    
        /* value is calculated so : (int)(PCLK/16./baudrate) -1 */
        reg = get_PCLK() / (16 * gd->baudrate) - 1;
    
        /* FIFO enable, Tx/Rx FIFO clear */
        uart->UFCON = 0x07;
        uart->UMCON = 0x0;
        /* Normal,No parity,1 stop,8 bit */
        uart->ULCON = 0x3;
        /*
         * tx=level,rx=edge,disable timeout int.,enable rx error int.,
         * normal,interrupt or polling
         */
        uart->UCON = 0x245;
        uart->UBRDIV = reg;
    
    #ifdef CONFIG_HWFLOW
        uart->UMCON = 0x1; /* RTS up */
    #endif
        for (i = 0; i < 100; i++);
    }

    八、console_init_f(common/console.c)

    /* Called before relocation - use serial functions */
    int console_init_f (void)
    {
        gd->have_console = 1;
    
    #ifdef CONFIG_SILENT_CONSOLE
        if (getenv("silent") != NULL)
            gd->flags |= GD_FLG_SILENT;
    #endif
    
        return (0);
    }

    九、display_banner(lib_arm/board.c)

    static int display_banner (void)
    {
        printf ("
    
    %s
    
    ", version_string);
        debug ("U-Boot code: %08lX -> %08lX  BSS: -> %08lX
    ",
               _armboot_start, _bss_start, _bss_end);
    #ifdef CONFIG_MODEM_SUPPORT
        debug ("Modem Support enabled
    ");
    #endif
    #ifdef CONFIG_USE_IRQ
        debug ("IRQ Stack: %08lx
    ", IRQ_STACK_START);
        debug ("FIQ Stack: %08lx
    ", FIQ_STACK_START);
    #endif
    
        return (0);
    }

    十、dram_init(board/smdk2410.c)

    int dram_init (void)
    {
        gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
        gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
    
        return 0;
    }

    十、display_dram_config (lib_arm/board.c)

    static int display_dram_config (void)
    {
        int i;
    
    #ifdef DEBUG
        puts ("RAM Configuration:
    ");
    
        for(i=0; i<CONFIG_NR_DRAM_BANKS; i++) {
            printf ("Bank #%d: %08lx ", i, gd->bd->bi_dram[i].start);
            print_size (gd->bd->bi_dram[i].size, "
    ");
        }
    #else
        ulong size = 0;
    
        for (i=0; i<CONFIG_NR_DRAM_BANKS; i++) {
            size += gd->bd->bi_dram[i].size;
        }
        puts("DRAM:  ");
        print_size(size, "
    ");
    #endif
    
        return (0);
    }
  • 相关阅读:
    HDU 5001 Walk (暴力、概率dp)
    Codeforces Round #265 (Div. 2) C 暴力+ 找规律+ 贪心
    zoj 3812 We Need Medicine (dp 状压)
    ZOJ
    ZOJ 3811 / 2014 牡丹江赛区网络赛 C. Untrusted Patrol bfs/dfs/并查集
    POJ 2411 状压dp
    HDU 3001 三进制 状压dp
    POJ 2096 (dp求期望)
    poj 3311 状压dp 最短路
    数据挖掘的基本概念
  • 原文地址:https://www.cnblogs.com/amanlikethis/p/3449449.html
Copyright © 2011-2022 走看看