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

📄 kernel_init.c

📁 操作系统试验!通过这个试验
💻 C
字号:
#include <multiboot.h>    	/* for boot_info */#include <lmm.public.h>		/* for lmm_remove_free() */#include <stdio.h>		/* for lprintf_kern() */#include <x86/seg.h>		/* for install_user_segs() */#include <x86/pic.h>      	/* for pic_init() */#include <x86/base_irq.h> 	/* for base_irq_master/slave */#include <x86/pio.h>#include <interrupts.h>#include <timer_defines.h>#include <kernel_init.h>#include <keyhelp.h>extern lmm_t malloc_lmm;		/* state for kernel memory allocation. */extern struct multiboot_info boot_info;	/* Info about system gathered by the boot loader */void kernel_init(){	/*	* Tell the kernel memory allocator which memory it can't use.	* It already knows not to touch kernel image.	*/	lmm_remove_free( &malloc_lmm, (void*)USER_MEM_START, USER_MEM_SIZE );	lmm_remove_free( &malloc_lmm, (void*)0, 0x100000 );		/*	 * init the PIC so that IRQs and exception handlers	 * don't overlap in the IDT.	 */	pic_init( BASE_IRQ_MASTER_BASE, BASE_IRQ_SLAVE_BASE );		/*	 * Install interrupt handler	 */	/* ... */	/* 	 * Programmable Interval Timer here.	 * 	 */	/* ... */}unsigned int keyboard_handler(struct trap_state *ts){	/*Your keyboard handler*/	/* ... */	return 0;}unsigned int timer_handler(struct trap_state *ts){	/* Your timer handler here*/	/* ... */	return 0;}char readchar(){	return 0;}

⌨️ 快捷键说明

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