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

📄 sysalib.s

📁 开发环境Tornado2.2 For Pentium
💻 S
📖 第 1 页 / 共 2 页
字号:
*     int port;		/@ I/O port address @/*     short *address;	/@ address of data written to the port @/*     int count;	/@ count @/ */	.balign 16,0x90FUNC_LABEL(sysOutWordString)	pushl	%esi	movl	SP_ARG1+4(%esp),%edx	movl	SP_ARG2+4(%esp),%esi	movl	SP_ARG3+4(%esp),%ecx	cld	rep	outsw	(%esi),%dx	movl	%esi,%eax	popl	%esi	ret/********************************************************************************* sysOutLongString - output long string to I/O space** RETURNS: N/A* void sysOutLongString (port, address, count)*     int port;		/@ I/O port address @/*     long *address;	/@ address of data written to the port @/*     int count;	/@ count @/ */	.balign 16,0x90FUNC_LABEL(sysOutLongString)	pushl	%esi	movl	SP_ARG1+4(%esp),%edx	movl	SP_ARG2+4(%esp),%esi	movl	SP_ARG3+4(%esp),%ecx	cld	rep	outsl	(%esi),%dx	movl	%esi,%eax	popl	%esi	ret/********************************************************************************* sysWait - wait until the input buffer become empty** wait until the input buffer become empty** RETURNS: N/A* void sysWait (void) */	.balign 16,0x90FUNC_LABEL(sysWait)	xorl	%ecx,%ecxsysWait0:	movl	$0x64,%edx		/* Check if it is ready to write */	inb	%dx,%al	andb	$2,%al	loopnz	sysWait0	ret/********************************************************************************* sysReboot - warm start** RETURNS: N/A** NOMANUAL* void sysReboot () */	.balign 16,0x90FUNC_LABEL(sysReboot)	movl	$0,%eax	lgdt	(%eax)			/* crash the global descriptor table */	ret/********************************************************************************* sysCpuProbe - perform CPUID if supported and check a type of CPU FAMILY** This routine performs CPUID if supported and check a type of CPU FAMILY.* This routine is called only once in cacheArchLibInit().  If it is* called later, it returns the previously obtained result.** RETURNS: a type of CPU FAMILY; 0(386), 1(486), 2(P5/Pentium), *	   4(P6/PentiumPro) or 5(P7/Pentium4).** UINT sysCpuProbe (void)*/        .balign 16,0x90FUNC_LABEL(sysCpuProbe)	cmpl	$ NONE, FUNC(sysProcessor) /* is it executed already? */	je	sysCpuProbeStart	/*   no: start the CPU probing */	movl	FUNC(sysProcessor), %eax /* return the sysProcessor */	retsysCpuProbeStart:	pushfl				/* save EFLAGS */        cli				/* LOCK INTERRUPT */	/* check 386. AC bit is a new bit for 486, 386 can not toggle */	pushfl				/* push EFLAGS */	popl	%edx			/* pop EFLAGS on EDX */	movl	%edx, %ecx		/* save original EFLAGS to ECX */	xorl	$ EFLAGS_AC, %edx	/* toggle AC bit */	pushl	%edx			/* push new EFLAGS */	popfl				/* set new EFLAGS */	pushfl				/* push EFLAGS */	popl	%edx			/* pop EFLAGS on EDX */	xorl	%edx, %ecx		/* if AC bit is toggled ? */        jz	sysCpuProbe386		/*   no: it is 386 */	pushl	%ecx			/* push original EFLAGS */	popfl				/* restore original EFLAGS */	/* check 486. ID bit is a new bit for Pentium, 486 can not toggle */	pushfl				/* push EFLAGS */	popl	%edx			/* pop EFLAGS on EDX */	movl	%edx, %ecx		/* save original EFLAGS to ECX */	xorl	$ EFLAGS_ID, %edx	/* toggle ID bit */	pushl	%edx			/* push new EFLAGS */	popfl				/* set new EFLAGS */	pushfl				/* push EFLAGS */	popl	%edx			/* pop EFLAGS on EDX */	xorl	%edx, %ecx		/* if ID bit is toggled ? */	jz	sysCpuProbe486		/*   no: it is 486 */	/* execute CPUID to get vendor, family, model, stepping, features */	pushl	%ebx			/* save EBX */	movl	$ CPUID_486, FUNC(sysCpuId)+CPUID_SIGNATURE /* set it 486 */	/* EAX=0, get the highest value and the vendor ID */	movl	$0, %eax		/* set EAX 0 */	cpuid				/* execute CPUID */	movl	%eax, FUNC(sysCpuId)+CPUID_HIGHVALUE	/* save high value */	movl	%ebx, FUNC(sysCpuId)+CPUID_VENDORID	/* save vendor id[0] */	movl	%edx, FUNC(sysCpuId)+CPUID_VENDORID+4	/* save vendor id[1] */	movl	%ecx, FUNC(sysCpuId)+CPUID_VENDORID+8	/* save vendor id[2] */	cmpl	$1, %eax				/* is CPUID(1) ok? */	jl	sysCpuProbeEnd				/*   no: end probe */	/* EAX=1, get the processor signature and feature flags */	movl	$1, %eax		/* set EAX 1 */	cpuid				/* execute CPUID */	movl	%eax, FUNC(sysCpuId)+CPUID_SIGNATURE	/* save signature */	movl	%edx, FUNC(sysCpuId)+CPUID_FEATURES_EDX	/* save feature EDX */	movl	%ecx, FUNC(sysCpuId)+CPUID_FEATURES_ECX	/* save feature ECX */	movl	%ebx, FUNC(sysCpuId)+CPUID_FEATURES_EBX	/* save feature EBX */	cmpl	$2, FUNC(sysCpuId)+CPUID_HIGHVALUE	/* is CPUID(2) ok? */	jl	sysCpuProbeEnd				/*   no: end probe */	/* EAX=2, get the configuration parameters */	movl	$2, %eax		/* set EAX 2 */	cpuid				/* execute CPUID */	movl	%eax, FUNC(sysCpuId)+CPUID_CACHE_EAX	/* save config EAX */	movl	%ebx, FUNC(sysCpuId)+CPUID_CACHE_EBX	/* save config EBX */	movl	%ecx, FUNC(sysCpuId)+CPUID_CACHE_ECX	/* save config ECX */	movl	%edx, FUNC(sysCpuId)+CPUID_CACHE_EDX	/* save config EDX */	cmpl	$3, FUNC(sysCpuId)+CPUID_HIGHVALUE	/* is CPUID(3) ok? */	jl	sysCpuProbeEnd				/*   no: end probe */		/* EAX=3, get the processor serial no */	movl	$3, %eax		/* set EAX 3 */	cpuid				/* execute CPUID */	movl	%edx, FUNC(sysCpuId)+CPUID_SERIALNO	/* save serialno[2] */	movl	%ecx, FUNC(sysCpuId)+CPUID_SERIALNO+4	/* save serialno[3] */	/* EAX=0x80000000, to see if the Brand String is supported */	movl	$0x80000000, %eax	/* set EAX 0x80000000 */	cpuid				/* execute CPUID */	cmpl	$0x80000000, %eax	/* is Brand String supported? */	jbe	sysCpuProbeEnd		/*   no: end probe */	/* EAX=0x8000000[234], get the Brand String */	movl	$0x80000002, %eax	/* set EAX 0x80000002 */	cpuid				/* execute CPUID */	movl	%eax, FUNC(sysCpuId)+CPUID_BRAND_STR	/* save brandStr[0] */	movl	%ebx, FUNC(sysCpuId)+CPUID_BRAND_STR+4	/* save brandStr[1] */	movl	%ecx, FUNC(sysCpuId)+CPUID_BRAND_STR+8	/* save brandStr[2] */	movl	%edx, FUNC(sysCpuId)+CPUID_BRAND_STR+12	/* save brandStr[3] */	movl	$0x80000003, %eax	/* set EAX 0x80000003 */	cpuid				/* execute CPUID */	movl	%eax, FUNC(sysCpuId)+CPUID_BRAND_STR+16	/* save brandStr[4] */	movl	%ebx, FUNC(sysCpuId)+CPUID_BRAND_STR+20	/* save brandStr[5] */	movl	%ecx, FUNC(sysCpuId)+CPUID_BRAND_STR+24	/* save brandStr[6] */	movl	%edx, FUNC(sysCpuId)+CPUID_BRAND_STR+28	/* save brandStr[7] */	movl	$0x80000004, %eax	/* set EAX 0x80000004 */	cpuid				/* execute CPUID */	movl	%eax, FUNC(sysCpuId)+CPUID_BRAND_STR+32	/* save brandStr[8] */	movl	%ebx, FUNC(sysCpuId)+CPUID_BRAND_STR+36	/* save brandStr[9] */	movl	%ecx, FUNC(sysCpuId)+CPUID_BRAND_STR+40	/* save brandStr[10] */	movl	%edx, FUNC(sysCpuId)+CPUID_BRAND_STR+44	/* save brandStr[11] */		sysCpuProbeEnd:	popl	%ebx			/* restore EBX */	movl	FUNC(sysCpuId)+CPUID_SIGNATURE, %eax	/* get the signature */	andl	$ CPUID_FAMILY, %eax	/* mask it with FAMILY */	cmpl	$ CPUID_486, %eax	/* is the CPU FAMILY 486 ? */	je	sysCpuProbe486		/*   yes: jump to ..486 */	cmpl	$ CPUID_PENTIUM, %eax	/* is the CPU FAMILY PENTIUM ? */	je	sysCpuProbePentium	/*   yes: jump to ..Pentium */	cmpl	$ CPUID_PENTIUMPRO, %eax /* is the CPU FAMILY PENTIUMPRO ? */	je	sysCpuProbePentiumpro	/*   yes: jump to ..Pentiumpro */	cmpl	$ CPUID_EXTENDED, %eax	/* is the CPU FAMILY EXTENDED ? */	je	sysCpuProbeExtended	/*   yes: jump to ..Extended */sysCpuProbe486:        movl    $ X86CPU_486, %eax	/* set 1 for 486 */	jmp	sysCpuProbeExitsysCpuProbePentium:	movl	$ X86CPU_PENTIUM, %eax	/* set 2 for P5/Pentium */	jmp	sysCpuProbeExitsysCpuProbePentiumpro:	movl	$ X86CPU_PENTIUMPRO, %eax /* set 4 for P6/PentiumPro */	jmp	sysCpuProbeExitsysCpuProbeExtended:	movl	FUNC(sysCpuId)+CPUID_SIGNATURE, %eax	/* get the signature */	andl	$ CPUID_EXT_FAMILY, %eax /* mask it with EXTENDED FAMILY */	cmpl	$ CPUID_PENTIUM4, %eax	/* is the CPU FAMILY 486 ? */	je	sysCpuProbePentium4	/*   yes: jump to ..Pentium4 */	jmp	sysCpuProbe486		/* unknown CPU. assume it 486 */sysCpuProbePentium4:	movl	$ X86CPU_PENTIUM4, %eax	/* set 5 for P7/Pentium4 */	jmp	sysCpuProbeExitsysCpuProbe386:        movl    $ X86CPU_386, %eax	/* set 0 for 386 */sysCpuProbeExit:	popfl				/* restore EFLAGS */	movl	%eax, FUNC(sysProcessor) /* set the CPU FAMILY */	ret/********************************************************************************* sysLoadGdt - load the global descriptor table.** RETURNS: N/A** NOMANUAL* void sysLoadGdt (char *sysGdtr) */        .balign 16,0x90FUNC_LABEL(sysLoadGdt)	movl	4(%esp),%eax	lgdt	(%eax)	movw	$0x0010,%ax		/* a selector 0x10 is 3rd one */	movw	%ax,%ds		movw	%ax,%es	movw	%ax,%fs	movw	%ax,%gs	movw	%ax,%ss	ret/********************************************************************************* sysGdt - the global descriptor table.** RETURNS: N/A** NOMANUAL**/	.text        .balign 16,0x90FUNC_LABEL(sysGdtr)	.word	0x0027			/* size   : 39(8 * 5 - 1) bytes */	.long	FUNC(sysGdt)	.balign 16,0x90FUNC_LABEL(sysGdt)	/* 0(selector=0x0000): Null descriptor */	.word	0x0000	.word	0x0000	.byte	0x00	.byte	0x00	.byte	0x00	.byte	0x00	/* 1(selector=0x0008): Code descriptor, for the supervisor mode task */	.word	0xffff			/* limit: xffff */	.word	0x0000			/* base : xxxx0000 */	.byte	0x00			/* base : xx00xxxx */	.byte	0x9a			/* Code e/r, Present, DPL0 */	.byte	0xcf			/* limit: fxxxx, Page Gra, 32bit */	.byte	0x00			/* base : 00xxxxxx */	/* 2(selector=0x0010): Data descriptor */	.word	0xffff			/* limit: xffff */	.word	0x0000			/* base : xxxx0000 */	.byte	0x00			/* base : xx00xxxx */	.byte	0x92			/* Data r/w, Present, DPL0 */	.byte	0xcf			/* limit: fxxxx, Page Gra, 32bit */	.byte	0x00			/* base : 00xxxxxx */	/* 3(selector=0x0018): Code descriptor, for the exception */	.word	0xffff			/* limit: xffff */	.word	0x0000			/* base : xxxx0000 */	.byte	0x00			/* base : xx00xxxx */	.byte	0x9a			/* Code e/r, Present, DPL0 */	.byte	0xcf			/* limit: fxxxx, Page Gra, 32bit */	.byte	0x00			/* base : 00xxxxxx */	/* 4(selector=0x0020): Code descriptor, for the interrupt */	.word	0xffff			/* limit: xffff */	.word	0x0000			/* base : xxxx0000 */	.byte	0x00			/* base : xx00xxxx */	.byte	0x9a			/* Code e/r, Present, DPL0 */	.byte	0xcf			/* limit: fxxxx, Page Gra, 32bit */	.byte	0x00			/* base : 00xxxxxx */        .data        .balign 32,0x90FUNC_LABEL(sysCsSuper)        .long   0x00000008              /* CS for supervisor mode task */FUNC_LABEL(sysCsExc)        .long   0x00000018              /* CS for exception */FUNC_LABEL(sysCsInt)        .long   0x00000020              /* CS for interrupt */

⌨️ 快捷键说明

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