Skip to content

Commit b5e0e17

Browse files
committed
work in progress towards fixing CDS overwrite issue
git-svn-id: http://svn.code.sf.net/p/fdos/code/trunk@129 d9247ac3-808d-4053-b241-f1a6b6229609
1 parent ce270c2 commit b5e0e17

File tree

1 file changed

+38
-8
lines changed

1 file changed

+38
-8
lines changed

devload.asm

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
; TITLE DEVLOAD to load device drivers from command line.
44
; FORMAT COM
5-
; VERSION 3.22
5+
; VERSION 3.23
66
; CODE 80x86
77
; BUILD NASM -o devload.com in 3.21/newer ***
88
; AUTHOR David Woodhouse
@@ -183,6 +183,9 @@
183183
; Version 3.22 14/7/2011 - Jeremy: if error testing umb size don't fall
184184
; through and do double allocations, 2nd failing
185185

186+
; Version 3.23 02/8/2011 - Jeremy: don't overwrite CDS in use by non-block
187+
; driver
188+
186189
; .............................IMPROVEMENT IDEAS.............................
187190

188191

@@ -527,10 +530,36 @@ noprintladdr: mov ah,52h
527530

528531
; DS:TopCSeg, ES:InvarSeg
529532

530-
; Fetch LastDrUsed and LastDrive from 'invar' (list of lists)
533+
; Fetch nBlkDev and LastDrive from 'invar' (list of lists)
531534

532535
mov ax,[es:bx+20h]
533-
mov word [LastDrUsed],ax
536+
mov word [nBlkDev],ax ; *** updates nBlkDev & LastDrive
537+
538+
; Determine 1st free CDS entry
539+
push bx
540+
push es
541+
542+
; Get pointer to LASTDRIVE array (Current Directory Structure - CDS).
543+
les bx,[es:bx+16h]
544+
545+
; Calculate offset in CDS array of next free entry (>= current # of block devices)
546+
dec al ; AX set earlier to nBlkDev, -1 for zero based
547+
mov [LastDrUsed], al ; default to assume only block drivers have CDS entry
548+
mov ah,[LDrSize]
549+
mul ah
550+
; loop until free entry is found
551+
CDSinuse:
552+
add bx,ax
553+
inc byte [LastDrUsed]
554+
test byte [es:bx+44h], 0C0h ; CDS[AX].flags & 0C00h != 0 then drive in use
555+
jz CDSfound
556+
; increment to next CDS entry
557+
mov al,[LDrSize]
558+
cbw
559+
jmp CDSinuse
560+
CDSfound:
561+
pop es
562+
pop bx
534563

535564
; Fetch max. sector size from 'invar' (list of lists)
536565

@@ -765,11 +794,11 @@ noblocks: mov bl,[CharsDone]
765794
inc dx
766795
chnoplural: int 21h
767796

768-
; Insert new LastDrUsed into 'invar'. (list of lists)
797+
; Insert new nBlkDev into 'invar'. (list of lists)
769798

770799
noprintnuminst: les bx,[Invar]
771800

772-
mov al,[LastDrUsed]
801+
mov al,[nBlkDev]
773802
mov byte [es:bx+20h],al
774803

775804
; Restore driver size in paragraphs.
@@ -1303,9 +1332,9 @@ secsizeok: mov al,[cs:LastDrUsed]
13031332
jnz ldrok
13041333
jmp ldrerr
13051334

1306-
; Increase LastDrUsed.
1335+
; Increase nBlkDev.
13071336

1308-
ldrok: inc byte [cs:LastDrUsed]
1337+
ldrok: inc byte [cs:nBlkDev]
13091338

13101339
; Store absolute block no. and block no. in device.
13111340

@@ -1615,6 +1644,7 @@ EmptyPath dw 0
16151644

16161645
NameBuffer times 80h db 0 ; resb 80h
16171646
1647+
nBlkDev db 0 ; resb 1
16181648
LastDrUsed db 0 ; resb 1
16191649
LastDrive db 0 ; resb 1
16201650

@@ -1655,7 +1685,7 @@ LASTBYTE equ $
16551685

16561686
; ................DATA WHICH ISN'T NEEDED AFTER RELOCATION...................
16571687

1658-
SignOnMsg db 'DEVLOAD v3.22 - load DOS device drivers '
1688+
SignOnMsg db 'DEVLOAD v3.23 - load DOS device drivers '
16591689
db '- license' ; db '- free -'
16601690
db ' GNU General Public License 2',13,10
16611691
db '(c) 1992-2011 David Woodhouse, Eric Auer '

0 commit comments

Comments
 (0)