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

📄 entry.s

📁 jos lab3代码
💻 S
字号:
/* See COPYRIGHT for copyright information. */#include <inc/mmu.h>#include <inc/memlayout.h>#include <inc/trap.h># Shift Right Logical #define SRL(val, shamt)		(((val) >> (shamt)) & ~(-1 << (32 - (shamt))))#################################################################### The kernel (this code) is linked at address ~(KERNBASE + 1 Meg), # but the bootloader loads it at address ~1 Meg.#	# RELOC(x) maps a symbol x from its link address to its actual# location in physical memory (its load address).	 ####################################################################define	RELOC(x) ((x) - KERNBASE).set CODE_SEL,0x8		# index of code seg within mygdt.set DATA_SEL,0x10		# index of data seg within mygdt#define MULTIBOOT_PAGE_ALIGN  (1<<0)#define MULTIBOOT_MEMORY_INFO (1<<1)#define MULTIBOOT_HEADER_MAGIC (0x1BADB002)#define MULTIBOOT_HEADER_FLAGS (MULTIBOOT_MEMORY_INFO | MULTIBOOT_PAGE_ALIGN)#define CHECKSUM (-(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS))#################################################################### entry point###################################################################.text# The Multiboot header.align 4.long MULTIBOOT_HEADER_MAGIC.long MULTIBOOT_HEADER_FLAGS.long CHECKSUM.globl		_start_start:	movw	$0x1234,0x472			# warm boot	# Establish our own GDT in place of the boot loader's temporary GDT.	lgdt	RELOC(mygdtdesc)		# load descriptor table	# Immediately reload all segment registers (including CS!)	# with segment selectors from the new GDT.	movl	$DATA_SEL, %eax			# Data segment selector	movw	%ax,%ds				# -> DS: Data Segment	movw	%ax,%es				# -> ES: Extra Segment	movw	%ax,%ss				# -> SS: Stack Segment	ljmp	$CODE_SEL,$relocated		# reload CS by jumpingrelocated:	# Clear the frame pointer register (EBP)	# so that once we get into debugging C code,	# stack backtraces will be terminated properly.	movl	$0x0,%ebp			# nuke frame pointer        # Leave a few words on the stack for the user trap frame	movl	$(bootstacktop-SIZEOF_STRUCT_TRAPFRAME),%esp	# now to C code	call	i386_init	# Should never get here, but in case we do, just spin.spin:	jmp	spin###################################################################	# See <inc/memlayout.h> for a complete description of these two symbols.###################################################################.data	.globl	vpt	.set	vpt, VPT	.globl	vpd	.set	vpd, (VPT + SRL(VPT, 10))#################################################################### boot stack###################################################################	.p2align	PGSHIFT		# force page alignment	.globl		bootstackbootstack:	.space		KSTKSIZE	.globl		bootstacktop   bootstacktop:#################################################################### setup the GDT	###################################################################	.p2align	2		# force 4 byte alignmentmygdt:	SEG_NULL				# null seg	SEG(STA_X|STA_R, -KERNBASE, 0xffffffff)	# code seg	SEG(STA_W, -KERNBASE, 0xffffffff)	# data segmygdtdesc:	.word	0x17			# sizeof(mygdt) - 1	.long	RELOC(mygdt)		# address mygdt

⌨️ 快捷键说明

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