linux 内核 函数

linux 内核 函数,第1张

像这样全部大写的一般应该是个宏定义。在mips_machine.h中:

/*

 *  Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>

 *

 *  This program is free software you can redistribute it and/or modify it

 *  under the terms of the GNU General Public License version 2 as published

 *  by the Free Software Foundation.

 *

 */

#ifndef __ASM_MIPS_MACHINE_H

#define __ASM_MIPS_MACHINE_H

#include <linux/init.h>

#include <linux/stddef.h>

#include <asm/bootinfo.h>

struct mips_machine {

    unsigned long        mach_type

    const char        *mach_id

    const char        *mach_name

    void            (*mach_setup)(void)

}

#define MIPS_MACHINE(_type, _id, _name, _setup)            \

static const char machine_name_##_type[] __initconst        \

            __aligned(1) = _name            \

static const char machine_id_##_type[] __initconst        \

            __aligned(1) = _id            \

static struct mips_machine machine_##_type            \

        __used __section(.mips.machines.init) =        \

{                                \

    .mach_type    = _type,                \

    .mach_id    = machine_id_##_type,            \

    .mach_name    = machine_name_##_type,            \

    .mach_setup    = _setup,                \

}

extern long __mips_machines_start

extern long __mips_machines_end

#ifdef CONFIG_MIPS_MACHINE

int  mips_machtype_setup(char *id) __init

void mips_machine_setup(void) __init

#else

static inline int mips_machtype_setup(char *id) { return 1 }

static inline void mips_machine_setup(void) { }

#endif /* CONFIG_MIPS_MACHINE */

#endif /* __ASM_MIPS_MACHINE_H */

“linux内核不是在lookup_machine_type的时候应经选好开发板的吗”

我明白你的疑问,但是这边还不能这么说,mach-smdk2410.c能否被编译是取决于arch/arm/mach下面的kconfig和makefile的。也就是你的linux内核配置,说白了就是取决于你。

lookup_machine_type,不会为你选择什么开发板,他只能帮你检查你的配置是否和uboot传来的参数匹配

当lookup_machine_type时候会把uboot传进来的r1的值也就是你的mach-type号与mach-smdk2410.c中的MACHINE_START(xxx, "xxx")进行对比(这里我说的比价通俗,这个过程其实涉及到一些arch.info.init段和lookup_machine_type汇编我就不讲了),二者匹配就ok,不匹配说明你传错mach-type或者在linux配置的时候选错的开发板。

我就是搞arm linux BSP架构的。 :)


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/7104545.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-01
下一篇2023-04-01

发表评论

登录后才能评论

评论列表(0条)

    保存