Chinaunix首页 | 论坛 | 博客
  • 博客访问: 427247
  • 博文数量: 123
  • 博客积分: 2686
  • 博客等级: 少校
  • 技术积分: 1349
  • 用 户 组: 普通用户
  • 注册时间: 2009-12-23 22:11
文章分类
文章存档

2012年(3)

2011年(10)

2010年(100)

2009年(10)

我的朋友

分类: LINUX

2009-12-29 13:18:13

1、u-boot顶层目录结构分析

u-boot-2009-11 目录结构说明

=============================================================
- api                    为外部应用程序提供的独立于体系结构的API接口

- board                  与具体电路板相关的文件放在这个目录里面

- common                 存放各个体系结构共用的函数

- cpu                    存放某个特定cpu的相关文件

    - arm920T            存放有关arm920T核心的文件
    ……
    - i386               存放i386核心相关的文件
    
- disk                   磁盘分区相关代码

- doc                    文档

-    driver              常用设备驱动程序

-    fs                  常用文件系统代码(cramfs, ext2, jffs2, etc.

- include                头文件

- lib_arm                arm体系结构通用的文件

- lib_avr32              avr32系统结构通用的文件

- lib_ppc                powerpc系统结构通用的文件
    …………
- lib_generic            存放所有体系结构通用的文件

- libfdt              Library files to support flattened device trees

- net                    网络相关代码

- post                   上电自检程序

- rtc                    实时时钟(Real Time Clock)驱动

- tools                  生成U-boot的工具


2、u-boot宏的类型

对u-boot进行配置,使用了2种宏:
一种宏用于选项配置 (_OPTIONS_),以 "CONFIG_" 开头,用于选择cpu,soc,开发板类型,设置系统时钟,选择设备驱动程序,可以看下smdk2410.h文件:
/*
 * High Level Configuration Options
 * (easy to change)
 */
#define CONFIG_ARM920T        1    /* This is an ARM920T Core    */
#define    CONFIG_S3C2410        1    /* in a SAMSUNG S3C2410 SoC     */
#define CONFIG_SMDK2410        1    /* on a SAMSUNG SMDK2410 Board  */

/*
 * Hardware drivers
 */
#define CONFIG_NET_MULTI
#define CONFIG_CS8900        /* we have a CS8900 on-board */
#define CONFIG_CS8900_BASE    0x19000300
#define CONFIG_CS8900_BUS16    /* the Linux driver does accesses as shorts */

以CONFIG_ 开头的宏,决定着某段代码是否被编译。一般,在程序中把某段代码放在 一对宏中间,宏起着开关的作用。
比如,代码/drivers/net//cs8900.c,CONFIG_CS8900_BUS32控制着代码的编译。

#ifdef CONFIG_CS8900_BUS32

#define REG_WRITE(v, a) writel((v),(a))
#define REG_READ(a) readl((a))

/* we don't need 16 bit initialisation on 32 bit bus */
#define get_reg_init_bus(r,d) get_reg((r),(d))

#else

#define REG_WRITE(v, a) writew((v),(a))
#define REG_READ(a) readw((a))

static u16 get_reg_init_bus(struct eth_device *dev, int regno)
{
    /* force 16 bit busmode */
    volatile u8 c;
    struct cs8900_priv *priv = (struct cs8900_priv *)(dev->priv);
    uint8_t volatile * const iob = (uint8_t volatile * const)dev->iobase;

    c = readb(iob);
    c = readb(iob + 1);
    c = readb(iob);
    c = readb(iob + 1);
    c = readb(iob);

    REG_WRITE(regno, &priv->regs->pptr);
    return REG_READ(&priv->regs->pdata);
}
#endif


另一种宏用于参数设置 (_SETTINGS_), 以 "CONFIG_SYS_" 开头

/* input clock of PLL */
#define CONFIG_SYS_CLK_FREQ    12000000/* the SMDK2410 has 12MHz input clock */

/*
 * Size of malloc() pool
 */
#define CONFIG_SYS_MALLOC_LEN        (CONFIG_ENV_SIZE + 128*1024)
#define CONFIG_SYS_GBL_DATA_SIZE    128    /* size in bytes reserved for initial data */


总结,u-boot的编译和链接过程中,几乎每个文件跑一遍,至于每个文件里面那些代码被编译,就由 CONFIG_ 类型的宏决定。
CONFIG_SYS_类型的宏主要用于参数设定,比如串口波特率,cpu频率,RAM开始地址等。


阅读(1394) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~