内核中arch和proc信息

在内核启动阶段二时涉及的下面的这段代码,这里做进一步分析
.long __proc_info_begin  @存放proc_info_list结构体起始地址
.long __proc_info_end
3: .long .
.long __arch_info_begin  @存放machine_desc结构体起始地址
.long __arch_info_end

===================================================================================================
proc_info_list结构体在arch/arm/include/asm/procinfo.h定义
struct proc_info_list {
unsigned int cpu_val;
unsigned int cpu_mask;
unsigned long __cpu_mm_mmu_flags; /* used by head.S */
unsigned long __cpu_io_mmu_flags; /* used by head.S */
unsigned long __cpu_flush; /* used by head.S */
const char *arch_name;
const char *elf_name;
unsigned int elf_hwcap;
const char *cpu_name;
struct processor *proc;
struct cpu_tlb_fns *tlb;
struct cpu_user_fns *user;
struct cpu_cache_fns *cache;
};
这个结构体在哪里被使用,成员又是在哪里何时被赋予初值?????
==================================================================================================
machine_desc结构在 arch/arm/include/asm/mach/arch.h中
struct machine_desc {
/*
* Note! The first four elements are used
* by assembler code in head.S, head-common.S
*/
unsigned int nr; /* architecture number */
unsigned int phys_io; /* start of physical io */
unsigned int io_pg_offst; /* byte offset for io
* page tabe entry */
const char *name; /* architecture name */
unsigned long boot_params; /* tagged list */


unsigned int video_start; /* start of video RAM */
unsigned int video_end; /* end of video RAM */


unsigned int reserve_lp0 :1; /* never has lp0 */
unsigned int reserve_lp1 :1; /* never has lp1 */
unsigned int reserve_lp2 :1; /* never has lp2 */
unsigned int soft_reboot :1; /* soft reboot */
void (*fixup)(struct machine_desc *,
struct tag *, char **,
struct meminfo *);
void (*map_io)(void);/* IO mapping function */
void (*init_irq)(void);
struct sys_timer *timer; /* system tick timer */
void (*init_machine)(void);
};
struct machine_desc {
/*
* Note! The first four elements are used
* by assembler code in head.S, head-common.S
*/
unsigned int nr; /* architecture number */
unsigned int phys_io; /* start of physical io */
unsigned int io_pg_offst; /* byte offset for io
* page tabe entry */


const char *name; /* architecture name */
unsigned long boot_params; /* tagged list */


unsigned int video_start; /* start of video RAM */
unsigned int video_end; /* end of video RAM */


unsigned int reserve_lp0 :1; /* never has lp0 */
unsigned int reserve_lp1 :1; /* never has lp1 */
unsigned int reserve_lp2 :1; /* never has lp2 */
unsigned int soft_reboot :1; /* soft reboot */
void (*fixup)(struct machine_desc *,
struct tag *, char **,
struct meminfo *);
void (*map_io)(void);/* IO mapping function */
void (*init_irq)(void);
struct sys_timer *timer; /* system tick timer */
void (*init_machine)(void);
};
接着是两个宏定义:
#define MACHINE_START(_type,_name) \
static const struct machine_desc __mach_desc_##_type \
  __used \
  __attribute__((__section__(".arch.info.init"))) = { \
.nr = MACH_TYPE_##_type, \
.name = _name,

#define MACHINE_END \
};



由上面两个宏定义再加上两个宏调用:(在linux\arch\arm\mach-s3c2440\mach-tq2440.c)
MACHINE_START(S3C2440, "SMDK2440")
    .phys_io = S3C2410_PA_UART,
    .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
    .boot_params = S3C2410_SDRAM_PA + 0x100,


    .init_irq = s3c24xx_init_irq,
    .map_io  = smdk2440_map_io,
    .init_machine = smdk2440_machine_init,
    .timer  = &s3c24xx_timer,
MACHINE_END
将上面这个宏调用展开就可以得到S3C2440 的machine_desc结构体同时给结构体成员赋予初值
static const struct machine_desc __mach_desc_S3C2440
  __used
  __attribute__((__section__(".arch.info.init"))) =
{
    .nr  = MACH_TYPE_S3C2440,
    .name  = "SMDK2440",
    .phys_io = S3C2410_PA_UART,
    .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
    .boot_params = S3C2410_SDRAM_PA + 0x100,


    .init_irq = s3c24xx_init_irq,
    .map_io  = smdk2440_map_io,
    .init_machine = smdk2440_machine_init,
    .timer  = &s3c24xx_timer,
};
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值