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

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