     1                                  ;	SCCSID = @(#)dinfo.asm	1.1 85/04/10
     2                                  ;	SCCSID = @(#)dinfo.asm	1.1 85/04/10
     3                                  ;TITLE	DISK_INFO - Internal Get Disk Info
     4                                  ;NAME	DISK_INFO
     5                                  ; Low level routine for returning disk drive information from a local
     6                                  ;   or NET device
     7                                  ;
     8                                  ; DISK_INFO
     9                                  ;
    10                                  ;   Modification history:
    11                                  ;
    12                                  ;	Created: ARR 30 March 1983
    13                                  ;
    14                                  
    15                                  ;
    16                                  ; get the appropriate segment definitions
    17                                  ;
    18                                  [list -]
    18          ******************       warning: redefining multi-line macro `struc' [-w+pp-macro-redef-multi]
    14                              <4> [list -]
    14                              <3> [list -]
     3                              <2> 
     4                              <2> addsection DOSSTART, align=16 PUBLIC class=DOSSTART
     5                              <2> ; (no prior section) ; DOSSTART		ENDS
     6                              <2> 
     7                              <2> addsection DOSSTARTJUMP, align=1 PUBLIC class=START
     8                              <2> ; (no prior section) ; DOSSTARTJUMP		ENDS
     9                              <2> 
    10                              <2> addsection CONSTANTS, align=2 PUBLIC class=CONST
    11                              <2> ; (no prior section) ; CONSTANTS	ENDS
    12                              <2> 
    13                              <2> addsection DATA, align=2 PUBLIC class=DATA
    14                              <2> ; (no prior section) ; DATA		ENDS
    15                              <2> 
    16                              <2> addsection TABLE, align=2 PUBLIC class=TABLE
    17                              <2> ; (no prior section) ; TABLE		ENDS
    18                              <2> 
    19                              <2> addsection DOSDATATABLE, align=2 PUBLIC class=DOSDATACODE
    20                              <2> ; (no prior section) ; DOSDATATABLE		ENDS
    21                              <2> 
    22                              <2> addsection DOSDATACODE, align=1 PUBLIC class=DOSDATACODE
    23                              <2> ; (no prior section) ; DOSDATACODE		ENDS
    24                              <2> 
    25                              <2> addsection DOSBIODATA, align=2 PUBLIC class=DOSBIODATA
    26                              <2> 
    27                              <2> addsection LAST, align=16 PUBLIC class=LAST
    28                              <2> ; (no prior section) ; LAST		ENDS
    29                              <2> 
    30                              <2> group DOSGROUP DOSSTART DOSSTARTJUMP CONSTANTS DATA TABLE DOSDATATABLE DOSDATACODE DOSBIODATA LAST
     8                              <1> 
     9                              <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
    10                              <1> 
    11                              <1> section LAST
    12                              <1> ; (no prior section) ; LAST		ENDS
    20                                  
    21                                  [list +]
    22                                  section DOSCODECODE
    23                                  [list -]
    23          ******************       warning: out: ... for DOS Version 4.00 ... [-w+user]
    23          ******************       warning: out: BPB.INC... [-w+user]
    23          ******************       warning: out: ... CLONE version build switch on ... [-w+user]
    23          ******************       warning: out: DEVSYM.INC... [-w+user]
    30                                  
    31                                  %iassign Installed TRUE
    32                                  
    33                                  	i_need	THISCDS,DWORD
    34                                  	i_need	CURBUF,DWORD
    35                                  	i_need	EXTERR_LOCUS,BYTE
    36                                  %if debug
    37                                  	I_need	BugLev,WORD
    38                                  	I_need	BugTyp,WORD
    39                                  %include "bugtyp.nas"
    40                                  %endif
    41                                  
    42                                   assume nocheck, ss:DOSGROUP
    43                                  
    44                                  Break	<DISK_INFO -- Get Disk Drive Information>
    45                                  
    46                                  ; Inputs:
    47                                  ;	[THISCDS] Points to the Macro List Structure of interest
    48                                  ;		(It MAY NOT be NUL, error not detected)
    49                                  ; Function:
    50                                  ;	Get Interesting Drive Information
    51                                  ; Returns:
    52                                  ;	DX = Number of free allocation units
    53                                  ;	BX = Total Number of allocation units on disk
    54                                  ;	CX = Sector size
    55                                  ;	AL = Sectors per allocation unit
    56                                  ;	AH = FAT ID BYTE
    57                                  ;	Carry set if error (currently user FAILed to I 24)
    58                                  ; Segs except ES preserved, others destroyed
    59                                  
    60                                  	procedure   DISK_INFO,NEAR
    60          ******************       warning: proc DISK_INFO... [-w+user]
    61                                  	DOSAssume   CS,<DS>,"Disk_Info"
    62                                  	ASSUME	ES:NOTHING
    63                                  
    64 00000000 E8(0000)                	Invoke	TestNet
    65 00000003 7306                    	JNC	LOCAL_INFO
    66                                  %IFN Installed
    67                                  	transfer NET_DISK_INFO
    68                                  %ELSE
    69                                  multNET equ MultNET	; NASM port equate
    70 00000005 B80C11                  	MOV	AX,(multNET << 8) | 12
    71 00000008 CD2F                    	INT	2FH
    72 0000000A C3                      	return
    73                                  %ENDIF
    74                                  
    75                                  LOCAL_INFO:
    76 0000000B C606[0000]02            	MOV	byte [EXTERR_LOCUS],errLOC_Disk
    77 00000010 E8(0000)                	EnterCrit   critDisk
    78 00000013 E8(0000)                	invoke	FATREAD_CDS		; perform media check.
    79 00000016 7241                    	JC	CRIT_LEAVE
    80 00000018 BB0200                  	MOV	BX,2
    81 0000001B E8(0000)                	invoke	UNPACK			; Get first FAT sector into CURBUF
    82 0000001E 7239                    	JC	CRIT_LEAVE
    83 00000020 C536[0000]              	LDS	SI,[CURBUF]
    84                                  ASSUME	DS:NOTHING
    85                                  bufinsiz equ BUFINSIZ	; NASM port equate
    86 00000024 8A6410                  	MOV	AH,[SI + bufinsiz]	; get FAT ID BYTE
    87 00000027 161F                    	context DS
    88 00000029 268B4E0D                	MOV	CX,[ES:BP + dpb_max_cluster]
    89                                  ;
    90                                  ; Examine the current free count.  If it indicates that we have an invalid
    91                                  ; count, do the expensive calculation.
    92                                  ;
    93 0000002D 268B561F                	MOV	DX,[ES:BP + dpb_free_cnt] ; get free count
    94 00000031 83FAFF                  	CMP	DX,-1			; is it valid?
    95 00000034 7404                    	JZ	DoScan
    96                                  ;
    97                                  ; Check to see if it is in a reasonalbe range.	If so, trust it and return.
    98                                  ; Otherwise, we need to blast out an internal error message and then recompute
    99                                  ; the count.
   100                                  ;
   101 00000036 39CA                    	CMP	DX,CX			; is it in a reasonable range?
   102 00000038 7223                    	JB	GotVal			; yes, trust it.
   103                                  	fmt	TypInt,LevLog,<"Internal error: MaxClus <= FreeClus\n">
   104                                  DoScan:
   105 0000003A 31D2                    	XOR	DX,DX
   106 0000003C 49                      	DEC	CX
   107                                  SCANFREE:
   108 0000003D E8(0000)                	invoke	UNPACK
   109                                  Crit_Leave equ CRIT_LEAVE	; NASM port label
   110 00000040 7217                    	JC	Crit_Leave
   111 00000042 7501                    	JNZ	NOTFREECLUS
   112 00000044 42                      	INC	DX			; A free one
   113                                  NOTFREECLUS:
   114 00000045 43                      	INC	BX			; Next cluster
   115 00000046 E2F5                    	LOOP	SCANFREE
   116 00000048 4B                      	DEC	BX			; BX was next cluster.	Convert to
   117                                  ReturnVals:
   118 00000049 4B                      	DEC	BX			; count
   119 0000004A 268A4604                	MOV	AL,[ES:BP + dpb_cluster_mask]
   120 0000004E FEC0                    	INC	AL			; Sectors/cluster
   121                                  					; overflow to 0 if it is 256
   122 00000050 268B4E02                	MOV	CX,[ES:BP + dpb_sector_size]  ; Bytes/sector
   123 00000054 2689561F                	MOV	[ES:BP + dpb_free_cnt],DX
   124 00000058 F8                      	CLC
   125                                  CRIT_LEAVE:
   126 00000059 E8(0000)                	LeaveCrit   critDisk
   127 0000005C C3                      	return
   128                                  ;
   129                                  ; We have correctly computed everything previously.  Load up registers for
   130                                  ; return.
   131                                  ;
   132 0000005D 89CB                    GotVal: MOV	BX,CX			; get cluster count
   133 0000005F EBE8                    	JMP	ReturnVals
   134                                  
   135                                  EndProc DISK_INFO
   136                                  
   137                                      END
