home *** CD-ROM | disk | FTP | other *** search
- ;
- ; The Greenleaf Comm Library
- ;
- ; Copyright (C) 1990 Greenleaf Software Inc. All Rights Reserved.
- ;
- .xlist
- include model.h
- include prologue.h
- include asiports.equ
- .list
-
- extrn serv0:far
-
- dseg _commlib
- extrn inttbl:word
- endds
-
- pseg _asinew
- ;==>-- int _asifirst(port,latch,p)
- ; int port,latch;
- ; struct PORT_TABLE *p;
- ;
- ; Responsible for taking information from the table and
- ; "Setting up the machine"
- ;
- cproc _asifirst,,_asifirs,,,<DS,ES,NOSI,EXIT,OKEXIT>
- if _LDATA
- lds bx,parm3_
- else
- mov bx,parm3_
- endif
- mov ax,ds
- mov es,ax ;es=ds
- mov cx,[bx+base_8250] ;check for non 0 8250 i/o address
- or cx,cx
- mov ax,ASINVPAR
- jnz ok8250
- funcexit ;exit function AX=Error code
- ok8250: mov dx,cx ;read character from 8250
- in al,dx
- KILL_TIME
- mov dx,INTID
- add dx,cx ;see if there is really an 8250 by
- in al,dx ;looking at the interrupt id register
- KILL_TIME
- and al,0f8h ;bits 3-7 should be 0 if installed
- mov ax,ASNO8250
- jz in8250
- funcexit ;exit function, AX = Error code
- in8250: cld ;strings do auto-increment
- xor ah,ah
- lea di,[bx+p_8250lcr] ;es:di point to save area for 8250
- mov dx,LCREG
- add dx,cx ;dx=line control register address
- in al,dx
- KILL_TIME
- stosw ;save in structure
- and al,not DLAB ;**2.10
- out dx,al ;set DLAB = 0 ;**2.10
- KILL_TIME
- inc dx ;dx=modem control register port
- in al,dx
- KILL_TIME
- stosw ;save in structure
- test al,RTS ;is RTS asserted?
- jz rtslow
- or word ptr[bx+chst_bits],RTSACTIVE
- ;update status bit in structure
- rtslow: mov dx,INTER
- add dx,cx ;dx=interrupt enable register port
- in al,dx
- KILL_TIME
- stosw ;read and save it.
- xor al,al ;shut down any interrupt enables
- out dx,al
- KILL_TIME
- mov dx,LCREG ;now set dlab to 1 so we can read
- add dx,cx ;the baud rate divisor
- in al,dx
- KILL_TIME
- or al,DLAB
- out dx,al
- KILL_TIME
- mov dx,cx ;read least significant byte of
- in al,dx ;baud rate divisor
- KILL_TIME
- stosw ;and save in structure
- inc dx
- in al,dx ;read most significant byte
- KILL_TIME
- stosw
- mov dx,LCREG ;set dlab to 0 once and for all!
- add dx,cx
- in al,dx
- KILL_TIME
- and al,not DLAB
- out dx,al
- KILL_TIME
- mov dx,LSREG
- add dx,cx
- in al,dx
- KILL_TIME
- xor ah,ah ;set up line status field in structure
- mov [bx+line_stat],ax
- mov dx,MSREG ;do the same thing with modem_stat
- add dx,cx
- in al,dx
- KILL_TIME
- mov [bx+modem_stat],ax
- and byte ptr parm2_,1
- jz no8259 ;if parameter = 0 then don't set
- mov ax,[bx+intrpt_num] ;get interrupt number to al
- or al,al ;see if we have one to set
- jz novect ;if not don't bother it
- mov ah,35h
- mov di,bx ;stash bx for dos function 35h
- int 21h ;get what is at interrupt vector
- xchg bx,di ;bx points back to structure, es:di^
- mov word ptr[bx+p_vector],di ;save offset
- mov word ptr[bx+p_vector+2],es ;&segment
- mov ax,[bx+intrpt_num] ;get interrupt number to al
- push ds
- push bx
- ifdef DSNOTHING
- mov bx,__commlib_DATA
- else
- mov bx,DGROUP
- endif
- mov ds,bx
- mov bl,parm1_ ;get port number for this structure
- xor bh,bh
- shl bx,1 ;*2;
- mov dx,inttbl[bx] ;get address of this port's routine
- mov bx,seg serv0
- mov ds,bx ;ds=cs
- mov ah,25h
- int 21h ;set interrupt vector
- pop bx
- pop ds
- novect: mov cx,[bx+irq_8259] ;prepare to enable 8259
- or cx,cx ;check for 0
- jz no8259
- mov al,1
- shl al,cl ;shift 1 bit into correct position
- not al
- mov cl,al
- mov dx,[bx+port_8259] ;get i/o address of 8259
- inc dx ;++port
- in al,dx
- KILL_TIME
- xor ah,ah
- mov [bx+p_8259],ax ;save previous setting
- and al,cl ;enable correct bit
- out dx,al ;and set in 8259
- KILL_TIME
- no8259:
- mov cx,[bx+base_8250]
- mov dx,LSREG ;read line status register
- add dx,cx ;and store starting variables in struc
- in al,dx
- KILL_TIME
- push ax ;save for now
- mov ah,al
- not ah
- mov [bx+line_stat],ax
- mov dx,MSREG ;read modem status register
- add dx,cx
- in al,dx
- KILL_TIME
- mov dl,al ;save modem status register in dl
- mov ah,al
- not ah
- mov [bx+modem_stat],ax ;save in structure
- and dl,0f0h ;mask bits 0-3 out
- pop ax ;get line status back to al
- and al,0eh ;mask un wanted bits
- or al,dl ;merge the two
- xor ah,ah
- mov [bx+wide_stat],ax ;save in structure
- mov dx,cx ;read receiver to clear possible int.
- in al,dx
- KILL_TIME
- mov dx,INTID
- add dx,cx
- in al,dx ;read interrupt I.D. register
- KILL_TIME
- mov dx,INTER ;enable modem/line status ;**2.10
- add dx,cx
- mov al,ENRXS+ENMS
- cli
- out dx,al
- KILL_TIME
- out dx,al ;do it twice (per National) ;**2.10
- KILL_TIME
- sti
- mov dx,MCREG ;enable out2
- add dx,cx
- in al,dx ;read what's there first
- KILL_TIME
- or al,OUT2 ;assert OUT2
- out dx,al
- KILL_TIME
- xor ax,ax ;Exit function with success
- cproce
- endps
- end
-
-