|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T p
Length: 8984 (0x2318) Types: TextFile Names: »pktdd.asm«
└─⟦9ae75bfbd⟧ Bits:30007242 EUUGD3: Starter Kit └─⟦349c9a24c⟧ »EurOpenD3/network/ka9q/pktd.tar.Z« └─⟦613ecc654⟧ └─⟦this⟧ »./src/pktdd.asm«
; @@(#)pktdd.asm.u 1.2 2/7/90\r ;\r ; Copyright (c) 1989, 1990 Sun Microsystems, Inc.\r ;\r \r ;\r ;macros\r status macro state,err,rc\r ifidn <state>,<done>\r or es:word ptr srh_sta_fld[bx],0100h\r endif\r ifidn <state>,<busy>\r or es:word ptr srh_sta_fld[bx],0200h\r endif\r ifidn <err>,<error>\r or es:word ptr srh_sta_fld[bx],8000h\r endif\r ifnb <rc>\r or es:word ptr srh_sta_fld[bx],rc\r endif\r endm\r \r ; parameter block offsets\r \r srh equ 0 ;static request header start\r srh_len equ 13 ; " " " length\r srh_len_fld equ srh ; " " " " field\r srh_ucd_fld equ srh+1 ; " " " unit code field\r srh_ccd_fld equ srh+2 ; " " " command code field\r srh_sta_fld equ srh+3 ; " " " status field\r srh_res_fld equ srh+5 ; " " " reserved area field\r \r \r ;\r ; ioctl i/o structure\r ;\r \r ioc_req struc\r \r ioc_res db 13 dup (?) ; srh area\r ioc_media_b db ?\r ioc_addr dd ?\r ioc_count dw ?\r ioc_sector dw ?\r \r ioc_req ends\r \r \r ; init\r \r units equ srh+srh_len\r units_len equ 1\r br_addr_0 equ units+units_len\r br_addr_1 equ br_addr_0+2\r br_addr_len equ 4\r bpb_ptr_off equ br_addr_0+br_addr_len\r bpb_ptr_seg equ bpb_ptr_off+2\r \r \r end_addr_off equ 14\r end_addr_seg equ 16\r \f \r pktd_driver proc far\r begin:\r start equ $\r \r ; device header\r next_dev dd -1 ; pointer to next device\r attribute dw 0c000h ; character device with ioctl\r strategy dw dev_strategy ; ptr to dev strategy\r interrupt dw dev_int ; ptr to dev interrupt\r dev_name db 'NFSLINK1' ; ethernet device driver\r \r public ethinit_offset\r \r ethinit_offset dw offset ethinit\r ethinit_segment dw 0\r ethsend_offset dw offset ethsend\r ethsend_segment dw 0\r \r rh_off dw ? ; request header offset\r rh_seg dw ? ; request header segment\r \r matchtable db 'i' ;interrupt number\r db 'm' ;shared memory offset base (32K)\r \r matchnum equ $-matchtable ;maximum number of entries\r \r routinetable dw intnumchange ;change default int num\r dw memoffchange ;change default shared memory base\r \r \r \r ; function table\r funtab label byte\r dw init ;initialization\r dw media_check\r dw build_bpb\r dw ioctl_in\r dw input ; read\r dw nd_input\r dw in_stat ; input status\r dw in_flush\r dw output ; write\r dw out_verify ; write w verify\r dw out_stat\r dw out_flush\r dw ioctl_out\r \r init_msg db 10,13,'Sun Microsystems PC-NFS Packet Driver Interface'\r db 10,13\r db 'Version 3.2'\r db 10,13\r db 'Copyright (c) 1989, 1990 Sun Microsystems, Inc.'\r db 10,13\r db 'This driver may be freely copied, but not resold. It is NOT a supported'\r db 10,13\r db 'Sun Microsystems product, and is provided "as is", with no warranty.'\r db 10,13\r db 'It is designed to work with drivers conforming to Version 1.08 of the'\r db 10,13\r db 'FTP Software Packet Driver Specification.'\r db 10,13\r db 10,13\r db '*** This version will support NetWare coexistence when used with ***'\r db 10,13\r db '*** an appropriate NetWare packet driver. ***'\r db 10,13\r db 10,13,'$'\r page\r \r ; device strategy\r dev_strategy:\r mov rh_seg, es ; save segment of request header\r mov rh_off, bx ; save offset of rh\r ret\r \r \r ; device interrupt handler\r dev_int:\r ; preserve machine state on entry\r \r cld\r push ds\r push es\r push ax\r push bx\r push cx\r push dx\r push di\r push si\r \r ; do the branch according to the function passed\r mov es,cs:rh_seg ;get request header\r mov bx,cs:rh_off\r mov al, es:[bx]+2 ; get function byte\r \r shl al, 1 ; get offset into table\r lea di, funtab ; get address of function table\r xor ah, ah\r add di, ax\r jmp word ptr [di]\r \r init:\r push cs\r pop dx\r mov ethinit_segment, dx ; save segment for long pointer\r mov ethsend_segment, dx\r \r extrn last_statement:near\r \r mov ax, offset last_statement\r mov cl, 4\r shr ax, cl\r add ax, dx\r inc ax\r xor dx, dx\r mov es:[bx][end_addr_off], dx\r mov es:[bx][end_addr_seg], ax\r call parsecmdline\r status done,noerror,0 ; set status word (done, noerror)\r push dx\r push ax\r mov dx, offset init_msg\r mov ah, 9\r int 21h\r \r pop ax\r pop dx\r jmp exit\r \r \r ; the following are not supported\r output:\r media_check:\r build_bpb:\r nd_input:\r in_stat:\r in_flush:\r out_stat:\r out_flush:\r out_verify:\r input:\r \r status done, error, 02h ; device not ready\r jmp exit\r \r ;common exit\r exit:\r pop si\r pop di\r pop dx\r pop cx\r pop bx\r pop ax\r pop es\r pop ds\r ret\r \r parsecmdline proc near\r \r ; this proc is called at init time to parse the command line\r ; initially only the number of files is passed\r ; on entry es:bx point to the request header\r \r push es\r push bx ;save pointers to request header\r les di,es:dword ptr bpb_ptr_off[bx] ;point to char after 'device =' in config.sys\r cld\r getnextitem:\r mov cx,-1 ;max\r mov al,'/' ;look for /\r s_loop:\r scasb ;look for one\r jz foundslash\r cmp es:byte ptr [di-1],0dh ;cr ends the line\r jz noslash\r cmp es:byte ptr [di-1],0ah ;line feed also ends it\r jz noslash\r loop s_loop\r jmp short noslash\r foundslash:\r call getcharacter ;get next non blank character\r jnc gotchar ;if carry set then eol reached\r jmp noslash\r gotchar:\r cmp al,'A' ;see if upper case\r jb lower ;must be digit or trash\r cmp al,'Z'\r ja lower\r or al,20h ;convert to lower\r lower:\r push es\r push di ;save pointer\r push cs\r pop es ;look for match\r mov di,offset matchtable\r mov cx,matchnum ;get number of entries\r repne scasb ;try to find a match\r pop di\r pop es ;get pointer back\r jnz getnextitem ;nothing so try again\r sub cx,matchnum ;find the right one\r neg cx\r dec cx\r mov bx,cx\r shl bx,1\r call cs:routinetable[bx] ;call routine\r jnc getnextitem\r noslash:\r pop bx ;get header ptr back\r pop es\r ret ;return if eol\r \r parsecmdline endp\r ;\r \r \r getcharacter proc near\r \r ; this procedure will get a character from ES:DI and inc di\r ; if the character is a terminator carry will be set\r ; and the pointer will point at the terminator character\r ; if the character is a non blank the character is returned\r ; in al with carry clear. Pointer will point to next character\r ; Blanks and tabs are skipped\r \r jcxz term\r mov al,es:[di] ;get the character\r cmp al,9 ;tab\r je blank\r cmp al,' ' ;space\r je blank\r cmp al,0dh ;cr\r je term\r cmp al,0ah ;lf\r je term\r cmp al,1ah ;end of file\r je term\r inc di ;point to next character\r dec cx\r clc\r ret ;and return to caller\r blank:\r inc di ;point to next\r dec cx\r jmp getcharacter ;and get another\r \r term:\r stc\r ret ;got a terminator\r \r getcharacter endp\r \r getnumber proc near\r \r ; this procedure will obtain a number from the input buffer\r ; pointed to by ES:DI\r ; value is returned in BX\r \r sub bx,bx\r mov cx,-1 ;max characters in num\r gn0:\r call getcharacter ;get a character\r jnc gn1 ;got one\r ret ;terminator reached\r gn1:\r cmp al,'/' ; if slash, we are done\r je end_gn\r cmp al,'0' ;must be digit\r jb numerror\r cmp al,'9'\r ja numerror\r push ax\r mov al,10\r mul bl ;bump up bl\r mov bx,ax\r pop ax\r sub al,'0' ;convert to binary\r add bl,al\r jmp gn0 ;try for more\r \r numerror:\r ret ;return with carry set\r \r end_gn:\r dec di ;set di to point to '/' for main loop\r ret\r \r getnumber endp\r \r intnumchange proc near\r \r clc\r ret\r \r intnumchange endp\r \r \r \r memoffchange proc near\r \r clc\r ret\r memoffchange endp\r \r \r gethnumber proc near\r \r ; this procedure will obtain a number from the input buffer\r ; pointed to by ES:DI\r ; value is returned in BX\r \r sub bx,bx\r mov cx,-1 ;max characters in num\r ghn0:\r call getcharacter ;get a character\r jnc ghn1 ;got one\r ret ;terminator reached\r ghn1:\r cmp al,'/' ; if slash, we are done\r je end_ghn\r cmp al,'0' ;must be digit\r jb numbererr\r cmp al,'9'\r jb ok_num\r or al,20H ; should be a character, toupper it\r cmp al,'a'\r jb numbererr\r cmp al,'f' ; 'f' is max legal hex char\r ja numbererr\r sub al,57H ; subtract enough so 'a' becomes 0x0a\r jmp ok_letter\r \r ok_num:\r sub al,'0'\r \r ok_letter:\r shl bx,1 ; move a nibble\r shl bx,1\r shl bx,1\r shl bx,1\r or bl,al ; or in al, the new char\r jmp ghn0 ;try for more\r \r numbererr:\r mov bx,0 ; make sure return with illegal number\r ret ;return with carry set\r \r end_ghn:\r dec di ;set di to point to '/' for main loop\r ret\r \r gethnumber endp\r \r \r \r \r \r ; i/o control\r ;\r \r ;\r ; to use i/o control:\r ;\r ; 1. write an ioctl string to this device containing\r ; one (1) byte; this byte is a function code.\r ;\r ; 2. read the ioctl string returned - it is four bytes, and\r ; is the double word pointer selected by the function code\r ; you just wrote in #1.\r ;\r \r \r ioctl_out:\r \r status done, noerror, 0\r jmp exit\r \r \r ioctl_in:\r status done, noerror, 0\r jmp exit\r \r \r \r \r pktd_driver endp\r