1 ;-------------------------------------------------------------------------
4 ; This file contains the volume_id subroutines and data structures.
6 ; Routines in this file are:
7 ; Set_Volume_ID - main routine, calls other routines.
8 ; read_volume_id - read the volume ID and tells if it has
10 ; Transfer_volume_id - copy the volume ID from TMP to special
12 ; Check_Volume_ID - compare volume ID in TMP area with one
14 ; Fat_Check - see of the fatID has changed in the
16 ; Init_Vid_loop - set up for VID scan or move
19 ;-------------------------------------------------------------------------
22 ; length of the volume id
27 PATHSTART 001,VOLID ;3.30
33 nul_vid db "NO NAME ",0
36 ; data scratch area used to hold volume ids
39 tmp_vid db "NO NAME ",0
41 PATHEND 001,VOLID ;3.30
45 ; If drive has changeline support, read in and set the volume_ID
46 ; and the last FAT_ID byte. If no change line support then do nothing.
49 ; DS:DI points to the BDS for this disk.
50 ; AH contains media byte
56 ; Error and AX has error code
60 PUBLIC SET_VOLUME_ID ;3.30
61 push dx ; save registers
63 CALL HasChange ; does drive have changeline support?
64 jz setvret ; no, get out
66 call read_volume_ID ; read the volume ID
68 jc SetErr ; if error go to error routine
69 call transfer_volume_ID ; copy the volume id to special drive
70 call ResetChanged ; restore value of change line
72 setvret: ; SET Volume RETurn
73 clc ; no error, clear carry flag
74 pop ax ; restore registers
78 pop dx ; pop stack but don't overwrite AX
84 root_sec DW ? ;Root sector #
90 ; read_volume_id read the volume ID and tells if it has been changed.
93 ; DS:DI points to current BDS for drive.
101 ; Error and AX has error code.
105 push ES ; preserve registers
110 push DS ; Preserve Current BDS
112 push cs ; get ES segment correct
114 push cs ; get DS segment correct
116 mov di,offset tmp_vid
117 mov si,offset nul_vid
119 rep movsb ; initialize tmp_vid to null vi_id
121 pop DI ; Restore Current BDS
123 mov al,byte ptr ds:[di].cFAT ; # of fats
124 mov cx,word ptr ds:[di].csecfat ; sectors / fat
125 mul cl ; size taken by fats
126 add ax,word ptr ds:[di].ressec ; add on reserved sectors
127 ; AX is now sector # (0 based)
128 mov cs:[root_sec],ax ; set initial value
129 mov ax,[di].cDir ; # root dir entries
130 mov cl,4 ; 16 entries/sector
131 shr ax,cl ; divide by 16
132 mov cx,ax ; cx is # of sectors to scan
134 push cx ; save outer loop counter
135 mov ax,cs:[root_sec] ; get sector #
136 mov cx,word ptr ds:[di].seclim ; sectors / track
139 ; set up registers for call to read_sector
140 inc DX ; dx= sectors into track, ax= track count from 0
141 mov cl,dl ; sector to read
143 div word ptr ds:[di].hdlim ; # heads on this disc
144 mov dh,dl ; Head number
146 call read_sector ; get first sector of the root directory,
148 jc ReadVIDErr ; error on read
149 mov cx,16 ; # of dir entries in a block of root
150 mov al,08h ; volume label bit
152 cmp byte ptr es:[bx],0 ; End of dir?
153 jz no_vid ; yes, no vol id
154 cmp byte ptr es:[bx],0E5h ; empty entry?
155 jz ent_loop ; yes, skip
156 test es:[bx+11],al ; is volume label bit set in fcb?
157 jnz found_vid ; jmp yes
159 ADD BX,32 ;MJB003 ADD LENGTH OF DIRECTORY ENTRY ;3.30
162 inc cs:[root_sec] ; next sector
163 loop next_sec ; continue
169 pop cx ; clean stack of outer loop counter
170 mov si,bx ; point to volume_id
171 push ds ; preserve currnet BDS
173 push es ; es:si points to volume id.
174 pop ds ; source segment
176 pop es ; destination segment
177 mov di,offset tmp_vid ; dest of volume_id
178 mov cx,vid_size -1 ; length of string minus NUL
179 rep movsb ; mov volume label to tmp_vid
181 stosb ; Null terminate
183 pop DI ; restore current BDS
189 pop BX ; restore register
195 pop cx ; clean stack of outer loop counter
196 jmp NotFound ; not found
205 ; Transfer_volume_id - copy the volume ID from TMP to special drive
207 ; Inputs: DS:DI nas current BDS
208 ; Outputs: BDS for drive has volume ID from TMP
212 push DS ; preserve current BDS
223 pop DI ; restore current BDS
229 ; Check_Volume_ID - compare volume ID in TMP area with one expected for
232 ; Inputs: DS:DI has current BDS for drive
233 ; Outputs: SI = 0 if compare succeeds
234 ; SI = -1 if compare fails.
237 push DS ; preserve current BDS for drive
243 repz cmpsb ; are the 2 volume_ids the same?
244 mov si,0 ; assume unknown
245 jz check_vid_ret ; carry clear if jump taken
250 pop DI ; restore current BDS
255 ; Fat_Check - see of the fatID has changed in the specified drive.
256 ; - uses the FAT ID obtained from the boot sector.
258 ; Inputs: MedByt is expected FAT ID
259 ; DS:DI points to current BDS
260 ; Output: Carry Clear
261 ; SI = -1 if fat ID different,
263 ; No other registers changed.
267 xor SI, SI ; say FAT ID's are same.
269 cmp AL, byte ptr [DI].Mediad ; compare it with the BDS medbyte
270 jz OKRET1 ; carry clear
278 ; Init_Vid_loop - set up for VID scan or move
280 ; Inputs: DS:DI pionts to BDS for the drive
281 ; Outputs: DS:SI points to tmp_vid
282 ; ES:DI points to vid for drive
283 ; CX has size for VID compare
292 mov si,offset tmp_vid ; source