Chinaunix首页 | 论坛 | 博客
  • 博客访问: 400514
  • 博文数量: 101
  • 博客积分: 2247
  • 博客等级: 大尉
  • 技术积分: 979
  • 用 户 组: 普通用户
  • 注册时间: 2011-06-15 22:39
文章分类

全部博文(101)

文章存档

2012年(1)

2011年(100)

分类: 嵌入式

2011-06-29 13:35:45

1.u-boot-2011.06-rc3/arch/arm/cpu/armv7/u-boot.lds
uboot入口

2.u-boot-2011.06-rc3/arch/arm/cpu/armv7/start.s
硬件设备初始化,主要做了以下工作:
(1)设置异常向量
(2)CPU进入SVC32模式
(3)设置cpu
(4)屏蔽中断
(5)初始化RAM
(6)设置堆栈
(7)清除BSS段
(8)跳转到第二阶段代码入口

3.u-boot-2011.06-rc3/arch/arm/cpu/armv7/omap3/lowlevel_init.S
内存初始化
start.S和lowlevel_init.S都在U-Boot的前4KB的代码中。

判断U-Boot是在NAND Flash启动还是NOR Flash启动, 对于从NOR Flash启动的情况,NOR Flash的开始地址即为0,必须通过一定的命令序列才能向NOR Flash中写数据,所以可以根据这点差别来分辨是从NAND Flash还是NOR Flash启动:向地址0写入一个数据,然后读出来,如果发现写入失败的就是NOR Flash,否则就是NAND Flash。

4.u-boot-2011.06-rc3/arch/arm/lib/board.c
通过jump_2_ram调用board.c下的board_init_r函数进行第二阶段初始化。
旧版本是start_armboot函数。

(1)U-Boot使用了一个结构体gd_t来存储全局数据区的数据,这个结构体在u-boot-2011.06-rc3/arch/arm/include/asm/global_data.h中定义如下:
typedef struct global_data {
bd_t *bd;
unsigned long flags;
unsigned long baudrate;
unsigned long have_console; /* serial_init() was called */
unsigned long env_addr; /* Address  of Environment struct */
unsigned long env_valid; /* Checksum of Environment valid? */
unsigned long fb_base; /* base address of frame buffer */
#ifdef CONFIG_VFD
unsigned char vfd_type; /* display type */
#endif
#ifdef CONFIG_FSL_ESDHC
unsigned long sdhc_clk;
#endif
#ifdef CONFIG_AT91FAMILY
/* "static data" needed by at91's clock.c */
unsigned long cpu_clk_rate_hz;
unsigned long main_clk_rate_hz;
unsigned long mck_rate_hz;
unsigned long plla_rate_hz;
unsigned long pllb_rate_hz;
unsigned long at91_pllb_usb_init;
#endif
#ifdef CONFIG_ARM
/* "static data" needed by most of timer.c on ARM platforms */
unsigned long timer_rate_hz;
unsigned long tbl;
unsigned long tbu;
unsigned long long timer_reset_value;
unsigned long lastinc;
#endif
unsigned long relocaddr; /* Start address of U-Boot in RAM */
phys_size_t ram_size; /* RAM size */
unsigned long mon_len; /* monitor len */
unsigned long irq_sp; /* irq stack pointer */
unsigned long start_addr_sp; /* start_addr_stackpointer */
unsigned long reloc_off;
#if !(defined(CONFIG_SYS_NO_ICACHE) && defined(CONFIG_SYS_NO_DCACHE))
unsigned long tlb_addr;
#endif
void **jt; /* jump table */
char env_buf[32]; /* buffer for getenv() before reloc. */
} gd_t;

U-Boot使用了一个存储在寄存器中的指针gd来记录全局数据区的地址:
#define DECLARE_GLOBAL_DATA_PTR     register volatile gd_t *gd asm ("r8")
DECLARE_GLOBAL_DATA_PTR定义一个gd_t全局数据结构的指针,这个指针存放在指定的寄存器r8中。这个声明也避免编译器把r8分配给其它的变量。任何想要访问全局数据区的代码,只要代码开头加入“DECLARE_GLOBAL_DATA_PTR”一行代码,然后就可以使用gd指针来访问全局数据区了。

(2)bd_t结构体
在u-boot-2011.06-rc3/arch/arm/include/asm/u-boot.h定义
typedef struct bd_info {
    int bi_baudrate; /* serial console baudrate */
    unsigned long bi_ip_addr; /* IP Address */
    ulong        bi_arch_number; /* unique id for this board */
    ulong        bi_boot_params; /* where this board expects params */
    struct /* RAM configuration */
    {
ulong start;
ulong size;
    } bi_dram[CONFIG_NR_DRAM_BANKS];
} bd_t;
 U-Boot启动内核时要给内核传递参数,这时就要使用gd_t,bd_t结构体中的信息来设置标记列表。

(3)init_sequence数组
U-Boot使用一个数组init_sequence来存储对于大多数开发板都要执行的初始化函数的函数指针。定义在u-boot-2011.06-rc3/arch/arm/lib/board.c文件下。

init_fnc_t *init_sequence[] = {
#if defined(CONFIG_ARCH_CPU_INIT)
arch_cpu_init, /* basic arch cpu dependent setup */
#endif
#if defined(CONFIG_BOARD_EARLY_INIT_F)
board_early_init_f,
#endif
timer_init, /* initialize timer */
#ifdef CONFIG_FSL_ESDHC
get_clocks,
#endif
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
#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
init_func_i2c,
#endif
dram_init, /* configure available RAM banks */
#if defined(CONFIG_CMD_PCI) || defined (CONFIG_PCI)
arm_pci_init,
#endif
NULL,
};

5.u-boot-2011.06-rc3/common/main.c
进入main_loop函数

阅读(1628) | 评论(0) | 转发(0) |
0

上一篇:Android safe mode

下一篇:U-Boot启动Linux

给主人留下些什么吧!~~