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

📄 prempc.asm

📁 X86 GX1 BOOTLOAD代码 ,支持WINCE操作系统!
💻 ASM
字号:
;**************************************************************************
;*
;*  PREMPC.ASM
;*
;*  Copyright (c) 1999 National Semiconductor Corporation.
;*  All Rights Reserved.
;*
;*  Function:
;*    Early SC1x00 Super I/O configuration
;*
;*  $Revision: 3 $
;**************************************************************************

	.486P

	INCLUDE DEF.INC
	INCLUDE MACROS.INC
	INCLUDE PORT80.INC
	INCLUDE OPTIONS.INC
	INCLUDE MPC.INC
	INCLUDE NSSIO.INC
	INCLUDE strings.inc

INSTALL_NSSIO SC1x00

_TEXT SEGMENT PUBLIC use16 'CODE'

	EXTERN	cy55x0RegRead8:NEAR
	EXTERN	cy55x0RegWrite8:NEAR
	EXTERN	cy55x0RegRead32:NEAR
	EXTERN	cy55x0RegWrite32:NEAR

	; The tables are used for F0 and F5 registers configuration in
	; order to enable external SIO on LPC and internal SIO concurect
	; The format of the table:
	;	offset, mask, value
F0SIO_INIT_TABLE:
	DB	  GEODE_REG47, 0FBh, LPC	; Enable F0BAR1 (LPC)
	DB	  GEODE_REG5A, 000h, 001h	; Enable RTC Positive decode
	DB	  GEODE_REG5B, 000h, 020h	; Enable ROM Positive decode
F0SIO_INIT_COUNT EQU (($ - F0SIO_INIT_TABLE)/(3*SIZEOF(BYTE)))

	; F5 registers
F5SIO_INIT_TABLE:
	DB	GEODE_REG40, 000h, 0C1h	; X-BUS BAR0 mask (64-bytes I/O space)
	DB	GEODE_REG41, 000h, 0FFh
	DB	GEODE_REG42, 000h, 0FFh
	DB	GEODE_REG43, 000h, 0FFh

	DB	GEODE_REG10, 000h, (GEODE_XBUS_BASE and 0ffh) or 01h	; X-BUS BAR0 = 6201h (I/O mapped)
	DB	GEODE_REG11, 000h, ((GEODE_XBUS_BASE shr 8) and 0ffh)
	DB	GEODE_REG12, 000h, ((GEODE_XBUS_BASE shr 16) and 0ffh)
	DB	GEODE_REG13, 000h, ((GEODE_XBUS_BASE shr 24) and 0ffh)
IF (SCx1xx_PROCESSOR)
	DB	GEODE_REG50, 000h, 000h	; X-BUS BAR4 mask (16MB Memory space)
	DB	GEODE_REG51, 000h, 000h
	DB	GEODE_REG52, 000h, 000h
	DB	GEODE_REG53, 000h, 0FFh

	DB	GEODE_REG20, 000h, (GEODE_ROMCS4_BASE and 0ffh)			; X-BUS BAR5 = 41000000h (Memory mapped)
	DB	GEODE_REG21, 000h, ((GEODE_ROMCS4_BASE shr 8) and 0ffh)
	DB	GEODE_REG22, 000h, ((GEODE_ROMCS4_BASE shr 16) and 0ffh)
	DB	GEODE_REG23, 000h, ((GEODE_ROMCS4_BASE shr 24) and 0ffh)

	DB	GEODE_REG54, 000h, 000h	; X-BUS BAR5 mask (16MB Memory space)
	DB	GEODE_REG55, 000h, 000h
	DB	GEODE_REG56, 000h, 000h
	DB	GEODE_REG57, 000h, 0FFh

	DB	GEODE_REG24, 000h, (GEODE_ROMCS5_BASE and 0ffh)			; X-BUS BAR5 = 41000000h (Memory mapped)
	DB	GEODE_REG25, 000h, ((GEODE_ROMCS5_BASE shr 8) and 0ffh)
	DB	GEODE_REG26, 000h, ((GEODE_ROMCS5_BASE shr 16) and 0ffh)
	DB	GEODE_REG27, 000h, ((GEODE_ROMCS5_BASE shr 24) and 0ffh)
