22
33; TITLE DEVLOAD to load device drivers from command line.
44; FORMAT COM
5- ; VERSION 3.23
5+ ; VERSION 3.24
66; CODE 80x86
77; BUILD NASM -o devload.com in 3.21/newer ***
88; AUTHOR David Woodhouse
186186; Version 3.23 02/8/2011 - Jeremy: don't overwrite CDS in use by non-block
187187; driver
188188
189+ ; Version 3.24 04/08/2011 - Jeremy: improve handling holes in and lack of
190+ ; free CDS better, add /D option to specify
191+ ; which CDS slot to begin free search from -
192+ ; i.e. what drive letter to assign device
193+
189194; .............................IMPROVEMENT IDEAS.............................
190195
191196
@@ -531,6 +536,7 @@ noprintladdr: mov ah,52h
531536 ; DS:TopCSeg, ES:InvarSeg
532537
533538 ; Fetch nBlkDev and LastDrive from 'invar' (list of lists)
539+ int 3
534540
535541 mov ax ,[ es : bx + 20h ]
536542 mov word [ nBlkDev ], ax ; *** updates nBlkDev & LastDrive
@@ -543,17 +549,19 @@ noprintladdr: mov ah,52h
543549 les bx ,[ es : bx + 16h ]
544550
545551 ; 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
552+ mov al ,[ LastDrUsed ] ; [LastDrUsed] init to drive to begin search with
548553 mov ah ,[ LDrSize ]
549554 mul ah
550555 ; loop until free entry is found
551556CDSinuse:
552557 add bx , ax
553- test byte [ es : bx + 44h ], 0C0h ; CDS[AX].flags & 0C00h != 0 then drive in use
558+ test byte [ es : bx + 44h ], 0C0h ; CDS[AX].flags & 0C00h != 0 then drive in use
554559 jz CDSfound
555560 ; increment to next CDS entry
556561 inc byte [ LastDrUsed ]
562+ mov al ,[ LastDrive ]
563+ cmp al ,[ LastDrUsed ]
564+ jb CDSfound ; no free CDS, user notified in InstallDevice
557565 mov al ,[ LDrSize ]
558566 cbw
559567 jmp CDSinuse
@@ -1645,9 +1653,9 @@ EmptyPath dw 0
16451653
16461654NameBuffer times 80h db 0 ; resb 80h
16471655
1648- nBlkDev db 0 ; resb 1 ; Note: nBlkDev & LastDrive
1649- LastDrive db 0 ; resb 1 ; must be together as loaded from LoL together
1650- LastDrUsed db 0 ; resb 1
1656+ nBlkDev db 0 ; resb 1 ; Note: nBlkDev & LastDrive
1657+ LastDrive db 0 ; resb 1 ; must be together as loaded from LoL together
1658+ LastDrUsed db 1 ; default to C:, may be overridden by cmd line option
16511659
16521660OldAllocStr at dw 0 ; resw 1 ; DOS allocation strategy
16531661BlockSize dw 0 ; resw 1
@@ -1686,7 +1694,7 @@ LASTBYTE equ $
16861694
16871695; ................DATA WHICH ISN'T NEEDED AFTER RELOCATION...................
16881696
1689- SignOnMsg db 'DEVLOAD v3.23 - load DOS device drivers '
1697+ SignOnMsg db 'DEVLOAD v3.24 - load DOS device drivers '
16901698 db '- license' ; db '- free -'
16911699 db ' GNU General Public License 2' , 13 , 10
16921700 db '(c) 1992-2011 David Woodhouse, Eric Auer '
@@ -1710,6 +1718,7 @@ HelpMsg1 db 'Usage: DEVLOAD [switches] filename [params]',13,10
17101718 db ' /Q - quiet mode.' , 13 , 10
17111719 db ' /V - verbose mode.' , 13 , 10
17121720 db ' /A - auto-mode (see docs).' , 13 , 10
1721+ db ' /D - drive letter, eg. /DS installs to S: or later.' , 13 , 10
17131722 db 13 , 10
17141723 db 'DEVLOAD is free software. It comes with NO waranty.' , 13 , 10
17151724 db 'Debug hints: self-reloc @ $'
@@ -1913,6 +1922,8 @@ isswitch: lodsw
19131922 jz auto
19141923 cmp ah , 'V'
19151924 jz verbose
1925+ cmp ah , 'D'
1926+ jz driveletter
19161927
19171928 ; Unrecognised switch - print error and exit.
19181929
@@ -1979,7 +1990,14 @@ auto: or byte [cs:ModeFlag],AutoFlag
19791990
19801991quiet: or byte [ cs :ModeFlag ], QuietFlag
19811992 and byte [ cs :ModeFlag ], ~ VerboseFlag
1982- jmp short switchloop ; optimization 3.16
1993+ jmp short switchloop ; optimization 3.16
1994+
1995+ ; Set initial drive letter to assign device to (or 1st available after this one)
1996+ driveletter:
1997+ lodsb ; get drive letter, spaces before it are not supported e.g. /DS
1998+ sub al , 65 ; convert letter to 0 based #, cmd line upcased above so -'A'
1999+ mov [ CS :LastDrUsed ], al
2000+ jmp short switchloop
19832001
19842002 ; Set load into UMB (devicehigh) mode flag.
19852003
0 commit comments