U-Boot与Linux内核的交互
U-Boot与Linux内核的交互
说明:本文所使用的U-Boot的版本是1.1.6,平台是S3C2440。
U-Boot源代码下载地址
目录
一、简介1.1标记列表
二、设置标记存放的地址
2.1相关的结构体定义
2.2标记存放地址的设定
三、标记的设置
3.1设置标记ATAG_CORE
3.2设置内存标记ATAG_MEM
3.3设置命令行标记ATAG_CMDLINE
3.4设置ATAG_NONE
一、简介
U-Boot与Linux内核的交互是单向的,U-Boot将各类参数传递给讷河。由于他们不能同时运行,传递办法只能有一个个:U-Boot将参数放在某个约定的地方之后,在启动内核,内核启动后从这个地方获得参数。
1.1标记列表
除了约定好参数存放的地方外,还要规定参数的结构。Linux2.4.x以后的内核都以标记列表(tagged list)的形式来传递参数。标记就是一种数据结构;标记列表就是挨着存放的多个标记。标记列表以标记ATAG_CORE开始,以ATAGE_NONE结束。
标记的数据结构为tag,它是偶一个tag_header结构和一个联合体(union)组成。tag_header结构体表示标记的类型及长度,比如是表示内存还是表示命令行参数等。对于不同类型的标记使用不同的联合体,比如表示内存=时使用tag_men32,表示命令行时使用tag_cmdline。其定定义在include/asm-arm/setup.c文件中。
- /*
- * The new way of passing information: a list of tagged entries
- */
- /* The list ends with an ATAG_NONE node. */
- #define ATAG_NONE 0x00000000
- struct tag_header {
- u32 size;
- u32 tag;
- };
- /* The list must start with an ATAG_CORE node */
- #define ATAG_CORE 0x54410001
- struct tag_core {
- u32 flags; /* bit 0 = read-only */
- u32 pagesize;
- u32 rootdev;
- };
- /* it is allowed to have multiple ATAG_MEM nodes */
- #define ATAG_MEM 0x54410002
- struct tag_mem32 {
- u32 size;
- u32 start; /* physical start address */
- };
- /* VGA text type displays */
- #define ATAG_VIDEOTEXT 0x54410003
- struct tag_videotext {
- u8 x;
- u8 y;
- u16 video_page;
- u8 video_mode;
- u8 video_cols;
- u16 video_ega_bx;
- u8 video_lines;
- u8 video_isvga;
- u16 video_points;
- };
- /* describes how the ramdisk will be used in kernel */
- #define ATAG_RAMDISK 0x54410004
- struct tag_ramdisk {
- u32 flags; /* bit 0 = load, bit 1 = prompt */
- u32 size; /* decompressed ramdisk size in _kilo_ bytes */
- u32 start; /* starting block of floppy-based RAM disk image */
- };
- /* describes where the compressed ramdisk image lives (virtual address) */
- /*
- * this one accidentally used virtual addresses - as such,
- * its depreciated.
- */
- #define ATAG_INITRD 0x54410005
- /* describes where the compressed ramdisk image lives (physical address) */
- #define ATAG_INITRD2 0x54420005
- struct tag_initrd {
- u32 start; /* physical start address */
- u32 size; /* size of compressed ramdisk image in bytes */
- };
- /* board serial number. "64 bits should be enough for everybody" */
- #define ATAG_SERIAL 0x54410006
- struct tag_serialnr {
- u32 low;
- u32 high;
- };
- /* board revision */
- #define ATAG_REVISION 0x54410007
- struct tag_revision {
- u32 rev;
- };
- /* initial values for vesafb-type framebuffers. see struct screen_info
- * in include/linux/tty.h
- */
- #define ATAG_VIDEOLFB 0x54410008
- struct tag_videolfb {
- u16 lfb_width;
- u16 lfb_height;
- u16 lfb_depth;
- u16 lfb_linelength;
- u32 lfb_base;
- u32 lfb_size;
- u8 red_size;
- u8 red_pos;
- u8 green_size;
- u8 green_pos;
- u8 blue_size;
- u8 blue_pos;
- u8 rsvd_size;
- u8 rsvd_pos;
- };
- /* command line: \0 terminated string */
- #define ATAG_CMDLINE 0x54410009
- struct tag_cmdline {
- char cmdline[1]; /* this is the minimum size */
- };
- /* acorn RiscPC specific information */
- #define ATAG_ACORN 0x41000101
- struct tag_acorn {
- u32 memc_control_reg;
- u32 vram_pages;
- u8 sounddefault;
- u8 adfsdrives;
- };
- /* footbridge memory clock, see arch/arm/mach-footbridge/arch.c */
- #define ATAG_MEMCLK 0x41000402
- struct tag_memclk {
- u32 fmemclk;
- };
- struct tag {
- struct tag_header hdr;
- union {
- struct tag_core core;
- struct tag_mem32 mem;
- struct tag_videotext videotext;
- struct tag_ramdisk ramdisk;
- struct tag_initrd initrd;
- struct tag_serialnr serialnr;
- struct tag_revision revision;
- struct tag_videolfb videolfb;
- struct tag_cmdline cmdline;
- /*
- * Acorn specific
- */
- struct tag_acorn acorn;
- /*
- * DC21285 specific
- */
- struct tag_memclk memclk;
- } u;
- };
- #define tag_next(t)<span style="white-space:pre"> </span>((struct tag *)((u32 *)(t) + (t)->hdr.size))
- #define tag_size(type)<span style="white-space:pre"> </span>((sizeof(struct tag_header) + sizeof(struct type)) >> 2) //???
|
评论暂时关闭