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

📄 286reset.asm

📁 X86 GX1 BOOTLOAD代码 ,支持WINCE操作系统!
💻 ASM
字号:
;**************************************************************************
;*
;*  286RESET.ASM
;*
;*  Copyright (c) 1999-2000 National Semiconductor Corporation.
;*  All Rights Reserved.
;*
;*  Function:
;*    Provides the 286-style reset functionality to bring the
;*    processor out of protected mode.
;*
;*  $Revision:: 2   $
;*
;**************************************************************************

.386

	INCLUDE MACROS.INC
	INCLUDE DEF.INC
	INCLUDE PORT80.INC
	INCLUDE BDA.INC
	INCLUDE OPTIONS.INC
	INCLUDE 5530.INC

_TEXT SEGMENT PUBLIC use16 'CODE'

	EXTERN	CpuMemRegRead:NEAR
	EXTERN	CpuMemRegWrite:NEAR
	EXTERN	cpuCacheOn:NEAR
	EXTERN	resetVectorOffset:NEAR
	EXTERN	Cy55x0RegRead8:NEAR
	EXTERN	Cy55x0RegWrite8:NEAR

;**************************************************************************
;*
;*	ignitionCheck
;*
;*	Named from a description from an IBM'er who associated the
;*	286-style reboot with  driving 55mph in a car and turning the
;*	engine off and back on again.
;*
;*	Returns on BX if no shutdown code found or supported.
;*	or 
;*	Returns to original caller who was trying to get out of
;*	protected mode.
;*
;*	Entry:
;*	Exit:
;*	Destroys:
;*
;**************************************************************************
ignitionCheck PROC NEAR PUBLIC
	PORT80	069h			; Post code 69h, Prot Mode Reset
	
	NOSTACKCMOSREAD 0fh
	; Shutdown byte 
	cmp	al, 05h
	je	shutdown05
	cmp	al, 0Ah
	je	shutdown0A
	cmp	al, 04h
	je	shutdown04

	NOSTACKCMOSWRITE 0fh, 0		; Clear Shutdown byte

	;
	; For any reason for being here, force an X-Bus shutdown
	;
	PORT80	071h			; X-Bus Reset

	;
	; Try 5530 first
	;
	mov	eax, CX55x0_ID 
	mov	ah, FUNC0
	mov	al, 044h		; Reset control reg
	NOSTACK	bx, Cy55x0RegRead8

	or	dl, 001h		; Bit 0 Set = RESET SYSTEM
	mov	eax, CX55x0_ID 
	mov	ah, FUNC0
	mov	al, 044h		; Reset control reg
	NOSTACK	bx, Cy55x0RegWrite8

	;
	; If we made it here, must be a 5520, do X-Bus on 5520
	;
	PORT80	072h			; 5520 X-Bus Reset

	hlt
	jmp	$

shutdown05:
	NOSTACKCMOSWRITE 0fh, 0h	; Clear Shutdown byte
	PORT80	05h			; Type 05h
	
	NOSTACK	dx, cpuCacheOn

	mov	cx, 50
	cld
keyloop1:
	in	al, 060h		; suck in anything thats in the
	loop keyloop1			; keyboard controller

	mov	al, 011h		; Enable PIC for PC usage
	out	PIC_MASTER_PORT0, al	; icw1
	out	PIC_SLAVE_PORT0, al

	mov	al, 08h			; icw2
	out	PIC_MASTER_PORT1, al
	mov	al, 070h
	out	PIC_SLAVE_PORT1, al

	mov	al, 04h			; icw3
	out	PIC_MASTER_PORT1, al
	mov	al, 02h
	out	PIC_SLAVE_PORT1, al

	mov	al, 01h			; icw4
	out	PIC_MASTER_PORT1, al
	out	PIC_SLAVE_PORT1, al


	mov	al, 020h
	out	PIC_SLAVE_PORT0, al	; End of Int - 
	out	PIC_MASTER_PORT0, al	; set ocw2 for non-specific EOI

	mov	al, 056h		;
	out	043h, al		; 
	mov	al, 012h		; 
	out	041h, al		; Start TIMER 1

	mov	ax, 040h
	mov	ds, ax
	mov	si, 067h

	jmp	dword ptr ds:[si]

shutdown0A:
	NOSTACKCMOSWRITE 0fh, 0h	; Clear Shutdown byte
	PORT80	0Ah			; Type 0Ah

	NOSTACK	dx, cpuCacheOn

	mov	cx, 50
	cld
keyloop2:
	in	al, 060h		; suck in anything thats in the
	loop keyloop2			; keyboard controller

	mov	ax, 040h
	mov	ds, ax
	mov	si, 067h

	jmp	dword ptr ds:[si]



shutdown04:
	NOSTACKCMOSWRITE 0fh, 0h	; Clear Shutdown byte
	PORT80	04h			; Type 0Ah

	NOSTACK	dx, cpuCacheOn

	mov	cx, 50
	cld
keyloop4:
	in	al, 060h		; suck in anything thats in the
	loop	keyloop4		; keyboard controller

	int	19h

	hlt
	jmp	$


ignitionCheck ENDP

;**************************************************************************
;*
;*	ignitionCheckPatch
;*
;*	Entry:
;*	Exit:
;*	Destroys:
;*
;**************************************************************************
ignitionCheckPatch PROC NEAR PUBLIC
	push	bx

	cli

	mov	eax, CPU_BC_XMAP_3
	NOSTACK	bx, CpuMemRegRead	; Set F000:0 For read/write
	push	edx
	and	edx, 00000ffffh
	or	edx, 033330000h
	NOSTACK  bx, CpuMemRegWrite

	jmp	$+2			; Implicit Jump
	mov	eax, cr3		; Force a TLB Flush
	jmp	$+2

	mov	bx, OFFSET resetVectorOffset
	mov	WORD PTR cs:[bx], OFFSET ignitionCheck

	mov	eax, CPU_BC_XMAP_3
	NOSTACK	bx, CpuMemRegRead
	pop	edx
	NOSTACK	bx, CpuMemRegWrite

	jmp	$+2			; Implicit Jump
	mov	eax, cr3		; Force a TLB Flush
	jmp	$+2

	sti
	pop	bx
	jmp	bx

ignitionCheckPatch ENDP

_TEXT ENDS

END

⌨️ 快捷键说明

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