vivi boot loader的实现

2026/1/26 4:48:19

以下代码来自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的实现.doc 将本文的Word文档下载到电脑
搜索更多关于: vivi boot loader的实现 的文档
相关推荐
相关阅读
× 游客快捷下载通道(下载后可以自由复制和排版)

下载本文档需要支付 10

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:xuecool-com QQ:370150219