生活随笔
收集整理的這篇文章主要介紹了
machine_desc结构体【转】
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
轉自:http://blog.csdn.net/myarrow/article/details/8609564
1. 簡介
內核提供了一個重要的結構體struct machine_desc ,這個結構體在內核移植中起到相當重要的作用,內核通過machine_desc結構體來控制系統體系架構相關部分的初始化。
?????? machine_desc結構體通過MACHINE_START宏來初始化,在代碼中, 通過在start_kernel->setup_arch中調用setup_machine_fdt來獲取。
?
2. machine_desc結構體
???????? machine_desc結構體定義如下:
?
[cpp]?view plaincopy
struct?machine_desc?{??????unsigned?int????????nr;?????????const?char??????*name;??????????unsigned?long???????boot_params;????????const?char??????**dt_compat;??????????unsigned?int????????nr_irqs;??????????unsigned?int????????video_start;????????unsigned?int????????video_end;????????unsigned?int????????reserve_lp0?:1;?????unsigned?int????????reserve_lp1?:1;?????unsigned?int????????reserve_lp2?:1;?????unsigned?int????????soft_reboot?:1;?????void????????????(*fixup)(struct?machine_desc?*,???????????????????????struct?tag?*,?char?**,???????????????????????struct?meminfo?*);??????void????????????(*reserve)(void);????void????????????(*map_io)(void);????void????????????(*init_early)(void);??????void????????????(*init_irq)(void);??????struct?sys_timer????*timer;?????????void????????????(*init_machine)(void);??#ifdef?CONFIG_MULTI_IRQ_HANDLER??????void????????????(*handle_irq)(struct?pt_regs?*);??#endif??};?? ?
?3. machine_desc初始化
machine_desc初始化例子如下:
[cpp]?view plaincopy
MACHINE_START(MA,?"myboard")??????.boot_params????=?PLAT_PHYS_OFFSET?+?0x800,??????.fixup??????=?ma_fixup,??????.reserve?????????????=?&ma_reserve,??????.map_io?????=?ma_map_io,??????.init_irq???=?ma_init_irq,??????.timer??????=?&ma_timer,??????.init_machine???=?machine_ma_board_init,??MACHINE_END?? MACHINE_START和MACHINE_END宏定義如下:
[cpp]?view plaincopy
#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?????????????\??};??
轉載于:https://www.cnblogs.com/sky-heaven/p/4837252.html
總結
以上是生活随笔為你收集整理的machine_desc结构体【转】的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。