     1                                  ;	PAGE ,132 ;
     2                                  ;	TITLE MSDISK - BIOS
     3                                  	%warning out: ...MSDISK.ASM
     3          ******************       warning: out: ...MSDISK.ASM [-w+user]
     4                                  
     5                                  ;==============================================================================
     6                                  ;REVISION HISTORY:
     7                                  ;AN000 - New for DOS Version 4.00 - J.K.
     8                                  ;AC000 - Changed for DOS Version 4.00 - J.K.
     9                                  ;AN00x - PTM number for DOS Version 4.00 - J.K.
    10                                  ;==============================================================================
    11                                  ;AN001; d24 Multi Track enable/disable command in CONFIG.SYS	    6/27/87 J.K.
    12                                  ;AN002; d9  Double word MOV instruction 			    7/1/87  J.K.
    13                                  ;AN003: d25 Change DASD ERP to that recommended by Storage systems  7/28/87 J.K.
    14                                  ;AN004; D113 Disable I/O access to unformatted media		    9/03/87 J.K.
    15                                  ;AN005; P985 Allow I/O access to unformatted media		    9/14/87 J.K.
    16                                  ;AN006; P1535 Disallow I/O access to unformatted media.		   10/15/87 J.K.
    17                                  ;	(Give the user to control this - Generic IOCTL subfunction 64h/44h
    18                                  ;AN007; p2828 Do not retry for multi-track format request	   12/08/87 J.K.
    19                                  ;AC008; p3197 Should reset change line after BPB set in BDS table  01/21/88 J.K.
    20                                  ;AN009; p3349 Should retry at hard file timeout error		   02/03/88 J.K.
    21                                  ;AN010; p4696 ECC error handler should cover PC ATs for CMC disks  05/04/88 J.K.
    22                                  ;AN011; p5034 Possible virgin hard file problem with direct INT 13 06/03/88 J.K.
    23                                  ;AN012; P5049 Attempt to write at DISK BASE table in ROM BIOS	   06/06/88 J.K.
    24                                  ;AN013; P5055 Diskcopy fails (Regression of P5049)		   06/09/88 J.K.
    25                                  ;==============================================================================
    26                                  
    27                                  ;for testing, set itest to 1.  So as MSBIO1.ASM.
    28                                  	itest equ 0
    29                                  	EXTRN NUMERR:ABS		;MSDATA
    30                                  
    31                                  	%include "ddataseg.nas"
     1                              <1> 
     2                              <1> %include "lmacros3.mac"
     1                              <2> [list -]
     1          ******************  <2>  warning: redefining multi-line macro `struc' [-w+pp-macro-redef-multi]
    14                              <3> [list -]
    14                              <2> [list -]
     3                              <1> 
     4                              <1> addsection DOSSTART, align=16 PUBLIC class=DOSSTART
     5                              <1> ; (no prior section) ; DOSSTART		ENDS
     6                              <1> 
     7                              <1> addsection DOSSTARTJUMP, align=1 PUBLIC class=START
     8                              <1> ; (no prior section) ; DOSSTARTJUMP		ENDS
     9                              <1> 
    10                              <1> addsection CONSTANTS, align=2 PUBLIC class=CONST
    11                              <1> ; (no prior section) ; CONSTANTS	ENDS
    12                              <1> 
    13                              <1> addsection DATA, align=2 PUBLIC class=DATA
    14                              <1> ; (no prior section) ; DATA		ENDS
    15                              <1> 
    16                              <1> addsection TABLE, align=2 PUBLIC class=TABLE
    17                              <1> ; (no prior section) ; TABLE		ENDS
    18                              <1> 
    19                              <1> addsection DOSDATATABLE, align=2 PUBLIC class=DOSDATACODE
    20                              <1> ; (no prior section) ; DOSDATATABLE		ENDS
    21                              <1> 
    22                              <1> addsection DOSDATACODE, align=1 PUBLIC class=DOSDATACODE
    23                              <1> ; (no prior section) ; DOSDATACODE		ENDS
    24                              <1> 
    25                              <1> addsection DOSBIODATA, align=2 PUBLIC class=DOSBIODATA
    26                              <1> 
    27                              <1> addsection LAST, align=16 PUBLIC class=LAST
    28                              <1> ; (no prior section) ; LAST		ENDS
    29                              <1> 
    30                              <1> group DOSGROUP DOSSTART DOSSTARTJUMP CONSTANTS DATA TABLE DOSDATATABLE DOSDATACODE DOSBIODATA LAST
    32                                  	%include "msequ.mac"
     1                              <1> %warning out: MSEQU.INC...
     1          ******************  <1>  warning: out: MSEQU.INC... [-w+user]
     2                              <1> ;==============================================================================
     3                              <1> 
     4                              <1> FTOOBIG 	EQU	80H
     5                              <1> FBIG		EQU	40H
     6                              <1> ROMSTATUS	EQU	1
     7                              <1> ROMREAD 	EQU	2
     8                              <1> ROMWRITE	EQU	3
     9                              <1> ROMVERIFY	EQU	4
    10                              <1> ROMFORMAT	EQU	5
    11                              <1> VID_SIZE	EQU 12
    12                              <1> 
    13                              <1> %include "msbds.mac"    ; VARIOUS EQUATES FOR BDS
     1                              <2> 
     2                              <2> %warning out: MSBDS.INC...
     2          ******************  <2>  warning: out: MSBDS.INC... [-w+user]
     3                              <2> ;	SCCSID = @(#)IBMBDS.ASM 1.9 85/09/16
     4                              <2> ;==============================================================================
     5                              <2> ;REVISION HISTORY:
     6                              <2> ;AN000 - New for DOS Version 4.00 - J.K.
     7                              <2> ;AC000 - Changed for DOS Version 4.00 - J.K.
     8                              <2> ;AN00x - PTM number for DOS Version 4.00 - J.K.
     9                              <2> ;==============================================================================
    10                              <2> ;AN001; D113 Disable I/O access to unformatted media		    9/03/87 J.K.
    11                              <2> ;==============================================================================
    12                              <2> 
    13                              <2> ; VALUES FOR VARIOUS FLAGS IN BDS.FLAGS.
    14                              <2> 
    15                              <2> FNON_REMOVABLE	    EQU     01H 	;FOR NON-REMOVABLE MEDIA
    16                              <2> FCHANGELINE	    EQU     02H 	;IF CHANGELINE SUPPORTED ON DRIVE
    17                              <2> RETURN_FAKE_BPB     EQU     04H 	; WHEN SET, DON'T DO A BUILD BPB
    18                              <2> 					; JUST RETURN THE FAKE ONE
    19                              <2> GOOD_TRACKLAYOUT    EQU     08H 	; THE TRACK LAYOUT HAS NO FUNNY SECTORS
    20                              <2> ; FCHANGED_BY_FORMAT  EQU	    08H
    21                              <2> FI_AM_MULT	    EQU     10H 	;IF MORE THAN ONE LOGICAL FOR THIS PHYSICAL
    22                              <2> FI_OWN_PHYSICAL     EQU     20H 	;SIGNIFY LOGICAL OWNER OF THIS PHYSICAL
    23                              <2> FCHANGED	    EQU     40H 	;INDICATES MEDIA CHANGED
    24                              <2> SET_DASD_TRUE	    EQU     80H 	; SET DASD BEFORE NEXT FORMAT
    25                              <2> FCHANGED_BY_FORMAT  EQU    100H 	;MEDIA CHANGED BY FORMAT
    26                              <2> UNFORMATTED_MEDIA   EQU    200H 	;AN001; Fixed disk only
    27                              <2> F_LBA		equ	400h		; LBA supported
    28                              <2> 
    29                              <2> LBAPACKETSTRUC struc
    30 00000000 ????                <2> lpSize		dw ?
    31 00000002 ????                <2> lpCount		dw ?
    32 00000004 ????????            <2> lpBuffer	dd ?
    33 00000008 ????????????????    <2> lpSector	dd ?,?
    34                              <2> LBAPACKETSTRUC ends
    35                              <2> 
    36                              <2> ;
    37                              <2> ; VARIOUS FORM FACTORS TO DESCRIBE MEDIA
    38                              <2> ;
    39                              <2> FF48TPI 	    EQU     0
    40                              <2> FF96TPI 	    EQU     1
    41                              <2> FFSMALL 	    EQU     2
    42                              <2> FFHARDFILE	    EQU     5
    43                              <2> FFOTHER 	    EQU     7
    44                              <2> 
    45                              <2> BDS_TYPE	STRUC
    46 00000000 ????????            <2> LINK		DD		?	; LINK TO NEXT BDS
    47 00000004 ??                  <2> DRIVENUM	DB		?	; INT 13 DRIVE NUMBER
    48 00000005 ??                  <2> DRIVELET	DB		?	; DOS DRIVE NUMBER
    49 00000006 ????                <2> BYTEPERSEC	DW		?	; NUMBER OF BYTES/SEC
    50 00000008 ??                  <2> SECPERCLUS	DB		?	; SEC PER ALLOCATION UNIT
    51 00000009 ????                <2> RESSEC		DW		?	; NUMBER OF RESERVED SECTORS
    52 0000000B ??                  <2> CFAT		DB		?	; NUMBER OF FATS
    53 0000000C ????                <2> CDIR		DW		?	; NUMBER OF DIRECTORY ENTRIES
    54 0000000E ????                <2> DRVLIM		DW		?	; NUMBER OF SECTORS ON MEDIUM
    55 00000010 ??                  <2> MEDIAD		DB		?	; MEDIA DESCRIPTOR BYTE
    56 00000011 ????                <2> CSECFAT 	DW		?	; NUMBER OF SECTORS/FAT
    57 00000013 ????                <2> SECLIM		DW		?	; SECTORS PER TRACK
    58 00000015 ????                <2> HDLIM		DW		?	; MAX NUMBER OF HEADS
    59 00000017 ????                <2> HIDSEC_L	DW		?	; NUMBER OF HIDDEN SECTORS
    60 00000019 ????                <2> HIDSEC_H	dw		? ;0	;J.K.87
    61 0000001B ????                <2> DRVLIM_L	dw		? ;0	;J.K.87
    62 0000001D ????                <2> DRVLIM_H	dw		? ;0	;J.K.87
    63 0000001F ??                  <2> FATSIZ		DB		?	; FLAGS...
    64 00000020 ????                <2> OPCNT		DW		?	; OPEN REF. COUNT
    65 00000022 ??                  <2> FORMFACTOR	DB		?	; FORM FACTOR INDEX
    66 00000023 ????                <2> FLAGS		DW		?	; VARIOUS FLAGS
    67 00000025 ????                <2> CCYLN		DW		?	; MAX NUMBER OF CYLINDERS
    68 00000027 ????                <2> RBYTEPERSEC	DW		?	; RECOMMENDED BPB
    69 00000029 ??                  <2> RSECPERCLUS	DB		?
    70 0000002A ????                <2> RRESSEC 	DW		?
    71 0000002C ??                  <2> RCFAT		DB		?
    72 0000002D ????                <2> RCDIR		DW		?
    73 0000002F ????                <2> RDRVLIM 	DW		?
    74 00000031 ??                  <2> RMEDIAD 	DB		?
    75 00000032 ????                <2> RCSECFAT	DW		?
    76 00000034 ????                <2> RSECLIM 	DW		?
    77 00000036 ????                <2> RHDLIM		DW		?
    78 00000038 ????                <2> RHIDSEC_L	DW		?
    79 0000003A ????                <2> RHIDSEC_H	DW		? ;0	;J.K.87
    80 0000003C ????                <2> RDRVLIM_L	dw		? ;0	;J.K.87
    81 0000003E ????                <2> RDRVLIM_H	dw		? ;0	;J.K.87
    82 00000040 ????????????        <2> RESERVE 	DB		6 DUP (?)	; RESERVED FOR FUTURE
    83 00000046 ??                  <2> TRACK		DB		?	; LAST TRACK ACCESSED ON DRIVE
    84 00000047 ????                <2> TIM_LO		DW		?	; TIME OF LAST ACCESS. KEEP
    85 00000049 ????                <2> TIM_HI		DW		?	; THESE CONTIGUOUS.
    86 0000004B <res Ch>            <2> VOLID		DB		12 DUP (?)	; VOLUME ID OF MEDIUM
    87 00000057 ????????            <2> VOL_SERIAL	dd	? ;0	  ;J.K.87 Current volume serial number from Boot record
    88 0000005B <res 9h>            <2> FILESYS_Id	db	9 dup (?) ;(0) ;J.K.87 Current file system id from Boot record
    89                              <2> BDS_TYPE	ENDS
    90                              <2> 
    91                              <2> BPBSIZE     equ	TRACK - RBYTEPERSEC ; SIZE IN BYTES OF RECBPB AREA IN THE BDS
    92                              <2> 
    93                              <2> 
    94                              <2> ;*********************************************************************
    95                              <2> ;	BDS structure for mini disk - J.K. 4/7/86
    96                              <2> ;*********************************************************************
    97                              <2> 
    98                              <2> BDSM_type	struc
    99 00000000 ????                <2> mlink		DW	? ;-1			;Link to next structure
   100 00000002 ????                <2> 		DW	?
   101 00000004 ??                  <2> mdriveNum	DB	? ;80			;Int 13 Drive Number
   102 00000005 ??                  <2> mdriveLet	DB	? ;3			;Logical Drive Number
   103 00000006 ????                <2> mBytePerSec	DW	? ;512
   104 00000008 ??                  <2> mSecPerClus	DB	? ;1			;Sectors/allocation unit
   105 00000009 ????                <2> mRESSEC 	DW	? ;1			;Reserved sectors for DOS
   106 0000000B ??                  <2> mcFAT		DB	? ;2			;No. of allocation tables
   107 0000000C ????                <2> mcDIR		DW	? ;16			;Number of directory entries
   108 0000000E ????                <2> mDRVLIM 	DW	? ;0			;Number of sectors (at 512 bytes each)
   109 00000010 ??                  <2> mMediad 	DB	? ;11111000B		;Media descriptor
   110 00000011 ????                <2> mcSecFat	DW	? ;1			;Number of FAT sectors
   111 00000013 ????                <2> mSECLIM 	DW	? ;0			;Sector limit
   112 00000015 ????                <2> mHDLIM		DW	? ;0			;Head limit
   113 00000017 ????                <2> mHIDSEC_L	DW	? ;0			;Hidden sector count
   114 00000019 ????                <2> mHidsec_H	dw	? ;0			;J.K.87
   115 0000001B ????                <2> mDrvlim_L	dw	? ;0			;J.K.87
   116 0000001D ????                <2> mDrvlim_H	dw	? ;0			;J.K.87
   117 0000001F ??                  <2> mFatSiz 	DB	? ;0			;TRUE => bigfat
   118 00000020 ????                <2> mOPCNT		DW	? ;0			;Open Ref. Count
   119 00000022 ??                  <2> mFormFactor	DB	? ;3			;Form Factor
   120 00000023 ????                <2> mFLAGS		DW	? ;0020H		;Various Flags
   121 00000025 ????                <2> mcCyln		dw	? ;40			;max number of cylinders
   122 00000027 <res 1Fh>           <2> mRecBPB 	db	31 dup (?) ;(0)		;Recommended BPB for drive
   123 00000046 ??                  <2> mTrack		db	? ;-1
   124 00000047 ????                <2> IsMini		dw	? ;1			;Overlapping TIM_LOH
   125 00000049 ????                <2> Hidden_Trks	dw	? ;0			;Overlapping TIM_HIH
   126 0000004B <res Bh>            <2> mVOLID		DB	11 dup (?) ;"NO NAME    "           ;Volume ID for this disk
   127 00000056 ??                  <2> 		DB	? ;0			;ASCIZII for "NO NAME    "
   128 00000057 ????????            <2> mVol_Serial	dd	? ;0	   ;Current volume serial number from Boot record
   129 0000005B ????????????????    <2> mFileSys_Id	db	8 dup (?) ;"FAT12   " ;Current file system id from Boot record
   130 00000063 ??                  <2> 		db	? ;0
   131                              <2> 
   132                              <2> BDSM_type	ENDS
   133                              <2> ;******************************************************************************
   134                              <2> Max_mini_dsk_num equ 23	      ;J.K. 4/7/86 - max # of mini disk ibmbio can support
   135                              <2> ;
   136                              <2> 
    14                              <1> 
    15                              <1> ;AN000; Extended BPB structure.
    16                              <1> BPB_TYPE STRUC
    17 00000000 ????                <1> SECSIZE DW	?
    18 00000002 ??                  <1> SECALL	DB	?
    19 00000003 ????                <1> RESNUM	DW	?
    20 00000005 ??                  <1> FATNUM	DB	?
    21 00000006 ????                <1> DIRNUM	DW	?
    22 00000008 ????                <1> SECNUM	DW	?
    23 0000000A ??                  <1> FATID	DB	?
    24 0000000B ????                <1> FATSIZE DW	?
    25 0000000D ????                <1> SLIM	DW	?
    26 0000000F ????                <1> HLIM	DW	?
    27 00000011 ????                <1> HIDDEN_L  DW	  ?
    28 00000013 ????                <1> HIDDEN_H  dw	  ? ;0			;J.K.
    29 00000015 ????                <1> SECNUM_L  dw	  ? ;0			;J.K.
    30 00000017 ????                <1> SECNUM_H  dw	  ? ;0			;J.K.
    31                              <1> BPB_TYPE ENDS
    32                              <1> 
    33                              <1> ;;;;;;;;;;;
    34                              <1> BOOT_SERIAL_SIZE	equ	4	;J.K.
    35                              <1> BOOT_VOLUME_LABEL_SIZE	equ	11	;J.K.
    36                              <1> BOOT_SYSTEM_ID_SIZE	equ	8	;J.K.
    37                              <1> EXT_BOOT_SIGNATURE	equ	41	;J.K.
    38                              <1> RSINIT equ 0A3H		      ;RS232 INITIALIZATION
    39                              <1> 			      ;9600 BAUD:NO PARITY:1 STOP:8 BIT WORD
    40                              <1> LF equ 10			      ;LINE FEED
    41                              <1> CR equ 13			      ;CARRIAGE RETURN
    42                              <1> BACKSP equ 8		      ;BACKSPACE
    43                              <1> BRKADR equ 1BH * 4		      ;006C  1BH BREAK VECTOR ADDRESS
    44                              <1> TIMADR equ 1CH * 4		      ;0070  1CH TIMER INTERRUPT
    45                              <1> DSKADR equ 1EH * 4		      ;ADDRESS OF PTR TO DISK PARAMETERS
    46                              <1> SEC9 equ 522H		      ;ADDRESS OF DISK PARAMETERS
    47                              <1> HEADSETTLE equ SEC9+9	      ; ARR 2.20 ADDRESS OF HEAD SETTLE TIME
    48                              <1> NORMSETTLE equ 15		      ; ARR 2.20 NORMAL HEAD SETTLE
    49                              <1> SPEEDSETTLE equ 0		      ; ARR 2.20 SPEED UP SETTLE TIME
    50                              <1> INITSPOT equ 534H		      ; ARR IBM WANTS 4 ZEROS HERE
    51                              <1> AKPORT equ 20H
    52                              <1> EOI equ 20H
    53                              <1> CMDLEN	equ	    0			    ;LENGTH OF THIS COMMAND
    54                              <1> UNIT	equ	    1			    ;SUB UNIT SPECIFIER
    55                              <1> CMD	equ	    2			    ;COMMAND CODE
    56                              <1> STATUS	equ	    3			    ;STATUS
    57                              <1> MEDIA	equ	    13			    ;MEDIA DESCRIPTOR
    58                              <1> TRANS	equ	    14			    ;TRANSFER ADDRESS
    59                              <1> COUNT	equ	    18			    ;COUNT OF BLOCKS OR CHARACTERS
    60                              <1> START	equ	    20			    ;FIRST BLOCK TO TRANSFER
    61                              <1> EXTRA	equ	    22			    ;USUALLY A POINTER TO VOL ID FOR ERROR 15
    62                              <1> CHROUT	equ	    29H
    63                              <1> MAXERR	equ	     5
    64                              <1> LSTDRV	equ	     504H
    65                              <1> 
    66                              <1> NOTBUSYSTATUS	equ	10000000B	    ; NOT BUSY
    67                              <1> ACKSTATUS	equ	01000000B	    ; ACKNOWLEDGE (FOR WHAT?)
    68                              <1> NOPAPERSTATUS	equ	00100000B	    ; NO MORE PAPER
    69                              <1> SELECTEDSTATUS	equ	00010000B	    ; THE PRINTER SAID IT WAS SELECTED
    70                              <1> IOERRSTATUS	equ	00001000B	    ; SOME KINDA ERROR
    71                              <1> RESERVED	equ	00000110B	    ; NOPS
    72                              <1> TIMEOUTSTATUS	equ	00000001B	    ; TIME OUT.
    73                              <1> ERROR_UNKNOWN_MEDIA   equ 7		    ; FOR USE IN BUILD BPB CALL
    74                              <1> 
    75                              <1> PATHGEN 	equ	1
    33                                  	%include "pushpop.mac"
     1                              <1> ; NASM original macros
     2                              <1> 
     3                              <1> %unimacro stripangles 2.nolist
     4                              <1> %assign ?stackdepth 0
     5                              <1> 
     6                              <1> %imacro stripangles 2.nolist
     7                              <1> %defstr %%param %2
     8                              <1> %rep 16
     9                              <1>  %substr %%opening %%param 1
    10                              <1>  %ifidn %%opening, '<'
    11                              <1>   %substr %%param %%param 2,-1
    12                              <1>  %endif
    13                              <1> %endrep
    14                              <1> %rep 16
    15                              <1>  %strlen %%length %%param
    16                              <1>  %substr %%closing %%param %%length
    17                              <1>  %ifidn %%closing, '>'
    18                              <1>   %substr %%param %%param 1,-2
    19                              <1>  %endif
    20                              <1> %endrep
    21                              <1> %deftok %%token %%param
    22                              <1> %1 %%token
    23                              <1> %endmacro
    24                              <1> 
    25                              <1> ;BREAK <SaveReg - save a set of registers>
    26                              <1> 
    27                              <1> %imacro SaveReg 0-*.nolist                 ;; push those registers
    28                              <1>  %rep %0
    29                              <1> 	%assign ?stackdepth ?stackdepth + 1
    30                              <1> 	stripangles push, %1
    31                              <1> 	%rotate 1
    32                              <1>  %endrep
    33                              <1> %endmacro
    34                              <1> ;.xcref  SaveReg
    35                              <1> 
    36                              <1> ;BREAK <RestoreReg - unsave some registers>
    37                              <1> 
    38                              <1> %imacro RestoreReg 0-*.nolist             ;; pop those registers
    39                              <1>  %rep %0
    40                              <1> 	%assign ?stackdepth ?stackdepth - 1
    41                              <1> 	stripangles pop, %1
    42                              <1> 	%rotate 1
    43                              <1>  %endrep
    44                              <1> %endmacro
    45                              <1> ;.xcref  RestoreReg
    34                                  	%include "devsym.mac"
     1                              <1> 	%warning out: DEVSYM.INC...
     1          ******************  <1>  warning: out: DEVSYM.INC... [-w+user]
     2                              <1> ;	SCCSID = @(#)DEVSYM.ASM 1.10 85/09/04
     3                              <1> ;	SCCSID = @(#)DEVSYM.ASM 1.10 85/09/04
     4                              <1> 
     5                              <1> ; THE DEVICE TABLE LIST HAS THE FORM:
     6                              <1> SYSDEV	       STRUC
     7 00000000 ????????            <1> SDEVNEXT       DD    ?		    ;POINTER TO NEXT DEVICE HEADER
     8 00000004 ????                <1> SDEVATT        DW    ?		    ;ATTRIBUTES OF THE DEVICE
     9 00000006 ????                <1> SDEVSTRAT      DW    ?		    ;STRATEGY ENTRY POINT
    10 00000008 ????                <1> SDEVINT        DW    ?		    ;INTERRUPT ENTRY POINT
    11 0000000A ????????????????    <1> SDEVNAME       DB    8 DUP (?)	    ;NAME OF DEVICE (ONLY FIRST BYTE USED FOR BLOCK)
    12                              <1> SYSDEV	       ENDS
    13                              <1> 
    14                              <1> ;
    15                              <1> ; ATTRIBUTE BIT MASKS
    16                              <1> ;
    17                              <1> ; CHARACTER DEVICES:
    18                              <1> ;
    19                              <1> ; BIT 15 -> MUST BE 1
    20                              <1> ;     14 -> 1 IF THE DEVICE UNDERSTANDS IOCTL CONTROL STRINGS
    21                              <1> ;     13 -> 1 IF THE DEVICE SUPPORTS OUTPUT-UNTIL-BUSY
    22                              <1> ;     12 -> UNUSED
    23                              <1> ;     11 -> 1 IF THE DEVICE UNDERSTANDS OPEN/CLOSE
    24                              <1> ;     10 -> MUST BE 0
    25                              <1> ;      9 -> MUST BE 0
    26                              <1> ;      8 -> UNUSED
    27                              <1> ;      7 -> UNUSED
    28                              <1> ;      6 -> UNUSED
    29                              <1> ;      5 -> UNUSED
    30                              <1> ;      4 -> 1 IF DEVICE IS RECIPIENT OF INT 29H
    31                              <1> ;      3 -> 1 IF DEVICE IS CLOCK DEVICE
    32                              <1> ;      2 -> 1 IF DEVICE IS NULL DEVICE
    33                              <1> ;      1 -> 1 IF DEVICE IS CONSOLE OUTPUT
    34                              <1> ;      0 -> 1 IF DEVICE IS CONSOLE INPUT
    35                              <1> ;
    36                              <1> ; BLOCK DEVICES:
    37                              <1> ;
    38                              <1> ; BIT 15 -> MUST BE 0
    39                              <1> ;     14 -> 1 IF THE DEVICE UNDERSTANDS IOCTL CONTROL STRINGS
    40                              <1> ;     13 -> 1 IF THE DEVICE DETERMINES MEDIA BY EXAMINING THE FAT ID BYTE.
    41                              <1> ;	    THIS REQUIRES THE FIRST SECTOR OF THE FAT TO *ALWAYS* RESIDE IN
    42                              <1> ;	    THE SAME PLACE.
    43                              <1> ;     12 -> UNUSED
    44                              <1> ;     11 -> 1 IF THE DEVICE UNDERSTANDS OPEN/CLOSE/REMOVABLE MEDIA
    45                              <1> ;     10 -> MUST BE 0
    46                              <1> ;      9 -> MUST BE 0
    47                              <1> ;      8 -> UNUSED
    48                              <1> ;      7 -> UNUSED
    49                              <1> ;      6 -> IF DEVICE HAS SUPPORT FOR GETMAP/SETMAP OF LOGICAL DRIVES.
    50                              <1> ;	    IF THE DEVICE UNDERSTANDS GENERIC IOCTL FUNCTION CALLS.
    51                              <1> ;      5 -> UNUSED
    52                              <1> ;      4 -> UNUSED
    53                              <1> ;      3 -> UNUSED
    54                              <1> ;      2 -> UNUSED
    55                              <1> ;      1 -> UNUSED
    56                              <1> ;      0 -> UNUSED
    57                              <1> ;
    58                              <1> 
    59                              <1> DEVTYP	       EQU   8000H	    ; BIT 15 - 1  IF CHAR, 0 IF BLOCK
    60                              <1> CHARDEV        EQU   8000H
    61                              <1> DEVIOCTL       EQU   4000H	    ; BIT 14 - CONTROL MODE BIT
    62                              <1> ISFATBYDEV     EQU   2000H	    ; BIT 13 - DEVICE USES FAT ID BYTES,
    63                              <1> 				    ;  COMP MEDIA.
    64                              <1> OUTTILBUSY     EQU   2000H	    ; OUTPUT UNTIL BUSY IS ENABLED
    65                              <1> ISNET	       EQU   1000H	    ; BIT 12 - 1 IF A NET DEVICE, 0 IF
    66                              <1> 				    ;  NOT.  CURRENTLY BLOCK ONLY.
    67                              <1> DEVOPCL        EQU   0800H	    ; BIT 11 - 1 IF THIS DEVICE HAS
    68                              <1> 				    ;  OPEN,CLOSE AND REMOVABLE MEDIA
    69                              <1> 				    ;  ENTRY POINTS, 0 IF NOT
    70                              <1> 
    71                              <1> EXTENTBIT      EQU   0400H	    ; BIT 10 - CURRENTLY 0 ON ALL DEVS
    72                              <1> 				    ;  THIS BIT IS RESERVED FOR FUTURE USE
    73                              <1> 				    ;  TO EXTEND THE DEVICE HEADER BEYOND
    74                              <1> 				    ;  ITS CURRENT FORM.
    75                              <1> 
    76                              <1> ; NOTE BIT 9 IS CURRENTLY USED ON IBM SYSTEMS TO INDICATE "DRIVE IS SHARED".
    77                              <1> ;    SEE IOCTL FUNCTION 9. THIS USE IS NOT DOCUMENTED, IT IS USED BY SOME
    78                              <1> ;    OF THE UTILITIES WHICH ARE SUPPOSED TO FAIL ON SHARED DRIVES ON SERVER
    79                              <1> ;    MACHINES (FORMAT,CHKDSK,RECOVER,..).
    80                              <1> 
    81                              <1> DEV320	       EQU   0040H	    ;BIT 6 - FOR BLOCK DEVICES, THIS
    82                              <1> 				    ;DEVICE SUPPORTS SET/GET MAP OF
    83                              <1> 				    ;LOGICAL DRIVES, AND SUPPORTS
    84                              <1> 				    ;GENERIC IOCTL CALLS.
    85                              <1> 				    ;FOR CHARACTER DEVICES, THIS
    86                              <1> 				    ;DEVICE SUPPORTS GENERIC IOCTL.
    87                              <1> 				    ;THIS IS A DOS 3.2 DEVICE DRIVER.
    88                              <1> ISSPEC	       EQU   0010H	    ;BIT 4 - THIS DEVICE IS SPECIAL
    89                              <1> ISCLOCK        EQU   0008H	    ;BIT 3 - THIS DEVICE IS THE CLOCK DEVICE.
    90                              <1> ISNULL	       EQU   0004H	    ;BIT 2 - THIS DEVICE IS THE NULL DEVICE.
    91                              <1> ISCOUT	       EQU   0002H	    ;BIT 1 - THIS DEVICE IS THE CONSOLE OUTPUT.
    92                              <1> ISCIN	       EQU   0001H	    ;BIT 0 - THIS DEVICE IS THE CONSOLE INPUT.
    93                              <1> EXTDRVR        EQU   0002H	    ;BIT 1 - BLOCK DEVICE EXTNDED DRIVER
    94                              <1> 
    95                              <1> ;STATIC REQUEST HEADER
    96                              <1> SRHEAD	       STRUC
    97 00000000 ??                  <1> REQLEN	       DB    ?		    ;LENGTH IN BYTES OF REQUEST BLOCK
    98 00000001 ??                  <1> REQUNIT        DB    ?		    ;DEVICE UNIT NUMBER
    99 00000002 ??                  <1> REQFUNC        DB    ?		    ;TYPE OF REQUEST
   100 00000003 ????                <1> REQSTAT        DW    ?		    ;STATUS WORD
   101 00000005 ????????????????    <1> 	       DB    8 DUP(?)	    ;RESERVED FOR QUEUE LINKS
   102                              <1> SRHEAD	       ENDS
   103                              <1> 
   104                              <1> ;STATUS WORD MASKS
   105                              <1> STERR	       EQU   8000H	    ;BIT 15 - ERROR
   106                              <1> STBUI	       EQU   0200H	    ;BIT 9 - BUISY
   107                              <1> STDON	       EQU   0100H	    ;BIT 8 - DONE
   108                              <1> STECODE        EQU   00FFH	    ;ERROR CODE
   109                              <1> ;						  2/12/KK
   110                              <1> ; Interim  character identifier 		  2/12/KK
   111                              <1> Ddkey		EQU	0000010000000000B	; 2/12/KK
   112                              <1> 
   113                              <1> ;FUNCTION CODES
   114                              <1> DEVINIT        EQU   0		    ;INITIALIZATION
   115                              <1> DINITHL        EQU   26 	    ;SIZE OF INIT HEADER
   116                              <1> DEVMDCH        EQU   1		    ;MEDIA CHECK
   117                              <1> DMEDHL	       EQU   15 	    ;SIZE OF MEDIA CHECK HEADER
   118                              <1> DEVBPB	       EQU   2		    ;GET BPB
   119                              <1> DEVRDIOCTL     EQU   3		    ;IOCTL READ
   120                              <1> DBPBHL	       EQU   22 	    ;SIZE OF GET BPB HEADER
   121                              <1> DEVRD	       EQU   4		    ;READ
   122                              <1> DRDWRHL        EQU   22 	    ;SIZE OF RD/WR HEADER
   123                              <1> DEVRDND        EQU   5		    ;NON DESTRUCTIVE READ NO WAIT (CHARACTER DEVS)
   124                              <1> DRDNDHL        EQU   14 	    ;SIZE OF NON DESTRUCTIVE READ HEADER
   125                              <1> DEVIST	       EQU   6		    ;INPUT STATUS
   126                              <1> DSTATHL        EQU   13 	    ;SIZE OF STATUS HEADER
   127                              <1> DEVIFL	       EQU   7		    ;INPUT FLUSH
   128                              <1> DFLSHL	       EQU   15 	    ;SIZE OF FLUSH HEADER
   129                              <1> DEVWRT	       EQU   8		    ;WRITE
   130                              <1> DEVWRTV        EQU   9		    ;WRITE WITH VERIFY
   131                              <1> DEVOST	       EQU   10 	    ;OUTPUT STATUS
   132                              <1> DEVOFL	       EQU   11 	    ;OUTPUT FLUSH
   133                              <1> DEVWRIOCTL     EQU   12 	    ;IOCTL WRITE
   134                              <1> DEVOPN	       EQU   13 	    ;DEVICE OPEN
   135                              <1> DEVCLS	       EQU   14 	    ;DEVICE CLOSE
   136                              <1> DOPCLHL        EQU   13 	    ;SIZE OF OPEN/CLOSE HEADER
   137                              <1> DEVRMD	       EQU   15 	    ;REMOVABLE MEDIA
   138                              <1> REMHL	       EQU   13 	    ;SIZE OF REMOVABLE MEDIA HEADER
   139                              <1> GENIOCTL       EQU   19
   140                              <1> ; THE NEXT THREE ARE USED IN DOS 4.0
   141                              <1> ;		     20
   142                              <1> ;		     21
   143                              <1> ;		     22
   144                              <1> DEVGETOWN      EQU   23 	    ;GET DEVICE OWNER
   145                              <1> DEVSETOWN      EQU   24 	    ;SET DEVICE OWNER
   146                              <1> QUERYGENIOCTL equ 25		; query generic IOCTL support (MS-DOS v5+)
   147                              <1> OWNHL	       EQU   13 	    ;SIZE OF DEVICE OWNER HEADER
   148                              <1> 
   149                              <1> DEVOUT	       EQU   16 	    ; OUTPUT UNTIL BUSY.
   150                              <1> DEVOUTL        EQU   DEVWRT	    ; LENGTH OF OUTPUT UNTIL BUSY
   151                              <1> 
   152                              <1> ; GENERIC IOCTL REQUEST STRUCTURE
   153                              <1> ;	SEE THE DOS 4.0 DEVICE DRIVER SPEC FOR FURTHER ELABORATION.
   154                              <1> ;
   155                              <1> IOCTL_REQ      STRUC
   156 00000000 <res Dh>            <1> 	       DB    (SRHEAD_struc_size) DUP(?)
   157                              <1> 				    ; GENERIC IOCTL ADDITION.
   158 0000000D ??                  <1> MAJORFUNCTION  DB    ?		    ;FUNCTION CODE
   159 0000000E ??                  <1> MINORFUNCTION  DB    ?		    ;FUNCTION CATEGORY
   160 0000000F ????                <1> REG_SI	       DW    ?
   161 00000011 ????                <1> REG_DI	       DW    ?
   162 00000013 ????????            <1> GENERICIOCTL_PACKET DD ?	    ; POINTER TO DATA BUFFER
   163                              <1> IOCTL_REQ      ENDS
   164                              <1> 
   165                              <1> ;	DEFINITIONS FOR IOCTL_REQ.MINORFUNCTION
   166                              <1> GEN_IOCTL_WRT_TRK   EQU   40H
   167                              <1> GEN_IOCTL_RD_TRK    EQU   60H
   168                              <1> GEN_IOCTL_FN_TST    EQU   20H	    ; USED TO DIFF. BET READS AND WRTS
   169                              <1> 
   170                              <1> ;; 32-bit absolute read/write input list structure
   171                              <1> 
   172                              <1> ABS_32RW	 STRUC
   173 00000000 ????????            <1> SECTOR_RBA	 DD	 ?	    ; relative block address
   174 00000004 ????                <1> ABS_RW_COUNT	 DW	 ?	    ; number of sectors to be transferred
   175 00000006 ????????            <1> BUFFER_ADDR	 DD	 ?	    ; data addrress
   176                              <1> ABS_32RW	 ENDS
   177                              <1> 
   178                              <1> ;; media ID info
   179                              <1> 
   180                              <1> MEDIA_ID_INFO	 STRUC
   181 00000000 ????                <1> MEDIA_level	 DW	 ?	    ; info level
   182 00000002 ????????            <1> MEDIA_Serial	 DD	 ?	    ; serial #
   183 00000006 <res Bh>            <1> MEDIA_Label	 DB	 11 dup (?) ;volume label
   184 00000011 ????????????????    <1> MEDIA_System	 DB	 8  dup (?) ;system type
   185                              <1> MEDIA_ID_INFO	 ENDS
   186                              <1> 
   187                              <1> ;; equates for DOS34_FLAG
   188                              <1> 
   189                              <1> IFS_ABSRW	      EQU   00001H	   ;IFS absolute read/write
   190                              <1> NO_IFS_ABSRW	      EQU   0FFFEH	   ;no IFS absolute read/write
   191                              <1> IFS_DRIVE_RESET       EQU   00002H	   ;IFS drvive reset
   192                              <1> NO_IFS_DRIVE_RESET    EQU   0FFFDH	   ;no IFS drive reset
   193                              <1> FROM_DISK_RESET       EQU   00004H	   ;from disk reset
   194                              <1> NO_FROM_DISK_RESET    EQU   0FFFBH	   ;not from disk reset
   195                              <1> From_String_Output    EQU   00008H	   ;from con string output
   196                              <1> NO_From_String_Output EQU   0FFF7H	   ;not from con string output
   197                              <1> From_DOS_WRITE	      EQU   00010H	   ;from dos_write
   198                              <1> NO_From_DOS_WRITE     EQU   0FFEFH	   ;not from dos_write
   199                              <1> Force_I24_Fail	      EQU   00020H	   ;form IFS CALL BACK
   200                              <1> NO_Force_I24_Fail     EQU   0FFDFH	   ;not form IFS CALL BACK
   201                              <1> Disable_EOF_I24       EQU   00040H	   ;disable EOF int24 for input status
   202                              <1> NO_Disable_EOF_I24    EQU   0FFBFH	   ;disable EOF int24 for input status
   203                              <1> DBCS_VOLID	      EQU   00080H	   ;indicate from volume id
   204                              <1> DBCS_VOLID2	      EQU   00100H	   ;indicate 8th char is DBCS
   205                              <1> CTRL_BREAK_FLAG       EQU   00200H	   ;indicate control break is input
   206                              <1> NO_CTRL_BREAK_FLAG    EQU   0FDFFH	   ;reset control break
   207                              <1> SEARCH_FASTOPEN       EQU   00400H	   ;set fastopen flag for search
   208                              <1> X25_special	      EQU   00800H	   ;flag for X25 driver
    35                                  	%include "msdskpr.mac"
     1                              <1> ; The following structure defines the disk parameter table
     2                              <1> ; pointed to by Interrupt vector 1EH (location 0:78H)
     3                              <1> 
     4                              <1> DISK_PARMS	STRUC
     5 00000000 ??                  <1> DISK_SPECIFY_1	DB	?
     6 00000001 ??                  <1> DISK_SPECIFY_2	DB	?
     7 00000002 ??                  <1> DISK_MOTOR_WAIT DB	?	; Wait till motor off
     8 00000003 ??                  <1> DISK_SECTOR_SIZ DB	?	; Bytes/Sector (2 = 512)
     9 00000004 ??                  <1> DISK_EOT	DB	?	; Sectors per track (MAX)
    10 00000005 ??                  <1> DISK_RW_GAP	DB	?	; Read Write Gap
    11 00000006 ??                  <1> DISK_DTL	DB	?
    12 00000007 ??                  <1> DISK_FORMT_GAP	DB	?	; Format Gap Length
    13 00000008 ??                  <1> DISK_FILL	DB	?	; Format Fill Byte
    14 00000009 ??                  <1> DISK_HEAD_STTL	DB	?	; Head Settle Time (MSec)
    15 0000000A ??                  <1> DISK_MOTOR_STRT DB	?	; Motor start delay
    16                              <1> DISK_PARMS	ENDS
    17                              <1> 
    18                              <1> ROMStatus	equ	1
    19                              <1> ROMRead 	equ	2
    20                              <1> ROMWrite	equ	3
    21                              <1> ROMVerify	equ	4
    22                              <1> ROMFormat	equ	5
    36                                  	%include "biostruc.mac"
     1                              <1> %warning out: BIOSTRUC.INC...
     1          ******************  <1>  warning: out: BIOSTRUC.INC... [-w+user]
     2                              <1> ;	SCCSID = @(#)BIOSTRUC.INC 1.0 86/09/30
     3                              <1> ; ROM BIOS CALL PACKET STRUCTURES
     4                              <1> 
     5                              <1> ;*******************************
     6                              <1> ;System Service call ( Int 15h )
     7                              <1> ;*******************************
     8                              <1> ;Function AH = 0C0h, Return system configuration
     9                              <1> ;For PC and PCJR on return:
    10                              <1> ;	(AH)	= 80h
    11                              <1> ;	(CY)	= 1
    12                              <1> ;For PCXT, PC PORTABLE and PCAT on return:
    13                              <1> ;	(AH)	= 86h
    14                              <1> ;	(CY)	= 1
    15                              <1> ;For all others:
    16                              <1> ;	(AH)	= 0
    17                              <1> ;	(CY)	= 0
    18                              <1> ;	(ES:BX) = pointer to system descriptor vector in ROS
    19                              <1> ; System descriptor :
    20                              <1> ;	DW	xxxx		length of descriptor in bytes,
    21                              <1> ;				minimum length = 8
    22                              <1> ;	DB	xx		model byte
    23                              <1> ;				0FFh	= PC
    24                              <1> ;				0FEh	= PC/XT, Portable
    25                              <1> ;				0FDh	= PC/JR
    26                              <1> ;				0FCh	= PC/AT, 6Mhz PC/AT,
    27                              <1> ;					  6Mhz PC/AT running coprocessor(?),
    28                              <1> ;					  PS/2 Model 50, 50 z
    29                              <1> ;				0FAh	= PS/2 Model 25, 30
    30                              <1> ;				0F9h	= PC Convertible
    31                              <1> ;				0F8h	= PS/2 Model 80
    32                              <1> ;				0F7h	= Nova
    33                              <1> ;				0E0 thru 0EFh = reserved
    34                              <1> ;
    35                              <1> ;	DB	xx		secondary model byte
    36                              <1> ;				000h	= PC1
    37                              <1> ;				000h	= PC/XT, Portable
    38                              <1> ;				000h	= PC/JR
    39                              <1> ;				000h	= PC/AT
    40                              <1> ;				001h	= 6Mhz PC/AT
    41                              <1> ;				003h	= 6Mhz PC/AT running coprocessor(?)
    42                              <1> ;				004h	= PS/2 Model 50, 50z
    43                              <1> ;				001h	= PS/2 Model 25
    44                              <1> ;				000h	= PC Convertible
    45                              <1> ;				000h	= PS/2 Model 80
    46                              <1> ;				000h	= Nova
    47                              <1> ;
    48                              <1> ;	DB	xx		bios revision level
    49                              <1> ;				00 for first release, subsequent release
    50                              <1> ;				of code with same model byte and
    51                              <1> ;				secondary model byte require revison level
    52                              <1> ;				to increase by one.
    53                              <1> ;
    54                              <1> ;	DB	xx		feature information byte 1
    55                              <1> ;				X0000000 = 1, bios use DMA channel 3
    56                              <1> ;					 = 0, DMA channel 3 not used
    57                              <1> ;
    58                              <1> ;				0X000000 = 1, 2nd Interrupt chip present
    59                              <1> ;					 = 0, 2nd Interrupt chip not present
    60                              <1> ;
    61                              <1> ;				00X00000 = 1, Real Time Clock present
    62                              <1> ;					 = 0, Real Time Clock not present
    63                              <1> ;
    64                              <1> ;				000X0000 = 1, Keyboard escape sequence(INT15h)
    65                              <1> ;						called in keyboard interrupt
    66                              <1> ;						(Int 09h).
    67                              <1> ;					 = 0, Keyboard escape sequence not
    68                              <1> ;						called.
    69                              <1> ;				0000XXXX reserved
    70                              <1> ;
    71                              <1> ;	DB	xx		feature information byte 2 - reserved
    72                              <1> ;
    73                              <1> ;	DB	xx		feature information byte 2 - reserved
    74                              <1> ;
    75                              <1> ;	DB	xx		feature information byte 2 - reserved
    76                              <1> ;
    77                              <1> ;	DB	xx		feature information byte 2 - reserved
    78                              <1> ;
    79                              <1> 
    80                              <1> BIOS_SYSTEM_DESCRIPTOR	struc
    81 00000000 ????                <1> bios_SD_leng		dw	?
    82 00000002 ??                  <1> bios_SD_modelbyte	db	?
    83 00000003 ??                  <1> bios_SD_scnd_modelbyte	db	?
    84 00000004 ??                  <1> 			db	?
    85 00000005 ??                  <1> bios_SD_featurebyte1	db	?
    86 00000006 ????????            <1> 			db   4 dup (?)
    87                              <1> BIOS_SYSTEM_DESCRIPTOR ends
    88                              <1> 
    89                              <1> ;FeatureByte1	bit map equates
    90                              <1> DMAchannel3		equ 10000000b
    91                              <1> ScndIntController	equ 01000000b
    92                              <1> RealTimeClock		equ 00100000b
    93                              <1> KeyEscapeSeq		equ 00010000b
    94                              <1> ;
    95                              <1> ;Model Byte
    96                              <1> MDL_PC1 	EQU	0FFH
    97                              <1> MDL_XT		EQU	0FEH
    98                              <1> MDL_JR		EQU	0FDH
    99                              <1> MDL_AT		EQU	0FCH
   100                              <1> MDL_CONVERT	EQU	0F9H
   101                              <1> 
   102                              <1> mdl_ps2_30	equ	0fah
   103                              <1> mdl_ps2_80	equ	0f8h
    37                                  	%include "entryseg.nas"
     1                              <1> 
     2                              <1> %ifndef ENTRYSEGNAS
     3                              <1> %define ENTRYSEGNAS 1
     4                              <1> 
     5                              <1> %include "lmacros3.mac"
     1                              <2> [list -]
     6                              <1> %include "entrysw.mac"
     1                              <2> 
     2                              <2> %ifndef __ENTRYSW_MAC__
     3                              <2>  %assign __ENTRYSW_MAC__ 1
     4                              <2> 
     5                              <2> %assign _DOSCODEHMA		1
     6                              <2> %assign _RELOCATEDOSCODE	1
     7                              <2> 
     8                              <2> 		; Write a label "%1" (only if DOSCODE isn't relocated) and
     9                              <2> 		; "relocated%1" (always).
    10                              <2> 	%imacro relocated 1-2.nolist
    11                              <2> %ifnidni %2, device
    12                              <2>  %ifnidni %2, amis
    13                              <2>   %ifn _RELOCATEDOSCODE
    14                              <2> %1:
    15                              <2> 	global %1
    16                              <2>   %endif
    17                              <2>  %endif
    18                              <2> %endif
    19                              <2> relocated%1:				; always used for local labels
    20                              <2> 	global relocated%1
    21                              <2> 	%endmacro
    22                              <2> 
    23                              <2> %if _RELOCATEDOSCODE
    24                              <2> DOSENTRYADJUSTSEGMENT equ 60h - 26h
    25                              <2> %else
    26                              <2> DOSENTRYADJUSTSEGMENT equ 0
    27                              <2> %endif
    28                              <2> DOSENTRYADJUSTOFFSET equ DOSENTRYADJUSTSEGMENT * 16
    29                              <2> 
    30                              <2> DOSENTRYDEVICEBASE equ 10h
    31                              <2> 
    32                              <2> %endif
     7                              <1> [list -]
    39                              <1> usesection DOSENTRY
    40                              <1> 
    41                              <1> %endif
    38                                  	%include "entrysw.mac"
     1                              <1> 
     2                              <1> %ifndef __ENTRYSW_MAC__
     3                              <1>  %assign __ENTRYSW_MAC__ 1
     4                              <1> 
     5                              <1> %assign _DOSCODEHMA		1
     6                              <1> %assign _RELOCATEDOSCODE	1
     7                              <1> 
     8                              <1> 		; Write a label "%1" (only if DOSCODE isn't relocated) and
     9                              <1> 		; "relocated%1" (always).
    10                              <1> 	%imacro relocated 1-2.nolist
    11                              <1> %ifnidni %2, device
    12                              <1>  %ifnidni %2, amis
    13                              <1>   %ifn _RELOCATEDOSCODE
    14                              <1> %1:
    15                              <1> 	global %1
    16                              <1>   %endif
    17                              <1>  %endif
    18                              <1> %endif
    19                              <1> relocated%1:				; always used for local labels
    20                              <1> 	global relocated%1
    21                              <1> 	%endmacro
    22                              <1> 
    23                              <1> %if _RELOCATEDOSCODE
    24                              <1> DOSENTRYADJUSTSEGMENT equ 60h - 26h
    25                              <1> %else
    26                              <1> DOSENTRYADJUSTSEGMENT equ 0
    27                              <1> %endif
    28                              <1> DOSENTRYADJUSTOFFSET equ DOSENTRYADJUSTSEGMENT * 16
    29                              <1> 
    30                              <1> DOSENTRYDEVICEBASE equ 10h
    31                              <1> 
    32                              <1> %endif
    39                                  	%include "msgroup.mac"	;DEFINE CODE SEGMENT
     1                              <1> EVBOUND equ 1  ;THIS VALUE BEING 0 DOES NO BOUNDARY ALLIGNMENT, VALUE 1	  ;3.30
     2                              <1> 	     ; ALIGNS TO EVEN						  ;3.30
     3                              <1> 
     4                              <1> ; NASM original macros
     5                              <1> 
     6                              <1> %include "dcodeseg.nas"
     1                              <2> 
     2                              <2> %ifndef DCODESEGNAS
     3                              <2> %assign DCODESEGNAS 1
     4                              <2> 
     5                              <2> section DOSCODETABLE align=2 PUBLIC class=DOSCODE
     6                              <2> ; (no prior section) ; DOSCODETABLE		ENDS
     7                              <2> section DOSCODECODE align=1 PUBLIC class=DOSCODE
     8                              <2> ; (no prior section) ; DOSCODECODE		ENDS
     9                              <2> section DOSBIOCODE align=2 PUBLIC class=DOSCODE
    10                              <2> section BIOCODE	align=2 PUBLIC class=DOSCODE
    11                              <2> 
    12                              <2> %ifnidni DOSENTRYGROUP, DOSCODEGROUP
    13                              <2>  group DOSCODEGROUP DOSCODETABLE DOSCODECODE DOSBIOCODE BIOCODE
    14                              <2> %endif
    15                              <2> 
    16                              <2> %endif
     7                              <1> 
     8                              <1> 	%if EVBOUND	;;IF EVEN (WORD) ALLIGNMENT IS REQUESTED,	  ;3.30
     9                              <1> 
    10                              <1> %imacro EVENB 0.nolist
    11                              <1> 	EVEN	;;ADJUST TO EVEN BOUNDARY
    12                              <1> %endmacro
    13                              <1> 
    14                              <1> %imacro ODD 0.nolist
    15                              <1> %if (($ - $$) % 2) == 0
    16                              <1> 	db ?
    17                              <1> %endif
    18                              <1> %endmacro
    19                              <1> 
    20                              <1> 	%else	;;SINCE EVEN ALLIGNMENT IS NOT DESIRED, JUST USE BYTE ALLI;3.30 GNMENT
    21                              <1> 
    22                              <1> %imacro EVENB 0.nolist
    23                              <1> ;;REQUEST FOR WORD ALLIGNMENT DOES NOTHING				  ;3.30
    24                              <1> %endmacro
    25                              <1> 
    26                              <1> %imacro ODD 0.nolist
    27                              <1> ;;REQUEST FOR ODD ALLIGNMENT DOES NOTHING				  ;3.30
    28                              <1> %endmacro
    29                              <1> 
    30                              <1> 	%endif								  ;3.30
    31                              <1> 
    32                              <1> %imacro CODE_SEGMENT 0.nolist
    33                              <1> 	section BIOCODE
    34                              <1> %endmacro
    35                              <1> 
    36                              <1> ; end of NASM original macros
    37                              <1> 
    38                              <1> 	CODE_SEGMENT							  ;3.30
    39                              <1> 	ASSUME	CS:BIOCODE 						  ;3.30
    40                              <1> 									  ;3.30
    40                                  	%include "msmacro.mac"
     1                              <1> 
     2                              <1> %include "dcodeseg.nas"
     1                              <2> 
     2                              <2> %ifndef DCODESEGNAS
     3                              <2> %assign DCODESEGNAS 1
     4                              <2> 
     5                              <2> section DOSCODETABLE align=2 PUBLIC class=DOSCODE
     6                              <2> ; (no prior section) ; DOSCODETABLE		ENDS
     7                              <2> section DOSCODECODE align=1 PUBLIC class=DOSCODE
     8                              <2> ; (no prior section) ; DOSCODECODE		ENDS
     9                              <2> section DOSBIOCODE align=2 PUBLIC class=DOSCODE
    10                              <2> section BIOCODE	align=2 PUBLIC class=DOSCODE
    11                              <2> 
    12                              <2> %ifnidni DOSENTRYGROUP, DOSCODEGROUP
    13                              <2>  group DOSCODEGROUP DOSCODETABLE DOSCODECODE DOSBIOCODE BIOCODE
    14                              <2> %endif
    15                              <2> 
    16                              <2> %endif
     3                              <1> section BIOCODE
     4                              <1> 
     5                              <1> ;
     6                              <1> ; This file contains three macros used in debugging the system.  If the
     7                              <1> ; variable "itest" (in msbio.asm) is nonzero code is included in the
     8                              <1> ; modules to print debugging messages.	The level of debugging is controlled
     9                              <1> ; by the value of the variable fTestBits in msbio.asm.	Specific bits in
    10                              <1> ; the variable determine which messages to print.  The equ's below tell
    11                              <1> ; which bits control which funcitons.  For example the fifth bit
    12                              <1> ; cooresponds to disk activity (see fTestDisk equ below).
    13                              <1> ;
    14                              <1> ;   The macros in the file are:
    15                              <1> ;
    16                              <1> ;	message    Prints an ascii string on the screen.
    17                              <1> ;		   Example usage:
    18                              <1> ;
    19                              <1> ;		      message fTestDisk, <"Start Disk Write", CR, LF>
    20                              <1> ;		      message fTestINIT, <"Begin BDS initialization">
    21                              <1> ;
    22                              <1> ;
    23                              <1> ;	MNUM	   Print the value in a register or memory location on
    24                              <1> ;		   the screen. Value is displayed in hex.
    25                              <1> ;		   Usage:
    26                              <1> ;		      MNUM  bitpattern, valueLocation
    27                              <1> ;
    28                              <1> ;		   valueLocation is typically a regester:
    29                              <1> ;
    30                              <1> ;		      mnum  fTestCom, AX
    31                              <1> ;		      mnum  fTestDisk, DX
    32                              <1> ;
    33                              <1> ;		   ValueLocation can also be a memory location:
    34                              <1> ;
    35                              <1> ;		      mnum  fTestINIT, Final_Dos_Location
    36                              <1> ;
    37                              <1> ;		   If no valueLocation is given the macro defaults to
    38                              <1> ;		   the BX register.
    39                              <1> ;
    40                              <1> ;	ZWAIT	    Stops the program until any key is pressed.
    41                              <1> ;
    42                              <1> ;
    43                              <1> ;	The three macros preserve all register values.	If "test" is zero
    44                              <1> ;	defined during assembly then the  marco produce no code.
    45                              <1> ;
    46                              <1> 
    47                              <1> 	%IF	itest							  ;3.30
    48                              <1> 		EXTRN	MSGOUT:NEAR,MSGNUM:NEAR 			  ;3.30
    49                              <1> 	    EXTRN   NUMBUF:BYTE,DIGITS:BYTE,FTESTBITS:WORD		  ;3.30
    50                              <1> 		EXTRN	DUMPBYTES:NEAR,OUTCHAR:NEAR,HEX_TO_ASCII:NEAR	  ;3.30
    51                              <1> 
    52                              <1> 
    53                              <1> fTestALL    equ     1111111111111111b	; watch everything
    54                              <1> fTestHARD   equ     0000000000000001b	; watch hard disk initialization
    55                              <1> fTest96     equ     0000000000000010b	; watch 96 tpi activity
    56                              <1> FTEST13     EQU     0000000000000100B	; WATCH INT 13 ACTIVITY 	  ;3.30
    57                              <1> FTESTCOM    EQU     0000000000001000B	; WATCH PACKET ACTIVITY 	  ;3.30
    58                              <1> FTESTINIT   EQU     0000000000010000B	; WATCH INITIALIZATION MESSAGES   ;3.30
    59                              <1> FTESTDISK   EQU     0000000000100000B	; WATCH DISK DEVICE DRIVER CALLS  ;3.30
    60                              <1> FTESTCON    EQU     0000000001000000B	; WATCH SYSTEM WAIT ACTIVITY IN CO;3.30 NSOLE
    61                              <1> FtestClock  equ     0000000010000000b	; wathc clock device  5/2/86  ;3.30
    62                              <1> 
    63                              <1> ; NASM original macros
    64                              <1> 
    65                              <1> ;
    66                              <1> ; message macro -- see above for description
    67                              <1> ;
    68                              <1> 
    69                              <1> %unimacro stripangles 2+.nolist
    70                              <1> 
    71                              <1> %imacro stripangles 2+.nolist
    72                              <1> %defstr %%param %2
    73                              <1> %rep 16
    74                              <1>  %substr %%opening %%param 1
    75                              <1>  %ifidn %%opening, '<'
    76                              <1>   %substr %%param %%param 2,-1
    77                              <1>  %endif
    78                              <1> %endrep
    79                              <1> %rep 16
    80                              <1>  %strlen %%length %%param
    81                              <1>  %substr %%closing %%param %%length
    82                              <1>  %ifidn %%closing, '>'
    83                              <1>   %substr %%param %%param 1,-2
    84                              <1>  %endif
    85                              <1> %endrep
    86                              <1> %deftok %%token %%param
    87                              <1> %1 %%token
    88                              <1> %endmacro
    89                              <1> 
    90                              <1> %imacro MESSAGE 2+
    91                              <1> 	jmp short %%b
    92                              <1> %%a:
    93                              <1> 	stripangles db, %2
    94                              <1> 	db 0
    95                              <1> %%b:	push	SI
    96                              <1> 	push	AX
    97                              <1> 	mov	AX, %1
    98                              <1> 	mov	SI, OFFSET %%a
    99                              <1> 	call	MSGOUT
   100                              <1> 	pop	AX
   101                              <1> 	pop	SI
   102                              <1> %endmacro
   103                              <1> 
   104                              <1> 
   105                              <1> ;
   106                              <1> ; mnum macro -- see above for description
   107                              <1> ;
   108                              <1> 
   109                              <1> %imacro MNum 1-2
   110                              <1> 	push	AX
   111                              <1> %ifempty %2
   112                              <1> 	mov	AX,%1
   113                              <1> 	call	MSGNUM
   114                              <1> %else
   115                              <1> 	push	BX
   116                              <1> 	mov	BX,%2
   117                              <1> 	mov	AX,%1
   118                              <1> 	call	MSGNUM
   119                              <1> 	pop	BX
   120                              <1> %endif
   121                              <1> 	pop	AX
   122                              <1> %endmacro
   123                              <1> 
   124                              <1> 
   125                              <1> ;
   126                              <1> ; zwait macro -- see above for description
   127                              <1> ;
   128                              <1> 
   129                              <1> %imacro ZWAIT 0
   130                              <1> 	Message fTestALL,<"? ">
   131                              <1> 	CALL	ZWAITrtn
   132                              <1> %endmacro
   133                              <1> 
   134                              <1> ZWAITrtn:
   135                              <1> 	pushf				; save the flags
   136                              <1> 	push	AX			; preserve AX
   137                              <1> 	xor	AH, AH			; set command to get character ;3.30*
   138                              <1> 	int	16h			; call rom keyboard routine    ;3.30*
   139                              <1> 	pop	AX			; restore AX
   140                              <1> 	popf				; restore the flags
   141                              <1> 	ret
   142                              <1> 
   143                              <1> ;Dump_byte dumps the memory contents in hex. 				  ;3.30
   144                              <1> ;DUMPOFFLABEL should be a label or a variable defined in DUMPSEG.	  ;3.30
   145                              <1> %imacro DUMP_BYTE 3
   146                              <1> 	push	es							  ;3.30
   147                              <1> 	PUSH	DS							  ;3.30
   148                              <1> 	PUSH	SI							  ;3.30
   149                              <1> 	PUSH	CX							  ;3.30
   150                              <1> 									  ;3.30
   151                              <1> 	MOV	CX, %1							  ;3.30
   152                              <1> 	MOV	DS, CX							  ;3.30
   153                              <1> 	MOV	SI, OFFSET %2						  ;3.30
   154                              <1> 	MOV	CX, %3							  ;3.30
   155                              <1> 	call	dumpbytes						  ;3.30
   156                              <1> 									  ;3.30
   157                              <1> 	POP	CX							  ;3.30
   158                              <1> 	POP	SI							  ;3.30
   159                              <1> 	POP	DS							  ;3.30
   160                              <1> 	pop	es							  ;3.30
   161                              <1> %endmacro								  ;3.30
   162                              <1> 									  ;3.30
   163                              <1> ;Dump_Byte_Reg dumps the memory contents in hex. -  4/9/86		  ;3.30
   164                              <1> ;DUMPOFFREG should be a register contains the offset value in DUMPSEG.	  ;3.30
   165                              <1> %imacro DUMP_BYTE_REG 3
   166                              <1> DUMP_BYTE_REG	MACRO	DUMPSEG, DUMPOFFREG, BYTELENGTH 		  ;3.30
   167                              <1> 	push	es							  ;3.30
   168                              <1> 	PUSH	DS							  ;3.30
   169                              <1> 	PUSH	SI							  ;3.30
   170                              <1> 	PUSH	CX							  ;3.30
   171                              <1> 									  ;3.30
   172                              <1> 	MOV	CX, %1							  ;3.30
   173                              <1> 	MOV	DS, CX							  ;3.30
   174                              <1> 	MOV	SI, %2							  ;3.30
   175                              <1> 	MOV	CX, %3							  ;3.30
   176                              <1> 	call	dumpbytes						  ;3.30
   177                              <1> 									  ;3.30
   178                              <1> 	POP	CX							  ;3.30
   179                              <1> 	POP	SI							  ;3.30
   180                              <1> 	POP	DS							  ;3.30
   181                              <1> 	pop	es							  ;3.30
   182                              <1> %endmacro								  ;3.30
   183                              <1> 
   184                              <1> %else
   185                              <1> 		; if test is not defined then make macro into null statements
   186                              <1> %imacro Message 0-1+.nolist
   187                              <1> %endmacro
   188                              <1> 
   189                              <1> %imacro MNUM 0-1+.nolist
   190                              <1> %endmacro
   191                              <1> 
   192                              <1> %imacro ZWAIT 0-1+.nolist
   193                              <1> %endmacro
   194                              <1> 
   195                              <1> %imacro DUMP_BYTE 0-1+.nolist
   196                              <1> %endmacro
   197                              <1> 
   198                              <1> %imacro DUMP_BYTE_REG 0-1+.nolist
   199                              <1> %endmacro
   200                              <1> 
   201                              <1> %endif
   202                              <1> 
   203                              <1> %unimacro PATHSTART 2
   204                              <1> %unimacro PATHEND 2
   205                              <1> 
   206                              <1> %imacro PATHSTART 2
   207                              <1> 	%IF	PATHGEN							  ;3.30
   208                              <1> 	    PUBLIC  %2%1S,%2%1E						  ;3.30
   209                              <1> 	    %2%1S LABEL	 BYTE						  ;3.30
   210                              <1> 	%ENDIF								  ;3.30
   211                              <1> %endmacro								  ;3.30
   212                              <1> 									  ;3.30
   213                              <1> %imacro PATHEND 2
   214                              <1> 	%IF	PATHGEN							  ;3.30
   215                              <1> 	    %2%1E LABEL	 BYTE						  ;3.30
   216                              <1> 	%ENDIF								  ;3.30
   217                              <1> %endmacro								  ;3.30
    41                                  	%include "lmacros2.mac"
     1                              <1> [list -]
    42                                  
    43                                  	extern biocode_get_ds_dosentry, biocode_get_es_dosentry
    44                                  	extern biocode_get_ds_dosbiodata
    45                                  	extern biocode_get_es_dosbiodata
    46                                  
    47                                  	EXTRN INT2F_DISK:FAR		;MSBIO2
    48                                  	EXTRN MEDIACHECK:NEAR		;96TPI
    49                                  	EXTRN HASCHANGE:NEAR		;96TPI
    50                                  	EXTRN MEDIA_SET_VID:NEAR	;96TPI
    51                                  	EXTRN HIDENSITY:NEAR		;96TPI
    52                                  	EXTRN CHECKLATCHIO:NEAR 	;96TPI
    53                                  	EXTRN CHECKIO:NEAR		;96TPI
    54                                  	EXTRN SET_CHANGED_DL:NEAR	;96TPI
    55                                  	EXTRN SET_VOLUME_ID:NEAR	;MSVOLID
    56                                  	EXTRN SWPDSK:NEAR		;MSBIO2
    57                                  	EXTRN CMDERR:NEAR		;MSBIO1
    58                                  	EXTRN STRATEGY:NEAR		;MSBIO1
    59                                  	EXTRN ERR$CNT:NEAR		;MSBIO1
    60                                  	EXTRN DSK$IN:NEAR		;MSBIO1
    61                                  	EXTRN EXIT:NEAR 		;MSBIO1
    62                                  	EXTRN BUS$EXIT:NEAR		;MSBIO1
    63                                  	EXTRN ERR$EXIT:NEAR		;MSBIO1
    64                                  	extrn ResetChanged:near 	;AN000; MS96TPI
    65                                  
    66                                  ;DATA
    67                                  	EXTRN OLD13:DWORD		;MSBIO2
    68                                  	EXTRN PTRSAV:DWORD		;MSBIO1
    69                                  	EXTRN COM1DEV:WORD		;MSAUX
    70                                  	EXTRN DAYCNT:WORD		;MSCLOCK
    71                                  	EXTRN TIM_DRV:BYTE		;MSDATA
    72                                  	EXTRN ACCESSCOUNT:BYTE		;MSDATA
    73                                  	EXTRN SM92:BYTE 		;MSDATA
    74                                  	EXTRN DISKSECTOR:BYTE		;MSDATA
    75                                  	EXTRN MEDIABYTE:BYTE		;MSDATA
    76                                  	EXTRN SECPERCLUSINSECTOR:BYTE	;MSDATA
    77                                  	EXTRN BPB_IN_SECTOR:WORD	;MSDATA
    78                                  	EXTRN DISKSECTOR:BYTE		;MSDATA
    79                                  	EXTRN STEP_DRV:BYTE		;MSDATA
    80                                  	EXTRN START_BDS:WORD		;MSDATA
    81                                  	EXTRN PHYS_DRV:BYTE		;MSDATA
    82                                  	EXTRN WRTVERIFY:WORD		;MSDATA
    83                                  	EXTRN FSETOWNER:BYTE		;MSDATA
    84                                  	EXTRN SINGLE:BYTE		;MSDATA
    85                                  	EXTRN RFLAG:BYTE		;MSDATA
    86                                  	EXTRN MEDBYT:BYTE		;MSDATA
    87                                  	EXTRN SPSAV:WORD		;MSDATA
    88                                  	EXTRN SECCNT:WORD		;MSDATA
    89                                  	EXTRN DPT:DWORD 		;MSDATA
    90                                  	EXTRN CURSEC:BYTE,CURHD:BYTE	;MSDATA
    91                                  	EXTRN CURTRK:WORD		;MSDATA
    92                                  	EXTRN EOT:BYTE			;MSDATA
    93                                  	EXTRN MOTORSTARTUP:BYTE,SETTLECURRENT:BYTE,SETTLESLOW:BYTE ;MSDATA
    94                                  	EXTRN CURHD:BYTE		;MSDATA
    95                                  	EXTRN LSTERR:BYTE		;MSDATA
    96                                  	EXTRN ERRIN:BYTE,ERROUT:BYTE	;MSDATA
    97                                  	EXTRN PREVOPER:WORD		;MSDATA
    98                                  	EXTRN ORIG13:DWORD		;MSDATA
    99                                  	EXTRN FLAGBITS:WORD		;MSDATA
   100                                  	EXTRN NUMBER_OF_SEC:BYTE	;MSDATA
   101                                  	EXTRN FHAVE96:BYTE		;MSDATA
   102                                  	EXTRN NEW_ROM:BYTE		;MSDATA
   103                                  	EXTRN FORMT_EOT:BYTE,HDNUM:BYTE,TRKNUM:WORD,GAP_PATCH:BYTE ;MSDATA
   104                                  	EXTRN NEXT2F_13:WORD		;MSDATA
   105                                  	extrn Save_head_sttl:byte	;msbdata
   106                                  	extrn Secrete_Code:word 	;msbdata J.K. 11/7/86 Secrete code for DOS 3.3 MSBIO
   107                                  	extrn Ext_Boot_Sig:byte 	;AN000; msbdata
   108                                  	extrn Boot_Serial_L:word	;AN000; msbdata
   109                                  	extrn Boot_Serial_H:word	;AN000; msbdata
   110                                  	extrn Boot_Volume_Label:byte	;AN000; msbdata
   111                                  	extrn Boot_System_ID:byte	;AN000; msbdata
   112                                  	extrn Model_Byte:Byte		;MSBIO2
   113                                  	extrn Secondary_Model_Byte:Byte ;MSBIO2
   114                                  
   115                                  ;-----------------------------------------------------------------
   116                                  ;
   117                                  ;	DISK INTERFACE ROUTINES
   118                                  ;
   119                                  ; DEVICE ATTRIBUTE BITS:
   120                                  ;	BIT 6 - GET/SET MAP FOR LOGICAL DRIVES AND GENERIC IOCTL.
   121                                  ;
   122                                  
   123                                  MAXERR	equ	5
   124                                  LSTDRV	equ	504H
   125                                  
   126                                  ; SOME FLOPPIES DO NOT HAVE CHANGELINE.  AS A RESULT, MEDIA-CHECK WOULD
   127                                  ; NORMALLY RETURN I-DON'T-KNOW, THE DOS WOULD CONTINUALLY REREAD THE FAT, AND
   128                                  ; DISCARD CACHED DATA.	WE OPTIMIZE THIS BY IMPLEMENTING A LOGICAL DOOR-
   129                                  ; LATCH:  IT IS PHYSICALLY IMPOSSIBLE TO CHANGE A DISK IN UNDER 2 SECONDS.  WE
   130                                  ; RETAIN THE TIME OF THE LAST SUCCESSFUL DISK OPERATION AND COMPARE IT WITH
   131                                  ; THE CURRENT TIME DURING MEDIA-CHECK.	IF < 2 SECONDS AND AT LEAST 1 TIMER
   132                                  ; TICK HAS PASSED, THE WE SAY NO CHANGE.  IF > 2 SECONDS THEN WE SAY I-
   133                                  ; DON'T-KNOW.  FINALLY, SINCE WE CANNOT TRUST THE TIMER TO BE ALWAYS
   134                                  ; AVAILABLE, WE RECORD THE NUMBER OF MEDIA CHECKS THAT HAVE OCCURRED WHEN NO
   135                                  ; APPARENT TIME HAS ELAPSED.  WHILE THIS NUMBER IS < A GIVEN THRESHOLD, WE SAY
   136                                  ; NO CHANGE.  WHEN IT EXCEEDS THAT THRESHOLD, WE SAY I-DON'T-KNOW AND RESET
   137                                  ; THE COUNTER TO 0.  WHEN WE STORE THE TIME OF LAST SUCCESSFUL ACCESS, IF WE
   138                                  ; SEE THAT TIME HAS PASSED TOO, WE RESET THE COUNTER.
   139                                  ;
   140                                  ACCESSMAX	equ	5
   141                                  ;
   142                                  ; DUE TO VARIOUS BOGOSITIES, WE NEED TO CONTINUALLY ADJUST WHAT THE HEAD
   143                                  ; SETTLE TIME IS.  THE FOLLOWING ALGORITHM IS USED:
   144                                  ;
   145                                  ;   GET THE CURRENT HEAD SETTLE VALUE.
   146                                  ;   IF IT IS 0, THEN
   147                                  ;	SET SLOW = 15
   148                                  ;   ELSE
   149                                  ;	SET SLOW = VALUE
   150                                  ;   ...
   151                                  ;*********************************************
   152                                  ;************ OLD ALGORITHM ******************
   153                                  ;*   IF WE ARE SEEKING AND WRITING THEN
   154                                  ;*	 USE SLOW
   155                                  ;*   ELSE
   156                                  ;*	 USE FAST
   157                                  ;*********************************************
   158                                  ;*********** IBM'S REQUESTED LOGIC ***********
   159                                  ;   IF WE ARE SEEKING AND WRITING AND NOT ON AN AT THEN
   160                                  ;	USE SLOW
   161                                  ;   ELSE
   162                                  ;	USE FAST
   163                                  ;   ...
   164                                  ;   RESTORE CURRENT HEAD SETTLE VALUE
   165                                  ;
   166                                  
   167                                  
   168                                  section BIOCODE
   169                                  
   170                                  	public	Fat_12_ID
   171 00000000 464154313220202000      Fat_12_ID  DB  "FAT12   ",0     ;AN000;  Default System ID for floppy.
   172                                  	public	Fat_16_ID
   173 00000009 464154313620202000      Fat_16_ID  DB  "FAT16   ",0     ;AN000;
   174                                  	public	Vol_No_Name
   175 00000012 4E4F204E414D452020-     Vol_No_Name db "NO NAME    ",0  ;AN000;
   175 0000001B 202000             
   176                                  
   177                                  
   178                                  section DOSENTRY
   179                                  
   180                                  MULTRK_ON	EQU	10000000B	;User spcified Mutitrack=on, or System turns
   181                                  					; it on after handling CONFIG.SYS file as a
   182                                  					; default value, if MulTrk_flag = MULTRK_OFF1.
   183                                  MULTRK_OFF1	EQU	00000000B	;initial value. No "Multitrack=" command entered.
   184                                  MULTRK_OFF2	EQU	00000001B	;User specified Multitrack=off.
   185                                  
   186                                  	extern Set_ID_Flag, Saved_Word
   187                                  	extern VRetry_Cnt, Soft_ECC_Cnt, MultiTrk_Format_Flag
   188                                  
   189                                  	extern lbapacket
   190                                  	extern	Temp_H
   191                                  	extern	Start_Sec_H
   192                                  	extern	MulTrk_Flag
   193                                  	extern EC35_Flag
   194                                  
   195                                  
   196                                  section BIOCODE
   197                                  
   198                                         PUBLIC MEDIA$CHK
   199                                  MEDIA$CHK PROC	NEAR
   200                                   assume ds:nothing, es:nothing, ss:nothing
   201                                  	MESSAGE FTESTDISK,<"DISK MEDIA CHECK ">
   202                                  	MNUM	FTESTDISK,AX
   203                                  	MESSAGE FTESTDISK,<CR,LF>
   204 0000001E E8E803                  	CALL	SETDRIVE
   205                                   assume ds:UPB
   206 00000021 7303E9(0000)            	jc DSK$UNKNOWN
   207                                  
   208 00000026 1E                      	push ds
   209 00000027 E8(0000)                	call biocode_get_ds_dosentry	; Secrete_Code in DOSENTRY
   210                                   assume ds:DOSENTRYGROUP
   211 0000002A 813E[0000]6B6A          	cmp word [Secrete_Code], 'kj'	;J.K.11/7/86 Secrete code for DOS 3.3 IBMBIO.	; NASM port swapped text literals
   212 00000030 1F                      	pop ds
   213                                   assume ds:UPB
   214                                  media$done equ MEDIA$DONE	; NASM port label
   215 00000031 7553                    	jne	media$done		;J.K.11/7/86
   216                                  
   217                                  ; FOR NON-REMOVABLE DISKS ONLY RETURN CHANGED IF CHANGED BY FORMAT, OTHERWISE
   218                                  ; RETURN 'NOT CHANGED'.
   219 00000033 BE0100                  	MOV	SI,1			; ASSUME NO CHANGE
   220 00000036 F745230001              	TEST	WORD PTR [DI + FLAGS],FCHANGED_BY_FORMAT
   221 0000003B 741B                    	JZ	WEARENOTFAKINGIT
   222 0000003D 816523FFFE              	AND	WORD PTR [DI + FLAGS],~ FCHANGED_BY_FORMAT	; RESET FLAG
   223                                  ; IF MEDIA HAS BEEN CHANGED BY FORMAT, WE MUST ASK THE ROM. CANNOT RELY ON THE
   224                                  ; 2 SECOND TIME CHECK.
   225 00000042 1E                      	push ds
   226 00000043 E8(0000)                	call biocode_get_ds_dosbiodata
   227                                   assume ds:DOSGROUP
   228 00000046 C606[0000]FF            	MOV	byte [TIM_DRV],-1 	; ENSURE THAT WE ASK THE ROM IF MEDIA
   229                                  					; HAS CHANGED
   230 0000004B 1F                      	pop ds
   231                                   assume ds:UPB
   232 0000004C F745230100              	TEST	WORD PTR [DI + FLAGS],FNON_REMOVABLE
   233 00000051 740C                    	JZ	WEHAVEAFLOPPY
   234 00000053 BEFFFF                  	MOV	SI,-1			; INDICATE MEDIA CHANGED
   235 00000056 EB2E                    	JMP	SHORT MEDIA$DONE
   236                                  ;
   237                                  ; WE NEED TO RETURN 'NOT CHANGED' IF WE HAVE A HARD FILE.
   238                                  ;
   239                                  WEARENOTFAKINGIT:
   240                                   assume ds:UPB, es:nothing, ss:nothing
   241 00000058 F745230100              	TEST	WORD PTR [DI + FLAGS],FNON_REMOVABLE
   242 0000005D 7527                    	JNZ	MEDIA$DONE
   243                                  WEHAVEAFLOPPY:
   244 0000005F 31F6                    	XOR	SI,SI			; PRESUME "I DON'T KNOW"
   245                                  ;
   246                                  ; IF WE HAVE A FLOPPY WITH CHANGELINE SUPPORT, WE ASK THE ROM TO DETERMINE IF
   247                                  ; MEDIA HAS CHANGED. WE DO NOT PERFORM THE 2 SECOND CHECK FOR THESE DRIVES.
   248                                  ;----------------------------------------|
   249                                  ; WARNING: DO NOT CHANGE THE FOLLOWING. ;|
   250                                  ;	   IT GETS PATCHED IN MSINIT	;|
   251 00000061 E80D15                  	call ispatched
   252 00000064 720A                    	jc @F
   253                                  	PUBLIC MEDIA_PATCH		;|
   254                                  MEDIA_PATCH:				;|
   255 00000066 E8(0000)                	CALL	MEDIACHECK		;|
   256 00000069 7241                    	JC	ERR$EXITJ		;|
   257 0000006B E8(0000)                	CALL	HASCHANGE		;|
   258 0000006E 7516                    	JNZ	MEDIA$DONE		;|
   259                                  @@:
   260                                  ;----------------------------------------|
   261                                  ; IF WE COME HERE, WE HAVE A FLOPPY WITH NO CHANGELINE SUPPORT
   262 00000070 BE0100                  	MOV	SI,1			; PRESUME NO CHANGE
   263 00000073 1E                      	push ds
   264 00000074 E8(0000)                	call biocode_get_ds_dosbiodata
   265                                   assume ds:DOSGROUP
   266 00000077 A0[0000]                	MOV	AL,[TIM_DRV]		; LAST DRIVE ACCESSED
   267 0000007A 1F                      	pop ds
   268                                   assume ds:UPB
   269 0000007B 3A4504                  	CMP	AL,BYTE PTR [DI + DRIVENUM]   ;IS DRIVE OF LAST ACCESS THE SAME?
   270 0000007E 7505                    	JNZ	MEDIA$UNK		; NO, THEN "I DON'T KNOW"
   271                                  ;
   272                                  ; CHECK TO SEE IF THIS DRIVE HAS BEEN ACCESSED IN THE LAST 2 SECONDS.
   273 00000080 E82F00                  	CALL	CHECK_TIME_OF_ACCESS	; SETS SI CORRECTLY
   274 00000083 EB01                    	JMP	SHORT MEDIA$DONE
   275                                  
   276                                  MEDIA$UNK:
   277 00000085 4E                      	DEC	SI			; RETURN "I DON'T KNOW"
   278                                  ;
   279                                  ; SI NOW CONTAINS THE CORRECT VALUE FOR MEDIA CHANGE.  CLEAN UP THE LEFT OVERS
   280                                  ;
   281                                  MEDIA$DONE:
   282 00000086 E8(0000)                	call biocode_get_es_dosentry	; PTRSAV in DOSENTRY
   283                                   assume es:DOSENTRYGROUP
   284 00000089 26C41E[0000]            	LES	BX,[es:PTRSAV]		; GET ORIGINAL PACKET
   285                                   assume es:nothing
   286 0000008E 2689770E                	MOV	WORD PTR [ES:BX + TRANS],SI
   287 00000092 85F6                    	test	SI,SI
   288 00000094 7803                    	JS	INIT_PATCH_before
   289 00000096 E9(0000)                	JMP	EXIT
   290                                  MEDIA$CHK ENDP
   291                                  ;----------------------------------------|
   292                                  ; WARNING: DO NOT CHANGE THE FOLLOWING. ;|
   293                                  ;	   IT GETS PATCHED IN MSINIT	;|
   294                                  INIT_PATCH_before:
   295 00000099 E8D514                  	call ispatched
   296 0000009C 7203                    	jc @F
   297                                  	PUBLIC INIT_PATCH		;|
   298                                  INIT_PATCH PROC NEAR			;|
   299 0000009E E8(0000)                	CALL	MEDIA_SET_VID		;|
   300                                  @@:
   301                                  ;----------------------------------------|
   302 000000A1 E8(0000)                	call biocode_get_ds_dosbiodata
   303                                   assume ds:DOSGROUP
   304 000000A4 C606[0000]FF            	MOV	byte [TIM_DRV], -1	; MAKE SURE WE ASK ROM FOR MEDIA CHECK
   305                                  VOLIDOK:
   306 000000A9 E9(0000)                	JMP	EXIT
   307                                  INIT_PATCH ENDP
   308                                  
   309                                  ERR$EXITJ PROC NEAR
   310                                   assume ds:nothing, es:nothing, ss:nothing
   311                                  
   312                                  	MESSAGE FTESTCOM,<"ERR$EXITJ: ">
   313                                  	MNUM	FTESTCOM,AX
   314                                  	MESSAGE FTESTCOM,<" == ">
   315 000000AC E8FE09                  	CALL	MAPERROR
   316                                  	MNUM	FTESTCOM,AX
   317                                  	MESSAGE FTESTCOM,<CR,LF>
   318 000000AF E9(0000)                	JMP	ERR$EXIT
   319                                  ERR$EXITJ ENDP
   320                                  
   321                                  ;
   322                                  ; PERFORM A CHECK ON THE TIME PASSED SINCE THE LAST ACCESS FOR THIS PHYSICEL
   323                                  ; DRIVE.
   324                                  ; WE ARE ACCESSING THE SAME DRIVE.  IF THE TIME OF LAST SUCCESSFUL ACCESS WAS
   325                                  ; LESS THAN 2 SECONDS AGO, THEN WE MAY PRESUME THAT THE DISK WAS NOT CHANGED.
   326                                  ; RETURNS IN SI:
   327                                  ;	0 - IF TIME OF LAST ACCESS WAS >= 2 SECONDS
   328                                  ;	1 - IF TIME WAS < 2 SECONDS (I.E NO MEDIA CHANGE ASSUMED)
   329                                  ; REGISTERS AFFECTED AX,CX,DX, FLAGS.
   330                                  ;
   331                                  CHECK_TIME_OF_ACCESS PROC NEAR
   332                                  	PUBLIC CHECK_TIME_OF_ACCESS
   333                                   assume ds:UPB
   334                                  
   335 000000B2 BE0100                  	MOV	SI,1			; PRESUME NO CHANGE.
   336                                  ;SB33014*************************************************************
   337 000000B5 30E4                    	xor	AH,AH			; set command to read time
   338 000000B7 CD1A                    	int	1Ah			; call rom-bios clock routine
   339                                  ;SB33014*************************************************************
   340                                  ;
   341                                  ; NOW THAT WE ARE READING THE TIME, WE MUST MAKE SURE THAT WE DO NOT LOSE A
   342                                  ; DATE WRAP.  THE ROM WILL RETURN THE VALUE ONLY ONCE, SO WE NEED TO NOTE THIS
   343                                  ; FACT.
   344                                  ;
   345 000000B9 06                      	push es
   346 000000BA E8(0000)                	call biocode_get_es_dosbiodata
   347                                   assume es:DOSGROUP
   348 000000BD D0E8                    	SHR	AL,1
   349 000000BF 268316[0000]00          	ADC	word [es:DAYCNT],0		; ADD IT IN TO OUR REMEMBERED DAY COUNT
   350                                  ;
   351                                  ; COMPUTE ELAPSED TIME
   352                                  ;
   353 000000C5 8B4547                  	MOV	AX,WORD PTR [DI + TIM_LO]   ; GET STORED TIME
   354 000000C8 29C2                    	SUB	DX,AX
   355 000000CA 8B4549                  	MOV	AX,WORD PTR [DI + TIM_HI]
   356 000000CD 19C1                    	SBB	CX,AX
   357                                  ;
   358                                  ; CX:DX IS THE ELAPSED TIME
   359                                  ;
   360 000000CF 751D                    	JNZ	TIMECHECK_UNK		; CX <> 0 => > 1 HOUR
   361 000000D1 85D2                    	test	DX,DX			; TIME MUST PASS
   362 000000D3 7514                    	JNZ	TIMEPASSED		; YES, EXAMINE MAX VALUE
   363                                  ;
   364                                  ; NO NOTICEABLE TIME HAS PASSED.  WE CANNOT TRUST THE COUNTER TO BE ALWAYS
   365                                  ; AVAILABLE AS THERE ARE BOGUS PROGRAMS THAT GO AND REPROGRAM THE THING.  WE
   366                                  ; KEEP A COUNT OF THE NUMBER OF MEDIA CHECKS THAT WE'VE SEEN THAT DO NOT HAVE
   367                                  ; ANY TIME PASSING.  IF WE EXCEED A GIVE THRESHOLD, WE GIVE UP ON THE TIMER.
   368                                  ;
   369 000000D5 26FE06[0000]            	INC	BYTE [es:ACCESSCOUNT]
   370 000000DA 26803E[0000]05          	CMP	BYTE [es:ACCESSCOUNT],ACCESSMAX
   371 000000E0 720D                    	JB	TIMECHECK_RET		; IF COUNT IS LESS THAN THRESHOLD, OK
   372 000000E2 26FE0E[0000]            	DEC	BYTE [es:ACCESSCOUNT]	; DON'T LET THE COUNT WRAP
   373 000000E7 EB05                    	JMP	SHORT TIMECHECK_UNK	; "I DON'T KNOW" IF MEDIA CHANGED
   374                                  ;
   375                                  ; 18.2 TICS PER SECOND.
   376                                  ;
   377                                  TIMEPASSED:
   378 000000E9 83FA24                  	CMP	DX,18 * 2		; MIN ELAPSED TIME?
   379 000000EC 7601                    	JBE	TIMECHECK_RET		; YES, PRESUME NO CHANGE
   380                                  ;
   381                                  ; EVERYTHING INDICATES THAT WE DO NOT KNOW WHAT HAS HAPPENED.
   382                                  ;
   383                                  TIMECHECK_UNK:
   384 000000EE 4E                      	DEC	SI			 ; PRESUME I DON'T KNOW
   385                                  TIMECHECK_RET:
   386 000000EF 07                      	pop es
   387                                   assume es:nothing
   388 000000F0 C3                      	RET
   389                                  CHECK_TIME_OF_ACCESS ENDP
   390                                  
   391 000000F1 EBB9                    ERR$EXITJ2: JMP ERR$EXITJ
   392                                  ;
   393                                  ; BUILD A VALID BPB FOR THE DISK IN THE DRIVE.
   394                                  ;
   395                                  	PUBLIC GET$BPB
   396                                  GET$BPB PROC	NEAR
   397                                   assume ds:DOSGROUP, es:nothing, ss:nothing
   398                                  	MESSAGE FTESTDISK,<"DISK BUILD BPB ">
   399                                  	MNUM	FTESTDISK,AX
   400                                  	MESSAGE FTESTDISK,<CR,LF>
   401 000000F3 268A25                  	MOV	AH,BYTE PTR [ES:DI]	;GET FAT ID BYTE READ BY DOS
   402 000000F6 E81003                  	CALL	SETDRIVE		; GET THE CORRECT BDS FOR THE DRIVE
   403                                   assume ds:UPB
   404 000000F9 7303E9(0000)            	jc DSK$UNKNOWN
   405 000000FE F745230100              	TEST	WORD PTR [DI + FLAGS],FNON_REMOVABLE
   406 00000103 752B                    	JNZ	ALREADY_GOTBPB		; NO NEED TO BUILD FOR FIXED DISKS
   407                                  ;J.K. Let's set the default value for VOLID,Vol_Serial,FileSys_ID in BDS table
   408 00000105 E84200                  	call	Clear_IDs		;AN000;
   409 00000108 1E                      	push ds
   410 00000109 E8(0000)                	call biocode_get_ds_dosbiodata
   411                                   assume ds:DOSGROUP
   412 0000010C C606[0000]01            	mov	byte [Set_ID_Flag],1	;AN000; Indicate to set system id in BDS
   413 00000111 1F                      	pop ds
   414                                   assume ds:UPB
   415 00000112 E86E00                  	CALL	GETBP			;BUILD A BPB IF NECESSARY.
   416 00000115 72DA                    	JC	ERR$EXITJ2		;AN000; If error, Set_ID_flag is set to 0 already.
   417 00000117 1E                      	push ds
   418 00000118 E8(0000)                	call biocode_get_ds_dosbiodata
   419                                   assume ds:DOSGROUP
   420 0000011B 803E[0000]02            	cmp	byte [Set_ID_Flag],2	;AN000; Already, volume_Label set from Boot record
   421 00000120 C606[0000]00            	mov	byte [Set_ID_Flag],0	;AN000;  to BDS table?
   422 00000125 1F                      	pop ds
   423                                   assume ds:UPB
   424                                  Already_GotBPB equ ALREADY_GOTBPB	; NASM port label
   425 00000126 7408                    	je	Already_GotBPB		;AN000; Then do not set it again from Root directory.
   426                                  					;AN000; Otherwise, conventional Boot record.
   427                                  GET$BPB ENDP
   428                                  ;----------------------------------------|
   429                                  ; WARNING: DO NOT CHANGE THE FOLLOWING. ;|
   430                                  ;	   IT GETS PATCHED IN MSINIT	;|
   431 00000128 E84614                  	call ispatched
   432 0000012B 7203                    	jc @F
   433                                  	PUBLIC SET_PATCH		;|
   434                                  SET_PATCH PROC	NEAR			;|
   435 0000012D E8(0000)                	CALL	SET_VOLUME_ID		;|
   436                                  @@:
   437                                  ;----------------------------------------|
   438                                  	MESSAGE FTESTDISK,<"SET VOLUME ID">
   439                                  	MNUM	FTESTDISK,DI
   440                                  	MESSAGE FTESTDISK,<"  ">
   441                                  	MNUM	FTESTDISK,DS
   442                                  	MESSAGE FTESTDISK,<CR,LF>
   443                                  
   444                                  ALREADY_GOTBPB:
   445 00000130 83C706                  	ADD	DI,BYTEPERSEC		; RETURN THE BPB THAT IS IN THE CURRENT BDS
   446                                  
   447                                  	PUBLIC	SETPTRSAV
   448                                  SETPTRSAV:				; RETURN POINT FOR DSK$INIT
   449                                   assume ds:nothing, es:nothing, ss:nothing
   450 00000133 E8(0000)                	call biocode_get_es_dosentry	; PTRSAV in DOSENTRY
   451                                   assume es:DOSENTRYGROUP
   452 00000136 26C41E[0000]            	LES	BX,[es:PTRSAV]
   453                                   assume es:nothing
   454 0000013B 2688670D                	MOV	[ES:BX + MEDIA],AH
   455 0000013F 26897F12                	MOV	[ES:BX + COUNT],DI
   456 00000143 268C5F14                	MOV	[ES:BX + COUNT + 2],DS
   457 00000147 E9(0000)                	JMP	EXIT
   458                                  SET_PATCH ENDP
   459                                  
   460                                  ;J.K. Clear IDs in BDS table. Only applied for Floppies.
   461                                  ;Input:  DS:DI -> BDS table
   462                                  ;Output: VOLID set to "NO NAME    "
   463                                  ;	 VOL_SERIAL set to 0.
   464                                  ;	 FileSys_ID set to "FAT12   " or "FAT16   "
   465                                  ;	   depending on the flag FATSIZE in BDS.
   466                                  ;All registers saved.
   467                                  	public	Clear_IDs
   468                                  Clear_IDs	proc near		;AN000;
   469                                   assume ds:UPB, es:nothing, ss:nothing
   470 0000014A 1E                      	push	ds			;AN000;
   471 0000014B 57                      	push	di			;AN000;
   472 0000014C 06                      	push	es			;AN000;
   473 0000014D 56                      	push	si			;AN000;
   474 0000014E 51                      	push	cx			;AN000;
   475                                  
   476 0000014F 31C9                    	xor cx, cx			;AN000; no serial number
   477 00000151 894D57                  	mov	word ptr [di + VOL_SERIAL],cx	 ;AN000;
   478 00000154 894D59                  	mov	word ptr [di + VOL_SERIAL + 2],cx ;AN000;
   479                                  
   480 00000157 1E                      	push	ds			;AN000;
   481 00000158 07                      	pop	es			;AN000; es -> bds
   482                                   assume es:UPB
   483 00000159 0E                      	push	cs			;AN000; get => DOSCODE
   484 0000015A 1F                      	pop	ds			;AN000; ds = cs => BIOCODE / DOSCODE
   485                                   assume ds:DOSCODEGROUP
   486                                  
   487 0000015B B10B                    	mov	cl, BOOT_VOLUME_LABEL_SIZE	 ;AN000; =11
   488                                  VOL_NO_NAME equ Vol_No_Name	; NASM port label
   489 0000015D BE[1200]                	mov	si, offset VOL_NO_NAME		 ;AN000;
   490 00000160 57                      	push	di				 ;AN000; save BDS pointer
   491 00000161 83C74B                  	add	di, VOLID			 ;AN000; points to VOLID field
   492 00000164 F3A4                    	rep	movsb				 ;AN000;
   493 00000166 5F                      	pop	di				 ;AN000; restore BDS pointer
   494 00000167 26F6451F40              	test	byte [es:di + FATSIZ], FBIG		 ;AN000;
   495 0000016C 7505                    	jnz	CI_BigFat			 ;AN000; small fat
   496                                  FAT_12_ID equ Fat_12_ID	; NASM port label
   497 0000016E BE[0000]                	mov	si, offset FAT_12_ID		 ;AN000;
   498 00000171 EB03                    	jmp	CI_Filesys			 ;AN000;
   499                                  
   500                                  CI_BigFat:					 ;AN000;
   501                                  FAT_16_ID equ Fat_16_ID	; NASM port label
   502 00000173 BE[0900]                	mov	si, offset FAT_16_ID		 ;AN000; big fat
   503                                  CI_Filesys:					 ;AN000;
   504 00000176 B108                    	mov	cl, BOOT_SYSTEM_ID_SIZE		 ;AN000; =8
   505                                  FILESYS_ID equ FILESYS_Id	; NASM port equate
   506 00000178 83C75B                  	add	di, FILESYS_ID			 ;AN000; points to FILESYS_ID field
   507 0000017B F3A4                    	rep	movsb				 ;AN000;
   508                                  
   509 0000017D 59                      	pop	cx				 ;AN000;
   510 0000017E 5E                      	pop	si				 ;AN000;
   511 0000017F 07                      	pop	es				 ;AN000;
   512                                   assume es:nothing
   513 00000180 5F                      	pop	di				 ;AN000;
   514 00000181 1F                      	pop	ds				 ;AN000;
   515                                   assume ds:UPB
   516 00000182 C3                      	ret					 ;AN000;
   517                                  Clear_IDs	endp				 ;AN000;
   518                                  
   519                                  
   520                                  ;   GETBP - RETURN BPB FROM THE DRIVE SPECIFIED BY THE BDS.
   521                                  ;	    IF THE RETURN_FAKE_BPB FLAG IS SET, THEN IT DOES NOTHING.
   522                                  ;	    NOTE THAT WE NEVER COME HERE FOR FIXED DISKS.
   523                                  ;	    FOR ALL OTHER CASES,
   524                                  ;	      - IT READS BOOT SECTOR TO PULL OUT THE BPB
   525                                  ;	      - IF NO VALID BPB IS FOUND, IT THEN READS THE FAT SECTOR,
   526                                  ;		TO GET THE FAT ID BYTE TO BUILD THE BPB FROM THERE.
   527                                  ;
   528                                  ;   INPUTS:	DS:DI POINT TO CORRECT BDS.
   529                                  ;
   530                                  ;   OUTPUTS:	FILLS IN BPB IN CURRENT BDS IF VALID BPB OR FAT ID ON DISK.
   531                                  ;		CARRY SET, AND AL=7 IF INVALID DISK.
   532                                  ;		CARRY SET AND ERROR CODE IN AL IF OTHER ERROR.
   533                                  ;		If failed to recognize the Boot Record, then will set the
   534                                  ;		Set_ID_Flag to 0.
   535                                  ;		J.K. This routine will only work for a floppy diskette.
   536                                  ;		     For a fixed disk, it will just return.
   537                                  
   538                                  	PUBLIC GETBP
   539                                  GETBP	PROC	NEAR
   540                                   assume ds:UPB, es:nothing, ss:nothing
   541                                  ; IF RETURNING FAKE BPB THEN RETURN BPB AS IS.
   542 00000183 F745230500              	TEST	WORD PTR [DI + FLAGS],RETURN_FAKE_BPB | FNON_REMOVABLE
   543 00000188 7403                    	JZ	GETBP1
   544 0000018A E9F700                  	JMP	GETRET_EXIT
   545                                  
   546                                  GETBP1:
   547                                  	MESSAGE FTESTDISK,<"BUILDING BPB FROM SCRATCH",CR,LF>
   548 0000018D 51520653                	SAVEREG <CX,DX,ES,BX>
   549                                  ;
   550                                  ; ATTEMPT TO READ IN BOOT SECTOR AND DETERMINE BPB.
   551                                  ; WE ASSUME THAT THE 2.X AND GREATER DOS DISKS ALL HAVE A VALID BOOT SECTOR.
   552                                  ;
   553                                  RDBOOT:
   554 00000191 E80F01                  	CALL	READBOOTSEC
   555                                   assume es:DOSENTRYGROUP
   556                                  GETBP_ERR_RET_brdg equ Getbp_err_ret_brdg	; NASM port label
   557 00000194 7264                    	JC	GETBP_ERR_RET_brdg	; CARRY SET IF THERE WAS ERROR.
   558 00000196 83FB00                  	CMP	BX,0			; BX IS 0 IF BOOT SECTOR IS VALID.
   559 00000199 7562                    	JNZ	DOFATBPB
   560                                  
   561                                  ; MOVES THE BPB READ FROM THE BOOT SECTOR INTO REGISTERS FOR USE BY
   562                                  ; GETBP ROUTINE AT HAS1
   563                                  ;J.K.-
   564                                  ; If the Set_ID_Flag is 1, and if an extended Boot Record, then set Volume
   565                                  ; Serial Number, Volume Label, File System ID in BDS according to
   566                                  ; the BOOT reocrd.  After that, this routine will set the Set_ID_Flag to 2
   567                                  ; to signal that VOLUME Label is set already from the Extended BOOT record
   568                                  ; (so, don't set it again by calling "SET_VOLUME_ID" routine which uses
   569                                  ; the volume label in the root directory.
   570                                  
   571                                  ;	CALL	MOVBPB			; MOVE BPB INTO REGISTERS.
   572                                  ;MOVBPB	PROC	NEAR
   573 0000019B 26A1[0600]              	mov ax, word [es:BPB_IN_SECTOR + DIRNUM]
   574 0000019F 89450C                  	mov word [di + CDIR], ax
   575 000001A2 26A1[0B00]              	mov ax, word [es:BPB_IN_SECTOR + FATSIZE]
   576 000001A6 894511                  	mov word [di + CSECFAT], ax
   577 000001A9 26A1[0300]              	mov ax, word [es:BPB_IN_SECTOR + RESNUM]
   578 000001AD 894509                  	mov word [di + RESSEC], ax
   579 000001B0 26A0[0500]              	mov al, byte [es:BPB_IN_SECTOR + FATNUM]
   580 000001B4 88450B                  	mov byte [di + CFAT], al
   581                                  
   582 000001B7 1E57                    	SAVEREG <DS,DI>
   583 000001B9 06                      	PUSH	es
   584 000001BA 1F                      	POP	DS
   585                                   assume ds:DOSENTRYGROUP
   586 000001BB BF[0000]                	MOV	DI,OFFSET BPB_IN_SECTOR		; access with ds
   587 000001BE 8A7502                  	MOV	DH,BYTE PTR [DI + SECALL]     ;SECTORS PER UNIT
   588 000001C1 8A7D06                  	MOV	BH,BYTE PTR [DI + DIRNUM]     ;NUMBER OF DIRECTORY ENTRIES
   589 000001C4 8B4D08                  	MOV	CX,WORD PTR [DI + SECNUM]     ;SIZE OF DRIVE
   590 000001C7 8A650A                  	MOV	AH,BYTE PTR [DI + FATID]	    ;MEDIA DESCRIPTOR
   591 000001CA 8A450B                  	MOV	AL,BYTE PTR [DI + FATSIZE]    ;NUMBER OF FAT SECTORS
   592 000001CD 8A5D0D                  	MOV	BL,BYTE PTR [DI + SLIM]	    ;SECTORS PER TRACK
   593 000001D0 8A550F                  	MOV	DL,BYTE PTR [DI + HLIM]	    ;NUMBER OF HEADS
   594 000001D3 5F1F                    	RESTOREREG <DI,DS>
   595                                   assume ds:UPB
   596 000001D5 E8(0000)                	call biocode_get_es_dosbiodata
   597                                   assume es:DOSGROUP
   598 000001D8 26803E[0000]01          	cmp	byte [es:Set_ID_Flag], 1	     ;AC008 called by GET$BPB?
   599 000001DE 7516                    	jne	MovBPB_Ret		     ;AC008
   600 000001E0 E83401                  	call	Mov_Media_IDs		     ;AC008
   601 000001E3 7206                    	jc	MovBPB_Conv		     ;AC008 Conventional boot record?
   602 000001E5 26C606[0000]02          	mov	byte [es:Set_ID_Flag],2	     ;AC008 signals that Volume ID is set.
   603                                  MovBPB_Conv:				     ;AC008
   604                                  fHave96 equ FHAVE96	; NASM port label
   605 000001EB 26803E[0000]01          	cmp	byte [es:fHave96], 1		     ;AC008
   606 000001F1 7503                    	jne	MovBPB_Ret		     ;AC008
   607 000001F3 E8(0000)                	call	ResetChanged		     ;AC008 Reset Flags in BDS to NOT fCHANGED.
   608                                  MovBPB_Ret:				     ;AC008
   609 000001F6 F8                      	clc				     ;AC008
   610                                  ;MOVBPB	ENDP				     ;AC008
   611 000001F7 EB61                    	JMP	HAS1
   612 000001F9 90                      	nop	; identicalise
   613                                  
   614                                  Getbp_err_ret equ GETBP_ERR_RET	; NASM port label
   615 000001FA E98800                  Getbp_err_ret_brdg: jmp Getbp_err_ret
   616                                  ;
   617                                  ; WE HAVE A 1.X DISKETTE.
   618                                  ; IN THIS CASE READ IN THE FAT ID BYTE AND FILL IN BPB FROM THERE.
   619                                  ;
   620                                  DOFATBPB:
   621                                   assume ds:UPB
   622 000001FD E85D01                  	CALL	READFAT			; PUTS MEDIA DESCRIPTOR BYTE IN AH
   623                                   assume es:DOSENTRYGROUP
   624                                  GETBP_ERR_RET_Brdg equ Getbp_err_ret_brdg	; NASM port label
   625 00000200 72F8                    	JC	GETBP_ERR_RET_Brdg
   626                                  ;----------------------------------------|
   627                                  ; WARNING: DO NOT CHANGE THE FOLLOWING. ;|
   628                                  ;	   IT GETS PATCHED IN MSINIT	;|
   629 00000202 E86C13                  	call ispatched
   630 00000205 7203                    	jc @F
   631                                  	PUBLIC GETBP1_PATCH		;|
   632                                  GETBP1_PATCH:				;|
   633 00000207 E8(0000)                	CALL	HIDENSITY		;|
   634                                  @@:
   635                                  ;----------------------------------------|
   636                                  ;TEST FOR A VALID 3.5" MEDIUM
   637 0000020A 807D2202                	CMP	byte [DI + FORMFACTOR],FFSMALL
   638 0000020E 751C                    	JNZ	IS_FLOPPY
   639 00000210 80FCF9                  	CMP	AH,0F9H			; IS IT A VALID FAT ID BYTE FOR 3.5" ?
   640 00000213 757F                    	jnz short	GOT_UNKNOWN_MEDIUM
   641 00000215 BB[0000]                	MOV	BX,OFFSET SM92		; POINTER TO CORRECT BPB
   642 00000218 E8(0000)                	call biocode_get_es_dosbiodata
   643                                   assume es:DOSGROUP
   644                                  
   645                                  ;J.K. DS points to segment of BDS. The following should be modified
   646                                  ;J.K. to get spf,csec,spa,spt correctly. It had been wrong if DRIVER.SYS
   647                                  ;J.K. is loaded since the BDS is inside the driver.sys.
   648 0000021B 268A07                  	MOV	AL,[es:BX + SPF]
   649 0000021E 268B4F03                	MOV	CX,[es:BX + CSEC]
   650 00000222 268B5705                	MOV	DX,WORD PTR [es:BX + SPA]
   651 00000226 268B5F01                	MOV	BX,WORD PTR [es:BX + SPT]
   652 0000022A EB2E                    	JMP	SHORT HAS1
   653                                  ; MUST BE A 5.25" FLOPPY IF WE COME HERE
   654                                  IS_FLOPPY:
   655                                   assume es:DOSENTRYGROUP
   656 0000022C 88E1                    	MOV	CL,AH			;SAVE MEDIA
   657 0000022E 80E1F8                  	AND	CL,0F8H			;NORMALIZE
   658 00000231 80F9F8                  	CMP	CL,0F8H			;COMPARE WITH GOOD MEDIA BYTE
   659 00000234 755E                    	JNZ	GOT_UNKNOWN_MEDIUM
   660                                  
   661                                  GOODID:
   662 00000236 B001                    	MOV	AL,1			;SET NUMBER OF FAT SECTORS
   663 00000238 BB0840                  	MOV	BX,64*256+8		;SET DIR ENTRIES AND SECTOR MAX
   664 0000023B B94001                  	MOV	CX,40*8			;SET SIZE OF DRIVE
   665 0000023E BA0101                  	MOV	DX,01*256+1		;SET HEAD LIMIT AND SEC/ALL UNIT
   666 00000241 F6C402                  	TEST	AH,00000010B		;TEST FOR 8 OR 9 SECTOR
   667 00000244 7507                    	JNZ	HAS8			;NZ = HAS 8 SECTORS
   668 00000246 FEC0                    	INC	AL			;INC NUMBER OF FAT SECTORS
   669 00000248 FEC3                    	INC	BL			;INC SECTOR MAX
   670 0000024A 83C128                  	ADD	CX,40			;INCREASE SIZE
   671                                  HAS8:
   672 0000024D F6C401                  	TEST	AH,00000001B		;TEST FOR 1 OR 2 HEADS
   673 00000250 7408                    	JZ	HAS1			;Z = 1 HEAD
   674 00000252 01C9                    	ADD	CX,CX			;DOUBLE SIZE OF DISK
   675 00000254 B770                    	MOV	BH,112			;INCREASE NUMBER OF DIRECTORY ENTRIES
   676 00000256 FEC6                    	INC	DH			;INC SEC/ALL UNIT
   677 00000258 FEC2                    	INC	DL			;INC HEAD LIMIT
   678                                  
   679                                  HAS1:
   680                                  	PUBLIC	HAS1
   681                                   assume es:nothing
   682                                  
   683 0000025A 887508                  	MOV	BYTE PTR [DI + SECPERCLUS],DH
   684 0000025D 887D0C                  	MOV	BYTE PTR [DI + CDIR],BH
   685 00000260 894D0E                  	MOV	WORD PTR [DI + DRVLIM],CX
   686 00000263 886510                  	MOV	BYTE PTR [DI + MEDIAD],AH
   687 00000266 884511                  	MOV	BYTE PTR [DI + CSECFAT],AL
   688 00000269 885D13                  	MOV	BYTE PTR [DI + SECLIM],BL
   689 0000026C B600                    	mov dh, 0
   690 0000026E 895515                  	MOV	word PTR [DI + HDLIM], dx
   691                                  ;SB34DISK001*******************************************************************
   692                                  ;SB	the HIDSEC_H field and HIDSEC_L field and the
   693                                  ;SB	DRVLIM_H fields need to be set to 0 since this code here is for floppies
   694                                  ;SB		3 LOCS
   695                                  
   696 00000271 C745190000              	mov	word ptr [di + HIDSEC_H],0
   697 00000276 C745170000              	mov	word ptr [di + HIDSEC_L],0
   698 0000027B C7451D0000              	mov	word ptr [di + DRVLIM_H],0
   699                                  
   700                                  ;SB34DISK001*******************************************************************
   701                                  GETRET:
   702 00000280 5B                      	POP	BX
   703 00000281 075A59                  	RESTOREREG <ES,DX,CX>
   704                                   ASSUME ES:NOTHING
   705                                  
   706                                  GETRET_EXIT:
   707 00000284 C3                      	RET
   708                                  
   709                                  GETBP_ERR_RET:
   710                                  ;J.K. Before doing anything else, set Set_ID_Flag to 0.
   711 00000285 1E                      	push ds
   712 00000286 E8(0000)                	call biocode_get_ds_dosbiodata
   713                                   assume ds:DOSGROUP
   714 00000289 C606[0000]00            	mov	byte [Set_ID_Flag], 0	;AN000;
   715 0000028E 1F                      	pop ds
   716                                   assume ds:nothing
   717 0000028F E81B08                  	CALL	MAPERROR
   718 00000292 EBEC                    	JMP	SHORT GETRET
   719                                  ;
   720                                  ; WE HAVE A 3.5" DISKETTE FOR WHICH WE CANNOT BUILD A BPB. WE DO NOT ASSUME ANY
   721                                  ; TYPE OF BPB FOR THIS MEDIUM.
   722                                  ;
   723                                  GOT_UNKNOWN_MEDIUM:
   724 00000294 1E                      	push ds
   725 00000295 E8(0000)                	call biocode_get_ds_dosbiodata
   726                                   assume ds:DOSGROUP
   727 00000298 C606[0000]00            	mov	byte [Set_ID_Flag], 0	;AN000;
   728 0000029D 1F                      	pop ds
   729                                   assume ds:nothing
   730 0000029E B007                    	MOV	AL,ERROR_UNKNOWN_MEDIA
   731 000002A0 F9                      	STC
   732 000002A1 EBDD                    	JMP	SHORT GETRET
   733                                  GETBP	ENDP
   734                                  
   735                                  BPBTYPE STRUC
   736 00000000 ??                      SPF	DB	?
   737 00000001 ??                      SPT	DB	?
   738 00000002 ??                      CDIRE	DB	?
   739 00000003 ????                    CSEC	DW	?
   740 00000005 ??                      SPA	DB	?
   741 00000006 ??                      CHEAD	DB	?
   742                                  BPBTYPE ENDS
   743                                  
   744                                  ;
   745                                  ; READ IN THE BOOT SECTOR. SET CARRY IF ERROR IN READING SECTOR.
   746                                  ; BX IS SET TO 1 IF THE BOOT SECTOR IS INVALID, OTHERWISE IT IS 0.
   747                                  ;
   748                                  READBOOTSEC PROC NEAR
   749 000002A3 B600                    	 MOV	 DH,0			    ;HEAD 0
   750 000002A5 B90100                  	 MOV	 CX,0001		    ;CYLINDER 0, SECTOR 1
   751 000002A8 E8C400                  	 CALL	 READ_SECTOR
   752                                   assume es:DOSENTRYGROUP
   753 000002AB 7269                    	 JC	 ERR_RET
   754 000002AD 31DB                    	 XOR	 BX,BX			    ; ASSUME VALID BOOT SECTOR.
   755                                  
   756                                  ;*******************************************************************************
   757                                  ; PUT A SANITY CHECK FOR THE BOOT SECTOR IN HERE TO DETECT BOOT SECTORS THAT
   758                                  ; DO NOT HAVE VALID BPBS.
   759                                  ; WE EXAMINE THE FIRST TWO BYTES - THEY MUST CONTAIN A LONG JUMP (69H) OR A
   760                                  ; SHORT JUMP (EBH) FOLLOWED BY A NOP (90H), OR A SHORT JUMP (E9H).
   761                                  ; IF THIS TEST IS PASSED, WE FURTHER CHECK BY EXAMINING THE SIGNATURE AT
   762                                  ; THE END OF THE BOOT SECTOR FOR THE WORD AA55H.
   763                                  ; IF THE SIGNATURE IS NOT PRESENT, WE EXAMINE THE MEDIA DESCRIPTOR BYTE TO
   764                                  ; SEE IF IT IS VALID.
   765                                  ;J.K. 10/15/86 DCR00012. For DOS 3.3, this logic is modified a little bit.
   766                                  ; We are not going to check Signature.	Instead we are going to sanity
   767                                  ; check the media byte in BPB regardless of the validity of signature.
   768                                  ; This is to save the already developed commercial products that have
   769                                  ; good jump instruction and signature but with the false BPB informations
   770                                  ; that will crash the diskette drive operation. (For example, Symphony diskette).
   771                                  ;******************************************************************************
   772 000002AF 26803E[0000]69          	 CMP	BYTE PTR [es:DISKSECTOR],069H	; IS IT A DIRECT JUMP?
   773 000002B5 7418                    	 JE	Check_bpb_MediaByte		; DON'T NEED TO FIND A NOP
   774 000002B7 26803E[0000]E9          	 CMP	BYTE PTR [es:DISKSECTOR],0E9H	; DOS 2.0 JUMP?
   775 000002BD 7410                    	 JE	Check_bpb_MediaByte		; NO NEED FOR NOP
   776 000002BF 26803E[0000]EB          	 CMP	BYTE PTR [es:DISKSECTOR],0EBH	; HOW ABOUT A SHORT JUMP.
   777 000002C5 754C                    	 JNE	INVALIDBOOTSEC
   778 000002C7 26803E[0200]90          	 CMP	BYTE PTR [es:DISKSECTOR + 2],090H ; IS NEXT ONE A NOP?
   779 000002CD 7544                    	 JNE	INVALIDBOOTSEC
   780                                  
   781                                  
   782                                  ;J.K. 10/15/86 Don't have to perform the following signature check since
   783                                  ; we need to check the media byte even with the good signatured diskette.
   784                                  ;CHECK_SIGNATURE:
   785                                  ;	  CMP	  WORD PTR [es:DISKSECTOR+1FEH],0AA55H	 ; SEE IF NON-IBM DISK OR 1.X
   786                                  ;						   ; MEDIA.
   787                                  ;	  JZ	  CHECKSINGLESIDED	 ; GO SEE IF SINGLE SIDED MEDIUM. MAY
   788                                  ;					 ; NEED SOME SPECIAL HANDLING
   789                                  ;
   790                                  ; CHECK FOR NON-IBM DISKS WHICH DO NOT HAVE THE SIGNATURE AA55 AT THE
   791                                  ; END OF THE BOOT SECTOR, BUT STILL HAVE A VALID BOOT SECTOR. THIS IS DONE
   792                                  ; BY EXAMINING THE MEDIA DESCRIPTOR IN THE BOOT SECTOR.
   793                                  ;
   794                                  
   795                                  Check_bpb_MediaByte:
   796                                  
   797 000002CF 26A0[0000]              	 MOV	 AL,BYTE PTR [es:MEDIABYTE]
   798 000002D3 24F0                    	 AND	 AL,0F0H
   799 000002D5 3CF0                    	 CMP	 AL,0F0H		; ALLOW FOR STRANGE MEDIA
   800 000002D7 753A                    	 JNZ	 INVALIDBOOTSEC
   801                                  ;
   802                                  ; THERE WERE SOME (APPARENTLY A LOT OF THEM) DISKETTES THAT HAD BEEN FORMATTED
   803                                  ; UNDER DOS 3.1 AND EARLIER VERSIONS WHICH HAVE INVALID BPBS IN THEIR BOOT
   804                                  ; SECTORS. THESE ARE SPECIFICALLY DISKETTES THAT WERE FORMATTED IN DRIVES
   805                                  ; WITH ONE HEAD, OR WHOSE SIDE 0 WAS BAD. THESE CONTAIN BPBS IN THE BOOT
   806                                  ; SECTOR THAT HAVE THE SEC/CLUS FIELD SET TO 2 INSTEAD OF 1, AS IS STANDARD
   807                                  ; IN DOS. IN ORDER TO SUPPORT THEM, WE HAVE TO INTRODUCE A "HACK" THAT WILL
   808                                  ; HELP OUR BUILD BPB ROUTINE TO RECOGNISE THESE SPECIFIC CASES, AND TO
   809                                  ; SET UP OUT COPY OF THE BPB ACCORDINGLY.
   810                                  ; WE DO THIS BY CHECKING TO SEE IF THE BOOT SECTOR IS OFF A DISKETTE THAT
   811                                  ; IS SINGLE-SIDED AND IS A PRE-DOS 3.20 DISKETTE. IF IT IS, WE SET THE
   812                                  ; SEC/CLUS FIELD TO 1. IF NOT, WE CARRY ON AS NORMAL.
   813                                  CHECKSINGLESIDED:
   814 000002D9 26A0[0000]              	MOV	AL,BYTE PTR [es:MEDIABYTE]
   815 000002DD A801                    	TEST	AL,0001H	; IS LOW BIT SET? - INDICATES DOUBLE SIDED
   816 000002DF 7533                    	JNZ	GOODDSK
   817 000002E1 26803E[0000]02          	cmp	BYTE PTR [es:SECPERCLUSINSECTOR], 2
   818 000002E7 752B                    	jne	GOODDSK
   819 000002E9 26813E[0800]322E        	CMP	WORD PTR [es:DISKSECTOR+8],("." << 8) + "2"
   820 000002F0 7419                    	je	MUSTBEEARLIER
   821 000002F2 26813E[0800]332E        	CMP	WORD PTR [es:DISKSECTOR+8],("." << 8) + "3"
   822 000002F9 7519                    	jne	GOODDSK
   823 000002FB 26803E[0A00]30          	CMP	BYTE PTR [es:DISKSECTOR+10],"0"
   824 00000301 7211                    	jb	GOODDSK
   825 00000303 26803E[0A00]32          	CMP	BYTE PTR [es:DISKSECTOR+10],"2"
   826 00000309 7309                    	JAE	GOODDSK
   827                                  
   828                                  ; WE MUST HAVE A PRE-3.20 DISKETTE. SET THE SEC/CLUS FIELD TO 1
   829                                  MUSTBEEARLIER:
   830 0000030B 26C606[0000]01          	MOV	BYTE PTR [es:SECPERCLUSINSECTOR],1
   831 00000311 EB01                    	JMP	SHORT GOODDSK
   832                                  ;******************************************************************************
   833                                  
   834                                  INVALIDBOOTSEC:
   835 00000313 43                      	 INC	 BX			    ; INDICATE THAT BOOT SECTOR INVALID
   836                                  GOODDSK:				    ; CARRY ALREADY RESET
   837 00000314 F8                      	 CLC
   838 00000315 C3                      	 RET
   839                                  
   840                                  ERR_RET:				    ; CARRY IS ALREADY SET ON ENTRY HERE
   841                                  	 MESSAGE FTESTDISK,<"ERROR IN READBOOT",CR,LF>
   842 00000316 C3                      	 RET
   843                                  READBOOTSEC ENDP
   844                                  
   845                                  ;
   846                                  	public	Mov_Media_IDs
   847                                  Mov_Media_IDs	Proc	near		    ;AN000;
   848                                   assume ds:UPB, es:nothing, ss:nothing
   849                                  ;copy the boot_serial number, Volume id, and Filesystem id from the
   850                                  ;***Extended Boot record*** in DOSENTRY:DiskSector to the BDS table pointed
   851                                  ;by DS:DI.
   852                                  ;In.) DS:DI -> BDS
   853                                  ;     DOSENTRY:DiskSector = Valid extended boot record.
   854                                  ;Out.) Vol_Serial, Volid and System_Id in BDS are set according to
   855                                  ;      the boot record information.
   856                                  ;     Carry flag set if not an extended BPB.
   857                                  ;     All registers saved except the flag.
   858                                  
   859 00000317 06                      	push	es			    ;AN000;
   860 00000318 E8(0000)                	call biocode_get_es_dosentry	; DISKSECTOR in DOSENTRY
   861                                   assume es:DOSENTRYGROUP
   862 0000031B 26803E[0000]29          	cmp	byte [es:Ext_Boot_Sig], EXT_BOOT_SIGNATURE ;AN000; = 41
   863 00000321 7537                    	jne	MMI_Not_Ext		    ;AN000;
   864 00000323 51                      	push	cx			    ;AN000;
   865 00000324 268B0E[0000]            	mov	cx, [es:Boot_Serial_L]	    ;AN000;
   866 00000329 894D57                  	mov	word ptr [di + VOL_SERIAL],cx	 ;AN000;
   867 0000032C 268B0E[0000]            	mov	cx, [es:Boot_Serial_H]		 ;AN000;
   868 00000331 894D59                  	mov	word ptr [di + VOL_SERIAL+2],cx ;AN000;
   869 00000334 1E                      	push	ds			    ;AN000; Save regs.
   870 00000335 57                      	push	di			    ;AN000;
   871 00000336 56                      	push	si			    ;AN000;
   872                                  
   873 00000337 06                      	push es
   874 00000338 1E                      	push ds				; swap es, ds
   875 00000339 07                      	pop es				; es => UPB
   876 0000033A 1F                      	pop ds				; ds => DOSENTRY
   877                                   assume ds:DOSENTRYGROUP, es:UPB
   878                                  
   879 0000033B B90B00                  	mov	cx, BOOT_VOLUME_LABEL_SIZE  ;AN000;
   880 0000033E BE[0000]                	mov	si, offset Boot_Volume_Label;AN000; access with ds
   881 00000341 57                      	push	di
   882 00000342 83C74B                  	add	di, VOLID		    ;AN000;
   883 00000345 F3A4                    	rep	movsb			    ;AN000;
   884 00000347 5F                      	pop	di
   885 00000348 B90800                  	mov	cx, BOOT_SYSTEM_ID_SIZE     ;AN000;  =8
   886 0000034B BE[0000]                	mov	si, offset Boot_System_ID   ;AN000; accexd with ds
   887 0000034E 83C75B                  	add	di, FILESYS_ID		    ;AN000;
   888 00000351 F3A4                    	rep	movsb			    ;AN000;
   889                                  
   890 00000353 5E                      	pop	si			    ;AN000;
   891 00000354 5F                      	pop	di			    ;AN000;
   892 00000355 1F                      	pop	ds			    ;AN000;
   893                                   assume ds:UPB
   894 00000356 59                      	pop	cx			    ;AN000;
   895 00000357 F8                      	clc				    ;AN000;
   896                                  MMI_Ret:				    ;AN000;
   897 00000358 07                      	pop	es			    ;AN000;
   898                                   assume es:nothing
   899 00000359 C3                      	ret				    ;AN000;
   900                                  MMI_Not_Ext:				    ;AN000;
   901 0000035A 07                      	pop	es			    ;AN000;
   902                                   assume es:nothing
   903 0000035B F9                      	stc				    ;AN000;
   904 0000035C C3                      	ret				    ;AN000;
   905                                  Mov_Media_IDs	endp			    ;AN000;
   906                                  
   907                                  
   908                                  ; READ IN THE FAT SECTOR AND GET THE MEDIA BYTE FROM IT.
   909                                  ; INPUT : AL CONTAINS LOGICAL DRIVE.
   910                                  ; OUTPUT:
   911                                  ;	  CARRY SET IF AN ERROR OCCURS, AX CONTAINS ERROR CODE.
   912                                  ;	  OTHERWISE, AH CONTAINS MEDIA BYTE ON EXIT. AL IS PRESERVED.
   913                                  
   914                                  READFAT PROC	NEAR
   915                                   assume ds:nothing, es:nothing, ss:nothing
   916 0000035D 50                      	PUSH	AX			    ; PRESERVE LOGICAL DRIVE IN AL
   917 0000035E B600                    	MOV	DH,0			    ; HEAD 0
   918 00000360 B90200                  	MOV	CX,0002 		    ; CYLINDER 0, SECTOR 2
   919 00000363 E80900                  	CALL	READ_SECTOR		    ; es:BX POINTS TO FAT SECTOR
   920                                   assume es:DOSENTRYGROUP
   921 00000366 7205                    	JC	BAD_FAT_RET
   922 00000368 58                      	POP	AX			    ; RESET LOGICAL DRIVE
   923 00000369 268A27                  	MOV	AH,BYTE PTR [es:BX]	    ; MEDIA BYTE
   924 0000036C C3                      	RET
   925                                  
   926                                  BAD_FAT_RET:				     ; CARRY SET ON ENTRY
   927                                  	MESSAGE FTESTDISK,<"ERROR IN FAT READ",CR,LF>
   928 0000036D 59                      	POP	CX			     ; CLEAR STACK
   929 0000036E C3                      	RET
   930                                  READFAT ENDP
   931                                  
   932                                  ; READ A SINGLE SECTOR INTO THE TEMP BUFFER.
   933                                  ; PERFORM THREE RETRIES IN CASE OF ERROR.
   934                                  ;   INPUTS:	DRIVE HAS PHYSICAL DRIVE TO USE
   935                                  ;		CX HAS SECTOR AND CYLINDER
   936                                  ;		DH HAS HEAD
   937                                  ;   OUTPUTS:	CARRY CLEAR
   938                                  ;		    es:BX POINT TO SECTOR
   939                                  ;		CARRY SET
   940                                  ;		    AX HAS ROM ERROR CODE
   941                                  ; REGISTERS ES AND BP ARE PRESERVED.
   942                                  ; OUT:		es => DOSENTRY
   943                                  
   944                                  READ_SECTOR PROC NEAR
   945                                  	PUBLIC READ_SECTOR
   946                                   assume ds:UPB, es:nothing
   947                                  
   948 0000036F 55                      	PUSH	BP
   949 00000370 BD0300                  	MOV	BP,3		; MAKE 3 ATTEMPTS
   950                                  ;SB33015*****************************************************************
   951                                  DriveNum equ DRIVENUM	; NASM port equate
   952 00000373 8A5504                  	mov	DL, byte ptr [di + DriveNum]			       ;SB;3.30*
   953                                  DiskSector equ DISKSECTOR	; NASM port label
   954 00000376 BB[0000]                	mov	BX, offset DiskSector	; Get ES:BX to point to buffer ;SB;3.30*
   955 00000379 E8(0000)                	call biocode_get_es_dosentry	; DISKSECTOR in DOSENTRY
   956                                  					; now ES:BX is correct	       ;SB;3.30*
   957                                   assume es:DOSENTRYGROUP
   958                                  ;SB33015*****************************************************************
   959                                  RD_RET:
   960                                  ;SB33016*****************************************************************
   961 0000037C B80102                  	mov	AX, 0201h		; number of sectors to 1 (AL=1);SB;3.30*
   962 0000037F CD13                    	int	13h			; call rom-bios disk routines  ;SB;3.30*
   963                                  
   964                                  ;SB33016*****************************************************************
   965 00000381 7358                    	JNC	OKRET2
   966                                  Rd_rty:
   967 00000383 E8D90E                  	CALL	AGAIN		; RESET DISK, DECREMENT BP, PRESERVE AX
   968                                  Err_RD_RET equ ERR_RD_RET	; NASM port label
   969 00000386 7450                    	jz	Err_RD_RET
   970                                  flags equ FLAGS	; NASM port equate
   971                                  fNon_Removable equ FNON_REMOVABLE	; NASM port equate
   972 00000388 F745230100              	test	word ptr [di + flags],fNon_Removable
   973 0000038D 75ED                    	JNZ	RD_RET
   974 0000038F 06                      	push es
   975 00000390 E8(0000)                	call biocode_get_es_dosbiodata
   976                                   assume es:DOSGROUP
   977                                  Media_Set_For_Format equ MEDIA_SET_FOR_FORMAT	; NASM port label
   978 00000393 26803E[FF00]00          	cmp	byte [es:Media_Set_For_Format], 0 ;AN012;
   979 00000399 7514                    	jne	Rd_Skip1_DPT	;AN012;
   980 0000039B 1E                      	push	ds		;J.K. 11/7/86 For retry, set the head settle time
   981 0000039C 50                      	push	ax		;to 0Fh. PTM845.
   982 0000039D 26C536[0000]            	lds	si,[es:DPT]
   983                                   assume ds:nothing
   984                                  disk_head_sttl equ DISK_HEAD_STTL	; NASM port equate
   985 000003A2 8A4409                  	mov	al, [si + disk_head_sttl]
   986                                  save_head_sttl equ Save_head_sttl	; NASM port label
   987 000003A5 26A2[0000]              	mov	[es:save_head_sttl],al
   988                                  NormSettle equ NORMSETTLE	; NASM port equate
   989 000003A9 C644090F                	mov	byte ptr [si + disk_head_sttl], NormSettle
   990 000003AD 58                      	pop	ax
   991 000003AE 1F                      	pop	ds
   992                                   assume ds:UPB
   993                                  Rd_Skip1_DPT:			;AN012;
   994 000003AF 07                      	pop es
   995                                   assume es:DOSENTRYGROUP
   996                                  ;SB33017*****************************************************************
   997                                  					; SET CMD TO READ (AH=2) AND  ;SB ;3.30
   998 000003B0 B80102                  	MOV	AX, 0201h		; NUM OF SECTORS TO 1 (AL=1)  ;SB ;3.30
   999 000003B3 CD13                    	INT	13h			; CALL ROM-BIOS DISK ROUTINES ;SB ;3.30
  1000                                  ;SB33017*****************************************************************
  1001 000003B5 06                      	push es
  1002 000003B6 E8(0000)                	call biocode_get_es_dosbiodata
  1003                                   assume es:DOSGROUP
  1004 000003B9 9C                      	pushf			;AN012;
  1005 000003BA 26803E[FF00]00          	cmp	byte [es:Media_Set_For_Format], 0	;AN012;
  1006 000003C0 7510                    	jne	Rd_Skip2_DPT	       ;AN012;
  1007 000003C2 1E                      	push	ds
  1008 000003C3 50                      	push	ax
  1009 000003C4 26C536[0000]            	lds	si,[es:DPT]
  1010                                   assume ds:nothing
  1011 000003C9 26A0[0000]              	mov	al, [es:save_head_sttl]
  1012 000003CD 884409                  	mov	byte ptr [si + disk_head_sttl], al
  1013 000003D0 58                      	pop	ax
  1014 000003D1 1F                      	pop	ds
  1015                                   assume ds:UPB
  1016                                  Rd_Skip2_DPT:			;AN012;
  1017 000003D2 9D                      	popf			;AN012;
  1018 000003D3 07                      	pop es
  1019                                   assume es:DOSENTRYGROUP
  1020 000003D4 7305                    	jnc	OKRET2
  1021 000003D6 EBAB                    	jmp	Rd_rty
  1022                                  ERR_RD_RET:
  1023 000003D8 B2FF                    	MOV	DL,-1		; MAKE SURE WE ASK ROM IF MEDIA HAS CHANGED
  1024 000003DA F9                      	STC			; RETURN ERROR
  1025                                  ; UPDATE INFORMATION PERTAINING TO LAST DRIVE ACCESSED, TIME OF ACCESS, LAST
  1026                                  ; TRACK ACCESSED IN THAT DRIVE.
  1027                                  OKRET2:
  1028 000003DB 06                      	push es
  1029 000003DC E8(0000)                	call biocode_get_es_dosbiodata
  1030                                   assume es:DOSGROUP
  1031 000003DF 268816[0000]            	MOV	[es:STEP_DRV],DL	; SET UP FOR HEAD SETTLE LOGIC IN DISK.
  1032 000003E4 268816[0000]            	MOV	[es:TIM_DRV],DL 	;SAVE DRIVE LAST ACCESSED
  1033 000003E9 886D46                  	MOV	BYTE PTR [DI + TRACK],CH	; SAVE LAST TRACK ACCESSED ON THIS DRIVE
  1034 000003EC 9C                      	PUSHF				; PRESERVE FLAGS IN CASE ERROR OCCURRED
  1035 000003ED E8D706                  	CALL	SET_TIM
  1036 000003F0 9D                      	POPF				; RESTORE FLAGS
  1037 000003F1 07                      	pop es
  1038                                   assume es:DOSENTRYGROUP
  1039 000003F2 5D                      	POP	BP
  1040 000003F3 C3                      	RET
  1041                                  READ_SECTOR ENDP
  1042                                  
  1043                                  ;-----------------------------------------------------------
  1044                                  ;
  1045                                  ;		DISK REMOVABLE ROUTINE ARR 2.41
  1046                                  ;
  1047                                  
  1048                                  DSK$REM PROC	NEAR			;ARR 2.41
  1049                                  	PUBLIC	DSK$REM
  1050                                   assume ds:DOSGROUP, es:nothing, ss:nothing
  1051                                  
  1052                                  	MESSAGE FTESTDISK,<"DISK REMOVABLE ">
  1053                                  	MNUM	FTESTDISK,AX
  1054                                  	MESSAGE FTESTDISK,<CR,LF>
  1055                                  ; AL IS UNIT #
  1056 000003F4 E81200                  	CALL	SETDRIVE		; GET BDS FOR THIS DRIVE
  1057                                   assume ds:UPB
  1058 000003F7 7303E9(0000)            	jc DSK$UNKNOWN
  1059 000003FC F745230100              	TEST	WORD PTR [DI + FLAGS],FNON_REMOVABLE
  1060 00000401 7503                    	JNZ	NON_REM
  1061 00000403 E9(0000)                	JMP	EXIT
  1062                                  
  1063                                  NON_REM:
  1064 00000406 E9(0000)                	JMP	BUS$EXIT		;ARR 2.41
  1065                                  DSK$REM ENDP
  1066                                  
  1067                                  ; SETDRIVE SCANS THROUGH THE DATA STRUCTURE OF BDSS, AND RETURNS A POINTER TO
  1068                                  ; THE ONE THAT BELONGS TO THE DRIVE SPECIFIED. CARRY IS SET IF NONE EXISTS FOR
  1069                                  ; THE DRIVE.
  1070                                  ; IF THE BYTE [PHYS_DRV] IS 0 THEN
  1071                                  ; ON ENTRY, AL CONTAINS THE LOGICAL DRIVE NUMBER.
  1072                                  ; ON EXIT, DS:DI POINTS TO CORRECT BDS FOR THE DRIVE IF CARRY CLEAR.
  1073                                  
  1074                                  ; ELSE IF THE BYTE [PHYS_DRV] IS 1 THEN (ONLY USED FOR FIXED DISKS WHEN AN ECC
  1075                                  ; ERROR OCCURS)
  1076                                  ; ON ENTRY, DL CONTAINS THE PYHSICAL DRIVE NUMBER.
  1077                                  ; ON EXIT, DS:DI POINTS TO CORRECT BDS FOR THE DRIVE IF CARRY CLEAR.
  1078                                  
  1079                                  	PUBLIC SETDRIVE
  1080                                  SETDRIVE PROC	NEAR
  1081                                   assume ds:nothing, es:nothing, ss:nothing
  1082                                  	MESSAGE FTESTDISK,<"SETDRIVE",CR,LF>
  1083 00000409 53                      	PUSH	BX
  1084 0000040A E8(0000)                	call biocode_get_ds_dosbiodata
  1085                                   assume ds:DOSGROUP
  1086 0000040D C53E[0000]              	lds	di, [START_BDS]
  1087                                   assume ds:UPB
  1088                                  SCAN_LOOP:
  1089 00000411 83FFFF                  	CMP	DI,-1
  1090 00000414 741C                    	je SCAN_NONE
  1091 00000416 1E                      	push ds
  1092 00000417 E8(0000)                	call biocode_get_ds_dosbiodata
  1093                                   assume ds:DOSGROUP
  1094 0000041A 803E[0000]01            	CMP	BYTE PTR [PHYS_DRV], 1		; DOES AL HAVE PHYSICAL DRIVE?
  1095 0000041F 1F                      	pop ds
  1096                                   assume ds:UPB
  1097 00000420 7207                    	JB	USE_LOGICAL_DRV
  1098 00000422 384504                  	CMP	BYTE PTR [DI + DRIVENUM],AL
  1099 00000425 740C                    	JE	SETDRV
  1100 00000427 EB05                    	JMP	SHORT GET_NXT_BDS
  1101                                  USE_LOGICAL_DRV:
  1102 00000429 384505                  	CMP	BYTE PTR [DI + DRIVELET],AL
  1103 0000042C 7405                    	JE	SETDRV
  1104                                  GET_NXT_BDS:
  1105 0000042E C53D                    	lds di, [DI + LINK]			; GO TO NEXT BDS
  1106 00000430 EBDF                    	jmp SCAN_LOOP
  1107                                  
  1108                                  SCAN_NONE:
  1109 00000432 F9                      	STC
  1110                                  SETDRV:
  1111 00000433 5B                      	POP	BX
  1112 00000434 C3                      	RET
  1113                                  SETDRIVE ENDP
  1114                                  
  1115                                  ;-----------------------------------------------------------
  1116                                  ;
  1117                                  ;		DISK I/O ROUTINES
  1118                                  ;
  1119                                  
  1120                                  DSK$WRITV PROC	NEAR
  1121                                  	PUBLIC	DSK$WRITV
  1122                                   assume ds:nothing, es:nothing, ss:nothing
  1123                                  
  1124                                  	MESSAGE FTESTDISK,<"DISK WRITE WITH VERIFY ">
  1125                                  	MNUM	FTESTDISK,AX
  1126                                  	MESSAGE FTESTDISK,<" ">
  1127                                  	MNUM	FTESTDISK,DX
  1128                                  	MESSAGE FTESTDISK,<" FOR ">
  1129                                  	MNUM	FTESTDISK,CX
  1130                                  	MESSAGE FTESTDISK,<CR,LF>
  1131 00000435 E8(0000)                	call biocode_get_ds_dosbiodata
  1132                                   assume ds:DOSGROUP
  1133 00000438 C706[0000]0301          	MOV	word [WRTVERIFY],103H
  1134                                  		; needn't preserve ds, DISKIO overwrites its INP:ds
  1135 0000043E EB09                    	JMP	SHORT DSK$CL
  1136                                  
  1137                                  DSK$WRIT:
  1138                                  	PUBLIC	DSK$WRIT
  1139                                   assume ds:nothing, es:nothing, ss:nothing
  1140                                  	MESSAGE FTESTDISK,<"DISK WRITE ">
  1141                                  	MNUM	FTESTDISK,AX
  1142                                  	MESSAGE FTESTDISK,<" ">
  1143                                  	MNUM	FTESTDISK,DX
  1144                                  	MESSAGE FTESTDISK,<" FOR ">
  1145                                  	MNUM	FTESTDISK,CX
  1146                                  	MESSAGE FTESTDISK,<CR,LF>
  1147 00000440 E8(0000)                	call biocode_get_ds_dosbiodata
  1148                                   assume ds:DOSGROUP
  1149 00000443 C706[0000]0300          	MOV	word [WRTVERIFY],ROMWRITE
  1150                                  		; needn't preserve ds, DISKIO overwrites its INP:ds
  1151                                  DSK$CL:
  1152 00000449 E89300                  	CALL	DISKIO
  1153                                  DSK$IO:
  1154 0000044C 7203                    	JC	DSKBAD
  1155 0000044E E9(0000)                	JMP	EXIT
  1156                                  DSKBAD:
  1157 00000451 E9(0000)                	JMP	ERR$CNT
  1158                                  DSK$WRITV ENDP
  1159                                  
  1160                                  DSK$READ PROC	NEAR
  1161                                  	PUBLIC	DSK$READ
  1162                                   assume ds:nothing, es:nothing, ss:nothing
  1163                                  	MESSAGE FTESTDISK,<"DISK READ ">
  1164                                  	MNUM	FTESTDISK,AX
  1165                                  	MESSAGE FTESTDISK,<" ">
  1166                                  	MNUM	FTESTDISK,DX
  1167                                  	MESSAGE FTESTDISK,<" FOR ">
  1168                                  	MNUM	FTESTDISK,CX
  1169                                  	MESSAGE FTESTDISK,<CR,LF>
  1170 00000454 E88000                  	CALL	DISKRD
  1171 00000457 EBF3                    	JMP	DSK$IO
  1172                                  DSK$READ ENDP
  1173                                  
  1174                                  ; MISCELLANEOUS ODD JUMP ROUTINES.  MOVED OUT OF MAINLINE FOR SPEED.
  1175                                  
  1176                                  
  1177                                  ; IF WE HAVE A SYSTEM WHERE WE HAVE VIRTUAL DRIVES, WE NEED TO PROMPT THE
  1178                                  ; USER TO PLACE THE CORRECT DISK IN THE DRIVE.
  1179                                  
  1180                                  CHECKSINGLE PROC NEAR
  1181                                  	PUBLIC CHECKSINGLE
  1182                                   assume ds:UPB, es:nothing, ss:nothing
  1183                                  
  1184 00000459 50                      	PUSH	AX
  1185 0000045A 8B4523                  	MOV	ax,WORD PTR [DI + FLAGS]
  1186                                   ; IF HARD DRIVE, CANNOT CHANGE DISK.
  1187                                   ; IF CURRENT OWNER OF PHYSICAL DRIVE, NO NEED TO CHANGE DISKETTE.
  1188 0000045D A821                    	TEST	al,FNON_REMOVABLE | FI_OWN_PHYSICAL
  1189 0000045F 7560                    	JNZ	SINGLERET
  1190 00000461 A810                    	TEST	al,FI_AM_MULT		 ; IS THERE A DRIVE SHARING THIS
  1191                                  					 ;   PHYSICAL DRIVE?
  1192 00000463 745C                    	JZ	SINGLERET
  1193                                  ; LOOK FOR THE PREVIOUS OWNER OF THIS PHYSICAL DRIVE AND RESET ITS OWNERSHIP
  1194                                  ; FLAG.
  1195 00000465 8A4504                  	MOV	AL,[DI + DRIVENUM]	; GET PHYSICAL DRIVE NUMBER
  1196 00000468 1E                      	PUSH	DS			; PRESERVE POINTER TO CURRENT BDS
  1197 00000469 57                      	PUSH	DI
  1198 0000046A E8(0000)                	call biocode_get_ds_dosbiodata
  1199                                   assume ds:DOSGROUP
  1200 0000046D BF[0000]                	MOV	DI,OFFSET START_BDS
  1201                                  SCAN_LIST:
  1202 00000470 C53D                    	lds di, [di + LINK]		; GO TO NEXT BDS
  1203                                   assume ds:UPB
  1204 00000472 83FFFF                  	CMP	DI,-1			; END OF LIST?
  1205 00000475 744C                    	je	SINGLE_ERR_RET		; MUST BE ERROR
  1206 00000477 384504                  	CMP	BYTE PTR [DI + DRIVENUM],AL
  1207 0000047A 75F4                    	jne	SCAN_LIST
  1208                                  
  1209                                  CHECK_OWN:
  1210 0000047C F6452320                	test byte [DI + FLAGS], FI_OWN_PHYSICAL
  1211 00000480 74EE                    	JZ	SCAN_LIST
  1212                                  
  1213                                  		; MS-DOS v5 flips these flags before the 2F.4A00 callout
  1214 00000482 806523DF                	and byte [DI + FLAGS], ~ FI_OWN_PHYSICAL; RESET OWNERSHIP FLAG
  1215 00000486 8A6505                  	MOV	ah, [DI + DRIVELET]		; ah = wanted DOS drive letter
  1216 00000489 5F                      	POP	DI			    ; RESTORE POINTER TO CURRENT BDS
  1217 0000048A 1F                      	POP	DS
  1218                                   assume ds:UPB
  1219 0000048B 804D2320                	or byte [DI + FLAGS], FI_OWN_PHYSICAL		    ; ESTABLISH CURRENT BDS AS OWNER
  1220                                  
  1221                                  ;
  1222                                  ; WE EXAMINE THE FSETOWNER FLAG. IF IT IS SET, THEN WE ARE USING THE CODE IN
  1223                                  ; CHECKSINGLE TO JUST SET THE OWNER OF A DRIVE. WE MUST NOT ISSUE THE PROMPT
  1224                                  ; IN THIS CASE.
  1225                                  ;
  1226 0000048F 1E                      	push ds
  1227 00000490 E8(0000)                	call biocode_get_ds_dosbiodata
  1228                                   assume ds:DOSGROUP
  1229 00000493 803E[0000]01            	CMP	BYTE PTR [FSETOWNER],1
  1230 00000498 1F                      	pop ds
  1231                                   assume ds:UPB
  1232 00000499 7426                    	JZ	SINGLERET
  1233                                  ; TO SUPPORT "BACKWARD" COMPATIBILITY WITH IBM'S "SINGLE DRIVE STATUS BYTE"
  1234                                  ; WE NOW CHECK TO SEE IF WE ARE IN A SINGLE DRIVE SYSTEM AND THE APPLICATION
  1235                                  ; HAS "CLEVERLY" DIDDLED THE SDSB
  1236 0000049B 1E                      	push ds
  1237 0000049C E8(0000)                	call biocode_get_ds_dosbiodata
  1238                                   assume ds:DOSGROUP
  1239 0000049F 803E[0000]02            	CMP	byte [SINGLE],2		    ; IF (SINGLE_DRIVE_SYSTEM)
  1240 000004A4 1F                      	pop ds
  1241                                   assume ds:UPB
  1242 000004A5 7517                    	JNE	SHORT IGNORE_SDSB
  1243 000004A7 1E5750                  	SAVEREG <DS,DI,AX>		    ;	THEN
  1244 000004AA 8A4505                  	MOV	AL,[DI + DRIVELET]	    ;	  IF (CURR_DRV == REQ_DRV)
  1245 000004AD 88C4                    	MOV	AH,AL
  1246 000004AF 31FF                    	XOR	DI,DI
  1247 000004B1 8EDF                    	MOV	DS,DI			; => 0
  1248                                   assume ds:IVT
  1249 000004B3 86060405                	XCHG	AL,BYTE PTR [LSTDRV]	    ;	     THEN SWAP(CURR_DRV,REQ_DRV)
  1250 000004B7 38C4                    	CMP	AH,AL			    ;	     ELSE
  1251 000004B9 585F1F                  	RESTOREREG <AX,DI,DS>		    ;		  SWAP(CURR_DRV,REQ_DRV)
  1252                                   assume ds:UPB
  1253 000004BC 7403                    	JE	SINGLERET		    ;		  ISSUE SWAP_DSK_MSG
  1254                                  
  1255                                  IGNORE_SDSB:
  1256 000004BE E8(0000)                	CALL	SWPDSK			    ;  ASK USER FOR CORRECT DISK
  1257                                  SINGLERET:
  1258 000004C1 58                      	POP	AX
  1259 000004C2 C3                      	RET
  1260                                  
  1261                                  SINGLE_ERR_RET:
  1262 000004C3 F9                      	STC
  1263 000004C4 5F                      	POP	DI			    ; RESTORE CURRENT BDS
  1264 000004C5 1F                      	POP	DS
  1265                                   assume ds:UPB
  1266 000004C6 EBF9                    	JMP	SHORT SINGLERET
  1267                                  
  1268                                  DISKIO_unknown:
  1269 000004C8 B001                    	mov al, 1			; unknown unit
  1270 000004CA A9                      	db __TEST_IMM16			; skip mov al
  1271                                  BADDRIVE:
  1272 000004CB B008                    	MOV	AL,8			;Sector not found
  1273 000004CD A9                      	db __TEST_IMM16			; skip mov al
  1274                                  UnformattedDrive:			;AN004;AN005;AN006;
  1275 000004CE B007                    	mov	al,7			;AN004;Unknown media;AN005;AN006;
  1276                                  BadDrive_Ret:
  1277 000004D0 F9                      	STC
  1278 000004D1 C3                      IORET:	RET
  1279                                  
  1280                                  
  1281                                  BOGUSSETTLE:
  1282 000004D2 B00F                    	MOV	AL,NORMSETTLE		; SOMEONE HAS DIDDLED THE SETTLE
  1283 000004D4 E9E002                  	JMP	GOTSLOWSETTLE
  1284                                  CHECKSINGLE ENDP
  1285                                  ;------------------------------------------------------------
  1286                                  ;
  1287                                  ;	DISK I/O HANDLER
  1288                                  ;
  1289                                  ;	AL = DRIVE NUMBER (0-6)
  1290                                  ;	AH = MEDIA DESCRIPTOR
  1291                                  ;	CX = SECTOR COUNT
  1292                                  ;	DX = FIRST SECTOR (low)
  1293                                  ;	[Start_Sec_H] = FIRST SECTOR (high) ;J.K. 32 bit calculation.
  1294                                  ;	ES:DI = TRANSFER ADDRESS
  1295                                  ;	[RFLAG]=OPERATION (2=READ, 3=WRITE)
  1296                                  ;	[VERIFY]=1 FOR VERIFY AFTER WRITE
  1297                                  ;
  1298                                  ;	IF SUCCESSFUL CARRY FLAG = 0
  1299                                  ;	  ELSE CF=1 AND AL CONTAINS ERROR CODE
  1300                                  ;
  1301                                  	PUBLIC DISKRD
  1302                                  DISKRD	PROC	NEAR
  1303 000004D7 E8(0000)                	call biocode_get_ds_dosbiodata
  1304                                   assume ds:DOSGROUP
  1305 000004DA C606[0000]02            	MOV	byte [RFLAG],ROMREAD
  1306                                  		; SETDRIVE overwrites ds, so no need to restore
  1307                                  
  1308                                  DISKIO:
  1309 000004DF 89FB                    	MOV	BX,DI			; ES:BX = TRANSFER ADDRESS
  1310 000004E1 E825FF                  	CALL	SETDRIVE		; MAP LOGICAL AND PHYSICAL
  1311                                   assume ds:UPB
  1312 000004E4 72E2                    	jc DISKIO_unknown
  1313 000004E6 8A4510                  	MOV	AL,BYTE PTR [DI + MEDIAD]
  1314 000004E9 1E                      	push ds
  1315 000004EA E8(0000)                	call biocode_get_ds_dosbiodata
  1316                                   assume ds:DOSGROUP
  1317 000004ED A2[0000]                	MOV	[MEDBYT],AL		; PRESERVE MEDIA BYTE FOR DRIVE FOR USE
  1318                                  					; IN DETERMINING MEDIA CHANGE.
  1319 000004F0 1F                      	pop ds
  1320                                   assume ds:UPB
  1321 000004F1 E3DE                    	JCXZ	IORET
  1322                                  ;SB34DISK006******************************************************************
  1323                                  ;SB	See if the Media is formatted or not by checking the flags field in
  1324                                  ;SB	in the BDS.  If it is unformatted we cannot allow I/O, so we should
  1325                                  ;SB	go to the error exit at label UnformattedDrive.  2LOCS
  1326                                  
  1327 000004F3 F745230002              	test	word ptr [di + FLAGS], UNFORMATTED_MEDIA
  1328 000004F8 75D4                    	jnz	UnformattedDrive
  1329                                  ;SB34DISK006******************************************************************
  1330 000004FA 1E                      	push ds
  1331 000004FB E8(0000)                	call biocode_get_ds_dosbiodata
  1332                                   assume ds:DOSGROUP
  1333 000004FE 890E[0000]              	mov	[SECCNT],CX		;save sector count
  1334 00000502 8926[0000]              	MOV	[SPSAV],SP		; SAVE SP
  1335 00000506 8306[0000]02            	add word [SPSAV], 2		; discard ds off the stack
  1336 0000050B 1F                      	pop ds
  1337                                   assume ds:UPB
  1338                                  
  1339                                  ; ENSURE THAT WE ARE TRYING TO ACCESS VALID SECTORS ON THE DRIVE
  1340                                  ;
  1341                                  
  1342 0000050C 89D0                    	mov	ax,dx			;AN000; save DX to AX
  1343 0000050E 31F6                    	xor	si,si			;AN000;
  1344 00000510 01CA                    	add	dx,cx			;AN000;
  1345 00000512 83D600                  	adc	si,0			;AN000;
  1346                                  DrvLim equ DRVLIM	; NASM port equate
  1347 00000515 837D0E00                	cmp	word [di + DrvLim], 0		;AN000; Is this drive > 32 bit sector ?
  1348 00000519 740C                    	je	Sanity32		;AN000;
  1349 0000051B 83FE00                  	cmp	si,0			;AN000;
  1350 0000051E 75AB                    	jne	BADDRIVE		;AN000;
  1351 00000520 3B550E                  	cmp	dx, [di + DrvLim] 	;AN000;
  1352 00000523 77A6                    	ja	BADDRIVE		;AN000;
  1353 00000525 EB15                    	jmp	short SanityOK		;AN000;
  1354                                  Sanity32:				;AN000;
  1355 00000527 1E                      	push ds
  1356 00000528 E8(0000)                	call biocode_get_ds_dosbiodata
  1357                                   assume ds:DOSGROUP
  1358 0000052B 0336[0000]              	add	si, [Start_Sec_H]	;AN000;
  1359 0000052F 1F                      	pop ds
  1360                                   assume ds:UPB
  1361                                  DrvLim_H equ DRVLIM_H	; NASM port equate
  1362 00000530 3B751D                  	cmp	si, [di + DrvLim_H]	;AN000;
  1363 00000533 7207                    	jb	SanityOK		;AN000;
  1364 00000535 7794                    	ja	BADDRIVE		;AN000;
  1365                                  DrvLim_L equ DRVLIM_L	; NASM port equate
  1366 00000537 3B551B                  	cmp	dx, [di + DrvLim_L]	;AN000;
  1367 0000053A 778F                    	ja	BADDRIVE		;AN000;
  1368                                  SanityOK:				;AN000;
  1369 0000053C 1E                      	push ds
  1370 0000053D E8(0000)                	call biocode_get_ds_dosbiodata
  1371                                   assume ds:DOSGROUP
  1372 00000540 8B16[0000]              	mov	dx,[Start_Sec_H]	;AN000;
  1373 00000544 1F                      	pop ds
  1374                                   assume ds:UPB
  1375 00000545 034517                  	add	ax,word ptr [di + HIDSEC_L]    ;AN000;
  1376                                  Hidsec_H equ HIDSEC_H	; NASM port equate
  1377 00000548 135519                  	adc	dx,word ptr [di + Hidsec_H]    ;AN000;
  1378                                  ;J.K. Now DX;AX have the physical first sector.
  1379                                  ;Since the following procedures is going to destroy AX, let's
  1380                                  ;save it temporarily to SAVED_WORD.
  1381 0000054B 1E                      	push ds
  1382 0000054C E8(0000)                	call biocode_get_ds_dosbiodata
  1383                                   assume ds:DOSGROUP
  1384 0000054F A3[0000]                	mov	[Saved_Word], ax	;AN000; Save the sector number (low)
  1385                                  
  1386                                  ;	 MOV	 SI,DX
  1387                                  ;	 ADD	 SI,CX
  1388                                  ;	 ADD	 DX,WORD PTR [DI].HIDSEC ; ADD IN THE HIDDEN SECTORS
  1389                                  ;	 CMP	 SI,WORD PTR [DI].DRVLIM ; COMPARE AGAINST DRIVE MAX
  1390                                  ;	 JA	 BADDRIVE
  1391                                  
  1392                                  ; SET UP POINTER TO DISK BASE TABLE IN [DPT]. WE CANNOT ASSUME THAT IOSETUP
  1393                                  ; WILL DO IT BECAUSE WE WILL SKIP THE SET UP STUFF WITH HARD DISKS.
  1394 00000552 31C0                    	XOR	AX,AX
  1395 00000554 8ED8                    	MOV	DS,AX
  1396                                   assume ds:IVT
  1397 00000556 FF367A00                	push word [DSKADR + 2]
  1398 0000055A 8B367800                	mov SI, [DSKADR]	; CURRENT DISK PARM TABLE
  1399 0000055E E8(0000)                	call biocode_get_ds_dosbiodata
  1400                                   assume ds:DOSGROUP
  1401 00000561 8936[0000]              	MOV	WORD PTR [DPT],SI
  1402 00000565 8F06[0200]              	pop	WORD PTR [DPT+2]
  1403 00000569 1F                      	POP	DS
  1404                                   assume ds:UPB
  1405 0000056A F745230100              	TEST	WORD PTR [DI + FLAGS],FNON_REMOVABLE
  1406 0000056F 750E                    	JNZ	SKIP_SETUP
  1407 00000571 E8E5FE                  	CALL	CHECKSINGLE
  1408                                  ;
  1409                                  ; CHECK TO SEE IF WE HAVE PREVIOUSLY NOTED A CHANGE LINE.  THE ROUTINE
  1410                                  ; RETURNS IF EVERYTHING IS OK.	OTHERWISE, IT POPS OFF THE STACK AND RETURNS
  1411                                  ; THE PROPER ERROR CODE.
  1412                                  ;
  1413                                  ;----------------------------------------|
  1414                                  ; WARNING: DO NOT CHANGE THE FOLLOWING. ;|
  1415                                  ;	   IT GETS PATCHED IN MSINIT	;|
  1416 00000574 E8FA0F                  	call ispatched
  1417 00000577 7203                    	jc @F
  1418                                  	PUBLIC DISKIO_PATCH		;|
  1419                                  DISKIO_PATCH:				;|
  1420 00000579 E8(0000)                	CALL	CHECKLATCHIO		;|
  1421                                  @@:
  1422                                  ;----------------------------------------|
  1423                                  ;
  1424                                  ; SET UP TABLES AND VARIABLES FOR I/O
  1425 0000057C E8F301                  	CALL	IOSETUP
  1426                                  ;
  1427                                  ; NOW THE SETTLE VALUES ARE CORRECT FOR THE FOLLOWING CODE
  1428                                  ;
  1429                                  SKIP_SETUP:
  1430                                  ;J.K. 32 bit sector calculation.
  1431                                  ; DX;[Saved_Word] = starting sector number.
  1432                                  
  1433 0000057F F745230100              	test	word ptr [di + FLAGS], fNon_Removable ;Fixed disk? - J.K. 4/7/86
  1434 00000584 741C                    	jz	DISK_NOT_MINI		;no, skip this. - J.K. 4/7/86
  1435 00000586 837D4701                	cmp	word [di + IsMini], 1		;Is this a mini disk? - J.K. 4/7/86
  1436 0000058A 7516                    	jnz	DISK_NOT_MINI		;No. continue to next.- J.K. 4/7/86
  1437 0000058C 89D1                    	mov cx, dx                      ; cx = high word sector number
  1438 0000058E 8B4513                  	mov ax, [di + SECLIM]           ; ax = number of CHS sectors
  1439 00000591 F76515                  	mul word ptr [di + HDLIM]        ; ax = sectors per cylinder (dx == zero)
  1440 00000594 F76549                  	mul word ptr [di + Hidden_Trks]   ; dx:ax = how many hidden sectors to add
  1441 00000597 1E                      	push ds
  1442 00000598 E8(0000)                	call biocode_get_ds_dosbiodata
  1443                                   assume ds:DOSGROUP
  1444 0000059B 0106[0000]              	add word ptr [Saved_Word], ax
  1445 0000059F 1F                      	pop ds
  1446                                   assume ds:UPB
  1447 000005A0 11CA                    	adc dx, cx                      ; add hidden sectors amount matching cyls
  1448                                  DISK_NOT_MINI:
  1449 000005A2 F745230004              	test word ptr [di + FLAGS], F_LBA
  1450 000005A7 7517                    	jnz diskio_lba		; --> (NC)
  1451 000005A9 E86501                  	call lbatochs_saved_word
  1452 000005AC 720F                    	jc BADDRIVE_Brdg
  1453                                  ;
  1454                                  ; WE ARE NOW SET UP FOR THE I/O.  NORMALLY, WE CONSIDER THE DMA BOUNDARY
  1455                                  ; VIOLATIONS HERE.  NOT TRUE.  WE PERFORM THE OPERATION AS IF EVERYTHING IS
  1456                                  ; SYMMETRIC; LET THE INT 13 HANDLER WORRY ABOUT THE DMA VIOLATIONS.
  1457                                  ;
  1458 000005AE 1E                      	push ds
  1459 000005AF E8(0000)                	call biocode_get_ds_dosbiodata
  1460                                   assume ds:DOSGROUP
  1461 000005B2 A1[0000]                	MOV	AX, [SECCNT]
  1462 000005B5 1F                      	pop ds
  1463                                   assume ds:UPB
  1464 000005B6 E89802                  	CALL	BLOCK
  1465                                  diskio_done:
  1466 000005B9 E80302                  	CALL	msbiodisk_DONE
  1467 000005BC C3                      	RET
  1468                                  
  1469                                  ;
  1470                                  Baddrive equ BADDRIVE	; NASM port label
  1471 000005BD E90BFF                  BADDRIVE_Brdg:jmp Baddrive
  1472                                  ;
  1473                                  
  1474                                  diskio_lba:
  1475 000005C0 1E                      	push ds
  1476 000005C1 E8(0000)                	call biocode_get_ds_dosbiodata
  1477                                   assume ds:DOSGROUP
  1478 000005C4 A1[0000]                	mov ax, word ptr [Saved_Word]
  1479 000005C7 8B0E[0000]              	mov cx, word ptr [SECCNT]
  1480 000005CB 1F                      	pop ds
  1481                                   assume ds:UPB
  1482                                  diskio_lba_loop:
  1483 000005CC E3EB                    	jcxz diskio_done
  1484 000005CE E82A02                  	call ishma_lba
  1485 000005D1 7368                    	jnc .nothma
  1486 000005D3 06                      	push es
  1487 000005D4 53                      	push bx
  1488 000005D5 51                      	push cx
  1489                                  
  1490 000005D6 1E                      	 push ds
  1491 000005D7 E8(0000)                	call biocode_get_ds_dosbiodata
  1492                                   assume ds:DOSGROUP
  1493 000005DA 803E[0000]02            	cmp byte [RFLAG], ROMREAD
  1494 000005DF 7413                    	je .hma_read
  1495 000005E1 06                      	push es
  1496 000005E2 57                      	push di
  1497 000005E3 56                      	push si
  1498 000005E4 06                      	 push es
  1499 000005E5 1F                      	 pop ds
  1500                                   assume ds:nothing
  1501 000005E6 89DE                    	mov si, bx
  1502 000005E8 E8(0000)                	call biocode_get_es_dosentry
  1503                                   assume es:DOSENTRYGROUP
  1504 000005EB BF[0000]                	mov di, DISKSECTOR
  1505 000005EE E8500F                  	call MOVE
  1506 000005F1 5E                      	pop si
  1507 000005F2 5F                      	pop di
  1508 000005F3 07                      	pop es
  1509                                   assume es:nothing
  1510                                  .hma_read:
  1511 000005F4 1F                      	 pop ds
  1512                                   assume ds:UPB
  1513 000005F5 E8(0000)                	call biocode_get_es_dosentry
  1514                                   assume es:DOSENTRYGROUP
  1515 000005F8 BB[0000]                	mov bx, DISKSECTOR
  1516 000005FB B90100                  	mov cx, 1
  1517 000005FE E86D00                  	call diskio_lba_simple
  1518 00000601 59                      	pop cx
  1519 00000602 5B                      	pop bx
  1520 00000603 07                      	pop es
  1521                                   assume es:nothing
  1522                                  
  1523 00000604 1E                      	push ds
  1524 00000605 E8(0000)                	call biocode_get_ds_dosbiodata
  1525                                   assume ds:DOSGROUP
  1526 00000608 803E[0000]02            	cmp byte [RFLAG], ROMREAD
  1527 0000060D 1F                      	pop ds
  1528                                   assume ds:UPB
  1529 0000060E 7511                    	jne .hma_write
  1530 00000610 1E                      	 push ds
  1531 00000611 56                      	 push si
  1532 00000612 57                      	 push di
  1533 00000613 89DF                    	mov di, bx
  1534 00000615 E8(0000)                	call biocode_get_ds_dosentry
  1535                                   assume ds:DOSENTRYGROUP
  1536 00000618 BE[0000]                	mov si, DISKSECTOR
  1537 0000061B E8230F                  	call MOVE
  1538 0000061E 5F                      	 pop di
  1539 0000061F 5E                      	 pop si
  1540 00000620 1F                      	 pop ds
  1541                                   assume ds:UPB
  1542                                  .hma_write:
  1543 00000621 83E901                  	sub cx, 1
  1544 00000624 80C702                  	add bh, 512 / 256
  1545 00000627 1E                      	push ds
  1546 00000628 E8(0000)                	call biocode_get_ds_dosbiodata
  1547                                   assume ds:DOSGROUP
  1548 0000062B A1[0800]                	mov ax, word ptr [lbapacket + lpSector]
  1549 0000062E 8B16[0A00]              	mov dx, word ptr [lbapacket + lpSector + 2]
  1550 00000632 1F                      	pop ds
  1551                                   assume ds:UPB
  1552 00000633 83C001                  	add ax, 1
  1553 00000636 83D200                  	adc dx, 0
  1554 00000639 EB91                    	jmp diskio_lba_loop
  1555                                  
  1556                                  .nothma:
  1557 0000063B 81F98000                	cmp cx, 128
  1558 0000063F 7227                    	jb diskio_lba_call_simple
  1559 00000641 51                      	push cx
  1560 00000642 B97F00                  	mov cx, 127
  1561 00000645 E82600                  	call diskio_lba_simple
  1562 00000648 59                      	pop cx
  1563 00000649 8CC0                    	mov ax, es
  1564 0000064B 05E00F                  	add ax, 127 * 512 / 16
  1565 0000064E 8EC0                    	mov es, ax
  1566                                   assume es:nothing
  1567 00000650 83E97F                  	sub cx, 127
  1568 00000653 1E                      	push ds
  1569 00000654 E8(0000)                	call biocode_get_ds_dosbiodata
  1570                                   assume ds:DOSGROUP
  1571 00000657 A1[0800]                	mov ax, word ptr [lbapacket + lpSector]
  1572 0000065A 8B16[0A00]              	mov dx, word ptr [lbapacket + lpSector + 2]
  1573 0000065E 1F                      	pop ds
  1574                                   assume ds:UPB
  1575 0000065F 83C07F                  	add ax, 127
  1576 00000662 83D200                  	adc dx, 0
  1577 00000665 E964FF                  	jmp diskio_lba_loop
  1578                                  
  1579                                  diskio_lba_call_simple:
  1580 00000668 E80300                  	call diskio_lba_simple
  1581 0000066B E94BFF                  	jmp diskio_done
  1582                                  
  1583                                  diskio_lba_simple:
  1584 0000066E 8A6D04                  	mov ch, byte ptr [di + DRIVENUM]
  1585 00000671 1E                      	push ds
  1586 00000672 56                      	push si
  1587 00000673 E8E400                  	call lba_packet_setup
  1588                                   assume ds:DOSGROUP
  1589 00000676 BD0500                  	MOV	BP,MAXERR		; SET UP RETRY COUNT
  1590 00000679 892E[0000]              	mov	[VRetry_Cnt], BP	;AN003;Verify op. retry cnt for Write-Verify.
  1591 0000067D 892E[0000]              	mov	[Soft_ECC_Cnt], BP	;AN003;Soft ECC error retry count.
  1592                                  diskio_lba_retry:
  1593 00000681 B80040                  	mov ax, 4000h			; ah will be 42h, 43h, 44h
  1594 00000684 0A26[0000]              	or ah, [RFLAG]			; GET READ/WRITE INDICATOR
  1595 00000688 FF7402                  	 push word ptr [si + lpCount]
  1596 0000068B 88EA                    	mov dl, ch
  1597 0000068D CD13                    	int 13h
  1598 0000068F 8F4402                  	 pop word ptr [si + lpCount]
  1599 00000692 7209                    	jc lba_noverify
  1600 00000694 813E[0000]0301          	cmp word [WRTVERIFY], 103h	; CHECK FOR WRITE AND VERIFY
  1601 0000069A 7444                    	je lba_doverify
  1602 0000069C F8                      	clc
  1603                                  lba_noverify:
  1604 0000069D 5E                      	pop si
  1605 0000069E 1F                      	pop ds
  1606                                   assume ds:UPB
  1607 0000069F 7201                    	jc diskio_lba_error
  1608 000006A1 C3                      	retn
  1609                                  
  1610                                  diskio_lba_error:
  1611 000006A2 E8CC0E                  	call ispatched
  1612 000006A5 7203                    	jc @F
  1613                                  	PUBLIC DSKERR_LBA_PATCH
  1614                                  DSKERR_LBA_PATCH:
  1615 000006A7 E8(0000)                	CALL CHECKIO
  1616                                  @@:
  1617 000006AA E8B20B                  	CALL	AGAIN
  1618                                  lba_DskErr0:				;AN003;
  1619 000006AD 742E                    	JZ	lba_HARDERR
  1620 000006AF F745230100              	test	word ptr [di + FLAGS], fNon_Removable	;AN009;
  1621 000006B4 7505                    	jnz	lba_Skip_TimeOut_Chk			;AN009;
  1622 000006B6 80FC80                  	CMP	AH,80H			;TIMEOUT?
  1623 000006B9 7422                    	JZ	lba_HARDERR		;***
  1624                                  lba_Skip_TimeOut_Chk:			;AN009;
  1625 000006BB 1E                      	push ds
  1626 000006BC E8(0000)                	call biocode_get_ds_dosbiodata
  1627                                   assume ds:DOSGROUP
  1628 000006BF 80FCCC                  	cmp	ah, 0cch		;AN003;Write Fault error?
  1629 000006C2 7414                    	jz	lba_Write_Fault_Err	;AN003; Then, don't retry.
  1630 000006C4 C706[0000]0500          	mov	word [Soft_ECC_Cnt], MAXERR ;AN003;Set Soft_ECC_Cnt back to MAXERR
  1631                                  lba_DSKERR1:
  1632 000006CA 1F                      	pop ds
  1633                                   assume ds:UPB
  1634 000006CB 8A6D04                  	mov ch, byte ptr [di + DRIVENUM]
  1635 000006CE 1E                      	push ds
  1636 000006CF 56                      	push si
  1637 000006D0 E8(0000)                	call biocode_get_ds_dosbiodata
  1638                                   assume ds:DOSGROUP
  1639 000006D3 BE[0000]                	mov si, offset lbapacket	; access with ds
  1640 000006D6 EBA9                    	JMP	diskio_lba_retry
  1641                                  
  1642                                  lba_Write_Fault_Err:			;AN003;
  1643 000006D8 BD0100                  	mov	bp, 1			;AN003;Just retry only once for Write Fault error.
  1644                                  lba_DskErr1 equ lba_DSKERR1	; NASM port label
  1645 000006DB EBED                    	jmp	lba_DskErr1		;AN003;
  1646                                  
  1647                                  lba_HARDERR:
  1648 000006DD E96D03                  	jmp HARDERR
  1649                                  
  1650                                  lba_doverify:
  1651                                   assume ds:DOSGROUP
  1652 000006E0 B444                    	mov ah, 44h
  1653 000006E2 FF7402                  	 push word ptr [si + lpCount]
  1654 000006E5 CD13                    	int 13h
  1655 000006E7 8F4402                  	 pop word ptr [si + lpCount]
  1656 000006EA 73B1                    	jnc lba_noverify
  1657                                  
  1658 000006EC 80FC11                  	cmp	ah,11h			; SOFT ECC error ?
  1659 000006EF 750C                    	jnz	.Not_SoftECC_Err
  1660                                  		; here NC
  1661 000006F1 FF0E[0000]              	dec	word [SOFT_ECC_CNT]
  1662 000006F5 74A6                    	jz	lba_noverify		; no more retry --> (NC)
  1663 000006F7 E86A0B                  	call	ResetDisk		; reset disk
  1664 000006FA 5E                      	pop si
  1665 000006FB EBCD                    	jmp	lba_DskErr1		; retry
  1666                                  
  1667                                  .Not_SoftECC_Err:			;AN003;Other error.
  1668 000006FD E8640B                  	call	ResetDisk
  1669 00000700 FF0E[0000]              	dec word [VRetry_Cnt]
  1670 00000704 5E                      	pop si
  1671 00000705 1F                      	pop ds
  1672                                   assume ds:UPB
  1673 00000706 EBA5                    	jmp	lba_DskErr0
  1674                                  
  1675                                  DISKRD	ENDP
  1676                                  
  1677                                  
  1678                                  		; INP:	dx:ax = LBA
  1679                                  		;	ds:di -> UPB
  1680                                  		; OUT:	word [DOSDATA:CURTRK] = cylinder
  1681                                  		;	byte [DOSDATA:CURHD] = head
  1682                                  		;	byte [DOSDATA:CURSEC] = sector (1-based)
  1683                                  		;	CY if overflow
  1684                                  		; CHG:	dx, ax, cx
  1685                                  	public lbatochs
  1686                                  lbatochs:
  1687                                   assume ds:UPB, es:nothing, ss:nothing
  1688 00000708 06                      	push es
  1689 00000709 E8(0000)                	call biocode_get_es_dosbiodata
  1690                                   assume es:DOSGROUP
  1691 0000070C 26A3[0000]                      mov word ptr [es:Saved_Word], ax
  1692 00000710 A8                              db __TEST_IMM8			; skip push
  1693                                  lbatochs_saved_word:
  1694 00000711 06                      	push es
  1695                                   assume ds:UPB, es:nothing, ss:nothing
  1696 00000712 E8(0000)                	call biocode_get_es_dosbiodata
  1697                                   assume es:DOSGROUP
  1698 00000715 92                      	xchg	ax, dx			; ax = high word, dx clobbered
  1699 00000716 31D2                    	xor	dx,dx			;AN000;
  1700 00000718 F77513                  	DIV	WORD PTR [DI + SECLIM]	;DIVIDE BY SEC PER TRACK
  1701 0000071B 26A3[0000]              	mov	[es:Temp_H],ax		;AN000;
  1702 0000071F 26A1[0000]              	mov	ax, [es:Saved_Word]	;AN000; Restore the lower word
  1703                                  SecLim equ SECLIM	; NASM port equate
  1704 00000723 F77513                  	div	word ptr [di + SecLim]	;AN000;
  1705                                  ;Now, [Temp_H],AX = track #, DX = sector
  1706 00000726 FEC2                    	INC	DL			;Sector number is 1 based.
  1707 00000728 268816[0000]            	MOV	[es:CURSEC],DL		;SAVE CURRENT SECTOR
  1708 0000072D 8B4D15                  	MOV	CX,WORD PTR [DI + HDLIM]	;GET NUMBER OF HEADS
  1709                                  
  1710 00000730 50                      	push	ax			;AN000;
  1711 00000731 31D2                    	XOR	DX,DX			;DIVIDE TRACKS BY HEADS PER CYLINDER
  1712 00000733 26A1[0000]              	mov	ax, [es:Temp_H]		;AN000;
  1713 00000737 F7F1                    	DIV	CX
  1714 00000739 26A3[0000]              	mov	[es:Temp_H],ax		;AN000;
  1715 0000073D 58                      	pop	ax			;AN000;
  1716 0000073E F7F1                    	div	cx			;AN000;
  1717                                  ;Now, [Temp_H],AX = cyliner #, DX = head
  1718 00000740 26833E[0000]00          	cmp	word [es:Temp_H],0		;AN000;
  1719 00000746 770F                    	ja	lbatochs_cy		;AN000;
  1720 00000748 3D0004                  	cmp	AX, 1024		;AN000; 2**10 currently maxium for track #.
  1721 0000074B 730A                    	jae	lbatochs_cy		;AN000;
  1722 0000074D 268816[0000]            	MOV	[es:CURHD],DL		;SAVE CURRENT HEAD
  1723 00000752 26A3[0000]              	MOV	[es:CURTRK],AX		;SAVE CURRENT TRACK
  1724 00000756 A8                      	db 0A8h				; test al, imm8 - skip stc and NC
  1725                                  
  1726                                  lbatochs_cy:
  1727 00000757 F9                      	stc
  1728 00000758 07                      	pop es
  1729                                   assume es:nothing
  1730 00000759 C3                      	ret
  1731                                  
  1732                                  
  1733                                  		; INP:	es:bx -> transfer address
  1734                                  		;	cl = count
  1735                                  		;	dx:ax = sector number
  1736                                  		; OUT:	ds:si -> LBA packet
  1737                                  		;	ah = 42h
  1738                                  	public lba_packet_setup
  1739                                  lba_packet_setup:
  1740                                   assume ds:nothing, es:nothing, ss:nothing
  1741 0000075A E8(0000)                	call biocode_get_ds_dosbiodata
  1742                                   assume ds:DOSGROUP
  1743 0000075D BE[0000]                	mov si, offset lbapacket	; access with ds
  1744 00000760 884C02                  	mov byte ptr [si + lpCount], cl
  1745 00000763 895C04                  	mov word ptr [si + lpBuffer], bx
  1746 00000766 8C4406                  	mov word ptr [si + lpBuffer + 2], es
  1747 00000769 894408                  	mov word ptr [si + lpSector + 0], ax
  1748 0000076C 89540A                  	mov word ptr [si + lpSector + 2], dx
  1749 0000076F B442                    	mov ah, 42h
  1750 00000771 C3                      	retn
  1751                                  
  1752                                  
  1753                                  ; SET THE DRIVE-LAST-ACCESSED FLAG FOR DISKETTE ONLY.  WE KNOW THAT THE HARD
  1754                                  ; DISK WILL NOT BE REMOVED.
  1755                                  ; DS:DI -> CURRENT BDS.
  1756                                  ; AX,CX,SI ARE DESTROYED.
  1757                                  ;
  1758                                  	PUBLIC IOSETUP
  1759                                  IOSETUP PROC	NEAR
  1760                                   assume ds:UPB, es:nothing, ss:nothing
  1761 00000772 8A4504                  	MOV	AL,[DI + DRIVENUM]
  1762 00000775 06                      	push es
  1763 00000776 E8(0000)                	call biocode_get_es_dosbiodata
  1764                                   assume es:DOSGROUP
  1765 00000779 26A2[0000]              	MOV	[es:TIM_DRV],AL 	; SAVE DRIVE LETTER
  1766                                  ;
  1767                                  ; DETERMINE PROPER HEAD SETTLE VALUES
  1768                                  ;
  1769 0000077D 26803E[FF00]00          	cmp	byte [es:Media_Set_For_Format], 0	;AN012;
  1770 00000783 7538                    	jne	Skip_DPT_Setting		;AN012;
  1771 00000785 8CD9                    	MOV	CX,DS
  1772 00000787 26C536[0000]            	LDS	SI,[es:DPT]	; GET POINTER TO DISK BASE TABLE
  1773                                   assume ds:nothing
  1774 0000078C 26A0[0000]              	MOV	AL,[es:EOT]
  1775 00000790 884404                  	MOV	[SI + DISK_EOT],AL	; BUMP FOR US
  1776 00000793 8A440A                  	MOV	AL,[SI + DISK_MOTOR_STRT] ; PRESERVE OLD MOTOR START TIME
  1777 00000796 26A2[0000]              	MOV	[es:MOTORSTARTUP],AL
  1778                                  ;
  1779                                  ; FOR 3.5" DRIVES, BOTH EXTERNAL AS WELL AS ON THE K09, WE NEED TO SET THE
  1780                                  ; MOTOR START TIME TO 4. THIS CHECKING FOR EVERY I/O IS GOING TO AFFECT
  1781                                  ; PERFORMANCE ACROSS THE BOARD, BUT IS NECESSARY!! - RS
  1782                                  ;
  1783 0000079A 06                      	PUSH	ES
  1784 0000079B 8EC1                    	MOV	ES,CX			; ES:DI -> TO CURRENT BDS
  1785                                   assume es:UPB
  1786 0000079D 26807D2202              	CMP	BYTE PTR [ES:DI + FORMFACTOR],FFSMALL
  1787 000007A2 7505                    	JNZ	MOTOR_START_OK
  1788 000007A4 B004                    	MOV	AL,4
  1789 000007A6 86440A                  	XCHG	AL,[SI + DISK_MOTOR_STRT]
  1790                                  MOTOR_START_OK:
  1791 000007A9 07                      	POP	ES
  1792                                   assume es:DOSGROUP
  1793                                  ;
  1794                                  ; DS:SI NOW POINTS TO DISK PARAMETER TABLE.  GET CURRENT SETTLE AND SET FAST
  1795                                  ; SETTLE
  1796                                  ;
  1797 000007AA 30C0                    	XOR	AL,AL
  1798 000007AC FEC0                    	INC	AL			; IBM WANTS FAST SETTLE TO BE 1 - RS.
  1799 000007AE 864409                  	XCHG	AL,[SI + DISK_HEAD_STTL]	; GET SETTLE AND SET UP FOR FAST
  1800 000007B1 26A2[0000]              	MOV	[es:SETTLECURRENT],AL
  1801 000007B5 B00F                    	MOV	AL,NORMSETTLE		; SOMEONE HAS DIDDLED THE SETTLE
  1802                                  GOTSLOWSETTLE:
  1803 000007B7 8ED9                    	MOV	DS,CX
  1804                                   assume ds:UPB
  1805 000007B9 26A2[0000]              	MOV	[es:SETTLESLOW],AL
  1806                                  Skip_DPT_Setting:			;AN012;
  1807 000007BD 07                      	pop es
  1808                                   assume es:nothing
  1809 000007BE C3                      	RET
  1810                                  ;
  1811                                  ; SET TIME OF LAST ACCESS, AND RESET DEFAULT VALUES IN THE DPT.
  1812                                  ;
  1813                                  msbiodisk_DONE:
  1814 000007BF F745230100              	TEST	WORD PTR [DI + FLAGS],FNON_REMOVABLE
  1815 000007C4 7534                    	JNZ	RETZ			; DO NOT SET FOR NON-REMOVABLE MEDIA
  1816 000007C6 E8FE02                  	CALL	SET_TIM 		; SET TIME OF LAST ACCESS FOR DRIVE
  1817                                  ;
  1818                                  ; RESTORE HEAD SETTLE AND EOT VALUES
  1819                                  ;
  1820                                  DIDDLEBACK:
  1821                                   assume ds:nothing, es:nothing, ss:nothing
  1822 000007C9 9C                      	pushf					;AN013;Save flag
  1823 000007CA 06                      	push es
  1824 000007CB E8(0000)                	call biocode_get_es_dosbiodata
  1825                                   assume es:DOSGROUP
  1826 000007CE 26803E[FF00]00          	cmp	byte [es:Media_Set_For_Format], 0	;AN012;
  1827 000007D4 7522                    	jne	NoDiddleBack			;AN012;
  1828 000007D6 50                      	PUSH	AX
  1829 000007D7 8CDA                    	MOV	DX,DS
  1830 000007D9 26A0[0000]              	MOV	AL,[es:SETTLECURRENT]
  1831 000007DD 268A26[0000]            	MOV	AH,[es:MOTORSTARTUP]
  1832 000007E2 26C536[0000]            	LDS	SI,[es:DPT]
  1833                                   assume ds:nothing
  1834                                  ;	 MOV	 [SI].DISK_EOT,9	 ;J.K. 4/25/86. Should not change the EOT value
  1835                                  					;of diskbase to 9.  This cause a problem
  1836                                  					;with 1.44M diskette in Polaris when the user
  1837                                  					;issue INT 13 with the default system
  1838                                  					;diskbase.
  1839 000007E7 C6440409                	mov	byte [si + DISK_EOT],9 	;J.K. 11/5/86. For compatibility reason, return
  1840                                  					;back to set it to 9 ( PTM826 ).
  1841 000007EB 884409                  	MOV	[SI + DISK_HEAD_STTL],AL
  1842 000007EE C6440302                	MOV	byte [SI + DISK_SECTOR_SIZ],2
  1843 000007F2 88640A                  	MOV	[SI + DISK_MOTOR_STRT],AH
  1844 000007F5 8EDA                    	MOV	DS,DX
  1845                                   assume ds:nothing
  1846 000007F7 58                      	POP	AX
  1847                                  NoDiddleBack:				;AN013;
  1848 000007F8 07                      	pop es
  1849                                   assume es:nothing
  1850 000007F9 9D                      	popf				;AN013;Restore flag
  1851                                  RETZ:
  1852 000007FA C3                      	RET
  1853                                  
  1854                                  ishma_lba:
  1855                                   assume ds:nothing, es:nothing, ss:nothing
  1856 000007FB 50                      	push ax
  1857 000007FC 51                      	push cx
  1858 000007FD 53                      	push bx
  1859 000007FE 1E                      	push ds
  1860 000007FF E8(0000)                	call biocode_get_ds_dosbiodata
  1861                                   assume ds:DOSGROUP
  1862 00000802 D006[0D01]              	rol byte [config_bounce_any_lba], 1
  1863 00000806 7228                    	jc ishma_chs.ret		; always bounce -->
  1864 00000808 D006[0B01]              	rol byte [config_bounce_uma_lba], 1
  1865 0000080C 7227                    	jc ishma_chs.uma
  1866 0000080E D006[0901]              	rol byte [config_bounce_hma_lba], 1
  1867 00000812 EB17                    	jmp ishma_chs.none_or_hma
  1868                                  
  1869                                  ishma_chs:
  1870                                   assume ds:nothing, es:nothing, ss:nothing
  1871 00000814 50                      	push ax
  1872 00000815 51                      	push cx
  1873 00000816 53                      	push bx
  1874 00000817 1E                      	push ds
  1875 00000818 E8(0000)                	call biocode_get_ds_dosbiodata
  1876                                   assume ds:DOSGROUP
  1877 0000081B D006[0C01]              	rol byte [config_bounce_any_chs], 1
  1878 0000081F 720F                    	jc .ret				; always bounce -->
  1879 00000821 D006[0A01]              	rol byte [config_bounce_uma_chs], 1
  1880 00000825 720E                    	jc .uma
  1881 00000827 D006[0801]              	rol byte [config_bounce_hma_chs], 1
  1882                                  .none_or_hma:
  1883 0000082B 7303                    	jnc .ret
  1884                                  .hma:
  1885 0000082D E81300                  	call .getax
  1886                                  .ret:
  1887 00000830 1F                      	pop ds
  1888                                   assume ds:nothing
  1889 00000831 5B                      	pop bx
  1890 00000832 59                      	pop cx
  1891 00000833 58                      	pop ax
  1892 00000834 C3                      	retn
  1893                                  
  1894                                  .uma:
  1895                                   assume ds:DOSGROUP
  1896 00000835 E80B00                  	call .getax
  1897 00000838 7209                    	jc @F				; if in HMA, treat as UMA bounce too -->
  1898                                   extern ENDMEM
  1899 0000083A 3B06[0000]              	cmp ax, [ENDMEM]		; CY if end < UMA, NC if end >= UMA start
  1900 0000083E 74F0                    	jz .ret				; if end == UMA start --> (NC)
  1901 00000840 F5                      	cmc				; CY if end > UMA start
  1902 00000841 EBED                    	jmp .ret
  1903                                  @@:
  1904                                  
  1905                                  .getax:
  1906 00000843 8CC0                    	mov ax, es
  1907 00000845 B104                    	mov cl, 4
  1908 00000847 D3EB                    	shr bx, cl
  1909 00000849 01D8                    	add ax, bx
  1910 0000084B 7203                    	jc @F
  1911 0000084D 83C020                  	add ax, paras(512)
  1912                                  @@:
  1913 00000850 C3                      	retn
  1914                                  
  1915                                  ;READ THE NUMBER OF SECTORS SPECIFIED IN AX, HANDLING TRACK BOUNDARIES
  1916                                  ;DS:DI -> BDS FOR THIS DRIVE
  1917                                  BLOCK:
  1918                                   assume ds:UPB, es:nothing, ss:nothing
  1919 00000851 85C0                    	test	AX,AX			;SEE IF ANY SECTORS TO READ
  1920 00000853 74A5                    	JZ	RETZ	; fixme
  1921 00000855 E8BCFF                  	call ishma_chs
  1922 00000858 730C                    	jnc .nothma
  1923 0000085A 1E                      	push ds
  1924 0000085B E8(0000)                	call biocode_get_ds_dosbiodata
  1925                                   assume ds:DOSGROUP
  1926 0000085E C606[0701]FF            	mov byte [hma_operation], 0FFh
  1927 00000863 1F                      	pop ds
  1928                                   assume ds:UPB
  1929 00000864 EB1A                    	jmp BLOCK_FLOPPY
  1930                                  .nothma:
  1931                                  ;Fixed disk will not be restricted to the track-by-track basis. -J.K.4/10/86
  1932                                  Flags equ FLAGS	; NASM port equate
  1933 00000866 F745230100              	test	word ptr [di + Flags], fNon_Removable  ;J.K. Fixed disk?
  1934 0000086B 7413                    	jz	BLOCK_FLOPPY				;J.K.
  1935                                  ;SB34DISK002*****************************************************************
  1936                                  ;SB	Check to see if multi track operation is allowed.  If not
  1937                                  ;SB	we have to go to the block_floppy below to break up the operation.
  1938                                  ;SB		2 LOCS
  1939 0000086D 1E                      	push ds
  1940 0000086E E8(0000)                	call biocode_get_ds_dosbiodata
  1941                                   assume ds:DOSGROUP
  1942                                  MulTrk_ON equ MULTRK_ON	; NASM port equate
  1943 00000871 F706[0000]8000          	test	word [MulTrk_Flag], MulTrk_ON
  1944 00000877 1F                      	pop ds
  1945                                   assume ds:UPB
  1946 00000878 7406                    	jz	BLOCK_FLOPPY
  1947                                  ;SB34DISK002*****************************************************************
  1948 0000087A E8A600                  	call	DISK					;J.K.
  1949 0000087D 31C0                    	xor	ax,ax
  1950 0000087F C3                      	RET						;J.K.
  1951                                  BLOCK_FLOPPY:						;J.K.4/10/86
  1952                                  ;
  1953                                  ; READ AT MOST 1 TRACK WORTH.  PERFORM MINIMIZATION AT SECTOR / TRACK
  1954                                  ;
  1955 00000880 8A4D13                  	MOV	CL,BYTE PTR [DI + SECLIM]
  1956 00000883 FEC1                    	INC	CL
  1957 00000885 1E                      	push ds
  1958 00000886 E8(0000)                	call biocode_get_ds_dosbiodata
  1959                                   assume ds:DOSGROUP
  1960 00000889 2A0E[0000]              	SUB	CL,[CURSEC]		; LEEAC 3.20 ADD SEGMENT OVERRIDE
  1961 0000088D D006[0701]              	rol byte [hma_operation], 1
  1962 00000891 731D                    	jnc .nohma
  1963 00000893 803E[0000]02            	cmp byte [RFLAG], ROMREAD
  1964 00000898 7413                    	je .hma_read
  1965 0000089A 06                      	push es
  1966 0000089B 57                      	push di
  1967 0000089C 56                      	push si
  1968 0000089D 06                      	 push es
  1969 0000089E 1F                      	 pop ds
  1970                                   assume ds:nothing
  1971 0000089F 89DE                    	mov si, bx
  1972 000008A1 E8(0000)                	call biocode_get_es_dosentry
  1973                                   assume es:DOSENTRYGROUP
  1974 000008A4 BF[0000]                	mov di, DISKSECTOR		; access with es
  1975 000008A7 E8970C                  	call MOVE
  1976 000008AA 5E                      	pop si
  1977 000008AB 5F                      	pop di
  1978 000008AC 07                      	pop es
  1979                                   assume es:nothing
  1980                                  .hma_read:
  1981 000008AD F9                      	stc
  1982 000008AE B101                    	mov cl, 1
  1983                                  .nohma:
  1984 000008B0 1F                      	pop ds
  1985                                   assume ds:UPB
  1986 000008B1 7308                    	jnc @F
  1987 000008B3 06                      	push es
  1988 000008B4 53                      	push bx
  1989 000008B5 E8(0000)                	call biocode_get_es_dosentry
  1990                                   assume es:DOSENTRYGROUP
  1991 000008B8 BB[0000]                	mov bx, DISKSECTOR		; access with es
  1992                                  @@:
  1993                                   assume es:nothing
  1994 000008BB 30ED                    	XOR	CH,CH
  1995 000008BD 39C8                    	CMP	AX,CX
  1996 000008BF 7302                    	JAE	GOTMIN
  1997 000008C1 89C1                    	MOV	CX,AX
  1998                                  GOTMIN:
  1999                                  ;
  2000                                  ; AX IS THE REQUESTED NUMBER OF SECTORS TO READ
  2001                                  ; CX IS THE NUMBER THAT WE CAN DO ON THIS TRACK
  2002                                  ;
  2003 000008C3 50                      	PUSH	AX
  2004 000008C4 51                      	PUSH	CX
  2005 000008C5 89C8                    	MOV	AX,CX			; AL IS NUMBER OF SECTORS TO READ
  2006 000008C7 E85900                  	CALL	DISK
  2007 000008CA 59                      	POP	CX
  2008 000008CB 58                      	POP	AX
  2009                                  
  2010 000008CC 1E                      	push ds
  2011 000008CD E8(0000)                	call biocode_get_ds_dosbiodata
  2012                                   assume ds:DOSGROUP
  2013 000008D0 D006[0701]              	rol byte [hma_operation], 1
  2014 000008D4 7325                    	jnc .nohma
  2015 000008D6 F616[0701]              	not byte [hma_operation]
  2016 000008DA 803E[0000]02            	cmp byte [RFLAG], ROMREAD
  2017 000008DF 7516                    	jne .hma_write
  2018 000008E1 1F                      	pop ds
  2019                                   assume ds:UPB
  2020 000008E2 5B                      	pop bx
  2021 000008E3 07                      	pop es
  2022                                   assume es:nothing
  2023 000008E4 1E                      	 push ds
  2024 000008E5 56                      	 push si
  2025 000008E6 57                      	 push di
  2026 000008E7 89DF                    	mov di, bx
  2027 000008E9 E8(0000)                	call biocode_get_ds_dosentry
  2028                                   assume ds:DOSENTRYGROUP
  2029 000008EC BE[0000]                	mov si, DISKSECTOR		; access with ds
  2030 000008EF E84F0C                  	call MOVE
  2031 000008F2 5F                      	 pop di
  2032 000008F3 5E                      	 pop si
  2033 000008F4 1F                      	 pop ds
  2034                                   assume ds:UPB
  2035 000008F5 EB05                    	jmp @F
  2036                                  .hma_write:
  2037 000008F7 1F                      	pop ds
  2038                                   assume ds:UPB
  2039 000008F8 5B                      	pop bx
  2040 000008F9 07                      	pop es
  2041                                   assume es:nothing
  2042 000008FA A8                      	db __TEST_IMM8		; skip pop
  2043                                  .nohma:
  2044 000008FB 1F                      	pop ds
  2045                                   assume ds:UPB
  2046                                  @@:
  2047                                  
  2048                                  ;
  2049                                  ; CX IS THE NUMBER OF SECTORS JUST TRANSFERRED
  2050                                  ;
  2051 000008FC 29C8                    	SUB	AX,CX			; REDUCE SECTORS-REMAINING BY LAST I/O
  2052 000008FE D0E1                    	SHL	CL,1
  2053 00000900 00CF                    	ADD	BH,CL			; ADJUST TRANSFER ADDRESS
  2054 00000902 E94CFF                  	JMP	BLOCK
  2055                                  IOSETUP ENDP
  2056                                  
  2057                                  DskErr equ DSKERR	; NASM port label
  2058 00000905 E9FF00                  DskErr_Brdg: jmp DskErr 		;AN003;
  2059                                  
  2060                                  
  2061                                  		; INP:	variables from lbatochs
  2062                                  		;	ds:di -> UPB
  2063                                  		; OUT:	cx:dx = tuple value
  2064                                  	public chstotuple
  2065                                  chstotuple:
  2066                                   assume ds:UPB, es:nothing, ss:nothing
  2067 00000908 1E                      	push ds
  2068 00000909 E8(0000)                	call biocode_get_ds_dosbiodata
  2069                                   assume ds:DOSGROUP
  2070 0000090C 8B0E[0000]              	MOV	cx, [CURTRK]		;LOAD CURRENT CYLINDER
  2071 00000910 D0CD                    	ROR	ch, 1
  2072 00000912 D0CD                    	ROR	ch, 1
  2073                                  
  2074 00000914 0A2E[0000]              	OR	ch, [CURSEC]
  2075 00000918 86E9                    	XCHG	CH,CL			; CL = SECTOR, CH = CYLINDER
  2076 0000091A 8A36[0000]              	MOV	DH,BYTE PTR [CURHD]	; LOAD CURRENT HEAD NUMBER AND
  2077 0000091E 1F                      	pop ds
  2078                                   assume ds:UPB
  2079 0000091F 8A5504                  	MOV	DL,BYTE PTR [DI + DRIVENUM]  ; PHYSICAL DRIVE NUMBER
  2080 00000922 C3                      	ret
  2081                                  
  2082                                  ;
  2083                                  ;PERFORM DISK I/O WITH RETRIES
  2084                                  ; AL = NUMBER OF SECTORS (1-8, ALL ON ONE TRACK)
  2085                                  ; DI POINT TO DRIVE PARAMETERS
  2086                                  ; ES:BX = TRANSFER ADDRESS (MUST NOT CROSS A 64K PHYSICAL BOUNDARY)
  2087                                  ; [RFLAG] = 2 IF READ, 3 IF WRITE
  2088                                  ; [VERIFY] = 0 FOR NORMAL, 1 FOR VERIFY AFTER WRITE
  2089                                  
  2090                                  	PUBLIC DISK
  2091                                  DISK	PROC	NEAR
  2092                                   assume ds:UPB, es:nothing, ss:nothing
  2093 00000923 BD0500                  	MOV	BP,MAXERR		; SET UP RETRY COUNT
  2094 00000926 1E                      	push ds
  2095 00000927 E8(0000)                	call biocode_get_ds_dosbiodata
  2096                                   assume ds:DOSGROUP
  2097 0000092A 892E[0000]              	mov	[VRetry_Cnt], BP	;AN003;Verify op. retry cnt for Write-Verify.
  2098 0000092E 892E[0000]              	mov	[Soft_ECC_Cnt], BP	;AN003;Soft ECC error retry count.
  2099 00000932 8A26[0000]              	MOV	AH,[RFLAG]		;GET READ/WRITE INDICATOR
  2100 00000936 1F                      	pop ds
  2101                                   assume ds:UPB
  2102                                  
  2103                                  RETRY:
  2104                                   assume ds:UPB
  2105 00000937 50                      	PUSH	AX
  2106                                  
  2107 00000938 E8CDFF                  	call chstotuple
  2108 0000093B 807D2205                	CMP	BYTE PTR [DI + FORMFACTOR],FFHARDFILE
  2109 0000093F 7419                    	JZ	DO_FAST 		; HARD FILES USE FAST SPEED
  2110                                  ; IF WE HAVE [STEP_DRV] SET TO -1, WE USE THE SLOW SETTLE TIME.
  2111                                  ; THIS HELPS WHEN WE HAVE JUST DONE A RESED DISK OPERATION AND THE HEAD HAS
  2112                                  ; BEEN MOVED TO ANOTHER CYLINDER - THE PROBLEM CROPS UP WITH 3.5" DRIVES.
  2113 00000941 1E                      	push ds
  2114 00000942 E8(0000)                	call biocode_get_ds_dosbiodata
  2115                                   assume ds:DOSGROUP
  2116 00000945 803E[0000]FF            	CMP	byte [STEP_DRV],-1
  2117 0000094A 1F                      	pop ds
  2118                                   assume ds:UPB
  2119 0000094B 740A                    	JZ	DO_WRITEJ
  2120 0000094D 80FC02                  	CMP	AH,ROMREAD		; ARR 2.20
  2121 00000950 7408                    	JE	DO_FAST
  2122 00000952 80FC04                  	CMP	AH, ROMVERIFY
  2123 00000955 7403                    	JE	DO_FAST
  2124                                  DO_WRITEJ:
  2125                                  ; READS ALWAYS FAST, UNLESS WE HAVE JUST DONE A DISK RESET OPERATION
  2126 00000957 EB6B                    	JMP	DO_WRITE		; ARR 2.20 READS ALWAYS FAST
  2127 00000959 90                      	nop	; identicalise
  2128                                  DO_FAST:				; ARR 2.20
  2129 0000095A E84201                  	CALL	FASTSPEED		; MZ  2.21 CHANGE SETTLE MODE
  2130                                  TESTERR:				; MZ  2.21
  2131                                  DSKERR_brdg equ DskErr_Brdg	; NASM port label
  2132 0000095D 72A6                    	JC	DSKERR_brdg
  2133                                  ; SET DRIVE AND TRACK OF LAST ACCESS
  2134 0000095F 886D46                  	MOV	BYTE PTR [DI + TRACK],CH	; ARR 2.20 SAVE TRACK
  2135 00000962 1E                      	push ds
  2136 00000963 E8(0000)                	call biocode_get_ds_dosbiodata
  2137                                   assume ds:DOSGROUP
  2138 00000966 8816[0000]              	MOV	[STEP_DRV],DL	; ARR 2.20 SET DRIVE
  2139 0000096A 813E[0000]0301          	CMP	word [WRTVERIFY],103H	; CHECK FOR WRITE AND VERIFY
  2140 00000970 1F                      	pop ds
  2141                                   assume ds:UPB
  2142 00000971 7466                    	JZ	DOVERIFY
  2143                                  NOVERIFY:
  2144 00000973 58                      	POP	AX
  2145                                  
  2146                                  ;SB34DISK003*****************************************************************
  2147                                  ;SB	Check the flags word in the BDS to see if the drive is non removable
  2148                                  ;SB	If not we needn't do anything special
  2149                                  ;SB	If it is a hard disk then check to see if multi-track operation
  2150                                  ;SB	is specified.  If specified we don't have to calculate for the next
  2151                                  ;SB	track since we are already done.  So we can go to the exit of this 
  2152                                  ;SB	routine.	5 LOCS
  2153                                  
  2154                                  fNON_REMOVABLE equ FNON_REMOVABLE	; NASM port equate
  2155 00000974 F745230100              	test	word ptr [di + FLAGS], fNON_REMOVABLE
  2156 00000979 1E                      	push ds
  2157 0000097A E8(0000)                	call biocode_get_ds_dosbiodata
  2158                                   assume ds:DOSGROUP
  2159 0000097D 7408                    	jz	ITS_REMOVABLE
  2160 0000097F F706[0000]8000          	test	word [MulTrk_Flag], MulTrk_ON
  2161 00000985 753A                    	jnz	DISK_RET
  2162                                  ITS_REMOVABLE:
  2163                                  ;SB34DISK003*****************************************************************
  2164 00000987 80E13F                  	AND	CL,03FH 		; ELIMINATE CYLINDER BITS FROM SECTOR
  2165 0000098A 30E4                    	XOR	AH,AH
  2166 0000098C 2906[0000]              	SUB	[SECCNT],AX		; REDUCE COUNT OF SECTORS TO GO
  2167 00000990 00C1                    	ADD	CL,AL			; NEXT SECTOR
  2168 00000992 880E[0000]              	MOV	[CURSEC],CL
  2169 00000996 1F                      	pop ds
  2170                                   assume ds:UPB
  2171 00000997 1E                      	push ds
  2172 00000998 3A4D13                  	CMP	CL,BYTE PTR [DI + SECLIM] ; SEE IF SECTOR/TRACK LIMIT REACHED
  2173 0000099B E8(0000)                	call biocode_get_ds_dosbiodata
  2174                                   assume ds:DOSGROUP
  2175 0000099E 7621                    	JBE	DISK_RET
  2176                                  NEXTTRACK:
  2177 000009A0 C606[0000]01            	MOV	byte [CURSEC],1		; START WITH FIRST SECTOR OF NEXT TRACK
  2178 000009A5 8A36[0000]              	MOV	DH,[CURHD]
  2179 000009A9 FEC6                    	INC	DH
  2180 000009AB 740A                    	jz nexttrack_xor
  2181 000009AD 1F                      	pop ds
  2182                                   assume ds:UPB
  2183 000009AE 1E                      	push ds
  2184 000009AF 3A7515                  	CMP	DH,BYTE PTR [DI + HDLIM]
  2185 000009B2 E8(0000)                	call biocode_get_ds_dosbiodata
  2186                                   assume ds:DOSGROUP
  2187 000009B5 7206                    	JB	NOXOR
  2188                                  nexttrack_xor:
  2189 000009B7 30F6                    	XOR	DH,DH
  2190 000009B9 FF06[0000]              	INC	word [CURTRK]		;NEXT TRACK
  2191                                  NOXOR:
  2192 000009BD 8836[0000]              	MOV	[CURHD],DH
  2193                                  DISK_RET:
  2194 000009C1 1F                      	pop ds
  2195                                   assume ds:UPB
  2196 000009C2 F8                      	CLC				; LEEAC
  2197 000009C3 C3                      	RET
  2198                                  DISK	ENDP
  2199                                  
  2200                                  
  2201                                  ; THE REQUEST IS FOR WRITE.  DETERMINE IF WE ARE TALKING ABOUT THE SAME
  2202                                  ; TRACK AND DRIVE.  IF SO, USE THE FAST SPEED.
  2203                                  
  2204                                  DO_WRITE PROC	NEAR
  2205 000009C4 1E                      	push ds
  2206 000009C5 E8(0000)                	call biocode_get_ds_dosbiodata
  2207                                   assume ds:DOSGROUP
  2208 000009C8 3A16[0000]              	CMP	DL,[STEP_DRV]	; ARR 2.20
  2209 000009CC 1F                      	pop ds
  2210                                   assume ds:UPB
  2211 000009CD 7505                    	JNZ	DO_NORM 		;  WE HAVE CHANGED DRIVES
  2212                                  
  2213 000009CF 3A6D46                  	CMP	CH,BYTE PTR [DI + TRACK]	; ARR 2.20
  2214 000009D2 7486                    	JZ	DO_FAST 		; WE ARE STILL ON THE SAME TRACK
  2215                                  
  2216                                  DO_NORM:
  2217 000009D4 E89600                  	CALL	NORMSPEED
  2218 000009D7 EB84                    	JMP	SHORT TESTERR		; MZ  2.21 TEST FOR ERROR
  2219                                  DO_WRITE ENDP
  2220                                  ;
  2221                                  ; WE HAVE A VERIFY REQUEST ALSO.  GET STATE INFO AND GO VERIFY
  2222                                  ;
  2223                                  
  2224                                  DOVERIFY PROC	NEAR
  2225 000009D9 58                      	POP	AX			; RESTORE SECTOR COUNT
  2226 000009DA 50                      	PUSH	AX
  2227 000009DB B404                    	MOV	AH,ROMVERIFY		; REQUEST VERIFY
  2228 000009DD E8BF00                  	CALL	FASTSPEED		; MZ  2.21 CHANGE SETTLE MODE
  2229 000009E0 7391                    	JNC	NOVERIFY
  2230                                  
  2231                                  ;SB34DISK004**************************************************************
  2232                                  ;SB	check the error returned in AH to see if it is a SOFT ECC error.
  2233                                  ;SB	If it is not we needn't do anything special.  If it is a SOFT
  2234                                  ;SB	ECC error then decrement the SOFT_ECC_CNT error retry count. If
  2235                                  ;SB	this retry count becomes 0 then we just  ignore the error and go to
  2236                                  ;SB	No_verify but if we can still try then we call the routine to reset
  2237                                  ;SB	the disk and go to DSKerr1 to retry the operation.	6 LOCS
  2238                                  
  2239 000009E2 80FC11                  	cmp	ah,11h			;SOFT ECC error ?
  2240 000009E5 7511                    	jnz	Not_SoftECC_Err
  2241                                  SOFT_ECC_CNT equ Soft_ECC_Cnt	; NASM port label
  2242 000009E7 1E                      	push ds
  2243 000009E8 E8(0000)                	call biocode_get_ds_dosbiodata
  2244                                   assume ds:DOSGROUP
  2245 000009EB FF0E[0000]              	dec	word [SOFT_ECC_CNT]
  2246 000009EF 1F                      	pop ds
  2247                                   assume ds:UPB
  2248                                  NoVerify equ NOVERIFY	; NASM port label
  2249 000009F0 7481                    	jz	NoVerify		;no more retry
  2250                                  ResetDisk equ RESETDISK	; NASM port label
  2251 000009F2 E86F08                  	call	ResetDisk		;reset disk
  2252                                  DskErr1 equ DSKERR1	; NASM port label
  2253 000009F5 EB4D                    	jmp	DskErr1			;retry
  2254 000009F7 90                      	nop	; identicalise
  2255                                  
  2256                                  ;SB34DISK004**************************************************************
  2257                                  
  2258                                  Not_SoftECC_Err:			;AN003;Other error.
  2259 000009F8 E86908                  	call	ResetDisk		;AN003;
  2260 000009FB 1E                      	push ds
  2261 000009FC E8(0000)                	call biocode_get_ds_dosbiodata
  2262                                   assume ds:DOSGROUP
  2263 000009FF FF0E[0000]              	dec	word [VRetry_Cnt]		;AN003;
  2264 00000A03 1F                      	pop ds
  2265                                   assume ds:UPB
  2266 00000A04 EB20                    	jmp	DskErr0 		;AN003;
  2267 00000A06 90                      	nop	; identicalise
  2268                                  DOVERIFY ENDP
  2269                                  ;
  2270                                  ; NEED TO SPECIAL CASE THE CHANGE-LINE ERROR AH=06H.  IF WE GET THIS, WE
  2271                                  ; NEED TO RETURN IT.
  2272                                  ;
  2273                                  ;----------------------------------------|
  2274                                  ; WARNING: DO NOT CHANGE THE FOLLOWING. ;|
  2275                                  ;	   IT GETS PATCHED IN MSINIT	;|
  2276                                  	PUBLIC DSKERR			;|
  2277                                  DSKERR	PROC	NEAR			;|
  2278 00000A07 E8670B                  	call ispatched
  2279 00000A0A 7203                    	jc @F
  2280                                  	PUBLIC DSKERR_PATCH
  2281                                  DSKERR_PATCH:
  2282 00000A0C E8(0000)                	CALL	CHECKIO 		;|
  2283                                  @@:
  2284                                  ;---------------------------------------;|
  2285                                  
  2286 00000A0F 1E                      	push ds
  2287 00000A10 E8(0000)                	call biocode_get_ds_dosbiodata
  2288                                   assume ds:DOSGROUP
  2289 00000A13 803E[0000]01            	cmp	byte [MultiTrk_Format_Flag], 1 ;AN007;Multi trk format request?
  2290 00000A18 7508                    	jne	DoChkAgain		   ;AN007;
  2291 00000A1A BD0100                  	mov	bp, 1			   ;AN007;No more retry.
  2292 00000A1D C606[0000]00            	mov	byte [MultiTrk_Format_Flag], 0 ;AN007;Clear the flag.
  2293                                  DoChkAgain:				   ;AN007;
  2294 00000A22 1F                      	pop ds
  2295                                   assume ds:UPB
  2296 00000A23 E83908                  	CALL	AGAIN
  2297                                  DskErr0:				;AN003;
  2298 00000A26 7425                    	JZ	HARDERR
  2299 00000A28 F745230100              	test	word ptr [di + FLAGS], fNon_Removable	;AN009;
  2300 00000A2D 7505                    	jnz	Skip_TimeOut_Chk			;AN009;
  2301 00000A2F 80FC80                  	CMP	AH,80H			;TIMEOUT?
  2302 00000A32 7419                    	JZ	HARDERR			;***
  2303                                  Skip_TimeOut_Chk:			;AN009;
  2304 00000A34 80FCCC                  	cmp	ah, 0cch		;AN003;Write Fault error?
  2305 00000A37 740F                    	jz	Write_Fault_Err		;AN003; Then, don't retry.
  2306 00000A39 1E                      	push ds
  2307 00000A3A E8(0000)                	call biocode_get_ds_dosbiodata
  2308                                   assume ds:DOSGROUP
  2309 00000A3D C706[0000]0500          	mov	word [Soft_ECC_Cnt], MAXERR ;AN003;Set Soft_ECC_Cnt back to MAXERR
  2310 00000A43 1F                      	pop ds
  2311                                   assume ds:UPB
  2312                                  DSKERR1:
  2313 00000A44 58                      	POP	AX			;RESTORE SECTOR COUNT
  2314 00000A45 E9EFFE                  	JMP	RETRY
  2315                                  
  2316                                  Write_Fault_Err:			;AN003;
  2317 00000A48 BD0100                  	mov	bp, 1			;AN003;Just retry only once for Write Fault error.
  2318 00000A4B EBF7                    	jmp	DskErr1			;AN003;
  2319                                  
  2320                                  HARDERR:
  2321                                  	PUBLIC	HARDERR
  2322                                  
  2323 00000A4D E85D00                  	CALL	MAPERROR
  2324                                  
  2325                                  HARDERR2:			; FOR ROUTINES THAT CALL MAPERROR THEMSELVES
  2326                                  	PUBLIC	HARDERR2
  2327                                  
  2328 00000A50 1E                      	push ds
  2329 00000A51 E8(0000)                	call biocode_get_ds_dosbiodata
  2330                                   assume ds:DOSGROUP
  2331 00000A54 8F06[0000]              	pop word [dosbiodata_temp_ds]
  2332 00000A58 C606[0000]FF            	MOV	byte [TIM_DRV],-1	;FORCE A MEDIA CHECK THROUGH ROM
  2333 00000A5D 8B0E[0000]              	MOV	CX,[SECCNT]		;GET COUNT OF SECTORS TO GO
  2334 00000A61 8B26[0000]              	MOV	SP,[SPSAV]		;RECOVER ENTRY STACK POINTER
  2335 00000A65 8E1E[0000]              	mov ds, word [dosbiodata_temp_ds]
  2336                                   assume ds:UPB
  2337                                  ;
  2338                                  ; SINCE WE ARE PERFORMING A NON-LOCAL GOTO, RESTORE THE DISK PARAMETERS
  2339                                  ;
  2340                                  MEDBYT_OK:
  2341 00000A69 E85DFD                  	CALL	DIDDLEBACK
  2342 00000A6C C3                      	RET				;AND RETURN
  2343                                  DSKERR	ENDP
  2344                                  
  2345                                  ;
  2346                                  ; CHANGE SETTLE VALUE FROM SETTLECURRENT TO WHATEVER IS APPROPRIATE
  2347                                  ; NOTE THAT THIS ROUTINE IS NEVER CALLED FOR A FIXED DISK.
  2348                                  ;
  2349                                  NORMSPEED PROC	NEAR
  2350 00000A6D 06                      	push es
  2351 00000A6E E8(0000)                	call biocode_get_es_dosbiodata
  2352                                   assume es:DOSGROUP
  2353 00000A71 26803E[FF00]00          	cmp	byte [es:Media_Set_For_Format], 0	;AN012;
  2354 00000A77 7525                    	jne	FASTSPEED_es			;AN012;
  2355 00000A79 1E                      	PUSH	DS
  2356 00000A7A 50                      	PUSH	AX
  2357 00000A7B 26A0[0000]              	MOV	AL,[es:SETTLESLOW]
  2358 00000A7F 26C536[0000]            	LDS	SI,[es:DPT]		; CURRENT DISK PARM TABLE
  2359                                   assume ds:nothing
  2360 00000A84 884409                  	MOV	[SI + DISK_HEAD_STTL],AL
  2361 00000A87 58                      	POP	AX
  2362 00000A88 1F                      	POP	DS
  2363                                   assume ds:UPB
  2364 00000A89 07                      	pop es
  2365                                   assume es:nothing
  2366 00000A8A E81200                  	CALL	FASTSPEED
  2367 00000A8D 06                      	push es
  2368 00000A8E E8(0000)                	call biocode_get_es_dosbiodata
  2369                                   assume es:DOSGROUP
  2370 00000A91 1E                      	PUSH	DS
  2371 00000A92 26C536[0000]            	LDS	SI,[es:DPT]
  2372                                   assume ds:nothing
  2373 00000A97 C6440901                	MOV	byte [SI + DISK_HEAD_STTL],1	; 1 IS FAST SETTLE VALUE
  2374 00000A9B 1F                      	POP	DS
  2375                                   assume ds:UPB
  2376 00000A9C 07                      	pop es
  2377                                   assume es:nothing
  2378 00000A9D C3                      	RET
  2379                                  NORMSPEED ENDP
  2380                                  
  2381                                  FASTSPEED_es:
  2382 00000A9E 07                      	pop es
  2383                                   assume es:nothing
  2384                                  FASTSPEED PROC	NEAR
  2385                                   assume ds:UPB, es:nothing, ss:nothing
  2386                                  ;
  2387                                  ; IF THE DRIVE HAS BEEN MARKED AS TOO BIG (I.E. STARTING SECTOR OF THE
  2388                                  ; PARTITION IS > 16 BITS, THEN ALWAYS RETURN DRIVE NOT READY.
  2389                                  ;
  2390 00000A9F F6451F80                	TEST	BYTE PTR [DI + FATSIZ],FTOOBIG
  2391                                   %IF itest
  2392                                  	JZ	READY
  2393                                  	JMP	NOTREADY
  2394                                  READY:
  2395                                   %ELSE
  2396 00000AA3 7503                    	JNZ	NOTREADY
  2397                                   %ENDIF
  2398                                  
  2399                                  	MESSAGE FTESTINIT,<"<">
  2400                                  	MNUM	FTESTINIT,AX
  2401                                  	MESSAGE FTESTINIT,<",">
  2402                                  	MNUM	FTESTINIT,ES
  2403                                  	MESSAGE FTESTINIT,<":">
  2404                                  	MNUM	FTESTINIT
  2405                                  	MESSAGE FTESTINIT,<",">
  2406                                  	MNUM	FTESTINIT,CX
  2407                                  	MESSAGE FTESTINIT,<",">
  2408                                  	MNUM	FTESTINIT,DX
  2409                                  	MESSAGE FTESTINIT,<">">
  2410 00000AA5 CD13                    	INT	13H
  2411                                  DEATH:
  2412 00000AA7 C3                      	RET
  2413                                  NOTREADY:
  2414 00000AA8 F9                      	STC
  2415 00000AA9 B480                    	MOV	AH,80H
  2416 00000AAB EBFA                    	JMP	DEATH
  2417                                  FASTSPEED ENDP
  2418                                  
  2419                                  ; MAP ERROR RETURNED BY ROM IN AH INTO CORRESPONDING CODE TO BE RETURNED TO
  2420                                  ; DOS IN AL.
  2421                                  ;
  2422                                  MAPERROR PROC	NEAR
  2423                                  	PUBLIC	MAPERROR
  2424                                  
  2425 00000AAD 51                      	PUSH	CX			; SAVE CX
  2426 00000AAE E8(0000)                	call biocode_get_es_dosbiodata
  2427                                   assume es:DOSGROUP
  2428                                  					;MAKE ES THE LOCAL SEGMENT
  2429 00000AB1 88E0                    	MOV	AL,AH			;PUT ERROR CODE IN AL
  2430 00000AB3 26A2[0000]              	MOV	[es:LSTERR],AL		;TERMINATE LIST WITH ERROR CODE
  2431 00000AB7 B9[0000]                	MOV	CX,NUMERR		;NUMBER OF POSSIBLE ERROR CONDITIONS
  2432 00000ABA BF[0000]                	MOV	DI,OFFSET ERRIN      ;POINT TO ERROR CONDITIONS ; access with es
  2433 00000ABD F2AE                    	REPNE	SCASB
  2434 00000ABF 268A85[FFFF]            	MOV	AL,[es:DI + NUMERR - 1]    ;GET TRANSLATION
  2435 00000AC4 59                      	POP	CX			; RESTORE CX
  2436 00000AC5 F9                      	STC				;FLAG ERROR CONDITION
  2437 00000AC6 C3                      	RET
  2438                                  MAPERROR ENDP
  2439                                  
  2440                                  ; SET THE TIME OF LAST ACCESS FOR THIS DRIVE. THIS IS DONE ONLY FOR REMOVABLE
  2441                                  ; MEDIA.
  2442                                  
  2443                                  	PUBLIC SET_TIM
  2444                                  SET_TIM PROC	NEAR
  2445                                   assume ds:UPB, es:nothing, ss:nothing
  2446 00000AC7 50                      	PUSH	AX
  2447                                  ;SB33018******************************************************************
  2448 00000AC8 30E4                    	xor	AH, AH			; set command to get time      ;SB;3.30*
  2449 00000ACA CD1A                    	int	1Ah			; call rom-bios timer function ;SB;3.30*
  2450                                  ;SB33018******************************************************************
  2451 00000ACC 08C0                    	OR	AL,AL
  2452 00000ACE 7409                    	JZ	NOROLL3
  2453 00000AD0 1E                      	push ds
  2454 00000AD1 E8(0000)                	call biocode_get_ds_dosbiodata
  2455                                   assume ds:DOSGROUP
  2456 00000AD4 FF06[0000]              	INC	word [DAYCNT]		; CATCH ROLLOVER
  2457 00000AD8 1F                      	pop ds
  2458                                   assume ds:UPB
  2459                                  NOROLL3:
  2460                                  ; WE HAVE THE NEW TIME. IF WE SEE THAT THE TIME HAS PASSED, THEN WE RESET
  2461                                  ; THE THRESHOLD COUNTER...
  2462 00000AD9 3B5547                  	CMP	DX,WORD PTR [DI + TIM_LO]
  2463 00000ADC 7505                    	JNZ	SETACCESS
  2464 00000ADE 3B4D49                  	CMP	CX,WORD PTR [DI + TIM_HI]
  2465 00000AE1 7410                    	JZ	DONE_SET
  2466                                  SETACCESS:
  2467 00000AE3 1E                      	push ds
  2468 00000AE4 E8(0000)                	call biocode_get_ds_dosbiodata
  2469                                   assume ds:DOSGROUP
  2470 00000AE7 C606[0000]00            	MOV	BYTE PTR [ACCESSCOUNT],0
  2471 00000AEC 1F                      	pop ds
  2472                                   assume ds:UPB
  2473 00000AED 895547                  	MOV	WORD PTR [DI + TIM_LO],DX 	    ;SAVE IT
  2474 00000AF0 894D49                  	MOV	WORD PTR [DI + TIM_HI],CX
  2475                                  DONE_SET:
  2476 00000AF3 F8                      	CLC
  2477 00000AF4 58                      	POP	AX
  2478 00000AF5 C3                      	RET
  2479                                  SET_TIM ENDP
  2480                                  
  2481                                  	ASSUME	DS:NOTHING,ES:NOTHING,SS:NOTHING
  2482                                  
  2483                                  ;
  2484                                  ; THIS IS THE TRUE INT 13 HANDLER.  WE PARSE THE REQUEST TO SEE IF THERE IS
  2485                                  ; A DMA VIOLATION.  IF SO, DEPENDING ON THE FUNCTION, WE:
  2486                                  ;   READ/WRITE	BREAK THE REQUEST INTO THREE PIECES AND MOVE THE MIDDLE ONE
  2487                                  ;	INTO OUR INTERNAL BUFFER.
  2488                                  ;   FORMAT	COPY THE FORMAT TABLE INTO THE BUFFER
  2489                                  ;   VERIFY	POINT THE TRANSFER ADDRESS INTO THE BUFFER
  2490                                  ;
  2491                                  ; THIS IS THE BIGGEST BOGOSITY OF ALL.	THE IBM CONTROLLER DOES NOT HANDLE
  2492                                  ; OPERATIONS THAT CROSS PHYSICAL 64K BOUNDARIES.  IN THESE CASES, WE COPY
  2493                                  ; THE OFFENDING SECTOR INTO THE BUFFER BELOW AND DO THE I/O FROM THERE.
  2494                                  ;
  2495                                  
  2496                                  
  2497                                  INT13FRAME  STRUC
  2498 00000000 ????                    OLDBP	DW  ?
  2499 00000002 ????                    OLDAX	DW  ?
  2500 00000004 ????                    OLDBX	DW  ?
  2501 00000006 ????                    OLDCX	DW  ?
  2502 00000008 ????                    OLDDX	DW  ?
  2503 0000000A ????????                OLDDD	DD  ?
  2504 0000000E ????                    OLDF	DW  ?
  2505                                  INT13FRAME  ENDS
  2506                                  
  2507                                  section DOSENTRY
  2508                                  
  2509                                  	extern Prev_DX, dosbiodata_temp_ds
  2510                                  
  2511                                  
  2512                                  section BIOCODE
  2513                                  
  2514                                  ;   ENTRY CONDITIONS:
  2515                                  ;	AH = FUNCTION
  2516                                  ;	AL = NUMBER OF SECTORS
  2517                                  ;	ES:BX = DMA ADDRESS
  2518                                  ;	CX = PACKED TRACK AND SECTOR
  2519                                  ;	DX = HEAD AND DRIVE
  2520                                  ;   OUTPUT CONDITIONS:
  2521                                  ;	NO DMA VIOLATION.
  2522                                  ;
  2523                                  relocated msdisk_i13
  2524                                  	PUBLIC BLOCK13
  2525                                  BLOCK13 PROC	FAR
  2526                                  ;
  2527                                  ; LET THE OPPERATION PROCEED.  IF THERE IS A DMA VIOLATION, THEN WE DO THINGS.
  2528                                  ;
  2529 00000AF6 1E                      	push ds
  2530 00000AF7 E8(0000)                	call biocode_get_ds_dosbiodata
  2531                                   assume ds:DOSGROUP
  2532 00000AFA A3[0000]                	MOV	[PREVOPER],AX		; SAVE REQUEST
  2533 00000AFD 1F                      	pop ds
  2534                                   assume ds:nothing
  2535 00000AFE 9C                      	PUSHF
  2536 00000AFF 80FC05                  	CMP	AH,ROMFORMAT
  2537 00000B02 750D                    	JNZ	NOT_FORMAT
  2538                                  ; SET CHANGED BY FORMAT BIT FOR ALL LOGICAL DRIVES USING THIS PHYSICAL DRIVE
  2539                                  ;---------------------------------------------------------|
  2540                                  ; WARNING: DO NOT CHANGE THE FOLLOWING.
  2541                                  ; IT GETS PATCHED IN AT INIT TIME			  |
  2542 00000B04 53                      	push bx
  2543 00000B05 BB4001                  	MOV	bx,FCHANGED_BY_FORMAT+FCHANGED
  2544 00000B08 E8660A                  	call ispatched
  2545 00000B0B 7203                    	jc @F
  2546                                  	PUBLIC CHANGED_PATCH
  2547                                  CHANGED_PATCH:
  2548 00000B0D E8(0000)                	CALL	SET_CHANGED_DL		; INDICATE THAT MEDIA CHANGED BY FORMAT
  2549                                  @@:
  2550 00000B10 5B                      	pop bx
  2551                                  ;							  |
  2552                                  ;---------------------------------------------------------|
  2553                                  NOT_FORMAT:
  2554 00000B11 1E                      	push ds
  2555 00000B12 E8(0000)                	call biocode_get_ds_dosbiodata
  2556                                   assume ds:DOSGROUP
  2557 00000B15 F6C280                  	test	dl, 80h			; floppy or hard disk?
  2558 00000B18 7529                    	jnz	not_floppy		; if hard, skip this nonsense
  2559 00000B1A 803E[0000]00            	cmp	byte [EC35_Flag], 0		; any electrically compat. drives?
  2560 00000B1F 7422                    	jz	not_floppy		; no; proceed unhindered
  2561 00000B21 505351                  	SAVEREG	<ax, bx, cx>
  2562 00000B24 88D1                    	mov	cl, dl			; turn drive number into bit map:
  2563 00000B26 B001                    	mov	al, 1			;   assume drive 0
  2564 00000B28 D2E0                    	shl	al, cl			;   shift over correct number of times
  2565 00000B2A 8406[0000]              	test	al, [EC35_Flag]		; is THIS drive an electrically compatible 3.5 incher?
  2566 00000B2E 7410                    	jz	.not_EC35		; no; don't change anything
  2567 00000B30 88D3                    	mov	bl, dl			; which drive was it?
  2568 00000B32 30FF                    	xor	bh, bh			; need only one byte of index
  2569 00000B34 B84000                  	mov	ax, 40h			; the machine state byte is in the...
  2570 00000B37 1E                      	push ds
  2571 00000B38 8ED8                    	mov	ds, ax			; ...segment at 40h
  2572                                   assume ds:BDA
  2573 00000B3A C687900093              	mov	byte ptr [90h+bx], 93H	; establish drive type as: (360k disk in 360k drive, no double-stepping, 250 kbs transfer rate)
  2574 00000B3F 1F                      	pop ds
  2575                                   assume ds:DOSGROUP
  2576                                  .not_EC35:
  2577 00000B40 595B58                  	RESTOREREG <cx, bx, ax>
  2578                                  not_floppy:
  2579                                  model_byte equ Model_Byte	; NASM port label
  2580 00000B43 803E[0000]FA            	cmp	byte [model_byte], mdl_ps2_30	; is this a ps2/30?
  2581 00000B48 750A                    	jne	not_ps2_30		; if not, just do normal call
  2582 00000B4A 80FC08                  	cmp	ah, 8			;J.K. 1/30/87 Read Driver Parm ?
  2583 00000B4D 7412                    	je	ps2_30_Problem		;J.K. 1/30/87
  2584 00000B4F 80FC15                  	cmp	ah, 15h
  2585 00000B52 740D                    	je	ps2_30_Problem
  2586                                  not_ps2_30:
  2587 00000B54 1F                      	pop ds
  2588                                   assume ds:nothing
  2589 00000B55 9A[0000][ssss]          	call DOSENTRY:transfer_orig13	; SIMULATE INT 13
  2590 00000B5A 7203                    	JC	GOTERR13_br		; ERROR?
  2591 00000B5C E9(0000)                	jmp Leave13			; NO, RETURN AND CLEAR FLAGS
  2592                                  
  2593                                  Goterr13 equ GOTERR13	; NASM port label
  2594 00000B5F EB32                    GOTERR13_br: jmp Goterr13
  2595                                  
  2596                                  section DOSENTRY
  2597                                  
  2598                                  	extern transfer_orig13
  2599                                  
  2600                                  
  2601                                  section BIOCODE
  2602                                  
  2603                                  	extern Leave13
  2604                                  
  2605                                  
  2606                                  ;J.K.1/30/87 ps2_30 machine has some problem with AH=8h(Read Drive Parm), Int 13h.
  2607                                  ;This function does not reset the common buses after the execution.
  2608                                  ;To solve this problem, when we detect AH=8h, then we will save the result and
  2609                                  ;will issue AH=1 (Read Status) call to reset the buses.
  2610                                  
  2611                                  ps2_30_Problem:				;J.K. 1/30/87; ps2_30 = PS2 Model 30.
  2612                                   assume ds:DOSGROUP
  2613 00000B61 8916[0000]              	mov	[Prev_DX], DX		;save orignal drive number
  2614 00000B65 1F                      	pop ds
  2615                                   assume ds:nothing
  2616                                  Orig13 equ ORIG13	; NASM port label
  2617 00000B66 9A[0000][ssss]          	call DOSENTRY:transfer_orig13		;Do "Read drive parm"
  2618                                  
  2619 00000B6B 50                      	push ax
  2620 00000B6C 53                      	push bx
  2621 00000B6D 51                      	push cx
  2622 00000B6E 52                      	push dx
  2623 00000B6F 57                      	push di
  2624 00000B70 56                      	push si
  2625 00000B71 55                      	push bp
  2626 00000B72 1E                      	push ds
  2627 00000B73 06                      	push es
  2628 00000B74 9C                      	pushf
  2629 00000B75 E8(0000)                	call biocode_get_ds_dosbiodata
  2630                                   assume ds:DOSGROUP
  2631 00000B78 8B16[0000]              	mov	dx, [Prev_DX]		;restore orignal drive
  2632 00000B7C B401                    	mov	ah, 1			;Read Status.
  2633 00000B7E 9C                      	 pushf
  2634 00000B7F 9A[0000][ssss]          	call DOSENTRY:transfer_orig13	;Reset the bus as a side effect of this call.
  2635                                  
  2636 00000B84 9D                      	popf
  2637 00000B85 07                      	pop es
  2638                                   assume es:nothing
  2639 00000B86 1F                      	pop ds
  2640                                   assume ds:nothing
  2641 00000B87 5D                      	pop bp
  2642 00000B88 5E                      	pop si
  2643 00000B89 5F                      	pop di
  2644 00000B8A 5A                      	pop dx
  2645 00000B8B 59                      	pop cx
  2646 00000B8C 5B                      	pop bx
  2647 00000B8D 58                      	pop ax
  2648                                  GotErr13 equ GOTERR13	; NASM port label
  2649 00000B8E 7203                    	jc	GotErr13		;AH=8 had been an error?
  2650 00000B90 E9(0000)                	jmp Leave13
  2651                                  
  2652                                  ;
  2653                                  ; SOME KIND OF ERROR OCCURRED.	SEE IF IT IS DMA VIOLATION
  2654                                  ;
  2655                                  GOTERR13:
  2656 00000B93 9C                      	PUSHF
  2657 00000B94 80FC09                  	cmp	ah, 09h 		;AN011; DMA error?
  2658 00000B97 7408                    	je	Chk_ValidMedia_ERR13	;AN011;
  2659 00000B99 80FC11                  	cmp	ah, 11h 		;AN011; ECC error?
  2660 00000B9C 7403                    	je	Chk_ValidMedia_ERR13	;AN011;
  2661 00000B9E EB53                    	jmp	Skip_Ecc_Check		;AN011; Other error.  Just return back.
  2662 00000BA0 90                      	nop	; identicalise
  2663                                  
  2664                                  Chk_ValidMedia_ERR13:			;AN011;If SetDrive fails, then just
  2665 00000BA1 1E                      	push	ds			;AN011;    return back to INT 13h caller,
  2666 00000BA2 57                      	push	di			;AN011;      without performing ECC, DMA
  2667 00000BA3 50                      	push	ax			;AN011; 	error handling.
  2668 00000BA4 E8(0000)                	call biocode_get_ds_dosbiodata
  2669                                   assume ds:DOSGROUP
  2670                                  Phys_Drv equ PHYS_DRV	; NASM port label
  2671 00000BA7 C606[0000]01            	mov	byte ptr [Phys_Drv], 1 ;AN011;
  2672 00000BAC 88D0                    	mov	al, dl			;AN011;
  2673                                  SetDrive equ SETDRIVE	; NASM port label
  2674 00000BAE E858F8                  	call	SetDrive		;AN011;
  2675                                   assume ds:UPB
  2676 00000BB1 E8(0000)                	call biocode_get_ds_dosbiodata
  2677                                   assume ds:DOSGROUP
  2678 00000BB4 C606[0000]00            	mov	byte ptr [Phys_Drv], 0 ;AN011;
  2679 00000BB9 58                      	pop	ax			;AN011;
  2680 00000BBA 5F                      	pop	di			;AN011;
  2681 00000BBB 1F                      	pop	ds			;AN011;
  2682                                   assume ds:nothing
  2683 00000BBC 7235                    	jc	Skip_Ecc_Check		;AN011;
  2684                                  
  2685                                  ; TEST OF BIT PATTERN 08H LET OTHER ERRORS BE PASSED AS DMA ERRORS - PTR 32D0519
  2686                                  ;	TEST	AH,08H			; DMA BIT
  2687 00000BBE 80FC09                  	CMP	AH, 09H 		; DMA ERROR CODE
  2688 00000BC1 7503                    	JNZ	CHECK_ECC
  2689 00000BC3 E98F00                  	JMP	GOTDMAERR
  2690                                  CHECK_ECC:
  2691                                  ;J.K. AN003; Soft ECC bug is only applied to PC1 and PC-XT. So, we will enforce
  2692                                  ;this ECC error handler for them.   Also, since CMC hardfiles in PC AT also
  2693                                  ;generate a lot of unnecessary ECC errors, we will still cover PC ATs as
  2694                                  ;it is done in the earlier version of MSBIO.
  2695                                  ;During Format/Verify operation, we are going to consider any Soft Ecc as a
  2696                                  ;hard error.
  2697                                  
  2698                                  ;SB34DISK005*****************************************************************
  2699                                  ;SB	See if the machine we are operating on is a PC, XT or AT by checking
  2700                                  ;SB	the model byte.  The soft ECC bug is only on these machines and if
  2701                                  ;SB	the machine we are operating on is not one of these three then we
  2702                                  ;SB	needn't do anything special.  If we are operating one these however
  2703                                  ;SB	we check to see if the error occured during format by checking
  2704                                  ;SB	media_set_for_format.  If it did occur during format we cannot do
  2705                                  ;SB	anything but if not during format then check to see if the error
  2706                                  ;SB	returned in AH is the SOFT_ECC error and if so go to OK11 since
  2707                                  ;SB	the error can be ignored.  6 LOCS
  2708                                  
  2709 00000BC6 1E                      	push ds
  2710 00000BC7 E8(0000)                	call biocode_get_ds_dosbiodata
  2711                                   assume ds:DOSGROUP
  2712 00000BCA 803E[FF00]01            	cmp	byte [Media_Set_For_Format], 1 ; formatting?
  2713 00000BCF 7421                    	je	Skip_Ecc_Check_pop
  2714 00000BD1 803E[0000]FE            	cmp	byte [Model_Byte], 0FEh	; PC or XT?
  2715 00000BD6 7315                    	jae	Go_Chk_Ecc
  2716 00000BD8 803E[0000]FB            	cmp	byte [Model_Byte], 0FBh	; XT?
  2717 00000BDD 740E                    	je	Go_Chk_Ecc
  2718 00000BDF 803E[0000]FC            	cmp	byte [Model_Byte], 0FCh
  2719 00000BE4 750D                    	jne	Skip_Ecc_Check
  2720 00000BE6 803E[0000]02            	cmp	byte [Secondary_Model_Byte], 2 ; AT?
  2721 00000BEB 7706                    	ja	Skip_Ecc_Check
  2722                                  Go_Chk_Ecc:				; for PC, XT, AT
  2723 00000BED 80FC11                  	CMP	AH,11H
  2724 00000BF0 7405                    	JZ	OK11
  2725                                  Skip_Ecc_Check_pop:
  2726 00000BF2 1F                      	pop ds
  2727                                   assume ds:nothing
  2728                                  Skip_Ecc_Check:				;AN003; Just return back to INT 13h caller.
  2729                                  
  2730                                  ;SB34DISK005*****************************************************************
  2731                                  
  2732 00000BF3 9D                      	POPF
  2733 00000BF4 E9(0000)                	jmp Leave13
  2734                                  ;
  2735                                  ; WE HAVE AN ERROR STATUS 11H.	THIS INDICATES AN ECC-CORRECTED ERROR.	NOTE
  2736                                  ; THAT THIS INDICATES THAT THE DATA IS PROBABLY CORRECT BUT NOT CERTAINLY
  2737                                  ; CORRECT. THE ROMS ON PC-1S AND PC_XTS HAVE A 'BUG' IN THAT IF AN ECC ERROR
  2738                                  ; OCCURS FOR A MULTI-SECTOR READ, ONLY THE SECTORS UP TO THE ONE WHERE THE
  2739                                  ; ERROR OCCURRED ARE READ IN. WE HAVE NO WAY OF KNOWING HOW MANY WERE READ IN
  2740                                  ; THIS CASE, SO WE REDO THE OPERATION, READING ONE SECTOR AT A TIME. IF WE
  2741                                  ; GET AN ECC ERROR ON READING ONE SECTOR, WE IGNORE THE ERROR BECAUSE THE
  2742                                  ; SECTOR HAS BEEN READ IN.
  2743                                  ;
  2744                                  	PUBLIC OK11
  2745                                  OK11:
  2746 00000BF7 1F                      	pop ds
  2747                                   assume ds:nothing
  2748                                  ;	 POPF
  2749                                  ;J.K. 8/29/86 Here, it is better reset the system. So, we are going to
  2750                                  ;call Orig13 again
  2751                                  
  2752 00000BF8 30E4                    	xor	ah, ah
  2753 00000BFA 9A[0000][ssss]          	call DOSENTRY:transfer_orig13	;reset. Don't care about the result
  2754                                  
  2755 00000BFF 1E                      	push ds
  2756 00000C00 E8(0000)                	call biocode_get_ds_dosbiodata
  2757                                   assume ds:DOSGROUP
  2758 00000C03 A1[0000]                	MOV	AX,[PREVOPER]		; RETRIEVE REQUEST
  2759                                  ;
  2760                                  ; THIS WILL PROVIDE A TERMINATION POINT.
  2761                                  ;
  2762 00000C06 3C01                    	CMP	AL,1			; IF REQUEST FOR ONE SECTOR, ASSUME OK
  2763 00000C08 7506                    	JNZ	ECC_ERR_HANDLE
  2764 00000C0A 1F                      	pop ds
  2765                                   assume ds:nothing
  2766 00000C0B 30E4                    	XOR	AH,AH			; CLEAR CARRY TOO!
  2767 00000C0D E9(0000)                	jmp Leave13
  2768                                  
  2769                                  	PUBLIC ECC_ERR_HANDLE
  2770                                  ECC_ERR_HANDLE:
  2771                                   assume ds:DOSGROUP
  2772 00000C10 1F                      	pop ds
  2773                                   assume ds:nothing
  2774 00000C11 535152                  	SAVEREG <BX,CX,DX>
  2775 00000C14 1E                      	push ds
  2776 00000C15 E8(0000)                	call biocode_get_ds_dosbiodata
  2777                                   assume ds:DOSGROUP
  2778 00000C18 A2[0000]                	MOV	[NUMBER_OF_SEC],AL
  2779                                  LOOP_ECC:
  2780 00000C1B A1[0000]                	MOV	AX,[PREVOPER]
  2781 00000C1E B001                    	MOV	AL,1			; REQUEST FOR ONE SECTOR ONLY
  2782                                  ;
  2783                                  ; WE DO READS ONE SECTOR AT A TIME. THIS ENSURES THAT WE WILL EVENTUALLY
  2784                                  ; FINISH THE REQUEST SINCE ECC ERRORS ON ONE SECTOR DO READ IN THAT SECTOR.
  2785                                  ;
  2786                                  ; WE NEED TO PUT IN SOME "INTELLIGENCE" INTO THE ECC HANDLER TO HANDLE READS
  2787                                  ; THAT ATTEMPT TO READ MORE SECTORS THAN ARE AVAILABLE ON A PARTICULAR
  2788                                  ; TRACK.
  2789                                  ; WE CALL CHECK_WRAP TO SET UP THE SECTOR #, HEAD # AND CYLINDER # FOR
  2790                                  ; THIS REQUEST.
  2791                                  ; AT THIS POINT, ALL REGISTERS ARE SET UP FOR THE CALL TO ORIG13, EXCEPT
  2792                                  ; THAT THERE MAY BE A STARTING SECTOR NUMBER THAT IS BIGGER THAN THE NUMBER
  2793                                  ; OF SECTORS ON A TRACK.
  2794                                  ;
  2795 00000C20 E86308                  	CALL	CHECK_WRAP		; GET CORRECT PARAMETERS FOR INT 13
  2796 00000C23 1F                      	 pop ds
  2797                                   assume ds:nothing
  2798 00000C24 9C                      	PUSHF
  2799 00000C25 9A[0000][ssss]          	call DOSENTRY:transfer_orig13
  2800 00000C2A 7310                    	JNC	OK11_OP
  2801 00000C2C 80FC11                  	CMP	AH,11H			; ONLY ALLOW ECC ERRORS
  2802 00000C2F F9                      	stc				;J.K. 8/28/86 Set carry bit again.
  2803 00000C30 751D                    	JNZ	OK11_EXIT_err		;J.K. 8/26/86 Other error? --> (CY)
  2804 00000C32 B400                    	mov	ah, 0			;J.K. ECC error. Reset the system again.
  2805 00000C34 9C                      	pushf
  2806 00000C35 9A[0000][ssss]          	call DOSENTRY:transfer_orig13
  2807 00000C3A 31C0                    	xor	ax, ax			; clear the error code so that if this 
  2808                                  					; was the last sector, no error code 
  2809                                  					; will be returned for the corrected 
  2810                                  					; read. (clear carry too.)
  2811                                  OK11_OP:
  2812 00000C3C 1E                      	push ds
  2813 00000C3D E8(0000)                	call biocode_get_ds_dosbiodata
  2814                                   assume ds:DOSGROUP
  2815 00000C40 FE0E[0000]              	DEC	byte [NUMBER_OF_SEC]
  2816 00000C44 7408                    	JZ	OK11_EXIT		; ALL DONE?
  2817 00000C46 FEC1                    	INC	CL			; ADVANCE SECTOR NUMBER
  2818 00000C48 FEC7                    	INC	BH			; ADD 200H TO ADDRESS
  2819 00000C4A FEC7                    	INC	BH
  2820 00000C4C EBCD                    	JMP	SHORT LOOP_ECC
  2821                                  OK11_EXIT:
  2822 00000C4E 1F                      	pop ds
  2823                                   assume ds:nothing
  2824                                  OK11_EXIT_err:
  2825 00000C4F 5A595B                  	RESTOREREG <DX,CX,BX>
  2826 00000C52 E9(0000)                	jmp Leave13
  2827                                  ;
  2828                                  ; WE TRULY HAVE A DMA VIOLATION.  RESTORE REGISTER AX AND RETRY THE
  2829                                  ; OPERATION AS BEST WE CAN.
  2830                                  ;
  2831                                  GOTDMAERR:
  2832 00000C55 58                      	POP	AX			; CLEAN UP STACK
  2833 00000C56 1E                      	push ds
  2834 00000C57 E8(0000)                	call biocode_get_ds_dosbiodata
  2835                                   assume ds:DOSGROUP
  2836 00000C5A A1[0000]                	MOV	AX,[PREVOPER]
  2837 00000C5D 1F                      	pop ds
  2838                                   assume ds:nothing
  2839 00000C5E FB                      	STI
  2840 00000C5F 80FC02                  	CMP	AH,ROMREAD		; SAVE USER FLAGS
  2841 00000C62 7268                    	JB	INTDONE
  2842 00000C64 80FC04                  	CMP	AH,ROMVERIFY
  2843 00000C67 7439                    	JZ	INTVERIFY
  2844 00000C69 80FC05                  	CMP	AH,ROMFORMAT
  2845 00000C6C 7447                    	JZ	INTFORMAT
  2846 00000C6E 775C                    	JA	INTDONE
  2847                                  ;
  2848                                  ; WE ARE DOING A READ/WRITE CALL.  CHECK FOR DMA PROBLEMS
  2849                                  ;
  2850 00000C70 52515350                	SAVEREG <DX,CX,BX,AX>
  2851 00000C74 55                      	PUSH	BP
  2852 00000C75 89E5                    	MOV	BP,SP
  2853 00000C77 8CC2                    	MOV	DX,ES			; CHECK FOR 64K BOUNDARY ERROR
  2854                                  
  2855 00000C79 D1E2                    	SHL	DX,1
  2856 00000C7B D1E2                    	SHL	DX,1
  2857 00000C7D D1E2                    	SHL	DX,1
  2858 00000C7F D1E2                    	SHL	DX,1			; SEGMENT CONVERTED TO ABSOLUTE ADDRESS
  2859                                  
  2860 00000C81 01DA                    	ADD	DX,BX			; COMBINE WITH OFFSET
  2861 00000C83 81C2FF01                	ADD	DX,511			; SIMULATE A TRANSFER
  2862                                  ;
  2863                                  ; IF CARRY IS SET, THEN WE ARE WITHIN 512 BYTES OF THE END OF THE SEGMENT.
  2864                                  ; WE SKIP THE FIRST TRANSFER AND PERFORM THE REMAINING BUFFERING AND TRANSFER
  2865                                  ;
  2866 00000C87 7306                    	JNC	NO_SKIP_FIRST
  2867 00000C89 8A7609                  	MOV	DH,BYTE PTR [BP + OLDDX+1]	; SET UP HEAD NUMBER
  2868 00000C8C E9A500                  	JMP	BUFFER			;J.K. 4/10/86
  2869                                  ;	JMP	SHORT BUFFER
  2870                                  ;
  2871                                  ; DX IS THE PHYSICAL 16 BITS OF START OF TRANSFER.  COMPUTE REMAINING
  2872                                  ; SECTORS IN SEGMENT.
  2873                                  ;
  2874                                  NO_SKIP_FIRST:
  2875 00000C8F D0EE                    	SHR	DH,1			; DH = NUMBER OF SECTORS BEFORE ADDRESS
  2876 00000C91 B480                    	MOV	AH,128			; AH = MAX NUMBER OF SECTORS IN SEGMENT
  2877 00000C93 28F4                    	SUB	AH,DH
  2878                                  ;
  2879                                  ; AH IS NOW THE NUMBER OF SECTORS THAT WE CAN SUCCESSFULLY WRITE IN THIS
  2880                                  ; SEGMENT.  IF THIS NUMBER IS ABOVE OR EQUAL TO THE REQUESTED NUMBER, THEN WE
  2881                                  ; CONTINUE THE OPERATION AS NORMAL.  OTHERWISE, WE BREAK IT INTO PIECES.
  2882                                  ;
  2883 00000C95 38C4                    	CMP	AH,AL			; CAN WE FIT IT IN?
  2884                                  DOBLOCK equ DoBlock	; NASM port label
  2885 00000C97 7238                    	JB	DOBLOCK			; NO, PERFORM BLOCKING.
  2886                                  ;
  2887                                  ; YES, THE REQUEST FITS.  LET IT HAPPEN
  2888                                  ;
  2889 00000C99 8A7609                  	MOV	DH,BYTE PTR [BP + OLDDX+1]	; SET UP HEAD NUMBER
  2890 00000C9C E8B908                  	CALL	DOINT
  2891 00000C9F E9FF00                  	JMP	BAD13
  2892                                  ;
  2893                                  ; VERIFY THE GIVEN SECTORS.  PLACE THE BUFFER POINTER INTO OUR SPACE.
  2894                                  ;
  2895                                  INTVERIFY:
  2896 00000CA2 0653                    	SAVEREG <ES,BX>
  2897 00000CA4 E8(0000)                	call biocode_get_es_dosentry	; DISKSECTOR in DOSENTRY
  2898                                   assume es:DOSENTRYGROUP
  2899                                  DOSIMPLE:
  2900 00000CA7 BB[0000]                	MOV	BX,OFFSET DISKSECTOR	; access with es
  2901 00000CAA 9C                      	PUSHF
  2902 00000CAB 9A[0000][ssss]          	call DOSENTRY:transfer_orig13
  2903 00000CB0 5B07                    	RESTOREREG  <BX,ES>
  2904                                   assume es:nothing
  2905 00000CB2 E9(0000)                	jmp Leave13
  2906                                  
  2907                                  ;
  2908                                  ; FORMAT OPERATION.  COPY THE PARAMETER TABLE INTO MEMORY
  2909                                  ;
  2910                                  INTFORMAT:
  2911 00000CB5 0653                    	SAVEREG <ES,BX>
  2912 00000CB7 56571E                  	SAVEREG <SI,DI,DS>
  2913 00000CBA 06                      	PUSH	ES
  2914 00000CBB E8(0000)                	call biocode_get_es_dosentry	; DISKSECTOR in DOSENTRY
  2915                                   assume es:DOSENTRYGROUP
  2916 00000CBE 1F                      	POP	DS
  2917                                   assume ds:nothing
  2918 00000CBF 89DE                    	MOV	SI,BX
  2919 00000CC1 BF[0000]                	MOV	DI,OFFSET DISKSECTOR	; access with es
  2920 00000CC4 E87A08                  	CALL	MOVE
  2921 00000CC7 1F5F5E                  	RESTOREREG  <DS,DI,SI>
  2922                                   assume ds:nothing
  2923 00000CCA EBDB                    	JMP	DOSIMPLE
  2924                                  ;
  2925                                  ; INLINE CONTINUATION OF OPERATION
  2926                                  ;
  2927                                  INTDONE:
  2928                                   assume ds:nothing, es:nothing
  2929 00000CCC EA[0000][ssss]          	jmp DOSENTRY:transfer_orig13
  2930                                  
  2931                                  ;
  2932                                  ; We can't fit the request into the entire block.  Perform the operation on
  2933                                  ; the first block.
  2934                                  ;
  2935                                  ; DoBlock is modified to correctly handle multi-sector disk I/O. -J.K. 4/10/86
  2936                                  ; Old DoBlock had added the number of sectors I/Oed (Ah in Old DoBlock) after
  2937                                  ; the DoInt call to CL.  Observing only the lower 6 bits of CL(=max. 64) can
  2938                                  ; represent a starting sector, if AH was big, then CL would be clobbered.
  2939                                  ; By the way, we still are going to use CL for this purpose since Checkwrap
  2940                                  ; routine will use it as an input.  To prevent CL from being clobbered, a
  2941                                  ; safe number of sectors should be calculated like "63 - # of sectors/track".
  2942                                  ; DoBlock will handle the first block of requested sectors within the
  2943                                  ; boundary of this safe value. - J.K. 2/28/86
  2944                                  
  2945                                  DoBlock:
  2946                                   assume ds:nothing, es:nothing
  2947                                  ;Try to get the # of sectors/track from BDS via Rom drive number.
  2948                                  ;For any mini disks installed, here we have to pray that they have the
  2949                                  ;same # of sector/track as the main DOS partition disk drive.
  2950                                  
  2951                                  	Message ftestDisk,<"!!!DMA DoBlock!!!">
  2952                                  
  2953                                  olddx equ OLDDX	; NASM port equate
  2954 00000CD1 8B5608                  	mov	dx, word ptr [bp + olddx] ;set head #
  2955 00000CD4 57                      	push	di
  2956 00000CD5 1E                      	push	ds
  2957 00000CD6 50                      	push	ax			;AH - # of sectors before DMA boundary
  2958                                  					;AL - User requeseted # of sectors for I/O.
  2959                                  phys_drv equ PHYS_DRV	; NASM port label
  2960 00000CD7 E8(0000)                	call biocode_get_ds_dosbiodata
  2961                                   assume ds:DOSGROUP
  2962 00000CDA C606[0000]01            	mov	byte ptr [phys_drv],1
  2963 00000CDF 88D0                    	mov	al, dl
  2964 00000CE1 E825F7                  	call	SetDrive		;get BDS pointer for this DISK.
  2965                                   assume ds:UPB
  2966                                  		; fixme: what if not found ?
  2967                                  		; see next jc (questionable)
  2968 00000CE4 58                      	pop	ax
  2969 00000CE5 1E                      	push ds
  2970 00000CE6 E8(0000)                	call biocode_get_ds_dosbiodata
  2971                                   assume ds:DOSGROUP
  2972 00000CE9 C606[0000]00            	mov byte ptr [phys_drv],0
  2973 00000CEE 1F                      	pop ds
  2974                                   assume ds:UPB
  2975 00000CEF 7207                    	jc @F
  2976 00000CF1 F745230100              	test	word ptr [DI + Flags], fNon_Removable	;don't have to worry
  2977 00000CF6 7504                    	jnz	DoBlockHard		;about floppies. They are track by track operation.
  2978                                  @@:
  2979 00000CF8 88E0                    	mov	al, ah			;set al = ah for floppies
  2980 00000CFA EB0D                    	jmp	short DoBlockCont
  2981                                  DoBlockHard:
  2982 00000CFC 51                      	push	cx
  2983 00000CFD 8B4D13                  	mov	cx, [DI + SecLim]	;# of sectors/track
  2984 00000D00 B53F                    	mov	ch, 63
  2985 00000D02 28CD                    	sub	ch, cl
  2986 00000D04 88E8                    	mov	al, ch
  2987 00000D06 86E0                    	xchg	ah, al			;now ah - safe # of sectors
  2988                                  					;al - # of sectors before DMA boundary
  2989 00000D08 59                      	pop	cx
  2990                                  DoBlockCont:
  2991 00000D09 1F                      	pop	ds
  2992                                   assume ds:nothing
  2993 00000D0A 5F                      	pop	di
  2994                                  DoBlockContinue:
  2995                                  	Message ftestDisk,<"%%DMA DoBlock Loop%%">
  2996 00000D0B 38C4                    	cmp	ah, al			;if safe_# >= #_of_sectors_to_go_before DMA,
  2997 00000D0D 7305                    	jae	DoBlocklast		;then #_of_sectors_to_go as it is for DoInt.
  2998 00000D0F 50                      	push	ax			;save AH, AL
  2999 00000D10 88E0                    	mov	al, ah			;Otherwise, set al to ah to operate.
  3000 00000D12 EB03                    	jmp	short DoBlockDoInt	;DoInt will set AH to a proper function in [BP.Oldax]
  3001                                  DoBlocklast:
  3002 00000D14 88C4                    	mov	ah, al
  3003 00000D16 50                      	push	ax			;save AH
  3004                                  DoBlockDoInt:				;let AH = AL = # of sectors for this shot
  3005                                  DoInt equ DOINT	; NASM port label
  3006 00000D17 E83E08                  	CALL	DoInt
  3007 00000D1A 7303E98200              	JC BAD13			;something happened, bye!
  3008 00000D1F 58                      	pop	ax
  3009                                  oldax equ OLDAX	; NASM port equate
  3010 00000D20 286602                  	SUB	BYTE PTR [BP + oldax], AH ;decrement by the successful operation
  3011 00000D23 00E1                    	ADD	CL,AH			;advance sector number. Safety gauranteed.
  3012 00000D25 00E7                    	ADD	BH,AH			;advance DMA address
  3013 00000D27 00E7                    	ADD	BH,AH			;twice for 512 byte sectors.
  3014 00000D29 38C4                    	cmp	ah, al			;check the previous value
  3015                                  Buffer equ BUFFER	; NASM port label
  3016 00000D2B 7407                    	je	Buffer			;if #_of_sectors_to_go < safe_#, then we are done already.
  3017 00000D2D 28E0                    	sub	al, ah			;otherwise, #_sector_to_go = #_of_sector_to_go - safe_#
  3018                                  Check_Wrap equ CHECK_WRAP	; NASM port label
  3019 00000D2F E85407                  	call	Check_Wrap		;get new CX, DH for the next operation.
  3020 00000D32 EBD7                    	jmp	short DoBlockContinue	;handles next sectors left.
  3021                                  ;End of modificaion of DoBlock	- J.K. 2/28/86
  3022                                  ;The following is the original one.
  3023                                  ;	 PUSH	 AX
  3024                                  ;	 MOV	 AL,AH			 ; get max to operate on
  3025                                  ;	 MOV	 AH,BYTE PTR [BP.oldax+1]; get function
  3026                                  ;	 mov	 dh,byte ptr [BP.olddx+1]	 ; set up head number
  3027                                  ;	 CALL	 DoInt
  3028                                  ;	 JC	 Bad13			 ; something happened, bye!
  3029                                  ;	 POP	 AX
  3030                                  ;	 SUB	 BYTE PTR [BP.oldax],AH  ; decrement by the successful operation
  3031                                  ;	 ADD	 CL,AH			 ; advance sector number
  3032                                  ;	 ADD	 BH,AH			 ; advance DMA address
  3033                                  ;	 ADD	 BH,AH			 ; twice for 512 byte sectors.
  3034                                  
  3035                                  ;
  3036                                  ; THE NEXT REQUEST WILL WRAP THE 64K BOUNDARY.	IF WE ARE WRITING, THEN COPY
  3037                                  ; THE OFFENDING SECTOR INTO OUR SPACE.
  3038                                  ;
  3039                                  ;   ES:BX POINTS TO THE SECTOR
  3040                                  ;   CX,DX CONTAIN THE CORRECT TRACK/SECTOR/HEAD/DRIVE INFO
  3041                                  ;   [BP.OLDAX] HAS CORRECT FUNCTION CODE
  3042                                  ;
  3043                                  BUFFER:
  3044 00000D34 53                      	PUSH	BX
  3045 00000D35 8A6603                  	MOV	AH,BYTE PTR [BP + OLDAX+1]
  3046 00000D38 80FC03                  	CMP	AH,ROMWRITE
  3047 00000D3B 7526                    	JNZ	.DOREAD
  3048                                  ;
  3049                                  ; COPY THE OFFENDING SECTOR INTO LOCAL BUFFER
  3050                                  ;
  3051 00000D3D 1E065657                	SAVEREG <DS,ES,SI,DI>
  3052 00000D41 06                      	PUSH	ES
  3053 00000D42 1F                      	POP	DS			; ds => user buffer
  3054                                   assume ds:nothing
  3055 00000D43 E8(0000)                	call biocode_get_es_dosentry	; DISKSECTOR in DOSENTRY ; es => DOSENTRY
  3056                                   assume es:DOSENTRYGROUP
  3057 00000D46 BF[0000]                	MOV	DI,OFFSET DISKSECTOR	; WHERE TO MOVE ; access with es
  3058 00000D49 57                      	PUSH	DI			; SAVE IT
  3059 00000D4A 89DE                    	MOV	SI,BX			; SOURCE
  3060 00000D4C E8F207                  	CALL	MOVE
  3061 00000D4F 5B                      	POP	BX			; NEW TRANSFER ADDRESS
  3062 00000D50 5F5E                    	RESTOREREG  <DI,SI>
  3063 00000D52 B001                    	MOV	AL,1
  3064                                  ; SEE IF WE ARE WRAPPING AROUND A TRACK OR HEAD
  3065 00000D54 8A5608                  	MOV	DL,BYTE PTR [BP + OLDDX]	; GET DRIVE NUMBER
  3066 00000D57 E82C07                  	CALL	CHECK_WRAP		; SETS UP REGISTERS IF WRAP-AROUND
  3067                                  ;
  3068                                  ;   AH IS FUNCTION
  3069                                  ;   AL IS 1 FOR SINGLE SECTOR TRANSFER
  3070                                  ;   ES:BX IS LOCAL TRANSFER ADDRES
  3071                                  ;   CX IS TRACK/SECTOR NUMBER
  3072                                  ;   DX IS HEAD/DRIVE NUMBER
  3073                                  ;   SI,DI UNCHANGED
  3074                                  ;
  3075 00000D5A E8FB07                  	CALL	DOINT
  3076 00000D5D 071F                    	RESTOREREG  <ES,DS>
  3077                                   assume es:nothing, ds:nothing
  3078 00000D5F 7240                    	JC	BAD13			; GO CLEAN UP
  3079 00000D61 EB28                    	JMP	SHORT DOTAIL
  3080                                  ;
  3081                                  ; READING A SECTOR.  DO INT FIRST, THEN MOVE THINGS AROUND
  3082                                  ;
  3083                                  .DOREAD:
  3084                                   assume es:nothing
  3085 00000D63 0653                    	SAVEREG <ES,BX>
  3086 00000D65 E8(0000)                	call biocode_get_es_dosentry	; DISKSECTOR in DOSENTRY
  3087                                   assume es:DOSENTRYGROUP
  3088 00000D68 BB[0000]                	MOV	BX,OFFSET DISKSECTOR	; access with es
  3089 00000D6B B001                    	MOV	AL,1
  3090                                  ; SEE IF OUR REQUEST WILL WRAP A TRACK OR HEAD BOUNDARY
  3091 00000D6D 8A5608                  	MOV	DL,BYTE PTR [BP + OLDDX]	; GET DRIVE NUMBER
  3092 00000D70 E81307                  	CALL	CHECK_WRAP		; SETS UP REGISTERS IF WRAP-AROUND
  3093                                  ;
  3094                                  ;   AH = FUNCTION
  3095                                  ;   AL = 1 FOR SINGLE SECTOR
  3096                                  ;   ES:BX POINTS TO LOCAL BUFFER
  3097                                  ;   CX, DX ARE TRACK/SECTOR, HEAD/DRIVE
  3098                                  ;
  3099 00000D73 E8E207                  	CALL	DOINT
  3100 00000D76 5B07                    	RESTOREREG  <BX,ES>
  3101                                   assume es:nothing
  3102 00000D78 7227                    	JC	BAD13			; ERROR => CLEAN UP
  3103 00000D7A 1E5657                  	SAVEREG <DS,SI,DI>
  3104 00000D7D E8(0000)                	call biocode_get_ds_dosentry	; DISKSECTOR in DOSENTRY !
  3105                                   assume ds:DOSENTRYGROUP
  3106 00000D80 89DF                    	MOV	DI,BX
  3107 00000D82 BE[0000]                	MOV	SI,OFFSET DISKSECTOR	; access with ds
  3108 00000D85 E8B907                  	CALL	MOVE
  3109 00000D88 5F5E1F                  	RESTOREREG  <DI,SI,DS>
  3110                                   assume ds:nothing
  3111                                  ;
  3112                                  ; NOTE THE FACT THAT WE'VE DONE 1 MORE SECTOR
  3113                                  ;
  3114                                  DOTAIL:
  3115 00000D8B 5B                      	POP	BX			; RETRIEVE NEW DMA AREA
  3116 00000D8C 80C702                  	ADD	BH,2			; ADVANCE OVER SECTOR
  3117 00000D8F 41                      	INC	CX
  3118 00000D90 8A4602                  	MOV	AL,BYTE PTR [BP + OLDAX]
  3119 00000D93 F8                      	CLC
  3120 00000D94 FEC8                    	DEC	AL
  3121 00000D96 7409                    	JZ	BAD13			; NO MORE I/O
  3122                                  ; SEE IF WE WRAP AROUND A TRACK OR HEAD BOUNDARY WITH STARTING SECTOR
  3123                                  ; WE ALREADY HAVE THE CORRECT HEAD NUMBER TO PASS TO CHECK_WRAP
  3124 00000D98 8A5608                  	MOV	DL,BYTE PTR [BP + OLDDX]	; GET DRIVE NUMBER
  3125 00000D9B E8E806                  	CALL	CHECK_WRAP		; SETS UP REGISTERS IF WRAP-AROUND
  3126 00000D9E E8B707                  	CALL	DOINT
  3127                                  ;
  3128                                  ; WE ARE DONE.	AX HAS THE FINAL CODE; WE THROW AWAY WHAT WE GOT BEFORE
  3129                                  ;
  3130                                  BAD13:
  3131 00000DA1 89EC                    	MOV	SP,BP
  3132 00000DA3 5D5B5B595A              	RESTOREREG  <BP,BX,BX,CX,DX>
  3133 00000DA8 E9(0000)                	jmp Leave13
  3134                                  BLOCK13 ENDP
  3135                                  ;	PAGE
  3136                                  ;=== Push trace listing source: msioctl.nas
  3137                                  	%include "msioctl.nas" ; NASM included file
     1                              <1> 	%warning out: MSIOCTL.SIL...
     1          ******************  <1>  warning: out: MSIOCTL.SIL... [-w+user]
     2                              <1> 	%include "ioctl.mac"
     1                              <2> 
     2                              <2> %warning out: IOCTL.INC...
     2          ******************  <2>  warning: out: IOCTL.INC... [-w+user]
     3                              <2> ; THESE ARE ALL THE IMPORTANT STRUCTURES AND EQUATES FOR IOCTL
     4                              <2> ;==============================================================================
     5                              <2> ;REVISION HISTORY:
     6                              <2> ;AN000 - New for DOS Version 4.00 - J.K.
     7                              <2> ;AC000 - Changed for DOS Version 4.00 - J.K.
     8                              <2> ;AN00x - PTM number for DOS Version 4.00 - J.K.
     9                              <2> ;==============================================================================
    10                              <2> ;AN001; D241 Provide support of Multi-track Format/Verify	   9/23/87 J.K.
    11                              <2> ;AN002; P1535 Unformatted hard file problem			  10/15/87 J.K.
    12                              <2> ;AN003; D490 IOCTL subfunction 63h,43h,64h,44h conflicts with OS2  2/26/88 J.K.
    13                              <2> ;==============================================================================
    14                              <2> 
    15                              <2> ;*** J.K.
    16                              <2> ;General Guide -
    17                              <2> ;Category Code:
    18                              <2> ; 0... .... DOS Defined
    19                              <2> ; 1... .... User defined
    20                              <2> ; .xxx xxxx Code
    21                              <2> 
    22                              <2> ;Function Code:
    23                              <2> ; 0... .... Return error if unsupported
    24                              <2> ; 1... .... Ignore if unsupported
    25                              <2> ; .0.. .... Intercepted by DOS
    26                              <2> ; .1.. .... Passed to driver
    27                              <2> ; ..0. .... Sends data/commands to device
    28                              <2> ; ..1. .... Quries data/info from device
    29                              <2> ; ...x .... Subfunction
    30                              <2> ;
    31                              <2> ; Note that "Sends/queries" data bit is intended only to regularize the
    32                              <2> ; function set.  It plays no critical role; some functions may contain both
    33                              <2> ; command and query elements. The convention is that such commands are
    34                              <2> ; defined as "sends data".
    35                              <2> 
    36                              <2> ;*****************************;*
    37                              <2> ; BLOCK DRIVERS 	      ;*
    38                              <2> ;*****************************;*
    39                              <2> 
    40                              <2> ; IOCTL SUB-FUNCTIONS
    41                              <2> IOCTL_GET_DEVICE_INFO	EQU	0
    42                              <2> IOCTL_SET_DEVICE_INFO	EQU	1
    43                              <2> IOCTL_READ_HANDLE	EQU	2
    44                              <2> IOCTL_WRITE_HANDLE	EQU	3
    45                              <2> IOCTL_READ_DRIVE	EQU	4
    46                              <2> IOCTL_WRITE_DRIVE	EQU	5
    47                              <2> IOCTL_GET_INPUT_STATUS	EQU	6
    48                              <2> IOCTL_GET_OUTPUT_STATUS EQU	7
    49                              <2> IOCTL_CHANGEABLE?	EQU	8
    50                              <2> IOCTL_DeviceLocOrRem?	EQU	9
    51                              <2> IOCTL_HandleLocOrRem?	EQU	0Ah   ;10
    52                              <2> IOCTL_SHARING_RETRY	EQU	0Bh   ;11
    53                              <2> GENERIC_IOCTL_HANDLE	EQU	0Ch   ;12
    54                              <2> GENERIC_IOCTL		EQU	0Dh   ;13
    55                              <2> 
    56                              <2> ; GENERIC IOCTL CATEGORY CODES
    57                              <2> IOC_OTHER		EQU	0	; Other device control J.K. 4/29/86
    58                              <2> IOC_SE			EQU	1	; SERIAL DEVICE CONTROL
    59                              <2> IOC_TC			EQU	2	; TERMINAL CONTROL
    60                              <2> IOC_SC			EQU	3	; SCREEN CONTROL
    61                              <2> IOC_KC			EQU	4	; KEYBOARD CONTROL
    62                              <2> IOC_PC			EQU	5	; PRINTER CONTROL
    63                              <2> IOC_DC			EQU	8	; DISK CONTROL (SAME AS RAWIO)
    64                              <2> 
    65                              <2> ; GENERIC IOCTL SUB-FUNCTIONS
    66                              <2> RAWIO			EQU	8
    67                              <2> 
    68                              <2> ; RAWIO SUB-FUNCTIONS
    69                              <2> GET_DEVICE_PARAMETERS	EQU	60H
    70                              <2> SET_DEVICE_PARAMETERS	EQU	40H
    71                              <2> READ_TRACK		EQU	61H
    72                              <2> WRITE_TRACK		EQU	41H
    73                              <2> VERIFY_TRACK		EQU	62H
    74                              <2> FORMAT_TRACK		EQU	42H
    75                              <2> GET_MEDIA_ID		EQU	66h		;AN000;AN003;changed from 63h
    76                              <2> SET_MEDIA_ID		EQU	46h		;AN000;AN003;changed from 43h
    77                              <2> GET_ACCESS_FLAG 	EQU	67h		;AN002;AN003;Unpublished function.Changed from 64h
    78                              <2> SET_ACCESS_FLAG 	EQU	47h		;AN002;AN003;Unpublished function.Changed from 44h
    79                              <2> 
    80                              <2> ; SPECIAL FUNCTION FOR GET DEVICE PARAMETERS
    81                              <2> BUILD_DEVICE_BPB	EQU	000000001B
    82                              <2> 
    83                              <2> ; SPECIAL FUNCTIONS FOR SET DEVICE PARAMETERS
    84                              <2> INSTALL_FAKE_BPB	EQU	000000001B
    85                              <2> ONLY_SET_TRACKLAYOUT	EQU	000000010B
    86                              <2> TRACKLAYOUT_IS_GOOD	EQU	000000100B
    87                              <2> 
    88                              <2> ; SPECIAL FUNCTION FOR FORMAT TRACK
    89                              <2> STATUS_FOR_FORMAT		EQU	000000001B
    90                              <2> DO_FAST_FORMAT			equ	000000010B	;AN001;
    91                              <2> ; CODES RETURNED FROM FORMAT STATUS CALL
    92                              <2> FORMAT_NO_ROM_SUPPORT		EQU	000000001B
    93                              <2> FORMAT_COMB_NOT_SUPPORTED	EQU	000000010B
    94                              <2> 
    95                              <2> ; DEVICETYPE VALUES
    96                              <2> MAX_SECTORS_IN_TRACK	EQU	63	; MAXIMUM SECTORS ON A DISK.(Was 40 in DOS 3.2)
    97                              <2> DEV_5INCH		EQU	0
    98                              <2> DEV_5INCH96TPI		EQU	1
    99                              <2> DEV_3INCH720KB		EQU	2
   100                              <2> DEV_8INCHSS		EQU	3
   101                              <2> DEV_8INCHDS		EQU	4
   102                              <2> DEV_HARDDISK		EQU	5
   103                              <2> DEV_OTHER		EQU	7
   104                              <2> 
   105                              <2> MAX_DEV_TYPE		EQU	7	; MAXIMUM DEVICE TYPE THAT WE
   106                              <2> 					; CURRENTLY SUPPORT.
   107                              <2> 
   108                              <2> %include "bpb.mac"
     1                              <3> 	%warning out: BPB.INC...
     1          ******************  <3>  warning: out: BPB.INC... [-w+user]
     2                              <3> ;	SCCSID = @(#)BPB.ASM	1.1 85/04/29
     3                              <3> ;----+----+----+----+----+----+----+----+----+----+----+----+----+----+----;
     4                              <3> ;	     C	A  V  E  A  T	  P  R	O  G  R  A  M  M  E  R		   ;
     5                              <3> ;									   ;
     6                              <3> 
     7                              <3> ; BIOS PARAMETER BLOCK DEFINITION
     8                              <3> ; THIS STRUCTURE IS USED TO BUILD A FULL DPB
     9                              <3> 
    10                              <3> BPBLOCK STRUC
    11 00000000 ????                <3> BPSECSZ DW	?			; SIZE IN BYTES OF PHYSICAL SECTOR
    12 00000002 ??                  <3> BPCLUS	DB	?			; SECTORS/ALLOC UNIT
    13 00000003 ????                <3> BPRES	DW	?			; NUMBER OF RESERVED SECTORS
    14 00000005 ??                  <3> BPFTCNT DB	?			; NUMBER OF FATS
    15 00000006 ????                <3> BPDRCNT DW	?			; NUMBER OF DIRECTORY ENTRIES
    16 00000008 ????                <3> BPSCCNT DW	?			; TOTAL NUMBER OF SECTORS
    17 0000000A ??                  <3> BPMEDIA DB	?			; MEDIA DESCRIPTOR BYTE
    18 0000000B ????                <3> BPFTSEC DW	?			; NUMBER OF SECTORS TAKEN UP BY ONE FAT
    19                              <3> BPBLOCK ENDS
    20                              <3> 
    21                              <3> A_BPB			STRUC
    22 00000000 ????                <3> BPB_BYTESPERSECTOR	DW	?
    23 00000002 ??                  <3> BPB_SECTORSPERCLUSTER	DB	?
    24 00000003 ????                <3> BPB_RESERVEDSECTORS	DW	?
    25 00000005 ??                  <3> BPB_NUMBEROFFATS	DB	?
    26 00000006 ????                <3> BPB_ROOTENTRIES 	DW	?
    27 00000008 ????                <3> BPB_TOTALSECTORS	DW	?
    28 0000000A ??                  <3> BPB_MEDIADESCRIPTOR	DB	?
    29 0000000B ????                <3> BPB_SECTORSPERFAT	DW	?
    30 0000000D ????                <3> BPB_SECTORSPERTRACK	DW	?
    31 0000000F ????                <3> BPB_HEADS		DW	?
    32 00000011 ????                <3> BPB_HIDDENSECTORS	DW	?
    33 00000013 ????                <3> 			DW	?
    34 00000015 ????                <3> BPB_BIGTOTALSECTORS	DW	?
    35 00000017 ????                <3> 			DW	?
    36 00000019 ????????????        <3> 			DB	6 DUP(?)
    37                              <3> A_BPB			ENDS
    38                              <3> ;									   ;
    39                              <3> ;	     C	A  V  E  A  T	  P  R	O  G  R  A  M  M  E  R		   ;
    40                              <3> ;----+----+----+----+----+----+----+----+----+----+----+----+----+----+----;
   109                              <2> 
   110                              <2> A_SECTORTABLE	    STRUC
   111 00000000 ????                <2> ST_SECTORNUMBER 	DW	?
   112 00000002 ????                <2> ST_SECTORSIZE		DW	?
   113                              <2> A_SECTORTABLE	    ENDS
   114                              <2> 
   115                              <2> A_DEVICEPARAMETERS  STRUC
   116 00000000 ??                  <2> DP_SPECIALFUNCTIONS	DB	?
   117 00000001 ??                  <2> DP_DEVICETYPE		DB	?
   118 00000002 ????                <2> DP_DEVICEATTRIBUTES	DW	?
   119 00000004 ????                <2> DP_CYLINDERS		DW	?
   120 00000006 ??                  <2> DP_MEDIATYPE		DB	?
   121 00000007 <res 1Fh>           <2> DP_BPB			DB	A_BPB_struc_size DUP (?)
   122 00000026 ????                <2> DP_TRACKTABLEENTRIES	DW	?
   123 00000028 <res FCh>           <2> DP_SECTORTABLE		DB MAX_SECTORS_IN_TRACK * A_SECTORTABLE_struc_size DUP (?)
   124                              <2> A_DEVICEPARAMETERS  ENDS
   125                              <2> 
   126                              <2> A_TRACKREADWRITEPACKET STRUC
   127 00000000 ??                  <2> TRWP_SPECIALFUNCTIONS	DB	?
   128 00000001 ????                <2> TRWP_HEAD		DW	?
   129 00000003 ????                <2> TRWP_CYLINDER		DW	?
   130 00000005 ????                <2> TRWP_FIRSTSECTOR	DW	?
   131 00000007 ????                <2> TRWP_SECTORSTOREADWRITE DW	?
   132 00000009 ????????            <2> TRWP_TRANSFERADDRESS	DD	?
   133                              <2> A_TRACKREADWRITEPACKET ENDS
   134                              <2> 
   135                              <2> ;AN001; - FP_TRACKCOUNT is only meaningful when FP_SPECIALFUNCTIONS bit 1 = 1.
   136                              <2> A_FORMATPACKET	    STRUC
   137 00000000 ??                  <2> FP_SPECIALFUNCTIONS	DB	?
   138 00000001 ????                <2> FP_HEAD 		DW	?
   139 00000003 ????                <2> FP_CYLINDER		DW	?
   140 00000005 ????                <2> FP_TRACKCOUNT		DW	? ;1
   141                              <2> A_FORMATPACKET	    ENDS
   142                              <2> 
   143                              <2> A_VERIFYPACKET	    STRUC
   144 00000000 ??                  <2> VP_SPECIALFUNCTIONS	DB	?
   145 00000001 ????                <2> VP_HEAD 		DW	?
   146 00000003 ????                <2> VP_CYLINDER		DW	?
   147                              <2> A_VERIFYPACKET	    ENDS
   148                              <2> 
   149                              <2> A_MEDIA_ID_INFO     STRUC
   150 00000000 ????                <2> MI_LEVEL		DW	? ;0		;J.K. 87 Info. level
   151 00000002 ????????            <2> MI_SERIAL		DD	?		;J.K. 87 Serial #
   152 00000006 <res Bh>            <2> MI_LABEL		DB     11 DUP (?) ;(' ')     ;J.K. 87 volume label
   153 00000011 ????????????????    <2> MI_SYSTEM		DB	8 DUP (?) ;(' ')     ;J.K. 87 File system type
   154                              <2> A_MEDIA_ID_INFO     ENDS
   155                              <2> 
   156                              <2> A_DISKACCESS_CONTROL	STRUC			;AN002; Unpublished function. Only for Hard file.
   157 00000000 ??                  <2> DAC_SPECIALFUNCTIONS	DB	? ;0		;AN002; Always 0
   158 00000001 ??                  <2> DAC_ACCESS_FLAG 	DB	? ;0		;AN002; Non Zero - allow disk I/O to unformatted hard file
   159                              <2> A_DISKACCESS_CONTROL	ENDS			;AN002; 0 - Disallow disk I/O to unformatted hard file
   160                              <2> 
   161                              <2> ;********************************;*
   162                              <2> ; CHARACTER DEVICES (PRINTERS)	 ;*
   163                              <2> ;********************************;*
   164                              <2> 
   165                              <2> ;RAWIO SUB-FUNCTIONS
   166                              <2> GET_RETRY_COUNT 	EQU	65H
   167                              <2> SET_RETRY_COUNT 	EQU	45H
   168                              <2> 
   169                              <2> A_RETRYCOUNT	    STRUC
   170 00000000 ????                <2> RC_COUNT		DW	?
   171                              <2> A_RETRYCOUNT	    ENDS
   172                              <2> 
   173                              <2> ;********************************;*		;J.K. 4/29/86
   174                              <2> ; CHARACTER DEVICES (SCREEN)	 ;*
   175                              <2> ;********************************;*		;J.K. 4/29/86
   176                              <2> ;
   177                              <2> ;SC_MODE_INFO	 struc
   178                              <2> ;SC_INFO_LENGTH 	 DW	 9
   179                              <2> ;SC_MODE		 DB	 0
   180                              <2> ;SC_COLORS		 DW	 0
   181                              <2> ;SC_WIDTH		 DW	 0
   182                              <2> ;SC_LENGTH		 DW	 0
   183                              <2> ;SC_MODE_INFO	 ends
   184                              <2> ;
   185                              <2> ;SC_INFO_PACKET_LENGTH	 EQU	 9		 ;LENGTH OF THE INFO PACKET.
   186                              <2> 
   187                              <2> ;SUBFUNCTIONS FOR CON$GENIOCTL
   188                              <2> ;GET_SC_MODE		 EQU	 60h
   189                              <2> ;SET_SC_MODE		 EQU	 40h
   190                              <2> ;The following subfunctions are reserved for installable CODE PAGE switch
   191                              <2> ;console devices. - J.K. 4/29/86
   192                              <2> ;Get_active_codepage	 equ	 6Ah
   193                              <2> ;Invoke_active_codepage  equ	 4Ah
   194                              <2> ;Start_designate_codepage equ	 4Ch
   195                              <2> ;End_designate_codepage  equ	 4Dh
   196                              <2> ;Get_list_of_designated_codepage equ 6Bh
   197                              <2> ;J.K. 4/29/86 *** End of Con$genioctl equates & structures
     3                              <1> ;	$SALUT $ioctl$
     4                              <1> 
     5                              <1> ;==============================================================================
     6                              <1> ;REVISION HISTORY:
     7                              <1> ;AN000 - New for DOS Version 4.00 - J.K.
     8                              <1> ;AC000 - Changed for DOS Version 4.00 - J.K.
     9                              <1> ;AN00x - PTM number for DOS Version 4.00 - J.K.
    10                              <1> ;==============================================================================
    11                              <1> ;AN001 - P58 Diskcopy format fails when error occurs during format op.6/26/87 J.K.
    12                              <1> ;AN002; - d24  MultiTrack= command added.			   6/29/87 J.K.
    13                              <1> ;AN003; - p155 Format intermittant failre due to haed settle time  8/18/87 J.K.
    14                              <1> ;AN004; D113 Disable I/O access to unformatted media		    9/03/87 J.K.
    15                              <1> ;AN005; P985 Allow I/O access to unformtted media		    9/14/87 J.K.
    16                              <1> ;AN006; D241 Provide support of Multi-track Format/Verify	    9/23/87 J.K.
    17                              <1> ;AN007; P1535 Unformatted hard file problem			   10/15/87 J.K.
    18                              <1> ;AN008; P2590 Change the recommended BPB info. after AFS format    11/20/87 J.K.
    19                              <1> ;AN009; P2828 Do not retry for multi-track format request	   12/08/87 J.K.
    20                              <1> ;AN010; P2781 Changeline error behavior incompatibile with DOS 3.3. 1/06/88 J.K.
    21                              <1> ;AN011; P3178 Set Media ID should update media info in BDS table.   1/21/88 J.K.
    22                              <1> ;AN012; D490 IOCTL subfunction 63h,43h,64h,44h conflicts with OS2   2/26/88 J.K.
    23                              <1> ;==============================================================================
    24                              <1> 
    25                              <1> ;J.K. 10/15/87
    26                              <1> ;NOTE: GetAccessFlag/SetAccessFlag is unpublished function.
    27                              <1> ;      This function is intended to give the user to control the
    28                              <1> ;      BDS table FLAGS of UNFORMATTED_MEDIA bit.
    29                              <1> ;      GetAccessFlag will show the status -
    30                              <1> ;	 A_DISKACCESS_CONTROL.DAC_ACCESS_FLAG = 0 DISK I/O not allowed
    31                              <1> ;						1 DISK I/O allowed
    32                              <1> ;      SetAccessFlag will Set/Reset the UNFORMATTED_MEDIA bit in FLAGS -
    33                              <1> ;	 A_DISKACCESS_CONTROL.DAC_ACCESS_FLAG = 0 Allow disk I/O
    34                              <1> ;						1 Disallow disk I/O
    35                              <1> ;------------------------------------------------------------------------------
    36                              <1> 
    37                              <1> section BIOCODE
    38                              <1> 
    39                              <1> 
    40 00000DAB 00                  <1> 	align 2, db 0
    41 00000DAC 00                  <1> 	db 0
    42                              <1> ; GENERIC IOCTL DISPATCH TABLES
    43                              <1> ;
    44 00000DAD 07                  <1> IOREADJUMPTABLE DB	7			;AN012;maximum number (0 based)
    45 00000DAE [270E]              <1> 		DW	OFFSET GETDEVICEPARAMETERS		;60h
    46 00000DB0 [F210]              <1> 		DW	OFFSET READTRACK			;61h
    47 00000DB2 [9110]              <1> 		DW	OFFSET VERIFYTRACK			;62h
    48 00000DB4 [210E]              <1> 		dw	Cmd_Err_Proc				;AN012;Overlapped with OS2 subfunction
    49 00000DB6 [210E]              <1> 		dw	Cmd_Err_Proc				;AN012;
    50 00000DB8 [210E]              <1> 		dw	Cmd_Err_Proc				;AN012;
    51 00000DBA [7913]              <1> 		dw	GetMediaID				;AN000;AN012;66h
    52 00000DBC [5E14]              <1> 		dw	GetAccessFlag				;AN007;AN012;67h Unpublished function
    53                              <1> 
    54 00000DBE 00                  <1> 	db 0
    55 00000DBF 07                  <1> IOWRITEJUMPTABLE DB	7					;AN012;
    56 00000DC0 [630E]              <1> 		DW	OFFSET SETDEVICEPARAMETERS		;40h
    57 00000DC2 [FE10]              <1> 		DW	OFFSET WRITETRACK			;41h
    58 00000DC4 [D70F]              <1> 		DW	OFFSET FORMATTRACK			;42h
    59 00000DC6 [210E]              <1> 		dw	Cmd_Err_Proc				;AN012;
    60 00000DC8 [210E]              <1> 		dw	Cmd_Err_Proc				;AN012;
    61 00000DCA [210E]              <1> 		dw	Cmd_Err_Proc				;AN012;
    62 00000DCC [B713]              <1> 		dw	SetMediaID				;AN000;AN012;46h
    63 00000DCE [7214]              <1> 		dw	SetAccessFlag				;AN007;AN012;47h Unpublished function
    64                              <1> 
    65                              <1> 
    66                              <1> section DOSBIODATA
    67                              <1> 
    68                              <1> ;
    69                              <1> ; TRACKTABLE CONTAINS A 4-TUPLES (C,H,R,N) FOR EACH SECTOR IN A TRACK
    70                              <1> ; C = CYLINDER NUMBER, H = HEAD NUMBER, R = SECTOR ID, N = BYTES PER SECTOR
    71                              <1> ;	N	BYTES PER SECTOR
    72                              <1> ;      ---	----------------
    73                              <1> ;	0	      128
    74                              <1> ;	1	      256
    75                              <1> ;	2	      512
    76                              <1> ;	3	     1024
    77                              <1> ;
    78                              <1> MAX_SECTORS_CURR_SUP	EQU	63	; CURRENT MAXIMUM SEC/TRK THAT
    79                              <1> 					; WE SUPPORT (Was 40 in DOS 3.2)
    80                              <1> 
    81                              <1> 	align 2, db 0
    82 00000000 2400                <1> SECTORSPERTRACK DW	36
    83 00000002 00000102            <1> TRACKTABLE	DB	0,0,1,2
    84 00000006 00000202            <1> 		DB	0,0,2,2
    85 0000000A 00000302            <1> 		DB	0,0,3,2
    86 0000000E 00000402            <1> 		DB	0,0,4,2
    87 00000012 00000502            <1> 		DB	0,0,5,2
    88 00000016 00000602            <1> 		DB	0,0,6,2
    89 0000001A 00000702            <1> 		DB	0,0,7,2
    90 0000001E 00000802            <1> 		DB	0,0,8,2
    91 00000022 00000902            <1> 		DB	0,0,9,2
    92 00000026 00000A02            <1> 		DB	0,0,10,2
    93 0000002A 00000B02            <1> 		DB	0,0,11,2
    94 0000002E 00000C02            <1> 		DB	0,0,12,2
    95 00000032 00000D02            <1> 		DB	0,0,13,2
    96 00000036 00000E02            <1> 		DB	0,0,14,2
    97 0000003A 00000F02            <1> 		DB	0,0,15,2
    98 0000003E 00001002            <1> 		db	0,0,16,2
    99 00000042 00001102            <1> 		db	0,0,17,2
   100 00000046 00001202            <1> 		db	0,0,18,2
   101 0000004A 00001302            <1> 		db	0,0,19,2
   102 0000004E 00001402            <1> 		db	0,0,20,2
   103 00000052 00001502            <1> 		db	0,0,21,2
   104 00000056 00001602            <1> 		db	0,0,22,2
   105 0000005A 00001702            <1> 		db	0,0,23,2
   106 0000005E 00001802            <1> 		db	0,0,24,2
   107 00000062 00001902            <1> 		db	0,0,25,2
   108 00000066 00001A02            <1> 		db	0,0,26,2
   109 0000006A 00001B02            <1> 		db	0,0,27,2
   110 0000006E 00001C02            <1> 		db	0,0,28,2
   111 00000072 00001D02            <1> 		db	0,0,29,2
   112 00000076 00001E02            <1> 		db	0,0,30,2
   113 0000007A 00001F02            <1> 		db	0,0,31,2
   114 0000007E 00002002            <1> 		db	0,0,32,2
   115 00000082 00002102            <1> 		db	0,0,33,2
   116 00000086 00002202            <1> 		db	0,0,34,2
   117 0000008A 00002302            <1> 		db	0,0,35,2
   118 0000008E 00002402            <1> 		db	0,0,36,2
   119 00000092 000000000000000000- <1> 		DB	4*MAX_SECTORS_CURR_SUP - ($ - TRACKTABLE) DUP (0)
   119 0000009B 000000000000000000- <1>
   119 000000A4 000000000000000000- <1>
   119 000000AD 000000000000000000- <1>
   119 000000B6 000000000000000000- <1>
   119 000000BF 000000000000000000- <1>
   119 000000C8 000000000000000000- <1>
   119 000000D1 000000000000000000- <1>
   119 000000DA 000000000000000000- <1>
   119 000000E3 000000000000000000- <1>
   119 000000EC 000000000000000000- <1>
   119 000000F5 000000000000000000  <1>
   120                              <1> 
   121                              <1> 
   122                              <1> ; THIS IS A REAL UGLY PLACE TO PUT THIS
   123                              <1> ; IT SHOULD REALLY GO IN THE BDS
   124 000000FE 00                  <1> MEDIATYPE	DB	0
   125                              <1> 
   126 000000FF 00                  <1> MEDIA_SET_FOR_FORMAT	DB	0	; 1 IF WE HAVE DONE AN INT 13 SET MEDIA
   127                              <1> 					; TYPE FOR FORMAT CALL
   128 00000100 00                  <1> Had_Format_Error	db	0	; 1 if the previous format operation
   129                              <1> 					; failed. - J.K. 7/8/86
   130                              <1> Dsk_time_out_Err	equ	80h	; Time out error (No media present).
   131                              <1> Dsk_change_line_Err	equ	6h	; Change line error
   132                              <1> Dsk_illegal_combination equ	0Ch	; Return code of ah=18h function.
   133                              <1> 
   134 00000101 00                  <1> 	align 2, db 0
   135                              <1> ; TEMP DISK BASE TABLE. IT HOLDS THE THE CURRENT DPT WHICH IS THEN REPLACED BY
   136                              <1> ; THE ONE PASSED BY "NEW ROMS" BEFORE WE PERFORM A FORMAT OPERATION. THE OLD
   137                              <1> ; DPT IS RESTORED IN RESTOREOLDDPT. THE FIRST ENTRY (DISK_SPECIFY_1) IS -1 IF
   138                              <1> ; THIS TABLE DOES NOT CONTAIN THE PREVIOUSLY SAVED DPT.
   139 00000102 FFFFFFFF            <1> TEMPDPT 	DD	-1
   140                              <1> 
   141                              <1> 
   142                              <1> section BIOCODE
   143                              <1> 
   144                              <1>  extern DSK$UNKNOWN
   145                              <1> 
   146                              <1> ;
   147                              <1> ; GENERIC$IOCTL:
   148                              <1> ;    PERFORM GENERIC IOCTL REQUEST
   149                              <1> ;    INPUT:
   150                              <1> ;	AL	- UNIT NUMBER
   151                              <1> ;    OUTPUT:
   152                              <1> ;	IF CARRY SET THEN AL CONTAINS ERROR CODE
   153                              <1> ;
   154                              <1>  global msbio_check_gen_ioctl
   155                              <1> msbio_check_gen_ioctl:
   156                              <1> 	PUBLIC GENERIC$IOCTL
   157                              <1> GENERIC$IOCTL:
   158                              <1>  assume ds:DOSGROUP, es:nothing, ss:nothing
   159                              <1> 	MESSAGE FTESTDISK,<"GENERIC IOCTL",CR,LF>
   160 00000DD0 E8(0000)            <1> 	call biocode_get_es_dosentry	; PTRSAV in DOSENTRY
   161                              <1>  assume es:DOSENTRYGROUP
   162 00000DD3 26C41E[0000]        <1> 	LES	BX,[es:PTRSAV]		; ES:BX POINTS TO REQUEST HEADER.
   163                              <1>  assume es:nothing
   164 00000DD8 E82EF6              <1> 	CALL	SETDRIVE		; DS:DI POINTS TO BDS FOR DRIVE.
   165                              <1>  assume ds:UPB
   166 00000DDB 7303E9(0000)        <1> 	jc DSK$UNKNOWN
   167                              <1> ;
   168                              <1> ; AT THIS POINT:
   169                              <1> ;    ES:BX - POINTS TO THE REQUEST HEADER
   170                              <1> ;    DS:DI POINTS TO THE BDS FOR THE DRIVE
   171                              <1> ;
   172 00000DE0 26807F0D08          <1> 	CMP	byte [ES:BX + MAJORFUNCTION], RAWIO
   173 00000DE5 7537                <1> 	JNE	IOCTL_FUNC_ERR
   174 00000DE7 268A470E            <1> 	MOV	AL, [ES:BX + MINORFUNCTION]
   175 00000DEB BE[AD0D]            <1> 	MOV	SI, OFFSET IOREADJUMPTABLE	; access with cs
   176 00000DEE A820                <1> 	TEST	AL, GEN_IOCTL_FN_TST			; TEST OF REQ. FUNCTION
   177 00000DF0 7503                <1> 	JNZ	NOTGENERICIOCTLWRITE			;   FUNCTION IS A READ.
   178 00000DF2 BE[BF0D]            <1> 	MOV	SI, OFFSET IOWRITEJUMPTABLE	; access with cs
   179                              <1> NOTGENERICIOCTLWRITE:
   180 00000DF5 24DF                <1> 	and al, ~ GEN_IOCTL_FN_TST		; 6xh to 4xh
   181 00000DF7 2C40                <1> 	sub al, 40h				; get 0-based
   182 00000DF9 2E3A04              <1> 	CMP	AL, [CS:SI]
   183 00000DFC 7720                <1> 	JA	IOCTL_FUNC_ERR
   184 00000DFE 98                  <1> 	CBW
   185 00000DFF D1E0                <1> 	SHL	AX, 1
   186 00000E01 46                  <1> 	INC	SI
   187 00000E02 01C6                <1> 	ADD	SI,AX
   188 00000E04 26807F0219          <1> 	cmp byte [es:bx + CMD], 19h
   189 00000E09 740C                <1> 	je .check
   190 00000E0B 26C45F13            <1> 	LES	BX, [ES:BX + GENERICIOCTL_PACKET]
   191                              <1> assume es:nothing
   192 00000E0F 2EFF14              <1> 	CALL	[CS:SI]
   193 00000E12 7210                <1> 	JC	FAILGENERIC$IOCTL
   194                              <1> .exit:
   195 00000E14 E9(0000)            <1> 	JMP	EXIT
   196                              <1> 
   197                              <1> .check:
   198 00000E17 2E813C[210E]        <1> 	cmp word [cs:si], Cmd_Err_Proc
   199 00000E1C 75F6                <1> 	jne .exit
   200                              <1> 
   201                              <1> IOCTL_FUNC_ERR:
   202                              <1>  assume ds:nothing, es:nothing, ss:nothing
   203 00000E1E E9(0000)            <1> 	JMP	CMDERR
   204                              <1> Cmd_Err_Proc:					;AN012;
   205 00000E21 5A                  <1> 	pop	dx				;AN012;clear up stack
   206 00000E22 EBFA                <1> 	jmp	IOCTL_FUNC_ERR			;AN012;Cmd error
   207                              <1> 
   208                              <1> FAILGENERIC$IOCTL:
   209                              <1>  assume ds:nothing, es:nothing, ss:nothing
   210 00000E24 E9(0000)            <1> 	JMP	ERR$EXIT
   211                              <1> 
   212                              <1> ;
   213                              <1> ; GETDEVICEPARAMETERS:
   214                              <1> ;
   215                              <1> ; INPUT: DS:DI POINTS TO BDS FOR DRIVE
   216                              <1> ;	 ES:BX POINTS TO DEVICE PARAMETER PACKET
   217                              <1> ;
   218                              <1> 	 PUBLIC GETDEVICEPARAMETERS
   219                              <1> GETDEVICEPARAMETERS PROC NEAR
   220                              <1>  assume ds:UPB, es:nothing, ss:nothing
   221                              <1> ; COPY INFO FROM BDS TO THE DEVICE PARAMETERS PACKET
   222 00000E27 8A4522              <1> 	MOV	AL, BYTE PTR [DI + FORMFACTOR]
   223 00000E2A 26884701            <1> 	MOV	BYTE PTR [ES:BX + DP_DEVICETYPE], AL
   224 00000E2E 8B4523              <1> 	MOV	AX, WORD PTR [DI + FLAGS]
   225 00000E31 83E003              <1> 	AND	AX,FNON_REMOVABLE+FCHANGELINE	; MASK OFF OTHER BITS
   226 00000E34 26894702            <1> 	MOV	WORD PTR [ES:BX + DP_DEVICEATTRIBUTES], AX
   227 00000E38 8B4525              <1> 	MOV	AX, WORD PTR [DI + CCYLN]
   228 00000E3B 26894704            <1> 	MOV	WORD PTR [ES:BX + DP_CYLINDERS], AX
   229                              <1> 
   230                              <1> ; SET MEDIA TYPE TO DEFAULT
   231 00000E3F 30C0                <1> 	XOR	AL, AL
   232 00000E41 26884706            <1> 	MOV	BYTE PTR [ES:BX + DP_MEDIATYPE], AL
   233                              <1> 
   234                              <1> ; COPY RECOMMENDED BPB
   235 00000E45 8D7527              <1> 	LEA	SI, [DI + RBYTEPERSEC]
   236 00000E48 26F60701            <1> 	TEST	BYTE PTR [ES:BX + DP_SPECIALFUNCTIONS], BUILD_DEVICE_BPB
   237 00000E4C 740B                <1> 	JZ	USE_BPB_PRESENT
   238                              <1> ; GET THE CORRECT DISK IN THE DRIVE
   239 00000E4E E808F6              <1> 	CALL	CHECKSINGLE
   240                              <1> ; BUILD THE BPB FROM SCRATCH
   241 00000E51 E82FF3              <1> 	CALL	GETBP
   242 00000E54 720C                <1> 	JC	GET_PARM_RET
   243 00000E56 8D7506              <1> 	LEA	SI,[DI + BYTEPERSEC]
   244                              <1> USE_BPB_PRESENT:
   245 00000E59 8D7F07              <1> 	LEA	DI, [BX + DP_BPB]
   246 00000E5C B91900              <1> 	MOV	CX, BPB_TYPE_struc_size		; FOR NOW USE 'SMALL' BPB
   247 00000E5F F3A4                <1> 	REP	MOVSB
   248 00000E61 F8                  <1> 	CLC
   249                              <1> GET_PARM_RET:
   250 00000E62 C3                  <1> 	RET
   251                              <1> GETDEVICEPARAMETERS ENDP
   252                              <1> 
   253                              <1> ;
   254                              <1> ; SETDEVICEPARAMETERS:
   255                              <1> ;
   256                              <1> ; INPUT: DS:DI POINTS TO BDS FOR DRIVE
   257                              <1> ;	 ES:BX POINTS TO DEVICE PARAMETER PACKET
   258                              <1> ;
   259                              <1> 	 PUBLIC SETDEVICEPARAMETERS
   260                              <1> SETDEVICEPARAMETERS PROC NEAR
   261                              <1>  assume ds:UPB, es:nothing, ss:nothing
   262                              <1> ; MAKE SURE THE FCHANGED_BY_FORMAT FLAG GETS SET TO KICK DOS INTO LOOKING AT
   263                              <1> ; THE BPB
   264 00000E63 814D234001          <1> 	OR	WORD PTR [DI + FLAGS], FCHANGED_BY_FORMAT | FCHANGED
   265 00000E68 26F60702            <1> 	TEST	BYTE PTR [ES:BX + DP_SPECIALFUNCTIONS], ONLY_SET_TRACKLAYOUT
   266 00000E6C 7403                <1> 	JZ	SHORT SETDEVPARM_1
   267 00000E6E EB79                <1> 	JMP	SETTRACKTABLE			; ORIGINALLY TRACKLAYOUT
   268 00000E70 90                  <1> 	nop	; identicalise
   269                              <1> 
   270                              <1> SETDEVPARM_1:
   271                              <1> ; COPY INFO FROM THE DEVICE PARAMETERS PACKET TO BDS
   272 00000E71 268A4701            <1> 	MOV	AL, BYTE PTR [ES:BX + DP_DEVICETYPE]
   273 00000E75 884522              <1> 	MOV	BYTE PTR [DI + FORMFACTOR], AL
   274                              <1> 
   275 00000E78 268B4704            <1> 	MOV	AX, WORD PTR [ES:BX + DP_CYLINDERS]
   276 00000E7C 894525              <1> 	MOV	WORD PTR [DI + CCYLN], AX
   277                              <1> 
   278                              <1> ; IF CHANGE LINE IS NOT LOADED THEN IGNORE CHANGELING FLAG
   279 00000E7F 268B4702            <1> 	MOV	AX, WORD PTR [ES:BX + DP_DEVICEATTRIBUTES]
   280 00000E83 1E                  <1> 	push ds
   281 00000E84 E8(0000)            <1> 	call biocode_get_ds_dosbiodata
   282                              <1>  assume ds:DOSGROUP
   283 00000E87 803E[0000]00        <1> 	CMP	byte [FHAVE96],0
   284 00000E8C 1F                  <1> 	pop ds
   285                              <1>  assume ds:UPB
   286 00000E8D 7503                <1> 	JNZ	HAVE_CHANGE
   287 00000E8F 83E0FD              <1> 	AND	AX,~ FCHANGELINE
   288                              <1> HAVE_CHANGE:
   289                              <1> ; IGNORE ALL BITS EXCEPT NON_REMOVABLE AND CHANGELINE
   290 00000E92 83E003              <1> 	AND	AX,FNON_REMOVABLE | FCHANGELINE
   291 00000E95 8B4D23              <1> 	MOV	CX, WORD PTR [DI + FLAGS]
   292                              <1> ;	 AND	 CX, NOT (FNON_REMOVABLE OR FCHANGELINE OR GOOD_TRACKLAYOUT)
   293 00000E98 81E1F4FD            <1> 	AND	CX, ~ (FNON_REMOVABLE | FCHANGELINE | GOOD_TRACKLAYOUT | UNFORMATTED_MEDIA) ;AN004;AN005;AN007;
   294 00000E9C 09C8                <1> 	OR	AX, CX
   295 00000E9E 894523              <1> 	MOV	WORD PTR [DI + FLAGS], AX
   296                              <1> 
   297                              <1> ; SET MEDIA TYPE
   298 00000EA1 268A4706            <1> 	MOV	AL, BYTE PTR [ES:BX + DP_MEDIATYPE]
   299 00000EA5 1E                  <1> 	push ds
   300 00000EA6 E8(0000)            <1> 	call biocode_get_ds_dosbiodata
   301                              <1>  assume ds:DOSGROUP
   302 00000EA9 A2[FE00]            <1> 	MOV	[MEDIATYPE], AL
   303 00000EAC 1F                  <1> 	pop ds
   304                              <1>  assume ds:UPB
   305                              <1> ; THE MEDIA CHANGED (MAYBE) SO WE WILL HAVE TO DO A SETDASD THE NEXT TIME
   306                              <1> ; WE FORMAT A TRACK
   307 00000EAD 814D238000          <1> 	OR	WORD PTR [DI + FLAGS], SET_DASD_TRUE
   308                              <1> 
   309 00000EB2 1E570653            <1> 	SAVEREG <DS,DI,ES,BX>
   310                              <1> ; FIGURE OUT WHAT WE ARE SUPPOSED TO DO WITH THE BPB
   311                              <1> 
   312                              <1> ; WERE WE ASKED TO INSTALL A FAKE BPB?
   313 00000EB6 26F60701            <1> 	TEST	BYTE PTR [ES:BX + DP_SPECIALFUNCTIONS], INSTALL_FAKE_BPB
   314 00000EBA 7513                <1> 	JNZ	SHORT INSTALLFAKEBPB
   315                              <1> 
   316                              <1> ; WERE WE RETURNING A FAKE BPB WHEN ASKED TO BUILD A BPB?
   317 00000EBC F745230400          <1> 	TEST	WORD PTR [DI + FLAGS], RETURN_FAKE_BPB
   318 00000EC1 7404                <1> 	JZ	SHORT INSTALLRECOMMENDEDBPB
   319                              <1> 
   320                              <1> ; WE WERE RETURNING A FAKE BPB BUT WE CAN STOP NOW
   321 00000EC3 836523FB            <1> 	AND	WORD PTR [DI + FLAGS], ~ RETURN_FAKE_BPB
   322                              <1> ;	 JMP	 DONEWITHBPBSTUFF		;AN008; Comment out this instruction.
   323                              <1> 
   324                              <1> INSTALLRECOMMENDEDBPB:
   325 00000EC7 B91F00              <1> 	MOV	CX, A_BPB_struc_size
   326 00000ECA 8D7D27              <1> 	LEA	DI, [DI + RBYTEPERSEC]
   327 00000ECD EB0A                <1> 	JMP	SHORT COPYTHEBPB
   328                              <1> 
   329                              <1> INSTALLFAKEBPB:
   330                              <1> return_fake_bpb equ RETURN_FAKE_BPB	; NASM port equate
   331 00000ECF 834D2304            <1> 	or	word ptr [di + flags], return_fake_bpb ;AN000; Problem
   332                              <1> 							;reported by WHS.
   333 00000ED3 B91900              <1> 	MOV	CX, BPB_TYPE_struc_size    ; MOVE 'SMALLER' BPB
   334 00000ED6 8D7D06              <1> 	LEA	DI, [DI + BYTEPERSEC]
   335                              <1> COPYTHEBPB:
   336 00000ED9 8D7707              <1> 	LEA	SI, [BX + DP_BPB]
   337                              <1> ; EXCHANGE ES AND DS
   338 00000EDC 06                  <1> 	PUSH	ES
   339 00000EDD 1E                  <1> 	PUSH	DS
   340 00000EDE 07                  <1> 	POP	ES
   341 00000EDF 1F                  <1> 	POP	DS
   342                              <1>  assume ds:nothing, es:UPB
   343                              <1> 
   344 00000EE0 F3A4                <1> 	REP	MOVSB
   345                              <1> 
   346                              <1> DONEWITHBPBSTUFF:
   347 00000EE2 E86804              <1> 	CALL	RESTOREOLDDPT		; RESTORE THE OLD DPT FROM TEMPDPT
   348 00000EE5 5B075F1F            <1> 	RESTOREREG <BX,ES,DI,DS>
   349                              <1>  assume ds:UPB, es:nothing
   350                              <1> 
   351                              <1> ; SET UP TRACK TABLE (IF NECCESSARY)
   352                              <1> SETTRACKTABLE:
   353 00000EE9 268B4F26            <1> 	MOV	CX, WORD PTR [ES:BX + DP_TRACKTABLEENTRIES]
   354 00000EED 1E                  <1> 	push ds
   355 00000EEE E8(0000)            <1> 	call biocode_get_ds_dosbiodata
   356                              <1>  assume ds:DOSGROUP
   357 00000EF1 890E[0000]          <1> 	MOV	[SECTORSPERTRACK], CX
   358 00000EF5 1F                  <1> 	pop ds
   359                              <1>  assume ds:UPB
   360 00000EF6 836523F7            <1> 	AND	WORD PTR [DI + FLAGS], ~ GOOD_TRACKLAYOUT
   361 00000EFA 26F60704            <1> 	TEST	BYTE PTR [ES:BX + DP_SPECIALFUNCTIONS], TRACKLAYOUT_IS_GOOD
   362 00000EFE 7404                <1> 	JZ	UGLYTRACKLAYOUT
   363 00000F00 834D2308            <1> 	OR	WORD PTR [DI + FLAGS], GOOD_TRACKLAYOUT
   364                              <1> 
   365                              <1> UGLYTRACKLAYOUT:
   366 00000F04 83F93F              <1> 	CMP	CX, MAX_SECTORS_IN_TRACK
   367 00000F07 771C                <1> 	JA	TOOMANYSECTORSPERTRACK
   368 00000F09 E318                <1> 	JCXZ	SECTORINFOSAVED
   369 00000F0B BF[0200]            <1> 	MOV	DI, OFFSET TRACKTABLE
   370 00000F0E 8D7728              <1> 	LEA	SI, [BX + DP_SECTORTABLE]
   371 00000F11 06                  <1> 	PUSH	ES
   372 00000F12 1F                  <1> 	POP	DS
   373                              <1>  assume ds:nothing
   374 00000F13 E8(0000)            <1> 	call biocode_get_es_dosbiodata
   375                              <1>  assume es:DOSGROUP
   376                              <1> STORESECTORINFO:
   377 00000F16 AF                  <1> 	scasw			; di += 2
   378                              <1> 	;INC	DI				; SKIP OVER CYLINDER
   379                              <1> 	;INC	DI				; SKIP OVER HEAD
   380 00000F17 AD                  <1> 	LODSW					; GET SECTOR ID
   381 00000F18 50                  <1> 	PUSH	AX				; SAVE IT
   382 00000F19 AD                  <1> 	LODSW					; GET SECTOR SIZE
   383 00000F1A E8BD02              <1> 	CALL	SECTORSIZETOSECTORINDEX
   384 00000F1D 5A                  <1> 	POP	DX				; GET SECTOR ID BACK
   385 00000F1E 88D0                <1> 	MOV	AL, DL				; AH = SECTOR SIZE INDEX
   386                              <1> 						; AL = SECTOR ID
   387 00000F20 AB                  <1> 	STOSW
   388 00000F21 E2F3                <1> 	LOOP	STORESECTORINFO
   389                              <1> 
   390                              <1> SECTORINFOSAVED:
   391 00000F23 F8                  <1> 	CLC
   392 00000F24 C3                  <1> 	RET
   393                              <1> 
   394                              <1> TOOMANYSECTORSPERTRACK:
   395 00000F25 B00C                <1> 	MOV	AL, 0CH
   396 00000F27 F9                  <1> 	STC
   397 00000F28 C3                  <1> 	RET
   398                              <1> 
   399                              <1> SETDEVICEPARAMETERS ENDP
   400                              <1> 
   401                              <1> ;
   402                              <1> ; SET MEDIA TYPE FOR FORMAT
   403                              <1> ; PERFORMS THE INT 13 WITH AH = 18H TO SEE IF THE MEDIUM DESCRIBED IN THE
   404                              <1> ; BPB AREA IN THE BDS CAN BE HANDLED BY THE ROM.
   405                              <1> ; ON INPUT, DS:DI -> CURRENT BDS.
   406                              <1> ; THE STATUS OF THE OPERATION IS RETURNED IN AL
   407                              <1> ;	- 0 - IF THE SUPPORT IS AVAILABLE, AND THE COMBINATION IS VALID.
   408                              <1> ;	- 1 - NO ROM SUPPORT
   409                              <1> ;	- 2 - ILLEGAL COMBINATION
   410                              <1> ;	- 3 - No media present (ROM support exists but cannot determine now)
   411                              <1> ; FLAGS ALSO MAY BE ALTERED. ALL OTHER REGISTERS PRESERVED.
   412                              <1> ; IF THE CALL TO ROM RETURNS NO ERROR, THEN THE CURRENT DPT IS "REPLACED" BY
   413                              <1> ; THE ONE RETURNED BY THE ROM. THIS IS DONE BY CHANGING THE POINTER IN [DPT]
   414                              <1> ; TO THE ONE RETURNED. THE ORIGINAL POINTER TO THE DISK BASE TABLE IS STORED
   415                              <1> ; IN TEMPDPT, UNTIL IT IS RESTORED.
   416                              <1> ;
   417                              <1> 	PUBLIC SET_MEDIA_FOR_FORMAT
   418                              <1> SET_MEDIA_FOR_FORMAT PROC NEAR
   419                              <1>  assume ds:UPB, es:nothing, ss:nothing
   420 00000F29 5152                <1> 	SAVEREG <CX,DX>
   421 00000F2B 31C0                <1> 	XOR	AX,AX
   422 00000F2D 1E                  <1> 	push ds
   423 00000F2E E8(0000)            <1> 	call biocode_get_ds_dosbiodata
   424                              <1>  assume ds:DOSGROUP
   425 00000F31 803E[0001]01        <1> 	cmp	byte [Had_Format_Error],1 ;Did we have a format error before?
   426 00000F36 7503                <1> 	jne	No_Form_Err		;AN001;
   427 00000F38 E82903              <1> 	call	ResetDisk
   428                              <1> No_Form_Err:				;AN001;
   429 00000F3B 803E[FF00]01        <1> 	CMP	BYTE PTR [MEDIA_SET_FOR_FORMAT],1
   430 00000F40 1F                  <1> 	pop ds
   431                              <1>  assume ds:UPB
   432 00000F41 7503                <1> 	jne	Do_Set_Media_for_Format
   433 00000F43 E98E00              <1> 	jmp	SET_MED_RET		; MEDIA ALREADY SET
   434                              <1> Do_Set_Media_for_Format:
   435 00000F46 1E56                <1> 	SAVEREG <DS,SI>
   436 00000F48 8ED8                <1> 	MOV	DS,AX
   437                              <1>  assume ds:IVT
   438 00000F4A C5367800            <1> 	LDS	SI,[DSKADR]	; GET POINTER TO DISK BASE TABLE
   439                              <1>  assume ds:nothing
   440                              <1> ;SB34IOCTL000******************************************************************
   441                              <1> ;SB	Initialise the head settle time to 0fh.  See the offsets given in
   442                              <1> ;SB	DSKPRM.INC.  1 LOC.
   443                              <1> 
   444 00000F4E C644090F            <1> 	mov	byte [si + DISK_HEAD_STTL], 0Fh
   445                              <1> ;SB34IOCTL000******************************************************************
   446 00000F52 1E                  <1> 	 push ds
   447 00000F53 E8(0000)            <1> 	call biocode_get_ds_dosbiodata
   448                              <1>  assume ds:DOSGROUP
   449 00000F56 8936[0000]          <1> 	MOV WORD PTR [DPT],SI
   450 00000F5A 8F06[0200]          <1> 	 pop WORD PTR [DPT+2],		; SAVE POINTER TO TABLE
   451 00000F5E C606[0000]01        <1> 	mov	byte [New_Rom], 1	;assume a new ROM.
   452 00000F63 5E1F                <1> 	RESTOREREG <SI,DS>
   453                              <1>  assume ds:UPB
   454                              <1> New_Rom equ NEW_ROM	; NASM port label
   455 00000F65 30C0                <1> 	XOR	AL,AL
   456                              <1> ;SB33031****************************************************************
   457                              <1> ccyln equ CCYLN	; NASM port equate
   458 00000F67 8B4D25              <1> 	mov	cx,[di + ccyln]	;get number of cylinders     ;SB  ;3.30*
   459 00000F6A 49                  <1> 	dec	cx			;cylinder must be zero based ;SB  ;3.30*
   460 00000F6B 80E503              <1> 	and	ch,03h			; blank out unnecessary bits
   461 00000F6E D0CD                <1> 	ror	ch,1			;put in int form	     ;SB  ;3.30*
   462 00000F70 D0CD                <1> 	ror	ch,1			;			     ;SB  ;3.30*
   463 00000F72 86E9                <1> 	xchg	ch,cl			;			     ;SB  ;3.30*
   464                              <1> seclim equ SECLIM	; NASM port equate
   465 00000F74 0A4D13              <1> 	or	cl,byte ptr [di + seclim] ;get number of sectors    ;SB  ;3.30*
   466                              <1> drivenum equ DRIVENUM	; NASM port equate
   467 00000F77 8A5504              <1> 	mov	dl,[di + drivenum]	;get drive number	     ;SB  ;3.30*
   468 00000F7A B418                <1> 	mov	ah,18h			;set media for format	     ;SB  ;3.30*
   469 00000F7C 061E5657            <1> 	SAVEREG <ES,DS,SI,DI>
   470 00000F80 CD13                <1> 	int	13h			;call rom bios		     ;SB  ;3.30*
   471                              <1>  assume es:nothing
   472                              <1> ;SB33031****************************************************************
   473 00000F82 7230                <1> 	JC	FORMAT_STAT_ERR
   474                              <1> ; ES:DI POINTS TO A DISK BASE TABLE FOR THIS COMBINATION FOR THIS DRIVE.
   475 00000F84 31C9                <1> 	XOR	CX,CX
   476 00000F86 8ED9                <1> 	MOV	DS,CX				; HAVE DS -> SEGMENT 0
   477                              <1>  assume ds:IVT
   478 00000F88 8B367800            <1> 	mov	SI,[DSKADR]	; GET CURRENT DISK BASE TABLE
   479 00000F8C FF367A00            <1> 	push word [DSKADR + 2]		; get segment
   480 00000F90 893E7800            <1> 	MOV	WORD PTR [DSKADR],DI
   481 00000F94 8C067A00            <1> 	MOV	WORD PTR [DSKADR+2],ES	; REPLACE WITH ONE RETURNED BY ROM
   482 00000F98 1F                  <1> 	pop ds				; pop segment
   483                              <1>  assume ds:nothing
   484 00000F99 E8(0000)            <1> 	call biocode_get_es_dosbiodata
   485                              <1>  assume es:DOSGROUP
   486 00000F9C 268936[0201]        <1> 	MOV	WORD PTR [es:TEMPDPT],SI
   487 00000FA1 268C1E[0401]        <1> 	MOV	WORD PTR [es:TEMPDPT+2],DS	; SAVE IT
   488 00000FA6 26C606[FF00]01      <1> 	MOV	BYTE PTR [es:MEDIA_SET_FOR_FORMAT],1
   489 00000FAC 30C0                <1> 	XOR	AL,AL			; LEGAL COMBINATION + ROM SUPPORT CODE
   490 00000FAE 26A2[0001]          <1> 	mov	[es:Had_Format_Error],al ;reset the flag
   491 00000FB2 EB1C                <1> 	JMP	SHORT POP_STAT_RET
   492                              <1> 
   493                              <1> FORMAT_STAT_ERR:
   494 00000FB4 80FC0C              <1> 	cmp	ah, Dsk_illegal_combination	;J.K. illegal combination = 0ch
   495 00000FB7 7411                <1> 	je	Format_stat_illegal_comb
   496                              <1> Dsk_Time_Out_Err equ Dsk_time_out_Err	; NASM port equate
   497 00000FB9 80FC80              <1> 	cmp	ah, Dsk_Time_Out_Err		;J.K. = 80h
   498 00000FBC 7410                <1> 	je	Format_stat_Time_out
   499 00000FBE B001                <1> 	mov	al, 1				;Function not supported.
   500 00000FC0 E8(0000)            <1> 	call biocode_get_ds_dosbiodata
   501                              <1>  assume ds:DOSGROUP
   502 00000FC3 C606[0000]00        <1> 	mov	byte [New_Rom], 0 		;So, it is an old rom.
   503                              <1> Pop_stat_ret equ POP_STAT_RET	; NASM port label
   504 00000FC8 EB06                <1> 	jmp	short Pop_stat_ret
   505                              <1> Format_stat_illegal_comb:			;J.K. Function supported, but
   506 00000FCA B002                <1> 	MOV	AL,2				;J.K. illegal sect/trk, trk combination.
   507 00000FCC EB02                <1> 	jmp	short Pop_stat_ret
   508                              <1> Format_stat_Time_out:				;J.K. Function supported, but
   509 00000FCE B003                <1> 	mov	al, 3				;J.K. media not present.
   510                              <1> POP_STAT_RET:
   511 00000FD0 5F5E1F07            <1> 	RESTOREREG <DI,SI,DS,ES>
   512                              <1>  assume ds:UPB, es:nothing
   513                              <1> SET_MED_RET:
   514 00000FD4 5A59                <1> 	RESTOREREG <DX,CX>
   515 00000FD6 C3                  <1> 	RET
   516                              <1> 
   517                              <1> SET_MEDIA_FOR_FORMAT ENDP
   518                              <1> 
   519                              <1> ;
   520                              <1> ; FORMATTRACK:
   521                              <1> ; IF SPECIALFUNCTION BYTE IS 1, THEN THIS IS A STATUS CALL TO SEE IF THERE IS
   522                              <1> ; ROM SUPPORT FOR THE COMBINATION OF SEC/TRK AND # OF CYLN, AND IF THE
   523                              <1> ; COMBINATION IS LEGAL. IF SPECIALFUNCTION BYTE IS 0, THEN FORMAT THE TRACK.
   524                              <1> ;
   525                              <1> ; INPUT: DS:DI POINTS TO BDS FOR DRIVE
   526                              <1> ;	 ES:BX POINTS TO FORMAT PACKET
   527                              <1> ;
   528                              <1> ; OUTPUT:
   529                              <1> ;	FOR STATUS CALL:
   530                              <1> ;	SPECIALFUNCTION BYTE SET TO:
   531                              <1> ;		0 - ROM SUPPORT + LEGAL COMBINATION
   532                              <1> ;		1 - NO ROM SUPPORT
   533                              <1> ;		2 - ILLEGAL COMBINATION
   534                              <1> ;		3 - no media present	;J.K. 7/8/86
   535                              <1> ;	CARRY CLEARED.
   536                              <1> ;
   537                              <1> ;	FOR FORMAT TRACK:
   538                              <1> ;		CARRY SET IF ERROR
   539                              <1> ;
   540                              <1> 	PUBLIC FORMATTRACK
   541                              <1> FORMATTRACK PROC NEAR
   542                              <1>  assume ds:UPB, es:nothing, ss:nothing
   543 00000FD7 26F60701            <1> 	TEST	BYTE PTR [ES:BX + DP_SPECIALFUNCTIONS],STATUS_FOR_FORMAT
   544 00000FDB 7408                <1> 	JZ	DO_FORMAT_TRACK
   545 00000FDD E849FF              <1> 	CALL	SET_MEDIA_FOR_FORMAT	; ALSO MOVES CURRENT DPT TO TEMPDPT
   546                              <1> STAT_RET:
   547 00000FE0 268807              <1> 	MOV	BYTE PTR [ES:BX + DP_SPECIALFUNCTIONS],AL
   548 00000FE3 F8                  <1> 	CLC
   549 00000FE4 C3                  <1> 	RET
   550                              <1> 
   551                              <1> DO_FORMAT_TRACK:
   552 00000FE5 807D2205            <1> 	CMP	BYTE PTR [DI + FORMFACTOR], DEV_HARDDISK
   553 00000FE9 7503                <1> 	jne	Do_Format_Diskette
   554                              <1> DoVerifyTrack equ DOVERIFYTRACK	; NASM port label
   555 00000FEB E99800              <1> 	jmp	DoVerifyTrack
   556                              <1> Do_Format_Diskette:
   557 00000FEE 1E570653            <1> 	SAVEREG <DS,DI,ES,BX>
   558                              <1> ;SB34IOCTL001*************************************************************
   559                              <1> ;SB	check the special functions word to see if DO_FAST_FORMAT has been
   560                              <1> ;SB	specified.  If so it is an error and we need to finish this operation
   561                              <1> ;SB	by indicating the error value 1 in register ah and going to the
   562                              <1> ;SB	the code at DO_MAP_IT to map the error.  This is because we cannot
   563                              <1> ;SB	allow multitrack format on floppies - 5 LOCS
   564                              <1> 
   565 00000FF2 26F60702            <1> 	test	byte ptr [es:bx + FP_SPECIALFUNCTIONS],DO_FAST_FORMAT
   566 00000FF6 7405                <1> 	jz	NO_FAST_FORMAT
   567 00000FF8 B401                <1> 	mov	ah, 1
   568                              <1> DO_MAP_IT equ Do_Map_it	; NASM port label
   569 00000FFA EB78                <1> 	jmp	DO_MAP_IT
   570 00000FFC 90                  <1> 	nop	; identicalise
   571                              <1> NO_FAST_FORMAT:
   572                              <1> ;SB34IOCTL001*************************************************************
   573 00000FFD E829FF              <1> 	CALL	SET_MEDIA_FOR_FORMAT	; ALSO MOVES CURRENT DPT TO TEMPDPT
   574 00001000 3C01                <1> 	CMP	AL,1		; DO WE HAVE ROM SUPPORT FOR sector/trk, # trks combination?
   575 00001002 7407                <1> 	JZ	Need_Set_DASD	;Old ROM.
   576 00001004 3C03                <1> 	cmp	al,3		;time out error?
   577                              <1> No_Set_DASD equ NO_SET_DASD	; NASM port label
   578 00001006 7506                <1> 	jnz	No_Set_DASD	;No, fine.(At this point, don't care about the illegal combination.)
   579 00001008 EB5D                <1> 	jmp	Format_Failed
   580 0000100A 90                  <1> 	nop	; identicalise
   581                              <1> Need_Set_DASD:
   582 0000100B E8DF01              <1> 	CALL	SETDASD		;AH=17h, INT 13h
   583                              <1> ;
   584                              <1> ; STORE CYLINDER,HEAD IN TRACK TABLE
   585                              <1> ;			***** ASSUMPTION *******
   586                              <1> ;	SINCE FORMAT REQUESTS ON FIXED MEDIA ARE CONVERTED TO VERIFIES, WE
   587                              <1> ;	ASSUME THAT WE ARE FORMATTING A FLOPPY AND HENCE HAVE 255 OR LESS
   588                              <1> ;	TRACKS AND HEADS. WE THEREFORE MUST CHANGE THE CYLINDER, HEAD DATA
   589                              <1> ;	FROM THE REQUEST PACKET SIZE TO THAT OF THE TRACKTABLE (SEE INT 13
   590                              <1> ;	INTERFACE IN IBM'S TECH REF.).
   591                              <1> 
   592                              <1> NO_SET_DASD:
   593                              <1> ; CHECK TO ENSURE CORRECT DISK IS IN DRIVE
   594 0000100E E848F4              <1> 	CALL	CHECKSINGLE
   595                              <1> 
   596 00001011 268B4703            <1> 	MOV	AX, WORD PTR [ES:BX + FP_CYLINDER]
   597 00001015 268B4F01            <1> 	MOV	CX, WORD PTR [ES:BX + FP_HEAD]
   598 00001019 E8(0000)            <1> 	call biocode_get_es_dosbiodata
   599                              <1>  assume es:DOSGROUP
   600 0000101C 26A3[0000]          <1> 	MOV	WORD PTR [es:TRKNUM],AX
   601 00001020 26880E[0000]        <1> 	MOV	BYTE PTR [es:HDNUM],CL
   602 00001025 88CC                <1> 	MOV	AH,CL
   603                              <1> 
   604 00001027 57                  <1> 	PUSH	DI					; SAVE PTR TO BDS
   605 00001028 BF[0200]            <1> 	MOV	DI, OFFSET TRACKTABLE			; access with es
   606 0000102B 268B0E[0000]        <1> 	MOV	CX, [es:SECTORSPERTRACK]
   607                              <1> STORECYLINDERHEAD:
   608 00001030 AB                  <1> 	STOSW
   609 00001031 47                  <1> 	INC	DI					; SKIP SECTOR ID
   610 00001032 47                  <1> 	INC	DI					; SKIP SECTOR SIZE
   611 00001033 E2FB                <1> 	LOOP	STORECYLINDERHEAD
   612 00001035 5F                  <1> 	POP	DI					; RESTORE PTR TO BDS
   613                              <1> 
   614 00001036 B90500              <1> 	MOV	CX, MAXERR			; SET UP RETRY COUNT
   615                              <1> FORMATRETRY:
   616 00001039 51                  <1> 	PUSH	CX
   617 0000103A BB[0200]            <1> 	MOV	BX, OFFSET TRACKTABLE
   618 0000103D E8(0000)            <1> 	call biocode_get_es_dosbiodata
   619                              <1>  assume es:DOSGROUP
   620 00001040 26A1[0000]          <1> 	MOV	AX, [es:SECTORSPERTRACK]
   621 00001044 B405                <1> 	MOV	AH, ROMFORMAT
   622 00001046 E82C02              <1> 	CALL	TO_ROM
   623 00001049 59                  <1> 	POP	CX
   624 0000104A 7330                <1> 	JNC	FORMATOK
   625                              <1> resetdisk equ RESETDISK	; NASM port label
   626 0000104C E81502              <1> 	call	resetdisk
   627 0000104F 26C606[0001]01      <1> 	mov	byte [es:Had_Format_Error],1
   628 00001055 50                  <1> 	push	ax
   629 00001056 51                  <1> 	push	cx
   630 00001057 52                  <1> 	push	dx
   631                              <1> Set_Media_For_Format equ SET_MEDIA_FOR_FORMAT	; NASM port label
   632 00001058 E8CEFE              <1> 	call	Set_Media_For_Format
   633 0000105B 3C01                <1> 	cmp	al, 1
   634 0000105D 7503                <1> 	jnz	While_Err
   635                              <1> SetDASD equ SETDASD	; NASM port label
   636 0000105F E88B01              <1> 	call	SetDASD
   637                              <1> While_Err:
   638 00001062 5A                  <1> 	pop	dx
   639 00001063 59                  <1> 	pop	cx
   640 00001064 58                  <1> 	pop	ax
   641 00001065 E2D2                <1> 	LOOP	FORMATRETRY
   642                              <1> ;SB33106*******************************************************************
   643                              <1> Format_Failed:
   644 00001067 26C606[0001]01      <1> 	mov	byte [es:Had_Format_Error], 1	;set the format error flag.
   645                              <1> Dsk_Change_Line_Err equ Dsk_change_line_Err	; NASM port equate
   646 0000106D 80FC06              <1> 	cmp	ah, Dsk_Change_Line_Err		;=06h. Convert change line
   647 00001070 7502                <1> 	jne	Do_Map_it			;error to Time Out error.
   648 00001072 B480                <1> 	mov	ah, Dsk_Time_Out_Err		;=80h
   649                              <1> ;SB33106*******************************************************************
   650                              <1> Do_Map_it:
   651 00001074 E836FA              <1> 	CALL	MAPERROR
   652 00001077 5B075F1F            <1> 	RESTOREREG <BX,ES,DI,DS>
   653                              <1>  assume ds:UPB, es:nothing, ss:nothing
   654 0000107B C3                  <1> 	RET
   655                              <1> 
   656                              <1> FORMATOK:
   657                              <1>  assume ds:nothing, es:DOSGROUP
   658 0000107C 26C606[0001]00      <1> 	mov	byte [es:Had_Format_Error],0	; reset the format error flag.
   659 00001082 5B075F1F            <1> 	RESTOREREG <BX,ES,DI,DS>
   660                              <1>  assume ds:UPB, es:nothing, ss:nothing
   661                              <1> 
   662                              <1> DOVERIFYTRACK:
   663 00001086 E80800              <1> 	CALL	VERIFYTRACK
   664 00001089 C3                  <1> 	RET
   665                              <1> 
   666                              <1> FORMATTRACK ENDP
   667                              <1> 
   668                              <1> VerifyTrack_Err:				;AN006;
   669 0000108A B401                <1> 	mov	ah, 1				;AN006;
   670                              <1> MapError equ MAPERROR	; NASM port label
   671 0000108C E81EFA              <1> 	call	MapError			;AN006;
   672 0000108F 1F                  <1> 	pop ds
   673                              <1>  assume ds:UPB, es:nothing, ss:nothing
   674 00001090 C3                  <1> 	ret					;AN006;
   675                              <1> 
   676                              <1> ;
   677                              <1> ; VERIFYTRACK:
   678                              <1> ;
   679                              <1> ; INPUT: DS:DI POINTS TO BDS FOR DRIVE
   680                              <1> ;	 ES:BX POINTS TO VERIFY PACKET
   681                              <1> ;
   682                              <1> 	PUBLIC VERIFYTRACK
   683                              <1> VERIFYTRACK PROC NEAR
   684                              <1>  assume ds:UPB, es:nothing, ss:nothing
   685 00001091 1E                  <1> 	push ds
   686 00001092 E8(0000)            <1> 	call biocode_get_ds_dosbiodata
   687                              <1>  assume ds:DOSGROUP
   688 00001095 C606[0000]04        <1> 	MOV	byte [RFLAG], ROMVERIFY
   689 0000109A 268B4703            <1> 	MOV	AX, WORD PTR [ES:BX + VP_CYLINDER]
   690 0000109E A3[0000]            <1> 	MOV	[CURTRK], AX
   691 000010A1 268B4701            <1> 	MOV	AX, WORD PTR [ES:BX + VP_HEAD]
   692                              <1> 
   693                              <1> ;	****** ASSUMPTION ******
   694                              <1> ;	WE ASSUME THAT WE HAVE LESS THAN 256 HEADS, AND THAT THE REQUEST
   695                              <1> ;	HEADER DATA STRUCTURE IS UNNECCESSARILY BIG
   696 000010A5 A2[0000]            <1> 	MOV	[CURHD], AL
   697 000010A8 8B0E[0000]          <1> 	MOV	CX, [SECTORSPERTRACK]		;CL = sectors/track
   698                              <1> ;SB34IOCTL005*************************************************************
   699                              <1> ;SB
   700                              <1> ;SB	Check SPECIALFUNCTIONS to see if DO_FAST_FORMAT has been specified
   701                              <1> ;SB	If not we should go to the normal track verification routine.  If
   702                              <1> ;SB	fast format has been specified we should get the number of tracks
   703                              <1> ;SB	to be verified and check it to see if it is > 255.  If it is then
   704                              <1> ;SB	it is an error and we should go to VerifyTrack_Err. If not multiply
   705                              <1> ;SB	the number of tracks by the sectors per track to get the total
   706                              <1> ;SB	number of sectors to be verified.  This should also be less than
   707                              <1> ;SB	equal to 255 otherwise we go to same error exit.  If everything
   708                              <1> ;SB	is okay we initalise cx to the total sectors. use ax as a temporary
   709                              <1> ;SB	register.  9 LOCS
   710                              <1> 
   711 000010AC 26F60702            <1> 	test	byte ptr [es:bx + FP_SPECIALFUNCTIONS],DO_FAST_FORMAT
   712 000010B0 742B                <1> 	jz	Norm_VerifyTrack
   713 000010B2 268B4705            <1> 	mov	ax,[es:bx + FP_TRACKCOUNT]	;ax <- tracks to be verify
   714 000010B6 3DFF00              <1> 	cmp	ax,0FFh
   715 000010B9 77CF                <1> 	ja	VerifyTrack_Err 		;#tracks > 255
   716 000010BB F6E1                <1> 	mul	cl
   717 000010BD 3DFF00              <1> 	cmp	ax,0FFh 			;#sectors > 255
   718 000010C0 77C8                <1> 	ja	VerifyTrack_Err
   719 000010C2 89C1                <1> 	mov	cx,ax				;#sectors to verify
   720                              <1> ;SB34IOCTL005*************************************************************
   721                              <1> 
   722 000010C4 1F                  <1> 	pop ds
   723                              <1>  assume ds:UPB
   724 000010C5 1E                  <1> 	push ds				; -> UPB
   725                              <1> 
   726                              <1> ;Set the multi track request flag
   727 000010C6 F745230100          <1> 	test	word ptr [di + Flags], fNON_REMOVABLE	;AN009;hard disk?
   728 000010CB 7410                <1> 	jz	Norm_VerifyTrack			;AN009;
   729                              <1> Multrk_Flag equ MulTrk_Flag	; NASM port label
   730 000010CD E8(0000)            <1> 	call biocode_get_ds_dosbiodata
   731                              <1>  assume ds:DOSGROUP
   732 000010D0 F706[0000]8000      <1> 	test	word [Multrk_Flag], MULTRK_ON		;AN009;MultiTrack operation = on?
   733 000010D6 7405                <1> 	jz	Norm_VerifyTrack			;AN009;
   734                              <1> Multitrk_Format_Flag equ MultiTrk_Format_Flag	; NASM port label
   735 000010D8 C606[0000]01        <1> 	mov	byte [Multitrk_Format_Flag], 1		;AN009; then set the flag
   736                              <1> Norm_VerifyTrack:				;AN006;
   737 000010DD 31C0                <1> 	XOR	AX, AX				;1st sector
   738                              <1> ; USE 0:0 AS THE TRANSFER ADDRESS FOR VERIFY
   739 000010DF 31DB                <1> 	XOR	BX, BX
   740 000010E1 8EC3                <1> 	MOV	ES, BX
   741                              <1>  assume es:IVT
   742 000010E3 1F                  <1> 	pop ds
   743                              <1>  assume ds:UPB
   744 000010E4 E84600              <1> 	CALL	TRACKIO
   745 000010E7 1E                  <1> 	push ds
   746 000010E8 E8(0000)            <1> 	call biocode_get_ds_dosbiodata
   747                              <1>  assume ds:DOSGROUP
   748 000010EB C606[0000]00        <1> 	mov	byte [Multitrk_Format_Flag], 0		;AN009;Reset the flag.
   749 000010F0 1F                  <1> 	pop ds
   750                              <1>  assume ds:UPB
   751 000010F1 C3                  <1> 	RET
   752                              <1> VERIFYTRACK ENDP
   753                              <1> 
   754                              <1> ;
   755                              <1> ; READTRACK:
   756                              <1> ;
   757                              <1> ; INPUT: DS:DI POINTS TO BDS FOR DRIVE
   758                              <1> ;	 ES:BX POINTS TO READ PACKET
   759                              <1> ;
   760                              <1> 	PUBLIC READTRACK
   761                              <1> READTRACK:
   762                              <1>  assume ds:UPB, es:nothing, ss:nothing
   763 000010F2 1E                  <1> 	push ds
   764 000010F3 E8(0000)            <1> 	call biocode_get_ds_dosbiodata
   765                              <1>  assume ds:DOSGROUP
   766 000010F6 C606[0000]02        <1> 	MOV	byte [RFLAG], ROMREAD
   767 000010FB 1F                  <1> 	pop ds
   768                              <1>  assume ds:UPB
   769 000010FC EB0C                <1> 	JMP	READWRITETRACK
   770                              <1> 
   771                              <1> ;
   772                              <1> ; WRITETRACK:
   773                              <1> ;
   774                              <1> ; INPUT: DS:DI POINTS TO BDS FOR DRIVE
   775                              <1> ;	 ES:BX POINTS TO WRITE PACKET
   776                              <1> ;
   777                              <1> 	PUBLIC WRITETRACK
   778                              <1> WRITETRACK:
   779                              <1>  assume ds:UPB, es:nothing, ss:nothing
   780 000010FE 1E                  <1> 	push ds
   781 000010FF E8(0000)            <1> 	call biocode_get_ds_dosbiodata
   782                              <1>  assume ds:DOSGROUP
   783 00001102 C606[0000]03        <1> 	MOV	byte [RFLAG], ROMWRITE
   784 00001107 1F                  <1> 	pop ds
   785                              <1>  assume ds:UPB
   786 00001108 EB00                <1> 	JMP	READWRITETRACK
   787                              <1> 
   788                              <1> ;
   789                              <1> ; READWRITETRACK:
   790                              <1> ;
   791                              <1> ; INPUT:
   792                              <1> ;    DS:DI POINTS TO BDS FOR DRIVE
   793                              <1> ;    ES:BX POINTS TO WRITE PACKET
   794                              <1> ;    RFLAG - 2 FOR READ, 3 FOR WRITE
   795                              <1> ;
   796                              <1> 	PUBLIC READWRITETRACK
   797                              <1> READWRITETRACK PROC NEAR
   798                              <1>  assume ds:UPB, es:nothing, ss:nothing
   799 0000110A 1E                  <1> 	push ds
   800 0000110B E8(0000)            <1> 	call biocode_get_ds_dosbiodata
   801                              <1>  assume ds:DOSGROUP
   802 0000110E 268B4703            <1> 	MOV	AX, WORD PTR [ES:BX + TRWP_CYLINDER]
   803 00001112 A3[0000]            <1> 	MOV	[CURTRK], AX
   804 00001115 268B4701            <1> 	MOV	AX, WORD PTR [ES:BX + TRWP_HEAD]
   805                              <1> 
   806                              <1> ;	****** ASSUMPTION ******
   807                              <1> ;	WE ASSUME THAT WE HAVE LESS THAN 256 HEADS, AND THAT THE REQUEST
   808                              <1> ;	HEADER DATA STRUCTURE IS UNNECCESSARILY BIG
   809 00001119 A2[0000]            <1> 	MOV	[CURHD], AL
   810 0000111C 268B4705            <1> 	MOV	AX, WORD PTR [ES:BX + TRWP_FIRSTSECTOR]
   811 00001120 268B4F07            <1> 	MOV	CX, WORD PTR [ES:BX + TRWP_SECTORSTOREADWRITE]
   812 00001124 26C45F09            <1> 	LES	BX, [ES:BX + TRWP_TRANSFERADDRESS]
   813 00001128 1F                  <1> 	pop ds
   814                              <1>  assume ds:UPB
   815 00001129 E80100              <1> 	CALL	TRACKIO
   816 0000112C C3                  <1> 	RET
   817                              <1> READWRITETRACK ENDP
   818                              <1> 
   819                              <1> 
   820                              <1> ;
   821                              <1> ; TRACKIO:
   822                              <1> ;    PERFORMS TRACK READ/WRITE/VERIFY
   823                              <1> ;
   824                              <1> ;   INPUT:
   825                              <1> ;      RFLAG	- 2 = READ
   826                              <1> ;		  3 = WRITE
   827                              <1> ;		  4 = VERIFY
   828                              <1> ;      AX	- INDEX INTO TRACK TABLE OF FIRST SECTOR TO IO
   829                              <1> ;      CX	- NUMBER OF SECTORS TO IO
   830                              <1> ;      ES:BX	- TRANSFER ADDRESS
   831                              <1> ;      DS:DI	- POINTER TO BDS
   832                              <1> ;      CURTRK	- CURRENT CYLINDER
   833                              <1> ;      CURHD	- CURRENT HEAD
   834                              <1> ;
   835                              <1> 	PUBLIC TRACKIO
   836                              <1> TRACKIO PROC NEAR
   837                              <1>  assume ds:DOSGROUP, es:nothing, ss:nothing
   838                              <1> ; PROCEDURE `DISK' WILL POP STACK TO SPSAV AND RETURN IF ERROR
   839 0000112D 1E                  <1> 	push ds
   840 0000112E E8(0000)            <1> 	call biocode_get_ds_dosbiodata
   841                              <1>  assume ds:DOSGROUP
   842 00001131 8926[0000]          <1> 	MOV	[SPSAV], SP
   843 00001135 8306[0000]02        <1> 	add word [SPSAV], 2		; discard ds off the stack
   844 0000113A 1F                  <1> 	pop ds
   845                              <1>  assume ds:UPB
   846                              <1> ; ENSURE CORRECT DISK IS IN DRIVE
   847 0000113B E81BF3              <1> 	CALL	CHECKSINGLE
   848                              <1> ; SEE IF WE HAVE ALREADY SET THE DISK BASE TABLE
   849 0000113E 1E                  <1> 	push ds
   850 0000113F E8(0000)            <1> 	call biocode_get_ds_dosbiodata
   851                              <1>  assume ds:DOSGROUP
   852 00001142 803E[FF00]01        <1> 	CMP	BYTE PTR [MEDIA_SET_FOR_FORMAT],1
   853 00001147 1F                  <1> 	pop ds
   854                              <1>  assume ds:UPB
   855 00001148 7407                <1> 	JZ	DPTALREADYSET
   856                              <1> ;
   857                              <1> ; SET UP TABLES AND VARIABLES FOR I/O
   858                              <1> ;
   859 0000114A 5051                <1> 	SAVEREG <AX,CX>
   860 0000114C E823F6              <1> 	CALL	IOSETUP
   861 0000114F 5958                <1> 	RESTOREREG <CX,AX>
   862                              <1> ;
   863                              <1> ; POINT SI AT THE TABLE ENTRY OF THE FIRST SECTOR TO BE IO'D
   864                              <1> ;
   865                              <1> DPTALREADYSET:
   866 00001151 BE[0200]            <1> 	MOV	SI, OFFSET TRACKTABLE
   867 00001154 D1E0                <1> 	SHL	AX, 1
   868 00001156 D1E0                <1> 	SHL	AX, 1
   869 00001158 01C6                <1> 	ADD	SI, AX
   870                              <1> ;
   871                              <1> ; WE WANT:
   872                              <1> ;    CX TO BE THE NUMBER OF TIMES WE HAVE TO LOOP
   873                              <1> ;    DX TO BE THE NUMBER OF SECTORS WE READ ON EACH ITERATION
   874 0000115A BA0100              <1> 	MOV	DX, 1
   875 0000115D F745230800          <1> 	TEST	WORD PTR [DI + FLAGS], GOOD_TRACKLAYOUT
   876 00001162 7402                <1> 	JZ	IONEXTSECTOR
   877                              <1> 
   878                              <1> ; HEY! WE CAN READ ALL THE SECTORS IN ONE BLOW
   879 00001164 87D1                <1> 	XCHG	DX, CX
   880                              <1> 
   881                              <1> IONEXTSECTOR:
   882 00001166 51                  <1> 	PUSH	CX
   883 00001167 52                  <1> 	PUSH	DX
   884 00001168 1E                  <1> 	push ds
   885 00001169 E8(0000)            <1> 	call biocode_get_ds_dosbiodata
   886                              <1>  assume ds:DOSGROUP
   887                              <1> ; SKIP OVER THE CYLINDER AND HEAD IN THE TRACK TABLE
   888 0000116C 46                  <1> 	INC	SI
   889 0000116D 46                  <1> 	INC	SI
   890                              <1> ; GET SECTOR ID FROM TRACK TABLE
   891 0000116E AC                  <1> 	LODSb
   892 0000116F A2[0000]            <1> 	MOV	[CURSEC], AL
   893                              <1> ;*** For a Fixed disk multi-track disk I/O - J.K. 4/14/86
   894                              <1> ;Assumptions: 1). In the input CX (# of sectors to go) to TRACKIO, only CL is
   895                              <1> ;valid.  2). Sector size should be set to 512 bytes. 3). GOODTRACKLAYOUT.
   896                              <1> ;
   897 00001172 1F                  <1> 	pop ds
   898                              <1>  assume ds:UPB
   899 00001173 1E                  <1> 	push ds
   900 00001174 F745230100          <1> 	test	word ptr [di + Flags], fNon_Removable	;Fixed disk? - J.K.
   901 00001179 7419                <1> 	jz	IOREMOVABLE				;no -J.K.
   902 0000117B E8(0000)            <1> 	call biocode_get_ds_dosbiodata
   903                              <1>  assume ds:DOSGROUP
   904 0000117E F706[0000]8000      <1> 	test	word [MulTrk_Flag], MULTRK_ON		;AN002; Allow multi-track operation?
   905                              <1> IORemovable equ IOREMOVABLE	; NASM port label
   906 00001184 740E                <1> 	jz	IORemovable				;AN002; No, don't do that.
   907                              <1> seccnt equ SECCNT	; NASM port label
   908 00001186 8916[0000]          <1> 	mov	[seccnt], dx 			;# of sectors to I/O -J.K.
   909 0000118A 89D0                <1> 	mov	ax, dx					;J.K.
   910 0000118C 1F                  <1> 	pop ds
   911                              <1>  assume ds:UPB
   912                              <1> disk equ DISK	; NASM port label
   913 0000118D E893F7              <1> 	call	disk					;J.K.
   914 00001190 5A                  <1> 	pop	dx					;J.K.
   915 00001191 59                  <1> 	pop	cx					;J.K.
   916 00001192 F8                  <1> 	clc						;J.K.
   917 00001193 C3                  <1> 	ret						;J.K.
   918                              <1> IOREMOVABLE:						;J.K.
   919                              <1> ; GET SECTOR SIZE INDEX FROM TRACK TABLE AND SAVE IT
   920 00001194 E8(0000)            <1> 	call biocode_get_ds_dosbiodata
   921                              <1>  assume ds:DOSGROUP
   922 00001197 AC                  <1> 	LODSb
   923 00001198 8F06[0000]          <1> 	pop word [dosbiodata_temp_ds]
   924 0000119C 50                  <1> 	PUSH	AX
   925                              <1> ; PATCH SECTOR SIZE IN DPT
   926 0000119D 56                  <1> 	PUSH	SI
   927 0000119E 1E                  <1> 	PUSH	DS
   928 0000119F C536[0000]          <1> 	LDS	SI, [DPT]
   929                              <1>  assume ds:nothing
   930 000011A3 884403              <1> 	MOV	BYTE PTR [SI + DISK_SECTOR_SIZ],AL
   931 000011A6 1E                  <1> 	push ds
   932 000011A7 E8(0000)            <1> 	call biocode_get_ds_dosbiodata
   933                              <1>  assume ds:DOSGROUP
   934 000011AA A0[0000]            <1> 	MOV	AL,[EOT]
   935 000011AD 1F                  <1> 	pop ds
   936                              <1>  assume ds:nothing
   937 000011AE 884404              <1> 	MOV	[SI + DISK_EOT],AL	; SET UP THE MAX NUMBER OF SEC/TRACK
   938 000011B1 1F                  <1> 	POP	DS
   939                              <1>  assume ds:DOSGROUP
   940 000011B2 88D0                <1> 	MOV	AL, DL
   941                              <1> DOTHEIO:
   942 000011B4 A3[0000]            <1> 	MOV	[SECCNT],AX		; SET UP THE COUNT OF SECTORS TO I/O
   943 000011B7 8E1E[0000]          <1> 	mov ds, word [dosbiodata_temp_ds]
   944                              <1>  assume ds:UPB
   945 000011BB E865F7              <1> 	CALL	DISK
   946                              <1> ; ADVANCE BUFFER POINTER BY ADDING SECTOR SIZE
   947 000011BE 5E                  <1> 	POP	SI
   948 000011BF 58                  <1> 	POP	AX
   949 000011C0 E82200              <1> 	CALL	SECTORSIZEINDEXTOSECTORSIZE
   950 000011C3 01C3                <1> 	ADD	BX, AX
   951 000011C5 5A                  <1> 	POP	DX
   952 000011C6 59                  <1> 	POP	CX
   953 000011C7 E29D                <1> 	LOOP	IONEXTSECTOR
   954 000011C9 1E                  <1> 	push ds
   955 000011CA E8(0000)            <1> 	call biocode_get_ds_dosbiodata
   956                              <1>  assume ds:DOSGROUP
   957 000011CD 803E[FF00]01        <1> 	cmp	byte ptr [Media_Set_For_Format], 1	;AN001;
   958 000011D2 1F                  <1> 	pop ds
   959                              <1>  assume ds:UPB
   960 000011D3 7403                <1> 	je	No_Need_Done				;AN001;
   961 000011D5 E8E7F5              <1> 	CALL	msbiodisk_DONE		; SET TIME OF LAST ACCESS, AND RESET
   962                              <1> No_Need_Done:				;AN001;
   963 000011D8 F8                  <1> 	CLC				; ENTRIES IN DPT.
   964 000011D9 C3                  <1> 	RET
   965                              <1> 
   966                              <1> TRACKIO ENDP
   967                              <1> ;
   968                              <1> ; THE SECTOR SIZE IN BYTES NEEDS TO BE CONVERTED TO AN INDEX VALUE FOR THE IBM
   969                              <1> ; ROM. (0=>128, 1=>256,2=>512,3=>1024). IT IS ASSUMED THAT ONLY THESE VALUES
   970                              <1> ; ARE PERMISSIBLE.
   971                              <1> ; ON INPUT   AX CONTAINS SECTOR SIZE IN BYTES
   972                              <1> ; ON OUTPUT  AL CONTAINS INDEX
   973                              <1> ;
   974                              <1> 	PUBLIC SECTORSIZETOSECTORINDEX
   975                              <1> SECTORSIZETOSECTORINDEX PROC NEAR
   976 000011DA 80FC02              <1> 	CMP	AH,2			; EXAMINE UPPER BYTE ONLY
   977 000011DD 7703                <1> 	JA	ONEK
   978 000011DF 88E0                <1> 	MOV	AL,AH			; VALUE IN AH IS THE INDEX!
   979 000011E1 C3                  <1> 	RET
   980                              <1> ONEK:
   981 000011E2 B003                <1> 	MOV	AL,3
   982 000011E4 C3                  <1> 	RET
   983                              <1> SECTORSIZETOSECTORINDEX ENDP
   984                              <1> 
   985                              <1> SECTORSIZEINDEXTOSECTORSIZE PROC NEAR
   986 000011E5 88C1                <1> 	MOV	CL, AL
   987 000011E7 B88000              <1> 	MOV	AX,128
   988 000011EA D3E0                <1> 	SHL	AX, CL
   989 000011EC C3                  <1> 	RET
   990                              <1> SECTORSIZEINDEXTOSECTORSIZE ENDP
   991                              <1> 
   992                              <1> ;
   993                              <1> ; SET UP THE ROM FOR FORMATTING.
   994                              <1> ; WE HAVE TO TELL THE ROM BIOS WHAT TYPE OF DISK IS IN THE DRIVE.
   995                              <1> ; ON INPUT   - DS:DI - POINTS TO BDS
   996                              <1> ;
   997                              <1> 	PUBLIC SETDASD
   998                              <1> SETDASD:
   999                              <1>  assume ds:UPB, es:nothing, ss:nothing
  1000                              <1> ; SEE IF WE HAVE PREVIOUSLY SET DASD TYPE
  1001                              <1> ;SB33114******************************************************************
  1002 000011ED 1E                  <1> 	push ds
  1003 000011EE E8(0000)            <1> 	call biocode_get_ds_dosbiodata
  1004                              <1>  assume ds:DOSGROUP
  1005 000011F1 803E[0001]01        <1> 	cmp	byte [Had_Format_Error],1
  1006 000011F6 1F                  <1> 	pop ds
  1007                              <1>  assume ds:UPB
  1008 000011F7 740C                <1> 	je	DoSetDasd
  1009                              <1> ;SB33114******************************************************************
  1010 000011F9 F745238000          <1> 	TEST	WORD PTR [DI + FLAGS], SET_DASD_TRUE
  1011 000011FE 7452                <1> 	JZ	DASDHASBEENSET
  1012 00001200 8165237FFF          <1> 	AND	WORD PTR [DI + FLAGS], ~ SET_DASD_TRUE
  1013                              <1> ;SB33115******************************************************************
  1014                              <1> DoSetDasd:
  1015 00001205 1E                  <1> 	push ds
  1016 00001206 E8(0000)            <1> 	call biocode_get_ds_dosbiodata
  1017                              <1>  assume ds:DOSGROUP
  1018 00001209 C606[0001]00        <1> 	mov	byte [Had_Format_Error],0 ;reset it
  1019                              <1> ;SB33115******************************************************************
  1020 0000120E C606[0000]50        <1> 	MOV	byte [GAP_PATCH],50H	; FORMAT GAP FOR 48TPI DISKS
  1021 00001213 1F                  <1> 	pop ds
  1022                              <1>  assume ds:UPB
  1023 00001214 B004                <1> 	MOV	AL,4
  1024 00001216 807D2202            <1> 	CMP	BYTE PTR [DI + FORMFACTOR],DEV_3INCH720KB
  1025 0000121A 741F                <1> 	JZ	DO_SET
  1026 0000121C 807D2201            <1> 	CMP	BYTE PTR [DI + FORMFACTOR], DEV_5INCH96TPI
  1027 00001220 7404                <1> 	JZ	GOT_BIG
  1028 00001222 B001                <1> 	MOV	AL,1			; 160/320K IN A 160/320K DRIVE
  1029 00001224 EB15                <1> 	JMP	SHORT DO_SET
  1030                              <1> GOT_BIG:
  1031 00001226 B002                <1> 	MOV	AL,2			; 160/320K IN A 1.2 MEG DRIVE
  1032 00001228 1E                  <1> 	push ds
  1033 00001229 E8(0000)            <1> 	call biocode_get_ds_dosbiodata
  1034                              <1>  assume ds:DOSGROUP
  1035 0000122C 803E[FE00]00        <1> 	CMP	byte [MEDIATYPE], 0
  1036 00001231 7507                <1> 	JNE	DO_SET_b
  1037 00001233 B003                <1> 	MOV	AL,3			; 1.2MEG IN A 1.2MEG DRIVE
  1038 00001235 C606[0000]54        <1> 	MOV	byte [GAP_PATCH],54H
  1039                              <1> DO_SET_b:
  1040 0000123A 1F                  <1> 	pop ds
  1041                              <1>  assume ds:UPB
  1042                              <1> DO_SET:
  1043 0000123B 1E                  <1> 	push	ds				;AN003;
  1044 0000123C 56                  <1> 	push	si				;AN003;
  1045                              <1> ;SB34IOCTL002****************************************************************
  1046                              <1> ;SB	Get the disk parameter table address (dword address) from the location
  1047                              <1> ;SB	0:[DSKADR] and fix the head settle time in this to be 0fh. 4 LOCS
  1048                              <1> 
  1049 0000123D 31F6                <1> 	xor	si, si
  1050 0000123F 8EDE                <1> 	mov	ds, si
  1051                              <1>  assume ds:IVT
  1052 00001241 C5367800            <1> 	lds	si, [DSKADR]
  1053                              <1>  assume ds:nothing
  1054 00001245 C644090F            <1> 	mov	byte [si + DISK_HEAD_STTL], 0Fh
  1055                              <1> ;SB34IOCTL002****************************************************************
  1056 00001249 5E                  <1> 	pop	si				;AN003;
  1057 0000124A 1F                  <1> 	pop	ds				;AN003;
  1058                              <1>  assume ds:UPB
  1059                              <1> ;SB33032******************************************************************
  1060 0000124B B417                <1> 	mov	AH, 17h 		; set command to Set DASD type;SB ;3.30*
  1061 0000124D 8A5504              <1> 	mov	DL, [di + DriveNum]	; set drive number	      ;SB ;3.30*
  1062 00001250 CD13                <1> 	int	13h			; call rom-bios 	      ;SB ;3.30*
  1063                              <1> ;SB33032******************************************************************
  1064                              <1> DASDHASBEENSET:
  1065 00001252 8A6513              <1> 	MOV	AH,BYTE PTR [DI + SECLIM]
  1066 00001255 1E                  <1> 	push ds
  1067 00001256 E8(0000)            <1> 	call biocode_get_ds_dosbiodata
  1068                              <1>  assume ds:DOSGROUP
  1069 00001259 8826[0000]          <1> 	MOV	[FORMT_EOT],AH
  1070 0000125D 1F                  <1> 	pop ds
  1071                              <1>  assume ds:UPB
  1072 0000125E C3                  <1> 	RET
  1073                              <1> 
  1074                              <1> ;
  1075                              <1> ; THIS ROUTINE IS CALLED IF AN ERROR OCCURS WHILE FORMATTING OR VERIFYING.
  1076                              <1> ; IT RESETS THE DRIVE, AND DECREMENTS THE RETRY COUNT.
  1077                              <1> ; ON ENTRY - DS:DI - POINTS TO BDS FOR THE DRIVE
  1078                              <1> ;	     BP    - CONTAINS RETRY COUNT
  1079                              <1> ; ON EXIT    FLAGS INDICATE RESULT OF DECREMENTING RETRY COUNT
  1080                              <1> ;
  1081                              <1> AGAIN:
  1082                              <1>  assume ds:UPB, es:nothing, ss:nothing
  1083 0000125F E80200              <1> 	CALL	RESETDISK
  1084                              <1> 
  1085                              <1> ;(deleted section here, as requested by D.L.)
  1086                              <1> 
  1087 00001262 4D                  <1> 	DEC	BP			; DECREMENT RETRY COUNT
  1088 00001263 C3                  <1> 	RET
  1089                              <1> 
  1090                              <1> 
  1091                              <1> ; RESET THE DRIVE.
  1092                              <1> ; WE ALSO SET [STEP_DRV] TO -1 TO FORCE THE MAIN DISK ROUTINE TO USE THE
  1093                              <1> ; SLOW HEAD SETTLE TIME FOR THE NEXT OPERATION. THIS IS BECAUSE THE RESET
  1094                              <1> ; OPERATION MOVES THE HEAD TO CYLINDER 0, SO WE NEED TO DO A SEEK THE NEXT
  1095                              <1> ; TIME AROUND - THERE IS A PROBLEM WITH 3.5" DRIVES IN THAT THE HEAD DOES
  1096                              <1> ; NOT SETTLE DOWN IN TIME, EVEN FOR READ OPERATIONS!!
  1097                              <1> ;
  1098                              <1> 	PUBLIC RESETDISK
  1099                              <1> RESETDISK:
  1100                              <1>  assume ds:UPB, es:nothing, ss:nothing
  1101 00001264 50                  <1> 	SAVEREG <AX>
  1102                              <1> ;SB33033******************************************************************
  1103 00001265 30E4                <1> 	xor	AH, AH			; set command to reset disk   ;SB ;3.30*
  1104 00001267 CD13                <1> 	int	13h			; call the rom-bios	      ;SB ;3.30*
  1105                              <1> ;SB33033******************************************************************
  1106 00001269 1E                  <1> 	push ds
  1107 0000126A E8(0000)            <1> 	call biocode_get_ds_dosbiodata
  1108                              <1>  assume ds:DOSGROUP
  1109 0000126D C606[0000]FF        <1> 	MOV	byte [STEP_DRV],-1	; ZAP UP THE SPEED
  1110 00001272 1F                  <1> 	pop ds
  1111                              <1>  assume ds:UPB
  1112 00001273 58                  <1> 	RESTOREREG <AX>
  1113 00001274 C3                  <1> 	RET
  1114                              <1> 
  1115                              <1> ;
  1116                              <1> ; THIS ROUTINE SETS UP THE DRIVE PARAMETER TABLE WITH THE VALUES NEEDED FOR
  1117                              <1> ; FORMAT, DOES AN INT 13. VALUES IN DPT ARE RESTORED AFTER A VERIFY IS DONE.
  1118                              <1> ;
  1119                              <1> ; ON ENTRY  -	DS:DI - POINTS TO BDS FOR THE DRIVE
  1120                              <1> ;		ES:BX - POINTS TO TRKBUF
  1121                              <1> ;		AL    - NUMBER OF SECTORS
  1122                              <1> ;		AH    - INT 13 FUNCTION CODE
  1123                              <1> ;		CL    - SECTOR NUMBER FOR VERIFY
  1124                              <1> ; ON EXIT   -	DS,DI,ES,BX REMAIN UNCHANGED.
  1125                              <1> ;		AX AND FLAGS ARE THE RESULTS OF THE INT 13
  1126                              <1> ;
  1127                              <1> 	PUBLIC TO_ROM
  1128                              <1> TO_ROM:
  1129 00001275 1E57065356          <1> 	SAVEREG <DS,DI,ES,BX,SI>
  1130 0000127A 1E                  <1> 	push ds
  1131 0000127B E8(0000)            <1> 	call biocode_get_ds_dosbiodata
  1132                              <1>  assume ds:DOSGROUP
  1133 0000127E F606[0000]01        <1> 	TEST	BYTE PTR [NEW_ROM],1
  1134 00001283 1F                  <1> 	pop ds
  1135                              <1>  assume ds:UPB
  1136 00001284 753D                <1> 	JNZ	GOT_VALID_DPT
  1137 00001286 50                  <1> 	PUSH	AX
  1138 00001287 8CDA                <1> 	MOV	DX,DS			; SAVE DS:DI-> BDS
  1139 00001289 31C0                <1> 	XOR	AX,AX
  1140 0000128B 8ED8                <1> 	MOV	DS,AX
  1141                              <1>  assume ds:IVT
  1142 0000128D C5367800            <1> 	LDS	SI,[DSKADR]	; GET POINTER TO DISK BASE TABLE
  1143                              <1>  assume ds:nothing
  1144 00001291 06                  <1> 	push es
  1145 00001292 E8(0000)            <1> 	call biocode_get_es_dosbiodata
  1146                              <1>  assume es:DOSGROUP
  1147 00001295 268936[0000]        <1> 	MOV	WORD PTR [es:DPT],SI
  1148 0000129A 268C1E[0200]        <1> 	MOV	WORD PTR [es:DPT+2],DS		; SAVE POINTER TO TABLE
  1149 0000129F 26A0[0000]          <1> 	MOV	AL,[es:FORMT_EOT]
  1150 000012A3 884404              <1> 	MOV	[SI + DISK_EOT],AL
  1151 000012A6 26A0[0000]          <1> 	MOV	AL,[es:GAP_PATCH]
  1152 000012AA 884407              <1> 	MOV	[SI + DISK_FORMT_GAP],AL	; IMPORTANT FOR FORMAT
  1153 000012AD C644090F            <1> 	MOV	byte [SI + DISK_HEAD_STTL],15	; ASSUME WE ARE DOING A SEEK OPERATION
  1154                              <1> ; SET UP MOTOR START CORRECTLY FOR 3.5" DRIVES.
  1155 000012B1 8EC2                <1> 	MOV	ES,DX
  1156                              <1>  assume es:UPB
  1157 000012B3 26807D2202          <1> 	CMP	BYTE PTR [ES:DI + FORMFACTOR],FFSMALL	; IS IT A 3.5" DRIVE?
  1158 000012B8 7505                <1> 	JNZ	MOTORSTRTOK
  1159 000012BA B004                <1> 	MOV	AL,4
  1160 000012BC 86440A              <1> 	XCHG	AL,[SI + DISK_MOTOR_STRT]
  1161                              <1> MOTORSTRTOK:
  1162 000012BF 07                  <1> 	POP	ES
  1163                              <1>  assume es:nothing
  1164                              <1> ;----------------------------------------------------------------------------
  1165                              <1> ; THE FOLLOWING TWO LINES ARE NO LONGER NECESSARY SINCE THEY ARE ONLY USEFUL
  1166                              <1> ; FOR A VERIFY OPERATION.
  1167                              <1> ;	MOV	AL,[CS:SECTOR_SIZ_IND]
  1168                              <1> ;	MOV	[SI].DISK_SECTOR_SIZ,AL ; IMPORTANT FOR VERIFY
  1169                              <1> ;----------------------------------------------------------------------------
  1170 000012C0 8EDA                <1> 	MOV	DS,DX			; RESTORE DS:DI-> BDS
  1171                              <1>  assume ds:UPB
  1172 000012C2 58                  <1> 	POP	AX
  1173                              <1> GOT_VALID_DPT:
  1174                              <1> ;SB33034*******************************************************************
  1175                              <1> trknum equ TRKNUM	; NASM port label
  1176 000012C3 1E                  <1> 	push ds
  1177 000012C4 E8(0000)            <1> 	call biocode_get_ds_dosbiodata
  1178                              <1>  assume ds:DOSGROUP
  1179 000012C7 8B16[0000]          <1> 	mov	dx, [trknum]		; set track number	      ;SB ;3.30*
  1180 000012CB 88D5                <1> 	mov	ch,dl			; set low 8 bits in ch	      ;SB ;3.30*
  1181 000012CD 8A36[0000]          <1> 	mov	DH, [HDNUM]		; set head number	      ;SB ;3.30*
  1182 000012D1 1F                  <1> 	pop ds
  1183                              <1>  assume ds:UPB
  1184 000012D2 8A5504              <1> 	mov	DL, [di + DriveNum]	; set drive number	      ;SB ;3.30*
  1185 000012D5 CD13                <1> 	int	13h			; call the rom-bios  routines ;SB ;3.30*
  1186                              <1> ;SB33034*******************************************************************
  1187 000012D7 5E5B075F1F          <1> 	RESTOREREG <SI,BX,ES,DI,DS>
  1188                              <1>  assume ds:UPB, es:nothing, ss:nothing
  1189 000012DC C3                  <1> 	RET
  1190                              <1> 
  1191                              <1> ;
  1192                              <1> ; GET THE OWNER OF THE PHYSICAL DRIVE REPRESENTED BY THE LOGICAL DRIVE IN BL.
  1193                              <1> ; THE ASSUMPTION IS THAT WE **ALWAYS** KEEP TRACK OF THE OWNER OF A DRIVE!!
  1194                              <1> ; IF THIS IS NOT THE CASE, THE SYSTEM MAY HANG, JUST FOLLOWING THE LINKED LIST.
  1195                              <1> ;
  1196                              <1> 	PUBLIC	IOCTL$GETOWN
  1197                              <1> IOCTL$GETOWN:
  1198 000012DD E829F1              <1> 	CALL	SETDRIVE
  1199                              <1>  assume ds:UPB, es:nothing, ss:nothing
  1200 000012E0 7303E9(0000)        <1> 	jc DSK$UNKNOWN
  1201 000012E5 8A4504              <1> 	MOV	AL,BYTE PTR [DI + DRIVENUM]	; GET PHYSICAL DRIVE NUMBER
  1202 000012E8 E8(0000)            <1> 	call biocode_get_ds_dosbiodata
  1203                              <1>  assume ds:DOSGROUP
  1204 000012EB C53E[0000]          <1> 	lds di, [START_BDS]
  1205                              <1>  assume ds:UPB
  1206                              <1> OWN_LOOP:
  1207 000012EF 83FFFF              <1> 	cmp di, -1
  1208 000012F2 7503E9(0000)        <1> 	je DSK$UNKNOWN
  1209 000012F7 384504              <1> 	CMP	BYTE PTR [DI + DRIVENUM],AL
  1210 000012FA 7507                <1> 	JNE	GETNEXTBDS
  1211 000012FC F745232000          <1> 	TEST	WORD PTR [DI + FLAGS],FI_OWN_PHYSICAL
  1212 00001301 7504                <1> 	JNZ	DONE_GETOWN
  1213                              <1> GETNEXTBDS:
  1214 00001303 C53D                <1> 	lds di, [DI + LINK]
  1215 00001305 EBE8                <1> 	JMP	SHORT OWN_LOOP
  1216                              <1> DONE_GETOWN:
  1217 00001307 EB2A                <1> 	JMP	SHORT EXIT_OWN
  1218                              <1> 
  1219                              <1> ;
  1220                              <1> ; SET THE OWNERSHIP OF THE PHYSICAL DRIVE REPRESENTED BY THE LOGICAL DRIVE IN
  1221                              <1> ; BL TO BL.
  1222                              <1> ;
  1223                              <1> 	PUBLIC IOCTL$SETOWN
  1224                              <1> IOCTL$SETOWN:
  1225 00001309 E8FDF0              <1> 	CALL	SETDRIVE
  1226                              <1>  assume ds:UPB, es:nothing, ss:nothing
  1227 0000130C 7303E9(0000)        <1> 	jc DSK$UNKNOWN
  1228 00001311 1E                  <1> 	push ds
  1229 00001312 E8(0000)            <1> 	call biocode_get_ds_dosbiodata
  1230                              <1>  assume ds:DOSGROUP
  1231 00001315 C606[0000]01        <1> 	MOV	BYTE PTR [FSETOWNER],1		; SET FLAG FOR CHECKSINGLE TO
  1232 0000131A 1F                  <1> 	pop ds
  1233                              <1>  assume ds:UPB
  1234                              <1> 						; LOOK AT.
  1235 0000131B E83BF1              <1> 	CALL	CHECKSINGLE			; SET OWNERSHIP OF DRIVE
  1236 0000131E 1E                  <1> 	push ds
  1237 0000131F E8(0000)            <1> 	call biocode_get_ds_dosbiodata
  1238                              <1>  assume ds:DOSGROUP
  1239 00001322 C606[0000]00        <1> 	MOV	BYTE PTR [FSETOWNER],0		; RESET FLAG
  1240 00001327 1F                  <1> 	pop ds
  1241                              <1>  assume ds:UPB
  1242 00001328 31DB                <1> 	XOR	BX,BX
  1243 0000132A 8EC3                <1> 	MOV	ES,BX
  1244                              <1>  assume es:IVT
  1245 0000132C B1FF                <1> 	MOV	CL,-1
  1246 0000132E 26880E0405          <1> 	MOV	BYTE PTR [ES:LSTDRV],CL 	; SET UP SDSB AS WELL
  1247                              <1> 
  1248                              <1> EXIT_OWN:
  1249                              <1>  assume ds:UPB, es:nothing, ss:nothing
  1250                              <1> ; IF THERE IS ONLY ONE LOGICAL DRIVE ASSIGNED TO THIS PHYSICAL DRIVE, RETURN
  1251                              <1> ; 0 TO USER TO INDICATE THIS.
  1252 00001333 30C9                <1> 	XOR	CL,CL
  1253 00001335 F745231000          <1> 	TEST	WORD PTR [DI + FLAGS],FI_AM_MULT
  1254 0000133A 7404                <1> 	JZ	EXIT_NO_MULT
  1255 0000133C 8A4D05              <1> 	MOV	CL,BYTE PTR [DI + DRIVELET]	; GET LOGICAL DRIVE NUMBER
  1256 0000133F 41                  <1> 	inc cx					; GET IT 1-BASED
  1257                              <1> EXIT_NO_MULT:
  1258 00001340 E8(0000)            <1> 	call biocode_get_ds_dosentry		; PTRSAV in DOSENTRY
  1259                              <1>  assume ds:DOSENTRYGROUP
  1260 00001343 C51E[0000]          <1> 	lds bx, [PTRSAV]
  1261                              <1>  assume ds:nothing
  1262 00001347 884F01              <1> 	MOV	BYTE PTR [BX + UNIT],CL
  1263 0000134A E9(0000)            <1> 	JMP	EXIT
  1264                              <1> 
  1265                              <1> 
  1266                              <1> ;
  1267                              <1> ; MOVES THE OLD DPT THAT HAD BEEN SAVED IN TEMPDPT BACK TO DPT. THIS IS DONE
  1268                              <1> ; ONLY IF THE FIRST BYTE OF TEMPDPT IS NOT -1.
  1269                              <1> ; ALL REGISTERS (INCLUDING FLAGS) ARE PRESERVED.
  1270                              <1> ;
  1271                              <1> 	PUBLIC RESTOREOLDDPT
  1272                              <1> RESTOREOLDDPT:
  1273                              <1>  assume ds:nothing, es:nothing, ss:nothing
  1274                              <1> ; IF WE HAVE ALREADY RESTORED THE DISK BASE TABLE EARLIER, DO NOT DO IT
  1275                              <1> ; AGAIN.
  1276 0000134D 50                  <1> 	PUSH	AX
  1277 0000134E 30C0                <1> 	XOR	AL,AL
  1278                              <1> ; RESET FLAG AND GET CURRENT FLAG SETTING
  1279 00001350 1E                  <1> 	push ds
  1280 00001351 E8(0000)            <1> 	call biocode_get_ds_dosbiodata
  1281                              <1>  assume ds:DOSGROUP
  1282 00001354 A2[0001]            <1> 	mov	[Had_Format_Error],al
  1283 00001357 8606[FF00]          <1> 	XCHG	BYTE PTR [MEDIA_SET_FOR_FORMAT],AL
  1284 0000135B 84C0                <1> 	test	AL,AL
  1285 0000135D 7416                <1> 	JZ	DONTRESTORE
  1286 0000135F 5606                <1> 	SAVEREG <SI,ES>
  1287 00001361 C536[0201]          <1> 	LDS	SI,[TEMPDPT]
  1288                              <1>  assume ds:nothing
  1289 00001365 31C0                <1> 	XOR	AX,AX
  1290 00001367 8EC0                <1> 	MOV	ES,AX				; HAVE ES -> SEGMENT 0
  1291                              <1>  assume es:IVT
  1292 00001369 2689367800          <1> 	MOV	WORD PTR [ES:DSKADR],SI
  1293 0000136E 268C1E7A00          <1> 	MOV	WORD PTR [ES:DSKADR+2],DS
  1294 00001373 075E                <1> 	RESTOREREG <ES,SI>
  1295                              <1>  assume es:nothing
  1296                              <1> DONTRESTORE:
  1297 00001375 1F                  <1> 	pop ds
  1298                              <1>  assume ds:nothing
  1299 00001376 58                  <1> 	POP	AX
  1300 00001377 F8                  <1> 	CLC				; CLEAR CARRY
  1301 00001378 C3                  <1> 	RET
  1302                              <1> 
  1303                              <1> ;******************************************************************************
  1304                              <1> ;AN000;  Get Media ID
  1305                              <1> ;*******************************************************************************
  1306                              <1> ;									       *
  1307                              <1> ; Function: Get the volume label, the system id and the serial number from     *
  1308                              <1> ;	    the media that has the extended boot record.		       *
  1309                              <1> ;	    For the conventional media, this routine will return "Unknown      *
  1310                              <1> ;	    media type" error to DOS.                                          *
  1311                              <1> ;									       *
  1312                              <1> ; Input :   DS:DI -> BDS table for this drive.				       *
  1313                              <1> ;	    ES:BX -> Request packet (= A_Media_ID_INFO structure)	       *
  1314                              <1> ;									       *
  1315                              <1> ; Output:   The request packet filled with the information, if not carry.      *
  1316                              <1> ;	    If carry set, then AL contains the device driver error number      *
  1317                              <1> ;	    that will be returned to DOS.				       *
  1318                              <1> ;	    Register DS,DX,AX,CX,DI,SI destroyed.			       *
  1319                              <1> ; Subroutines to be called:						       *
  1320                              <1> ;	BOOT_IO:NEAR							       *
  1321                              <1> ;									       *
  1322                              <1> ; Logic:								       *
  1323                              <1> ;	/*To recognize the extended boot record, this logic will actually  */  *
  1324                              <1> ;	/*access the boot sector even if it is a hard disk.		    */ *
  1325                              <1> ;	/*NOTE:the valid extended bpb is recognized by looking at the mediabyte*
  1326                              <1> ;	/*field of BPB and the extended Boot Signature. 		       *
  1327                              <1> ;									       *
  1328                              <1> ; {									       *
  1329                              <1> ;	Get logical drive number from BDS table;			       *
  1330                              <1> ;	RFLAG = Read operation; 					       *
  1331                              <1> ;	BOOT_IO;		 /*Get the media boot record into the buffer*/ *
  1332                              <1> ;	IF (no error) THEN						       *
  1333                              <1> ;	     IF (extended boot record) THEN				       *
  1334                              <1> ;		{ set Volume Label, Volume Serial number and System id	       *
  1335                              <1> ;		  of the Request packet to those of the boot record;	       *
  1336                              <1> ;		};							       *
  1337                              <1> ;	     ELSE		  /*Not an extended BPB */		       *
  1338                              <1> ;		{ set Register AL to "Unknown media.." error code;	       *
  1339                              <1> ;		  set Carry bit;					       *
  1340                              <1> ;		};							       *
  1341                              <1> ;	ELSE								       *
  1342                              <1> ;	     Exit;		 /*Already error code is set in the register AL*
  1343                              <1> ;									       *
  1344                              <1> ; Expected LOC: 40 (New)						       *
  1345                              <1> ;*******************************************************************************
  1346                              <1> 
  1347                              <1> GetMediaID	proc	near			;AN000;
  1348                              <1>  assume ds:UPB, es:nothing, ss:nothing
  1349 00001379 E8BB00              <1> 	call	Changeline_Chk			;AN010;
  1350 0000137C 8A4505              <1> 	mov	al, [DI + DRIVELET]		;AN000; logical drive number
  1351                              <1> RFlag equ RFLAG	; NASM port label
  1352 0000137F 1E                  <1> 	push ds
  1353 00001380 E8(0000)            <1> 	call biocode_get_ds_dosbiodata
  1354                              <1>  assume ds:DOSGROUP
  1355 00001383 C606[0000]02        <1> 	mov	byte [RFlag], ROMREAD		;AN000; read operation
  1356 00001388 E88E00              <1> 	call	Boot_IO				;AN000; read boot sector into DOSENTRY:DiskSector
  1357                              <1> ;	$IF	NC				;AN000;
  1358 0000138B 7228                <1> 	JC $IOCTL$IF1_pop_ds
  1359 0000138D E8(0000)            <1> 	call biocode_get_ds_dosentry	; DISKSECTOR in DOSENTRY
  1360                              <1>  assume ds:DOSENTRYGROUP
  1361                              <1> MediaByte equ MEDIABYTE	; NASM port label
  1362 00001390 8A0E[0000]          <1> 	   mov	   cl, [MediaByte]		;AN000; Mediabyte in BPB
  1363 00001394 80E1F0              <1> 	   and	   cl, 0F0h			;AN000;
  1364 00001397 80F9F0              <1> 	   cmp	   cl, 0F0h			;AN000; Is it a valid BPB?
  1365                              <1> ;	   $IF	   E,AND			;AN000;
  1366 0000139A 7516                <1> 	   JNE $IOCTL$IF2
  1367 0000139C 803E[0000]29        <1> 	      cmp   byte [Ext_Boot_Sig], EXT_BOOT_SIGNATURE ;AN000; =90h
  1368                              <1> ;	   $IF	   E				;AN000; Extended Boot Record
  1369 000013A1 750F                <1> 	   JNE $IOCTL$IF2
  1370 000013A3 BE[0000]            <1> 	      mov  si, offset Boot_Serial_L	;AN000; access with ds
  1371 000013A6 89DF                <1> 	      mov  di, bx			;AN000;
  1372 000013A8 83C702              <1> 	      add  di, MI_SERIAL		;AN000;
  1373 000013AB B91700              <1> 	      mov  cx, BOOT_SERIAL_SIZE+BOOT_VOLUME_LABEL_SIZE+BOOT_SYSTEM_ID_SIZE
  1374 000013AE F3A4                <1> 	      rep  movsb			;AN000;
  1375                              <1> ;	   $ELSE				;AN000;
  1376 000013B0 EB03                <1> 	   JMP SHORT $IOCTL$EN2
  1377                              <1> $IOCTL$IF2:
  1378 000013B2 B007                <1> 	      mov   al, ERROR_UNKNOWN_MEDIA	;AN000; =7
  1379 000013B4 F9                  <1> 	      stc				;AN000;
  1380                              <1> ;	   $ENDIF	;End Extended Boot Record check.
  1381                              <1> $IOCTL$EN2:
  1382                              <1> ;	$ENDIF	;Read boot sector failed. Hard error.
  1383                              <1> $IOCTL$IF1_pop_ds:
  1384 000013B5 1F                  <1> 	pop ds
  1385                              <1>  assume ds:UPB
  1386 000013B6 C3                  <1> 	ret					;AN000;
  1387                              <1> GetMediaID	endp
  1388                              <1> 
  1389                              <1> ;******************************************************************************
  1390                              <1> ;AN000;  Set Media ID
  1391                              <1> ;*******************************************************************************
  1392                              <1> ;									       *
  1393                              <1> ; Function: Set the volume label, the system id and the serial number of       *
  1394                              <1> ;	    the media that has the extended boot record.		       *
  1395                              <1> ;	    For the conventional media, this routine will return "Unknown      *
  1396                              <1> ;	    media.." error to DOS.                                             *
  1397                              <1> ;	    This routine will also set the corresponding informations in       *
  1398                              <1> ;	    the BDS table.						       *
  1399                              <1> ;									       *
  1400                              <1> ; Input :   DS:DI -> BDS table for this drive.				       *
  1401                              <1> ;	    ES:BX -> Request packet (= A_Media_ID_INFO structure)	       *
  1402                              <1> ;									       *
  1403                              <1> ; Output:   The extended boot record in the media will be set according to     *
  1404                              <1> ;	    the Request packet. 					       *
  1405                              <1> ;	    If carry set, then AL contains the device driver error number      *
  1406                              <1> ;	    that will be returned to DOS.				       *
  1407                              <1> ;									       *
  1408                              <1> ; Subroutines to be called:						       *
  1409                              <1> ;	BOOT_IO:NEAR							       *
  1410                              <1> ;									       *
  1411                              <1> ; Logic:								       *
  1412                              <1> ;									       *
  1413                              <1> ;									       *
  1414                              <1> ; {									       *
  1415                              <1> ;	Get Drive_Number from BDS;					       *
  1416                              <1> ;	RFLAG = "Read operation";					       *
  1417                              <1> ;	BOOT_IO;							       *
  1418                              <1> ;	IF (no error) THEN						       *
  1419                              <1> ;	     IF (extended boot record) THEN				       *
  1420                              <1> ;		{ set Volume Label, Volume Serial number and System id	       *
  1421                              <1> ;		  of the boot record to those of the Request packet;	       *
  1422                              <1> ;		  RFLAG = "Write operation";				       *
  1423                              <1> ;		  Get Drive Number from BDS;				       *
  1424                              <1> ;		  BOOT_IO;	  /*Write it back*/			       *
  1425                              <1> ;		};							       *
  1426                              <1> ;	     ELSE		  /*Not an extended BPB */		       *
  1427                              <1> ;		{ set Register AL to "Unknown media.." error code;	       *
  1428                              <1> ;		  set Carry bit;					       *
  1429                              <1> ;		  Exit; 	 /*Return back to caller */		       *
  1430                              <1> ;		};							       *
  1431                              <1> ;	ELSE								       *
  1432                              <1> ;	     Exit;		 /*Already error code is set */ 	       *
  1433                              <1> ;									       *
  1434                              <1> ; Expected LOC: 45 (New)						       *
  1435                              <1> ;*******************************************************************************
  1436                              <1> 
  1437                              <1> SetMediaID	proc	near
  1438                              <1>  assume ds:UPB, es:nothing, ss:nothing
  1439 000013B7 E87D00              <1> 	call	Changeline_Chk			;AN010;
  1440 000013BA 8A4505              <1> 	mov	al, [DI + DRIVELET]		;AN000; logical drive number
  1441 000013BD 88C2                <1> 	mov	dl, al				;AN000; save it for the time being.
  1442 000013BF 1E                  <1> 	push ds
  1443 000013C0 E8(0000)            <1> 	call biocode_get_ds_dosbiodata
  1444                              <1>  assume ds:DOSGROUP
  1445 000013C3 C606[0000]02        <1> 	mov	byte [RFlag], ROMREAD		;AN000; read operation
  1446 000013C8 52                  <1> 	push	dx				;AN000; save drive number
  1447 000013C9 E84D00              <1> 	call	Boot_IO 			;AN000; read boot sector into DOSENTRY:DiskSector
  1448 000013CC 5A                  <1> 	pop	dx				;AN000; restore drive number
  1449                              <1> ;	$IF	NC				;AN000;
  1450 000013CD 7248                <1> 	JC $IOCTL$IF6_pop_ds
  1451 000013CF E8(0000)            <1> 	call biocode_get_ds_dosentry	; DISKSECTOR in DOSENTRY
  1452                              <1>  assume ds:DOSENTRYGROUP
  1453 000013D2 8A0E[0000]          <1> 	   mov	   cl, [MediaByte]		;AN000; Mediabyte in BPB
  1454 000013D6 80E1F0              <1> 	   and	   cl, 0F0h			;AN000;
  1455 000013D9 80F9F0              <1> 	   cmp	   cl, 0F0h			;AN000; Is it a valid BPB?
  1456                              <1> ;	   $IF	   E,AND			;AN000;
  1457 000013DC 7536                <1> 	   JNE $IOCTL$IF7
  1458 000013DE 803E[0000]29        <1> 	      cmp   byte [Ext_Boot_Sig], EXT_BOOT_SIGNATURE ;AN000; =41 (=29h)
  1459                              <1> ;	   $IF	   E				;AN000; Extended Boot Record
  1460 000013E3 752F                <1> 	   JNE $IOCTL$IF7
  1461 000013E5 1F                  <1> 	   pop ds
  1462                              <1>  assume ds:UPB
  1463 000013E6 1E                  <1> 	      push ds				;AN011; save BDS pointer
  1464 000013E7 57                  <1> 	      push di				;AN011;
  1465 000013E8 06                  <1> 	      push es				;AN000;
  1466 000013E9 1F                  <1> 	      pop  ds				;AN000;Now DS-> Request packet
  1467                              <1>  assume ds:nothing
  1468 000013EA E8(0000)            <1> 	call biocode_get_es_dosentry	; DISKSECTOR in DOSENTRY
  1469                              <1>  assume es:DOSENTRYGROUP			;AN000;Now ES -> Boot Record
  1470 000013ED BF[0000]            <1> 	      mov  di, offset Boot_Serial_L	;AN000; access with es
  1471 000013F0 89DE                <1> 	      mov  si, bx			;AN000;
  1472                              <1> MI_Serial equ MI_SERIAL	; NASM port equate
  1473 000013F2 83C602              <1> 	      add  si, MI_Serial		;AN000;
  1474 000013F5 B91700              <1> 	      mov  cx, BOOT_SERIAL_SIZE+BOOT_VOLUME_LABEL_SIZE+BOOT_SYSTEM_ID_SIZE
  1475 000013F8 F3A4                <1> 	      rep  movsb			;AN000;
  1476 000013FA 5F                  <1> 	      pop  di				;AN011;Restore BDS pointer
  1477 000013FB 1F                  <1> 	      pop  ds				;AN011;
  1478                              <1>  assume ds:UPB
  1479 000013FC E818EF              <1> 	      call Mov_Media_IDs		;AN011; Update the BDS media ID info.
  1480 000013FF 88D0                <1> 	      mov  al, dl			;AN000; set drive number for Boot_IO
  1481 00001401 1E                  <1> 	push ds
  1482 00001402 E8(0000)            <1> 	call biocode_get_ds_dosbiodata
  1483                              <1>  assume ds:DOSGROUP
  1484 00001405 C606[0000]03        <1> 	      mov  byte [RFlag], ROMWRITE		;AN000;
  1485 0000140A E80C00              <1> 	      call Boot_IO			;AN000; write it back.
  1486 0000140D C606[0000]FF        <1> 	      mov     byte [TIM_DRV], -1		;AN011; Make sure chk$media check the driver
  1487                              <1> ;	   $ELSE				;AN000;
  1488 00001412 EB03                <1> 	   JMP SHORT $IOCTL$EN7_pop_ds
  1489                              <1> $IOCTL$IF7:
  1490 00001414 B007                <1> 	      mov   al, ERROR_UNKNOWN_MEDIA	;AN000; =7
  1491 00001416 F9                  <1> 	      stc				;AN000;
  1492                              <1> ;	   $ENDIF	;End Extended Boot Record check.
  1493                              <1> ;	$ENDIF	;Read boot sector failed. Hard error.
  1494                              <1> $IOCTL$EN7_pop_ds:
  1495                              <1> $IOCTL$IF6_pop_ds:
  1496 00001417 1F                  <1> 	pop ds
  1497                              <1>  assume ds:UPB
  1498 00001418 C3                  <1> 	ret					;AN000;
  1499                              <1> SetMediaID	endp
  1500                              <1> 
  1501                              <1> ;******************************************************************************
  1502                              <1> ;AN000;  Boot_IO
  1503                              <1> ;*******************************************************************************
  1504                              <1> ;									       *
  1505                              <1> ; Function: Read/Write the boot record into Boot sector.		       *
  1506                              <1> ;									       *
  1507                              <1> ; Input :								       *
  1508                              <1> ;	    AL=logical drive number					       *
  1509                              <1> ;	    RFLAG = operation (read/write)				       *
  1510                              <1> ;									       *
  1511                              <1> ; Output:   For read operation, the boot record of the drive specified in BDS  *
  1512                              <1> ;	    be read into the DISKSECTOR buffer. 			       *
  1513                              <1> ;	    For write operation, the DISKSECTOR buffer image will be written   *
  1514                              <1> ;	    to the drive specified in BDS.				       *
  1515                              <1> ;	    If carry set, then AL contains the device driver error number      *
  1516                              <1> ;	    that will be returned to DOS.				       *
  1517                              <1> ;	    AX,CX,DX register destroyed.				       *
  1518                              <1> ;	    If carry set, then AL will contain the error code from DISKIO.     *
  1519                              <1> ;									       *
  1520                              <1> ; Subroutines to be called:						       *
  1521                              <1> ;	DISKIO:NEAR							       *
  1522                              <1> ;									       *
  1523                              <1> ; Logic:								       *
  1524                              <1> ;									       *
  1525                              <1> ; {									       *
  1526                              <1> ;	First_Sector = 0;	 /*logical sector 0 is the boot sector */      *
  1527                              <1> ;	SectorCount = 1;	 /*read 1 sector only */		       *
  1528                              <1> ;	Buffer = DISKSECTOR;	 /*read it into the disksector buffer */       *
  1529                              <1> ;	Call DISKIO (RFLAG, Drive_Number,First_Sector,SectorCount,Buffer);     *
  1530                              <1> ; }									       *
  1531                              <1> ; Expected LOC: 6 (New) 						       *
  1532                              <1> ;*******************************************************************************
  1533                              <1> Boot_IO 	proc	near			;AN000;
  1534                              <1>  assume ds:nothing, es:nothing, ss:nothing
  1535 00001419 1E                  <1> 	push	ds				;AN000;
  1536 0000141A 06                  <1> 	push	es				;AN000;
  1537 0000141B 57                  <1> 	push	di				;AN000;
  1538 0000141C 53                  <1> 	push	bx				;AN000;
  1539                              <1> ;SB34IOCTL003**************************************************************
  1540                              <1> ;SB	Call DISKIO to read/write the boot sector. The parameters which
  1541                              <1> ;SB	need to be initialised for this subroutine out here are
  1542                              <1> ;SB		- transfer address to DOSENTRY:DiskSector
  1543                              <1> ;SB		- low sector needs to be initalised to 0. This is a reg. param
  1544                              <1> ;SB		- hi sector in [DOSENTRY:Start_Sec_H] needs to be initialised to 0.
  1545                              <1> ;SB		- number of sectors <-- 1
  1546                              <1> ;SB	7 LOCS
  1547                              <1> 
  1548 0000141D E8(0000)            <1> 	call biocode_get_es_dosentry	; DISKSECTOR in DOSENTRY
  1549                              <1>  assume es:DOSENTRYGROUP
  1550                              <1> %ifidni %[DOSBIODATA], %[DOSENTRY]
  1551                              <1> 	push es
  1552                              <1> 	pop ds
  1553                              <1> %endif
  1554 00001420 BF[0000]            <1> 	mov	di, offset DiskSector	;es:di -> transfer address ; access with es
  1555 00001423 31D2                <1> 	xor	dx, dx			;first sector (H) -> 0
  1556                              <1> %ifnidni %[DOSBIODATA], %[DOSENTRY]
  1557 00001425 E8(0000)            <1> 	call biocode_get_ds_dosbiodata
  1558                              <1>  assume ds:DOSGROUP
  1559                              <1> %endif
  1560 00001428 8916[0000]          <1> 	mov	[Start_Sec_H], dx	;start sector (H) -> 0
  1561 0000142C B90100              <1> 	mov	cx, 1			;one sector
  1562 0000142F E8ADF0              <1> 	call	DISKIO
  1563                              <1> ;SB34IOCTL003**************************************************************
  1564 00001432 5B                  <1> 	pop	bx				;AN000;
  1565 00001433 5F                  <1> 	pop	di				;AN000;
  1566 00001434 07                  <1> 	pop	es				;AN000;
  1567                              <1>  assume es:nothing
  1568 00001435 1F                  <1> 	pop	ds				;AN000;
  1569                              <1>  assume ds:nothing
  1570 00001436 C3                  <1> 	ret					;AN000;
  1571                              <1> Boot_IO 	endp				;AN000;
  1572                              <1> 
  1573                              <1> ;*******************************************************************************
  1574                              <1> ;AN010;  Changeline_Chk
  1575                              <1> ;*******************************************************************************
  1576                              <1> ;When the user calls Get/Set media ID call before DOS establishes the media    *
  1577                              <1> ;by calling "Media$Chk", the change line activity of the drive is going to be  *
  1578                              <1> ;lost.	This routine will check the change line activity and will save the     *
  1579                              <1> ;history in the flags.							       *
  1580                              <1> ;									       *
  1581                              <1> ; Function: Check the change line error activity			       *
  1582                              <1> ;									       *
  1583                              <1> ; Input :  DS:DI -> BDS table.						       *
  1584                              <1> ;									       *
  1585                              <1> ; Output:   FLAG in BDS table will be updated if change line occurs.	       *
  1586                              <1> ;									       *
  1587                              <1> ; Subroutines to be called:						       *
  1588                              <1> ;	SET_CHANGED_DL							       *
  1589                              <1> ;									       *
  1590                              <1> ;*******************************************************************************
  1591                              <1> Changeline_Chk	proc	near			;AN010;
  1592                              <1>  assume ds:UPB, es:nothing, ss:nothing
  1593 00001437 8A5504              <1> 	mov	dl, byte ptr [di + DRIVENUM]	;AN010;
  1594 0000143A 08D2                <1> 	or	dl, dl				;AN010;Fixed disk?
  1595 0000143C 781F                <1> 	js	Chln_Chk_Ret			;AN010;Yes, skip it.
  1596 0000143E 1E                  <1> 	push ds
  1597 0000143F E8(0000)            <1> 	call biocode_get_ds_dosbiodata
  1598                              <1>  assume ds:DOSGROUP
  1599 00001442 803E[0000]01        <1> 	cmp	byte [fHave96], 1 		;AN011;This ROM support change line?
  1600 00001447 1F                  <1> 	pop ds
  1601                              <1>  assume ds:UPB
  1602 00001448 7513                <1> 	jne	Chln_Chk_Ret			;AN011;
  1603                              <1> HasChange equ HASCHANGE	; NASM port label
  1604 0000144A E8(0000)            <1> 	call	HasChange			;AN011;This drive support change line?
  1605 0000144D 740E                <1> 	jz	Chln_Chk_Ret			;AN011;do nothing
  1606                              <1> ;SB34IOCTL004*****************************************************************
  1607                              <1> ;SB	Execute the ROM disk interrupt to check changeline activity. 2 LOCS
  1608                              <1> 
  1609 0000144F B416                <1> 	mov	ah, 16h
  1610 00001451 CD13                <1> 	int	13h
  1611                              <1> ;SB34IOCTL004*****************************************************************
  1612 00001453 7308                <1> 	jnc	Chln_Chk_Ret			;AN010;no change line activity?
  1613 00001455 53                  <1> 	push bx
  1614 00001456 BB4000              <1> 	mov	bx, FCHANGED ;AN010;
  1615 00001459 E8(0000)            <1> 	call	SET_CHANGED_DL			;AN010;Update FLAG in BDS for this physical drive
  1616 0000145C 5B                  <1> 	pop bx
  1617                              <1> Chln_Chk_Ret:					;AN010;
  1618 0000145D C3                  <1> 	ret					;AN010;
  1619                              <1> Changeline_Chk	endp				;AN010;
  1620                              <1> 
  1621                              <1> ;******************************************************************************
  1622                              <1> ;AN007;  GetAccessFlag
  1623                              <1> ;*******************************************************************************
  1624                              <1> ;									       *
  1625                              <1> ; Function: Get the status of UNFORMATTED_MEDIA bit of FLAGS in BDS table      *
  1626                              <1> ;									       *
  1627                              <1> ; Input :								       *
  1628                              <1> ;	    es:bx -> A_DISKACCESS_CONTROL structure			       *
  1629                              <1> ;	    ds:di -> BDS table						       *
  1630                              <1> ;									       *
  1631                              <1> ; Output:   A_DISKACCESS_CONTROL.DAC_ACCESS_FLAG = 0 if disk I/O not allowed.  *
  1632                              <1> ;						 = 1 if disk I/O allowed.      *
  1633                              <1> ;*******************************************************************************
  1634                              <1> GetAccessFlag	proc					    ;AN007;
  1635                              <1>  assume ds:UPB, es:nothing, ss:nothing
  1636 0000145E F745230002          <1> 	test	word ptr [di + FLAGS], UNFORMATTED_MEDIA   ;AN007;Is it unformtted media?
  1637 00001463 7407                <1> 	jz	GAF_Allowed				    ;AN007;No, formatted media
  1638 00001465 26C6470100          <1> 	mov	byte [es:bx + DAC_ACCESS_FLAG], 0		    ;AN007;
  1639 0000146A EB05                <1> 	jmp	short GAF_Done				    ;AN007;
  1640                              <1> GAF_Allowed:						    ;AN007;
  1641 0000146C 26C6470101          <1> 	mov	byte [es:bx + DAC_ACCESS_FLAG], 1		    ;AN007;
  1642                              <1> GAF_Done:						    ;AN007;
  1643 00001471 C3                  <1> 	ret						    ;AN007;
  1644                              <1> GetAccessFlag	endp					    ;AN007;
  1645                              <1> 
  1646                              <1> ;******************************************************************************
  1647                              <1> ;AN007;  SetAccessFlag
  1648                              <1> ;*******************************************************************************
  1649                              <1> ;									       *
  1650                              <1> ; Function: Set/Reset the UNFORMATTED_MEDIA bit of FLAGS in BDS table	       *
  1651                              <1> ;									       *
  1652                              <1> ; Input :								       *
  1653                              <1> ;	    es:bx -> A_DISKACCESS_CONTROL structure			       *
  1654                              <1> ;	    ds:di -> BDS table						       *
  1655                              <1> ;									       *
  1656                              <1> ; Output:   UNFORMTTED_MEDIA bit modified according to the user request        *
  1657                              <1> ;*******************************************************************************
  1658                              <1> SetAccessFlag	proc					    ;AN007;
  1659                              <1>  assume ds:UPB, es:nothing, ss:nothing
  1660 00001472 26807F0100          <1> 	cmp	byte [es:bx + DAC_ACCESS_FLAG], 0		    ;AN007;
  1661 00001477 7507                <1> 	jne	SAF_Allow_Access			    ;AN007;
  1662 00001479 814D230002          <1> 	or	word ptr [di + FLAGS], UNFORMATTED_MEDIA   ;AN007;
  1663 0000147E EB05                <1> 	jmp	short SAF_Done				    ;AN007;
  1664                              <1> SAF_Allow_Access:					    ;AN007;
  1665 00001480 816523FFFD          <1> 	and	word ptr [di + FLAGS], ~ UNFORMATTED_MEDIA ;AN007;
  1666                              <1> SAF_Done:						    ;AN007;
  1667 00001485 C3                  <1> 	ret						    ;AN007;
  1668                              <1> SetAccessFlag	endp					    ;AN007;
  1669                              <1> 
  1670                              <1> 
  1671                              <1> 
  3138                                  ;=== Pop trace listing source
  3139                                  ;	PAGE
  3140                                  ; CHECK_WRAP IS A ROUTINE THAT ADJUSTS THE STARTING SECTOR, STARTING HEAD
  3141                                  ; AND STARTING CYLINDER FOR AN INT 13 REQUEST THAT REQUESTS I/O OF A LOT
  3142                                  ; OF SECTORS. IT ONLY DOES THIS FOR FIXED DISKS. IT IS USED IN THE SECTIONS
  3143                                  ; OF CODE THAT HANDLE ECC ERRORS AND DMA ERRORS. IT IS NECESSARY, BECAUSE
  3144                                  ; ORDINARILY THE ROM WOULD TAKE CARE OF WRAPS AROUND HEADS AND CYLINDERS,
  3145                                  ; BUT WE BREAK DOWN A REQUEST WHEN WE GET AN ECC OR DMA ERROR INTO SEVERAL
  3146                                  ; I/O OF ONE OR MORE SECTORS. IN THIS CASE, WE MAY ALREADY BE BEYOND THE
  3147                                  ; NUMBER OF SECTORS ON A TRACK ON THE MEDIUM, AND THE REQUEST WOULD FAIL.
  3148                                  ;
  3149                                  ; INPUT CONDITIONS:
  3150                                  ;	ALL REGISTERS SET UP FOR AN INT 13 REQUEST.
  3151                                  ;
  3152                                  ; OUTPUT:
  3153                                  ;	DH - CONTAINS STARTING HEAD NUMBER FOR REQUEST
  3154                                  ;	CX - CONTAINS STARTING SECTOR AND CYLINDER NUMBERS
  3155                                  ;	(THE ABOVE MAY OR MAY NOT HAVE BEEN CHANGED, AND ARE 0-BASED)
  3156                                  ;	ALL OTHER REGISTERS PRESERVED.
  3157                                  ;
  3158                                  	PUBLIC CHECK_WRAP
  3159                                  CHECK_WRAP:
  3160                                  	Message ftestDisk,<"Entering Check_Wrap...",cr,lf>
  3161 00001486 50531E57                	SAVEREG <AX,BX,DS,DI>
  3162 0000148A E8(0000)                	call biocode_get_ds_dosbiodata
  3163                                   assume ds:DOSGROUP
  3164 0000148D C606[0000]01            	MOV	BYTE PTR [PHYS_DRV],1	; USE PHYSICAL DRIVE IN AL TO GET BDS
  3165 00001492 88D0                    	MOV	AL,DL			; AL HAS PHYSICAL DRIVE NUMBER
  3166 00001494 E872EF                  	CALL	SETDRIVE		; GET POINTER TO BDS FOR DRIVE
  3167                                   assume ds:UPB
  3168 00001497 1E                      	push ds
  3169 00001498 E8(0000)                	call biocode_get_ds_dosbiodata
  3170                                   assume ds:DOSGROUP
  3171 0000149B C606[0000]00            	MOV	BYTE PTR [PHYS_DRV],0	; RESTORE FLAG TO USE LOGICAL DRIVE
  3172 000014A0 1F                      	pop ds
  3173                                   assume ds:UPB
  3174 000014A1 725E                    	JC	NO_WRAP 		; DO NOTHING IF WRONG PHYSICAL DRIVE
  3175 000014A3 F745230100              	TEST	WORD PTR [DI + FLAGS],FNON_REMOVABLE
  3176 000014A8 7457                    	JZ	NO_WRAP 		; NO WRAPPING FOR REMOVABLE MEDIA
  3177 000014AA 8B5D13                  	MOV	BX,[DI + SECLIM]
  3178 000014AD 89C8                    	MOV	AX,CX
  3179 000014AF 83E03F                  	AND	AX,003FH		; EXTRACT SECTOR NUMBER
  3180 000014B2 39D8                    	CMP	AX,BX			; ARE WE GOING TO WRAP?
  3181 000014B4 764B                    	JBE	NO_WRAP
  3182 000014B6 F6F3                    	DIV	BL			; AH=NEW SECTOR #, AL=# OF HEAD WRAPS
  3183                                  ; WE NEED TO BE CAREFUL HERE. IF THE NEW SECTOR # IS 0, THEN WE ARE ON THE
  3184                                  ; LAST SECTOR ON THAT TRACK.
  3185 000014B8 08E4                    	OR	AH,AH
  3186 000014BA 7504                    	JNZ	NOT_ON_BOUND
  3187 000014BC 88DC                    	MOV	AH,BL			; SET SECTOR=SECLIM IF ON BOUNDARY
  3188 000014BE FEC8                    	DEC	AL			; ALSO DECREMENT # OF HEAD WRAPS
  3189                                  NOT_ON_BOUND:
  3190 000014C0 80E1C0                  	AND	CL,0C0H 		; ZERO OUT SECTOR #
  3191 000014C3 08E1                    	OR	CL,AH			; OR IN NEW SECTOR #
  3192 000014C5 30E4                    	XOR	AH,AH			; AX = # OF HEAD WRAPS
  3193 000014C7 40                      	INC	AX
  3194 000014C8 00F0                    	ADD	AL,DH			; ADD IN STARTING HEAD #
  3195 000014CA 80D400                  	ADC	AH,0			; CATCH ANY CARRY
  3196 000014CD 3B4515                  	CMP	AX,[DI + HDLIM]		; ARE WE GOING TO WRAP AROUND A HEAD?
  3197 000014D0 7635                    	JBE	NO_WRAP_HEAD		; DO NOT LOSE NEW HEAD NUMBER!!
  3198 000014D2 52                      	PUSH	DX			; PRESERVE DRIVE NUMBER AND HEAD NUMBER
  3199 000014D3 31D2                    	XOR	DX,DX
  3200 000014D5 8B5D15                  	MOV	BX,[DI + HDLIM]
  3201 000014D8 F7F3                    	DIV	BX			; DX=NEW HEAD #, AX=# OF CYLINDER WRAPS
  3202                                  ; CAREFUL HERE! IF NEW HEAD # IS 0, THEN WE ARE ON THE LAST HEAD.
  3203 000014DA 85D2                    	test	DX,DX
  3204 000014DC 7507                    	JNZ	NO_HEAD_BOUND
  3205 000014DE 89DA                    	MOV	DX,BX			; ON BOUNDARY. SET TO HDLIM
  3206                                  ; IF WE HAD SOME CYLINDER WRAPS, WE NEED TO REDUCE THEM BY ONE!!
  3207 000014E0 85C0                    	test	AX,AX
  3208 000014E2 7401                    	JZ	NO_HEAD_BOUND
  3209 000014E4 48                      	DEC	AX			; REDUCE NUMBER OF CYLINDER WRAPS
  3210                                  NO_HEAD_BOUND:
  3211 000014E5 88D7                    	MOV	BH,DL			; BH HAS NEW HEAD NUMBER
  3212 000014E7 5A                      	POP	DX			; RESTORE DRIVE NUMBER AND HEAD NUMBER
  3213 000014E8 FECF                    	DEC	BH			; GET IT 0-BASED
  3214 000014EA 88FE                    	MOV	DH,BH			; SET UP NEW HEAD NUMBER IN DH
  3215 000014EC 88CF                    	MOV	BH,CL
  3216 000014EE 80E73F                  	AND	BH,3FH			; PRESERVE SECTOR NUMBER
  3217 000014F1 B306                    	MOV	BL,6
  3218 000014F3 86CB                    	XCHG	CL,BL
  3219 000014F5 D2EB                    	SHR	BL,CL			; GET MS CYLINDER BITS TO LS END
  3220 000014F7 00C5                    	ADD	CH,AL			; ADD IN CYLINDER WRAP
  3221 000014F9 10E3                    	ADC	BL,AH			; ADD IN HIGH BYTE
  3222 000014FB D2E3                    	SHL	BL,CL			; MOVE UP TO MS END
  3223 000014FD 86D9                    	XCHG	BL,CL			; RESTORE CYLINDER BITS INTO CL
  3224 000014FF 08F9                    	OR	CL,BH			; OR IN SECTOR NUMBER
  3225                                  
  3226                                  NO_WRAP:
  3227 00001501 F8                      	CLC				; RESET CARRY
  3228 00001502 5F1F5B58                	RESTOREREG <DI,DS,BX,AX>
  3229                                   assume ds:nothing
  3230 00001506 C3                      	RET
  3231                                  
  3232                                  NO_WRAP_HEAD:
  3233 00001507 88C6                    	MOV	DH,AL			; DO NOT LOSE NEW HEAD NUMBER
  3234 00001509 FECE                    	DEC	DH			; GET IT 0-BASED
  3235 0000150B EBF4                    	JMP	SHORT NO_WRAP
  3236                                  
  3237                                  ;
  3238                                  ; INT_2F_13:
  3239                                  ;		THIS CODE IS CHAINED INTO THE INT_2F INTERRUPT DURING BIOS
  3240                                  ;	INITIALIZATION.  IT ALLOWS THE USER TO CHANGE THE ORIG13 INT_13 VECTOR
  3241                                  ;	AFTER BOOTING.	THIS ALLOWS TESTING AND IMPLEMENTATION OF CUSTOM INT_13
  3242                                  ;	HANDLERS, WITHOUT GIVING UP MS-DOS ERROR RECOVERY
  3243                                  ;
  3244                                  ;	ENTRY CONDITIONS
  3245                                  ;		AH	== RESET_INT_13  (13H)
  3246                                  ;		DS:DX	== ADDRESS OF NEW INT_13 HANDLER
  3247                                  ;		ES:BX	== ADDRESS OF NEW INT_13 VECTOR USED BY WARM BOOT
  3248                                  ;								(INT 19)
  3249                                  ;
  3250                                  ;	EXIT CONDITIONS
  3251                                  ;		ORIG13	== ADDRESS OF NEW INT_13 HANDLER
  3252                                  ;		DS:DX	== OLD ORIG13 VALUE
  3253                                  ;		ES:BX	== OLD OLD13  VALUE
  3254                                  
  3255                                  
  3256                                  %ifn _RELOCATEDOSCODE
  3257                                   global i2F
  3258                                  i2F:
  3259                                  %endif
  3260                                  relocated head_i2F	; (destination of the real int 2Fh vector)
  3261                                  relocated set_i13_i2F
  3262                                   ASSUME DS:NOTHING,ES:NOTHING,SS:NOTHING
  3263 0000150D 80FC13                  	CMP	AH,13H			; IF (INTERRUPT_VALUE != RESET_INT_13)
  3264                                   extern relocateddisk_i2F
  3265 00001510 7403E9(0000)            	jne relocateddisk_i2F		;  THEN CONTINUE ON INT_2F CHAIN
  3266                                  CHG_ORIG13:				;	ELSE
  3267                                   assume ds:nothing, es:nothing, ss:nothing
  3268 00001515 FA                      	cli
  3269 00001516 50                      	push ax
  3270 00001517 8CD8                    	mov ax, ds
  3271 00001519 E8(0000)                	call biocode_get_ds_dosentry	; OLD13, ORIG13 in DOSENTRY !
  3272                                   assume ds:DOSENTRYGROUP
  3273 0000151C FF36[0000]              	PUSH	WORD PTR [ORIG13]	;	   SAVE OLD VALUE OF OLD13 AND
  3274 00001520 FF36[0200]              	PUSH	WORD PTR [ORIG13 + 2];	   ORIG13 SO THAT WE CAN
  3275                                  
  3276 00001524 FF36[0000]              	PUSH	WORD PTR [OLD13]	;	   RETURN THEM TO CALLER
  3277 00001528 FF36[0200]              	PUSH	WORD PTR [OLD13 + 2]
  3278                                  
  3279 0000152C 8916[0000]              	MOV	WORD PTR [ORIG13],DX ;	   ORIG13 := ADDR. OF NEW INT_13
  3280                                  					;				VECTOR
  3281 00001530 A3[0200]                	MOV	WORD PTR [ORIG13+2], ax
  3282                                  
  3283 00001533 891E[0000]              	MOV	WORD PTR [OLD13],BX	;	    OLD13 := ADDR. OF NEW
  3284                                  					;			  BOOT_13 VECTOR
  3285 00001537 8C06[0200]              	MOV	WORD PTR [OLD13+2],ES
  3286                                  
  3287 0000153B 07                      	POP	ES			;	    ES:BX := OLD OLD13 VECTOR
  3288                                   assume es:nothing
  3289 0000153C 5B                      	POP	BX
  3290                                  
  3291 0000153D 1F                      	POP	DS			;	    DS:DX := OLD ORIG13 VECTOR
  3292                                   assume ds:nothing
  3293 0000153E 5A                      	POP	DX
  3294 0000153F 58                      	pop ax
  3295                                  
  3296 00001540 CF                      	IRET				;	END ELSE
  3297                                  
  3298                                  INT_2F_13	ENDP
  3299                                  
  3300                                  MOVE	PROC	NEAR
  3301 00001541 FC                      	CLD
  3302 00001542 51                      	PUSH	CX
  3303 00001543 B90001                  	MOV	CX,512/2
  3304                                  
  3305 00001546 1E                      	push ds
  3306 00001547 E8(0000)                	call biocode_get_ds_dosbiodata
  3307                                   assume ds:DOSGROUP
  3308 0000154A D006[0601]              	rol byte [dosbiodata_have_386], 1
  3309 0000154E 1F                      	pop ds
  3310                                   assume ds:nothing
  3311 0000154F 7303                    	jnc @F
  3312                                  
  3313                                  ;J.K. Warning!!! Do not change the position of this label.
  3314                                  ;     The following three bytes will be NOPed out by MSINIT if the system
  3315                                  ;     does not support the DOUBLE WORD MOV instruction, i.e., (if
  3316                                  ;     not 386 base machine.)
  3317                                  ;----------------------------------------------------------------------------
  3318                                  	; public	DoubleWordMov
  3319                                  ; DoubleWordMov:			;AN002;
  3320 00001551 D1E9                    	shr	cx, 1		;AN002;Make it a double word.
  3321 00001553 66                      	o32			;AN002;Machine code for double word mov
  3322                                  ;----------------------------------------------------------------------------
  3323                                  @@:
  3324 00001554 F3A5                    	REP	MOVSW
  3325 00001556 59                      	POP	CX
  3326 00001557 C3                      	RET
  3327                                  MOVE ENDP
  3328                                  
  3329                                  DOINT	PROC	NEAR
  3330                                   assume ds:nothing, es:nothing, ss:nothing
  3331 00001558 8A5608                  	MOV	DL,BYTE PTR [BP + OLDDX]		; GET PHYSICAL DRIVE NUMBER
  3332 0000155B 30E4                    	XOR	AH,AH
  3333 0000155D 84C0                    	test	AL,AL
  3334 0000155F 740F                    	JZ	DOINTDONE
  3335 00001561 8A6603                  	MOV	AH,BYTE PTR [BP + OLDAX+1]	; GET REQUEST CODE
  3336 00001564 FF760E                  	PUSH	word [BP + OLDF]
  3337 00001567 9A[0000][ssss]          	call DOSENTRY:transfer_orig13
  3338 0000156C 9C                      	PUSHF
  3339 0000156D 8F460E                  	POP	word [BP + OLDF]
  3340                                  DOINTDONE:
  3341 00001570 C3                      	RET
  3342                                  DOINT	ENDP
  3343                                  
  3344                                  
  3345                                  	global ispatched
  3346                                  ispatched:
  3347                                   assume ds:nothing
  3348 00001571 1E                      	push ds
  3349 00001572 E8(0000)                	call biocode_get_ds_dosbiodata
  3350                                   assume ds:DOSGROUP
  3351 00001575 803E[0000]01            	cmp byte [FHAVE96], 1			; CY if 0
  3352 0000157A 1F                      	pop ds
  3353                                   assume ds:nothing
  3354 0000157B C3                      	retn
  3355                                  
  3356                                  
  3357                                  usesection DOSBIODATA
  3358                                  
  3359                                   global dosbiodata_have_386
  3360 00000106 00                      dosbiodata_have_386:	db 0
  3361 00000107 00                      hma_operation:		db 0
  3362                                  
  3363                                   global config_bounce_hma_chs
  3364                                   global config_bounce_hma_lba
  3365 00000108 00                      config_bounce_hma_chs:	db 0
  3366 00000109 00                      config_bounce_hma_lba:	db 0
  3367                                   global config_bounce_uma_chs
  3368                                   global config_bounce_uma_lba
  3369 0000010A 00                      config_bounce_uma_chs:	db 0
  3370 0000010B 00                      config_bounce_uma_lba:	db 0
  3371                                   global config_bounce_any_chs
  3372                                   global config_bounce_any_lba
  3373 0000010C 00                      config_bounce_any_chs:	db 0
  3374 0000010D 00                      config_bounce_any_lba:	db 0
