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

📄 linux.c

📁 blob2.0.4.tar,Blob的源码,完整
💻 C
字号:
/* * linux.c: support functions for booting a kernel * * Copyright (C) 2001  Erik Mouw (J.A.K.Mouw@its.tudelft.nl) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA * */#ident "$Id: linux.c,v 1.3 2001/08/30 08:39:49 erikm Exp $"#ifdef HAVE_CONFIG_H# include "config.h"#endif#include "linux.h"#include "main.h"#include "flash.h"#include "memory.h"#include "serial.h"#include "util.h"#include <asm-arm/setup.h>static void setup_start_tag(void);static void setup_memory_tags(void);static void setup_commandline_tag(char *commandline);static void setup_ramdisk_tag(void);static void setup_initrd_tag(void);static void setup_end_tag(void);static struct tag *params;void boot_linux(char *commandline){	register u32 i;	void (*theKernel)(int zero, int arch) = (void (*)(int, int))KERNEL_RAM_BASE;	setup_start_tag();	setup_memory_tags();	setup_commandline_tag(commandline);  	setup_initrd_tag();	setup_ramdisk_tag();	setup_end_tag();	/* we assume that the kernel is in place */	SerialOutputString("\nStarting kernel ...\n\n");	/* turn off I-cache */	asm ("mrc p15, 0, %0, c1, c0, 0": "=r" (i));	i &= ~0x1000;	asm ("mcr p15, 0, %0, c1, c0, 0": : "r" (i));	/* flush I-cache */	asm ("mcr p15, 0, %0, c7, c5, 0": : "r" (i));	theKernel(0, ARCH_NUMBER);	SerialOutputString("Hey, the kernel returned! This should not happen.\n");}static void setup_start_tag(void){	params = (struct tag *)BOOT_PARAMS;	params->hdr.tag = ATAG_CORE;	params->hdr.size = tag_size(tag_core);	params->u.core.flags = 0;	params->u.core.pagesize = 0;	params->u.core.rootdev = 0;	params = tag_next(params);}static void setup_memory_tags(void){	int i;	for(i = 0; i < NUM_MEM_AREAS; i++) {		if(memory_map[i].used) {			params->hdr.tag = ATAG_MEM;			params->hdr.size = tag_size(tag_mem32);			params->u.mem.start = memory_map[i].start;			params->u.mem.size = memory_map[i].len;						params = tag_next(params);		}	}}static void setup_commandline_tag(char *commandline){	char *p;	/* eat leading white space */	for(p = commandline; *p == ' '; p++)		;	/* skip non-existent command lines so the kernel will still         * use its default command line.	 */	if(*p == '\0')		return;	params->hdr.tag = ATAG_CMDLINE;	params->hdr.size = (sizeof(struct tag_header) + strlen(p) + 1 + 4) >> 2;	strcpy(params->u.cmdline.cmdline, p);	params = tag_next(params);}static void setup_initrd_tag(void){	/* an ATAG_INITRD node tells the kernel where the compressed         * ramdisk can be found. ATAG_RDIMG is a better name, actually.	 */	params->hdr.tag = ATAG_INITRD;	params->hdr.size = tag_size(tag_initrd);		params->u.initrd.start = RAMDISK_RAM_BASE;	params->u.initrd.size = INITRD_LEN;		params = tag_next(params);}static void setup_ramdisk_tag(void){	/* an ATAG_RAMDISK node tells the kernel how large the         * decompressed ramdisk will become.	 */	params->hdr.tag = ATAG_RAMDISK;	params->hdr.size = tag_size(tag_ramdisk);		params->u.ramdisk.start = 0;	params->u.ramdisk.size = RAMDISK_SIZE;	params->u.ramdisk.flags = 1;	/* automatically load ramdisk */		params = tag_next(params);}static void setup_end_tag(void){	params->hdr.tag = ATAG_NONE;	params->hdr.size = 0;}

⌨️ 快捷键说明

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