Leaked source code of windows server 2003
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.

4242 lines
98 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. have_install_cmd equ 00000001b ; config.sys has install= commands
  16. has_installed equ 00000010b ; sysinit_base installed.
  17. default_filenum = 8
  18. break macro ; dummy empty macro
  19. endm
  20. include sysvar.inc
  21. ifdef NEC_98
  22. include dpb.inc
  23. endif ;NEC_98
  24. include pdb.inc ; M020
  25. include syscall.inc
  26. include doscntry.inc
  27. include devsym.inc
  28. include devmark.inc
  29. include umb.inc
  30. include dossym.inc
  31. include dossvc.inc
  32. include cmdsvc.inc
  33. include softpc.inc
  34. ifndef NEC_98
  35. stacksw equ true ;include switchable hardware stacks
  36. else ;NEC_98
  37. stacksw equ false ;include switchable hardware stacks
  38. endif ;NEC_98
  39. if ibmjapver
  40. noexec equ true
  41. else
  42. noexec equ false
  43. endif
  44. ; external variable defined in ibmbio module for multi-track
  45. multrk_on equ 10000000b ;user spcified mutitrack=on,or system turns
  46. ; it on after handling config.sys file as a
  47. ; default value,if multrk_flag = multrk_off1.
  48. multrk_off1 equ 00000000b ;initial value. no "multitrack=" command entered.
  49. multrk_off2 equ 00000001b ;user specified multitrack=off.
  50. Bios_Data segment
  51. extrn multrk_flag:word
  52. extrn keyrd_func:byte
  53. extrn keysts_func:byte
  54. Bios_Data ends
  55. ; end of multi-track definition.
  56. sysinitseg segment
  57. assume cs:sysinitseg,ds:nothing,es:nothing,ss:nothing
  58. extrn badopm:byte,crlfm:byte,badcom:byte,badmem:byte,badblock:byte
  59. extrn badsiz_pre:byte,badld_pre:byte
  60. extrn badstack:byte,badcountrycom:byte
  61. extrn badcountry:byte,insufmemory:byte
  62. extrn condev:byte,auxdev:byte,prndev:byte,commnd:byte,config:byte
  63. extrn cntry_drv:byte,cntry_root:byte,cntry_path:byte
  64. extrn memory_size:word
  65. extrn buffers:word
  66. extrn files:byte,num_cds:byte
  67. extrn dosinfo:dword
  68. extrn fcbs:byte,keep:byte
  69. extrn confbot:word,alloclim:word,command_line:byte
  70. extrn zero:byte,sepchr:byte
  71. extrn count:word,chrptr:word,cntryfilehandle:word
  72. extrn memlo:word,memhi:word,prmblk:word,ldoff:word
  73. extrn packet:byte,unitcount:byte,break_addr:dword
  74. extrn bpb_addr:dword,drivenumber:byte,sysi_country:dword
  75. extrn config_size:word
  76. extrn install_flag:word
  77. extrn badorder:byte
  78. extrn errorcmd:byte
  79. extrn linecount:word
  80. extrn showcount:byte
  81. extrn buffer_linenum:word
  82. extrn h_buffers:word
  83. extrn badparm:byte
  84. extrn configmsgflag:word
  85. extrn org_count:word
  86. extrn multi_pass_id:byte
  87. extrn mem_err:near,setdoscountryinfo:near
  88. extrn pararound:near,tempcds:near
  89. extrn set_country_path:near,move_asciiz:near,delim:near
  90. extrn badfil:near,round:near
  91. extrn do_install_exec:near
  92. extrn setdevmark:near
  93. extrn print:near,organize:near,newline:near
  94. ifndef NEC_98
  95. extrn parseline:near
  96. else ;NEC_98
  97. extrn deviceparameters:byte
  98. extrn diddleback:near,parseline:near,setparms:near
  99. endif ;NEC_98
  100. extrn badload:near,calldev:near,prnerr:near
  101. extrn runhigh:byte
  102. extrn IsXMSLoaded:near
  103. extrn TryToMovDOSHi:near
  104. ifdef DBCS
  105. extrn testkanj:near
  106. endif
  107. ifdef JAPAN
  108. extrn badblock2:byte,badsiz_pre2:byte,badcountry2:byte,insufmemory2:byte
  109. extrn badcountry2:byte,badcountrycom2:byte,badstack2:byte,badopm2:byte
  110. extrn badparm2:byte,badorder2:byte,errorcmd2:byte
  111. endif
  112. extrn bEchoConfig:byte ; NTVDM flag off\on echo of cfg processing
  113. if stacksw
  114. ; internal stack parameters
  115. entrysize equ 8
  116. mincount equ 8
  117. defaultcount equ 9
  118. maxcount equ 64
  119. minsize equ 32
  120. defaultsize equ 128
  121. maxsize equ 512
  122. DOS_FLAG_OFFSET equ 86h
  123. extrn stack_count:word
  124. extrn stack_size:word
  125. extrn stack_addr:dword
  126. endif
  127. ifdef NEC_98
  128. DOS_FLAG_OFFSET equ 86h
  129. endif ;NEC_98
  130. public doconf
  131. public getchr
  132. public multi_pass
  133. public AllocUMB
  134. public AllocUMBLow ; NTVDM
  135. public multdeviceflag
  136. multdeviceflag db 0
  137. public devmark_addr
  138. devmark_addr dw ? ;segment address for devmark.
  139. public setdevmarkflag
  140. setdevmarkflag db 0 ;flag used for devmark
  141. ems_stub_installed db 0
  142. IFDEF DONT_LOAD_OS2_DD ; M045
  143. Os2ChkBuf DD 0 ; Tmp read buffer
  144. ENDIF ; M045
  145. badparm_ptr label dword
  146. badparm_off dw 0
  147. badparm_seg dw 0
  148. ;******************************************************************************
  149. ;take care of config.sys file.
  150. ;system parser data and code.
  151. ;******************************************************************************
  152. ;*******************************************************************
  153. ; parser options set for msbio sysconf module
  154. ;*******************************************************************
  155. ;
  156. ;**** default assemble swiches definition **************************
  157. ifndef farsw
  158. farsw equ 0 ; near call expected
  159. endif
  160. ifndef datesw
  161. datesw equ 0 ; check date format
  162. endif
  163. ifndef timesw
  164. timesw equ 0 ; check time format
  165. endif
  166. ifndef filesw
  167. filesw equ 1 ; check file specification
  168. endif
  169. ifndef capsw
  170. capsw equ 0 ; perform caps if specified
  171. endif
  172. ifndef cmpxsw
  173. cmpxsw equ 0 ; check complex list
  174. endif
  175. ifndef numsw
  176. numsw equ 1 ; check numeric value
  177. endif
  178. ifndef keysw
  179. keysw equ 0 ; support keywords
  180. endif
  181. ifndef swsw
  182. swsw equ 1 ; support switches
  183. endif
  184. ifndef val1sw
  185. val1sw equ 1 ; support value definition 1
  186. endif
  187. ifndef val2sw
  188. val2sw equ 0 ; support value definition 2
  189. endif
  190. ifndef val3sw
  191. val3sw equ 1 ; support value definition 3
  192. endif
  193. ifndef drvsw
  194. drvsw equ 1 ; support drive only format
  195. endif
  196. ifndef qussw
  197. qussw equ 0 ; support quoted string format
  198. endif
  199. include parse.asm ;together with psdata.inc
  200. ;control block definitions for parser.
  201. ;---------------------------------------------------
  202. ; buffer = [n | n,m] {/e}
  203. p_parms struc
  204. dw ?
  205. db 1 ; an extra delimiter list
  206. db 1 ; length is 1
  207. db ';' ; delimiter
  208. p_parms ends
  209. p_pos struc
  210. dw ? ; numeric value??
  211. dw ? ; function
  212. dw ? ; result value buffer
  213. ; note: by defining result_val before this structure, we could remove
  214. ; the "result_val" from every structure invocation
  215. dw ? ; value list
  216. db 0 ; no switches/keywords
  217. p_pos ends
  218. p_range struc
  219. db 1 ; range definition
  220. db 1 ; 1 definition of range
  221. db 1 ; item tag for this range
  222. dd ? ; numeric min
  223. dd ? ; numeric max
  224. p_range ends
  225. buf_parms p_parms <buf_parmsx>
  226. buf_parmsx dw 201h,buf_pos1,buf_pos2 ; min 1, max 2 positionals
  227. db 1 ; one switch
  228. dw sw_x_ctrl
  229. db 0 ; no keywords
  230. buf_pos1 p_pos <8000h,0,result_val,buf_range_1> ; numeric
  231. ifndef NEC_98
  232. buf_range_1 p_range <,,,1,99> ; M050
  233. else ;NEC_98
  234. ;<patch BIOS50-P18>
  235. buf_range_1 p_range <,,,1,62> ; M050
  236. endif ;NEC_98
  237. buf_pos2 p_pos <8001h,0,result_val,buf_range_2> ; optional num.
  238. buf_range_2 p_range <,,,0,8>
  239. sw_x_ctrl p_pos <0,0,result_val,noval,1> ; followed by one switch
  240. switch_x db '/X',0 ; M016
  241. p_buffers dw 0 ; local variables
  242. p_h_buffers dw 0
  243. p_buffer_slash_x db 0
  244. ;common definitions ------------
  245. noval db 0
  246. result_val label byte
  247. db ? ; type returned
  248. db ? ; item tag returned
  249. dw ? ; es:offset of the switch defined
  250. rv_byte label byte
  251. rv_dword dd ? ; value if number,or seg:offset to string.
  252. ;-------------------------------
  253. ; break = [ on | off ]
  254. brk_parms p_parms <brk_parmsx>
  255. brk_parmsx dw 101h,brk_pos ; min,max = 1 positional
  256. db 0 ; no switches
  257. db 0 ; no keywords
  258. brk_pos p_pos <2000h,0,result_val,on_off_string> ; simple string
  259. on_off_string label byte
  260. db 3 ; signals that there is a string choice
  261. db 0 ; no range definition
  262. db 0 ; no numeric values choice
  263. db 2 ; 2 strings for choice
  264. db 1 ; the 1st string tag
  265. dw on_string
  266. db 2 ; the 2nd string tag
  267. dw off_string
  268. on_string db "ON",0
  269. off_string db "OFF",0
  270. p_ctrl_break db 0 ; local variable
  271. ;--------------------------------
  272. ; country = n {m {path}}
  273. ; or
  274. ; country = n,,path
  275. cntry_parms p_parms <cntry_parmsx>
  276. cntry_parmsx dw 301h,cntry_pos1,cntry_pos2,cntry_pos3 ; min 1, max 3 pos.
  277. db 0 ; no switches
  278. db 0 ; no keywords
  279. cntry_pos1 p_pos <8000h,0,result_val,cc_range> ; numeric value
  280. cc_range p_range <,,,1,999>
  281. cntry_pos2 p_pos <8001h,0,result_val,cc_range> ; optional num.
  282. cntry_pos3 p_pos <201h,0,result_val,noval> ; optional filespec
  283. p_cntry_code dw 0 ; local variable
  284. p_code_page dw 0 ; local variable
  285. ;--------------------------------
  286. ; files = n
  287. files_parms p_parms <files_parmsx>
  288. files_parmsx dw 101h,files_pos ; min,max 1 positional
  289. db 0 ; no switches
  290. db 0 ; no keywords
  291. files_pos p_pos <8000h,0,result_val,files_range,0> ; numeric value
  292. files_range p_range <,,,8,255>
  293. p_files db 0 ; local variable
  294. ;-------------------------------
  295. ; fcbs = n,m
  296. fcbs_parms p_parms <fcbs_parmsx>
  297. fcbs_parmsx dw 201h,fcbs_pos_1,fcbs_pos_2 ; min,max = 2 positional
  298. db 0 ; no switches
  299. db 0 ; no keywords
  300. fcbs_pos_1 p_pos <8000h,0,result_val,fcbs_range> ; numeric value
  301. fcbs_range p_range <,,,1,255>
  302. fcbs_pos_2 p_pos <8000h,0,result_val,fcbs_keep_range> ; numeric value
  303. fcbs_keep_range p_range <,,,0,255>
  304. p_fcbs db 0 ; local variable
  305. p_keep db 0 ; local variable
  306. ;-------------------------------
  307. ; lastdrive = x
  308. ldrv_parms p_parms <ldrv_parmsx>
  309. ldrv_parmsx dw 101h,ldrv_pos ; min,max = 1 positional
  310. db 0 ; no switches
  311. db 0 ; no keywords
  312. ldrv_pos p_pos <110h,10h,result_val,noval> ; drive only, ignore colon
  313. ; remove colon at end
  314. p_ldrv db 0 ; local variable
  315. ;-------------------------------
  316. ; stacks = n,m
  317. stks_parms p_parms <stks_parmsx>
  318. stks_parmsx dw 202h,stks_pos_1,stks_pos_2 ; min,max = 2 positionals
  319. db 0 ; no switches
  320. db 0 ; no keywords
  321. stks_pos_1 p_pos <8000h,0,result_val,stks_range> ; numeric value
  322. stks_range p_range <,,,0,64>
  323. stks_pos_2 p_pos <8000h,0,result_val,stk_size_range> ; numeric value
  324. stk_size_range p_range <,,,0,512>
  325. p_stack_count dw 0 ; local variable
  326. p_stack_size dw 0 ; local variable
  327. ;-------------------------------
  328. ; multitrack = [ on | off ]
  329. mtrk_parms p_parms <mtrk_parmsx>
  330. mtrk_parmsx dw 101h,mtrk_pos ; min,max = 1 positional
  331. db 0 ; no switches
  332. db 0 ; no keywords
  333. mtrk_pos p_pos <2000h,0,result_val,on_off_string> ; simple string
  334. p_mtrk db 0 ; local variable
  335. ;-------------------------------
  336. ; switches=/k
  337. swit_parms p_parms <swit_parmsx>
  338. swit_parmsx dw 0 ; no positionals
  339. db 3 ; 2 switches for now. M059 M063
  340. dw swit_k_ctrl ; /k control
  341. dw swit_t_ctrl ; /t control M059
  342. dw swit_w_ctrl ; /w control M063
  343. db 0 ; no keywords
  344. swit_k_ctrl p_pos <0,0,result_val,noval,1> ; switch string follows
  345. swit_k db '/K',0
  346. swit_t_ctrl p_pos <0,0,result_val,noval,1> ; switch string follows M059
  347. swit_t db '/T',0 ; M059
  348. swit_w_ctrl p_pos <0,0,result_val,noval,1> ; switch string follows M063
  349. swit_w db '/W',0 ; M063
  350. p_swit_k db 0 ; local variable
  351. p_swit_t db 0 ; local variable M059
  352. p_swit_w db 0 ; local variable M063
  353. ;-------------------------------
  354. ; DOS = [ high | low ]
  355. dos_parms p_parms <dos_parmsx>
  356. dos_parmsx db 1 ; min parameters
  357. db 2 ; max parameters
  358. dw dos_pos ;
  359. dw dos_pos ;
  360. db 0 ; no switches
  361. db 0 ; no keywords
  362. dos_pos p_pos <2000h,0,result_val,dos_strings> ; simple string
  363. p_pos <2000h,0,result_val,dos_strings> ; simple string
  364. dos_strings label byte
  365. db 3 ; signals that there is a string choice
  366. db 0 ; no range definition
  367. db 0 ; no numeric values choice
  368. db 4 ; 4 strings for choice
  369. db 1 ; the 1st string tag
  370. dw hi_string
  371. db 2 ; the 2nd string tag
  372. dw lo_string
  373. db 3
  374. dw umb_string
  375. db 4
  376. dw noumb_string
  377. hi_string db "HIGH",0
  378. lo_string db "LOW",0
  379. umb_string db "UMB",0
  380. noumb_string db "NOUMB",0
  381. p_dos_hi db 0 ; local variable
  382. ; BUGBUG : I dont know whether PARSER uses
  383. ; this variable or not
  384. ;******************************************************************************
  385. public DevEntry
  386. DevSize dw ? ; size of the device driver being loaded(paras)
  387. DevLoadAddr dw ? ; Mem addr where the device driver is 2 b loaded
  388. DevLoadEnd dw ? ; MaxAddr to which device can be loaded
  389. DevEntry dd ? ; Entry point to the device driver
  390. DevBrkAddr dd ? ; Break address of the device driver
  391. ;
  392. DevUMB db 0 ; byte indicating whether to load DDs in UMBs
  393. DevUMBAddr dw 0 ; cuurent UMB used fro loading devices (paras)
  394. DevUMBSize dw 0 ; Size of the current UMB being used (paras)
  395. DevUMBFree dw 0 ; Start of free are in the current UMB (paras)
  396. ;
  397. DevXMSAddr dd ?
  398. ;
  399. DevExecAddr dw ? ; Device load address parameter to Exec call
  400. DevExecReloc dw ? ; Device load relocation factor
  401. ;
  402. DeviceHi db 0 ; Flag indicating whther the current device
  403. ; is being loaded into UMB
  404. DevSizeOption dw ? ; SIZE= option
  405. ;
  406. Int12Lied db 0 ; did we trap int 12 ?
  407. OldInt12Mem dw ? ; value in 40:13h (int 12 ram)
  408. ThreeComName db 'PROTMAN$' ; 3Com Device name
  409. ;
  410. FirstUMBLinked db 0
  411. DevDOSData dw ? ; segment of DOS Data
  412. DevCmdLine dd ? ; Current Command line
  413. ifndef NEC_98
  414. DevSavedDelim db ? ; The delimiter which was replaced with null
  415. else ;NEC_98
  416. DevSavedDelim db 00h ; The delimiter which was replaced with null
  417. endif ;NEC_98
  418. ; to use the file name in the command line
  419. ;
  420. ;----------------------------------------------------------------------------
  421. ;
  422. ; procedure : doconf
  423. ;
  424. ; Config file is parsed intitially with this routine. For the
  425. ; Subsequent passes 'multi_pass' entry is used .
  426. ;
  427. ;----------------------------------------------------------------------------
  428. ;
  429. doconf proc near
  430. push cs
  431. pop ds
  432. assume ds:sysinitseg
  433. mov ax,(char_oper shl 8) ;get switch character
  434. int 21h
  435. mov [command_line+1],dl ; set in default command line
  436. mov dx,offset config ;now pointing to file description
  437. mov ax,open shl 8 ;open file "config.sys"
  438. stc ;in case of int 24
  439. int 21h ;function request
  440. jnc noprob ; brif opened okay
  441. mov multi_pass_id,11 ; set it to unreasonable number
  442. ret
  443. noprob: ;get file size (note < 64k!!)
  444. mov bx,ax
  445. xor cx,cx
  446. xor dx,dx
  447. mov ax,(lseek shl 8) or 2
  448. int 21h
  449. mov [count],ax
  450. xor dx,dx
  451. mov ax,lseek shl 8 ;reset pointer to beginning of file
  452. int 21h
  453. mov dx,[confbot] ;use current confbot value
  454. mov ax,[count]
  455. mov [config_size],ax ;save the size of config.sys file.
  456. call pararound
  457. sub dx,ax
  458. sub dx,11h ;room for header
  459. mov [confbot],dx ; config starts here. new conbot value.
  460. call tempcds ; finally get cds to "safe" location
  461. assume ds:nothing,es:nothing
  462. mov dx,[confbot]
  463. mov ds,dx
  464. mov es,dx
  465. xor dx,dx
  466. mov cx,[count]
  467. mov ah,read
  468. stc ;in case of int 24
  469. int 21h ;function request
  470. pushf
  471. ; find the eof mark in the file. if present,then trim length.
  472. push ax
  473. push di
  474. push cx
  475. mov al,1ah ; eof mark
  476. mov di,dx ; point ro buffer
  477. jcxz puteol ; no chars
  478. repnz scasb ; find end
  479. jnz puteol ; none found and count exahusted
  480. ; we found a 1a. back up
  481. dec di ; backup past 1a
  482. ; just for the halibut,stick in an extra eol
  483. puteol:
  484. mov al,cr
  485. stosb
  486. mov al,lf
  487. stosb
  488. sub di,dx ; difference moved
  489. mov count,di ; new count
  490. pop cx
  491. pop di
  492. pop ax
  493. push cs
  494. pop ds
  495. assume ds:sysinitseg
  496. push ax
  497. mov ah,close
  498. int 21h
  499. pop ax
  500. popf
  501. jc conferr ;if not we've got a problem
  502. cmp cx,ax
  503. jz getcom ;couldn't read the file
  504. conferr:
  505. mov dx,offset config ;want to print config error
  506. call badfil
  507. endconv:
  508. ret
  509. ;
  510. ;----------------------------------------------------------------------------
  511. ;
  512. ; entry : multi_pass
  513. ;
  514. ; called to execute device=,install= commands
  515. ;
  516. ;----------------------------------------------------------------------------
  517. ;
  518. multi_pass:
  519. push cs
  520. pop ds
  521. cmp multi_pass_id,10
  522. jae endconv ; do nothing. just return.
  523. push confbot
  524. pop es ; es -> confbot
  525. mov si,org_count
  526. mov count,si ; set count
  527. xor si,si
  528. mov chrptr,si ; reset chrptr,linecount
  529. mov linecount,si
  530. call getchr
  531. jmp short conflp
  532. getcom:
  533. call organize ;organize the file
  534. call getchr
  535. conflp: jc endconv
  536. ;*** call reset_dos_version ; still need to reset version even ibmdos handles this through
  537. ;*** ; function 4bh call,since ibmdos does not know when load/overlay call finishes.
  538. inc linecount ; increase linecount.
  539. mov multdeviceflag,0 ; reset multdeviceflag.
  540. mov setdevmarkflag,0 ; reset setdevmarkflag.
  541. cmp al,lf ; linefeed?
  542. je blank_line ; then ignore this line.
  543. mov ah,al
  544. call getchr
  545. jnc tryi
  546. cmp multi_pass_id,2
  547. jae endconv ;do not show badop again for multi_pass.
  548. jmp badop
  549. coff: push cs
  550. pop ds
  551. call newline
  552. jmp conflp
  553. blank_line:
  554. call getchr
  555. jmp conflp
  556. coff_p:
  557. push cs
  558. pop ds
  559. ;to handle install= commands,we are going to use multi-pass.
  560. ;the first pass handles the other commands and only set install_flag when
  561. ;it finds any install command. the second pass will only handle the
  562. ;install= command.
  563. ;------------------------------------------------------------------------------
  564. ;install command
  565. ;------------------------------------------------------------------------------
  566. tryi:
  567. cmp multi_pass_id,0 ; the initial pass for DOS=HI
  568. je multi_try_doshi
  569. cmp multi_pass_id,2 ; the second pass was for ifs=
  570. je coff ; now it is NOPs
  571. ; This pass can be made use of if
  572. ; we want do some config.sys process
  573. ; after device drivers are loaded
  574. ; and before install= commands
  575. ; are processed
  576. cmp multi_pass_id,3 ; the third pass for install= ?
  577. je multi_try_i
  578. cmp ah, 'H'
  579. je coff
  580. cmp ah, 'E'
  581. je coff
  582. cmp ah,'I' ; install= command?
  583. jne tryb ; the first pass is for normal operation.
  584. or install_flag,have_install_cmd ; set the flag
  585. jmp coff ; and handles the next command
  586. multi_try_i:
  587. cmp ah,'I' ; install= command?
  588. jne multi_pass_filter ; no. ignore this.
  589. call do_install_exec ;install it.
  590. jmp coff ;to handle next install= command.
  591. multi_pass_filter:
  592. cmp ah,'Y' ; comment?
  593. je multi_pass_adjust
  594. cmp ah,'Z' ; bad command?
  595. je multi_pass_adjust
  596. cmp ah,'0' ; rem?
  597. jne coff ; ignore the rest of the commands.
  598. multi_pass_adjust: ; these commands need to
  599. dec chrptr ; adjust chrptr,count
  600. inc count ; for newline proc.
  601. multi_pass_coff:
  602. jmp coff ; to handle next install= commands.
  603. ;----------------------------------------------------------------------------
  604. ; DOS=HIGH/LOW command
  605. ;
  606. ; EchoConfig command turns on con echo for config processing
  607. ; NTVDM 14-Aug-1992 Jonle
  608. ;----------------------------------------------------------------------------
  609. ;
  610. multi_try_doshi:
  611. cmp ah, 'H'
  612. je it_is_h
  613. cmp ah, 'E'
  614. jne multi_pass_filter
  615. mov cs:bEchoConfig, ah ; init console
  616. CMDSVC SVC_CMDINITCONSOLE
  617. jmp coff
  618. it_is_h: ; M003 - removed initing DevUMB
  619. ; & runhigh
  620. mov di,offset dos_parms
  621. xor cx,cx
  622. mov dx,cx
  623. h_do_parse:
  624. call sysinit_parse
  625. jnc h_parse_ok ; parse error
  626. h_badparm:
  627. call badparm_p ; show message and end the serach loop.
  628. jmp short h_end
  629. h_parse_ok:
  630. cmp ax,$p_rc_eol ; end of line?
  631. jz h_end ; then end the $endloop
  632. call ProcDOS
  633. jmp short h_do_parse
  634. h_end:
  635. jmp coff
  636. ;------------------------------------------------------------------------------
  637. ; buffer command
  638. ;------------------------------------------------------------------------------
  639. ;*******************************************************************************
  640. ; *
  641. ; function: parse the parameters of buffers= command. *
  642. ; *
  643. ; input : *
  644. ; es:si -> parameters in command line. *
  645. ; output: *
  646. ; buffers set *
  647. ; buffer_slash_x flag set if /x option chosen. *
  648. ; h_buffers set if secondary buffer cache specified. *
  649. ; *
  650. ; subroutines to be called: *
  651. ; sysinit_parse *
  652. ; logic: *
  653. ; { *
  654. ; set di points to buf_parms; /*parse control definition*/ *
  655. ; set dx,cx to 0; *
  656. ; reset buffer_slash_x; *
  657. ; while (end of command line) *
  658. ; { sysinit_parse; *
  659. ; if (no error) then *
  660. ; if (result_val.$p_synonym_ptr == slash_e) then /*not a switch *
  661. ; buffer_slash_x = 1 *
  662. ; else if (cx == 1) then /* first positional */ *
  663. ; buffers = result_val.$p_picked_val; *
  664. ; else h_buffers = result_val.$p_picked_val; *
  665. ; else {show error message;error exit} *
  666. ; }; *
  667. ; if (buffer_slash_x is off & buffers > 99) then show_error; *
  668. ; }; *
  669. ; *
  670. ;*******************************************************************************
  671. tryb:
  672. cmp ah,'B'
  673. jnz tryc
  674. ; NTVDM - buffers command is ignored
  675. ; 15-Aug-1992 Jonle
  676. jmp coff
  677. if 0
  678. mov p_buffer_slash_x,0
  679. mov di,offset buf_parms
  680. xor cx,cx
  681. mov dx,cx
  682. do7:
  683. call sysinit_parse
  684. jnc if7 ; parse error,
  685. call badparm_p ; and show messages and end the search loop.
  686. jmp short sr7
  687. if7:
  688. cmp ax,$p_rc_eol ; end of line?
  689. jz en7 ; then jmp to $endloop for semantic check
  690. cmp result_val.$p_synonym_ptr,offset switch_x
  691. jnz if11
  692. ; mov p_buffer_slash_x,1 ; set the flag M016
  693. jmp short en11
  694. if11:
  695. mov ax,word ptr result_val.$p_picked_val
  696. cmp cx,1
  697. jnz if13
  698. mov p_buffers,ax
  699. jmp short en11
  700. if13:
  701. mov p_h_buffers,ax
  702. en11:
  703. jmp do7
  704. en7:
  705. cmp p_buffers,99
  706. jbe if18
  707. ; cmp p_buffer_slash_x,0 ; M016
  708. ; jnz if18
  709. call badparm_p
  710. mov p_h_buffers,0
  711. jmp short sr7
  712. if18:
  713. mov ax,p_buffers ; we don't have any problem.
  714. mov buffers,ax ; now,let's set it really.
  715. mov ax,p_h_buffers
  716. mov h_buffers,ax
  717. ; mov al,p_buffer_slash_x ; M016
  718. ; mov buffer_slash_x,al
  719. mov ax,linecount
  720. mov buffer_linenum,ax ; save the line number for the future use.
  721. sr7:
  722. jmp coff
  723. endif
  724. ;------------------------------------------------------------------------------
  725. ; break command
  726. ;------------------------------------------------------------------------------
  727. ;****************************************************************************
  728. ; *
  729. ; function: parse the parameters of break = command. *
  730. ; *
  731. ; input : *
  732. ; es:si -> parameters in command line. *
  733. ; output: *
  734. ; turn the control-c check on or off. *
  735. ; *
  736. ; subroutines to be called: *
  737. ; sysinit_parse *
  738. ; logic: *
  739. ; { *
  740. ; set di to brk_parms; *
  741. ; set dx,cx to 0; *
  742. ; while (end of command line) *
  743. ; { sysinit_parse; *
  744. ; if (no error) then *
  745. ; if (result_val.$p_item_tag == 1) then /*on */ *
  746. ; set p_ctrl_break,on; *
  747. ; else /*off */ *
  748. ; set p_ctrl_break,off; *
  749. ; else {show message;error_exit}; *
  750. ; }; *
  751. ; if (no error) then *
  752. ; dos function call to set ctrl_break check according to *
  753. ; }; *
  754. ; *
  755. ;****************************************************************************
  756. tryc:
  757. cmp ah,'C'
  758. jnz trym
  759. mov di,offset brk_parms
  760. xor cx,cx
  761. mov dx,cx
  762. do22:
  763. call sysinit_parse
  764. jnc if22 ; parse error
  765. call badparm_p ; show message and end the serach loop.
  766. jmp short sr22
  767. if22:
  768. cmp ax,$p_rc_eol ; end of line?
  769. jz en22 ; then end the $endloop
  770. cmp result_val.$p_item_tag,1
  771. jnz if26
  772. mov p_ctrl_break,1 ; turn it on
  773. jmp short en26
  774. if26:
  775. mov p_ctrl_break,0 ; turn it off
  776. en26:
  777. jmp short do22 ; we actually set the ctrl break
  778. en22:
  779. mov ah,set_ctrl_c_trapping ; if we don't have any parse error.
  780. mov al,1
  781. mov dl,p_ctrl_break
  782. int 21h
  783. sr22:
  784. jmp coff
  785. ;------------------------------------------------------------------------------
  786. ; multitrack command
  787. ;------------------------------------------------------------------------------
  788. ;******************************************************************************
  789. ; *
  790. ; function: parse the parameters of multitrack= command. *
  791. ; *
  792. ; input : *
  793. ; es:si -> parameters in command line. *
  794. ; output: *
  795. ; turn multrk_flag on or off. *
  796. ; *
  797. ; subroutines to be called: *
  798. ; sysinit_parse *
  799. ; logic: *
  800. ; { *
  801. ; set di to brk_parms; *
  802. ; set dx,cx to 0; *
  803. ; while (end of command line) *
  804. ; { sysinit_parse; *
  805. ; if (no error) then *
  806. ; if (result_val.$p_item_tag == 1) then /*on */ *
  807. ; set p_mtrk,on; *
  808. ; else /*off */ *
  809. ; set p_mtrk,off; *
  810. ; else {show message;error_exit}; *
  811. ; }; *
  812. ; if (no error) then *
  813. ; dos function call to set multrk_flag according to p_mtrk. *
  814. ; *
  815. ; }; *
  816. ; *
  817. ;******************************************************************************
  818. trym:
  819. cmp ah,'M'
  820. jnz tryu
  821. mov di,offset mtrk_parms
  822. xor cx,cx
  823. mov dx,cx
  824. do31:
  825. call sysinit_parse
  826. jnc if31 ; parse error
  827. call badparm_p ; show message and end the serach loop.
  828. jmp short sr31
  829. if31:
  830. cmp ax,$p_rc_eol ; end of line?
  831. jz en31 ; then end the $endloop
  832. cmp result_val.$p_item_tag,1
  833. jnz if35
  834. mov p_mtrk,1 ; turn it on temporarily.
  835. jmp short en35
  836. if35:
  837. mov p_mtrk,0 ; turn it off temporarily.
  838. en35:
  839. jmp short do31 ; we actually set the multrk_flag here
  840. en31:
  841. push ds
  842. mov ax,Bios_Data
  843. mov ds,ax
  844. assume ds:Bios_Data
  845. cmp p_mtrk,0
  846. jnz if39
  847. mov multrk_flag,multrk_off2 ; 0001h
  848. jmp short en39
  849. if39:
  850. mov multrk_flag,multrk_on ; 8000h
  851. en39:
  852. pop ds
  853. assume ds:sysinitseg
  854. sr31:
  855. jmp coff
  856. ;
  857. ;-----------------------------------------------------------------------------
  858. ; devicehigh command
  859. ;-----------------------------------------------------------------------------
  860. ;
  861. assume ds:nothing
  862. tryu:
  863. cmp ah, 'U'
  864. jne tryd
  865. mov badparm_off, si ; stash it there in case of an error
  866. mov badparm_seg, es
  867. call ParseSize ; process the size= option
  868. jnc @f
  869. call badparm_p
  870. jmp coff
  871. @@:
  872. push si
  873. push es
  874. @@:
  875. mov al, es:[si]
  876. cmp al, cr
  877. je @f
  878. cmp al, lf
  879. je @f
  880. call delim
  881. jz @f
  882. inc si
  883. jmp @b
  884. @@:
  885. ifndef NEC_98
  886. mov DevSavedDelim, al ; Save the delimiter before replacing
  887. ; it with null
  888. else ;NEC_98
  889. db 4 dup (90h) ; 4 bytes of NOPs
  890. endif ;NEC_98
  891. mov byte ptr es:[si], 0
  892. pop es
  893. pop si
  894. mov DeviceHi, 0
  895. cmp DevUMB, 0 ; do we support UMBs
  896. je LoadDevice ; no, we don't
  897. mov DeviceHi, 1
  898. jmp short LoadDevice
  899. ;
  900. ;------------------------------------------------------------------------------
  901. ; device command
  902. ;------------------------------------------------------------------------------
  903. assume ds:nothing
  904. tryd:
  905. cmp ah,'D'
  906. jz gotd
  907. jmp tryq
  908. gotd:
  909. mov DeviceHi, 0 ; not to be loaded in UMB ;M007
  910. mov DevSizeOption, 0
  911. ifndef NEC_98
  912. mov DevSavedDelim, ' ' ; In case of DEVICE= the null has to
  913. ; be replaced with a ' '
  914. else ;NEC_98
  915. mov DevSavedDelim, 00h
  916. endif ;NEC_98
  917. LoadDevice:
  918. mov bx,cs ;device= or devicehigh= command.
  919. mov ds,bx
  920. mov word ptr [bpb_addr],si ; pass the command line to the dvice
  921. mov word ptr [bpb_addr+2],es
  922. mov word ptr DevCmdLine, si ; save it for ourself
  923. mov word ptr DevCmdLine+2, es
  924. call round
  925. call SizeDevice
  926. jc BadFile
  927. call InitDevLoad
  928. mov ax, DevLoadAddr
  929. add ax, DevSize
  930. jc NoMem
  931. cmp DevLoadEnd, ax
  932. jae LoadDev
  933. NoMem:
  934. jmp mem_err
  935. BadFile:
  936. cmp byte ptr es:[si], cr
  937. jne @f
  938. jmp badop
  939. @@:
  940. call badload
  941. jmp coff
  942. LoadDev:
  943. push es
  944. pop ds
  945. assume ds:nothing
  946. mov dx,si ;ds:dx points to file name
  947. if noexec
  948. les bx,dword ptr cs:[memlo]
  949. call ldfil ;load in the device driver
  950. else
  951. call ExecDev ; load device driver using exec call
  952. endif
  953. badldreset:
  954. push ds
  955. pop es ;es:si back to config.sys
  956. push cs
  957. pop ds ;ds back to sysinit
  958. jc BadFile
  959. goodld:
  960. push es
  961. push si ; ???
  962. call RemoveNull
  963. push es
  964. push si
  965. push cs
  966. pop es
  967. ;NTVDM: block device drivers are not supported.
  968. ; Putup user warning popup for unsupported device driver
  969. ; 29-Sep-1992 Jonle
  970. ;
  971. push ds
  972. push si
  973. lds si, DevEntry ; peek the header attribute
  974. test word ptr ds:[si.sdevatt],devtyp ; IS block device driver?
  975. pop si
  976. pop ds
  977. jnz got_device_com_cont ; no!
  978. pop si ;clear the stack
  979. pop es
  980. ifndef NEC_98
  981. mov ax, NOSUPPORT_DRIVER
  982. BOP BOP_NOSUPPORT
  983. jmp short erase_dev_do
  984. endif ;NEC_98
  985. got_device_com_cont:
  986. call LieInt12Mem
  987. call UpdatePDB ; update the PSP:2 value M020
  988. cmp cs:multdeviceflag, 0 ; Pass limit only for the 1st device
  989. ; driver in the file ; M027
  990. jne skip_pass_limit ; ; M027
  991. mov word ptr break_addr, 0 ; pass the limit to the DD
  992. mov bx, DevLoadEnd
  993. mov word ptr break_addr+2, bx
  994. skip_pass_limit: ; M027
  995. mov bx,sdevstrat
  996. call calldev ; calldev (sdevstrat);
  997. mov bx,sdevint
  998. call calldev ; calldev (sdevint);
  999. call TrueInt12Mem
  1000. mov ax, word ptr break_addr ; move break addr from the req packet
  1001. mov word ptr DevBrkAddr, ax
  1002. mov ax, word ptr break_addr+2
  1003. mov word ptr DevBrkAddr+2, ax
  1004. assume ds:nothing
  1005. cmp DevUMB, 0
  1006. jz @f
  1007. call AllocUMB
  1008. @@:
  1009. ;
  1010. ;------ If we are waiting to be moved into hma lets try it now !!!
  1011. ;
  1012. cmp runhigh, 0ffh
  1013. jne @f
  1014. call TryToMovDOSHi ; move DOS into HMA if reqd
  1015. @@:
  1016. pop si
  1017. pop ds
  1018. mov byte ptr [si],0 ; *p = 0;
  1019. push cs
  1020. pop ds
  1021. jmp short was_device_com
  1022. erase_dev_do: ; modified to show message "error in config.sys..."
  1023. pop si
  1024. pop es
  1025. push cs
  1026. pop ds
  1027. ; test [setdevmarkflag],setbrkdone ;if already set_break is done,
  1028. ; jnz skip1_resetmemhi ; then do not
  1029. ; dec [memhi] ;adjust memhi by a paragrah of devmark.
  1030. skip1_resetmemhi:
  1031. cmp configmsgflag,0
  1032. je no_error_line_msg
  1033. call error_line ; no "error in config.sys" msg for device driver. dcr d493
  1034. mov configmsgflag,0 ;set the default value again.
  1035. no_error_line_msg:
  1036. jmp coff
  1037. ;
  1038. ;----------------------------------------------------------------------------
  1039. ;
  1040. was_device_com:
  1041. mov ax,word ptr [DevBrkAddr+2]
  1042. cmp ax,DevLoadEnd
  1043. jbe breakok
  1044. pop si
  1045. pop es
  1046. jmp BadFile
  1047. breakok:
  1048. lds si,DevEntry ;ds:si points to header
  1049. les di,cs:[dosinfo] ;es:di point to dos info
  1050. mov ax,ds:[si.sdevatt] ;ax Dev attributes
  1051. ;
  1052. ;------ lets deal with character devices,
  1053. ; NTVDM: removed check for block drivers, jonle
  1054. ;
  1055. ischardev:
  1056. or cs:[setdevmarkflag],for_devmark
  1057. call DevSetBreak ; go ahead and alloc mem for device
  1058. jc erase_dev_do ;device driver's init routine failed.
  1059. test ax,iscin ;is it a console in?
  1060. jz tryclk
  1061. mov word ptr es:[di.sysi_con],si
  1062. mov word ptr es:[di.sysi_con+2],ds
  1063. tryclk: test ax,isclock ;is it a clock device?
  1064. jz linkit
  1065. mov word ptr es:[di+sysi_clock],si
  1066. mov word ptr es:[di+sysi_clock+2],ds
  1067. linkit:
  1068. mov cx,word ptr es:[di.sysi_dev] ;dx:cx = head of list
  1069. mov dx,word ptr es:[di.sysi_dev+2]
  1070. mov word ptr es:[di.sysi_dev],si ;set head of list in dos
  1071. mov word ptr es:[di.sysi_dev+2],ds
  1072. mov ax,ds:[si] ;get pointer to next device
  1073. mov word ptr cs:[DevEntry],ax ;and save it
  1074. mov word ptr ds:[si],cx ;link in the driver
  1075. mov word ptr ds:[si+2],dx
  1076. enddev:
  1077. pop si
  1078. pop es
  1079. inc ax ;ax = ffff (no more devs if yes)?
  1080. jz coffj3
  1081. inc cs:multdeviceflag ; possibly multiple device driver.
  1082. call DevBreak ; M009
  1083. jmp goodld ; otherwise pretend we loaded it in
  1084. coffj3: mov cs:multdeviceflag,0 ; reset the flag
  1085. call DevBreak
  1086. jmp coff
  1087. bad_bpb_size_sector:
  1088. pop si
  1089. pop es
  1090. mov dx,offset badsiz_pre
  1091. ifdef JAPAN
  1092. call IsDBCSCodePage
  1093. jz @f
  1094. mov dx,offset badsiz_pre2
  1095. @@:
  1096. endif
  1097. mov bx,offset crlfm
  1098. call prnerr
  1099. ; test [setdevmarkflag],setbrkdone ;if already set_break is done,
  1100. ; jnz skip2_resetmemhi ; then do not
  1101. ; dec [memhi] ;adjust memhi by a paragrah of devmark.
  1102. skip2_resetmemhi:
  1103. jmp coff
  1104. ;------------------------------------------------------------------------------
  1105. ; country command
  1106. ; the syntax is:
  1107. ; country=country id {,codepage {,path}}
  1108. ; country=country id {,,path} :default codepage id in dos
  1109. ;------------------------------------------------------------------------------
  1110. tryq:
  1111. cmp ah,'Q'
  1112. jz tryq_cont
  1113. jmp tryf
  1114. tryq_cont:
  1115. mov cntry_drv,0 ; reset the drive,path to default value.
  1116. mov p_code_page,0
  1117. mov di,offset cntry_parms
  1118. xor cx,cx
  1119. mov dx,cx
  1120. do52:
  1121. call sysinit_parse
  1122. jnc if52 ; parse error,check error code and
  1123. call cntry_error ; show message and end the search loop.
  1124. mov p_cntry_code,-1 ; signals that parse error.
  1125. jmp short sr52
  1126. if52:
  1127. cmp ax,$p_rc_eol ; end of line?
  1128. jz sr52 ; then end the search loop
  1129. cmp result_val.$p_type,$p_number ; numeric?
  1130. jnz if56
  1131. mov ax,word ptr result_val.$p_picked_val
  1132. cmp cx,1
  1133. jnz if57
  1134. mov p_cntry_code,ax
  1135. jmp short en57
  1136. if57:
  1137. mov p_code_page,ax
  1138. en57:
  1139. jmp short en56 ; path entered
  1140. if56:
  1141. push ds
  1142. push es
  1143. push si
  1144. push di
  1145. push cs
  1146. pop es
  1147. lds si,rv_dword ; move the path to known place.
  1148. mov di,offset cntry_drv
  1149. call move_asciiz
  1150. pop di
  1151. pop si
  1152. pop es
  1153. pop ds
  1154. en56:
  1155. jmp do52
  1156. sr52:
  1157. cmp p_cntry_code,-1 ; had a parse error?
  1158. jne tryq_open
  1159. jmp coff
  1160. tryqbad: ;"invalid country code or code page"
  1161. stc
  1162. mov dx,offset badcountry
  1163. ifndef NEC_98
  1164. ifdef JAPAN
  1165. pushf
  1166. call IsDBCSCodePage
  1167. jz @f
  1168. mov dx,offset badcountry2
  1169. @@:
  1170. popf
  1171. endif
  1172. else ;NEC_98
  1173. ifdef JAPAN
  1174. call IsDBCSCodePage
  1175. jz @f
  1176. mov dx,offset badsiz_pre2
  1177. @@:
  1178. endif
  1179. endif ;NEC_98
  1180. jmp tryqchkerr
  1181. tryq_open:
  1182. cmp cntry_drv,0
  1183. je tryq_def
  1184. mov dx,offset cntry_drv
  1185. jmp short tryq_openit
  1186. tryq_def:
  1187. mov dx,offset cntry_root
  1188. tryq_openit:
  1189. mov ax,3d00h ;open a file
  1190. stc
  1191. int 21h
  1192. jc tryqfilebad ;open failure
  1193. mov cs:cntryfilehandle,ax ;save file handle
  1194. mov bx,ax
  1195. mov ax,cs:p_cntry_code
  1196. mov dx,cs:p_code_page ; now,ax=country id,bx=filehandle
  1197. mov cx,cs:[memhi]
  1198. add cx,384 ; need 6k buffer to handle country.sys
  1199. ; M023
  1200. cmp cx,cs:[alloclim]
  1201. ja tryqmemory ;cannot allocate the buffer for country.sys
  1202. mov si,offset cntry_drv ;ds:si -> cntry_drv
  1203. cmp byte ptr [si],0 ;default path?
  1204. jne tryq_set_for_dos
  1205. inc si
  1206. inc si ;ds:si -> cntry_root
  1207. tryq_set_for_dos:
  1208. les di,cs:sysi_country ;es:di -> country info tab in dos
  1209. push di ;save di
  1210. add di,ccpath_countrysys
  1211. call move_asciiz ;set the path to country.sys in dos.
  1212. pop di ;es:di -> country info tab again.
  1213. mov cx,cs:[memhi]
  1214. mov ds,cx
  1215. xor si,si ;ds:si -> 2k buffer to be used.
  1216. call setdoscountryinfo ;now do the job!!!
  1217. jnc tryqchkerr ;read error or could not find country,code page combination
  1218. cmp cx,-1 ;could not find matching country_id,code page?
  1219. je tryqbad ;then "invalid country code or code page"
  1220. tryqfilebad:
  1221. push cs
  1222. pop es
  1223. cmp cs:cntry_drv,0 ;is the default file used?
  1224. je tryqdefbad
  1225. mov si,offset cntry_drv
  1226. jmp short tryqbadload
  1227. tryqdefbad: ;default file has been used.
  1228. mov si,offset cntry_root ;es:si -> \country.sys in sysinit_seg
  1229. tryqbadload:
  1230. call badload ;ds will be restored to sysinit_seg
  1231. mov cx,cs:[confbot]
  1232. mov es,cx ;restore es -> confbot.
  1233. jmp short coffj4
  1234. tryqmemory:
  1235. mov dx,offset insufmemory
  1236. ifdef JAPAN
  1237. pushf
  1238. call IsDBCSCodePage
  1239. jz @f
  1240. mov dx,offset insufmemory2
  1241. @@:
  1242. popf
  1243. endif
  1244. tryqchkerr:
  1245. mov cx,cs:[confbot]
  1246. mov es,cx ;restore es -> confbot seg
  1247. push cs
  1248. pop ds ;retore ds to sysinit_seg
  1249. jnc coffj4 ;if no error,then exit
  1250. call print ;else show error message
  1251. call error_line
  1252. coffj4:
  1253. mov bx,cntryfilehandle
  1254. mov ah,3eh
  1255. int 21h ;close a file. don't care even if it fails.
  1256. jmp coff
  1257. cntry_error proc near
  1258. ;function: show "invalid country code or code page" messages,or
  1259. ; "error in country command" depending on the error code
  1260. ; in ax returned by sysparse;
  1261. ;in: ax - error code
  1262. ; ds - sysinitseg
  1263. ; es - confbot
  1264. ;out: show message. dx destroyed.
  1265. cmp ax,$p_out_of_range
  1266. jnz if64
  1267. mov dx,offset badcountry ;"invalid country code or code page"
  1268. ifdef JAPAN
  1269. call IsDBCSCodePage
  1270. jz @f
  1271. mov dx,offset badcountry2
  1272. @@:
  1273. endif
  1274. jmp short en64
  1275. if64:
  1276. mov dx,offset badcountrycom ;"error in contry command"
  1277. ifdef JAPAN
  1278. call IsDBCSCodePage
  1279. jz @f
  1280. mov dx,offset badcountrycom2
  1281. @@:
  1282. endif
  1283. en64:
  1284. call print
  1285. call error_line
  1286. ret
  1287. cntry_error endp
  1288. ;------------------------------------------------------------------------------
  1289. ; files command
  1290. ;------------------------------------------------------------------------------
  1291. ;*******************************************************************************
  1292. ; function: parse the parameters of files= command. *
  1293. ; *
  1294. ; input : *
  1295. ; es:si -> parameters in command line. *
  1296. ; output: *
  1297. ; variable files set. *
  1298. ; *
  1299. ; subroutines to be called: *
  1300. ; sysinit_parse *
  1301. ; logic: *
  1302. ; { *
  1303. ; set di points to files_parms; *
  1304. ; set dx,cx to 0; *
  1305. ; while (end of command line) *
  1306. ; { sysinit_parse; *
  1307. ; if (no error) then *
  1308. ; files = result_val.$p_picked_val *
  1309. ; else *
  1310. ; error exit; *
  1311. ; }; *
  1312. ; }; *
  1313. ; *
  1314. ;*******************************************************************************
  1315. tryf:
  1316. cmp ah,'F'
  1317. jnz tryl
  1318. mov di,offset files_parms
  1319. xor cx,cx
  1320. mov dx,cx
  1321. do67:
  1322. call sysinit_parse
  1323. jnc if67 ; parse error
  1324. ; sudeepb - 27-Feb-1997
  1325. ; if a bad value is found, set it to DOS default i.e. 20. If its WOW VDM
  1326. ; the BOP will return the right value.
  1327. mov p_files,20
  1328. ; call badparm_p ; and show messages and end the search loop.
  1329. jmp short en67
  1330. if67:
  1331. cmp ax,$p_rc_eol ; end of line?
  1332. jz en67 ; then end the $endloop
  1333. mov al,byte ptr result_val.$p_picked_val
  1334. mov p_files,al ; save it temporarily
  1335. jmp short do67
  1336. en67:
  1337. mov al,p_files
  1338. SVC SVC_DEMWOWFILES ; For WOW VDM Set the file= to max.
  1339. mov files,al ; no error. really set the value now.
  1340. sr67:
  1341. jmp coff
  1342. ;------------------------------------------------------------------------------
  1343. ; lastdrive command
  1344. ;------------------------------------------------------------------------------
  1345. ;*******************************************************************************
  1346. ; function: parse the parameters of lastdrive= command. *
  1347. ; *
  1348. ; input : *
  1349. ; es:si -> parameters in command line. *
  1350. ; output: *
  1351. ; set the variable num_cds. *
  1352. ; *
  1353. ; subroutines to be called: *
  1354. ; sysinit_parse *
  1355. ; logic: *
  1356. ; { *
  1357. ; set di points to ldrv_parms; *
  1358. ; set dx,cx to 0; *
  1359. ; while (end of command line) *
  1360. ; { sysinit_parse; *
  1361. ; if (no error) then *
  1362. ; set num_cds to the returned value; *
  1363. ; else /*error exit*/ *
  1364. ; error exit; *
  1365. ; }; *
  1366. ; }; *
  1367. ; *
  1368. ;*******************************************************************************
  1369. tryl:
  1370. cmp ah,'L'
  1371. jnz tryp
  1372. jmp coff
  1373. ;NTVDM Ignore the lastdrive command. Dos will figure this from the host OS.
  1374. ; 17-Aug-1992 Jonle
  1375. if 0
  1376. mov di,offset ldrv_parms
  1377. xor cx,cx
  1378. mov dx,cx
  1379. do73:
  1380. call sysinit_parse
  1381. jnc if73 ; parse error
  1382. call badparm_p ; and show messages and end the search loop.
  1383. jmp short sr73
  1384. if73:
  1385. cmp ax,$p_rc_eol ; end of line?
  1386. jz en73 ; then end the $endloop
  1387. mov al,rv_byte ; pick up the drive number
  1388. mov p_ldrv,al ; save it temporarily
  1389. jmp do73
  1390. en73:
  1391. mov al,p_ldrv
  1392. mov num_cds,al ; no error. really set the value now.
  1393. sr73:
  1394. jmp coff
  1395. endif
  1396. ;--------------------------------------------------------------------------
  1397. ; setting drive parameters
  1398. ;--------------------------------------------------------------------------
  1399. tryp:
  1400. cmp ah,'P'
  1401. jnz tryk
  1402. jmp coff
  1403. ; sudeepb 04-Mar-1991 : Ignoring DRIVEPARM command
  1404. ; call parseline
  1405. ; jc trypbad
  1406. ;
  1407. ; call setparms
  1408. ; call diddleback
  1409. ; jc trypbad
  1410. ; jmp coff
  1411. ;trypbad:jmp badop
  1412. ;--------------------------------------------------------------------------
  1413. ; setting internal stack parameters
  1414. ; stacks=m,n where
  1415. ; m is the number of stacks (range 8 to 64,default 9)
  1416. ; n is the stack size (range 32 to 512 bytes,default 128)
  1417. ; j.k. 5/5/86: stacks=0,0 implies no stack installation.
  1418. ; any combinations that are not within the specified limits will
  1419. ; result in "unrecognized command" error.
  1420. ;--------------------------------------------------------------------------
  1421. ;****************************************************************************
  1422. ; *
  1423. ; function: parse the parameters of stacks= command. *
  1424. ; the minimum value for "number of stacks" and "stack size" is *
  1425. ; 8 and 32 each. in the definition of sysparse value list,they *
  1426. ; are set to 0. this is for accepting the exceptional case of *
  1427. ; stacks=0,0 case (,which means do not install the stack.) *
  1428. ; so,after sysparse is done,we have to check if the entered *
  1429. ; values (stack_count,stack_size) are within the actual range, *
  1430. ; (or if "0,0" pair has been entered.) *
  1431. ; input : *
  1432. ; es:si -> parameters in command line. *
  1433. ; output: *
  1434. ; set the variables stack_count,stack_size. *
  1435. ; *
  1436. ; subroutines to be called: *
  1437. ; sysinit_parse *
  1438. ; logic: *
  1439. ; { *
  1440. ; set di points to stks_parms; *
  1441. ; set dx,cx to 0; *
  1442. ; while (end of command line) *
  1443. ; { sysinit_parse; *
  1444. ; if (no error) then *
  1445. ; { if (cx == 1) then /* first positional = stack count */ *
  1446. ; p_stack_count = result_val.$p_picked_val; *
  1447. ; if (cx == 2) then /* second positional = stack size */ *
  1448. ; p_stack_size = result_val.$p_picked_val; *
  1449. ; } *
  1450. ; else /*error exit*/ *
  1451. ; error exit; *
  1452. ; }; *
  1453. ; here check p_stack_count,p_stack_size if it meets the condition; *
  1454. ; if o.k.,then set stack_count,stack_size; *
  1455. ; else error_exit; *
  1456. ; }; *
  1457. ;****************************************************************************
  1458. tryk:
  1459. ifndef NEC_98
  1460. cmp ah,'K'
  1461. je do_tryk
  1462. jmp trys
  1463. if stacksw
  1464. do_tryk:
  1465. mov di,offset stks_parms
  1466. xor cx,cx
  1467. mov dx,cx
  1468. do79:
  1469. call sysinit_parse
  1470. jnc if79 ; parse error
  1471. mov dx,offset badstack ; "invalid stack parameter"
  1472. ifdef JAPAN
  1473. call IsDBCSCodePage
  1474. jz @f
  1475. mov dx,offset badstack2
  1476. @@:
  1477. endif
  1478. call print ; and show messages and end the search loop.
  1479. call error_line
  1480. jmp sr79
  1481. if79:
  1482. cmp ax,$p_rc_eol ; end of line?
  1483. jz en79 ; then end the $endloop
  1484. mov ax,word ptr result_val.$p_picked_val
  1485. cmp cx,1
  1486. jnz if83
  1487. mov p_stack_count,ax
  1488. jmp short en83
  1489. if83:
  1490. mov p_stack_size,ax
  1491. en83:
  1492. jmp do79
  1493. en79:
  1494. cmp p_stack_count,0
  1495. jz if87
  1496. cmp p_stack_count,mincount
  1497. jb ll88
  1498. cmp p_stack_size,minsize
  1499. jnb if88
  1500. ll88:
  1501. mov p_stack_count,-1 ; invalid
  1502. if88:
  1503. jmp short en87
  1504. if87:
  1505. cmp p_stack_size,0
  1506. jz en87
  1507. mov p_stack_count,-1 ; invalid
  1508. en87:
  1509. cmp p_stack_count,-1 ; invalid?
  1510. jnz if94
  1511. mov stack_count,defaultcount ;reset to default value.
  1512. mov stack_size,defaultsize
  1513. mov word ptr stack_addr,0
  1514. mov dx,offset badstack
  1515. ifdef JAPAN
  1516. call IsDBCSCodePage
  1517. jz @f
  1518. mov dx,offset badstack2
  1519. @@:
  1520. endif
  1521. call print
  1522. call error_line
  1523. jmp short sr79
  1524. if94:
  1525. mov ax,p_stack_count
  1526. mov stack_count,ax
  1527. mov ax,p_stack_size
  1528. mov stack_size,ax
  1529. mov word ptr stack_addr,-1 ; stacks= been accepted.
  1530. sr79:
  1531. jmp coff
  1532. endif
  1533. else ;NEC_98
  1534. if stacksw
  1535. cmp ah,'K'
  1536. je do_tryk
  1537. jmp trys
  1538. do_tryk:
  1539. mov di,offset stks_parms
  1540. xor cx,cx
  1541. mov dx,cx
  1542. do79:
  1543. call sysinit_parse
  1544. jnc if79 ; parse error
  1545. mov dx,offset badstack ; "invalid stack parameter"
  1546. ifdef JAPAN
  1547. call IsDBCSCodePage
  1548. jz @f
  1549. mov dx,offset badstack2
  1550. @@:
  1551. endif
  1552. call print ; and show messages and end the search loop.
  1553. call error_line
  1554. jmp sr79
  1555. if79:
  1556. cmp ax,$p_rc_eol ; end of line?
  1557. jz en79 ; then end the $endloop
  1558. mov ax,word ptr result_val.$p_picked_val
  1559. cmp cx,1
  1560. jnz if83
  1561. mov p_stack_count,ax
  1562. jmp short en83
  1563. if83:
  1564. mov p_stack_size,ax
  1565. en83:
  1566. jmp do79
  1567. en79:
  1568. cmp p_stack_count,0
  1569. jz if87
  1570. cmp p_stack_count,mincount
  1571. jb ll88
  1572. cmp p_stack_size,minsize
  1573. jnb if88
  1574. ll88:
  1575. mov p_stack_count,-1 ; invalid
  1576. if88:
  1577. jmp short en87
  1578. if87:
  1579. cmp p_stack_size,0
  1580. jz en87
  1581. mov p_stack_count,-1 ; invalid
  1582. en87:
  1583. cmp p_stack_count,-1 ; invalid?
  1584. jnz if94
  1585. mov stack_count,defaultcount ;reset to default value.
  1586. mov stack_size,defaultsize
  1587. mov word ptr stack_addr,0
  1588. mov dx,offset badstack
  1589. ifdef JAPAN
  1590. call IsDBCSCodePage
  1591. jz @f
  1592. mov dx,offset badstack2
  1593. @@:
  1594. endif
  1595. call print
  1596. call error_line
  1597. jmp short sr79
  1598. if94:
  1599. mov ax,p_stack_count
  1600. mov stack_count,ax
  1601. mov ax,p_stack_size
  1602. mov stack_size,ax
  1603. mov word ptr stack_addr,-1 ; stacks= been accepted.
  1604. sr79:
  1605. jmp coff
  1606. endif
  1607. endif ;NEC_98
  1608. ;------------------------------------------------------------------------
  1609. ; shell command
  1610. ;------------------------------------------------------------------------
  1611. trys:
  1612. cmp ah,'S'
  1613. jnz tryx
  1614. mov [command_line+1],0
  1615. mov di,offset commnd + 1
  1616. mov [di-1],al
  1617. storeshell:
  1618. call getchr
  1619. or al,al
  1620. jz getshparms
  1621. cmp al," "
  1622. jb endsh
  1623. mov [di],al
  1624. inc di
  1625. jmp storeshell
  1626. endsh:
  1627. mov byte ptr [di],0
  1628. ; push di
  1629. ; mov di,offset commnd
  1630. ; SVC SVC_SETSHELLNAME
  1631. ; pop di
  1632. call getchr
  1633. cmp al,lf
  1634. jnz conv
  1635. call getchr
  1636. conv: jmp conflp
  1637. getshparms:
  1638. mov byte ptr [di],0
  1639. mov di,offset command_line+1
  1640. parmloop:
  1641. call getchr
  1642. cmp al," "
  1643. jb endsh
  1644. mov [di],al
  1645. inc di
  1646. jmp parmloop
  1647. ;------------------------------------------------------------------------
  1648. ; fcbs command
  1649. ;------------------------------------------------------------------------
  1650. ;************************************************************************
  1651. ; function: parse the parameters of fcbs= command. *
  1652. ; *
  1653. ; input : *
  1654. ; es:si -> parameters in command line. *
  1655. ; output: *
  1656. ; set the variables fcbs,keep. *
  1657. ; *
  1658. ; subroutines to be called: *
  1659. ; sysinit_parse *
  1660. ; logic: *
  1661. ; { *
  1662. ; set di points to fcbs_parms; *
  1663. ; set dx,cx to 0; *
  1664. ; while (end of command line) *
  1665. ; { sysparse; *
  1666. ; if (no error) then *
  1667. ; { if (cx == 1) then /* first positional = fcbs */ *
  1668. ; fcbs = result_val.$p_picked_val; *
  1669. ; if (cx == 2) then /* second positional = keep */ *
  1670. ; keep = result_val.$p_picked_val; *
  1671. ; } *
  1672. ; else /*error exit*/ *
  1673. ; error exit; *
  1674. ; }; *
  1675. ; }; *
  1676. ;************************************************************************
  1677. tryx:
  1678. cmp ah,'X'
  1679. jnz tryy
  1680. mov di,offset fcbs_parms
  1681. xor cx,cx
  1682. mov dx,cx
  1683. do98:
  1684. call sysinit_parse
  1685. jnc if98 ; parse error
  1686. call badparm_p ; and show messages and end the search loop.
  1687. jmp short sr98
  1688. if98:
  1689. cmp ax,$p_rc_eol ; end of line?
  1690. jz en98 ; then end the $endloop
  1691. mov al,byte ptr result_val.$p_picked_val
  1692. cmp cx,1 ; the first positional?
  1693. jnz if102
  1694. mov p_fcbs,al
  1695. jmp short en102
  1696. if102:
  1697. mov p_keep,al
  1698. en102:
  1699. jmp do98
  1700. en98:
  1701. mov al,p_fcbs ; M017
  1702. mov fcbs,al ; M017
  1703. mov keep,0 ; M017
  1704. sr98:
  1705. jmp coff
  1706. ;-------------------------------------------------------------------------
  1707. ; comment= do nothing. just decrese chrptr,and increase count for correct
  1708. ; line number
  1709. ;-------------------------------------------------------------------------
  1710. tryy:
  1711. cmp ah,'Y'
  1712. jne try0
  1713. donothing:
  1714. dec chrptr
  1715. inc count
  1716. jmp coff
  1717. ;------------------------------------------------------------------------
  1718. ; rem command
  1719. ;------------------------------------------------------------------------
  1720. try0: ;do nothing with this line.
  1721. cmp ah,'0'
  1722. je donothing
  1723. ;-----------------------------------------------------------------------
  1724. ; switches command
  1725. ;-----------------------------------------------------------------------
  1726. ;****************************************************************************
  1727. ; *
  1728. ; function: parse the option switches specified. *
  1729. ; note - this command is intended for the future use also. when we need to *
  1730. ; to set system data flag,use this command. *
  1731. ; *
  1732. ; input : *
  1733. ; es:si -> parameters in command line. *
  1734. ; output: *
  1735. ; p_swit_k set if /k option chosen. *
  1736. ; *
  1737. ; subroutines to be called: *
  1738. ; sysinit_parse *
  1739. ; logic: *
  1740. ; { *
  1741. ; set di points to swit_parms; /*parse control definition*/ *
  1742. ; set dx,cx to 0; *
  1743. ; while (end of command line) *
  1744. ; { sysinit_parse; *
  1745. ; if (no error) then *
  1746. ; if (result_val.$p_synonym_ptr == swit_k) then *
  1747. ; p_swit_k = 1 *
  1748. ; endif *
  1749. ; else {show error message;error exit} *
  1750. ; }; *
  1751. ; }; *
  1752. ; *
  1753. ;****************************************************************************
  1754. cmp ah,'1' ;switches= command entered?
  1755. je do_try1
  1756. jmp tryt
  1757. do_try1:
  1758. mov di,offset swit_parms
  1759. xor cx,cx
  1760. mov dx,cx
  1761. do110:
  1762. call sysinit_parse
  1763. jnc if110 ; parse error
  1764. call badparm_p ; and show messages and end the search loop.
  1765. jmp short sr110
  1766. if110:
  1767. cmp ax,$p_rc_eol ; end of line?
  1768. jz en110 ; then jmp to $endloop for semantic check
  1769. cmp result_val.$p_synonym_ptr,offset swit_k
  1770. jnz if115 ; ;M059
  1771. mov p_swit_k,1 ; set the flag
  1772. jmp do110
  1773. if115: ;M059
  1774. cmp result_val.$p_synonym_ptr, offset swit_t ;M059
  1775. jne if116 ;M059 M063
  1776. mov p_swit_t, 1 ;M059
  1777. jmp do110 ;M059
  1778. if116:
  1779. cmp result_val.$p_synonym_ptr, offset swit_w ;M063
  1780. jne do110 ;M063
  1781. mov p_swit_w, 1 ;M063
  1782. jmp do110 ;M063
  1783. en110:
  1784. cmp p_swit_k,1 ;if /k entered,
  1785. push ds
  1786. mov ax,Bios_Data
  1787. mov ds,ax
  1788. assume ds:Bios_Data
  1789. jnz if117
  1790. mov keyrd_func,0 ;use the conventional keyboard functions
  1791. mov keysts_func,1
  1792. if117:
  1793. ifndef NEC_98
  1794. ; mov al, p_swit_t ;M059
  1795. else ;NEC_98
  1796. mov al, p_swit_t ;M059
  1797. endif ;NEC_98
  1798. ; mov t_switch, al ;M059
  1799. cmp p_swit_w, 0 ;M063
  1800. je skip_dos_flag ;M063
  1801. push es
  1802. push bx
  1803. mov ah, GET_IN_VARS ;M063
  1804. int 21h ;M063
  1805. or byte ptr es:[DOS_FLAG_OFFSET], SUPPRESS_WINA20 ;M063
  1806. pop bx
  1807. pop es
  1808. skip_dos_flag: ;M063
  1809. pop ds
  1810. assume ds:sysinitseg
  1811. sr110:
  1812. jmp coff
  1813. ;------------------------------------------------------------------------
  1814. ; NTCMDPROMPT command. This command forces SCS functionality to use
  1815. ; cmd.exe prompt rather than command.com's prompt on shelling out
  1816. ; and on finding a TSR.
  1817. ;------------------------------------------------------------------------
  1818. tryt:
  1819. cmp ah,'T'
  1820. je tryt_5
  1821. jmp short tryo
  1822. tryt_5:
  1823. push si
  1824. push bp
  1825. xor ax,ax
  1826. mov bp,ax
  1827. mov si,ax
  1828. mov al,4
  1829. mov ah,setdpb
  1830. int 21h
  1831. pop bp
  1832. pop si
  1833. jmp coff
  1834. ;------------------------------------------------------------------------
  1835. ; DOSONLY command. This command forces only DOS binaries to run from
  1836. ; command.com prompt. non_dos binaries will putup the stub message
  1837. ; of unable to run it under DOS.
  1838. ;------------------------------------------------------------------------
  1839. tryo:
  1840. cmp ah,'O'
  1841. je tryo_5
  1842. jmp short tryz
  1843. tryo_5:
  1844. push si
  1845. push bp
  1846. xor ax,ax
  1847. mov bp,ax
  1848. mov si,ax
  1849. mov al,6
  1850. mov ah,setdpb
  1851. int 21h
  1852. pop bp
  1853. pop si
  1854. jmp coff
  1855. ;------------------------------------------------------------------------
  1856. ; bogus command
  1857. ;------------------------------------------------------------------------
  1858. tryz:
  1859. cmp ah,0ffh
  1860. je tryff
  1861. dec chrptr
  1862. inc count
  1863. jmp short badop
  1864. ;------------------------------------------------------------------------
  1865. ; null command
  1866. ;------------------------------------------------------------------------
  1867. tryff: ;skip this command.
  1868. jmp donothing
  1869. doconf endp
  1870. ;------------------------------------------------------------------------------
  1871. sysinit_parse proc
  1872. ;set up registers for sysparse
  1873. ;in) es:si -> command line in confbot
  1874. ; di -> offset of the parse control defintion.
  1875. ;
  1876. ;out) calls sysparse.
  1877. ; carry will set if parse error.
  1878. ; *** the caller should check the eol condition by looking at ax
  1879. ; *** after each call.
  1880. ; *** if no parameters are found,then ax will contain a error code.
  1881. ; *** if the caller needs to look at the synomym@ of the result,
  1882. ; *** the caller should use cs:@ instead of es:@.
  1883. ; cx register should be set to 0 at the first time the caller calls this
  1884. ; procedure.
  1885. ; ax - exit code
  1886. ; bl - terminated delimeter code
  1887. ; cx - new positional ordinal
  1888. ; si - set to pase scanned operand
  1889. ; dx - selected result buffer
  1890. push es ;save es,ds
  1891. push ds
  1892. push es
  1893. pop ds ;now ds:si -> command line
  1894. push cs
  1895. pop es ;now es:di -> control definition
  1896. mov cs:badparm_seg,ds ;save the pointer to the parm
  1897. mov cs:badparm_off,si ; we are about to parse for badparm msg.
  1898. mov dx,0
  1899. call sysparse
  1900. cmp ax,$p_no_error ;no error
  1901. ;**cas note: when zero true after cmp, carry clear
  1902. jz ll4
  1903. cmp ax,$p_rc_eol ;or the end of line?
  1904. jnz if4
  1905. ll4:
  1906. clc
  1907. jmp short en4
  1908. if4:
  1909. stc
  1910. en4:
  1911. pop ds
  1912. pop es
  1913. ret
  1914. sysinit_parse endp
  1915. ;
  1916. ;----------------------------------------------------------------------------
  1917. ;
  1918. ; procedure : badop_p
  1919. ;
  1920. ; same thing as badop,but will make sure to set ds register back
  1921. ; to sysinitseg and return back to the caller.
  1922. ;
  1923. ;----------------------------------------------------------------------------
  1924. ;
  1925. badop_p proc near
  1926. push cs
  1927. pop ds ;set ds to configsys seg.
  1928. mov dx,offset badopm
  1929. ifdef JAPAN
  1930. call IsDBCSCodePage
  1931. jz @f
  1932. mov dx,offset badopm2
  1933. @@:
  1934. endif
  1935. call print
  1936. call error_line
  1937. ret
  1938. badop_p endp
  1939. ;
  1940. ;----------------------------------------------------------------------------
  1941. ;
  1942. ; label : badop
  1943. ;
  1944. ;----------------------------------------------------------------------------
  1945. ;
  1946. badop: mov dx,offset badopm ;want to print command error "unrecognized command..."
  1947. ifdef JAPAN
  1948. call IsDBCSCodePage
  1949. jz @f
  1950. mov dx,offset badopm2
  1951. @@:
  1952. endif
  1953. call print
  1954. call error_line ;show "error in config.sys ..." .
  1955. jmp coff
  1956. ;
  1957. ;----------------------------------------------------------------------------
  1958. ;
  1959. ; procedure : badparm_p
  1960. ;
  1961. ; show "bad command or parameters - xxxxxx"
  1962. ; in badparm_seg,badparm_off -> xxxxx
  1963. ;
  1964. ;----------------------------------------------------------------------------
  1965. ;
  1966. badparm_p proc near
  1967. push ds
  1968. push dx
  1969. push si
  1970. push cs
  1971. pop ds
  1972. mov dx,offset badparm
  1973. ifdef JAPAN
  1974. call IsDBCSCodePage
  1975. jz @f
  1976. mov dx,offset badparm2
  1977. @@:
  1978. endif
  1979. call print ;"bad command or parameters - "
  1980. lds si,badparm_ptr
  1981. ; print "xxxx" until cr.
  1982. do1:
  1983. mov dl,byte ptr [si] ; get next character
  1984. cmp dl,cr ; is a carriage return?
  1985. jz en1 ; exit loop if so
  1986. mov ah,std_con_output ; function 2
  1987. int 21h ; display character
  1988. inc si ; next character
  1989. jmp do1
  1990. en1:
  1991. push cs
  1992. pop ds
  1993. mov dx,offset crlfm
  1994. call print
  1995. call error_line
  1996. pop si
  1997. pop dx
  1998. pop ds
  1999. badparmp_ret:
  2000. ret
  2001. badparm_p endp
  2002. ;
  2003. ;----------------------------------------------------------------------------
  2004. ;
  2005. ; procedure : getchr
  2006. ;
  2007. ;----------------------------------------------------------------------------
  2008. ;
  2009. getchr proc near
  2010. push cx
  2011. mov cx,count
  2012. jcxz nochar
  2013. mov si,chrptr
  2014. mov al,es:[si]
  2015. dec count
  2016. inc chrptr
  2017. clc
  2018. get_ret:
  2019. pop cx
  2020. ret
  2021. nochar: stc
  2022. jmp short get_ret
  2023. getchr endp
  2024. ;
  2025. ;----------------------------------------------------------------------------
  2026. ;
  2027. ; procedure : incorrect_order
  2028. ;
  2029. ; show "incorrect order in config.sys ..." message.
  2030. ;
  2031. ;----------------------------------------------------------------------------
  2032. ;
  2033. incorrect_order proc near
  2034. mov dx,offset badorder
  2035. ifdef JAPAN
  2036. call IsDBCSCodePage
  2037. jz @f
  2038. mov dx,offset badorder2
  2039. @@:
  2040. endif
  2041. call print
  2042. call showlinenum
  2043. ret
  2044. incorrect_order endp
  2045. ;
  2046. ;----------------------------------------------------------------------------
  2047. ;
  2048. ; procedure : error_line
  2049. ;
  2050. ; show "error in config.sys ..." message.
  2051. ;
  2052. ;----------------------------------------------------------------------------
  2053. ;
  2054. public error_line
  2055. error_line proc near
  2056. push cs
  2057. pop ds
  2058. mov dx,offset errorcmd
  2059. ifdef JAPAN
  2060. call IsDBCSCodePage
  2061. jz @f
  2062. mov dx,offset errorcmd2
  2063. @@:
  2064. endif
  2065. call print
  2066. call showlinenum
  2067. ret
  2068. error_line endp
  2069. ;
  2070. ;----------------------------------------------------------------------------
  2071. ;
  2072. ; procedure : showlinenum
  2073. ;
  2074. ; convert the binary linecount to decimal ascii string in showcount
  2075. ;and display showcount at the current curser position.
  2076. ;in.) linecount
  2077. ;
  2078. ;out) the number is printed.
  2079. ;
  2080. ;----------------------------------------------------------------------------
  2081. ;
  2082. showlinenum proc near
  2083. push es
  2084. push ds
  2085. push di
  2086. push cs
  2087. pop es ; es=cs
  2088. push cs
  2089. pop ds
  2090. mov di,offset showcount+4 ; di -> the least significant decimal field.
  2091. mov cx,10 ; decimal devide factor
  2092. mov ax,cs:linecount
  2093. sln_loop:
  2094. cmp ax,10 ; < 10?
  2095. jb sln_last
  2096. xor dx,dx
  2097. div cx
  2098. or dl,30h ; add "0" (= 30h) to make it an ascii.
  2099. mov [di],dl
  2100. dec di
  2101. jmp sln_loop
  2102. sln_last:
  2103. or al,30h
  2104. mov [di],al
  2105. mov dx,di
  2106. call print ; show it.
  2107. pop di
  2108. pop ds
  2109. pop es
  2110. ret
  2111. showlinenum endp
  2112. comment ^
  2113. set_devmark proc near
  2114. ;***************************************************************************
  2115. ; function: set a paragraph of informations infront of a device file or *
  2116. ; an ifs file to be loaded for mem command. *
  2117. ; the structure is: *
  2118. ; devmark_id byte "d" for device,"i" for ifs *
  2119. ; devmark_size size in para for the device loaded *
  2120. ; devmark_filename 11 bytes. filename *
  2121. ; *
  2122. ; input : *
  2123. ; [memhi] = address to set up devmark. *
  2124. ; [memlo] = 0 *
  2125. ; es:si -> pointer to [drive][path]filename,0 *
  2126. ; [ifs_flag] = is_ifs bit set if ifs= command. *
  2127. ; *
  2128. ; output: devmark_id,devmark_filename set *
  2129. ; cs:[devmark_addr] set. *
  2130. ; ax,cx register destroyed. *
  2131. ;***************************************************************************
  2132. push ds
  2133. push si
  2134. push es
  2135. push di
  2136. mov di,cs:[memhi]
  2137. mov ds,di
  2138. assume ds:nothing
  2139. mov [devmark_addr],di ; save the devmark address for the future.
  2140. mov ds:[devmark_id],devmark_device ; 'd'
  2141. inc di
  2142. mov ds:[devmark_seg],di
  2143. xor al,al
  2144. push si
  2145. pop di ; now es:si = es:di = [path]filename,0
  2146. mov cx,128 ; maximum 128 char
  2147. repnz scasb ; find 0
  2148. dec di ; now es:di-> 0
  2149. sdvmk_backward: ; find the pointer to the start of the filename.
  2150. mov al,byte ptr es:[di] ; we do this by check es:di backward until
  2151. cmp al,'\' ; di = si or di -> '\' or di -> ':'.
  2152. je sdvmk_gotfile
  2153. cmp al,':'
  2154. je sdvmk_gotfile
  2155. cmp di,si
  2156. je sdvmk_fileptr
  2157. dec di
  2158. jmp sdvmk_backward
  2159. sdvmk_gotfile:
  2160. inc di
  2161. sdvmk_fileptr: ; now es:di -> start of file name
  2162. push di ; cas - holy sh*t!!! CODE!
  2163. pop si ; save di to si.
  2164. push ds ; switch es,ds
  2165. push es
  2166. pop ds
  2167. pop es ; now,ds:si -> start of filename
  2168. mov di,devmark_filename
  2169. push di
  2170. mov al,' '
  2171. mov cx,8
  2172. rep stosb ; clean up memory.
  2173. pop di
  2174. mov cx,8 ; max 8 char. only
  2175. sdvmk_loop:
  2176. lodsb
  2177. cmp al,'.'
  2178. je sdvmk_done
  2179. cmp al,0
  2180. je sdvmk_done
  2181. stosb
  2182. loop sdvmk_loop
  2183. sdvmk_done:
  2184. pop di
  2185. pop es
  2186. pop si
  2187. pop ds
  2188. ret
  2189. set_devmark endp
  2190. ^
  2191. ; =========================================================================
  2192. ;reset_dos_version proc near
  2193. ;
  2194. ;;function: issue ax=122fh,dx=0,int 2fh to restore the dos version.
  2195. ;
  2196. ; push ax
  2197. ; push dx
  2198. ; mov ax,122fh
  2199. ; mov dx,0
  2200. ; int 2fh
  2201. ; pop dx
  2202. ; pop ax
  2203. ; ret
  2204. ;reset_dos_version endp
  2205. ;
  2206. ;
  2207. ; =========================================================================
  2208. IFDEF DONT_LOAD_OS2_DD ; M045
  2209. EXE_SIG EQU 5a4dh ; .EXE file signature
  2210. OS2_SIG EQU 454eh ; OS2 .EXE file signature
  2211. SIGNATURE_LEN EQU 2 ; Lenght of .EXE signature in bytes
  2212. SIZE_DWORD EQU 4
  2213. SEG_SIG_OFFSET EQU 18h ; Offset of segmented .EXE signature
  2214. SEG_EXE_SIG EQU 40h ; Signature of a segmented .EXE file
  2215. SEG_HEADER_PTR EQU 3ch ; Offsets of ptr to segmented header
  2216. ; =========================================================================
  2217. ; CheckForOS2 PROC
  2218. ;
  2219. ; Examines an open file to see if it is really an OS2 executable file.
  2220. ;
  2221. ; REGISTERS: AX - Open file handle
  2222. ; RETURNS: Carry - Carry set if file is an OS2 executable or error.
  2223. ; DESTROYS: NOTHING
  2224. ; NOTE: The file ptr is assumed to be set to start of file
  2225. ; on entry and is not reset to begining of the file
  2226. ; on exit.
  2227. ;
  2228. ; Strategy: If word value at 00h == 454eh file is OS2
  2229. ; else if word value at 00h == 5a4dh and
  2230. ; (word value at 18h == 40h and the dword ptr at 3ch
  2231. ; points to word value of 454eh) file is OS2.
  2232. ;
  2233. ; =========================================================================
  2234. CheckForOS2 PROC NEAR
  2235. push AX
  2236. push BX
  2237. push CX
  2238. push DX
  2239. push DS
  2240. push BP
  2241. push CS ; BUGBUG
  2242. pop DS ; NOT ROM DOS COMPATIBLE
  2243. mov BX,AX ; Put open file handle in BX
  2244. mov BP,offset DS:Os2ChkBuf ; Save buff offset for latter
  2245. ; First we need to read in the first 2 bytes of the file
  2246. ; to see if it's an OS2 .EXE file and if not see if
  2247. ; it is a DOS .EXE file.
  2248. mov AX,(read shl 8) ; AH = DOS read function
  2249. mov CX,SIGNATURE_LEN ; CX = size of word value
  2250. mov DX,BP ; DS:DX --> tmp buffer
  2251. int 21h
  2252. jc OS2ChkExit ; Return carry on error
  2253. dec AX ; Check number of byte read
  2254. dec AX
  2255. jnz NotOs2 ; Must be at end of file
  2256. mov AX, WORD PTR DS:Os2ChkBuf
  2257. cmp AX, OS2_SIG ; Check for 454eh
  2258. je IsOS2 ; Return is OS2 if match
  2259. cmp AX, EXE_SIG ; Now see if it's a DOS .EXE
  2260. jne NotOS2 ; If no match can't be OS2
  2261. ; Here we know the file has a valid DOS .EXE signature so
  2262. ; now we need to see if it's a segmented .EXE file by looking
  2263. ; for the segmented .EXE signature at file offset 18h
  2264. mov AX,(lseek shl 8) ; AX = Seek from begining
  2265. xor CX,CX
  2266. mov DX,SEG_SIG_OFFSET ; CX:DX = offset of segmented
  2267. int 21h ; Seek to offset 18h
  2268. jc OS2ChkExit ; Return carry on error
  2269. mov AX,read shl 8 ; AX = Read file
  2270. mov CX,SIGNATURE_LEN ; CX = size of word value
  2271. mov DX,BP ; Restore buffer offset
  2272. int 21h ; DS:DX -> buffer
  2273. jc OS2ChkExit ; Return carry on error
  2274. dec AX ; Check number of byte read
  2275. dec AX
  2276. jnz NotOs2 ; Must be at end of file
  2277. cmp WORD PTR DS:Os2ChkBuf,SEG_EXE_SIG ; Chk for segmented .EXE file
  2278. jne NotOS2 ; Can't be OS2 if no match
  2279. ; Here we know we have a segmented .EXE file so we have
  2280. ; to get the offset of the start of the segmented header
  2281. ; from offset 3ch in the file.
  2282. mov AX,(lseek shl 8) ; AX = Seek from begining
  2283. xor CX,CX
  2284. mov DX,SEG_HEADER_PTR ; CX:DX = offset of head ptr
  2285. int 21h ; Seek to offset 3ch
  2286. jc OS2ChkExit ; Return carry on error
  2287. mov AX,(read shl 8) ; AX = Read file
  2288. mov CX,SIZE_DWORD ; CX = size of dword (4 bytes)
  2289. mov DX,BP ; Restore buffer offset
  2290. int 21h ; Read in 4 byte offset
  2291. jc OS2ChkExit ; Return carry on error
  2292. cmp AX,SIZE_DWORD ; Check number of byte read
  2293. jne NotOs2 ; Must be at end of file
  2294. ; At this point OS2ChkBuf has a 4 byte offset into the file
  2295. ; to the start of a segmented .EXE header so we need to read
  2296. ; the 2 bytes at this location to see if they are 454eh
  2297. mov DX,WORD PTR DS:Os2ChkBuf
  2298. mov CX,WORD PTR DS:Os2ChkBuf[2] ; CX:DX = offset of new header
  2299. mov AX,(lseek shl 8) ; AX = Seek from begining
  2300. int 21h ; Seek to offset 3ch
  2301. jc OS2ChkExit ; Return carry on error
  2302. mov AX,(read shl 8) ; AX = Read file
  2303. mov CX,SIGNATURE_LEN ; CX = size of word (2 bytes)
  2304. mov DX,BP ; DS:DX --> Os2ChkBuf
  2305. int 21h ; Read in 4 byte offset
  2306. jc OS2ChkExit ; Return carry on error
  2307. dec AX ; Check number of byte read
  2308. dec AX
  2309. jnz NotOs2 ; Must be at end of file
  2310. ; We have the segmented .EXE header in OS2ChkBuf so all
  2311. ; we have left to do is see if it's a .EXE signature.
  2312. cmp WORD PTR DS:OS2ChkBuf,OS2_SIG ; Check for 454eh
  2313. jne NotOs2 ; Not OS2 if it doesn't match
  2314. IsOs2:
  2315. stc ; Signal error or OS2 .EXE
  2316. jmp SHORT OS2ChkExit
  2317. NotOs2:
  2318. clc ; Signal no err and not OS2
  2319. OS2ChkExit:
  2320. pop BP
  2321. pop DS
  2322. pop DX
  2323. pop CX
  2324. pop BX
  2325. pop AX
  2326. ret
  2327. CheckForOS2 ENDP
  2328. ENDIF ; M045
  2329. ;
  2330. ;----------------------------------------------------------------------------
  2331. ;
  2332. ; procedure : ProcDOS
  2333. ;
  2334. ; Process the result of DOS= parsing
  2335. ;
  2336. ; result_val.$p_item_tag = 1 for DOS=HIGH
  2337. ; = 2 for DOS=LOW
  2338. ; = 3 for DOS=UMB
  2339. ; = 4 for DOS=NOUMB
  2340. ;----------------------------------------------------------------------------
  2341. ;
  2342. ProcDOS proc near
  2343. assume ds:nothing, es:nothing
  2344. xor ah, ah
  2345. mov al, result_val.$p_item_tag
  2346. dec ax
  2347. jz pd_hi
  2348. dec ax
  2349. jz pd_lo
  2350. dec ax
  2351. jz pd_umb
  2352. mov DevUMB, 0
  2353. ret
  2354. pd_umb:
  2355. mov DevUMB, 0ffh
  2356. ret
  2357. pd_lo:
  2358. mov runhigh, 0
  2359. ret
  2360. pd_hi:
  2361. mov runhigh, 0ffh
  2362. ret
  2363. ProcDOS endp
  2364. ;
  2365. ;----------------------------------------------------------------------------
  2366. ;
  2367. ; procedure : LieInt12Mem
  2368. ;
  2369. ; Input : DevEntry points to Device Start address (offset == 0)
  2370. ; alloclim set to the limit of low memory.
  2371. ;
  2372. ; Output : none
  2373. ;
  2374. ; Changes the ROM BIOS variable which stores the total low memory
  2375. ; If a 3com device driver (any character device with name 'PROTMAN$')
  2376. ; is being loaded alloclim is converted into Ks and stored in 40:13h
  2377. ; Else if a device driver being loaded into UMB the DevLoadEnd is
  2378. ; converted into Ks and stored in 40:13h
  2379. ;
  2380. ;----------------------------------------------------------------------------
  2381. ;
  2382. LieInt12Mem proc near
  2383. assume ds:nothing, es:nothing
  2384. mov ax, alloclim ; lie INT 12 as alloclim
  2385. ; assuming that it is 3Com
  2386. call IsIt3Com? ; Is it 3Com driver?
  2387. je lim_set ; yes, lie to him differently
  2388. cmp DeviceHi, 0 ; Is the DD being loaded in UMB
  2389. je limx ; no, don't lie
  2390. mov ax, DevLoadEnd ; lie INT 12 as end of UMB
  2391. lim_set:
  2392. call SetInt12Mem
  2393. limx:
  2394. ret
  2395. LieInt12Mem endp
  2396. ;
  2397. ;----------------------------------------------------------------------------
  2398. ;
  2399. ; procedure : SetInt12Mem
  2400. ;
  2401. ; Input : AX = Memory size to be set (in paras)
  2402. ; Output : none
  2403. ;
  2404. ; Sets the variable 40:13 to the memory size passed in AX
  2405. ; It saves the old value in 40:13 in OldInt12Mem,
  2406. ; It also sets a flag Int12Lied to 0ffh, which is checked before
  2407. ; restoring the value of 40:13
  2408. ;
  2409. ;----------------------------------------------------------------------------
  2410. ;
  2411. SetInt12Mem proc near
  2412. assume ds:nothing, es:nothing
  2413. push ds
  2414. mov bx, 40h
  2415. mov ds, bx ; ROM BIOS Data Segment
  2416. mov bx, word ptr ds:[13h] ; INT 12 memory variable
  2417. mov OldInt12Mem, bx ; save it
  2418. mov cl, 6
  2419. shr ax, cl ; convert paras into Ks
  2420. mov word ptr ds:[13h], ax ; Lie
  2421. mov Int12Lied, 0ffh ; mark that we are lying
  2422. pop ds
  2423. ret
  2424. SetInt12Mem endp
  2425. ;
  2426. ;----------------------------------------------------------------------------
  2427. ;
  2428. ; procedure : TrueInt12Mem
  2429. ;
  2430. ; Input : Int12Lied = 0 if we are not lying currently
  2431. ; = 0ffh if we are lying
  2432. ; OldInt12Mem = Saved value of 40:13h
  2433. ;
  2434. ; Output : none
  2435. ;
  2436. ; Resets the INT 12 Memory variable if we were lying about int 12
  2437. ; and resets the flag which indicates that we were lying
  2438. ;
  2439. ;----------------------------------------------------------------------------
  2440. ;
  2441. TrueInt12Mem proc near
  2442. assume ds:nothing, es:nothing
  2443. cmp Int12Lied, 0 ; were we lying so far?
  2444. mov Int12Lied, 0 ; reset it anyway
  2445. je timx ; no, we weren't
  2446. push ds
  2447. mov ax, 40h
  2448. mov ds, ax
  2449. mov ax, OldInt12Mem
  2450. mov word ptr ds:[13h], ax ; restore INT 12 memory
  2451. pop ds
  2452. timx:
  2453. ret
  2454. TrueInt12Mem endp
  2455. ;
  2456. ;----------------------------------------------------------------------------
  2457. ;
  2458. ; procedure : IsIt3Com?
  2459. ;
  2460. ; Input : DevEntry = Seg:0 of device driver
  2461. ; Output : Zero flag set if device name is 'PROTMAN$'
  2462. ; else Zero flag is reset
  2463. ;
  2464. ;----------------------------------------------------------------------------
  2465. ;
  2466. IsIt3Com? proc near
  2467. assume ds:nothing, es:nothing, ss:nothing
  2468. push ds
  2469. push es
  2470. push si
  2471. lds si, DevEntry ; ptr to device header
  2472. add si, sdevname ; ptr device name
  2473. push cs
  2474. pop es
  2475. mov di, offset ThreeComName
  2476. mov cx, 8 ; name length
  2477. rep cmpsb
  2478. pop si
  2479. pop es
  2480. pop ds
  2481. ret
  2482. IsIt3Com? endp
  2483. ;M020 : BEGIN
  2484. ;
  2485. ;----------------------------------------------------------------------------
  2486. ;----------------------------------------------------------------------------
  2487. ;
  2488. UpdatePDB proc near
  2489. assume ds:nothing
  2490. push ds
  2491. mov ah, 62h
  2492. int 21h
  2493. mov ds, bx
  2494. mov bx, alloclim
  2495. mov ds:[PDB_Block_Len], bx
  2496. pop ds
  2497. ret
  2498. UpdatePDB endp
  2499. ;
  2500. ; M020 : END
  2501. ;
  2502. ;----------------------------------------------------------------------------
  2503. ;
  2504. ; procedure : InitDevLoad
  2505. ;
  2506. ; Input : DeviceHi = 0 indicates load DD in low memory
  2507. ; = 1 indicates load in UMB
  2508. ; DevSize = Size of the device driver file in paras
  2509. ;
  2510. ; Output : none
  2511. ;
  2512. ; Initializes DevLoadAddr, DevLoadEnd & DevEntry.
  2513. ; Also sets up a header for the Device driver entry for mem utility
  2514. ;
  2515. ;----------------------------------------------------------------------------
  2516. ;
  2517. InitDevLoad proc near
  2518. assume ds:nothing, es:nothing
  2519. cmp DeviceHi, 0 ; Are we loading in UMB
  2520. je InitForLo ; no, init for lo mem
  2521. call SpaceInUMB? ; Do we have space left in the
  2522. ; current UMB ?
  2523. jnc InitForHi ; yes, we have
  2524. call ShrinkUMB ; shrink the current UMB in use
  2525. call GetUMBForDev ; else try to allocate new UMB
  2526. jc InitForLo ; we didn't succeed, so load
  2527. ; in low memory
  2528. InitForHi:
  2529. mov ax, DevUMBFree ; get Para addr of free mem
  2530. mov dx, DevUMBAddr ; UMB start addr
  2531. add dx, DevUMBSize ; DX = UMB End addr
  2532. jmp short idl1
  2533. InitForLo:
  2534. mov DeviceHi, 0 ; in case we failed to load
  2535. ; into UMB indicate that we
  2536. ; are loading low
  2537. mov ax, memhi ; AX = start of Low memory
  2538. mov dx, alloclim ; DX = End of Low memory
  2539. idl1:
  2540. call DevSetMark ; setup a sub-arena for DD
  2541. mov DevLoadAddr, ax ; init the Device load address
  2542. mov DevLoadEnd, dx ; init the limit of the block
  2543. mov word ptr DevEntry, 0 ; init Entry point to DD
  2544. mov word ptr DevEntry+2, ax
  2545. ret
  2546. InitDevLoad endp
  2547. ;------------------------------------------------------------------
  2548. ; NTVDM 08-Dec-1992 Jonle
  2549. ;
  2550. ; AllocUMBLow- Allocates a chunk from memory from UMB area
  2551. ; or from low memory area in case UMB memory
  2552. ; is unavailable.
  2553. ;
  2554. ; The arena is marked as
  2555. ;
  2556. ; Input: es:di addr of arena name to copy
  2557. ; cx size to allocate
  2558. ;
  2559. ; Output: es:di points to memory allocated
  2560. ;
  2561. ;------------------------------------------------------------------
  2562. AllocUMBLow proc near
  2563. assume ds:nothing, es:nothing
  2564. mov ax, cx ; convert size to paras
  2565. add ax, 18 ; extra for dummy dev header for mem.exe
  2566. call pararound
  2567. mov DevSize, ax
  2568. mov word ptr [bpb_addr], di ; fake cmd line for dev name
  2569. mov word ptr [bpb_addr+2], es
  2570. mov al, DevUMB ; we want UMB
  2571. mov DeviceHi, al
  2572. call InitDevLoad
  2573. mov ax, word ptr DevEntry+2 ; mark arena for mem.exe
  2574. dec ax
  2575. mov es, ax
  2576. mov byte ptr es:[devmark_id], devmark_spc
  2577. inc ax ; mark final size
  2578. add ax, DevSize
  2579. mov word ptr DevBrkAddr+2,ax
  2580. mov word ptr DevBrkAddr, 0
  2581. call DevBreak
  2582. mov di, word ptr DevEntry ; es:di -> deventry
  2583. mov ax, word ptr DevEntry+2
  2584. mov es, ax
  2585. AllocUMBLow endp
  2586. ;
  2587. ;----------------------------------------------------------------------------
  2588. ;
  2589. ; procedure : SpaceInUMB?
  2590. ;
  2591. ; Input : DevUMBAddr, DevUMBSize, DevUMBFree & DevSize
  2592. ; Output : Carry set if no space in UMB
  2593. ; Carry clear if Space is available for the device in
  2594. ; current UMB
  2595. ;
  2596. ;----------------------------------------------------------------------------
  2597. ;
  2598. SpaceInUMB? proc near
  2599. assume ds:nothing, es:nothing
  2600. mov ax, DevUMBSize
  2601. add ax, DevUMBAddr ; End of UMB
  2602. sub ax, DevUMBFree ; - Free = Remaining space
  2603. or ax, ax ; Nospace ?
  2604. jnz @f
  2605. stc
  2606. ret
  2607. @@:
  2608. dec ax ; space for sub-arena
  2609. cmp ax, DevSize ; do we have space ?
  2610. ret
  2611. SpaceInUMB? endp
  2612. ;
  2613. ;----------------------------------------------------------------------------
  2614. ;
  2615. ; procedure : GetUMBForDev
  2616. ;
  2617. ; Input : DevSize
  2618. ; Output : Carry set if couldn't allocate a UMB to fit the
  2619. ; the device.
  2620. ; If success carry clear
  2621. ;
  2622. ; Allocates the biggest UMB for loading devices and updates
  2623. ; DevUMBSize, DevUMBAddr & DevUMBFree if it succeeded in allocating
  2624. ; UMB.
  2625. ;
  2626. ; This routine relies on the fact that all of the low memory
  2627. ; is allocated, and any DOS alloc calls should return memory
  2628. ; from the UMB pool.
  2629. ;
  2630. ;----------------------------------------------------------------------------
  2631. ;
  2632. GetUMBForDev proc near
  2633. assume ds:nothing, es:nothing
  2634. if 0
  2635. ;;
  2636. mov bx, 0ffffh
  2637. mov ax, 4800h
  2638. int 21h
  2639. or bx, bx
  2640. jz gufd_err
  2641. dec bx
  2642. cmp DevSize, bx
  2643. ja gufd_err
  2644. inc bx
  2645. mov ax, 4800h
  2646. int 21h
  2647. jc gufd_err
  2648. push ds
  2649. dec ax
  2650. mov ds, ax
  2651. mov word ptr ds:[arena_owner], 8
  2652. mov word ptr ds:[arena_name], 'DS'
  2653. inc ax
  2654. pop ds
  2655. mov DevUMBSize, bx ; update the UMB Variables
  2656. mov DevUMBAddr, ax
  2657. mov DevUMBFree, ax
  2658. clc ; mark no error
  2659. ret
  2660. gufd_err:
  2661. xor ax, ax
  2662. mov DevUMBSize, ax ; erase the previous values
  2663. mov DevUMBAddr, ax
  2664. mov DevUMBFree, ax
  2665. stc
  2666. ret
  2667. else
  2668. ;; we changed the allocation strategy to best-fit for NT. This is because
  2669. ;; we want to reserve bigger blocks for loadhigh command. In most case,
  2670. ;; device drivers are smaller than TSR(ran from loadhigh). This change give
  2671. ;; us a better chance to load the big tsr like DOSX.EXE to UMB and
  2672. ;; give applications more free conventional memory.
  2673. ;; The following implementation seems slow because every time we need an
  2674. ;; UMB, we go through the chain. This is done because each request has
  2675. ;; different size - We can grab all UMBs from the very beginning and put
  2676. ;; them in a list, but we have to maintain the list. -williamh
  2677. push cx
  2678. push dx
  2679. push es
  2680. xor cx, cx ;; allocated count = 0
  2681. mov dx, DevSize
  2682. inc dx ;; minimum size in paras
  2683. ;; bios needs its sub-arena
  2684. search_for_best_block:
  2685. mov bx, 0ffffh ;; get largest block size
  2686. mov ah, 48h ;; so far
  2687. int 21h
  2688. cmp bx, dx ;; will this satisfy ours?
  2689. jb allocate_the_block ;; no, break
  2690. mov ah, 48h ;; allocate this block
  2691. int 21h
  2692. jc allocate_the_block ;; failed, use the previous one
  2693. inc cx ;; we have one more allocated
  2694. push bx ;; save the size
  2695. push ax ;; save the address
  2696. jmp short search_for_best_block
  2697. allocate_the_block:
  2698. ;; the block saved on the top of the stack is the best fit one
  2699. ;; grab it if there is one
  2700. jcxz gufd_err ;; no block found, error
  2701. pop ax ;; get the address
  2702. pop DevUMBSize ;; and size
  2703. mov DevUMBAddr, ax
  2704. mov DevUMBFree, ax
  2705. dec ax
  2706. push ds
  2707. mov ds, ax
  2708. mov word ptr ds:[arena_owner], 8
  2709. mov word ptr ds:[arena_name], 'DS'
  2710. pop ds
  2711. dec cx
  2712. ;; now free those unnecessary blocks
  2713. jcxz allocate_done
  2714. free_allocated_blocks:
  2715. pop es ;; get the address
  2716. add sp, 2 ;; discard the size
  2717. mov ah, 49h ;; free it
  2718. int 21h
  2719. loop free_allocated_blocks
  2720. allocate_done:
  2721. clc ; mark no error
  2722. jmp short GetUMBForDevExit
  2723. gufd_err:
  2724. xor ax, ax
  2725. mov DevUMBSize, ax ; erase the previous values
  2726. mov DevUMBAddr, ax
  2727. mov DevUMBFree, ax
  2728. stc
  2729. GetUMBForDevExit:
  2730. pop es
  2731. pop dx
  2732. pop cx
  2733. ret
  2734. endif
  2735. GetUMBForDev endp
  2736. ;
  2737. ;----------------------------------------------------------------------------
  2738. ;
  2739. ; procedure : DevSetMark
  2740. ;
  2741. ; Input : AX - Free segment were device is going to be loaded
  2742. ; Output : AX - Segment at which device can be loaded (AX=AX+1)
  2743. ;
  2744. ; Creates a sub-arena for the device driver
  2745. ; puts 'D' marker in the sub-arena
  2746. ; Put the owner of the sub-arena as (AX+1)
  2747. ; Copies the file name into sub-arena name field
  2748. ;
  2749. ; Size field of the sub-arena will be set only at succesful
  2750. ; completion of Device load.
  2751. ;
  2752. ;----------------------------------------------------------------------------
  2753. ;
  2754. DevSetMark proc near
  2755. assume ds:nothing, es:nothing
  2756. push es
  2757. push di
  2758. push ds
  2759. push si
  2760. mov es, ax
  2761. mov byte ptr es:[devmark_id], devmark_device ; 'D'
  2762. inc ax
  2763. mov word ptr es:[devmark_seg], ax
  2764. ;
  2765. ;-------------- Copy file name
  2766. ;
  2767. push ax ; save load addr
  2768. lds si, bpb_addr ; command line is still there
  2769. ;M004 - BEGIN
  2770. mov di, si
  2771. cld
  2772. dsm_again:
  2773. lodsb
  2774. cmp al, ':'
  2775. jne isit_slash
  2776. mov di, si
  2777. jmp dsm_again
  2778. isit_slash:
  2779. cmp al, '\'
  2780. jne isit_null
  2781. mov di, si
  2782. jmp dsm_again
  2783. isit_null:
  2784. ifdef DBCS
  2785. call testkanj
  2786. jz @f ; if this is not lead byte
  2787. lodsb ; get tail byte
  2788. @@:
  2789. endif
  2790. or al, al
  2791. jnz dsm_again
  2792. mov si, di
  2793. ;M004 - END
  2794. mov di, devmark_filename
  2795. mov cx, 8 ; maximum 8 characters
  2796. dsm_next_char:
  2797. lodsb
  2798. or al, al
  2799. jz blankout
  2800. cmp al, '.'
  2801. jz blankout
  2802. stosb
  2803. loop dsm_next_char
  2804. blankout:
  2805. jcxz dsm_exit
  2806. mov al, ' '
  2807. rep stosb ; blank out the rest
  2808. dsm_exit:
  2809. pop ax ; restore load addr
  2810. pop si
  2811. pop ds
  2812. pop di
  2813. pop es
  2814. ret
  2815. DevSetMark endp
  2816. ;
  2817. ;----------------------------------------------------------------------------
  2818. ;
  2819. ; procedure : SizeDevice
  2820. ;
  2821. ; Input : ES:SI - points to device file to be sized
  2822. ;
  2823. ; Output : Carry set if file cannot be opened or if it is an OS2EXE file
  2824. ;
  2825. ; Calculates the size of the device file in paras and stores it
  2826. ; in DevSize
  2827. ;
  2828. ;----------------------------------------------------------------------------
  2829. ;
  2830. SizeDevice proc near
  2831. assume ds:nothing, es:nothing
  2832. push es
  2833. pop ds
  2834. mov dx, si ; ds:dx -> file name
  2835. mov ax, 3d00h ; open
  2836. int 21h
  2837. jc sd_err ; open failed
  2838. IFDEF DONT_LOAD_OS2_DD ; M045
  2839. call CheckForOS2 ; is it a OS2 EXE file ?
  2840. jc sd_close ; yeah, we dont load them
  2841. ENDIF ; M045
  2842. mov bx, ax ; BX - file handle
  2843. mov ax, 4202h ; seek
  2844. xor cx, cx
  2845. mov dx, cx ; to end of file
  2846. int 21h
  2847. jc sd_close ; did seek fail (impossible)
  2848. add ax, 15 ; para convert
  2849. adc dx, 0
  2850. test dx, 0fff0h ; size > 0ffff paras ?
  2851. jz @f ; no
  2852. mov DevSize, 0ffffh ; invalid device size
  2853. ; assuming that we fail later
  2854. jmp short sd_close
  2855. @@:
  2856. mov cl, 4 ; conver it to paras
  2857. shr ax, cl
  2858. mov cl, 12
  2859. shl dx, cl
  2860. or ax, dx ;
  2861. cmp ax, DevSizeOption
  2862. ja @f
  2863. mov ax, DevSizeOption
  2864. @@:
  2865. mov DevSize, ax ; save file size
  2866. clc
  2867. sd_close:
  2868. pushf ; let close not spoil our
  2869. ; carry flag
  2870. mov ax, 3e00h ; close
  2871. int 21h ; we are not checking for err
  2872. popf
  2873. sd_err:
  2874. ret
  2875. SizeDevice endp
  2876. ;
  2877. ;----------------------------------------------------------------------------
  2878. ;
  2879. ; procedure : ExecDev
  2880. ;
  2881. ; Input : ds:dx -> device to be executed
  2882. ; DevLoadAddr - contains where device has to be loaded
  2883. ;
  2884. ; Output : Carry if error
  2885. ; Carry clear if no error
  2886. ;
  2887. ; Loads a device driver using the 4b03h function call
  2888. ;
  2889. ;----------------------------------------------------------------------------
  2890. ;
  2891. ExecDev proc near
  2892. assume ds:nothing, es:nothing
  2893. mov bx, DevLoadAddr
  2894. mov DevExecAddr, bx ; Load the parameter block
  2895. ; block for exec with
  2896. ; Load address
  2897. mov DevExecReloc, bx
  2898. mov bx,cs
  2899. mov es,bx
  2900. mov bx,offset DevExecAddr ;es:bx points to parameters
  2901. mov al,3
  2902. mov ah,exec
  2903. int 21h ;load in the device driver
  2904. ret
  2905. ExecDev endp
  2906. ;
  2907. ;----------------------------------------------------------------------------
  2908. ;
  2909. ; procedure : RemoveNull
  2910. ;
  2911. ; Input : ES:SI points to a null terminated string
  2912. ;
  2913. ; Output : none
  2914. ;
  2915. ; Replaces the null at the end of a string with blank
  2916. ;
  2917. ;----------------------------------------------------------------------------
  2918. ;
  2919. RemoveNull proc near
  2920. assume ds:nothing, es:nothing
  2921. rn_next:
  2922. mov bl, es:[si]
  2923. or bl, bl ; null ?
  2924. jz rn_gotnull
  2925. inc si ; advance the pointer
  2926. jmp rn_next
  2927. rn_gotnull:
  2928. mov bl, DevSavedDelim
  2929. mov byte ptr es:[si], bl ; replace null with blank
  2930. ret
  2931. RemoveNull endp
  2932. ;
  2933. ;----------------------------------------------------------------------------
  2934. ;
  2935. ; procedure : RoundBreakAddr
  2936. ;
  2937. ; Input : DevBrkAddr
  2938. ; Output : DevBrkAddr
  2939. ;
  2940. ; Rounds DevBrkAddr to a para address so that it is of the form xxxx:0
  2941. ;
  2942. ;----------------------------------------------------------------------------
  2943. ;
  2944. RoundBreakAddr proc near
  2945. assume ds:nothing, es:nothing
  2946. mov ax, word ptr DevBrkAddr
  2947. call pararound
  2948. add word ptr DevBrkAddr+2, ax
  2949. mov word ptr DevBrkAddr, 0
  2950. mov ax, DevLoadEnd
  2951. cmp word ptr DevBrkAddr+2, ax
  2952. jbe rba_ok
  2953. jmp mem_err
  2954. rba_ok:
  2955. ret
  2956. RoundBreakAddr endp
  2957. ;
  2958. ;----------------------------------------------------------------------------
  2959. ;
  2960. ; procedure : DevSetBreak
  2961. ;
  2962. ; Input : DevBrkAddr
  2963. ; Output : Carry set if Device returned Init failed
  2964. ; Else carry clear
  2965. ;
  2966. ;----------------------------------------------------------------------------
  2967. ;
  2968. DevSetBreak proc near
  2969. assume ds:nothing, es:nothing
  2970. push ax
  2971. mov ax,word ptr [DevBrkAddr+2] ;remove the init code
  2972. cmp multdeviceflag, 0
  2973. jne set_break_continue ;do not check it.
  2974. cmp ax, DevLoadAddr
  2975. jne set_break_continue ;if not same, then o.k.
  2976. cmp word ptr [DevBrkAddr],0
  2977. je break_failed ;[DevBrkAddr+2]=[memhi] & [DevBrkAddr]=0
  2978. set_break_continue:
  2979. call RoundBreakAddr
  2980. pop ax
  2981. clc
  2982. ret
  2983. break_failed:
  2984. pop ax
  2985. stc
  2986. ret
  2987. DevSetBreak endp
  2988. ;
  2989. ;----------------------------------------------------------------------------
  2990. ;
  2991. ; procedure : DevBreak
  2992. ;
  2993. ; Input : DevLoadAddr & DevBrkAddr
  2994. ; Output : none
  2995. ;
  2996. ; Marks a succesful install of a device driver
  2997. ; Sets device size field in sub-arena &
  2998. ; Updates Free ptr in UMB or adjusts memhi
  2999. ;
  3000. ;----------------------------------------------------------------------------
  3001. ;
  3002. DevBreak proc near
  3003. assume ds:nothing, es:nothing
  3004. push ds
  3005. mov ax, DevLoadAddr
  3006. mov bx, word ptr [DevBrkAddr+2]
  3007. dec ax ; seg of sub-arena
  3008. mov ds, ax
  3009. inc ax ; Back to Device segment
  3010. sub ax, bx
  3011. neg ax ; size of device in paras
  3012. mov ds:[devmark_size], ax ; store it in sub-arena
  3013. cmp DeviceHi, 0
  3014. je db_lo
  3015. mov DevUMBFree, bx ; update Free ptr in UMB
  3016. jmp short db_exit
  3017. db_lo:
  3018. mov memhi, bx
  3019. mov memlo, 0
  3020. db_exit:
  3021. pop ds
  3022. ret
  3023. DevBreak endp
  3024. ;
  3025. ;----------------------------------------------------------------------------
  3026. ;
  3027. ; procedure : ParseSize
  3028. ;
  3029. ; Parses the command line for SIZE= command
  3030. ;
  3031. ; ES:SI = command line to parsed
  3032. ;
  3033. ; returns ptr to command line after SIZE= option in ES:SI
  3034. ; updates the DevSizeOption variable with value supplied
  3035. ; in SIZE=option
  3036. ; Returns carry if the SIZE option was invalid
  3037. ;
  3038. ;----------------------------------------------------------------------------
  3039. ;
  3040. ParseSize proc near
  3041. assume ds:nothing, es:nothing
  3042. mov DevSizeOption, 0 ; init the value
  3043. mov word ptr DevCmdLine, si
  3044. mov word ptr DevCmdLine+2, es
  3045. call SkipDelim
  3046. cmp word ptr es:[si], 'IS'
  3047. jne ps_no_size
  3048. cmp word ptr es:[si+2], 'EZ'
  3049. jne ps_no_size
  3050. mov al, es:[si+4]
  3051. call delim
  3052. jne ps_no_size
  3053. add si, 5
  3054. call GetHexNum
  3055. jc ps_err
  3056. mov DevSizeOption, ax
  3057. call SkipDelim
  3058. ps_no_size:
  3059. clc
  3060. ret
  3061. ps_err:
  3062. stc
  3063. ret
  3064. ParseSize endp
  3065. ;
  3066. ;----------------------------------------------------------------------------
  3067. ;
  3068. ; procedure : SkipDelim
  3069. ;
  3070. ; Skips delimiters in the string pointed to by ES:SI
  3071. ; Returns ptr to first non-delimiter character in ES:SI
  3072. ;
  3073. ;----------------------------------------------------------------------------
  3074. ;
  3075. SkipDelim proc near
  3076. assume ds:nothing, es:nothing
  3077. sd_next_char:
  3078. mov al, es:[si]
  3079. call delim
  3080. jnz sd_ret
  3081. inc si
  3082. jmp sd_next_char
  3083. sd_ret:
  3084. ret
  3085. SkipDelim endp
  3086. ;
  3087. ;----------------------------------------------------------------------------
  3088. ;
  3089. ; procedure : GetHexNum
  3090. ;
  3091. ; Converts an ascii string terminated by a delimiter into binary.
  3092. ; Assumes that the ES:SI points to a Hexadecimal string
  3093. ;
  3094. ; Returns in AX the number number of paras equivalent to the
  3095. ; hex number of bytes specified by the hexadecimal string.
  3096. ;
  3097. ; Returns carry in case it encountered a non-hex character or
  3098. ; if it encountered crlf
  3099. ;
  3100. ;----------------------------------------------------------------------------
  3101. ;
  3102. GetHexNum proc near
  3103. assume ds:nothing, es:nothing
  3104. xor ax, ax
  3105. xor dx, dx
  3106. ghn_next:
  3107. mov bl, es:[si]
  3108. cmp bl, cr
  3109. je ghn_err
  3110. cmp bl, lf
  3111. je ghn_err
  3112. push ax
  3113. mov al, bl
  3114. call Delim
  3115. pop ax
  3116. jz ghn_into_paras
  3117. call GetNibble
  3118. jc ghn_err
  3119. mov cx, 4
  3120. ghn_shift1:
  3121. shl ax, 1
  3122. rcl dx, 1
  3123. loop ghn_shift1
  3124. or al, bl
  3125. inc si
  3126. jmp ghn_next
  3127. ghn_into_paras:
  3128. add ax, 15
  3129. adc dx, 0
  3130. test dx, 0fff0h
  3131. jnz ghn_err
  3132. mov cx, 4
  3133. ghn_shift2:
  3134. clc
  3135. rcr dx, 1
  3136. rcr ax, 1
  3137. loop ghn_shift2
  3138. clc
  3139. ret
  3140. ghn_err:
  3141. stc
  3142. ret
  3143. GetHexNum endp
  3144. ;
  3145. ;----------------------------------------------------------------------------
  3146. ;
  3147. ; procedure : GetNibble
  3148. ;
  3149. ; Convert one nibble (hex digit) in BL into binary
  3150. ;
  3151. ; Retruns binary value in BL
  3152. ;
  3153. ; Returns carry if BL contains non-hex digit
  3154. ;
  3155. ;----------------------------------------------------------------------------
  3156. ;
  3157. GetNibble proc near
  3158. cmp bl, '0'
  3159. jb gnib_err
  3160. cmp bl, '9'
  3161. ja is_it_hex
  3162. sub bl, '0' ; clc
  3163. ret
  3164. is_it_hex:
  3165. cmp bl, 'A'
  3166. jb gnib_err
  3167. cmp bl, 'F'
  3168. ja gnib_err
  3169. sub bl, 'A'- 10 ; clc
  3170. ret
  3171. gnib_err:
  3172. stc
  3173. ret
  3174. GetNibble endp
  3175. ;
  3176. ;
  3177. ;============================================================================
  3178. ;============================================================================
  3179. ;
  3180. ;----------------------------------------------------------------------------
  3181. ;
  3182. ; procedure : AllocUMB
  3183. ;
  3184. ; Allocate all UMBs and link it to DOS arena chain
  3185. ;
  3186. ;----------------------------------------------------------------------------
  3187. ;
  3188. AllocUMB proc near
  3189. call InitAllocUMB ; link in the first UMB
  3190. jc au_exit ; quit on error
  3191. au_next:
  3192. call umb_allocate ; allocate
  3193. jc au_coalesce
  3194. call umb_insert ; & insert till no UMBs
  3195. jmp short au_next
  3196. au_coalesce:
  3197. call umb_coalesce ; coalesce all UMBs
  3198. au_exit:
  3199. ret
  3200. AllocUMB endp
  3201. ;
  3202. ;----------------------------------------------------------------------------
  3203. ;
  3204. ; procedure : InitAllocUMB
  3205. ;
  3206. ;----------------------------------------------------------------------------
  3207. ;
  3208. InitAllocUMB proc near
  3209. call IsXMSLoaded
  3210. jnz iau_err ; quit on no XMS driver
  3211. mov ah, 52h
  3212. int 21h ; get DOS DATA seg
  3213. mov DevDOSData, es ; & save it for later
  3214. mov ax, 4310h
  3215. int 2fh
  3216. mov word ptr DevXMSAddr, bx ; get XMS driver address
  3217. mov word ptr DevXMSAddr+2, es
  3218. cmp FirstUMBLinked, 0 ; have we already linked a UMB?
  3219. jne @f ; quit if we already did it
  3220. call LinkFirstUMB ; else link the first UMB
  3221. jc iau_err
  3222. mov FirstUMBLinked, 0ffh ; mark that 1st UMB linked
  3223. @@:
  3224. clc
  3225. ret
  3226. iau_err:
  3227. stc
  3228. ret
  3229. InitAllocUMB endp
  3230. ;-------------------------------------------------------------------------
  3231. ;
  3232. ; Procedure Name : umb_allocate
  3233. ;
  3234. ; Inputs : DS = data
  3235. ;
  3236. ; Outputs : if UMB available
  3237. ; Allocates the largest available UMB and
  3238. ; BX = segment of allocated block
  3239. ; DX = size of allocated block
  3240. ; NC
  3241. ; else
  3242. ; CY
  3243. ;
  3244. ; Uses : BX, DX
  3245. ;
  3246. ;-------------------------------------------------------------------------
  3247. umb_allocate proc near
  3248. push ax
  3249. mov ah, XMM_REQUEST_UMB
  3250. mov dx, 0ffffh ; try to allocate largest
  3251. ; possible
  3252. call dword ptr DevXMSAddr
  3253. ; dx now contains the size of
  3254. ; the largest UMB
  3255. or dx, dx
  3256. jz ua_err
  3257. mov ah, XMM_REQUEST_UMB
  3258. call dword ptr DevXMSAddr
  3259. cmp ax, 1 ; Q: was the reqst successful
  3260. jne ua_err ; N: error
  3261. clc
  3262. ua_done:
  3263. pop ax
  3264. ret
  3265. ua_err:
  3266. stc
  3267. jmp short ua_done
  3268. umb_allocate endp
  3269. ;---------------------------------------------------------------------------
  3270. ;
  3271. ; Procedure Name : umb_insert
  3272. ;
  3273. ; Inputs : DOSDATA:UMB_HEAD = start of umb chain
  3274. ; : BX = seg address of UMB to be linked in
  3275. ; : DX = size of UMB to be linked in paras
  3276. ; ; DS = data
  3277. ;
  3278. ; Outputs : links the UMB into the arena chain
  3279. ;
  3280. ; Uses : AX, CX, ES, DX, BX
  3281. ;
  3282. ;---------------------------------------------------------------------------
  3283. umb_insert proc near
  3284. push ds
  3285. mov ds, [DevDOSData]
  3286. mov ds, ds:[UMB_ARENA] ; es = UMB_HEAD
  3287. mov ax, ds
  3288. mov es, ax
  3289. ui_next:
  3290. cmp ax, bx ; Q: is current block above
  3291. ; new block
  3292. ja ui_insert ; Y: insert it
  3293. ; Q: is current block the
  3294. ; last
  3295. cmp es:[arena_signature], arena_signature_end
  3296. jz ui_append ; Y: append new block to chain
  3297. ; N: get next block
  3298. mov ds, ax ; M005
  3299. call get_next ; ax = es = next block
  3300. jmp short ui_next
  3301. ui_insert:
  3302. mov cx, ds ; ds = previous arena
  3303. inc cx ; top of previous block
  3304. sub cx, bx
  3305. neg cx ; cx = size of used block
  3306. mov ds:[arena_signature], arena_signature_normal
  3307. mov ds:[arena_owner], 8 ; mark as system owned
  3308. mov ds:[arena_size], cx
  3309. mov word ptr ds:[arena_name], 'CS'
  3310. ; prepare the arena at start of new block
  3311. mov es, bx
  3312. mov es:[arena_signature], arena_signature_normal
  3313. mov es:[arena_owner], arena_owner_system
  3314. ; mark as free
  3315. sub dx, 2 ; make room for arena at
  3316. ; start & end of new block
  3317. mov es:[arena_size], dx
  3318. ; prepare arena at end of new block
  3319. add bx, dx
  3320. inc bx
  3321. mov es, bx ; es=arena at top of new block
  3322. inc bx ; bx=top of new block
  3323. ; ax contains arena just above
  3324. ; this block
  3325. sub ax, bx ; ax = size of used block
  3326. mov es:[arena_signature], arena_signature_normal
  3327. mov es:[arena_owner], 8 ; mark as system owned
  3328. mov es:[arena_size], ax
  3329. mov word ptr es:[arena_name], 'CS'
  3330. jmp short ui_done
  3331. ui_append:
  3332. ; es = arena of last block
  3333. add ax, es:[arena_size] ; ax=top of last block-1 para
  3334. sub es:[arena_size], 1 ; reflect the space we are
  3335. ; going to rsrv on top of this
  3336. ; block for the next arena.
  3337. mov es:[arena_signature], arena_signature_normal
  3338. mov cx, ax ; cx=top of prev block-1
  3339. inc ax
  3340. sub ax, bx ; ax=top of prev block -
  3341. ; seg. address of new block
  3342. neg ax
  3343. mov es, cx ; ds = arena of unused block
  3344. mov es:[arena_signature], arena_signature_normal
  3345. mov es:[arena_owner], 8 ; mark as system owned
  3346. mov es:[arena_size], ax
  3347. mov word ptr es:[arena_name], 'CS'
  3348. ; prepare the arena at start of new block
  3349. mov es, bx
  3350. mov es:[arena_signature], arena_signature_end
  3351. mov es:[arena_owner], arena_owner_system
  3352. ; mark as free
  3353. dec dx ; make room for arena
  3354. mov es:[arena_size], dx
  3355. ui_done:
  3356. pop ds
  3357. ret
  3358. umb_insert endp
  3359. ;
  3360. ;----------------------------------------------------------------------------
  3361. ;
  3362. ;** umb_coalesce - Combine free blocks ahead with current block
  3363. ;
  3364. ; Coalesce adds the block following the argument to the argument block,
  3365. ; iff it's free. Coalesce is usually used to join free blocks, but
  3366. ; some callers (such as $setblock) use it to join a free block to it's
  3367. ; preceeding allocated block.
  3368. ;
  3369. ; EXIT 'C' clear if OK
  3370. ; (ds) unchanged, this block updated
  3371. ; (ax) = address of next block, IFF not at end
  3372. ; 'C' set if arena trashed
  3373. ; USES cx, di, ds, es
  3374. ;
  3375. ;----------------------------------------------------------------------------
  3376. ;
  3377. umb_coalesce proc near
  3378. xor di, di
  3379. mov es, [DevDOSData]
  3380. mov es, es:[UMB_ARENA] ; es = UMB_HEAD
  3381. uc_nextfree:
  3382. mov ax, es
  3383. mov ds, ax
  3384. cmp es:[arena_owner], di ; Q: is current arena free
  3385. jz uc_again ; Y: try to coalesce with next block
  3386. ; N: get next arena
  3387. call get_next ; es, ax = next arena
  3388. jc uc_done
  3389. jmp short uc_nextfree
  3390. uc_again:
  3391. call get_next ; ES, AX <- next block
  3392. jc uc_done
  3393. uc_check:
  3394. cmp es:[arena_owner],di ; Q: is arena free
  3395. jnz uc_nextfree ; N: get next free arena
  3396. ; Y: coalesce
  3397. mov cx,es:[arena_size] ; cx <- next block size
  3398. inc cx ; cx <- cx + 1 (for header size)
  3399. add ds:[arena_size],cx ; current size <- current size + cx
  3400. mov cl,es:[di] ; move up signature
  3401. mov ds:[di],cl
  3402. jmp short uc_again ; try again
  3403. uc_done:
  3404. ret
  3405. umb_coalesce endp
  3406. ;
  3407. ;----------------------------------------------------------------------------
  3408. ;
  3409. ;** get_next - Find Next item in Arena
  3410. ;
  3411. ; ENTRY dS - pointer to block head
  3412. ; EXIT AX,ES - pointers to next head
  3413. ; 'C' set iff arena damaged
  3414. ;
  3415. ;----------------------------------------------------------------------------
  3416. ;
  3417. get_next proc near
  3418. cmp byte ptr ds:[0], arena_signature_end
  3419. je gn_err
  3420. mov ax,ds ; ax=current block
  3421. add ax,ds:[arena_size] ; ax=ax + current block length
  3422. inc ax ; remember that header!
  3423. mov es, ax
  3424. clc
  3425. ret
  3426. gn_err:
  3427. stc
  3428. ret
  3429. get_next endp
  3430. ;
  3431. ;----------------------------------------------------------------------------
  3432. ;
  3433. ; procedure : LinkFirstUMB
  3434. ;
  3435. ;----------------------------------------------------------------------------
  3436. ;
  3437. LinkFirstUMB proc near
  3438. call umb_allocate
  3439. ifndef NEC_98
  3440. jc lfu_err
  3441. else ;NEC_98
  3442. jnc lfu_next
  3443. jmp lfu_err
  3444. lfu_next:
  3445. endif ;NEC_98
  3446. ; bx = segment of allocated UMB
  3447. ; dx = size of UMB
  3448. ifndef NEC_98
  3449. int 12h ; ax = size of memory
  3450. else ;NEC_98
  3451. xor cx,cx
  3452. mov es,cx
  3453. mov al,byte ptr es:[501h] ; BIOS_FLG
  3454. and ax,07h ; main memory size
  3455. inc ax
  3456. mov cl,7
  3457. shl ax,cl ; ax= size of memory
  3458. test byte ptr es:[501h],08h ; hireso?
  3459. jz got_mm ; no
  3460. cmp ax,768
  3461. jb got_mm
  3462. sub ax,64
  3463. got_mm:
  3464. endif ;NEC_98
  3465. mov cl, 6
  3466. shl ax, cl ; ax = size in paragraphs
  3467. mov cx, ax ; cx = size in paras
  3468. sub ax, bx ; ax = - size of unused block
  3469. neg ax
  3470. sub cx, 1 ; cx = first umb_arena
  3471. mov es, cx ; es = first umb_arena
  3472. mov es:[arena_signature], arena_signature_normal
  3473. mov es:[arena_owner], 8 ; mark as system owned
  3474. mov es:[arena_size], ax
  3475. mov word ptr es:[arena_name], 'CS'
  3476. ; put in the arena for the first UMB
  3477. mov es, bx ; es has first free umb seg
  3478. mov es:[arena_signature], arena_signature_end
  3479. mov es:[arena_owner], arena_owner_system
  3480. ; mark as free
  3481. dec dx ; make room for arena
  3482. mov es:[arena_size], dx
  3483. mov es, [DevDOSData]
  3484. mov di, UMB_ARENA
  3485. mov es:[di], cx ; initialize umb_head in DOS
  3486. ; data segment with the arena
  3487. ; just below Top of Mem
  3488. ; we must now scan the arena chain and update the size of the last
  3489. ; arena
  3490. mov di, DOS_ARENA
  3491. mov es, word ptr es:[di] ; es = start arena
  3492. xor di, di
  3493. scan_next:
  3494. cmp byte ptr es:[di], arena_signature_end
  3495. jz got_last
  3496. mov ax, es
  3497. add ax, es:[arena_size]
  3498. inc ax
  3499. mov es, ax
  3500. jmp short scan_next
  3501. got_last:
  3502. ;; -williamh- we reserved the last paragraph for UMB_HEAD already.
  3503. ;; refer to sysinit1.asm!goinit
  3504. ;; The following instruction was commentted out for this reason.
  3505. ;; sub es:[arena_size], 1
  3506. ;;
  3507. ifdef NEC_98
  3508. sub es:[arena_size], 1
  3509. endif ;NEC_98
  3510. mov es:[arena_signature], arena_signature_normal
  3511. clc
  3512. ret
  3513. lfu_err:
  3514. stc
  3515. ret
  3516. LinkFirstUMB endp
  3517. ;
  3518. ;----------------------------------------------------------------------------
  3519. ;
  3520. ; procedure : ShrinkUMB
  3521. ;
  3522. ; Shrinks the current UMB in use, so that the unused portions
  3523. ; of the UMB is given back to the DOS free mem pool
  3524. ;
  3525. ;----------------------------------------------------------------------------
  3526. ;
  3527. public ShrinkUMB
  3528. ShrinkUMB proc near
  3529. cmp DevUMBAddr, 0
  3530. je su_exit
  3531. push es
  3532. push bx
  3533. mov bx, DevUMBFree
  3534. sub bx, DevUMBAddr
  3535. mov es, DevUMBAddr
  3536. mov ax, 4a00h
  3537. int 21h
  3538. mov ax, es
  3539. dec ax
  3540. mov es, ax
  3541. mov word ptr es:[arena_owner], 8
  3542. pop bx
  3543. pop es
  3544. su_exit:
  3545. ret
  3546. ShrinkUMB endp
  3547. ;M002 - BEGIN
  3548. ;
  3549. ;----------------------------------------------------------------------------
  3550. ;
  3551. ; procedure : UnlinkUMB
  3552. ;
  3553. ; Unlinks the UMBs from the DOS arena chain
  3554. ;
  3555. ;----------------------------------------------------------------------------
  3556. ;
  3557. public UnlinkUMB
  3558. UnlinkUMB proc near
  3559. push ds
  3560. push es
  3561. cmp FirstUMBLinked, 0
  3562. je ulu_x ; nothing to unlink
  3563. mov es, DevDOSData ; get DOS data seg
  3564. mov ds, es:[DOS_ARENA]
  3565. mov di, es:[UMB_ARENA]
  3566. ulu_next:
  3567. call get_next
  3568. jc ulu_x
  3569. cmp di, ax ; is the next one UMB ?
  3570. je ulu_found
  3571. mov ds, ax
  3572. jmp ulu_next
  3573. ulu_found:
  3574. mov ds:[arena_signature], 'Z'
  3575. ulu_x:
  3576. pop es
  3577. pop ds
  3578. ret
  3579. UnlinkUMB endp
  3580. ;M002 - END
  3581. ; =========================================================================
  3582. ;
  3583. ifdef JAPAN
  3584. public IsDBCSCodePage
  3585. IsDBCSCodePage proc near
  3586. push ax
  3587. push bx
  3588. mov ax,4f01h ; get code page
  3589. xor bx,bx
  3590. int 2fh
  3591. cmp bx,932
  3592. pop bx
  3593. pop ax
  3594. ret
  3595. IsDBCSCodePage endp
  3596. endif
  3597. sysinitseg ends
  3598. end
  3599.