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

📄 tail.asm

📁 dos下的网卡驱动程序。支持一般通用网卡
💻 ASM
📖 第 1 页 / 共 2 页
字号:
	jmp	not_terminate
terminate:

	cmp	entry_point,0		;did they ask for the default?
	jne	terminate_int_ok	;no, run with it.

	mov	entry_point,60h
terminate_check_int:
	call	verify_packet_int
	jc	terminate_check_int_1
	jne	terminate_check_int_1
	cmp	entry_point_fnd,0	;did we already find one?
	jne	terminate_check_int_2	;yes, it's ambiguous - give error.
	mov	al,entry_point		;no, remember it.
	mov	entry_point_fnd,al
terminate_check_int_1:
	inc	entry_point		;go look at the next one
	cmp	entry_point,80h
	jbe	terminate_check_int	;keep going to the end.

	mov	al,entry_point_fnd	;restore the last one found.
	mov	entry_point,al
	cmp	entry_point_fnd,0	;did we find one?
	jne	terminate_int_ok	;yes.
	mov	dx,offset cgroup:no_pkt_msg	;no packet drivers installed!
	jmp	error
terminate_check_int_2:
	mov	dx,offset cgroup:two_pkts_msg	;two packet drivers - which one??
	jmp	error

terminate_int_ok:
	call	verify_packet_int	;is the one they specified acceptable?
	jnc	terminate_1		;no, it's not in range.
	jmp	error
terminate_1:
	je	terminate_2		;go if we found a signature.
	mov	dx,offset cgroup:no_pkint_msg	;no packet driver there.
	jmp	already_error_1
terminate_2:

	mov	their_isr.offs,bx
	mov	their_isr.segm,es

	mov	ax,1ffh			;driver_info
	pushf
	cli
	call	their_isr
	call	fatal_error
	movseg	ds,cs

	mov	ah,2			;access_type
	mov	al,ch			;their class from driver_info().
	mov	bx,dx			;their type from driver_info().
	mov	dl,cl			;their number from driver_info().
	mov	cx,2			;use type length 2.
	mov	si,offset cgroup:bogus_type
	movseg	es,cs
	mov	di,offset cgroup:our_recv
	pushf
	cli
	call	their_isr
	call	fatal_error
	mov	handle,ax

	mov	ah,5			;terminate the driver.
	mov	bx,handle
	pushf
	cli
	call	their_isr
	jnc	now_close
	call	print_error
	mov	ah,3			;release_type
	mov	bx,handle
	pushf
	cli
	call	their_isr
	int	20h
now_close:
	mov	dx,offset cgroup:terminated_msg
	mov	ah,9
	int	21h
	int	20h

usage_error_j_2:
	jmp	usage_error
not_terminate:

	call	parse_args
	jc	usage_error_j_2

	call	skip_blanks		;end of line?
	cmp	al,CR
	jne	usage_error_j_2

	call	verify_packet_int
	jnc	packet_int_ok
	jmp	error
packet_int_ok:
	jne	packet_int_unused
	jmp	already_error		;give an error if there's one there.
packet_int_unused:
;
; Verify that the interrupt number they gave is valid.
;
	cmp	int_no,15		;can't possibly be > 15.
	ja	int_bad
	test	sys_features,TWO_8259	; 2nd 8259 ?
	jnz	int_ok			;yes, no need to check for <= 7.
	mov	int_msg_num,'7'+' '*256	;correct the error message, just in case.
	cmp	int_no,7		;make sure that the packet interrupt
	jbe	int_ok_7		;  number is in range.
int_bad:
	mov	dx,offset cgroup:int_msg
	jmp	error
int_ok_7:
	cmp	int_no,5		;Are they trying to use irq 5 on an XT?
	jne	int_ok			;no.

	push	ds
	mov	ax,40h
	mov	ds,ax
	mov	al,ds:[75h]		;get the number of hard disks.
	pop	ds

	or	al,al			;do they have one?
	je	int_ok			;unbelievably, no.
	mov	dx,offset cgroup:xt_hd_warn_msg
	mov	ah,9
	int	21h
int_ok:

;
; Map IRQ 2 to IRQ 9 if needed.
;
	test	sys_features,TWO_8259	; 2nd 8259 ?
	je	no_mapping_needed	;no, no mapping needed
	cmp	int_no,2		;map IRQ 2 to IRQ 9.
	jne	no_mapping_needed
	mov	int_no,9
no_mapping_needed:

; If they chose the -d option, don't call etopen when we are loaded,
; but when we are called for the first time
;
; Save part of the tail, needed by delayed etopen
	test	flagbyte,D_OPTION
	jz	open_now
	mov	memory_to_keep,offset cgroup:end_tail_1	; save first part of tail
	jmp	delayed_open_1
open_now:
	or	flagbyte,CALLED_ETOPEN
	call	etopen			;init the driver.  If any errors,
					;this routine returns cy.
	jnc	yes_resident
	jmp	no_resident

