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

📄 init.c

📁 jos lab3代码
💻 C
字号:
/* See COPYRIGHT for copyright information. */#include <inc/stdio.h>#include <inc/string.h>#include <inc/assert.h>#include <kern/monitor.h>#include <kern/console.h>#include <kern/pmap.h>#include <kern/kclock.h>#include <kern/env.h>#include <kern/trap.h>voidi386_init(void){	extern char edata[], end[];	// Before doing anything else, complete the ELF loading process.	// Clear the uninitialized global data (BSS) section of our program.	// This ensures that all static/global variables start out zero.	memset(edata, 0, end - edata);	// Initialize the console.	// Can't call cprintf until after we do this!	cons_init();	cprintf("6828 decimal is %o octal!\n", 6828);	// Lab 2 memory management initialization functions	i386_detect_memory();	i386_vm_init();	// Lab 3 user environment initialization functions	env_init();	idt_init();	// Temporary test code specific to LAB 3#if defined(TEST)	// Don't touch -- used by grading script!	ENV_CREATE2(TEST, TESTSIZE);#else	// Touch all you want.	ENV_CREATE(user_hello);#endif // TEST*	// We only have one user environment for now, so just run it.	env_run(&envs[0]);}/* * Variable panicstr contains argument to first call to panic; used as flag * to indicate that the kernel has already called panic. */static const char *panicstr;/* * Panic is called on unresolvable fatal errors. * It prints "panic: mesg", and then enters the kernel monitor. */void_panic(const char *file, int line, const char *fmt,...){	va_list ap;	if (panicstr)		goto dead;	panicstr = fmt;	va_start(ap, fmt);	cprintf("kernel panic at %s:%d: ", file, line);	vcprintf(fmt, ap);	cprintf("\n");	va_end(ap);dead:	/* break into the kernel monitor */	while (1)		monitor(NULL);}/* like panic, but don't */void_warn(const char *file, int line, const char *fmt,...){	va_list ap;	va_start(ap, fmt);	cprintf("kernel warning at %s:%d: ", file, line);	vcprintf(fmt, ap);	cprintf("\n");	va_end(ap);}

⌨️ 快捷键说明

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