U-boot下netconsole实现

U-boot下netconsole实现


参考1.函数main_loop和u-boot命令执行

上面的do-while会循环命令解析器的"命令输入解析–执行"运行模式。
其中的函数run_list执行如下的函数调用流程:run_list–>run_list_real–>run_pipe_real->cmd_process

源码跟读

# u-boot/common/main.c

void main_loop(void)
	cli_init();
	...
	s = bootdelay_process();	
	...
	autoboot_command(s);
	cli_loop();	



# u-boot/common/board_r.c	
;...
static init_fnc_t init_sequence_r[] = {
	...
	stdio_init_tables,
		INIT_LIST_HEAD(&(devs.list));
	initr_serial,
		serial_initialize();	
			serial_init();		
	...
	stdio_add_devices,
		drv_system_init ();
			...
			strcpy (dev.name, "serial");
			dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_INPUT;
			dev.putc  = stdio_serial_putc;		
		#ifdef CONFIG_NETCONSOLE
		drv_nc_init ();
			...
			strcpy(dev.name, "nc");
			dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_INPUT;
			dev.start = nc_stdio_start;
			dev.putc  = nc_stdio_putc;
	...
	run_main_loop,
		for (;;)
			main_loop();		// 进入交互终端
			


void main_loop(void)			
	cli_init();			
		#ifdef CONFIG_HUSH_PARSER		// 使用HUSH解释器
		u_boot_hush_start();
			if (top_vars == NULL) {
				top_vars = malloc(sizeof(struct variables));
				top_vars->name  = "HUSH_VERSION";			// 使用命令showvar可查看 
				top_vars->value = "0.01";		
		...
		s = bootdelay_process();
			s = env_get("bootdelay");		// 获取bootdelay信息
			bootdelay = s ? (int)simple_strtol(s, NULL, 10) : CONFIG_BOOTDELAY;

			#ifdef CONFIG_OF_CONTROL
			bootdelay = fdtdec_get_config_int(gd->fdt_blob, "bootdelay", bootdelay);			// 支持fdt中修改的bootdelay;
			...
			s = env_get("bootcmd");			// 获取默认引导命令;
			process_fdt_options(gd->fdt_blob);	// 获取:kernel-offset、rootdisk-offset信息;
			stored_bootdelay = bootdelay;	// 记录引导倒计时:bootdelay

			return s;						// 返回引导命令:bootcmd
		...
		autoboot_command(s);				// 执行引导命令:bootcmd
			if (stored_bootdelay != -1 && s && !abortboot(stored_bootdelay)) {		// 有设置bootdelay,引导命令非空,无人为打断
				run_command_list(s, -1, 0);			// 执行
				autoboot_command_fail_handle();
				
		cli_loop();							// 自动引导未正常进行后,进入命令行交互


#ifndef CONFIG_CONSOLE_DISABLE_CLI
void cli_loop(void)
	#ifdef CONFIG_HUSH_PARSER				// rk3568_defconfig, 开启
	parse_file_outer();
		struct in_str input;
		
		setup_file_in_str(&input);
			i->peek = file_peek;
			i->get  = file_get;				// 与b_getch 关联:#define b_getch(input) ((input)->get(input))
			...
		rcode = parse_stream_outer(&input, FLAG_PARSE_SEMICOLON);			// flags标记:分号
			...
			do {
				...
				rcode = parse_stream(&temp, &ctx, inp, flag & FLAG_CONT_ON_NEWLINE ? -1 : '\n');
				
				
					
					
	/* This point is never reached */	// 不应运行到此
	for (;;);
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值