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

📄 abutils.asm

📁 X86 GX1 BOOTLOAD代码 ,支持WINCE操作系统!
💻 ASM
📖 第 1 页 / 共 2 页
字号:
;**************************************************************************
;*
;*  ABUTILS.ASM
;*
;*  Copyright (c) 1998-1999 National Semiconductor Corporation.
;*  All Rights Reserved.
;*
;*  Function:
;*    Access.Bus low level interface.  Supports two Access.Bus
;*    devices.
;* 
;*  $Revision: 1 $
;*
;**************************************************************************

	.486P

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

INSTALL_NSSIO SC1x00

_TEXT SEGMENT PUBLIC use16 'CODE'

;**************************************************************************
;*
;*	LoadABAddr
;*
;*	Load Access.Bus base address
;*
;*	Entry:
;*	  BP = number of Access.bus: ACCESS_BUS1_DEVICE or ACCESS_BUS2_DEVICE
;*	  DI - Return address
;*
;*	Exit:
;*	  AX - Base Address
;*
;*	Destroys:
;*	  AX
;*
;**************************************************************************
LoadABAddr PROC NEAR
	mov dx, NSSIO_AB1_BASE
	cmp	bp, ACCESS_BUS1_DEVICE
	jz	exit
	mov dx, NSSIO_AB2_BASE

exit:
	jmp	di
LoadABAddr ENDP

;**************************************************************************
;*
;*	ABBaseRead
;*
;*	Read from the base address of Access.Bus device
;*
;*	Entry:
;*	  AL - Register offset
;*	  BP = number of Access.bus: ACCESS_BUS1_DEVICE or ACCESS_BUS2_DEVICE
;*	  BX - Return address
;*
;*	Exit:
;*	  AH - Register data
;*
;*	Destroys:
;*	  DI, DX
;*
;**************************************************************************
ABBaseRead PROC NEAR
	ror	eax, 16			; Store offset and data
	NOSTACK	di, LoadABAddr
	ror	eax, 16			; Restore offset and data
	add	dl, al			; Select the register
	xchg	ah, al
	in	al, dx			; Read the data
	xchg	ah, al

	jmp	bx				; return	
ABBaseRead ENDP

;**************************************************************************
;*
;*	ABBaseWrite
;*
;*	Write to the base address of Access.Bus device
;*
;*	Entry:
;*	  AL - Register offset
;*	  AH - Register data
;*	  BP = number of Access.bus: ACCESS_BUS1_DEVICE or ACCESS_BUS2_DEVICE
;*	  BX - Return address
;*
;*	Exit:
;*	  None
;*
;*	Destroys:
;*	  DI, DX
;*
;**************************************************************************
ABBaseWrite PROC NEAR
	ror	eax, 16			; Store offset and data
	NOSTACK	di, LoadABAddr
	ror	eax, 16			; Restore offset and data
	add	dl, al			; Select the register
	xchg	ah, al
	out	dx, al			; Write the data

	jmp	bx			; return	
ABBaseWrite ENDP

;**************************************************************************
;*
;*	StopSignalABData
;*
;*	Stops transaction on the Access.Bus device
;*
;*	Entry:
;*	  BP = number of Access.bus: ACCESS_BUS1_DEVICE or ACCESS_BUS2_DEVICE
;*
;*	Exit:
;*	  None
;*
;*	Destroys:
;*	  AX, DI, DX
;*
;**************************************************************************
StopSignalABData PROC NEAR PUBLIC
	ror	ebx, 16			; Store return address

	; Issue STOP event
	mov	al, NSSIO_ACBCTL1
	NOSTACK	bx, ABBaseRead
	or	ah, 02h
	NOSTACK	bx, ABBaseWrite

	ror	ebx, 16			; Restore return address
	jmp	bx			; return
StopSignalABData ENDP

;**************************************************************************
;*
;*	StartSignalABData
;*
;*	Starts transaction on the Access.Bus device
;*
;*	Entry:
;*	  BP = number of Access.bus: ACCESS_BUS1_DEVICE or ACCESS_BUS2_DEVICE
;*
;*	Exit:
;*	  None
;*
;*	Destroys:
;*	  AX, DI, DX
;*
;**************************************************************************
StartSignalABData PROC NEAR PUBLIC
	ror	ebx, 16			; Store return address

	; Issue START event
	mov	al, NSSIO_ACBCTL1
	NOSTACK	bx, ABBaseRead
	or	ah, 01h
	NOSTACK	bx, ABBaseWrite

	ror	ebx, 16			; Restore return address
	jmp	bx			; return
StartSignalABData ENDP

;**************************************************************************
;*
;*	SetACKABData
;*
;*	Set ACK bit on the Access.Bus device
;*
;*	Entry:
;*	  BP = number of Access.bus: ACCESS_BUS1_DEVICE or ACCESS_BUS2_DEVICE
;*
;*	Exit:
;*	  None
;*
;*	Destroys:
;*	  AX, DI, DX
;*
;**************************************************************************
SetACKABData PROC NEAR PUBLIC
	ror	ebx, 16			; Store return address

	mov	al, NSSIO_ACBCTL1
	NOSTACK	bx, ABBaseRead
	or	ah, 10h
	NOSTACK	bx, ABBaseWrite

	ror	ebx, 16			; Restore return address
	jmp	bx			; return
SetACKABData ENDP

;**************************************************************************
;*
;*	ClearACKABData
;*
;*	Clear ACK bit on the Access.Bus device.
;*
;*	Entry:
;*	  BP = number of Access.bus: ACCESS_BUS1_DEVICE or ACCESS_BUS2_DEVICE
;*
;*	Exit:
;*	  None
;*
;*	Destroys:
;*	  AX, DI, DX
;*
;**************************************************************************
ClearACKABData PROC NEAR PUBLIC
	ror	ebx, 16			; Store return address

	mov	al, NSSIO_ACBCTL1
	NOSTACK	bx, ABBaseRead
	and	ah, 0E7h