yes_resident:
	mov	si,offset cgroup:rom_address	;copy their original address to
	movseg	es,ds
	mov	di,offset cgroup:my_address	;  their current address.
	mov	cx,MAX_ADDR_LEN/2
	rep	movsw

; tell them what kind of system they have.
	mov	dx,offset cgroup:system_msg
	mov	ah,9
	int	21h

	mov	dx,offset cgroup:i386_msg
	cmp	is_386,0
	jne	have_processor
	mov	dx,offset cgroup:i286_msg
	cmp	is_286,0
	jne	have_processor
	mov	dx,offset cgroup:i186_msg
	cmp	is_186,0
	jne	have_processor
	mov	dx,offset cgroup:i8088_msg
have_processor:
	mov	ah,9
	int	21h

	mov	dx,offset cgroup:mca_msg
	test	sys_features,SYS_MCA
	jne	have_bus
	mov	dx,offset cgroup:eisa_msg
	cmp	is_eisa,0
	jne	have_bus
	mov	dx,offset cgroup:isa_msg
have_bus:
	mov	ah,9
	int	21h

	test	sys_features,TWO_8259
	je	only_one_8259
	mov	dx,offset cgroup:two_8259_msg
	mov	ah,9
	int	21h
only_one_8259:

	call	crlf

	mov	di,offset cgroup:entry_point
	mov	dx,offset cgroup:entry_point_name
	call	print_number

	call	print_parameters	;echo our parameters.

	cmp	driver_class,BLUEBOOK	;Blue Book Ethernet?
	je	print_eaddr		;yes.
	cmp	driver_class,IEEE8023	;IEEE 802.3 Ethernet?
	jne	print_addr_2		;no, don't print what we don't have.

print_eaddr:
	mov	dx,offset cgroup:eaddr_msg
	mov	ah,9
	int	21h

	mov	si,offset cgroup:rom_address
	call	print_ether_addr

	call	crlf

print_addr_2:

	cmp	driver_class,8		;ARCnet?
	jne	print_addr_3		;no, don't print what we don't have.

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

	mov	al,rom_address
	mov	cl,' '			;Don't eliminate leading zeroes.
	call	byteout

	call	crlf

print_addr_3:
delayed_open_1:
	mov	ah,35h			;remember their packet interrupt.
	mov	al,entry_point
	int	21h
	mov	their_isr.offs,bx
	mov	their_isr.segm,es

	mov	ah,25h			;install our packet interrupt
	mov	dx,offset cgroup:our_isr
	int	21h

	mov	ah,49h			;free our environment, because
	mov	es,phd_environ		;  we won't need it.
	int	21h

	mov	bx,1			;get the stdout handle.
	mov	ah,3eh			;close it in case they redirected it.
	int	21h

	test	flagbyte,D_OPTION
	jne	f_release_type_1	;no.
	cmp	rcv_modes+2[3*2],0	;does mode 3 exist?
	je	f_release_type_1	;no.
	call	rcv_modes+2[3*2]	;  call it.
f_release_type_1:

	mov	dx,memory_to_keep	;keep the greater of this and
	cmp	dx,free_mem		;  free_mem.
	jae	go_resident
	mov	dx,free_mem
go_resident:
	add	dx,0fh			;round up to next highest paragraph.
	mov	cl,4
	shr	dx,cl
	mov	ah,31h			;terminate, stay resident.
	mov	al,etopen_diagn		; errorlevel (0 - 9, just diagnostics)
	int	21h

no_resident:
	mov	ah,9			;print their error message.
	int	21h

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

	mov	ax,4c00h + 32		; give errorlevel 32
	cmp	al,etopen_diagn
	ja	no_et_diagn		; etopen gave specific reason?
	mov	al,etopen_diagn		; yes, use that for error level
no_et_diagn:
	int	21h

; 			Suggested errorlevels:
;
; _____________________  0 = normal
; 			 1 = unsuitable memory address given; corrected
; In most cases every-	 2 = unsuitable IRQ level given; corrected
; thing should work as	 3 = unsuitable DMA channel given; corrected
; expected for lev 1-5	 4 = unsuitable IO addr given; corrected (only 1 card)
; _____________________	 5 = packet driver for this int # already loaded
; External errors, when	20 = general cable failure (but pkt driver is loaded)
; corrected normal	21 = network cable is open             -"-
; operation starts	22 = network cable is shorted          -"-
; _____________________ 23 = 
; Packet driver not	30 = usage message
; loaded. A new load	31 = arguments out of range
; attempt must be done	32 = unspecified device initialization error
;			33 = 
;			34 = suggested memory already occupied
;			35 = suggested IRQ already occupied
;			36 = suggested DMA channel already occupied
;			37 = could not find the network card at this IO address


	include	verifypi.asm
	include	getnum.asm
	include	getdig.asm
	include	skipblk.asm
	include	printea.asm
	include	pkterr.asm
	include	getenv.asm

	public	branding_msg
branding_msg	db	'$'

init	ends

	end

⌨️ 快捷键说明

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