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

📄 pre317.asm

📁 X86 GX1 BOOTLOAD代码 ,支持WINCE操作系统!
💻 ASM
字号:
;**************************************************************************
;*
;*  PRE317.ASM
;*
;*  Copyright (c) 1999 National Semiconductor Corporation.
;*  All Rights Reserved.
;*
;*  Function:
;*    Code to be run before the NS 317 SuperIO initialization.
;*
;*  $Revision:: 1    $
;*
;**************************************************************************

	;.MODEL TINY
	.486P

	INCLUDE DEF.INC
	INCLUDE MACROS.INC
	INCLUDE PORT80.INC

_TEXT SEGMENT PUBLIC use16 'CODE'

PM_BASE		equ	0E8h
GPIO_BASE	equ	0E0h
PM1A_CNT	EQU	0AC0Ch

;**************************************************************************
; Register Table
;
NS317_INIT_TABLE1:
	
	DW NS317,	07h,	00h,	08h	; device PM
	DW NS317,	60h,	00h,	00h	; Base Address
	DW NS317,	61h,	00h,	PM_BASE
	DW NS317,	30h,	00h,	01h	; Activation
	DW 70h,		0ah,	0F0h,	06h	; RTC Periodic rate select
	DW PM_BASE,	03h,	0ffh,	07h	; Power Managment Control 2 Register - Clk source=on-chip and multiplier enabled
NS317_INIT_COUNT1 EQU (($ - NS317_INIT_TABLE1) / 8)

NS317_INIT_TABLE2:
	DW NS317,	07h,	00h,	02h	; Real Time Clock
	DW NS317,	70h,	00h,	08h	; Interrupt
	DW NS317,	30h,	00h,	01h	; Activation

	DW NS317,	07h,	00h,	00h	; Keyboard
	DW NS317,	70h,	00h,	01h	; Interrupt
	DW NS317,	30h,	00h,	01h	; Activation

	DW NS317,	07h,	00h,	07h	; GPIO
	DW NS317,	60h,	00h,	00h	; Base Address
	DW NS317,	61h,	00h,	GPIO_BASE
	DW NS317,	30h,	00h,	01h	; Activation

; ACPI register settings / Soft off / POR setup registers 
;	DW PM_BASE, 	08h,	00h,	80h	; PM1 Event register = AC80
;	DW PM_BASE, 	09h,	00h,	0ACh	;
;	DW PM_BASE, 	0ah,	00h,	88h	; PM Timer register = AC88
;	DW PM_BASE, 	0bh,	00h,	0ach	;
;	DW PM_BASE, 	0ch,	00h,	084h	; PM1 Control register = AC84
;	DW PM_BASE, 	0dh,	00h,	0ach	;
;	DW PM_BASE, 	0eh,	00h,	90h	; General Purpose	Status =	AC90
;	DW PM_BASE, 	0fh,	00h,	0ach	; has to be on paragraph boundry or will not work
;	DW PM_BASE, 	01h,	00h,	0BFh	; FER2 enable APC
;	DW 0ffffh,	0AC90h+4h, 00h,	02h	; PME2 activates both POR and ONCTL
;	DW 0ffffh,	0AC90h+8h, 00h, 4Fh	; PME1, PME2, IRRX1, IRRX2, activate POR + GPIO10 toggles POR	
;POR on	DW 0ffffh, 	0AC84h, 0ffh,	01h	; SCI on / POR off
; end of soft off code
	
	DW 70h,	0Ah,	00h,	26h	; Status registers A-D
	DW 70h,	0Bh,	00h,	02h	;
	DW 70h,	0Ch,	00h,	50h	;
	DW 70h,	0Dh,	00h,	80h	;
	
	DW 70h,	0Ah,	8Fh,	040h	; switch to bank 2
	DW 70h,	40h,	00h,	00h	; APC Control Registers 1-7
	DW 70h,	41h,	00h,	00h	;
	DW 70h,	42h,	00h,	83h	; APC Status registers
	DW 70h,	43h,	00h,	0C0h	; WDW
	DW 70h,	44h,	00h,	0C0h	; WDM
	DW 70h,	45h,	00h,	0C0h	; WM
	DW 70h,	46h,	00h,	0C0h	; WY
	DW 70h,	47h,	00h,	00h	; RAM lock register
	DW 70h,	48h,	00h,	0C0h	; WC
	DW 70h,	49h,	00h,	0A0h	;
	DW 70h,	4Ah,	00h,	2Dh	;
	DW 70h,	4Bh,	00h,	2Dh	;
	DW 70h,	4Ch,	00h,	2Dh	;
	DW 70h,	4Dh,	00h,	15h	;
	DW 70h,	4Eh,	00h,	01h	;
	DW 70h,	4Fh,	00h,	0C9h	; DADDR
	DW 70h,	50h,	00h,	0CAh	; MADDR
	DW 70h,	51h,	00h,	0C8h	; CADDR
	DW 70h,	0Ah,	8Fh,	030h	; switch to bank 1

	DW 70h,	49h,	00h,	0C0h	; DMAR - set don't care
	DW 70h,	4Ah,	00h,	0C0h	; MAR  - set don't care
	DW 70h,	48h,	00h,	00h	; CR

	DW 70h,	0Ah,	8Fh,	020h	; leave at bank 0

	DW NS317, 07h,	00h,	08h	; device PM
