Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1609 lines
32 KiB

  1. page ,160
  2. title bios system initialization
  3. ;
  4. ;----------------------------------------------------------------------------
  5. ;
  6. ; Modification history
  7. ;
  8. ; 26-Feb-1991 sudeepb Ported for NT DOSEm
  9. ;----------------------------------------------------------------------------
  10. include version.inc ; set version build flags
  11. include biosseg.inc ; establish bios segment structure
  12. lf equ 10
  13. cr equ 13
  14. tab equ 9
  15. ; the following depends on the positions of the various letters in switchlist
  16. switchnum equ 11111000b ; which switches require number
  17. include syscall.inc
  18. include doscntry.inc
  19. include devsym.inc
  20. include ioctl.inc
  21. include devmark.inc ; needed
  22. stacksw equ true ;include switchable hardware stacks
  23. if ibmjapver
  24. noexec equ true
  25. else
  26. noexec equ false
  27. endif
  28. sysinitseg segment public
  29. assume cs:sysinitseg,ds:nothing,es:nothing,ss:nothing
  30. extrn badopm:byte,crlfm:byte,badcom:byte,badmem:byte,badblock:byte
  31. extrn badsiz_pre:byte,badld_pre:byte
  32. extrn dosinfo:dword
  33. extrn memory_size:word,fcbs:byte,keep:byte
  34. extrn default_drive:byte,confbot:word,alloclim:word
  35. extrn buffers:word,zero:byte,sepchr:byte
  36. extrn files:byte
  37. extrn count:word,chrptr:word
  38. extrn bufptr:byte,memlo:word,prmblk:byte,memhi:word
  39. extrn ldoff:word,area:word,packet:byte,unitcount:byte,
  40. extrn break_addr:dword,bpb_addr:dword,drivenumber:byte
  41. extrn com_level:byte, cmmt:byte, cmmt1:byte, cmmt2:byte
  42. extrn cmd_indicator:byte
  43. extrn donotshownum:byte
  44. extrn multdeviceflag:byte
  45. extrn devmark_addr:word
  46. extrn setdevmarkflag:byte
  47. extrn org_count:word
  48. extrn pararound:near
  49. extrn getchr:near
  50. extrn stall:near
  51. extrn error_line:near
  52. extrn DevEntry:dword
  53. insert_blank db 0 ; M051: indicates that blank has been
  54. ; M051: inserted
  55. public int24,open_dev,organize,mem_err,newline,calldev,badload
  56. public prndev,auxdev,config,commnd,condev,getnum,badfil,prnerr
  57. public round,delim,print
  58. public parseline,
  59. public setdoscountryinfo,set_country_path,move_asciiz
  60. public cntry_drv,cntry_root,cntry_path
  61. public delim
  62. public pathstring
  63. public MseDev ; NTVDM internal mouse driver
  64. ;
  65. ;----------------------------------------------------------------------------
  66. ;
  67. ; procedure : parseline
  68. ;
  69. ; entry point is parseline. al contains the first character in command line.
  70. ;
  71. ;----------------------------------------------------------------------------
  72. ;
  73. parseline proc near
  74. ; don't get character first time
  75. push ds
  76. push cs
  77. pop ds
  78. assume ds:sysinitseg
  79. nextswtch:
  80. cmp al,cr ; carriage return?
  81. jz done_line
  82. cmp al,lf ; linefeed?
  83. jz put_back ; put it back and done
  84. ; anything less or equal to a space is ignored.
  85. cmp al,' ' ; space?
  86. jbe get_next ; skip over space
  87. cmp al,'/'
  88. jz getparm
  89. stc ; mark error invalid-character-in-input
  90. jmp short exitpl
  91. getparm:
  92. call check_switch
  93. mov word ptr switches,bx ; save switches read so far
  94. jc swterr
  95. get_next:
  96. call getchr
  97. jc done_line
  98. jmp nextswtch
  99. swterr:
  100. jmp short exitpl ; exit if error
  101. done_line:
  102. test word ptr switches,flagdrive ; see if drive specified
  103. jnz okay
  104. stc ; mark error no-drive-specified
  105. jmp short exitpl
  106. okay:
  107. ; mov ax,word ptr switches
  108. ; and ax,0003h ; get flag bits for changeline and non-rem
  109. ; mov word ptr deviceparameters.dp_deviceattributes,ax
  110. ; mov word ptr deviceparameters.dp_tracktableentries, 0
  111. ; clc ; everything is fine
  112. ; call setdeviceparameters
  113. exitpl:
  114. pop ds
  115. ret
  116. put_back:
  117. inc count ; one more char to scan
  118. dec chrptr ; back up over linefeed
  119. jmp short done_line
  120. parseline endp
  121. ;
  122. ;----------------------------------------------------------------------------
  123. ;
  124. ; procedure : check_switch
  125. ;
  126. ; processes a switch in the input. it ensures that the switch is valid, and
  127. ; gets the number, if any required, following the switch. the switch and the
  128. ; number *must* be separated by a colon. carry is set if there is any kind of
  129. ; error.
  130. ;
  131. ;----------------------------------------------------------------------------
  132. ;
  133. check_switch proc near
  134. call getchr
  135. jc err_check
  136. and al,0dfh ; convert it to upper case
  137. cmp al,'A'
  138. jb err_check
  139. cmp al,'Z'
  140. ja err_check
  141. push es
  142. push cs
  143. pop es
  144. mov cl,byte ptr switchlist ; get number of valid switches
  145. mov ch,0
  146. mov di,1+offset switchlist ; point to string of valid switches
  147. repne scasb
  148. pop es
  149. jnz err_check
  150. mov ax,1
  151. shl ax,cl ; set bit to indicate switch
  152. mov bx,word ptr switches ; get switches so far
  153. or bx,ax ; save this with other switches
  154. mov cx,ax
  155. test ax, switchnum ; test against switches that require number to follow
  156. jz done_swtch
  157. call getchr
  158. jc err_swtch
  159. cmp al,':'
  160. jnz err_swtch
  161. call getchr
  162. push bx ; preserve switches
  163. mov byte ptr cs:sepchr,' ' ; allow space separators
  164. call getnum
  165. mov byte ptr cs:sepchr,0
  166. pop bx ; restore switches
  167. ; because getnum does not consider carriage-return or line-feed as ok, we do
  168. ; not check for carry set here. if there is an error, it will be detected
  169. ; further on (hopefully).
  170. call process_num
  171. done_swtch:
  172. clc
  173. ret
  174. err_swtch:
  175. xor bx,cx ; remove this switch from the records
  176. err_check:
  177. stc
  178. ret
  179. check_switch endp
  180. ;
  181. ;----------------------------------------------------------------------------
  182. ;
  183. ; procedure : process_num
  184. ;
  185. ; this routine takes the switch just input, and the number following (if any),
  186. ; and sets the value in the appropriate variable. if the number input is zero
  187. ; then it does nothing - it assumes the default value that is present in the
  188. ; variable at the beginning. zero is ok for form factor and drive, however.
  189. ;
  190. ;----------------------------------------------------------------------------
  191. ;
  192. process_num proc near
  193. test word ptr switches,cx ; if this switch has been done before,
  194. jnz done_ret ; ignore this one.
  195. test cx,flagdrive
  196. jz try_f
  197. mov byte ptr drive,al
  198. jmp short done_ret
  199. try_f:
  200. test cx,flagff
  201. jz try_t
  202. ; ensure that we do not get bogus form factors that are not supported
  203. ; mov byte ptr deviceparameters.dp_devicetype,al
  204. jmp short done_ret
  205. try_t:
  206. or ax,ax
  207. jz done_ret ; if number entered was 0, assume default value
  208. test cx,flagcyln
  209. jz try_s
  210. ; mov word ptr deviceparameters.dp_cylinders,ax
  211. jmp short done_ret
  212. try_s:
  213. test cx,flagseclim
  214. jz try_h
  215. mov word ptr slim,ax
  216. jmp short done_ret
  217. ; must be for number of heads
  218. try_h:
  219. mov word ptr hlim,ax
  220. done_ret:
  221. clc
  222. ret
  223. process_num endp
  224. ;
  225. ;----------------------------------------------------------------------------
  226. ;
  227. ; procedure : organize
  228. ;
  229. ;----------------------------------------------------------------------------
  230. ;
  231. assume ds:nothing, es:nothing
  232. organize proc near
  233. mov cx,[count]
  234. jcxz nochar1
  235. call mapcase
  236. xor si,si
  237. mov di,si
  238. xor ax,ax
  239. mov com_level, 0
  240. ;org1: call get ;skip leading control characters
  241. ; cmp al,' '
  242. ; jb org1
  243. org1:
  244. call skip_comment
  245. jz end_commd_line ; found a comment string and skipped.
  246. call get2 ; not a comment string. then get a char.
  247. cmp al, lf
  248. je end_commd_line ; starts with a blank line.
  249. cmp al, ' '
  250. jbe org1 ; skip leading control characters
  251. jmp short findit
  252. end_commd_line:
  253. stosb ; store line feed char in buffer for the linecount.
  254. mov com_level, 0 ; reset the command level.
  255. jmp org1
  256. nochar1:
  257. stc
  258. ret
  259. findit:
  260. push cx
  261. push si
  262. push di
  263. mov bp,si
  264. dec bp
  265. mov si,offset comtab ;prepare to search command table
  266. mov ch,0
  267. findcom:
  268. mov di,bp
  269. mov cl,[si]
  270. inc si
  271. jcxz nocom
  272. repe cmpsb
  273. lahf
  274. add si,cx ;bump to next position without affecting flags
  275. sahf
  276. lodsb ;get indicator letter
  277. jnz findcom
  278. cmp byte ptr es:[di], cr ;the next char might be cr,lf
  279. je gotcom0 ; such as in "rem",cr,lf case.
  280. cmp byte ptr es:[di], lf
  281. je gotcom0
  282. push ax
  283. mov al, byte ptr es:[di] ;now the next char. should be a delim.
  284. call delim
  285. pop ax
  286. jnz findcom
  287. gotcom0:
  288. pop di
  289. pop si
  290. pop cx
  291. jmp short gotcom
  292. nocom:
  293. pop di
  294. pop si
  295. pop cx
  296. mov al,'Z'
  297. stosb ; save indicator char.
  298. skip_line:
  299. call get2
  300. cmp al, lf ; skip this bad command line
  301. jne skip_line
  302. jmp end_commd_line ; handle next command line
  303. gotcom: stosb ;save indicator char in buffer
  304. mov cmd_indicator, al ; save it for the future use.
  305. org2: call get2 ;skip the commad name until delimiter
  306. cmp al, lf
  307. je org21
  308. cmp al, cr
  309. je org21
  310. call delim
  311. jnz org2
  312. jmp short org3
  313. org21: ;if cr or lf then
  314. dec si ; undo si, cx register
  315. inc cx ; and continue
  316. org3:
  317. cmp cmd_indicator, 'Y' ; comment= command?
  318. je get_cmt_token
  319. cmp cmd_indicator, 'I' ; install= command?
  320. je org_file
  321. cmp cmd_indicator, 'D' ; device= command?
  322. je org_file
  323. cmp cmd_indicator, 'S' ; shell= is a special one!!!
  324. je org_file
  325. cmp cmd_indicator, '1' ; switches= command?
  326. je org_switch
  327. jmp org4
  328. org_switch:
  329. call skip_comment
  330. jz end_commd_line_brdg
  331. call get2
  332. call org_delim
  333. jz org_switch
  334. stosb
  335. jmp org5
  336. org_file: ; get the filename and put 0 at end,
  337. call skip_comment
  338. jz org_put_zero
  339. call get2 ; not a comment
  340. call delim
  341. jz org_file ; skip the possible delimeters
  342. stosb ; copy the first non delim char found in buffer
  343. org_copy_file:
  344. call skip_comment ; comment char in the filename?
  345. jz org_put_zero ; then stop copying filename at that point
  346. call get2
  347. cmp al, '/' ; a switch char? (device=filename/xxx)
  348. je end_file_slash ; this will be the special case.
  349. stosb ; save the char. in buffer
  350. call delim
  351. jz end_copy_file
  352. cmp al, ' '
  353. ja org_copy_file ; keep copying
  354. jmp short end_copy_file ; otherwise, assume end of the filename.
  355. get_cmt_token: ; get the token. just max. 2 char.
  356. call get2
  357. cmp al, ' ' ; skip white spaces or "=" char.
  358. je get_cmt_token ; (we are allowing the other special
  359. cmp al, tab ; charaters can used for comment id.
  360. je get_cmt_token ; character.)
  361. cmp al, '=' ; = is special in this case.
  362. je get_cmt_token
  363. cmp al, cr
  364. je get_cmt_end ; cannot accept the carridge return
  365. cmp al, lf
  366. je get_cmt_end
  367. mov cmmt1, al ; store it
  368. mov cmmt, 1 ; 1 char. so far.
  369. call get2
  370. cmp al, ' '
  371. je get_cmt_end
  372. cmp al, tab
  373. je get_cmt_end
  374. cmp al, cr
  375. je get_cmt_end
  376. cmp al, lf
  377. je end_commd_line_brdg
  378. mov cmmt2, al
  379. inc cmmt
  380. get_cmt_end:
  381. call get2
  382. cmp al, lf
  383. jne get_cmt_end ; skip it.
  384. end_commd_line_brdg: jmp end_commd_line ; else jmp to end_commd_line
  385. org_put_zero: ; make the filename in front of
  386. mov byte ptr es:[di], 0 ; the comment string to be an asciiz.
  387. inc di
  388. jmp end_commd_line ; (maybe null if device=/*)
  389. end_file_slash: ; al = "/" option char.
  390. mov byte ptr es:[di],0 ; make a filename an asciiz
  391. inc di ; and
  392. stosb ; store "/" after that.
  393. jmp short org5 ; continue with the rest of the line
  394. end_copy_file:
  395. mov byte ptr es:[di-1], 0 ; make it an asciiz and handle the next char.
  396. cmp al, lf
  397. je end_commd_line_brdg
  398. jmp short org5
  399. org4: ; org4 skips all delimiters after the command name except for '/'
  400. call skip_comment
  401. jz end_commd_line_brdg
  402. call get2
  403. call org_delim ; skip delimiters except '/' (mrw 4/88)
  404. jz org4
  405. jmp short org51
  406. org5: ; rest of the line
  407. call skip_comment ; comment?
  408. jz end_commd_line_brdg
  409. call get2 ; not a comment.
  410. org51:
  411. stosb ; copy the character
  412. cmp al, '"' ; a quote ?
  413. je at_quote
  414. cmp al, ' '
  415. ja org5
  416. ; M051 - Start
  417. cmp cmd_indicator, 'U' ; Q: is this devicehigh
  418. jne not_dh ; N:
  419. cmp al, lf ; Q: is this line feed
  420. je org_dhlf ; Y: stuff a blank before the lf
  421. cmp al, cr ; Q: is this a cr
  422. jne org5 ; N:
  423. mov byte ptr es:[di-1], ' ' ; overwrite cr with blank
  424. stosb ; put cr after blank
  425. inc [insert_blank] ; indicate that blank has been
  426. ; inserted
  427. jmp org5
  428. not_dh: ; M051 - End
  429. cmp al, lf ; line feed?
  430. je org1_brdg ; handles the next command line.
  431. jmp org5 ; handles next char in this line.
  432. org_dhlf: ; M051 - Start
  433. cmp [insert_blank], 1 ; Q:has a blank already been inserted
  434. je org1_brdg ; Y:
  435. mov byte ptr es:[di-1], ' ' ; overwrite lf with blank
  436. stosb ; put lf after blank
  437. ; M051 - End
  438. org1_brdg:
  439. mov [insert_blank], 0 ; M051: clear blank indicator for
  440. ; M051: devicehigh
  441. jmp org1
  442. at_quote:
  443. cmp com_level, 0
  444. je up_level
  445. mov com_level, 0 ; reset it.
  446. jmp org5
  447. up_level:
  448. inc com_level ; set it.
  449. jmp org5
  450. organize endp
  451. ;
  452. ;----------------------------------------------------------------------------
  453. ;
  454. ; procedure : get2
  455. ;
  456. ;----------------------------------------------------------------------------
  457. ;
  458. get2 proc near
  459. jcxz noget
  460. mov al,es:[si]
  461. inc si
  462. dec cx
  463. od_ret:
  464. ret
  465. noget:
  466. pop cx
  467. mov count,di
  468. mov org_count, di
  469. xor si,si
  470. mov chrptr,si
  471. ng_ret:
  472. ret
  473. get2 endp
  474. ;
  475. ;----------------------------------------------------------------------------
  476. ;
  477. ; procedure : skip_comment
  478. ;
  479. ;skip the commented string until lf, if current es:si-> a comment string.
  480. ;in) es:si-> sting
  481. ; cx -> length.
  482. ;out) zero flag not set if not found a comment string.
  483. ; zero flag set if found a comment string and skipped it. al will contain
  484. ; the line feed charater at this moment when return.
  485. ; ax register destroyed.
  486. ; if found, si, cx register adjusted accordingly.
  487. ;
  488. ;----------------------------------------------------------------------------
  489. ;
  490. skip_comment proc near
  491. jcxz noget ; get out of the organize routine.
  492. cmp com_level, 0 ; only check it if parameter level is 0.
  493. jne no_commt ; (not inside quotations)
  494. cmp cmmt, 1
  495. jb no_commt
  496. mov al, es:[si]
  497. cmp cmmt1, al
  498. jne no_commt
  499. cmp cmmt, 2
  500. jne skip_cmmt
  501. mov al, es:[si+1]
  502. cmp cmmt2, al
  503. jne no_commt
  504. skip_cmmt:
  505. jcxz noget ; get out of organize routine.
  506. mov al, es:[si]
  507. inc si
  508. dec cx
  509. cmp al, lf ; line feed?
  510. jne skip_cmmt
  511. no_commt:
  512. ret
  513. skip_comment endp
  514. ;
  515. ;----------------------------------------------------------------------------
  516. ;
  517. ; procedure : delim
  518. ;
  519. ;----------------------------------------------------------------------------
  520. ;
  521. delim proc near
  522. cmp al,'/' ; ibm will assume "/" as an delimeter.
  523. jz delim_ret
  524. cmp al, 0 ; special case for sysinit!!!
  525. jz delim_ret
  526. org_delim: ; used by organize routine except for getting
  527. cmp al,' ' ;the filename.
  528. jz delim_ret
  529. cmp al,9
  530. jz delim_ret
  531. cmp al,'='
  532. jz delim_ret
  533. cmp al,','
  534. jz delim_ret
  535. cmp al,';'
  536. delim_ret:
  537. ret
  538. delim endp
  539. ;
  540. ;----------------------------------------------------------------------------
  541. ;
  542. ; procedure : newline
  543. ;
  544. ; newline returns with first character of next line
  545. ;
  546. ;----------------------------------------------------------------------------
  547. ;
  548. newline proc near
  549. call getchr ;skip non-control characters
  550. jc nl_ret
  551. cmp al,lf ;look for line feed
  552. jnz newline
  553. call getchr
  554. nl_ret:
  555. ret
  556. newline endp
  557. ;
  558. ;----------------------------------------------------------------------------
  559. ;
  560. ; procedure : mapcase
  561. ;
  562. ;----------------------------------------------------------------------------
  563. ;
  564. mapcase proc near
  565. push cx
  566. push si
  567. push ds
  568. push es
  569. pop ds
  570. xor si,si
  571. convloop:
  572. lodsb
  573. ifdef DBCS
  574. call testkanj
  575. jz normconv ; if this is not lead byte
  576. mov ah,al
  577. lodsb ; get tail byte
  578. cmp ax,DB_SPACE
  579. jnz @f ; if this is not dbcs space
  580. mov word ptr [si-2],' ' ; set 2 single space
  581. @@:
  582. dec cx
  583. jcxz convdone ;just ignore 1/2 kanji error
  584. jmp short noconv
  585. ;fall through, know al is not in 'a'-'z' range
  586. normconv:
  587. endif
  588. cmp al,'a'
  589. jb noconv
  590. cmp al,'z'
  591. ja noconv
  592. sub al,20h
  593. mov [si-1],al
  594. noconv:
  595. loop convloop
  596. convdone:
  597. pop ds
  598. pop si
  599. pop cx
  600. ret
  601. ifdef DBCS
  602. public testkanj
  603. testkanj:
  604. push si
  605. push ds
  606. push ax
  607. mov ax,6300h ; get dos dbcs vector
  608. int 21h
  609. pop ax
  610. bdbcs_do:
  611. cmp ds:word ptr [si],0 ; end of lead byte info?
  612. jz bdbcs_notfound ; jump if so
  613. cmp al,ds:[si] ; less than first byte character?
  614. jb bdbcs_next ; jump if not
  615. cmp al,ds:[si+1] ; grater than first byte character?
  616. ja bdbcs_next
  617. bdbcs_found:
  618. push ax
  619. xor ax,ax
  620. inc ax ; reset zero flag
  621. pop ax
  622. bdbcs_exit:
  623. pop ds
  624. pop si
  625. ret
  626. bdbcs_notfound:
  627. push ax
  628. xor ax,ax ; set zero flag
  629. pop ax
  630. jmp short bdbcs_exit
  631. bdbcs_next:
  632. add si,2 ; points next lead byte table
  633. jmp short bdbcs_do
  634. endif ; DBCS
  635. mapcase endp
  636. ;
  637. ;----------------------------------------------------------------------------
  638. ;
  639. ; procedure : round
  640. ;
  641. ; round the values in memlo and memhi to paragraph boundary.
  642. ; perform bounds check.
  643. ;
  644. ;----------------------------------------------------------------------------
  645. ;
  646. round proc near
  647. push ax
  648. mov ax,[memlo]
  649. call pararound ; para round up
  650. add [memhi],ax
  651. mov [memlo],0
  652. mov ax,memhi ; ax = new memhi
  653. cmp ax,[alloclim] ; if new memhi >= alloclim, error
  654. jae mem_err
  655. test cs:[setdevmarkflag], for_devmark
  656. jz skip_set_devmarksize
  657. push es
  658. push si
  659. mov si, cs:[devmark_addr]
  660. mov es, si
  661. sub ax, si
  662. dec ax
  663. mov es:[devmark_size], ax ; paragraph
  664. and cs:[setdevmarkflag], not_for_devmark
  665. pop si
  666. pop es
  667. skip_set_devmarksize:
  668. pop ax
  669. clc ;clear carry
  670. ret
  671. mem_err:
  672. mov dx,offset badmem
  673. push cs
  674. pop ds
  675. call print
  676. jmp stall
  677. round endp
  678. ;
  679. ;----------------------------------------------------------------------------
  680. ;
  681. ; procedure : calldev
  682. ;
  683. ;----------------------------------------------------------------------------
  684. ;
  685. calldev proc near
  686. mov ds,word ptr cs:[DevEntry+2]
  687. add bx,word ptr cs:[DevEntry] ;do a little relocation
  688. mov ax,ds:[bx]
  689. push word ptr cs:[DevEntry]
  690. mov word ptr cs:[DevEntry],ax
  691. mov bx,offset packet
  692. call [DevEntry]
  693. pop word ptr cs:[DevEntry]
  694. ret
  695. calldev endp
  696. ;
  697. ;----------------------------------------------------------------------------
  698. ;
  699. ; procedure : todigit
  700. ;
  701. ;----------------------------------------------------------------------------
  702. ;
  703. todigit proc near
  704. sub al,'0'
  705. jb notdig
  706. cmp al,9
  707. ja notdig
  708. clc
  709. ret
  710. notdig:
  711. stc
  712. ret
  713. todigit endp
  714. ;
  715. ;----------------------------------------------------------------------------
  716. ;
  717. ; procedure : getnum
  718. ;
  719. ; getnum parses a decimal number.
  720. ; returns it in ax, sets zero flag if ax = 0 (may be considered an
  721. ; error), if number is bad carry is set, zero is set, ax=0.
  722. ;
  723. ;----------------------------------------------------------------------------
  724. ;
  725. getnum proc near
  726. push bx
  727. xor bx,bx ; running count is zero
  728. b2:
  729. call todigit ; do we have a digit
  730. jc badnum ; no, bomb
  731. xchg ax,bx ; put total in ax
  732. push bx ; save digit
  733. mov bx,10 ; base of arithmetic
  734. mul bx ; shift by one decimal di...
  735. pop bx ; get back digit
  736. add al,bl ; get total
  737. adc ah,0 ; make that 16 bits
  738. jc badnum ; too big a number
  739. xchg ax,bx ; stash total
  740. call getchr ;get next digit
  741. jc b1 ; no more characters
  742. cmp al, ' ' ; space?
  743. jz b15 ; then end of digits
  744. cmp al, ',' ; ',' is a seperator!!!
  745. jz b15 ; then end of digits.
  746. cmp al, tab ; tab
  747. jz b15
  748. cmp al,sepchr ; allow 0 or special separators
  749. jz b15
  750. cmp al,'/' ; see if another switch follows
  751. nop ; cas - remnant of old bad code
  752. nop
  753. jz b15
  754. cmp al,lf ; line-feed?
  755. jz b15
  756. cmp al,cr ; carriage return?
  757. jz b15
  758. or al,al ; end of line separator?
  759. jnz b2 ; no, try as a valid char...
  760. b15:
  761. inc count ; one more character to s...
  762. dec chrptr ; back up over separator
  763. b1:
  764. mov ax,bx ; get proper count
  765. or ax,ax ; clears carry, sets zero accordingly
  766. pop bx
  767. ret
  768. badnum:
  769. mov sepchr,0
  770. xor ax,ax ; set zero flag, and ax = 0
  771. pop bx
  772. stc ; and carry set
  773. ret
  774. getnum endp
  775. ;*****************************************************************
  776. setdoscountryinfo proc near
  777. ;input: es:di -> pointer to dos_country_cdpg_info
  778. ; ds:0 -> buffer.
  779. ; si = 0
  780. ; ax = country id
  781. ; dx = code page id. (if 0, then use ccsyscodepage as a default.)
  782. ; bx = file handle
  783. ; this routine can handle maxium 438 country_data entries.
  784. ;
  785. ;output: dos_country_cdpg_info set.
  786. ; carry set if any file read failure or wrong information in the file.
  787. ; carry set and cx = -1 if cannot find the matching country_id, codepage
  788. ; _id in the file.
  789. push di
  790. push ax
  791. push dx
  792. xor cx,cx
  793. xor dx,dx
  794. mov ax,512 ;read 512 bytes
  795. call readincontrolbuffer ;read the file header
  796. jc setdosdata_fail
  797. push es
  798. push si
  799. push cs
  800. pop es
  801. mov di,offset country_file_signature
  802. mov cx,8 ;length of the signature
  803. repz cmpsb
  804. pop si
  805. pop es
  806. jnz setdosdata_fail ;signature mismatch
  807. add si,18 ;si -> county info type
  808. cmp byte ptr ds:[si],1 ;only accept type 1 (currently only 1 header type)
  809. jne setdosdata_fail ;cannot proceed. error return
  810. inc si ;si -> file offset
  811. mov dx,word ptr ds:[si] ;get the info file offset.
  812. mov cx,word ptr ds:[si+2]
  813. mov ax,6144 ;read 6144 bytes.
  814. call readincontrolbuffer ;read info
  815. jc setdosdata_fail
  816. mov cx, word ptr ds:[si] ;get the # of country, codepage combination entries
  817. cmp cx, 438 ;cannot handle more than 438 entries.
  818. ;
  819. ja setdosdata_fail
  820. inc si
  821. inc si ;si -> entry information packet
  822. pop dx ;restore code page id
  823. pop ax ;restore country id
  824. pop di
  825. setdoscntry_find: ;search for desired country_id,codepage_id.
  826. cmp ax, word ptr ds:[si+2] ;compare country_id
  827. jne setdoscntry_next
  828. cmp dx, 0 ;no user specified code page ?
  829. je setdoscntry_any_codepage;then no need to match code page id.
  830. cmp dx, word ptr ds:[si+4] ;compare code page id
  831. je setdoscntry_got_it
  832. setdoscntry_next:
  833. add si, word ptr ds:[si] ;next entry
  834. inc si
  835. inc si ;take a word for size of entry itself
  836. loop setdoscntry_find
  837. mov cx, -1 ;signals that bad country id entered.
  838. setdoscntry_fail:
  839. stc
  840. ret
  841. setdosdata_fail:
  842. pop si
  843. pop cx
  844. pop di
  845. jmp short setdoscntry_fail
  846. setdoscntry_any_codepage: ;use the code_page_id of the country_id found.
  847. mov dx, word ptr ds:[si+4]
  848. setdoscntry_got_it: ;found the matching entry
  849. mov cs:cntrycodepage_id, dx ;save code page id for this country.
  850. mov dx, word ptr ds:[si+10] ;get the file offset of country data
  851. mov cx, word ptr ds:[si+12]
  852. mov ax, 512 ;read 512 bytes
  853. call readincontrolbuffer
  854. jc setdoscntry_fail
  855. mov cx, word ptr ds:[si] ;get the number of entries to handle.
  856. inc si
  857. inc si ;si -> first entry
  858. setdoscntry_data:
  859. push di ;es:di -> dos_country_cdpg_info
  860. push cx ;save # of entry left
  861. push si ;si -> current entry in control buffer
  862. mov al, byte ptr ds:[si+2] ;get data entry id
  863. call getcountrydestination ;get the address of destination in es:di
  864. jc setdoscntry_data_next ;no matching data entry id in dos
  865. mov dx, word ptr ds:[si+4] ;get offset of data
  866. mov cx, word ptr ds:[si+6]
  867. mov ax,4200h
  868. stc
  869. int 21h ;move pointer
  870. jc setdosdata_fail
  871. mov dx,512 ;start of data buffer
  872. mov cx,20 ;read 20 bytes only. we only need to
  873. mov ah,3fh ;look at the length of the data in the file.
  874. stc
  875. int 21h ;read the country.sys data
  876. jc setdosdata_fail ;read failure
  877. cmp ax,cx
  878. jne setdosdata_fail
  879. mov dx,word ptr ds:[si+4] ;get offset of data again.
  880. mov cx,word ptr ds:[si+6]
  881. mov ax,4200h
  882. stc
  883. int 21h ;move pointer back again
  884. jc setdosdata_fail
  885. push si
  886. mov si,(512+8) ;get length of the data from the file
  887. mov cx,word ptr ds:[si]
  888. pop si
  889. mov dx,512 ;start of data buffer
  890. add cx,10 ;signature + a word for the length itself
  891. mov ah,3fh ;read the data from the file.
  892. stc
  893. int 21h
  894. jc setdosdata_fail
  895. cmp ax, cx
  896. jne setdosdata_fail
  897. mov al,byte ptr ds:[si+2] ;save data id for future use.
  898. mov si,(512+8) ;si-> data buffer + id tag field
  899. mov cx,word ptr ds:[si] ;get the length of the file
  900. inc cx ;take care of a word for lenght of tab
  901. inc cx ;itself.
  902. cmp cx,(2048 - 512 - 8) ;fit into the buffer?
  903. ja setdosdata_fail
  904. if bugfix
  905. call setdbcs_before_copy
  906. endif
  907. cmp al, setcountryinfo ;is the data for setcountryinfo table?
  908. jne setdoscntry_mov ;no, don't worry
  909. push word ptr es:[di+ccmono_ptr-cccountryinfolen] ;cannot destroy ccmono_ptr address. save them.
  910. push word ptr es:[di+ccmono_ptr-cccountryinfolen+2] ;at this time di -> cccountryinfolen
  911. push di ;save di
  912. push ax
  913. mov ax,cs:cntrycodepage_id ;do not use the code page info in country_info
  914. mov ds:[si+4], ax ;use the saved one for this !!!!
  915. pop ax
  916. setdoscntry_mov:
  917. rep movsb ;copy the table into dos
  918. cmp al, setcountryinfo ;was the ccmono_ptr saved?
  919. jne setdoscntry_data_next
  920. pop di ;restore di
  921. pop word ptr es:[di+ccmono_ptr-cccountryinfolen+2] ;restore
  922. pop word ptr es:[di+ccmono_ptr-cccountryinfolen]
  923. setdoscntry_data_next:
  924. pop si ;restore control buffer pointer
  925. pop cx ;restore # of entries left
  926. pop di ;restore pointer to dso_country_cdpg
  927. add si, word ptr ds:[si] ;try to get the next entry
  928. inc si
  929. inc si ;take a word of entry length itself
  930. dec cx
  931. cmp cx,0
  932. je setdoscntry_ok
  933. jmp setdoscntry_data
  934. setdoscntry_ok:
  935. ret
  936. setdoscountryinfo endp
  937. if bugfix
  938. setdbcs_before_copy proc near
  939. cmp al,setdbcs ; dbcs vector set?
  940. jnz @f ; jump if not
  941. cmp word ptr es:[di], 0 ; zero byte data block?
  942. jz @f ; jump if so
  943. push di
  944. push ax
  945. push cx
  946. mov cx,es:[di] ; load block length
  947. add di,2 ; points actual data
  948. xor al,al ; fill bytes
  949. rep stosb ; clear data block
  950. pop cx
  951. pop ax
  952. pop di
  953. @@:
  954. ret
  955. setdbcs_before_copy endp
  956. endif
  957. getcountrydestination proc near
  958. ;get the destination address in the dos country info table.
  959. ;input: al - data id
  960. ; es:di -> dos_country_cdpg_info
  961. ;on return:
  962. ; es:di -> destination address of the matching data id
  963. ; carry set if no matching data id found in dos.
  964. push cx
  965. add di,ccnumber_of_entries ;skip the reserved area, syscodepage etc.
  966. mov cx,word ptr es:[di] ;get the number of entries
  967. inc di
  968. inc di ;si -> the first start entry id
  969. getcntrydest:
  970. cmp byte ptr es:[di],al
  971. je getcntrydest_ok
  972. cmp byte ptr es:[di],setcountryinfo ;was it setcountryinfo entry?
  973. je getcntrydest_1
  974. add di,5 ;next data id
  975. jmp short getcntrydest_loop
  976. getcntrydest_1:
  977. add di,new_country_size + 3 ;next data id
  978. getcntrydest_loop:
  979. loop getcntrydest
  980. stc
  981. jmp short getcntrydest_exit
  982. getcntrydest_ok:
  983. cmp al,setcountryinfo ;select country info?
  984. jne getcntrydest_ok1
  985. inc di ;now di -> cccountryinfolen
  986. jmp short getcntrydest_exit
  987. getcntrydest_ok1:
  988. les di,dword ptr es:[di+1] ;get the destination in es:di
  989. getcntrydest_exit:
  990. pop cx
  991. ret
  992. getcountrydestination endp
  993. readincontrolbuffer proc near
  994. ;move file pointer to cx:dx
  995. ;read ax bytes into the control buffer. (should be less than 2 kb)
  996. ;si will be set to 0 hence ds:si points to the control buffer.
  997. ;entry: cx,dx offset from the start of the file where the read/write pointer
  998. ; be moved.
  999. ; ax - # of bytes to read
  1000. ; bx - file handle
  1001. ; ds - buffer seg.
  1002. ;return: the control data information is read into ds:0 - ds:0200.
  1003. ; cx,dx value destroyed.
  1004. ; carry set if error in reading file.
  1005. push ax ;# of bytes to read
  1006. mov ax, 4200h
  1007. stc
  1008. int 21h ;move pointer
  1009. pop cx ;# of bytes to read
  1010. jc ricb_exit
  1011. xor dx,dx ;ds:dx -> control buffer
  1012. xor si,si
  1013. mov ah,3fh ;read into the buffer
  1014. stc
  1015. int 21h ;should be less than 1024 bytes.
  1016. ricb_exit:
  1017. ret
  1018. readincontrolbuffer endp
  1019. set_country_path proc near
  1020. ;in: ds - sysinitseg, es - confbot, si -> start of the asciiz path string
  1021. ; dosinfo_ext, cntry_drv, cntry_root, cntry_path
  1022. ; assumes current directory is the root directory.
  1023. ;out: ds:di -> full path (cntry_drv).
  1024. ; set the cntry_drv string from the country=,,path command.
  1025. ; ds, es, si value saved.
  1026. push si
  1027. push ds ;switch ds, es
  1028. push es
  1029. pop ds
  1030. pop es ;now ds -> confbot, es -> sysinitseg
  1031. call chk_drive_letter ;current ds:[si] is a drive letter?
  1032. jc scp_default_drv ;no, use current default drive.
  1033. mov al, byte ptr ds:[si]
  1034. inc si
  1035. inc si ;si -> next char after ":"
  1036. jmp short scp_setdrv
  1037. scp_default_drv:
  1038. mov ah, 19h
  1039. int 21h
  1040. add al, "A" ;convert it to a character.
  1041. scp_setdrv:
  1042. mov cs:cntry_drv, al ;set the drive letter.
  1043. mov di, offset cntry_path
  1044. mov al, byte ptr ds:[si]
  1045. cmp al, "\"
  1046. je scp_root_dir
  1047. cmp al,"/" ;let's accept "/" as an directory delim
  1048. je scp_root_dir
  1049. jmp short scp_path
  1050. scp_root_dir:
  1051. dec di ;di -> cntry_root
  1052. scp_path:
  1053. call move_asciiz ;copy it
  1054. mov di, offset cntry_drv
  1055. scpath_exit:
  1056. push ds ;switch ds, es
  1057. push es
  1058. pop ds
  1059. pop es ;ds, es value restored
  1060. pop si
  1061. ret
  1062. set_country_path endp
  1063. chk_drive_letter proc near
  1064. ;check if ds:[si] is a drive letter followed by ":".
  1065. ;assume that every alpha charater is already converted to upper case.
  1066. ;carry set if not.
  1067. push ax
  1068. cmp byte ptr ds:[si], "A"
  1069. jb cdletter_no
  1070. cmp byte ptr ds:[si], "Z"
  1071. ja cdletter_no
  1072. cmp byte ptr ds:[si+1], ":"
  1073. jne cdletter_no
  1074. jmp short cdletter_exit
  1075. cdletter_no:
  1076. stc
  1077. cdletter_exit:
  1078. pop ax
  1079. ret
  1080. chk_drive_letter endp
  1081. move_asciiz proc near
  1082. ;in: ds:si -> source es:di -> target
  1083. ;out: copy the string until 0.
  1084. ;assumes there exists a 0.
  1085. masciiz_loop:
  1086. movsb
  1087. cmp byte ptr ds:[si-1],0 ;was it 0?
  1088. jne masciiz_loop
  1089. ret
  1090. move_asciiz endp
  1091. ;
  1092. ; ds:dx points to string to output (asciz)
  1093. ;
  1094. ; prints <badld_pre> <string> <badld_post>
  1095. badfil:
  1096. push cs
  1097. pop es
  1098. mov si,dx
  1099. badload:
  1100. mov dx,offset badld_pre ;want to print config error
  1101. mov bx, offset crlfm
  1102. prnerr:
  1103. push cs
  1104. pop ds
  1105. call print
  1106. prn1:
  1107. mov dl,es:[si]
  1108. or dl,dl
  1109. jz prn2
  1110. mov ah,std_con_output
  1111. int 21h
  1112. inc si
  1113. jmp prn1
  1114. prn2:
  1115. mov dx,bx
  1116. call print
  1117. cmp donotshownum,1 ; suppress line number when handling command.com
  1118. je prnexit
  1119. call error_line
  1120. prnexit:
  1121. ret
  1122. print:
  1123. cmp cs:bEchoConfig, 0 ; NTVDM skip print call, Jonle
  1124. je prnexit
  1125. mov ah,std_con_string_output
  1126. int 21h
  1127. ret
  1128. if noexec
  1129. ; load non exe file called [ds:dx] at memory location es:bx
  1130. ldfil:
  1131. push ax
  1132. push bx
  1133. push cx
  1134. push dx
  1135. push si
  1136. push ds
  1137. push bx
  1138. xor ax,ax ;open the file
  1139. mov ah,open
  1140. stc ;in case of int 24
  1141. int 21h
  1142. pop dx ;clean stack in case jump
  1143. jc ldret
  1144. push dx
  1145. mov bx,ax ;handle in bx
  1146. xor cx,cx
  1147. xor dx,dx
  1148. mov ax,(lseek shl 8) or 2
  1149. stc ;in case of int 24
  1150. int 21h ; get file size in dx:ax
  1151. jc ldclsp
  1152. or dx,dx
  1153. jnz lderrp ; file >64k
  1154. pop dx
  1155. push dx
  1156. mov cx,es ; cx:dx is xaddr
  1157. add dx,ax ; add file size to xaddr
  1158. jnc dosize
  1159. add cx,1000h ; ripple carry
  1160. dosize:
  1161. mov ax,dx
  1162. call pararound
  1163. mov dx,ax
  1164. add cx,dx
  1165. cmp cx,[alloclim]
  1166. jb okld
  1167. jmp mem_err
  1168. okld:
  1169. xor cx,cx
  1170. xor dx,dx
  1171. mov ax,lseek shl 8 ;reset pointer to beginning of file
  1172. stc ;in case of int 24
  1173. int 21h
  1174. jc ldclsp
  1175. pop dx
  1176. push es ;read the file in
  1177. pop ds ;trans addr is ds:dx
  1178. mov cx,0ff00h ; .com files arn't any bigger than
  1179. ; 64k-100h
  1180. mov ah,read
  1181. stc ;in case of int 24
  1182. int 21h
  1183. jc ldcls
  1184. mov si,dx ;check for exe file
  1185. cmp word ptr [si],"ZM"
  1186. clc ; assume ok
  1187. jnz ldcls ; only know how to do .com files
  1188. stc
  1189. jmp short ldcls
  1190. lderrp:
  1191. stc
  1192. ldclsp:
  1193. pop dx ;clean stack
  1194. ldcls:
  1195. pushf
  1196. mov ah,close ;close the file
  1197. stc
  1198. int 21h
  1199. popf
  1200. ldret: pop ds
  1201. pop si
  1202. pop dx
  1203. pop cx
  1204. pop bx
  1205. pop ax
  1206. ret
  1207. endif
  1208. ;
  1209. ; open device pointed to by dx, al has access code
  1210. ; if unable to open do a device open null device instead
  1211. ;
  1212. open_dev:
  1213. call open_file
  1214. jnc open_dev3
  1215. open_dev1:
  1216. mov dx,offset nuldev
  1217. call open_file
  1218. of_ret:
  1219. ret
  1220. open_dev3:
  1221. mov bx,ax ; handle from open to bx
  1222. xor ax,ax ; get device info
  1223. mov ah,ioctl
  1224. int 21h
  1225. test dl,10000000b
  1226. jnz of_ret
  1227. mov ah,close
  1228. int 21h
  1229. jmp open_dev1
  1230. open_file:
  1231. mov ah,open
  1232. stc
  1233. int 21h
  1234. ret
  1235. ; test int24. return back to dos with the fake user response of "fail"
  1236. int24:
  1237. mov al, 3 ; fail the system call
  1238. iret ; return back to dos.
  1239. include copyrigh.inc ; copyright statement
  1240. nuldev db "NUL",0
  1241. condev db "CON",0
  1242. auxdev db "AUX",0
  1243. prndev db "PRN",0
  1244. MseDev db "MOUSE",0 ; NTVDM for internal spc mouse
  1245. ; NTVDM we use a temp file for config.sys 23-Nov-1992 Jonle
  1246. ; config db "C:\CONFIG.SYS",0
  1247. config db 64 dup (0)
  1248. cntry_drv db "A:"
  1249. cntry_root db "\"
  1250. cntry_path db "COUNTRY.SYS",0
  1251. db 52 dup (0)
  1252. country_file_signature db 0ffh,'COUNTRY'
  1253. cntrycodepage_id dw ?
  1254. commnd db "\COMMAND.COM",0
  1255. db 51 dup (0)
  1256. pathstring db 64 dup (0)
  1257. comtab label byte
  1258. ; cmd len command cmd code
  1259. ; ------- ------- --------
  1260. ;
  1261. db 7, "BUFFERS", 'B'
  1262. db 5, "BREAK", 'C'
  1263. db 6, "DEVICE", 'D'
  1264. db 10, "DEVICEHIGH", 'U'
  1265. db 5, "FILES", 'F'
  1266. db 4, "FCBS", 'X'
  1267. db 9, "LASTDRIVE", 'L'
  1268. db 10, "MULTITRACK", 'M'
  1269. db 8, "DRIVPARM", 'P'
  1270. if stacksw
  1271. db 6, "STACKS", 'K'
  1272. endif
  1273. db 7, "COUNTRY", 'Q'
  1274. db 5, "SHELL", 'S'
  1275. db 7, "INSTALL", 'I'
  1276. db 7, "COMMENT", 'Y'
  1277. db 3, "REM", '0'
  1278. db 8, "SWITCHES", '1'
  1279. db 3, "DOS", 'H'
  1280. db 10, "ECHOCONFIG", 'E' ; NTVDM 14-Aug-1992 Jonle
  1281. db 11, "NTCMDPROMPT", 'T' ; NTVDM 06-May-1993 sudeepb
  1282. db 7, "DOSONLY", 'O' ; NTVDM 06-May-1993 sudeepb
  1283. db 0
  1284. hlim dw 2
  1285. slim dw 9
  1286. public bEchoConfig ; NTVDM - 14-Aug-1992 Jonle
  1287. bEchoConfig db 0
  1288. public drive
  1289. drive db ?
  1290. public switches
  1291. switches dw 0
  1292. switchlist db 8,"FHSTDICN" ; preserve the positions of n and c.
  1293. ; the following depend on the positions of the various letters in switchlist
  1294. ;switchnum equ 11111000b ; which switches require number
  1295. flagec35 equ 00000100b ; electrically compatible 3.5 inch disk drive
  1296. flagdrive equ 00001000b
  1297. flagcyln equ 00010000b
  1298. flagseclim equ 00100000b
  1299. flagheads equ 01000000b
  1300. flagff equ 10000000b
  1301. sysinitseg ends
  1302. end
  1303.