ENDIF


	DB	GEODE_REG04, 000h, 001h	; I/O cycles
F5SIO_INIT_COUNT EQU (($ - F5SIO_INIT_TABLE)/(3*SIZEOF(BYTE)))

	; Internal SIO registers
NSSIO_INIT_TABLE:
	DB	  NSSIO_LOGICAL_DEVICE_NUMBER, RTC_DEVICE	;RTC		
	DB	  NSSIO_PRIMARY_INTERRUPT_SELECT, 08h
	DB	  NSSIO_ACTIVATE, 00h
	DB	  NSSIO_ACTIVATE, 01h

	; Access.Bus1 initialization
	DB	  NSSIO_LOGICAL_DEVICE_NUMBER, ACCESS_BUS1_DEVICE	; Select the ACCESS.bus device1
	DB	  NSSIO_PRIMARY_BASE_IO_ADDR_HI, NSSIO_AB1_BASE_HIGH
	DB	  NSSIO_PRIMARY_BASE_IO_ADDR_LOW, NSSIO_AB1_BASE_LOW
	DB	  NSSIO_ACTIVATE, 0				; Disable it in order to recover the bus
	DB	  NSSIO_ACTIVATE, 1				; Enable it
	
	DB	  NSSIO_LOGICAL_DEVICE_NUMBER, ACCESS_BUS2_DEVICE	; Select the ACCESS.bus device2
	DB	  NSSIO_PRIMARY_BASE_IO_ADDR_HI, NSSIO_AB2_BASE_HIGH
	DB	  NSSIO_PRIMARY_BASE_IO_ADDR_LOW, NSSIO_AB2_BASE_LOW
	DB	  NSSIO_ACTIVATE, 0				; Disable it in order to recover the bus
	DB	  NSSIO_ACTIVATE, 1				; Enable it

	DB	  NSSIO_LOGICAL_DEVICE_NUMBER, WAKEUP_DEVICE	; Select the Wake-Up device
	DB	  NSSIO_PRIMARY_BASE_IO_ADDR_HI, NSSIO_WAKEUP_BASE_HIGH
	DB	  NSSIO_PRIMARY_BASE_IO_ADDR_LOW, NSSIO_WAKEUP_BASE_LOW
	DB	  NSSIO_ACTIVATE, 1							; Enable it	

	; RTC registers initialization
;	DB	  NSSIO_RLR, 00h			; RAM lock register - RLR
;	DB	  NSSIO_DADDR, 0C9h			; Day of Month Alarm Address - DOMAO
;	DB	  NSSIO_MADDR, 0CAh			; Month Alarm Address - MAO
;	DB	  NSSIO_CADDR, 0C8h			; Century Month Alarm Address - CENO
NSSIO_INIT_COUNT EQU ($ - NSSIO_INIT_TABLE)

;**************************************************************************
;*
;*	preSioInit
;*
;*	Early on-chip SuperI/O test and configuration
;*
;*	Entry:
;*	  BX - return address
;*
;*	Exit:
;*	  None
;*
;*	Destroys:
;*	  EAX, EDX, SI, CX, BP, EDI
;*
;**************************************************************************
preSioInit PROC NEAR PUBLIC
	mov	gs, bx

	PORT80	P80_SIO+01h		; Indicate Entrance to SIO code
tryagain:
	mov	ax, LPC			; get lpc present
	or	ax,ax			; see if there
	jz	nolpc			; not present

	; Enable and configure LPC bridge
	mov	eax, FUNC0+GEODE_REG14
	mov	edx, GEODE_LPC_BASE
	NOSTACK	bx, cy55x0RegWrite32