;	DW NS317, 30h,	00h,	00h	; Turn off access to PM config regs
NS317_INIT_COUNT2 EQU (($ - NS317_INIT_TABLE2) / 8)

;**************************************************************************
;*
;*	preSioInit
;*
;*	Entry:
;*	Exit:
;*	Destroys:
;*
;**************************************************************************
preSioInit PROC NEAR PUBLIC

	shl	ebx, 16

	lea	si, NS317_INIT_TABLE1	; Start of table
	mov	cx, NS317_INIT_COUNT1	; Number of entry in the table

ns317loop1:
	mov	dx, cs:[si]		; get the index port
	add	si, 2

	cmp	dx, 0ffffh
	je	nodatapair1

	mov	al, cs:[si]
	add	si, 2

	out	dx, al			; set index
	xor	dx, 1			; Switch to data port
	jmp	nopairdone1

nodatapair1:	;not a data/index pair - load directly
	mov	dx, cs:[si]
	add	si, 2
	mov	al, dl
nopairdone1:
	in	al, dx
	mov	bl, cs:[si]		; get value to and
	add	si, 2
	and	al, bl
	mov	bl, cs:[si]		; get value to OR
	add	si, 2
	or	al, bl
	out	dx, al			; out to data port
	loop ns317loop1		; Go thru all items

unfreeze:				; we just set the internal clock source
	mov 	al, 03h			; now, wait for the clocks to unfreeze
	out	PM_BASE, al
	in 	al, PM_BASE+1
	test 	al, 80h
	je 	unfreeze

	lea	si, NS317_INIT_TABLE2	; Start of table
	mov	cx, NS317_INIT_COUNT2	; Number of entry in the table

ns317loop2:
	mov	dx, cs:[si]		; get the index port
	add	si, 2

	cmp	dx, 0ffffh
	je	nodatapair2

	mov	al, cs:[si]
	add	si, 2

	out	dx, al			; set index
	xor	dx, 1			; Switch to data port
	jmp	nopairdone2

nodatapair2:				;not a data/index pair - load directly
	mov	dx, cs:[si]
	add	si, 2
	mov	al, dl
nopairdone2:

	in	al, dx
	mov	bl, cs:[si]		; get value to and
	add	si, 2
	and	al, bl
	mov	bl, cs:[si]		; get value to OR
	add	si, 2
	or	al, bl
	out	dx, al			; out to data port
	loop ns317loop2		; Go thru all items
	shr	ebx, 16

	jmp	bx

preSioInit ENDP


_TEXT ENDS

END

⌨️ 快捷键说明

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