main.c

来自「SMDK2440 boot code, base on vivi」· C语言 代码 · 共 211 行

C
211
字号
/** * vivi/main.c: main routine * * Copyright (C) 2001-2004 MIZI Research, Inc. All Rights Reserved. * * Author:	Janghoon Lyu * Created:	October 3, 2003 * * Last modified: $Date: 2004/03/30 04:09:48 $ *                $Revision: 1.31 $ * */#include <config.h>#include <machine.h>#include <mmu.h>#include <vmalloc.h>#include <serial.h>#include <command.h>#include <getcmd.h>#include <vstring.h>#include <mtd/mtd.h>#include <processor.h>#include <reset_handle.h>#include <types.h>#include <button.h>#include <fb_core.h>#include <param.h>/** * a wait delay for user to enter interactive mode. */#define DEFAULT_BOOT_DELAY	0x30000000	extern char *vivi_banner;extern char *vivi_ibanner;extern void console_init(void);#ifdef CONFIG_VIVI_FSextern int vfs_init(void);#endifstatic voidhang(void){	printk("System is hanged.\n");	for (;;) ;}static void vivi_shell(void){#ifdef CONFIG_SERIAL_TERM	serial_term();#else#error there is no terminal.#endif}static void run_autoboot(void){	while (1) {		exec_string("boot");		printk("Failed 'boot' command. reentering vivi shell\n");		/* if default boot fails, drop into the shell */		vivi_shell();	}}void boot_or_vivi(void){	char c;	int ret;	ulong boot_delay;	ret = get_param_ulong("boot_delay", &boot_delay);	if (ret) boot_delay = DEFAULT_BOOT_DELAY;	/* If a value of boot_delay is zero, 	 * unconditionally call vivi shell */	if (boot_delay == 0) vivi_shell();	/*	 * wait for a keystroke (or a button press if you want.)	 */	printk("Press Return to start the LINUX now, any other key for vivi\n");	c = awaitkey(boot_delay, NULL);	if (((c != '\r') && (c != '\n') && (c != '\0'))) {		printk("\n\n%s", vivi_ibanner);		printk("Enter 'help' for a list of built-in commands.\n\n");		vivi_shell();	}	run_autoboot();	return;}extern int init_irq(void);extern void net_command_regist(void);extern int mtd_part_init(void);extern int mtd_dev_init(void);/** * start-up functions for vivi */ /* * Don't disturb order. * Note: vivi always runs on the ram except head.S. */static int start_vivi(void){	/* Initialize UART for user interface */	console_init();	printk("\r\n");	printk(vivi_banner);	printk("initialize board...\n");	if (board_init())		return 1;	/*	 *   4G甫 府聪绢(linear)窍霸 概俏窍绊, 敲贰浆 皋葛府甫	 *   盔窍绰 措肺 概俏窍绊,	 *   MMU甫 难技夸.	 */	printk("initialize MMU...\n");	mem_map_init(DEFAULT_BOOT_TYPE);	mmu_init();	/* 	 * 何飘肺歹俊辑 悼利 皋葛府 且寸阑 荤侩且 荐 乐档废	 * 林狼: 寸楷捞 捞 捞傈俊绰 vmalloc() 荤侩 阂啊	 */	/* initialize the heap area */	printk("initialize memory...\n");	vmalloc_init();#ifdef CONFIG_MTD	printk("initialize MTD device...\n");	if (mtd_dev_init())		return 1;#endif	#ifdef CONFIG_VIVI_FS	printk("initialzie simple vivi file system...\n");	if (vfs_init())		return 1;#endif#ifdef CONFIG_MTD_PARTITIONS	printk("initialize MTD partitions...\n");	if (mtd_part_init())		return 1;#endif	printk("initialize vivi paramters...\n");	if (init_param())		return 1;	init_builtin_cmds();#ifdef CONFIG_CHECK_BUTTON	check_buttons();#endif#ifdef CONFIG_FB	fb_init();#endif#ifdef CONFIG_NET	net_command_regist();	#endif#ifdef CONFIG_USE_IRQ	if (init_irq()) {		printk("failed intialize IRQ sub-system.\n");	} else {		printk("enabled IRQ sub-system.\n");	}#endif	/* 林狼: 酒贰 滴 窃荐狼 困摹 官操瘤 富巴. 怖 历措肺 出笛 巴 */	/*	 * 扁鸥 固柳茄 老甸阑 秦林搁 瞪 巴 鞍促.	 * 阿 敲阀汽 喊肺 漂捞茄 老甸阑.	 */	misc();	return 0;}/** * \brief main function of vivi */int main(int argc, char *argv[]){	if (start_vivi())		hang();	boot_or_vivi();	/* 咯扁鳖瘤 坷搁 捞惑窍瘤夸. 弊犯瘤 臼唱夸? */	hang();	return 0;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?