nolpc:
	; Configure F0 registers
	mov	cl, F0SIO_INIT_COUNT
	lea	si, F0SIO_INIT_TABLE

f0loop:
	mov	bp, cx			; Store counter
	mov	eax, CX55x0_ID
	mov	al, cs:[si]		; Get offset
	mov	edi, eax		; Store address
	NOSTACK	bx, cy55x0RegRead8
	mov	eax, edi		; Restore address
	inc	si			; Point to the mask
	and	dl, cs:[si]
	inc	si			; Point to the value
	or	dl, cs:[si]
	NOSTACK	bx, cy55x0RegWrite8
	inc	si			; Point to the next record
	mov	cx, bp			; Restore counter
	xor	ch, ch
	loop f0loop

	; Configure F5 registers
	mov	cl, F5SIO_INIT_COUNT
	lea	si, F5SIO_INIT_TABLE

f5loop:
	mov	bp, cx			; Store counter
	mov	eax, CX55x0_ID
	mov	ah, FUNC5
	mov	al, cs:[si]		; Get offset
	mov	edi, eax		; Store address
	NOSTACK	bx, cy55x0RegRead8
	mov	eax, edi		; Restore address
	inc	si			; Point to the mask
	and	dl, cs:[si]
	inc	si			; Point to the value
	or	dl, cs:[si]
	NOSTACK	bx, cy55x0RegWrite8
	inc	si			; Point to the next record
	mov	cx, bp			; Restore counter
	xor	ch, ch
	loop f5loop

	; Configure X-BUS registers
	; XBUS expansion registers
	mov	dx, GEODE_XBUS_BASE+GEODE_XBUS_CONTROL_1
	in	eax, dx
	; Enable internal SIO & USB, clear reserved bits, 
	; and set SIO base 15Ch/15Dh
	mov	eax, 00F000000h or (USBINSTALL shl 18)
	out	dx, eax

IF (SCx1xx_PROCESSOR)
	mov	dx, GEODE_XBUS_BASE+GEODE_XBUS_CONTROL_2
	in	eax, dx
	and	eax, 0FFFFFFFDh		; Disable bit-1 - Video Processor Access
	out	dx, eax
ENDIF

	; Attempt to id the SIO and if not identified then put out post code and stop
	mov	dx, GEODE_SIO_BASE
	mov	al, NSSIO_DEVICE_ID_REG
	out	dx, al
	xor	dx, 1
	in	al, dx
IF SC_CHIP
	cmp	al, NSSIO_SC1200_ID
ELSE
.ERR Wrong GEODE SCXX00 Processor
ENDIF
	je	nssioPresent
	PORT80	P80_SIO+0Bh		; Indicate invalid SIO response
; for some reason when an external pci card is installed
; we can't detect the sio the 1st time - lets tray again
; this is temp until I figure out what is going on!!!!!
	jmp	tryagain

nssioPresent:
	mov	cx, NSSIO_INIT_COUNT
	lea	si, NSSIO_INIT_TABLE
	mov	dx, GEODE_SIO_BASE

nsloop:
	mov	al, cs:[si]
	inc	si
	out	dx,al
	xor	dl,1
	loop nsloop

	; Configure RTC
	mov	dx, RTC_INDEX
	mov	al, RTC_STAT_REG_D
	out	dx, al
	mov	dx, RTC_DATA
	in	al, dx
	in	al, dx

	;put in 24 hour mode
	mov	dx, RTC_INDEX
	mov	al, RTC_STAT_REG_B
	out	dx, al
	mov	dx, RTC_DATA
	mov	al, RTC_24_12_MODE
	out	dx, al

exitPreSioInit:
	mov	bx, gs
	jmp	bx

preSioInit ENDP

_TEXT ENDS

	END
 

⌨️ 快捷键说明

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