]> wirehaze git hosting - MS-DOS.git/blob - v4.0/src/DOS/DINFO.ASM

wirehaze git hosting

MZ is back!
[MS-DOS.git] / v4.0 / src / DOS / DINFO.ASM
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 .xlist
19 include dosseg.asm
20
21 CODE SEGMENT BYTE PUBLIC 'CODE'
22 ASSUME SS:DOSGROUP,CS:DOSGROUP
23
24 .xcref
25 INCLUDE DOSSYM.INC
26 INCLUDE DEVSYM.INC
27 .cref
28 .list
29
30 Installed = TRUE
31
32 i_need THISCDS,DWORD
33 i_need CURBUF,DWORD
34 i_need EXTERR_LOCUS,BYTE
35 if debug
36 I_need BugLev,WORD
37 I_need BugTyp,WORD
38 include bugtyp.asm
39 endif
40
41 Break <DISK_INFO -- Get Disk Drive Information>
42
43 ; Inputs:
44 ; [THISCDS] Points to the Macro List Structure of interest
45 ; (It MAY NOT be NUL, error not detected)
46 ; Function:
47 ; Get Interesting Drive Information
48 ; Returns:
49 ; DX = Number of free allocation units
50 ; BX = Total Number of allocation units on disk
51 ; CX = Sector size
52 ; AL = Sectors per allocation unit
53 ; AH = FAT ID BYTE
54 ; Carry set if error (currently user FAILed to I 24)
55 ; Segs except ES preserved, others destroyed
56
57 procedure DISK_INFO,NEAR
58 DOSAssume CS,<DS>,"Disk_Info"
59 ASSUME ES:NOTHING
60
61 Invoke TestNet
62 JNC LOCAL_INFO
63 IF NOT Installed
64 transfer NET_DISK_INFO
65 ELSE
66 MOV AX,(multNET SHL 8) OR 12
67 INT 2FH
68 return
69 ENDIF
70
71 LOCAL_INFO:
72 MOV [EXTERR_LOCUS],errLOC_Disk
73 EnterCrit critDisk
74 invoke FATREAD_CDS ; perform media check.
75 JC CRIT_LEAVE
76 MOV BX,2
77 invoke UNPACK ; Get first FAT sector into CURBUF
78 JC CRIT_LEAVE
79 LDS SI,[CURBUF]
80 ASSUME DS:NOTHING
81 MOV AH,[SI].bufinsiz ; get FAT ID BYTE
82 context DS
83 MOV CX,ES:[BP.dpb_max_cluster]
84 ;
85 ; Examine the current free count. If it indicates that we have an invalid
86 ; count, do the expensive calculation.
87 ;
88 MOV DX,ES:[BP.dpb_free_cnt] ; get free count
89 CMP DX,-1 ; is it valid?
90 JZ DoScan
91 ;
92 ; Check to see if it is in a reasonalbe range. If so, trust it and return.
93 ; Otherwise, we need to blast out an internal error message and then recompute
94 ; the count.
95 ;
96 CMP DX,CX ; is it in a reasonable range?
97 JB GotVal ; yes, trust it.
98 fmt TypInt,LevLog,<"Internal error: MaxClus <= FreeClus\n">
99 DoScan:
100 XOR DX,DX
101 DEC CX
102 SCANFREE:
103 invoke UNPACK
104 JC Crit_Leave
105 JNZ NOTFREECLUS
106 INC DX ; A free one
107 NOTFREECLUS:
108 INC BX ; Next cluster
109 LOOP SCANFREE
110 DEC BX ; BX was next cluster. Convert to
111 ReturnVals:
112 DEC BX ; count
113 MOV AL,ES:[BP.dpb_cluster_mask]
114 INC AL ; Sectors/cluster
115 MOV CX,ES:[BP.dpb_sector_size] ; Bytes/sector
116 MOV ES:[BP.dpb_free_cnt],DX
117 CLC
118 CRIT_LEAVE:
119 LeaveCrit critDisk
120 return
121 ;
122 ; We have correctly computed everything previously. Load up registers for
123 ; return.
124 ;
125 GotVal: MOV BX,CX ; get cluster count
126 JMP ReturnVals
127
128 EndProc DISK_INFO
129
130 CODE ENDS
131 END