時(shí)間:2015/6/28來(lái)源:IT貓撲網(wǎng)作者:網(wǎng)管聯(lián)盟我要評(píng)論(0)
start_kernel() -> setup_arch(&command_line) -> mdesc = setup_machine(machine_arch_type) -> list = lookup_machine_type(nr) -> return struct machine_desc.
內(nèi)核在啟動(dòng)的時(shí)候就是最先運(yùn)行start_kernel() , 然后她就會(huì)調(diào)用體系結(jié)構(gòu)相關(guān)的setup_arch(&command_line), 如arm體系結(jié)構(gòu)的在arch/arm/kernel/setup.c中, 進(jìn)一步, 她就要初始化板級(jí)相關(guān)的設(shè)備, 但在此之前, 她必須找到這塊目標(biāo)板的描述結(jié)構(gòu), 所以她就先通過(guò)lookup_machine_type(nr)來(lái)查找這個(gè)結(jié)構(gòu), 傳入的參數(shù)是又uboot傳過(guò)來(lái)的, 存儲(chǔ)在r2中. 如假設(shè)她傳入的是'SMDK2410' 的nr, lookup_machine_type(nr) 就會(huì)找到如下的machine_desc. 這個(gè)結(jié)構(gòu)在一個(gè)專門描述sddk2410的文件中--arch/arm/mach-s3c2410/mach-smdk2410.c
MACHINE_START(SMDK2410, "SMDK2410") /* @TODO: request a new identifier and switch
* to SMDK2410 */
/* Maintainer: Jonas Dietsche */
.phys_io = S3C2410_PA_UART,
.io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
.boot_params = S3C2410_SDRAM_PA + 0x100,
//重要的板級(jí)初始化函數(shù)
.map_io = smdk2410_map_io,
.init_irq = s3c24xx_init_irq,
.init_machine = smdk2410_init,
.timer = &s3c24xx_timer,
MACHINE_END
MACHINE_START的第一個(gè)參數(shù)是用來(lái)構(gòu)造機(jī)器的類型的, 如這里的SMDK2410 ,
又下面的定義
.nr = MACH_TYPE_##_type
有 nr = MACH_TYPE_SMDK2410
而 MACH_TYPE_SMDK2410這些機(jī)器類型則在/include/asm-arm/mach-types.h中定義:
#define MACH_TYPE_SMDK2410 193
完整的結(jié)構(gòu)描述如下:
struct machine_desc {
/*
* Note! The first four elements are used
* by assembler code in head-armv.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);
};
/*
* Set of macros to define architecture features. This is built into
* a table by the linker.
*/
#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 \
};
在arch/arm/mach-s3c2410/mach-smdk2410.c 定義了以下兩個(gè)函數(shù)實(shí)現(xiàn):
static struct map_desc smdk2410_iodesc[] __initdata = {
/* nothing here yet */
};
static struct platform_device *smdk2410_devices[] __initdata = {
&s3c_device_usb,
&s3c_device_lcd,
&s3c_device_wdt,
&s3c_device_i2c,
&s3c_device_iis,
};
static void __init smdk2410_map_io(void)
{
//主要是做外圍設(shè)備的物理地址到虛擬地址的映射
s3c24xx_init_io(smdk2410_iodesc, ARRAY_SIZE(smdk2410_iodesc));
//頻率的初始化
s3c24xx_init_clocks(0);
//串口的初始化
s3c24xx_init_uarts(smdk2410_uartcfgs, ARRAY_SIZE(smdk2410_uartcfgs));
}
static void __init smdk2410_init(void)
{
//注冊(cè)smdk2410特有的設(shè)備
platform_add_devices(smdk2410_devices, ARRAY_SIZE(smdk2410_devices));
//smdk系列的初始化, 我們知道smdk有2410, 2412, 2440等等, 所以這里她又抽象出了一些共有的相同的部分, 都使用下面的函數(shù)做初始化工作.
smdk_machine_init();
}
/* devices we initialise */
static struct platform_device __initdata *smdk_devs[] = {
&s3c_device_nand,
&smdk_led4,
&smdk_led5,
&smdk_led6,
&smdk_led7,
};
void __init smdk_machine_init(void)
{
/* Configure the LEDs (even if we have no LED support)*/
s3c2410_gpio_cfgpin(S3C2410_GPF4, S3C2410_GPF4_OUTP);
s3c2410_gpio_cfgpin(S3C2410_GPF5, S3C2410_GPF5_OUTP);
s3c2410_gpio_cfgpin(S3C2410_GPF6, S3C2410_GPF6_OUTP);
s3c2410_gpio_cfgpin(S3C2410_GPF7, S3C2410_GPF7_OUTP);
s3c2410_gpio_setpin(S3C2410_GPF4, 1);
s3c2410_gpio_setpin(S3C2410_GPF5, 1);
s3c2410_gpio_setpin(S3C2410_GPF6, 1);
s3c2410_gpio_setpin(S3C2410_GPF7, 1);
if (machine_is_smdk2443())
smdk_nand_info.twrph0 = 50;
//注意這一行, 注冊(cè)了nand Flash的分區(qū)信息
s3c_device_nand.dev.platform_data = &smdk_nand_info;
//再一次注冊(cè)設(shè)備, 但這一次是smdk共有的. 如nand flash等等
platform_add_devices(smdk_devs, ARRAY_SIZE(smdk_devs));
//電源管理的初始化
s3c2410_pm_init();
}
關(guān)鍵詞標(biāo)簽:linux,板級(jí)設(shè)備
相關(guān)閱讀
熱門文章 安裝紅帽子RedHat Linux9.0操作系統(tǒng)教程使用screen管理你的遠(yuǎn)程會(huì)話GNU/Linux安裝vmware如何登錄linux vps圖形界面 Linux遠(yuǎn)程桌面連
人氣排行 Linux下獲取CPUID、硬盤序列號(hào)與MAC地址linux tc實(shí)現(xiàn)ip流量限制dmidecode命令查看內(nèi)存型號(hào)linux下解壓rar文件安裝紅帽子RedHat Linux9.0操作系統(tǒng)教程Ubuntu linux 關(guān)機(jī)、重啟、注銷 命令lcx.exe、nc.exe、sc.exe入侵中的使用方法查看linux服務(wù)器硬盤IO讀寫負(fù)載