第一范文网 - 专业文章范例文档资料分享平台

vivi boot loader的实现

来源:用户分享 时间:2025/6/27 17:28:34 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

以下代码来自testasecca的boot-patch for 89712 http://ttestasecca.free.fr/cdb89712/patch/boot_patch cdb89712/kernel/arch/boot/compressed/misc.c

int hermit_linux_cmdfunc(int argc, char *argv[]) {

struct tag *tag = (struct tag *) LINUX_PARAM_ADDRESS;

/* zero param block */

memzero (tag, LINUX_PARAM_SIZE);

/* set up core tag */

tag->hdr.tag = ATAG_CORE;

tag->hdr.size = tag_size(tag_core); tag->u.core.flags = 0;

tag->u.core.pagesize = 0x1000;

tag->u.core.rootdev = MKDEV(MTD_MAJOR, MTD_MINOR);

/* 16 MB of SDRAM at 0xc0000000 */ tag = tag_next(tag);

tag->hdr.tag = ATAG_MEM;

tag->hdr.size = tag_size(tag_mem32); tag->u.mem.size = DRAM1_SIZE >> 12; tag->u.mem.start = DRAM1_START;

/* an initial ramdisk image in flash at 0x00700000 */

/* tag = tag_next(tag);

tag->hdr.tag = ATAG_INITRD;

tag->hdr.size = tag_size(tag_initrd);

tag->u.initrd.start = INITRD_LOAD_ADDRESS; tag->u.initrd.size = INITRD_SIZE; */ /* the command line arguments */

/* if (argc > 1) {

tag = tag_next(tag);

tag->hdr.tag = ATAG_CMDLINE;

tag->hdr.size = (COMMAND_LINE_SIZE + 3 + sizeof(struct tag_header)) >> 2;

{

const unsigned char *src; unsigned char *dst;

dst = tag->u.cmdline.cmdline;

memzero (dst, COMMAND_LINE_SIZE); while (--argc > 0) { src = *++argv;

hprintf (\ while (*src)

*dst++ = *src++; *dst++ = ' '; }

*--dst = '\\0'; } }

*/

tag = tag_next(tag); tag->hdr.tag = 0; tag->hdr.size = 0;

/* branch to kernel image */ __asm__ volatile (

\

\ \

\ \ \

// \ );

/* never get here */ return 0; }

以下来自VIVI/lib/boot_kernel.c

static void setup_linux_param(ulong param_base) { struct param_struct *params = (struct param_struct *)param_base; char *linux_cmd; printk(\ memset(params, 0, sizeof(struct param_struct)); /* 2??à?á ??áà?? μé °íμé.. 3-μe°? °??èà?à?·? ′??? ??ào °í.. */ params->u1.s.page_size = LINUX_PAGE_SIZE; params->u1.s.nr_pages = (DRAM_SIZE >> LINUX_PAGE_SHIFT);

#if 0

#endif

params->u1.s.page_size = LINUX_PAGE_SIZE;

params->u1.s.nr_pages = (dram_size >> LINUX_PAGE_SHIFT); params->u1.s.ramdisk_size = 0; params->u1.s.rootdev = rootdev; params->u1.s.flags = 0; /* TODO */

/* If use ramdisk */ /*

params->u1.s.initrd_start = ?; params->u1.s.initrd_size = ?; params->u1.s.rd_start = ?; */

}

/* set linux command line */

linux_cmd = get_linux_cmd_line(); if (linux_cmd == NULL) { printk(\} else { memcpy(params->commandline, linux_cmd, strlen(linux_cmd) + 1); printk(\ }

附录 struct param_struct解释 asm-arm/setup.h

/* This is the old deprecated way to pass parameters to the kernel */

struct param_struct { union { struct {

unsigned long page_size; /* 0 */ unsigned long nr_pages; /* 4 */ unsigned long ramdisk_size; /* 8 */ unsigned long flags; /* 12 */ #define FLAG_READONLY 1 #define FLAG_RDLOAD 4 #define FLAG_RDPROMPT 8

unsigned long rootdev; /* 16 */ unsigned long video_num_cols; /* 20 */ unsigned long video_num_rows; /* 24 */ unsigned long video_x; /* 28 */ unsigned long video_y; /* 32 */

unsigned long memc_control_reg; /* 36 */ unsigned char sounddefault; /* 40 */ unsigned char adfsdrives; /* 41 */ unsigned char bytes_per_char_h; /* 42 */ unsigned char bytes_per_char_v; /* 43 */ unsigned long pages_in_bank[4]; /* 44 */ unsigned long pages_in_vram; /* 60 */ unsigned long initrd_start; /* 64 */ unsigned long initrd_size; /* 68 */ unsigned long rd_start; /* 72 */ unsigned long system_rev; /* 76 */ unsigned long system_serial_low; /* 80 */ unsigned long system_serial_high; /* 84 */ unsigned long mem_fclk_21285; /* 88 */ } s;

char unused[256]; } u1; union {

char paths[8][128]; struct {

unsigned long magic;

char n[1024 - sizeof(unsigned long)]; } s; } u2;

char commandline[COMMAND_LINE_SIZE]; };

Kernel initialisation parameters on ARM Linux ---------------------------------------------

The following document describes the kernel initialisation parameter structure, otherwise known as 'struct param_struct' which is used for most ARM Linux architectures.

This structure is used to pass initialisation parameters from the kernel loader to the Linux kernel proper, and may be short lived through the kernel initialisation process. As a general rule, it

should not be referenced outside of arch/arm/kernel/setup.c:setup_arch().

There are a lot of parameters listed in there, and they are described below:

page_size

This parameter must be set to the page size of the machine, and will be checked by the kernel.

nr_pages

This is the total number of pages of memory in the system. If the memory is banked, then this should contain the total number of pages in the system.

If the system contains separate VRAM, this value should not include this information.

ramdisk_size

This is now obsolete, and should not be used.

flags

Various kernel flags, including: bit 0 - 1 = mount root read only bit 1 - unused

bit 2 - 0 = load ramdisk

bit 3 - 0 = prompt for ramdisk

rootdev

major/minor number pair of device to mount as the root filesystem.

video_num_cols video_num_rows

These two together describe the character size of the dummy console, or VGA console character size. They should not be used for any other purpose.

It's generally a good idea to set these to be either standard VGA, or the equivalent character size of your fbcon display. This then allows all the bootup messages to be displayed correctly.

video_x video_y

This describes the character position of cursor on VGA console, and is otherwise unused. (should not used for other console types, and should not be used for other purposes).

memc_control_reg

MEMC chip control register for Acorn Archimedes and Acorn A5000 based machines. May be used differently by different architectures.

sounddefault

Default sound setting on Acorn machines. May be used differently by different architectures.

adfsdrives

Number of ADFS/MFM disks. May be used differently by different architectures.

bytes_per_char_h bytes_per_char_v

These are now obsolete, and should not be used.

pages_in_bank[4]

Number of pages in each bank of the systems memory (used for RiscPC). This is intended to be used on systems where the physical memory is non-contiguous from the processors point of view.

pages_in_vram

Number of pages in VRAM (used on Acorn RiscPC). This value may also be used by loaders if the size of the video RAM can't be obtained from the hardware.

initrd_start initrd_size

搜索更多关于: vivi boot loader的实现 的文档
vivi boot loader的实现.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c0pm530p7d1555jd3wydq_9.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top