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

📄 entry.s

📁 讲述linux的初始化过程
💻 S
📖 第 1 页 / 共 3 页
字号:
	ld	[%curptr + AOFF_task_ptrace], %l5	andcc	%l5, 0x02, %g0	be	1f	 nop	call	C_LABEL(syscall_trace)	 nop1:	/* We are returning to a signal handler. */	RESTORE_ALL	.align	4	.globl	C_LABEL(sys_rt_sigsuspend)C_LABEL(sys_rt_sigsuspend):	/* Note: %o0, %o1 already have correct value... */	call	C_LABEL(do_rt_sigsuspend)	 add	%sp, REGWIN_SZ, %o2	ld	[%curptr + AOFF_task_ptrace], %l5	andcc	%l5, 0x02, %g0	be	1f	 nop	call	C_LABEL(syscall_trace)	 nop1:	/* We are returning to a signal handler. */	RESTORE_ALL	.align	4	.globl	C_LABEL(sys_sigreturn)C_LABEL(sys_sigreturn):	call	C_LABEL(do_sigreturn)	 add	%sp, REGWIN_SZ, %o0	ld	[%curptr + AOFF_task_ptrace], %l5	andcc	%l5, 0x02, %g0	be	1f	 nop	call	C_LABEL(syscall_trace)	 nop1:	/* We don't want to muck with user registers like a	 * normal syscall, just return.	 */	RESTORE_ALL	.align	4	.globl	C_LABEL(sys_rt_sigreturn)C_LABEL(sys_rt_sigreturn):	call	C_LABEL(do_rt_sigreturn)	 add	%sp, REGWIN_SZ, %o0	ld	[%curptr + AOFF_task_ptrace], %l5	andcc	%l5, 0x02, %g0	be	1f	 nop	call	C_LABEL(syscall_trace)	 nop1:	/* We are returning to a signal handler. */	RESTORE_ALL	/* Now that we have a real sys_clone, sys_fork() is	 * implemented in terms of it.  Our _real_ implementation	 * of SunOS vfork() will use sys_vfork().	 *	 * XXX These three should be consolidated into mostly shared	 * XXX code just like on sparc64... -DaveM	 */	.align	4	.globl	C_LABEL(sys_fork), flush_patch_twoC_LABEL(sys_fork):	mov	%o7, %l5flush_patch_two:	FLUSH_ALL_KERNEL_WINDOWS;	rd	%psr, %g4	WRITE_PAUSE	mov	SIGCHLD, %o0			! arg0:	clone flags	rd	%wim, %g5	WRITE_PAUSE	mov	%fp, %o1			! arg1:	usp	std	%g4, [%curptr + AOFF_task_thread + AOFF_thread_fork_kpsr]	add	%sp, REGWIN_SZ, %o2		! arg2:	pt_regs ptr	mov	0, %o3	call	C_LABEL(do_fork)	 mov	%l5, %o7		/* Whee, kernel threads! */	.globl	C_LABEL(sys_clone), flush_patch_threeC_LABEL(sys_clone):	mov	%o7, %l5flush_patch_three:	FLUSH_ALL_KERNEL_WINDOWS;	rd	%psr, %g4	WRITE_PAUSE	/* arg0,1: flags,usp  -- loaded already */	cmp	%o1, 0x0			! Is new_usp NULL?	rd	%wim, %g5	WRITE_PAUSE	be,a	1f	 mov	%fp, %o1			! yes, use callers usp	andn	%o1, 7, %o1			! no, align to 8 bytes1:	std	%g4, [%curptr + AOFF_task_thread + AOFF_thread_fork_kpsr]	add	%sp, REGWIN_SZ, %o2		! arg2:	pt_regs ptr	mov	0, %o3	call	C_LABEL(do_fork)	 mov	%l5, %o7	/* Whee, real vfork! */	.globl	C_LABEL(sys_vfork), flush_patch_fourC_LABEL(sys_vfork):flush_patch_four:	FLUSH_ALL_KERNEL_WINDOWS;	rd	%psr, %g4	WRITE_PAUSE	rd	%wim, %g5	WRITE_PAUSE	std	%g4, [%curptr + AOFF_task_thread + AOFF_thread_fork_kpsr]	sethi	%hi(0x4000 | 0x0100 | SIGCHLD), %o0	mov	%fp, %o1	or	%o0, %lo(0x4000 | 0x0100 | SIGCHLD), %o0	sethi	%hi(C_LABEL(do_fork)), %l1	mov	0, %o3	jmpl	%l1 + %lo(C_LABEL(do_fork)), %g0	 add	%sp, REGWIN_SZ, %o2        .align  4linux_sparc_ni_syscall:	sethi   %hi(C_LABEL(sys_ni_syscall)), %l7	b       syscall_is_too_hard	 or     %l7, %lo(C_LABEL(sys_ni_syscall)), %l7linux_fast_syscall:	andn	%l7, 3, %l7	mov	%i0, %o0	mov	%i1, %o1	mov 	%i2, %o2	jmpl	%l7 + %g0, %g0	 mov	%i3, %o3linux_syscall_trace:	call	C_LABEL(syscall_trace)	 nop	mov	%i0, %o0	mov	%i1, %o1	mov	%i2, %o2	mov	%i3, %o3	b	2f	 mov	%i4, %o4	.globl	C_LABEL(ret_from_syscall)C_LABEL(ret_from_syscall):	b	C_LABEL(ret_sys_call)	 ld	[%sp + REGWIN_SZ + PT_I0], %o0#ifdef CONFIG_SMP	.globl	C_LABEL(ret_from_smpfork)C_LABEL(ret_from_smpfork):	wr	%l0, PSR_ET, %psr	WRITE_PAUSE	call	schedule_tail	 mov	%g3, %o0	b	C_LABEL(ret_sys_call)	 ld	[%sp + REGWIN_SZ + PT_I0], %o0#endif	/* Linux native and SunOS system calls enter here... */	.align	4	.globl	linux_sparc_syscalllinux_sparc_syscall:	/* Direct access to user regs, must faster. */	cmp	%g1, NR_SYSCALLS	bgeu	linux_sparc_ni_syscall	 sll	%g1, 2, %l4	ld	[%l7 + %l4], %l7	andcc	%l7, 1, %g0	bne	linux_fast_syscall	 /* Just do first insn from SAVE_ALL in the delay slot */	.globl	syscall_is_too_hardsyscall_is_too_hard:	SAVE_ALL_HEAD	 rd	%wim, %l3	wr	%l0, PSR_ET, %psr	mov	%i0, %o0	mov	%i1, %o1	mov	%i2, %o2	ld	[%curptr + AOFF_task_ptrace], %l5	mov	%i3, %o3	andcc	%l5, 0x02, %g0	mov	%i4, %o4	bne	linux_syscall_trace	 mov	%i0, %l52:	call	%l7	 mov	%i5, %o5	st	%o0, [%sp + REGWIN_SZ + PT_I0]	.globl	C_LABEL(ret_sys_call)C_LABEL(ret_sys_call):	ld	[%curptr + AOFF_task_ptrace], %l6	cmp	%o0, -ENOIOCTLCMD	ld	[%sp + REGWIN_SZ + PT_PSR], %g3	set	PSR_C, %g2	bgeu	1f	 andcc	%l6, 0x02, %l6		/* System call success, clear Carry condition code. */	andn	%g3, %g2, %g3	clr	%l6	st	%g3, [%sp + REGWIN_SZ + PT_PSR]		bne	linux_syscall_trace2	 ld	[%sp + REGWIN_SZ + PT_NPC], %l1 /* pc = npc */	add	%l1, 0x4, %l2			/* npc = npc+4 */	st	%l1, [%sp + REGWIN_SZ + PT_PC]	b	ret_trap_entry	 st	%l2, [%sp + REGWIN_SZ + PT_NPC]1:	/* System call failure, set Carry condition code.	 * Also, get abs(errno) to return to the process.	 */	sub	%g0, %o0, %o0	or	%g3, %g2, %g3	st	%o0, [%sp + REGWIN_SZ + PT_I0]	mov	1, %l6	st	%g3, [%sp + REGWIN_SZ + PT_PSR]	bne	linux_syscall_trace2	 ld	[%sp + REGWIN_SZ + PT_NPC], %l1 /* pc = npc */	add	%l1, 0x4, %l2			/* npc = npc+4 */	st	%l1, [%sp + REGWIN_SZ + PT_PC]	b	ret_trap_entry	 st	%l2, [%sp + REGWIN_SZ + PT_NPC]linux_syscall_trace2:	call	C_LABEL(syscall_trace)	 add	%l1, 0x4, %l2			/* npc = npc+4 */	st	%l1, [%sp + REGWIN_SZ + PT_PC]	b	ret_trap_entry	 st	%l2, [%sp + REGWIN_SZ + PT_NPC]	/*	 * Solaris system calls and indirect system calls enter here.         *	 * I have named the solaris indirect syscalls like that because	 * it seems like Solaris has some fast path syscalls that can	 * be handled as indirect system calls. - mig	 */linux_syscall_for_solaris:	sethi	%hi(sys_call_table), %l7	b	linux_sparc_syscall	 or	%l7, %lo(sys_call_table), %l7		.align	4	.globl	solaris_syscallsolaris_syscall:	cmp	%g1,59	be	linux_syscall_for_solaris	 cmp	%g1,2	be	linux_syscall_for_solaris	 cmp    %g1,42	be      linux_syscall_for_solaris	 cmp	%g1,119	be,a	linux_syscall_for_solaris	 mov	2, %g11:		SAVE_ALL_HEAD	 rd	%wim, %l3	wr	%l0, PSR_ET, %psr	nop	nop	mov	%i0, %l5	call	C_LABEL(do_solaris_syscall)	 add	%sp, REGWIN_SZ, %o0	st	%o0, [%sp + REGWIN_SZ + PT_I0]	set	PSR_C, %g2	cmp	%o0, -ENOIOCTLCMD	bgeu	1f	 ld	[%sp + REGWIN_SZ + PT_PSR], %g3	/* System call success, clear Carry condition code. */			andn	%g3, %g2, %g3	clr	%l6	b	2f	 st	%g3, [%sp + REGWIN_SZ + PT_PSR]	1:	/* System call failure, set Carry condition code.	 * Also, get abs(errno) to return to the process.	 */	sub	%g0, %o0, %o0	mov	1, %l6	st	%o0, [%sp + REGWIN_SZ + PT_I0]	or	%g3, %g2, %g3	st	%g3, [%sp + REGWIN_SZ + PT_PSR]	/* Advance the pc and npc over the trap instruction.	 * If the npc is unaligned (has a 1 in the lower byte), it means	 * the kernel does not want us to play magic (ie, skipping over	 * traps).  Mainly when the Solaris code wants to set some PC and	 * nPC (setcontext).	 */2:	ld	[%sp + REGWIN_SZ + PT_NPC], %l1	/* pc  = npc   */	andcc	%l1, 1, %g0	bne	1f	 add	%l1, 0x4, %l2			/* npc = npc+4 */	st	%l1, [%sp + REGWIN_SZ + PT_PC]	b	ret_trap_entry	 st	%l2, [%sp + REGWIN_SZ + PT_NPC]	/* kernel knows what it is doing, fixup npc and continue */1:	sub	%l1, 1, %l1 	b	ret_trap_entry		 st	%l1, [%sp + REGWIN_SZ + PT_NPC]#ifndef CONFIG_SUNOS_EMUL	.align	4	.globl	sunos_syscallsunos_syscall:	SAVE_ALL_HEAD	 rd	%wim, %l3	wr	%l0, PSR_ET, %psr	nop	nop	mov	%i0, %l5	call	C_LABEL(do_sunos_syscall)	 add	%sp, REGWIN_SZ, %o0#endif	/* {net, open}bsd system calls enter here... */	.align	4	.globl	bsd_syscallbsd_syscall:	/* Direct access to user regs, must faster. */	cmp	%g1, NR_SYSCALLS	blu,a	1f	 sll	%g1, 2, %l4	set	C_LABEL(sys_ni_syscall), %l7	b	bsd_is_too_hard	 nop1:	ld	[%l7 + %l4], %l7	.globl	bsd_is_too_hardbsd_is_too_hard:	rd	%wim, %l3	SAVE_ALL	wr	%l0, PSR_ET, %psr	WRITE_PAUSE2:	mov	%i0, %o0	mov	%i1, %o1	mov	%i2, %o2	mov	%i0, %l5	mov	%i3, %o3	mov	%i4, %o4	call	%l7	 mov	%i5, %o5	st	%o0, [%sp + REGWIN_SZ + PT_I0]	set	PSR_C, %g2	cmp	%o0, -ENOIOCTLCMD	bgeu	1f	 ld	[%sp + REGWIN_SZ + PT_PSR], %g3	/* System call success, clear Carry condition code. */			andn	%g3, %g2, %g3	clr	%l6	b	2f	 st	%g3, [%sp + REGWIN_SZ + PT_PSR]	1:	/* System call failure, set Carry condition code.	 * Also, get abs(errno) to return to the process.	 */	sub	%g0, %o0, %o0#if 0 /* XXX todo XXX */	sethi	%hi(C_LABEL(bsd_xlatb_rorl), %o3	or	%o3, %lo(C_LABEL(bsd_xlatb_rorl)), %o3	sll	%o0, 2, %o0	ld	[%o3 + %o0], %o0#endif	mov	1, %l6	st	%o0, [%sp + REGWIN_SZ + PT_I0]	or	%g3, %g2, %g3	st	%g3, [%sp + REGWIN_SZ + PT_PSR]	/* Advance the pc and npc over the trap instruction. */2:	ld	[%sp + REGWIN_SZ + PT_NPC], %l1	/* pc  = npc   */	add	%l1, 0x4, %l2			/* npc = npc+4 */	st	%l1, [%sp + REGWIN_SZ + PT_PC]	b	ret_trap_entry	 st	%l2, [%sp + REGWIN_SZ + PT_NPC]/* Saving and restoring the FPU state is best done from lowlevel code. * * void fpsave(unsigned long *fpregs, unsigned long *fsr, *             void *fpqueue, unsigned long *fpqdepth) */	.globl	C_LABEL(fpsave)C_LABEL(fpsave):	st	%fsr, [%o1]	! this can trap on us if fpu is in bogon state	ld	[%o1], %g1	set	0x2000, %g4	andcc	%g1, %g4, %g0	be	2f	 mov	0, %g2	/* We have an fpqueue to save. */1:	std	%fq, [%o2]fpsave_magic:	st	%fsr, [%o1]	ld	[%o1], %g3	andcc	%g3, %g4, %g0	add	%g2, 1, %g2	bne	1b	 add	%o2, 8, %o22:	st	%g2, [%o3]	std	%f0, [%o0 + 0x00]	std	%f2, [%o0 + 0x08]	std	%f4, [%o0 + 0x10]	std	%f6, [%o0 + 0x18]	std	%f8, [%o0 + 0x20]	std	%f10, [%o0 + 0x28]	std	%f12, [%o0 + 0x30]	std	%f14, [%o0 + 0x38]	std	%f16, [%o0 + 0x40]	std	%f18, [%o0 + 0x48]	std	%f20, [%o0 + 0x50]	std	%f22, [%o0 + 0x58]	std	%f24, [%o0 + 0x60]	std	%f26, [%o0 + 0x68]	std	%f28, [%o0 + 0x70]	retl	 std	%f30, [%o0 + 0x78]	/* Thanks for Theo Deraadt and the authors of the Sprite/netbsd/openbsd	 * code for pointing out this possible deadlock, while we save state	 * above we could trap on the fsr store so our low level fpu trap	 * code has to know how to deal with this.	 */fpsave_catch:	b	fpsave_magic + 4	 st	%fsr, [%o1]fpsave_catch2:	b	C_LABEL(fpsave) + 4	 st	%fsr, [%o1]	/* void fpload(unsigned long *fpregs, unsigned long *fsr); */	.globl	C_LABEL(fpload)C_LABEL(fpload):	ldd	[%o0 + 0x00], %f0	ldd	[%o0 + 0x08], %f2	ldd	[%o0 + 0x10], %f4	ldd	[%o0 + 0x18], %f6	ldd	[%o0 + 0x20], %f8	ldd	[%o0 + 0x28], %f10	ldd	[%o0 + 0x30], %f12	ldd	[%o0 + 0x38], %f14	ldd	[%o0 + 0x40], %f16	ldd	[%o0 + 0x48], %f18	ldd	[%o0 + 0x50], %f20	ldd	[%o0 + 0x58], %f22	ldd	[%o0 + 0x60], %f24	ldd	[%o0 + 0x68], %f26	ldd	[%o0 + 0x70], %f28	ldd	[%o0 + 0x78], %f30	ld	[%o1], %fsr	retl	 nop	.globl	C_LABEL(udelay)C_LABEL(udelay):	save	%sp, -REGWIN_SZ, %sp	mov	%i0, %o0	sethi	%hi(0x10c6), %o1	call	.umul	 or	%o1, %lo(0x10c6), %o1#ifndef CONFIG_SMP	sethi	%hi(C_LABEL(loops_per_jiffy)), %o3	call	.umul	 ld	[%o3 + %lo(C_LABEL(loops_per_jiffy))], %o1#else	GET_PROCESSOR_OFFSET(o4, o2)	set	C_LABEL(cpu_data), %o3	call	.umul	 ld	[%o3 + %o4], %o1#endif	call	.umul	 mov	100, %o0	cmp	%o0, 0x01:	bne	1b	 subcc	%o0, 1, %o0		ret	restore	/* Handle a software breakpoint */	/* We have to inform parent that child has stopped */	.align 4	.globl breakpoint_trapbreakpoint_trap:	rd	%wim,%l3	SAVE_ALL	wr 	%l0, PSR_ET, %psr	WRITE_PAUSE	st	%i0, [%sp + REGWIN_SZ + PT_G0] ! for restarting syscalls	call	C_LABEL(sparc_breakpoint)	 add	%sp, REGWIN_SZ, %o0	RESTORE_ALL	.align	4	.globl	C_LABEL(__handle_exception), flush_patch_exceptionC_LABEL(__handle_exception):flush_patch_exception:	FLUSH_ALL_KERNEL_WINDOWS;	ldd	[%o0], %o6	jmpl	%o7 + 0xc, %g0			! see asm-sparc/processor.h	 mov	1, %g1				! signal EFAULT condition	.align	4	.globl	C_LABEL(kill_user_windows), kuw_patch1_7win	.globl	kuw_patch1kuw_patch1_7win:	sll	%o3, 6, %o3	/* No matter how much overhead this routine has in the worst	 * case scenerio, it is several times better than taking the	 * traps with the old method of just doing flush_user_windows().	 */C_LABEL(kill_user_windows):	ld	[%g6 + AOFF_task_thread + AOFF_thread_uwinmask], %o0	! get current umask	orcc	%g0, %o0, %g0			! if no bits set, we are done	be	3f				! nothing to do	 rd	%psr, %o5			! must clear interrupts	or	%o5, PSR_PIL, %o4		! or else that could change	wr	%o4, 0x0, %psr			! the uwinmask state	WRITE_PAUSE				! burn them cycles1:	ld	[%g6 + AOFF_task_thread + AOFF_thread_uwinmask], %o0	! get consistant state	orcc	%g0, %o0, %g0			! did an interrupt come in?	be	4f				! yep, we are done	 rd	%wim, %o3			! get current wim	srl	%o3, 1, %o4			! simulate a savekuw_patch1:	sll	%o3, 7, %o3			! compute next wim	or	%o4, %o3, %o3			! result	andncc	%o0, %o3, %o0			! clean this bit in umask	bne	kuw_patch1			! not done yet	 srl	%o3, 1, %o4			! begin another save simulation	wr	%o3, 0x0, %wim			! set the new wim	st	%g0, [%g6 + AOFF_task_thread + AOFF_thread_uwinmask]	! clear uwinmask4:	wr	%o5, 0x0, %psr			! re-enable interrupts	WRITE_PAUSE				! burn baby burn3:	retl					! return	 st	%g0, [%g6 + AOFF_task_thread + AOFF_thread_w_saved]	! no windows saved	.align	4	.globl	C_LABEL(restore_current)C_LABEL(restore_current):	LOAD_CURRENT(g6, o0)	retl	 nop#ifdef CONFIG_PCI#include <asm/pcic.h>	.align	4	.globl	linux_trap_ipi15_pciclinux_trap_ipi15_pcic:	rd	%wim, %l3	SAVE_ALL	/*	 * First deactivate NMI	 * or we cannot drop ET, cannot get window spill traps.	 * The busy loop is necessary because the PIO error	 * sometimes does not go away quickly and we trap again.	 */	sethi	%hi(C_LABEL(pcic_regs)), %o1	ld	[%o1 + %lo(C_LABEL(pcic_regs))], %o2	! Get pending status for printouts later.	ld	[%o2 + PCI_SYS_INT_PENDING], %o0	mov	PCI_SYS_INT_PENDING_CLEAR_ALL, %o1	stb	%o1, [%o2 + PCI_SYS_INT_PENDING_CLEAR]1:	ld	[%o2 + PCI_SYS_INT_PENDING], %o1	andcc	%o1, ((PCI_SYS_INT_PENDING_PIO|PCI_SYS_INT_PENDING_PCI)>>24), %g0	bne	1b	 nop	or	%l0, PSR_PIL, %l4	wr	%l4, 0x0, %psr	WRITE_PAUSE	wr	%l4, PSR_ET, %psr	WRITE_PAUSE	call	C_LABEL(pcic_nmi)	 add	%sp, REGWIN_SZ, %o1	! struct pt_regs *regs	RESTORE_ALL	.globl	C_LABEL(pcic_nmi_trap_patch)C_LABEL(pcic_nmi_trap_patch):	sethi	%hi(linux_trap_ipi15_pcic), %l3	jmpl	%l3 + %lo(linux_trap_ipi15_pcic), %g0	 rd	%psr, %l0	.word	0#endif /* CONFIG_PCI *//* End of entry.S */

⌨️ 快捷键说明

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