⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmd_bootm.c.svn-base

📁 u-boot loader common files, like cpu, clock, environment...etc...
💻 SVN-BASE
📖 第 1 页 / 共 3 页
字号:
{	DECLARE_GLOBAL_DATA_PTR;	char buf[256], *start, *end;	char *cmdline = getenv ("bootargs");	/* Only fix cmdline when requested */	if (!(gd->flags & GD_FLG_SILENT))		return;	debug ("before silent fix-up: %s\n", cmdline);	if (cmdline) {		if ((start = strstr (cmdline, "console=")) != NULL) {			end = strchr (start, ' ');			strncpy (buf, cmdline, (start - cmdline + 8));			if (end)				strcpy (buf + (start - cmdline + 8), end);			else				buf[start - cmdline + 8] = '\0';		} else {			strcpy (buf, cmdline);			strcat (buf, " console=");		}	} else {		strcpy (buf, "console=");	}	setenv ("bootargs", buf);	debug ("after silent fix-up: %s\n", buf);}#endif /* CONFIG_SILENT_CONSOLE */#ifdef CONFIG_PPCstatic voiddo_bootm_linux (cmd_tbl_t *cmdtp, int flag,		int	argc, char *argv[],		ulong	addr,		ulong	*len_ptr,		int	verify){	DECLARE_GLOBAL_DATA_PTR;	ulong	sp;	ulong	len, checksum;	ulong	initrd_start, initrd_end;	ulong	cmd_start, cmd_end;	ulong	initrd_high;	ulong	data;	int	initrd_copy_to_ram = 1;	char    *cmdline;	char	*s;	bd_t	*kbd;	void	(*kernel)(bd_t *, ulong, ulong, ulong, ulong);	image_header_t *hdr = &header;	if ((s = getenv ("initrd_high")) != NULL) {		/* a value of "no" or a similar string will act like 0,		 * turning the "load high" feature off. This is intentional.		 */		initrd_high = simple_strtoul(s, NULL, 16);		if (initrd_high == ~0)			initrd_copy_to_ram = 0;	} else {	/* not set, no restrictions to load high */		initrd_high = ~0;	}#ifdef CONFIG_LOGBUFFER	kbd=gd->bd;	/* Prevent initrd from overwriting logbuffer */	if (initrd_high < (kbd->bi_memsize-LOGBUFF_LEN-LOGBUFF_OVERHEAD))		initrd_high = kbd->bi_memsize-LOGBUFF_LEN-LOGBUFF_OVERHEAD;	debug ("## Logbuffer at 0x%08lX ", kbd->bi_memsize-LOGBUFF_LEN);#endif	/*	 * Booting a (Linux) kernel image	 *	 * Allocate space for command line and board info - the	 * address should be as high as possible within the reach of	 * the kernel (see CFG_BOOTMAPSZ settings), but in unused	 * memory, which means far enough below the current stack	 * pointer.	 */	asm( "mr %0,1": "=r"(sp) : );	debug ("## Current stack ends at 0x%08lX ", sp);	sp -= 2048;		/* just to be sure */	if (sp > CFG_BOOTMAPSZ)		sp = CFG_BOOTMAPSZ;	sp &= ~0xF;	debug ("=> set upper limit to 0x%08lX\n", sp);	cmdline = (char *)((sp - CFG_BARGSIZE) & ~0xF);	kbd = (bd_t *)(((ulong)cmdline - sizeof(bd_t)) & ~0xF);	if ((s = getenv("bootargs")) == NULL)		s = "";	strcpy (cmdline, s);	cmd_start    = (ulong)&cmdline[0];	cmd_end      = cmd_start + strlen(cmdline);	*kbd = *(gd->bd);#ifdef	DEBUG	printf ("## cmdline at 0x%08lX ... 0x%08lX\n", cmd_start, cmd_end);	do_bdinfo (NULL, 0, 0, NULL);#endif	if ((s = getenv ("clocks_in_mhz")) != NULL) {		/* convert all clock information to MHz */		kbd->bi_intfreq /= 1000000L;		kbd->bi_busfreq /= 1000000L;#if defined(CONFIG_8260) || defined(CONFIG_MPC8560)		kbd->bi_cpmfreq /= 1000000L;		kbd->bi_brgfreq /= 1000000L;		kbd->bi_sccfreq /= 1000000L;		kbd->bi_vco     /= 1000000L;#endif /* CONFIG_8260 */#if defined(CONFIG_MPC5xxx)		kbd->bi_ipbfreq /= 1000000L;		kbd->bi_pcifreq /= 1000000L;#endif /* CONFIG_MPC5xxx */	}	kernel = (void (*)(bd_t *, ulong, ulong, ulong, ulong))hdr->ih_ep;	/*	 * Check if there is an initrd image	 */	if (argc >= 3) {		SHOW_BOOT_PROGRESS (9);		addr = simple_strtoul(argv[2], NULL, 16);		printf ("## Loading RAMDisk Image at %08lx ...\n", addr);		/* Copy header so we can blank CRC field for re-calculation */		memmove (&header, (char *)addr, sizeof(image_header_t));		if (hdr->ih_magic  != IH_MAGIC) {			puts ("Bad Magic Number\n");			SHOW_BOOT_PROGRESS (-10);			do_reset (cmdtp, flag, argc, argv);		}		data = (ulong)&header;		len  = sizeof(image_header_t);		checksum = hdr->ih_hcrc;		hdr->ih_hcrc = 0;		if (crc32 (0, (char *)data, len) != checksum) {			puts ("Bad Header Checksum\n");			SHOW_BOOT_PROGRESS (-11);			do_reset (cmdtp, flag, argc, argv);		}		SHOW_BOOT_PROGRESS (10);		print_image_hdr (hdr);		data = addr + sizeof(image_header_t);		len  = hdr->ih_size;		if (verify) {			ulong csum = 0;#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)			ulong cdata = data, edata = cdata + len;#endif	/* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */			puts ("   Verifying Checksum ... ");#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)			while (cdata < edata) {				ulong chunk = edata - cdata;				if (chunk > CHUNKSZ)					chunk = CHUNKSZ;				csum = crc32 (csum, (char *)cdata, chunk);				cdata += chunk;				WATCHDOG_RESET();			}#else	/* !(CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG) */			csum = crc32 (0, (char *)data, len);#endif	/* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */			if (csum != hdr->ih_dcrc) {				puts ("Bad Data CRC\n");				SHOW_BOOT_PROGRESS (-12);				do_reset (cmdtp, flag, argc, argv);			}			puts ("OK\n");		}		SHOW_BOOT_PROGRESS (11);		if ((hdr->ih_os   != IH_OS_LINUX)	||		    (hdr->ih_arch != IH_CPU_PPC)	||		    (hdr->ih_type != IH_TYPE_RAMDISK)	) {			puts ("No Linux PPC Ramdisk Image\n");			SHOW_BOOT_PROGRESS (-13);			do_reset (cmdtp, flag, argc, argv);		}		/*		 * Now check if we have a multifile image		 */	} else if ((hdr->ih_type==IH_TYPE_MULTI) && (len_ptr[1])) {		u_long tail    = ntohl(len_ptr[0]) % 4;		int i;		SHOW_BOOT_PROGRESS (13);		/* skip kernel length and terminator */		data = (ulong)(&len_ptr[2]);		/* skip any additional image length fields */		for (i=1; len_ptr[i]; ++i)			data += 4;		/* add kernel length, and align */		data += ntohl(len_ptr[0]);		if (tail) {			data += 4 - tail;		}		len   = ntohl(len_ptr[1]);	} else {		/*		 * no initrd image		 */		SHOW_BOOT_PROGRESS (14);		len = data = 0;	}	if (!data) {		debug ("No initrd\n");	}	if (data) {	    if (!initrd_copy_to_ram) {	/* zero-copy ramdisk support */		initrd_start = data;		initrd_end = initrd_start + len;	    } else {		initrd_start  = (ulong)kbd - len;		initrd_start &= ~(4096 - 1);	/* align on page */		if (initrd_high) {			ulong nsp;			/*			 * the inital ramdisk does not need to be within			 * CFG_BOOTMAPSZ as it is not accessed until after			 * the mm system is initialised.			 *			 * do the stack bottom calculation again and see if			 * the initrd will fit just below the monitor stack			 * bottom without overwriting the area allocated			 * above for command line args and board info.			 */			asm( "mr %0,1": "=r"(nsp) : );			nsp -= 2048;		/* just to be sure */			nsp &= ~0xF;			if (nsp > initrd_high)	/* limit as specified */				nsp = initrd_high;			nsp -= len;			nsp &= ~(4096 - 1);	/* align on page */			if (nsp >= sp)				initrd_start = nsp;		}		SHOW_BOOT_PROGRESS (12);		debug ("## initrd at 0x%08lX ... 0x%08lX (len=%ld=0x%lX)\n",			data, data + len - 1, len, len);		initrd_end    = initrd_start + len;		printf ("   Loading Ramdisk to %08lx, end %08lx ... ",			initrd_start, initrd_end);#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)		{			size_t l = len;			void *to = (void *)initrd_start;			void *from = (void *)data;			while (l > 0) {				size_t tail = (l > CHUNKSZ) ? CHUNKSZ : l;				WATCHDOG_RESET();				memmove (to, from, tail);				to += tail;				from += tail;				l -= tail;			}		}#else	/* !(CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG) */		memmove ((void *)initrd_start, (void *)data, len);#endif	/* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */		puts ("OK\n");	    }	} else {		initrd_start = 0;		initrd_end = 0;	}	debug ("## Transferring control to Linux (at address %08lx) ...\n",		(ulong)kernel);	SHOW_BOOT_PROGRESS (15);#if defined(CFG_INIT_RAM_LOCK) && !defined(CONFIG_E500)	unlock_ram_in_cache();#endif	/*	 * Linux Kernel Parameters:	 *   r3: ptr to board info data	 *   r4: initrd_start or 0 if no initrd	 *   r5: initrd_end - unused if r4 is 0	 *   r6: Start of command line string	 *   r7: End   of command line string	 */	(*kernel) (kbd, initrd_start, initrd_end, cmd_start, cmd_end);}#endif /* CONFIG_PPC */static voiddo_bootm_netbsd (cmd_tbl_t *cmdtp, int flag,		int	argc, char *argv[],		ulong	addr,		ulong	*len_ptr,		int	verify){	DECLARE_GLOBAL_DATA_PTR;	image_header_t *hdr = &header;	void	(*loader)(bd_t *, image_header_t *, char *, char *);	image_header_t *img_addr;	char     *consdev;	char     *cmdline;	/*	 * Booting a (NetBSD) kernel image	 *	 * This process is pretty similar to a standalone application:	 * The (first part of an multi-) image must be a stage-2 loader,	 * which in turn is responsible for loading & invoking the actual	 * kernel.  The only differences are the parameters being passed:	 * besides the board info strucure, the loader expects a command	 * line, the name of the console device, and (optionally) the	 * address of the original image header.	 */	img_addr = 0;	if ((hdr->ih_type==IH_TYPE_MULTI) && (len_ptr[1]))		img_addr = (image_header_t *) addr;	consdev = "";#if   defined (CONFIG_8xx_CONS_SMC1)	consdev = "smc1";#elif defined (CONFIG_8xx_CONS_SMC2)	consdev = "smc2";#elif defined (CONFIG_8xx_CONS_SCC2)	consdev = "scc2";#elif defined (CONFIG_8xx_CONS_SCC3)	consdev = "scc3";#endif	if (argc > 2) {		ulong len;		int   i;		for (i=2, len=0 ; i<argc ; i+=1)			len += strlen (argv[i]) + 1;		cmdline = malloc (len);		for (i=2, len=0 ; i<argc ; i+=1) {			if (i > 2)				cmdline[len++] = ' ';			strcpy (&cmdline[len], argv[i]);			len += strlen (argv[i]);		}	} else if ((cmdline = getenv("bootargs")) == NULL) {		cmdline = "";	}	loader = (void (*)(bd_t *, image_header_t *, char *, char *)) hdr->ih_ep;	printf ("## Transferring control to NetBSD stage-2 loader (at address %08lx) ...\n",		(ulong)loader);	SHOW_BOOT_PROGRESS (15);	/*	 * NetBSD Stage-2 Loader Parameters:	 *   r3: ptr to board info data	 *   r4: image address	 *   r5: console device	 *   r6: boot args string	 */	(*loader) (gd->bd, img_addr, consdev, cmdline);}#if defined(CONFIG_ARTOS) && defined(CONFIG_PPC)/* Function that returns a character from the environment */extern uchar (*env_get_char)(int);static voiddo_bootm_artos (cmd_tbl_t *cmdtp, int flag,		int	argc, char *argv[],		ulong	addr,		ulong	*len_ptr,		int	verify){	DECLARE_GLOBAL_DATA_PTR;	ulong top;	char *s, *cmdline;	char **fwenv, **ss;	int i, j, nxt, len, envno, envsz;	bd_t *kbd;	void (*entry)(bd_t *bd, char *cmdline, char **fwenv, ulong top);	image_header_t *hdr = &header;	/*	 * Booting an ARTOS kernel image + application	 */	/* this used to be the top of memory, but was wrong... */#ifdef CONFIG_PPC	/* get stack pointer */	asm volatile ("mr %0,1" : "=r"(top) );#endif	debug ("## Current stack ends at 0x%08lX ", top);	top -= 2048;		/* just to be sure */	if (top > CFG_BOOTMAPSZ)		top = CFG_BOOTMAPSZ;	top &= ~0xF;	debug ("=> set upper limit to 0x%08lX\n", top);	/* first check the artos specific boot args, then the linux args*/	if ((s = getenv("abootargs")) == NULL && (s = getenv("bootargs")) == NULL)		s = "";	/* get length of cmdline, and place it */

⌨️ 快捷键说明

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