网络设备初始化

    内核的选项解析完之后便进入各个子系统初始化函数调用阶段。kernel_init通过do_basic_setup调用do_initcalls函数完成。下面我们先来看do_initcalls的代码:

static void __init do_initcalls(void){
	initcall_t *call;
	int count = preempt_count();
	for (call = __initcall_start; call < __initcall_end; call++) {
		ktime_t t0, t1, delta;
		char *msg = NULL;
		char msgbuf[40];
		int result;
		if (initcall_debug) {
			printk("Calling initcall 0x%p", *call);
			print_fn_descriptor_symbol(": %s()",(unsigned long) *call);
			printk("\n");
			t0 = ktime_get();
		}
		result = (*call)();
		if (initcall_debug) {
			t1 = ktime_get();
			delta = ktime_sub(t1, t0);
			printk("initcall 0x%p", *call);
			print_fn_descriptor_symbol(": %s()",(unsigned long) *call);
			printk(" returned %d.\n", result);
			printk("initcall 0x%p ran for %Ld msecs: ", *call, (unsigned long long)delta.tv64 >> 20);
			print_fn_descriptor_symbol("%s()\n",(unsigned long) *call);
		}
		if (result && result != -ENODEV && initcall_debug) {
			sprintf(msgbuf, "error code %d", result);
			msg = msgbuf;
		}
		if (preempt_count() != count) {
			msg = "preemption imbalance";
			preempt_count() = count;
		}
		if (irqs_disabled()) {
			msg = "disabled interrupts";
			local_irq_enable();
		}
		if (msg) {
			printk(KERN_WARNING "initcall at 0x%p", *call);
			print_fn_descriptor_symbol(": %s()",(unsigned long) *call);
			printk(": returned with %s\n", msg);
		}
	}
	flush_scheduled_work();
}

其中通过result = (*call)();来调用call中保存的初始化函数,而被调用的函数可以异步地完成一些任务࿰

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值