NOSTACK	bx, ABBaseWrite

	ror	ebx, 16			; Restore return address
	jmp	bx			; return
ClearACKABData ENDP

;**************************************************************************
;*
;*	RequestMasterABData
;*
;*	This routine requests bus mastership the Access.bus
;*
;*	Entry::
;*	  BP = number of Access.bus: ACCESS_BUS1_DEVICE or ACCESS_BUS2_DEVICE
;*	  BX - return address
;*
;*	Exit:
;*	  Carry flag set as follows
;*	    Set = acknowledge bit = 1
;*	    Clr = acknowledge bit = 0
;*
;*	Destroys
;*	  AX, EBX, CX, DX
;*
;**************************************************************************
RequestMasterABData PROC NEAR PUBLIC
	ror	ebx, 16				; Store return address

	; Request bus mastership
	mov	al, NSSIO_ACBCTL1
	NOSTACK	bx, ABBaseRead
	or	ah, 01h				; Issue Start condition
	NOSTACK	bx, ABBaseWrite

	xor	cl, cl
RequestMasterABStart:
	mov	al, NSSIO_ACBST
	NOSTACK	bx, ABBaseRead
	inc	cl
	cmp	cl, 0FFh
	jz	RequestMasterABFailed		; timeout?

	test	ah, 60h				; SDAST and BER == 0?
	jz	RequestMasterABStart		; Wait if no events

	; Check that no bus confict is detected
	test	ah, 20h				; BER == 1
	jnz	RequestMasterABFailed		; bus conflict
	test	ah, 02h				; MASTER != 1
	jz	RequestMasterABFailed		; Master request failed

	ror	ebx, 16				; Restore return address
	stc
	jmp	bx

RequestMasterABFailed:
	ror	ebx, 16				; Restore return address
	mov	dx, bx
	jmp	AbortABData
RequestMasterABData ENDP	

;**************************************************************************
;*
;*	AddressABData
;*
;*	This routine sends the address byte on the Access.bus
;*
;*	Entry::
;*	  AH - slave address
;*	  BX - return address
;*	  BP = number of Access.bus: ACCESS_BUS1_DEVICE or ACCESS_BUS2_DEVICE
;*
;*	Exit:
;*	  Carry flag set as follows
;*	    Set = acknowledge bit = 1
;*	    Clr = acknowledge bit = 0
;*
;*	Destroys:
;*	  AX, BX, CX, DX
;*
;**************************************************************************
AddressABData PROC NEAR PUBLIC
	ror	ebx, 16				; Store return address
	ror	eax, 16				; Store slave address


	; Set STASTRE bit in order to recognize end of
	; address transfer (ACBST.STASTR bit)
	mov	al, NSSIO_ACBCTL1
	NOSTACK	bx, ABBaseRead
	or	ah, 080h
	NOSTACK	bx, ABBaseWrite

	; Write address	
	ror	eax, 16				; Restore slave address
	mov	al, NSSIO_ACBSDA
	NOSTACK	bx, ABBaseWrite

	; Wait for the address transmission to be completed
csAddressABWait:
	mov	al, NSSIO_ACBST
	NOSTACK	bx, ABBaseRead
	test	ah, 38h				; STASTR and BER and NEGACK == 0?
	jz	csAddressABWait			; Wait if no events

	; Check that no bus confict is detected
	test	ah, 20h				; BER == 1
	jnz	csAddressABFailed		; Bus error happened
	test	ah, 10h				; Negative acknowledge?
	jnz	csAddressABAbort		; YES, stop transaction and free the bus

	ror	ebx, 16				; Restore return address
	stc
	jmp	bx
	
csAddressABAbort:
	ror	ebx, 16				; Restore return address
	mov	dx, bx
	jmp	AbortABData

csAddressABFailed:
	ror	ebx, 16				; Restore return address
	jmp BusRecoveryABData
AddressABData ENDP	

;**************************************************************************
;*
;*	BusRecoveryABData
;*
;*	This routine recovere the Access.bus after fails
;*
;*	Entry:
;*	  BP = number of Access.bus: ACCESS_BUS1_DEVICE or ACCESS_BUS2_DEVICE
;*	  BX - return address
;*
;*	Exit:
;*
;*	Destroys
;*	  AX, CX, DX
;*
;**************************************************************************
BusRecoveryABData PROC NEAR PUBLIC
	mov	cx, bx
	ror ecx, 16			; Store BX return address

	; Free STALL after START
	mov	al, NSSIO_ACBCTL1
	NOSTACK	bx, ABBaseRead
	and	ah, 03Fh
	NOSTACK	bx, ABBaseWrite

	; Issue STOP event
	mov	al, NSSIO_ACBCTL1
	NOSTACK	bx, ABBaseRead
	or	ah, 02h
	NOSTACK	bx, ABBaseWrite

	; Clear NEGACK and STASTR
	mov	al, NSSIO_ACBST
	mov	ah, 038h
	NOSTACK	bx, ABBaseWrite

	NOSTACK	si, InitAB

	ror ecx, 16			; Restore BX return address
	mov	bx, cx
	clc	
	jmp	bx
BusRecoveryABData ENDP	

;**************************************************************************
;*
;*	AbortABData
;*
;*	This routine aborts transaction on the Access.bus
;*
;*	Entry:
;*	  BP = number of Access.bus: ACCESS_BUS1_DEVICE or ACCESS_BUS2_DEVICE
;*	  DX - return address
;*
;*	Exit:
;*
;*	Destroys
;*	  AX, DX
;*

⌨️ 快捷键说明

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