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

📄 locore.s

📁 早期freebsd实现
💻 S
📖 第 1 页 / 共 3 页
字号:
	andl	$3,%ecx		/* any fractional bytes? */	decl	%edi	decl	%esi	rep	movsb	movl	20(%esp),%ecx	/* copy remainder by words */	shrl	$2,%ecx	subl	$3,%esi	subl	$3,%edi	rep	movsl	popl	%edi	popl	%esi	xorl	%eax,%eax	cld	ret#ifdef notdef	.globl	_copyout	ALIGN32_copyout:	movl	_curpcb, %eax	movl	$cpyflt, PCB_ONFAULT(%eax) # in case we page/protection violate	pushl	%esi	pushl	%edi	pushl	%ebx	movl	16(%esp), %esi	movl	20(%esp), %edi	movl	24(%esp), %ebx 				/* first, check to see if "write fault" */1:	movl	%edi, %eax#ifdef notyet	shrl	$IDXSHIFT, %eax	/* fetch pte associated with address */	andb	$0xfc, %al	movl	_PTmap(%eax), %eax	andb	$7, %al		/* if we are the one case that won't trap... */	cmpb	$5, %al	jne	2f				/* ... then simulate the trap! */	pushl	%edi	call	_trapwrite	/* trapwrite(addr) */	popl	%edx	cmpl	$0, %eax	/* if not ok, return */	jne	cpyflt				/* otherwise, continue with reference */2:	movl	%edi, %eax	/* calculate remainder this pass */	andl	$0xfffff000, %eax	movl	$NBPG, %ecx	subl	%eax, %ecx	cmpl	%ecx, %ebx	jle	3f	movl	%ebx, %ecx3:	subl	%ecx, %ebx	movl	%ecx, %edx#else	movl	%ebx, %ecx	movl	%ebx, %edx#endif	shrl	$2,%ecx			/* movem */	cld	rep	movsl	movl	%edx, %ecx		/* don't depend on ecx here! */	andl	$3, %ecx	rep	movsb#ifdef notyet	cmpl	$0, %ebx	jl	1b#endif	popl	%ebx	popl	%edi	popl	%esi	xorl	%eax,%eax	movl	_curpcb,%edx	movl	%eax,PCB_ONFAULT(%edx)	ret	.globl	_copyin	ALIGN32_copyin:	movl	_curpcb,%eax	movl	$cpyflt,PCB_ONFAULT(%eax) # in case we page/protection violate	pushl	%esi	pushl	%edi	pushl	%ebx	movl	12(%esp),%esi	movl	16(%esp),%edi	movl	20(%esp),%ecx	shrl	$2,%ecx	cld	rep	movsl	movl	20(%esp),%ecx	andl	$3,%ecx	rep	movsb	popl	%ebx	popl	%edi	popl	%esi	xorl	%eax,%eax	movl	_curpcb,%edx	movl	%eax,PCB_ONFAULT(%edx)	ret	ALIGN32cpyflt:	popl	%ebx	popl	%edi	popl	%esi	movl	_curpcb,%edx	movl	$0,PCB_ONFAULT(%edx)	movl	$ EFAULT,%eax	ret#else	.globl	_copyout	ALIGN32_copyout:	movl	_curpcb,%eax	movl	$cpyflt,PCB_ONFAULT(%eax) # in case we page/protection violate	pushl	%esi	pushl	%edi	movl	12(%esp),%esi	movl	16(%esp),%edi	movl	20(%esp),%ecx	shrl	$2,%ecx	cld	rep	movsl	movl	20(%esp),%ecx	andl	$3,%ecx	rep	movsb	popl	%edi	popl	%esi	xorl	%eax,%eax	movl	_curpcb,%edx	movl	%eax,PCB_ONFAULT(%edx)	ret	.globl	_copyin	ALIGN32_copyin:	movl	_curpcb,%eax	movl	$cpyflt,PCB_ONFAULT(%eax) # in case we page/protection violate	pushl	%esi	pushl	%edi	movl	12(%esp),%esi	movl	16(%esp),%edi	movl	20(%esp),%ecx	shrl	$2,%ecx	cld	rep	movsl	movl	20(%esp),%ecx	andl	$3,%ecx	rep	movsb	popl	%edi	popl	%esi	xorl	%eax,%eax	movl	_curpcb,%edx	movl	%eax,PCB_ONFAULT(%edx)	ret	ALIGN32cpyflt: popl	%edi	popl	%esi	movl	_curpcb,%edx	movl	$0,PCB_ONFAULT(%edx)	movl	$ EFAULT,%eax	ret#endif	# insb(port,addr,cnt)	.globl	_insb	ALIGN32_insb:	pushl	%edi	movw	8(%esp),%dx	movl	12(%esp),%edi	movl	16(%esp),%ecx	cld	NOP	rep	insb	NOP	movl	%edi,%eax	popl	%edi	ret	# insw(port,addr,cnt)	.globl	_insw	ALIGN32_insw:	pushl	%edi	movw	8(%esp),%dx	movl	12(%esp),%edi	movl	16(%esp),%ecx	cld	NOP	.byte 0x66,0xf2,0x6d	# rep insw	NOP	movl	%edi,%eax	popl	%edi	ret	# outsw(port,addr,cnt)	.globl	_outsw	ALIGN32_outsw:	pushl	%esi	movw	8(%esp),%dx	movl	12(%esp),%esi	movl	16(%esp),%ecx	cld	NOP	.byte 0x66,0xf2,0x6f	# rep outsw	NOP	movl	%esi,%eax	popl	%esi	ret	# outsb(port,addr,cnt)	.globl	_outsb	ALIGN32_outsb:	pushl	%esi	movw	8(%esp),%dx	movl	12(%esp),%esi	movl	16(%esp),%ecx	cld	NOP	rep	outsb	NOP	movl	%esi,%eax	popl	%esi	ret	/*	 * void lgdt(struct region_descriptor *rdp);	 */	.globl	_lgdt	ALIGN32_lgdt:	/* reload the descriptor table */	movl	4(%esp),%eax	lgdt	(%eax)	/* flush the prefetch q */	jmp	1f	nop1:	/* reload "stale" selectors */	# movw	$KDSEL,%ax	movw	$0x10,%ax	movw	%ax,%ds	movw	%ax,%es	movw	%ax,%ss	/* reload code selector by turning return into intersegmental return */	movl	0(%esp),%eax	pushl	%eax	# movl	$KCSEL,4(%esp)	movl	$8,4(%esp)	lret	/*	 * void lidt(struct region_descriptor *rdp);	 */	.globl	_lidt	ALIGN32_lidt:	movl	4(%esp),%eax	lidt	(%eax)	ret	/*	 * void lldt(u_short sel)	 */	.globl	_lldt	ALIGN32_lldt:	lldt	4(%esp)	ret	/*	 * void ltr(u_short sel)	 */	.globl	_ltr	ALIGN32_ltr:	ltr	4(%esp)	ret	/*	 * void lcr3(caddr_t cr3)	 */	.globl	_lcr3	.globl	_load_cr3	ALIGN32_load_cr3:_lcr3:	inb	$0x84,%al	# check wristwatch	movl	4(%esp),%eax 	orl	$ I386_CR3PAT,%eax	movl	%eax,%cr3	inb	$0x84,%al	# check wristwatch	ret	# tlbflush()	.globl	_tlbflush	ALIGN32_tlbflush:	inb	$0x84,%al	# check wristwatch	movl	%cr3,%eax 	orl	$ I386_CR3PAT,%eax	movl	%eax,%cr3	inb	$0x84,%al	# check wristwatch	ret	# lcr0(cr0)	.globl	_lcr0,_load_cr0	ALIGN32_lcr0:_load_cr0:	movl	4(%esp),%eax	movl	%eax,%cr0	ret	# rcr0()	.globl	_rcr0	ALIGN32_rcr0:	movl	%cr0,%eax	ret	# rcr2()	.globl	_rcr2	ALIGN32_rcr2:	movl	%cr2,%eax	ret	# rcr3()	.globl	_rcr3	.globl	__cr3	ALIGN32__cr3:_rcr3:	movl	%cr3,%eax	ret	# ssdtosd(*ssdp,*sdp)	.globl	_ssdtosd	ALIGN32_ssdtosd:	pushl	%ebx	movl	8(%esp),%ecx	movl	8(%ecx),%ebx	shll	$16,%ebx	movl	(%ecx),%edx	roll	$16,%edx	movb	%dh,%bl	movb	%dl,%bh	rorl	$8,%ebx	movl	4(%ecx),%eax	movw	%ax,%dx	andl	$0xf0000,%eax	orl	%eax,%ebx	movl	12(%esp),%ecx	movl	%edx,(%ecx)	movl	%ebx,4(%ecx)	popl	%ebx	ret/* * {fu,su},{byte,word} */	ALIGN32ALTENTRY(fuiword)ENTRY(fuword)	movl	_curpcb,%ecx	movl	$fusufault,PCB_ONFAULT(%ecx)	movl	4(%esp),%edx	.byte	0x65		# use gs	movl	0(%edx),%eax	movl	$0,PCB_ONFAULT(%ecx)	ret		ALIGN32ENTRY(fusword)	movl	_curpcb,%ecx	movl	$fusufault,PCB_ONFAULT(%ecx) #in case we page/protection violate	movl	4(%esp),%edx	.byte	0x65		# use gs	movzwl	0(%edx),%eax	movl	$0,PCB_ONFAULT(%ecx)	ret		ALIGN32ALTENTRY(fuibyte)ENTRY(fubyte)	movl	_curpcb,%ecx	movl	$fusufault,PCB_ONFAULT(%ecx) #in case we page/protection violate	movl	4(%esp),%edx	.byte	0x65		# use gs	movzbl	0(%edx),%eax	movl	$0,PCB_ONFAULT(%ecx)	ret		ALIGN32fusufault:	movl	_curpcb,%ecx	xorl	%eax,%eax	movl	%eax,PCB_ONFAULT(%ecx) #in case we page/protection violate	decl	%eax	ret	ALIGN32ALTENTRY(suiword)ENTRY(suword)	movl	_curpcb,%ecx	movl	$fusufault,PCB_ONFAULT(%ecx) #in case we page/protection violate	movl	4(%esp),%edx	movl	8(%esp),%eax#ifdef notdef	shrl	$IDXSHIFT, %edx	/* fetch pte associated with address */	andb	$0xfc, %dl	movl	_PTmap(%edx), %edx	andb	$7, %dl		/* if we are the one case that won't trap... */	cmpb	$5 , %edx	jne	1f				/* ... then simulate the trap! */	pushl	%edi	call	_trapwrite	/* trapwrite(addr) */	popl	%edx	cmpl	$0, %eax	/* if not ok, return */	jne	fusufault	movl	8(%esp),%eax	/* otherwise, continue with reference */1:	movl	4(%esp),%edx#endif	.byte	0x65		# use gs	movl	%eax,0(%edx)	xorl	%eax,%eax	movl	%eax,PCB_ONFAULT(%ecx) #in case we page/protection violate	ret		ALIGN32ENTRY(susword)	movl	_curpcb,%ecx	movl	$fusufault,PCB_ONFAULT(%ecx) #in case we page/protection violate	movl	4(%esp),%edx	movl	8(%esp),%eax#ifdef notdefshrl	$IDXSHIFT, %edx	/* calculate pte address */andb	$0xfc, %dlmovl	_PTmap(%edx), %edxandb	$7, %edx	/* if we are the one case that won't trap... */cmpb	$5 , %edxjne	1f/* ..., then simulate the trap! */	pushl	%edi	call	_trapwrite	/* trapwrite(addr) */	popl	%edxmovl	_curpcb, %ecx	# restore trashed registerscmpl	$0, %eax	/* if not ok, return */jne	fusufaultmovl	8(%esp),%eax1: movl	4(%esp),%edx#endif	.byte	0x65		# use gs	movw	%ax,0(%edx)	xorl	%eax,%eax	movl	%eax,PCB_ONFAULT(%ecx) #in case we page/protection violate	ret	ALIGN32ALTENTRY(suibyte)ENTRY(subyte)	movl	_curpcb,%ecx	movl	$fusufault,PCB_ONFAULT(%ecx) #in case we page/protection violate	movl	4(%esp),%edx	movl	8(%esp),%eax#ifdef notdefshrl	$IDXSHIFT, %edx	/* calculate pte address */andb	$0xfc, %dlmovl	_PTmap(%edx), %edxandb	$7, %edx	/* if we are the one case that won't trap... */cmpb	$5 , %edxjne	1f/* ..., then simulate the trap! */	pushl	%edi	call	_trapwrite	/* trapwrite(addr) */	popl	%edxmovl	_curpcb, %ecx	# restore trashed registerscmpl	$0, %eax	/* if not ok, return */jne	fusufaultmovl	8(%esp),%eax1: movl	4(%esp),%edx#endif	.byte	0x65		# use gs	movb	%eax,0(%edx)	xorl	%eax,%eax	movl	%eax,PCB_ONFAULT(%ecx) #in case we page/protection violate	ret	ALIGN32	ENTRY(setjmp)	movl	4(%esp),%eax	movl	%ebx, 0(%eax)		# save ebx	movl	%esp, 4(%eax)		# save esp	movl	%ebp, 8(%eax)		# save ebp	movl	%esi,12(%eax)		# save esi	movl	%edi,16(%eax)		# save edi	movl	(%esp),%edx		# get rta	movl	%edx,20(%eax)		# save eip	xorl	%eax,%eax		# return (0);	ret	ALIGN32	ENTRY(longjmp)	movl	4(%esp),%eax	movl	 0(%eax),%ebx		# restore ebx	movl	 4(%eax),%esp		# restore esp	movl	 8(%eax),%ebp		# restore ebp	movl	12(%eax),%esi		# restore esi	movl	16(%eax),%edi		# restore edi	movl	20(%eax),%edx		# get rta	movl	%edx,(%esp)		# put in return frame	xorl	%eax,%eax		# return (1);	incl	%eax	ret/* * The following primitives manipulate the run queues.  _whichqs tells which * of the 32 queues _qs have processes in them.  Setrunqueue puts processes * into queues, Remrq removes them from queues.  The running process is on * no queue, other processes are on a queue related to p->p_priority, divided * by 4 actually to shrink the 0-127 range of priorities into the 32 available * queues. */	.globl	_whichqs,_qs,_cnt,_panic	.comm	_noproc,4	.comm	_runrun,4/* * Setrq(p) * * Call should be made at spl6(), and p->p_stat should be SRUN */	ALIGN32ENTRY(setrunqueue)	movl	4(%esp),%eax	cmpl	$0,P_BACK(%eax)		# should not be on q already	je	set1	pushl	$set2	call	_panic

⌨️ 快捷键说明

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