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

📄 tail.asm

📁 dos下的网卡驱动程序。支持一般通用网卡
💻 ASM
📖 第 1 页 / 共 2 页
字号:
;   Copyright 1988-1996 Russell Nelson.
;Licensed by Intel for distribution without complete source.

	include	defs.asm

cgroup	group	code,init,_text

code	segment para public 'code'
code	ends

_text	segment para public 'code'
_text	ends

;-> last byte of static memory used by driver-dependent code.
	extrn	end_resident: byte
	extrn	end_free_mem: byte

init	segment para public 'code'
	assume	cs:cgroup, ds:cgroup

	public	is_eisa
is_eisa	db	0			;=0 if ISA, =1 if EISA
	public	is_pci
is_pci	db	0			;=0 if PCI, =1 if PCI
	extrn	sys_features: byte	;bitmask of system features.
	extrn	is_186: byte		;=0 if 808[68], =1 if 80[1234]86.
	extrn	is_286: byte		;=0 if 80[1]8[68], =1 if 80[234]86.
	extrn	is_386: byte		;=0 if 80[12]8[68], =1 if 80[34]86.
	extrn	int_no: byte		;the board's interrupt level.
	extrn	hw_int_no: byte		;the 8259 interrupt level.
	extrn	driver_class: byte	;the class of this driver, per the spec.
	extrn	rcv_modes: word		;count of modes followed by mode handles.

;-> the fixed address of the card.
	extrn	rom_address: byte

;-> the current address of the card.
	extrn	my_address: byte

	extrn	phd_dioa: byte
	extrn	phd_environ: word
	extrn	flagbyte: byte

	include	printnum.asm
	include	decout.asm
	include	digout.asm
	include	crlf.asm
	include	chrout.asm

free_mem	dw	cgroup:end_resident	;allocate memory from here.
;also see memory_to_keep.

	public	malloc
malloc:
;enter with dx = amount of memory desired.
;exit with nc, dx -> that memory, or cy if there isn't enough memory.
	add	dx,free_mem		;make a pointer after that much memory.
	cmp	dx,offset cgroup:end_free_mem	;is it still in the free area?
	ja	malloc_1		;no, we're in trouble.
	xchg	dx,free_mem		;get the pointer back, store ptr->end.
	clc
	ret
malloc_1:
	stc
	ret


end_tail_1	label	byte		; end of the delayed init driver

;usage_msg is of the form "usage: driver [options] <packet_int_no> <args>"
	extrn	usage_msg: byte

options_i_msg	label	byte
db"   -i -- Force driver to report itself as IEEE 802.3 instead of Ethernet II.",CR,LF
options_msg	label	byte
db"   -d -- Delayed initialization.  Used for diskless booting",CR,LF
db"   -n -- NetWare conversion.  Converts 802.3 packets into 8137 packets",CR,LF
db"   -w -- Windows hack, obsoleted by winpkt",CR,LF
db"   -p -- Promiscuous mode disable",CR,LF
db"   -u -- Uninstall",CR,LF
db '$'

;copyright_msg is of the form:
;"Packet driver for the foobar",CR,LF
;"Portions Copyright 19xx, J. Random Hacker".
	extrn	copyright_msg: byte

copyleft_msg	label	byte
 db "Packet driver skeleton copyright 1988-96, Crynwr Software.",CR,LF
 db "Licensed by Intel for distribution without complete source.",CR,LF
 db CR,LF,'$'

no_resident_msg	label	byte
 db CR,LF,"*** Packet driver failed to initialize the board ***",CR,LF,'$'

;parse_args should parse the arguments.
;called with ds:si -> immediately after the entry_point.
	extrn	parse_args: near

;print_parameters should print the arguments.
	extrn	print_parameters: near

	extrn	our_isr: near, their_isr: dword
	extrn	entry_point: byte

eisa_signature	db	"EISA"

system_msg	db	"System: ",'$'
i386_msg	db	"[345]86 processor",'$'
i286_msg	db	"286 processor",'$'
i186_msg	db	"186 processor",'$'
i8088_msg	db	"8088/8086 processor",'$'
mca_msg		db	", Microchannel bus",'$'
eisa_msg	db	", EISA bus",'$'
isa_msg		db	", ISA bus",'$'
two_8259_msg	db	", Two 8259s",'$'
entry_point_name	db	"Packet driver software interrupt is ",'$'
eaddr_msg	db	"My Ethernet address is ",'$'
aaddr_msg	db	"My ARCnet address is ",'$'

already_msg	db	CR,LF,"Error: there is already a packet driver (you may uninstall it using -u) at ",'$'
no_pkint_msg	db	CR,LF,"Error: there is no packet driver at ",'$'
no_pkt_msg	db	CR,LF,"Error: no packet driver found between 0x60 and 0x80",CR,LF,'$'
two_pkts_msg	db	CR,LF,"Error: there are two packets drivers (specify the desired one after -u).",CR,LF,'$'
int_msg		db	CR,LF
		db	"Error: <hardware_irq> should be between 0 and "
int_msg_num	label	word
		db	"15 inclusive", '$'
xt_hd_warn_msg	db	CR,LF,"Warning: the hard disk on an XT usually uses IRQ 5.  Use a different interrupt",CR,LF,'$'
no_ieee_msg	db	CR,LF,"Error: this driver doesn't implement both IEEE 802.3 and Ethernet II",CR,LF,'$'
terminated_msg	db	"Uninstall completed",'$'

handle		dw	?

entry_point_fnd	db	0
bogus_type	db	0,0		;totally bogus type code.
our_recv:
	xor	di,di
	mov	es,di
	retf

	public	etopen_diagn
etopen_diagn	db	0		; errorlevel from etopen if set

