summaryrefslogtreecommitdiff
path: root/v4.0/src/DOS/DINFO.ASM
diff options
context:
space:
mode:
Diffstat (limited to 'v4.0/src/DOS/DINFO.ASM')
-rw-r--r--v4.0/src/DOS/DINFO.ASM131
1 files changed, 131 insertions, 0 deletions
diff --git a/v4.0/src/DOS/DINFO.ASM b/v4.0/src/DOS/DINFO.ASM
new file mode 100644
index 0000000..10738b1
--- /dev/null
+++ b/v4.0/src/DOS/DINFO.ASM
@@ -0,0 +1,131 @@
1; SCCSID = @(#)dinfo.asm 1.1 85/04/10
2; SCCSID = @(#)dinfo.asm 1.1 85/04/10
3TITLE DISK_INFO - Internal Get Disk Info
4NAME 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
19include dosseg.asm
20
21CODE SEGMENT BYTE PUBLIC 'CODE'
22 ASSUME SS:DOSGROUP,CS:DOSGROUP
23
24.xcref
25INCLUDE DOSSYM.INC
26INCLUDE DEVSYM.INC
27.cref
28.list
29
30Installed = TRUE
31
32 i_need THISCDS,DWORD
33 i_need CURBUF,DWORD
34 i_need EXTERR_LOCUS,BYTE
35if debug
36 I_need BugLev,WORD
37 I_need BugTyp,WORD
38include bugtyp.asm
39endif
40
41Break <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
63IF NOT Installed
64 transfer NET_DISK_INFO
65ELSE
66 MOV AX,(multNET SHL 8) OR 12
67 INT 2FH
68 return
69ENDIF
70
71LOCAL_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]
80ASSUME 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">
99DoScan:
100 XOR DX,DX
101 DEC CX
102SCANFREE:
103 invoke UNPACK
104 JC Crit_Leave
105 JNZ NOTFREECLUS
106 INC DX ; A free one
107NOTFREECLUS:
108 INC BX ; Next cluster
109 LOOP SCANFREE
110 DEC BX ; BX was next cluster. Convert to
111ReturnVals:
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
118CRIT_LEAVE:
119 LeaveCrit critDisk
120 return
121;
122; We have correctly computed everything previously. Load up registers for
123; return.
124;
125GotVal: MOV BX,CX ; get cluster count
126 JMP ReturnVals
127
128EndProc DISK_INFO
129
130CODE ENDS
131 END