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

📄 head.s

📁 ARM 嵌入式 系统 设计与实例开发 实验教材 二源码
💻 S
📖 第 1 页 / 共 2 页
字号:
/* $Id: head.S,v 1.86 2001/12/05 01:02:16 davem Exp $ * head.S: Initial boot code for the Sparc64 port of Linux. * * Copyright (C) 1996,1997 David S. Miller (davem@caip.rutgers.edu) * Copyright (C) 1996 David Sitsky (David.Sitsky@anu.edu.au) * Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz) * Copyright (C) 1997 Miguel de Icaza (miguel@nuclecu.unam.mx) */#include <linux/config.h>#include <linux/version.h>#include <linux/errno.h>#include <asm/asm_offsets.h>#include <asm/asi.h>#include <asm/pstate.h>#include <asm/ptrace.h>#include <asm/spitfire.h>#include <asm/page.h>#include <asm/pgtable.h>#include <asm/errno.h>#include <asm/signal.h>#include <asm/processor.h>#include <asm/lsu.h>#include <asm/dcr.h>#include <asm/dcu.h>#include <asm/head.h>#include <asm/ttable.h>	/* This section from from _start to sparc64_boot_end should fit into * 0x0000.0000.0040.4000 to 0x0000.0000.0040.8000 and will be sharing space * with bootup_user_stack, which is from 0x0000.0000.0040.4000 to * 0x0000.0000.0040.6000 and empty_bad_page, which is from * 0x0000.0000.0040.6000 to 0x0000.0000.0040.8000.  */	.text	.globl	start, _start, stext, _stext_start:start:_stext:stext:bootup_user_stack:! 0x0000000000404000	b	sparc64_boot	 flushw					/* Flush register file.      *//* This stuff has to be in sync with SILO and other potential boot loaders * Fields should be kept upward compatible and whenever any change is made, * HdrS version should be incremented. */        .global root_flags, ram_flags, root_dev        .global sparc_ramdisk_image, sparc_ramdisk_size	.globl	silo_args        .ascii  "HdrS"        .word   LINUX_VERSION_CODE        .half   0x0203          /* HdrS version */root_flags:        .half   1root_dev:        .half   0ram_flags:        .half   0sparc_ramdisk_image:        .word   0sparc_ramdisk_size:        .word   0        .xword  reboot_command	.xword	bootstr_len	.word	_end	/* We must be careful, 32-bit OpenBOOT will get confused if it	 * tries to save away a register window to a 64-bit kernel	 * stack address.  Flush all windows, disable interrupts,	 * remap if necessary, jump onto kernel trap table, then kernel	 * stack, or else we die.	 *	 * PROM entry point is on %o4	 */sparc64_boot:	rdpr	%ver, %g1	sethi	%hi(0x003e0014), %g5	srlx	%g1, 32, %g1	or	%g5, %lo(0x003e0014), %g5	cmp	%g1, %g5	bne,pt	%icc, spitfire_boot	 nopcheetah_boot:	mov	DCR_BPE | DCR_RPE | DCR_SI | DCR_IFPOE | DCR_MS, %g1	wr	%g1, %asr18	sethi	%uhi(DCU_ME | DCU_RE | /*DCU_PE |*/ DCU_HPE | DCU_SPE | DCU_SL | DCU_WE), %g5	or	%g5, %ulo(DCU_ME | DCU_RE | /*DCU_PE |*/ DCU_HPE | DCU_SPE | DCU_SL | DCU_WE), %g5	sllx	%g5, 32, %g5	or	%g5, DCU_DM | DCU_IM | DCU_DC | DCU_IC, %g5	stxa	%g5, [%g0] ASI_DCU_CONTROL_REG	membar	#Sync	mov	TSB_EXTENSION_P, %g3	stxa	%g0, [%g3] ASI_DMMU	stxa	%g0, [%g3] ASI_IMMU	membar	#Sync	mov	TSB_EXTENSION_S, %g3	stxa	%g0, [%g3] ASI_DMMU	membar	#Sync	mov	TSB_EXTENSION_N, %g3	stxa	%g0, [%g3] ASI_DMMU	stxa	%g0, [%g3] ASI_IMMU	membar	#Sync	wrpr    %g0, (PSTATE_PRIV|PSTATE_PEF|PSTATE_IE), %pstate	wr	%g0, 0, %fprs	/* Just like for Spitfire, we probe itlb-2 for a mapping which	 * matches our current %pc.  We take the physical address in	 * that mapping and use it to make our own.	 */	/* %g5 holds the tlb data */        sethi   %uhi(_PAGE_VALID | _PAGE_SZ4MB), %g5        sllx    %g5, 32, %g5        or      %g5, (_PAGE_CP | _PAGE_CV | _PAGE_P | _PAGE_L | _PAGE_W | _PAGE_G), %g5	/* Put PADDR tlb data mask into %g3. */	sethi	%uhi(_PAGE_PADDR), %g3	or	%g3, %ulo(_PAGE_PADDR), %g3	sllx	%g3, 32, %g3	sethi	%hi(_PAGE_PADDR), %g7	or	%g7, %lo(_PAGE_PADDR), %g7	or	%g3, %g7, %g3	set	2 << 16, %l0		/* TLB entry walker. */	set	0x1fff, %l2		/* Page mask. */	rd	%pc, %l3	andn	%l3, %l2, %g2		/* vaddr comparator */1:	ldxa	[%l0] ASI_ITLB_TAG_READ, %g1	membar	#Sync	andn	%g1, %l2, %g1	cmp	%g1, %g2	be,pn	%xcc, cheetah_got_tlbentry	 nop	and	%l0, (127 << 3), %g1	cmp	%g1, (127 << 3)	blu,pt	%xcc, 1b	 add	%l0, (1 << 3), %l0cheetah_got_tlbentry:	ldxa	[%l0] ASI_ITLB_DATA_ACCESS, %g1	membar	#Sync	and	%g1, %g3, %g1	sub	%g1, %g2, %g1	or	%g5, %g1, %g5	/* Clear out any KERNBASE area entries. */	set	2 << 16, %l0	sethi	%hi(KERNBASE), %g3	sethi	%hi(KERNBASE<<1), %g7	mov	TLB_TAG_ACCESS, %l7	/* First, check ITLB */1:	ldxa	[%l0] ASI_ITLB_TAG_READ, %g1	membar	#Sync	andn	%g1, %l2, %g1	cmp	%g1, %g3	blu,pn	%xcc, 2f	 cmp	%g1, %g7	bgeu,pn	%xcc, 2f	 nop	stxa	%g0, [%l7] ASI_IMMU	membar	#Sync	stxa	%g0, [%l0] ASI_ITLB_DATA_ACCESS	membar	#Sync2:	and	%l0, (127 << 3), %g1	cmp	%g1, (127 << 3)	blu,pt	%xcc, 1b	 add	%l0, (1 << 3), %l0	/* Next, check DTLB */	set	2 << 16, %l01:	ldxa	[%l0] ASI_DTLB_TAG_READ, %g1	membar	#Sync	andn	%g1, %l2, %g1	cmp	%g1, %g3	blu,pn	%xcc, 2f	 cmp	%g1, %g7	bgeu,pn	%xcc, 2f	 nop	stxa	%g0, [%l7] ASI_DMMU	membar	#Sync	stxa	%g0, [%l0] ASI_DTLB_DATA_ACCESS	membar	#Sync	2:	and	%l0, (511 << 3), %g1	cmp	%g1, (511 << 3)	blu,pt	%xcc, 1b	 add	%l0, (1 << 3), %l0	/* Now lock the TTE we created into ITLB-0 and DTLB-0,	 * entry 15 (and maybe 14 too).	 */	sethi	%hi(KERNBASE), %g3	set	(0 << 16) | (15 << 3), %g7	stxa	%g3, [%l7] ASI_DMMU	membar	#Sync	stxa	%g5, [%g7] ASI_DTLB_DATA_ACCESS	membar	#Sync	stxa	%g3, [%l7] ASI_IMMU	membar	#Sync	stxa	%g5, [%g7] ASI_ITLB_DATA_ACCESS	membar	#Sync	flush	%g3	membar	#Sync	sethi	%hi(_end), %g3			/* Check for bigkernel case */	or	%g3, %lo(_end), %g3	srl	%g3, 23, %g3			/* Check if _end > 8M */	brz,pt	%g3, 1f	 sethi	%hi(KERNBASE), %g3		/* Restore for fixup code below */	sethi	%hi(0x400000), %g3	or	%g3, %lo(0x400000), %g3	add	%g5, %g3, %g5			/* New tte data */	andn	%g5, (_PAGE_G), %g5	sethi	%hi(KERNBASE+0x400000), %g3	or	%g3, %lo(KERNBASE+0x400000), %g3	set	(0 << 16) | (14 << 3), %g7	stxa	%g3, [%l7] ASI_DMMU	membar	#Sync	stxa	%g5, [%g7] ASI_DTLB_DATA_ACCESS	membar	#Sync	stxa	%g3, [%l7] ASI_IMMU	membar	#Sync	stxa	%g5, [%g7] ASI_ITLB_DATA_ACCESS	membar	#Sync	flush	%g3	membar	#Sync	sethi	%hi(KERNBASE), %g3		/* Restore for fixup code below */	ba,pt	%xcc, 1f	 nop1:	set	sun4u_init, %g2	jmpl    %g2 + %g0, %g0	 nopspitfire_boot:	/* Typically PROM has already enabled both MMU's and both on-chip	 * caches, but we do it here anyway just to be paranoid.	 */	mov	(LSU_CONTROL_IC|LSU_CONTROL_DC|LSU_CONTROL_IM|LSU_CONTROL_DM), %g1	stxa	%g1, [%g0] ASI_LSU_CONTROL	membar	#Sync	/*	 * Make sure we are in privileged mode, have address masking,         * using the ordinary globals and have enabled floating         * point.	 *	 * Again, typically PROM has left %pil at 13 or similar, and	 * (PSTATE_PRIV | PSTATE_PEF | PSTATE_IE) in %pstate.         */	wrpr    %g0, (PSTATE_PRIV|PSTATE_PEF|PSTATE_IE), %pstate	wr	%g0, 0, %fprsspitfire_create_mappings:	/* %g5 holds the tlb data */        sethi   %uhi(_PAGE_VALID | _PAGE_SZ4MB), %g5        sllx    %g5, 32, %g5        or      %g5, (_PAGE_CP | _PAGE_CV | _PAGE_P | _PAGE_L | _PAGE_W | _PAGE_G), %g5	/* Base of physical memory cannot reliably be assumed to be	 * at 0x0!  Figure out where it happens to be. -DaveM	 */	/* Put PADDR tlb data mask into %g3. */	sethi	%uhi(_PAGE_PADDR_SF), %g3	or	%g3, %ulo(_PAGE_PADDR_SF), %g3	sllx	%g3, 32, %g3	sethi	%hi(_PAGE_PADDR_SF), %g7	or	%g7, %lo(_PAGE_PADDR_SF), %g7	or	%g3, %g7, %g3	/* Walk through entire ITLB, looking for entry which maps	 * our %pc currently, stick PADDR from there into %g5 tlb data.	 */	clr	%l0			/* TLB entry walker. */	set	0x1fff, %l2		/* Page mask. */	rd	%pc, %l3	andn	%l3, %l2, %g2		/* vaddr comparator */1:	/* Yes, the nops seem to be necessary for now, don't ask me why. -DaveM */	ldxa	[%l0] ASI_ITLB_TAG_READ, %g1	nop	nop	nop	andn	%g1, %l2, %g1		/* Get vaddr */	cmp	%g1, %g2	be,a,pn	%xcc, spitfire_got_tlbentry	 ldxa	[%l0] ASI_ITLB_DATA_ACCESS, %g1	cmp	%l0, (63 << 3)	blu,pt	%xcc, 1b	 add	%l0, (1 << 3), %l0spitfire_got_tlbentry:	/* Nops here again, perhaps Cheetah/Blackbird are better behaved... */	nop	nop	nop	and	%g1, %g3, %g1		/* Mask to just get paddr bits.       */	sub	%g1, %g2, %g1		/* Get rid of %pc offset to get base. */	/* NOTE: We hold on to %g1 paddr base as we need it below to lock	 * NOTE: the PROM cif code into the TLB.	 */	or	%g5, %g1, %g5		/* Or it into TAG being built.        */	clr	%l0			/* TLB entry walker. */	sethi	%hi(KERNBASE), %g3	/* 4M lower limit */	sethi	%hi(KERNBASE<<1), %g7	/* 8M upper limit */	mov	TLB_TAG_ACCESS, %l71:	/* Yes, the nops seem to be necessary for now, don't ask me why. -DaveM */	ldxa	[%l0] ASI_ITLB_TAG_READ, %g1	nop	nop	nop	andn	%g1, %l2, %g1		/* Get vaddr */	cmp	%g1, %g3	blu,pn	%xcc, 2f	 cmp	%g1, %g7	bgeu,pn	%xcc, 2f	 nop	stxa	%g0, [%l7] ASI_IMMU	stxa	%g0, [%l0] ASI_ITLB_DATA_ACCESS	membar	#Sync2:	cmp	%l0, (63 << 3)	blu,pt	%xcc, 1b	 add	%l0, (1 << 3), %l0	nop; nop; nop	clr	%l0			/* TLB entry walker. */1:	/* Yes, the nops seem to be necessary for now, don't ask me why. -DaveM */	ldxa	[%l0] ASI_DTLB_TAG_READ, %g1	nop	nop	nop	andn	%g1, %l2, %g1		/* Get vaddr */	cmp	%g1, %g3	blu,pn	%xcc, 2f	 cmp	%g1, %g7	bgeu,pn	%xcc, 2f	 nop	stxa	%g0, [%l7] ASI_DMMU	stxa	%g0, [%l0] ASI_DTLB_DATA_ACCESS	membar	#Sync2:	cmp	%l0, (63 << 3)	blu,pt	%xcc, 1b	 add	%l0, (1 << 3), %l0

⌨️ 快捷键说明

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