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

📄 rominit.s

📁 鼎鼎大名的WRS提供的VxWorks下pcPentium BSP开发包
💻 S
字号:
/* romInit.s - PC-386 ROM initialization module *//* Copyright 1984-1996 Wind River Systems, Inc. */	.data	.globl	_copyright_wind_river	.long	_copyright_wind_river/*modification history--------------------01l,03sep96,hdn  added the compression support.01k,21oct94,hdn  cleaned up.01j,23sep94,hdn  deleted _sysBootType and uses stack.01i,06apr94,hdn  moved a processor checking routine to sysALib.s.		 created the system GDT at GDT_BASE_OFFSET.01h,17feb94,hdn  deleted a piece of code which copy itself to upper memory.01g,27oct93,hdn  added _sysBootType.01f,25aug93,hdn  changed a way to enable A20.01e,12aug93,hdn  added codes to load a user defined global descriptor table.01d,09aug93,hdn  added codes to recognize a type of cpu.01c,17jun93,hdn  updated to 5.1.01b,26mar93,hdn  added some codes to switch to the protected mode01a,19mar92,hdn  written by modifying v01c of h32/romInit.s*//*DESCRIPTIONThis module contains the entry code for the VxWorks bootrom.The routine sysToMonitor(2) jumps to the location XXX bytespassed the beginning of romInit, to perform a "warm boot".This code is intended to be generic accross i80x86 boards.Hardware that requires special register setting or memorymapping to be done immediately, may do so here.*/#define _ASMLANGUAGE#include "vxWorks.h"#include "sysLib.h"#include "asm.h"#include "config.h"	/* internals */	.globl	_romInit	/* start of system code */	.globl	_sdata		/* start of data */_sdata:	.asciz	"start of data"	.text	.align 4/********************************************************************************* romInit - entry point for VxWorks in ROM** romInit (startType)*     int startType;	/@ only used by 2nd entry point @/*/_romInit:	/*	 * following codes are executed as 16 bits codes	 */	cli				/* LOCK INTERRUPT */	jmp	cold	.align 4,0x90_romWarmHigh:	cli				/* LOCK INTERRUPT */	movl    SP_ARG1(%esp),%ebx	/* %ebx has the startType */	jmp	warm	.align 4,0x90_romWarmLow:	cli				/* LOCK INTERRUPT */	cld				/* copy itself to the entry point */	movl	$ RAM_LOW_ADRS,%esi	movl	$ ROM_TEXT_ADRS,%edi	movl	$ ROM_SIZE,%ecx	shrl	$2,%ecx	rep	movsl	movl    SP_ARG1(%esp),%ebx	/* %ebx has the startType */	jmp	warm	/* copyright notice appears at beginning of ROM (in TEXT segment) */	.ascii   "Copyright 1984-1996 Wind River Systems, Inc."	.align 4	/* load temporary IDT */cold:	aword			/* next instruction has 32bit address */	word			/* next instruction has 32bit operand */	lidt	%cs:ROM_IDTR	/* load temporary GDT */	aword			/* next instruction has 32bit address */	word			/* next instruction has 32bit operand */	lgdt	%cs:ROM_GDTR	/* switch to protected mode */	mov	%cr0,%eax	/* move CR0 to EAX */	.byte	0x66		/* next instruction has 32bit operand */	or	$0x00000001,%eax/* set the PE bit */	mov	%eax,%cr0	/* move EAX to CR0 */	jmp	romInit1	/* near jump to flush a instruction queue */romInit1:	.byte	0x66		/* next instruction has 32bit operand */	mov	$0x0010,%eax	/* a selector 0x10 is 3rd descriptor */	mov	%ax,%ds		/* load it to DS */	mov	%ax,%es		/* load it to ES */	mov	%ax,%fs		/* load it to FS */	mov	%ax,%gs		/* load it to GS */	mov	%ax,%ss		/* load it to SS */	.byte	0x66		/* next instruction has 32bit operand */	mov	$ ROM_STACK,%esp /* set a stack pointer */	aword			/* next instruction has 32bit address */	word			/* next instruction has 32bit operand */	ljmp	$0x08, $ ROM_TEXT_ADRS + ROM_INIT2 /* far inter segment jump */_romIdtr:	.word	0x0000			/* size   : 0 */	.long	0x00000000		/* address: 0 */_romGdtr:	.word	0x0027			/* size   : 39(8 * 5 - 1) bytes */	.long	ROM_TEXT_ADRS + ROM_GDT /* address: romGdt */	.align 4,0x90_romGdt:	/* 0(selector=0x0000): Null descriptor */	.word	0x0000	.word	0x0000	.byte	0x00	.byte	0x00	.byte	0x00	.byte	0x00	/* 1(selector=0x0008): Code descriptor */	.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 nesting 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 */	/* 4(selector=0x0020): Code descriptor, for the nesting 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 */	/* following codes are executed as 32 bits codes */	.align 4,0x90_romInit2:	cli				/* LOCK INTERRUPT */	mov	$ ROM_STACK,%esp	/* set a stack pointer */	call	_romA20on		/* enable A20 */	movl    $ BOOT_COLD,%ebx	/* %ebx has the startType */warm:	movl	$_romGdtr,%eax		/* load the original GDT */	subl	$_romInit,%eax	addl	$ ROM_TEXT_ADRS,%eax	pushl	%eax		call	_romLoadGdt	movl	$ STACK_ADRS,%esp	/* initialise the stack pointer */	movl	$0,%ebp			/* initialise the frame pointer */	pushl	$0			/* initialise the %eflags */	popfl	pushl	%ebx			/* push the startType */	cld                             /* copy itself to the entry point */	movl    $ ROM_TEXT_ADRS,%esi	movl    $_romInit,%edi	movl    $_end,%ecx	subl    %edi,%ecx	shrl    $2,%ecx	rep	movsl	movl	$_romStart,%eax		/* jump to romStart */	call	*%eax	/* just in case, if there's a problem in usrInit */_romInitHlt:	hlt		/********************************************************************************* romA20on - enable A20** enable A20** RETURNS: N/A* void romA20on (void) */	.align 4,0x90_romA20on:	call	_romWait	movl	$0xd1,%eax		/* Write command */	outb	%al,$0x64	call	_romWait	movl	$0xdf,%eax		/* Enable A20 */	outb	%al,$0x60	call	_romWait	movl	$0xff,%eax		/* NULL command */	outb	%al,$0x64	call	_romWait	movl	$0x000000,%eax		/* Check if it worked */	movl	$0x100000,%edx	movl	$0x0,(%eax)	movl	$0x0,(%edx)	movl	$0x01234567,(%eax)	cmpl	$0x01234567,(%edx)	jne	romA20on0	/* another way to enable A20 */	movl	$0x02,%eax	outb	%al,$0x92	xorl	%ecx,%ecxromA20on1:	inb	$0x92,%al	andb	$0x02,%al	loopz	romA20on1	movl	$0x000000,%eax		/* Check if it worked */	movl	$0x100000,%edx	movl	$0x0,(%eax)	movl	$0x0,(%edx)	movl	$0x01234567,(%eax)	cmpl	$0x01234567,(%edx)	jne	romA20on0	movl	$-1,_romA20ResultromA20on0:	ret        .align 4,0x90_romA20Result:	.long	0x00000000	/* 0 if A20 is on, -1 if not *//********************************************************************************* romLoadGdt - load the global descriptor table.** RETURNS: N/A** NOMANUAL* void romLoadGdt (char *romGdtr) */        .align 4,0x90_romLoadGdt:	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/********************************************************************************* romWait - wait until the input buffer become empty** wait until the input buffer become empty** RETURNS: N/A* void romWait (void) */	.align 4,0x90_romWait:	xorl	%ecx,%ecxromWait0:	movl	$0x64,%edx		/* Check if it is ready to write */	inb	%dx,%al	andb	$2,%al	loopnz	romWait0	ret

⌨️ 快捷键说明

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