在u-boot的,kernel_entry指向哪个函数? [英] In u-boot, kernel_entry points to which function?

查看:1936
本文介绍了在u-boot的,kernel_entry指向哪个函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是从U-Boot的功能:

This is the function from u-boot:

static void boot_jump_linux(bootm_headers_t *images, int flag)
{
#ifdef CONFIG_ARM64
void (*kernel_entry)(void *fdt_addr);
int fake = (flag & BOOTM_STATE_OS_FAKE_GO);

kernel_entry = (void (*)(void *fdt_addr))images->ep;

debug("## Transferring control to Linux (at address %lx)...\n",
(ulong) kernel_entry);
bootstage_mark(BOOTSTAGE_ID_RUN_OS);

announce_and_cleanup(fake);

if (!fake)
kernel_entry(images->ft_addr);
#else
unsigned long machid = gd->bd->bi_arch_number;
char *s;
void (*kernel_entry)(int zero, int arch, uint params);
unsigned long r2;
int fake = (flag & BOOTM_STATE_OS_FAKE_GO);

kernel_entry = (void (*)(int, int, uint))images->ep;

s = getenv("machid");
if (s) {
strict_strtoul(s, 16, &machid);
printf("Using machid 0x%lx from environment\n", machid);
}

debug("## Transferring control to Linux (at address %08lx)" \
"...\n", (ulong) kernel_entry);
bootstage_mark(BOOTSTAGE_ID_RUN_OS);
announce_and_cleanup(fake);

if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len)
r2 = (unsigned long)images->ft_addr;
else
r2 = gd->bd->bi_boot_params;

if (!fake)
kernel_entry(0, machid, r2);
#endif
}

我从相关的问题理解:<一href=\"http://stackoverflow.com/questions/24409821/trying-to-understand-the-usage-of-function-pointer\">Trying理解函数指针认为的使用 kernel_entry 是一个指向 功能。有人可以帮助我了解那里的函数定义?我甚至不知道这个函数的名字,所以我没能的grep 它。

I understood from the related question: Trying to understand the usage of function pointer that kernel_entryis a pointer to a function. Can someone help me understand where that function is defined? I don't even know the name of this function so I failed to grepit.

注意:整个U-Boot的源$ C ​​$ c是的此处

NOTE: The entire u-boot source code is here.

推荐答案

确实 kernel_entry 是一个函数指针。它是从一块名为图像传递的数据,类型 EP 字段初始化> bootm_header_t 。那定义结构包含/ image.h的。这是一个可启动的映像头的定义,即内核映像包含基本信息的标题,以从引导装载程序引导的形象。显然,要启动它,你需要一个程序入口点,定期C程序的主要功能类似。

Indeed kernel_entry is a function pointer. It is initialized from the ep field of the piece of data passed in called images, of type bootm_header_t. The definition of that struct is in include/image.h. This is the definition of a bootable image header, ie the header of a kernel image which contain the basic info to boot that image from the boot loader. Obviously, to start it, you need a program entry point, similarly to the main function in regular C programs.

在该结构中,入口点被简单地定义为一个内存地址(无符号长),其中code你投上市到该函数指针。

In that structure, the entry point is simply defined as a memory address (unsigned long), which the code you listed cast into that function pointer.

这结构从装载磁盘上的图像文件,它的位置由引导加载已知的第一块获得

That structure as been obtained from loading the first blocks of the image file on disk, whose location is known already by the boot loader.

因此​​,通过该函数指针指向实际code属于一个不同的二进制,和函数的定义必须位于一个不同的源$ C ​​$ C。对于linux内核,这个切入点是一个汇编手codeD功能,它的源代码在的head.S 。此功能是高度依赖拱,你会发现这个名字的许多文件实施它进行的跨内核树。

Hence the actual code pointed by that function pointer belongs to a different binary, and the definition of the function must be located in a different source code. For a linux kernel, this entry point is an assembly hand coded function, whose source is in head.S. This function being highly arch dependent, you will find many files of that name implementing it accross the kernel tree.

这篇关于在u-boot的,kernel_entry指向哪个函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