;etopen should initialize the device.  If it needs to give an error, it
;can issue the error message and quit to dos.
	extrn	etopen: near

memory_to_keep	dw	cgroup:end_resident	;keep at least this much memory.
;also see free_mem.

already_error:
	mov	dx,offset cgroup:already_msg
already_error_1:
	mov	di,offset cgroup:entry_point
	call	print_number
	mov	ax,4c05h		; give errorlevel 5
	int	21h

usage_error:
	mov	dx,offset cgroup:usage_msg
	mov	ah,9
	int	21h
	mov	dx,offset cgroup:options_msg
	cmp	word ptr driver_class,BLUEBOOK + IEEE8023*256	;both present?
	jne	error
	mov	dx,offset cgroup:options_i_msg
	public	error
error:
	mov	ah,9
	int	21h
	mov	ax,4c0ah		; give errorlevel 10
	int	21h

;;;	include	timeout.asm

	public	start_1
start_1:
	cld

	mov	dx,offset cgroup:copyright_msg
	mov	ah,9
	int	21h

	mov	dx,offset cgroup:copyleft_msg
	mov	ah,9
	int	21h

	mov	dx,offset cgroup:branding_msg
	mov	ah,9
	int	21h

;** Identify the bus type (PCI, EISA, 8-bit ISA, 16-bit ISA, MCA)

	xor	cx,cx
	xor	dx,dx
	mov	ax,0b101h		;PCI BIOS present?
	int	1ah
	jc	not_pci
	cmp	dx,'CP'
	jne	not_pci
	inc	is_pci			;yes.
not_pci:

	mov	dx,0f000h		;ROM segment
	mov	es,dx
	mov	di,0ffd9h
	mov	si,offset cgroup:eisa_signature
	mov	cx,2
	repe	cmpsw
	jne	not_eisa
	inc	is_eisa
not_eisa:

;
; Get the feature byte (if reliable) so we can know if it is a microchannel
; computer and how many interrupts there are.
;
	mov	ah,0c0h
	int	15h			; es:bx <- sys features block
	jc	look_in_ROM		; error, must use rom.
	or	ah,ah
	jnz	look_in_ROM
	mov	dx,es:[bx]		; # of feature bytes
	cmp	dx,4			; do we have the feature byte we want?
	jae	got_features		;yes.
look_in_ROM:
	cmp	byte ptr es:[0fffeh],0fch;is this an AT?
	jne	identified		;no.
	or	sys_features,TWO_8259	; ATs have 2nd 8259
	jmp	short identified	; assume no microchannel
got_features:
	mov	ah,es:[bx+2]		; model byte
	cmp	ah,0fch
	je	at_ps2
	ja	identified		; FD, FE and FF are not ATs
	cmp	ah,0f8h
	je	at_ps2
	ja	identified		; F9, FA and FB are not ATs
	cmp	ah,09ah
	jbe	identified		; old non-AT Compacs go here
at_ps2:					; 9B - F8 and FC are assumed to
	mov	ah,es:[bx+5]		;   have reliable feature byte
	mov	sys_features,ah
identified:

;Determine the processor type.  The 8088 and 8086 will actually shift ax
;over by 33 bits, while the 80[123]86 use a shift count mod 32.
	mov	cl,33
	mov	ax,0ffffh
	shl	ax,cl			;186 or better?
	jz	processor_identified	;no.
	mov	is_186,1

	push	sp
	pop	ax
	cmp	ax,sp			;286 or better?
	jne	processor_identified	;no.
	mov	is_286,1

	pushf
	pop	ax
	or	ax,7000h		;the 386 lets us set these bits
	push	ax
	popf				;this should be a real popf.
	pushf
	pop	ax
	test	ax,7000h		;did the bits get set?
	je	processor_identified
	mov	is_386,1

processor_identified:

	mov	si,offset cgroup:phd_dioa+1
	call	skip_blanks		;end of line?
	cmp	al,CR
	je	usage_error_j_1

chk_options:
	call	skip_blanks
	cmp	al,'-'			; any options?
	jne	no_more_opt
	inc	si			; skip past option char
	lodsb				; read next char
	or	al,20h			; convert to lower case
	cmp	al,'d'
	jne	not_d_opt
	or	flagbyte,D_OPTION
	jmp	chk_options
not_d_opt:
	cmp	al,'n'
	jne	not_n_opt
	or	flagbyte,N_OPTION
	jmp	chk_options
not_n_opt:
	cmp	al,'w'
	jne	not_w_opt
	or	flagbyte,W_OPTION
	jmp	chk_options
not_w_opt:
	cmp	al,'p'
	jne	not_p_opt
	cmp	rcv_modes,6		;do they even *have* a promiscuous mode?
	jbe	chk_options		;no.
	mov	rcv_modes+2[6*2],0	;yes, nuke it.
	jmp	chk_options
not_p_opt:
	cmp	al,'u'
	jne	not_u_opt
	or	flagbyte,U_OPTION
	jmp	chk_options
not_u_opt:
	cmp	al,'i'
	jne	not_i_opt
	cmp	word ptr driver_class,BLUEBOOK + IEEE8023*256	;both present?
	mov	dx,offset cgroup:no_ieee_msg
	jne	usage_error_j_1		;no - give error
	mov	word ptr driver_class,IEEE8023 + BLUEBOOK*256	;yes, swap them.
	jmp	chk_options
not_i_opt:
usage_error_j_1:
	jmp	usage_error
no_more_opt:

	mov	di,offset cgroup:entry_point	;parse the packet interrupt number
	call	get_number		;  for them.

	test	flagbyte,U_OPTION	;should we terminate the driver?
	jne	terminate

⌨️ 快捷键说明

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