home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / caway349.zip / SOURCE / ALL / CW.INC < prev    next >
Text File  |  1995-03-04  |  31KB  |  1,257 lines

  1. ;-------------------------------------------------------------------------------
  2. ;
  3. ;Call a CauseWay system function. Operand supplied is the function number. Use
  4. ;of this macro is not obligatory, use your own version if you want. These are
  5. ;the low level functions. Other API emulations come later.
  6. ;
  7. Sys    macro p1
  8.     mov    ax,p1
  9.     int    31h
  10.     endm
  11.  
  12.  
  13. ;-------------------------------------------------------------------------------
  14. ;
  15. ;Get system selectors/flags.
  16. ;
  17. ;On Exit:
  18. ;
  19. ;AX    - Selector for real mode segment address of 00000h, 4G limit.
  20. ;BX    - Selector for current PSP segment. 100h limit.
  21. ;[E]CX    - Dos transfer buffer size. Always <64k.
  22. ;DX    - Dos transfer buffer real mode segment address.
  23. ;ES:[E]SI    - Dos transfer buffer protected mode address. ESI+ECX ALWAYS <64k.
  24. ;EDI    - System flags. Bits significant if set.
  25. ;
  26. ;    0 - 32 bit code default.
  27. ;
  28. ;    1 - Virtual memory manager functional.
  29. ;
  30. ;    2 \ Mode, 0 - raw, 1 - VCPI, 2 - DPMI.
  31. ;    3 /
  32. ;
  33. ;    4 - DPMI available.
  34. ;    5 - VCPI available.
  35. ;    6 - No memory managers.
  36. ;
  37. ;    7 - Descriptor table type. 0 - GDT, 1 - LDT.
  38. ;
  39. ;NOTES:
  40. ;
  41. ;Bits 1-2 of DI indicate the interface type being used by CauseWay. Bits 4-5
  42. ;indicate the interface types that are available.
  43. ;
  44. ;Bit 7 indicates the descriptor table being used to allocate selectors to the
  45. ;application when on a raw/vcpi system.
  46. ;
  47. ;The Dos transfer buffer is the area CauseWay uses to transfer data between
  48. ;conventional and extended memory during DOS interupts. This memory can be used
  49. ;as temporary work space for your own access to real mode code as long as you
  50. ;remember it may be over written the next time you issue an INT in protected
  51. ;mode that requires segment&|offset pointers.
  52. ;
  53. Info    equ    0ff00h        ;Get general purpose segment selectors.
  54.  
  55.  
  56. ;-------------------------------------------------------------------------------
  57. ;
  58. ;Simulate real mode interupt.
  59. ;
  60. ;On Entry:
  61. ;
  62. ;BL    - Interupt number.
  63. ;ES:[E]DI    - Parameter block.
  64. ;
  65. ;On Exit:
  66. ;
  67. ;Parameter block updated.
  68. ;
  69. ;NOTES:
  70. ;
  71. ;The parameter block referanced by ES:[E]DI should contain the register values
  72. ;you want passing to the real mode interupt handler. The SS:SP & Flags entries
  73. ;are currently filled in by CauseWay to ensure legal values are used and the
  74. ;CS:IP entries are ignored. This function bypasses protected mode interupt
  75. ;handlers and provides access to INT API's that would not otherwise be available
  76. ;using CauseWay.
  77. ;
  78. IntXX    equ    0ff01h
  79.  
  80.  
  81. ;-------------------------------------------------------------------------------
  82. ;
  83. ;Simulate real mode far call.
  84. ;
  85. ;On Entry:
  86. ;
  87. ;ES:[E]DI    - Parameter block.
  88. ;
  89. ;On Exit:
  90. ;
  91. ;Parameter block updated.
  92. ;
  93. ;NOTES:
  94. ;
  95. ;This function works much the same as IntXX but provides a 16 bit FAR stack
  96. ;frame and the CS:IP values used to pass control to the real mode code.
  97. ;
  98. FarCallReal    equ    0ff02h
  99.  
  100.  
  101. ;-------------------------------------------------------------------------------
  102. ;
  103. ;Allocate real mode call back address.
  104. ;
  105. ;On Entry:
  106. ;
  107. ;DS:[E]SI    - Call address.
  108. ;ES:[E]DI    - Real mode register structure.
  109. ;
  110. ;On Exit:
  111. ;
  112. ;Carry set on error, else,
  113. ;
  114. ;CX:DX    - Real mode address to trigger mode switch.
  115. ;
  116. ;NOTES:
  117. ;
  118. ;Real mode CallBack's provide a means of switching from real mode to protected
  119. ;mode. The address returned by this function is a unique real mode address that
  120. ;when given control in real mode will switch to protected mode and pass control
  121. ;to the protected mode routine supplied at entry to this function.
  122. ;
  123. GetCallBack    equ    0303h
  124.  
  125.  
  126. ;-------------------------------------------------------------------------------
  127. ;
  128. ;Release a real mode call back entry.
  129. ;
  130. ;On Entry:
  131. ;
  132. ;CX:DX    - Real mode address returned by GetCallBack
  133. ;
  134. RelCallBack    equ    0304h
  135.  
  136.  
  137. ;-------------------------------------------------------------------------------
  138. ;
  139. ;Get Protected mode interupt handler address.
  140. ;
  141. ;On Entry:
  142. ;
  143. ;BL    - Interupt vector number.
  144. ;
  145. ;On Exit:
  146. ;
  147. ;CF set on error else:-
  148. ;
  149. ;CX:[E]DX    - selector:offset of handler.
  150. ;
  151. GetVect    equ    0204h
  152.  
  153.  
  154. ;-------------------------------------------------------------------------------
  155. ;
  156. ;Set Protected mode interupt handler address.
  157. ;
  158. ;On Entry:
  159. ;
  160. ;BL    - Interupt vector number.
  161. ;CX:[E]DX    - selector:offset of new handler.
  162. ;
  163. ;On Exit:
  164. ;
  165. ;CF set on error.
  166. ;
  167. SetVect    equ    0205h
  168.  
  169.  
  170. ;-------------------------------------------------------------------------------
  171. ;
  172. ;Get real mode interupt handler address.
  173. ;
  174. ;On Entry:
  175. ;
  176. ;BL    - Interupt vector number.
  177. ;
  178. ;On Exit:
  179. ;
  180. ;CF set on error else:-
  181. ;
  182. ;CX:DX    - selector:offset of handler.
  183. ;
  184. GetRVect    equ    0200h
  185.  
  186.  
  187. ;-------------------------------------------------------------------------------
  188. ;
  189. ;Set real mode interupt handler address.
  190. ;
  191. ;On Entry:
  192. ;
  193. ;BL    - Interupt vector number.
  194. ;CX:DX    - selector:offset of new handler.
  195. ;
  196. ;On Exit:
  197. ;
  198. ;CF set on error.
  199. ;
  200. SetRVect    equ    0201h
  201.  
  202.  
  203. ;-------------------------------------------------------------------------------
  204. ;
  205. ;Get Protected mode exception handler address.
  206. ;
  207. ;On Entry:
  208. ;
  209. ;BL    - Exception vector number.
  210. ;
  211. ;On Exit:
  212. ;
  213. ;CF set on error else:-
  214. ;
  215. ;CX:[E]DX    - selector:offset of handler.
  216. ;
  217. GetEVect    equ    0202h
  218.  
  219.  
  220. ;-------------------------------------------------------------------------------
  221. ;
  222. ;Set Protected mode exception handler address.
  223. ;
  224. ;On Entry:
  225. ;
  226. ;BL    - Exception vector number.
  227. ;CX:[E]DX    - selector:offset of new handler.
  228. ;
  229. ;On Exit:
  230. ;
  231. ;CF set on error.
  232. ;
  233. SetEVect    equ    0203h
  234.  
  235.  
  236. ;-------------------------------------------------------------------------------
  237. ;
  238. ;Allocate a new selector.
  239. ;
  240. ;On Exit:
  241. ;
  242. ;BX    - Selector.
  243. ;
  244. ;NOTES:
  245. ;
  246. ;A selector is allocated and initialised with a base of 0, a limit of 0 and as
  247. ;read/write expand up data. Use SetSelDet to make the selector useful.
  248. ;
  249. GetSel    equ    0ff03h
  250.  
  251.  
  252. ;-------------------------------------------------------------------------------
  253. ;
  254. ;Allocate multiple selectors.
  255. ;
  256. ;On Entry:
  257. ;
  258. ;CX    - Number of selectors.
  259. ;
  260. ;On Exit:
  261. ;
  262. ;BX    - Base selector.
  263. ;
  264. ;NOTES:
  265. ;
  266. ;The selectors are allocated and initialised with a base of 0, a limit of 0 and
  267. ;as read/write expand up data. Use SetSelDet to make the selectors useful.
  268. ;
  269. GetSels    equ    0ff29h
  270.  
  271.  
  272. ;-------------------------------------------------------------------------------
  273. ;
  274. ;Release a selector.
  275. ;
  276. ;On Entry:
  277. ;
  278. ;BX    - Selector.
  279. ;
  280. RelSel    equ    0ff04h
  281.  
  282.  
  283. ;-------------------------------------------------------------------------------
  284. ;
  285. ;Make a selector execute/read type.
  286. ;
  287. ;On Entry:
  288. ;
  289. ;BX    - Selector.
  290. ;CL    - Default operation size. (0=16 bit,1=32 bit)
  291. ;
  292. ;NOTES:
  293. ;
  294. ;Allows a selector to be converted to a type suitable for execution.
  295. ;
  296. CodeSel    equ    0ff05h
  297.  
  298.  
  299. ;-------------------------------------------------------------------------------
  300. ;
  301. ;Create a read/write data selector with same base and limit as selector
  302. ;supplied.
  303. ;
  304. ;On Entry:
  305. ;
  306. ;BX    - Source selector
  307. ;
  308. ;On Exit:
  309. ;
  310. ;If function was successful:
  311. ;Carry flag is clear.
  312. ;AX    - New data selector
  313. ;
  314. ;If function was not successful:
  315. ;Carry flag is set.
  316. ;
  317. ;NOTES:
  318. ;
  319. ;This function always creates a read/write data selector regardless of the
  320. ;source selectors type. Can be used to provide access to variables in a code
  321. ;segment etc.
  322. ;
  323. AliasSel    equ    0ff06h
  324.  
  325.  
  326. ;-------------------------------------------------------------------------------
  327. ;
  328. ;Get selector linear base and limit.
  329. ;
  330. ;On Entry:
  331. ;
  332. ;BX    - Selector
  333. ;
  334. ;On Exit:
  335. ;
  336. ;CX:DX    - Linear base.
  337. ;SI:DI    - Byte granular limit.
  338. ;
  339. GetSelDet    equ    0ff07h
  340.  
  341.  
  342. ;-------------------------------------------------------------------------------
  343. ;
  344. ;Get selector linear base and limit.
  345. ;
  346. ;On Entry:
  347. ;
  348. ;BX    - Selector
  349. ;
  350. ;On Exit:
  351. ;
  352. ;EDX    - Linear base.
  353. ;ECX    - Byte granular limit.
  354. ;
  355. GetSelDet32    equ    0ff08h
  356.  
  357.  
  358. ;-------------------------------------------------------------------------------
  359. ;
  360. ;Set selector linear base and limit.
  361. ;
  362. ;On Entry:
  363. ;
  364. ;BX    - Selector.
  365. ;CX:DX    - Linear base.
  366. ;SI:DI    - Byte granular limit.
  367. ;
  368. SetSelDet    equ    0ff09h
  369.  
  370.  
  371. ;-------------------------------------------------------------------------------
  372. ;
  373. ;Set selector linear base and limit.
  374. ;
  375. ;On Entry:
  376. ;
  377. ;BX    - Selector.
  378. ;EDX    - Linear base.
  379. ;ECX    - Byte granular limit.
  380. ;
  381. SetSelDet32    equ    0ff0ah
  382.  
  383.  
  384. ;-------------------------------------------------------------------------------
  385. ;
  386. ;Allocate a block of memory.
  387. ;
  388. ;On Entry:
  389. ;
  390. ;CX:DX    - Size of block required in bytes. (-1:-1 to get maximum memory size)
  391. ;
  392. ;On Exit:
  393. ;
  394. ;Carry clear if OK &
  395. ;
  396. ;BX    - Selector to access the block with.
  397. ;
  398. ;Else if CX:DX was -1, CX:DX is size of largest block available.
  399. ;
  400. ;NOTES:
  401. ;
  402. ;This function allocates a block of extended (application) memory, and also a
  403. ;selector with a suitable base & limit.
  404. ;
  405. GetMem    equ    0ff0bh
  406.  
  407.  
  408. ;-------------------------------------------------------------------------------
  409. ;
  410. ;Allocate some memory and return selector:offset (16-bit).
  411. ;
  412. ;On Entry:
  413. ;
  414. ;CX:DX    - Size of block required in bytes.
  415. ;
  416. ;On Exit:
  417. ;
  418. ;Carry set on error else,
  419. ;
  420. ;SI:DI    - selector:offset of allocated memory.
  421. ;
  422. GetMemSO    equ    0ff2ch
  423.  
  424.  
  425. ;-------------------------------------------------------------------------------
  426. ;
  427. ;Allocate a block of memory.
  428. ;
  429. ;On Entry:
  430. ;
  431. ;ECX    - Size of block required in bytes. (-1 to get maximum memory size)
  432. ;
  433. ;On Exit:
  434. ;
  435. ;Carry clear if OK &
  436. ;
  437. ;BX    - Selector to access the block with.
  438. ;
  439. ;Else if ECX was -1, ECX is size of largest block available.
  440. ;
  441. ;NOTES:
  442. ;
  443. ;This function allocates a block of extended (application) memory, and also a
  444. ;selector with a suitable base & limit.
  445. ;
  446. GetMem32    equ    0ff0ch
  447.  
  448.  
  449. ;-------------------------------------------------------------------------------
  450. ;
  451. ;Re-size a previously allocated block of memory.
  452. ;
  453. ;On Entry:
  454. ;
  455. ;BX    - Selector for block.
  456. ;CX:DX    - New size of block required in bytes.
  457. ;
  458. ;On Exit:
  459. ;
  460. ;Carry clear if OK.
  461. ;
  462. ;NOTES:
  463. ;
  464. ;If the memory block can't be re-sized in its current location, but a free block
  465. ;of memory of the new size exists, the memory will be copied to a new block and
  466. ;the old one released. This is transparent to the application as long as only
  467. ;the selector origionaly allocated with GetMem is being used to access the
  468. ;memory.
  469. ;
  470. ResMem    equ    0ff0dh
  471.  
  472.  
  473. ;-------------------------------------------------------------------------------
  474. ;
  475. ;Re-size a block of memory allocated via GetMemSO.
  476. ;
  477. ;On Entry:
  478. ;
  479. ;SI:DI    - Selector:offset for block.
  480. ;CX:DX    - New size of block required in bytes.
  481. ;
  482. ;On Exit:
  483. ;
  484. ;Carry set on error else,
  485. ;
  486. ;SI:DI    - selector:offset new block address.
  487. ;
  488. ResMemSO    equ    0ff2dh
  489.  
  490.  
  491. ;-------------------------------------------------------------------------------
  492. ;
  493. ;Re-size a previously allocated block of memory.
  494. ;
  495. ;On Entry:
  496. ;
  497. ;BX    - Selector for block.
  498. ;ECX    - New size of block required in bytes.
  499. ;
  500. ;On Exit:
  501. ;
  502. ;Carry clear if OK.
  503. ;
  504. ;NOTES:
  505. ;
  506. ;If the memory block can't be re-sized in its current location, but a free block
  507. ;of memory of the new size exists, the memory will be copied to a new block and
  508. ;the old one released. This is transparent to the application as long as only
  509. ;the selector origionaly allocated with GetMem is being used to access the
  510. ;memory.
  511. ;
  512. ResMem32    equ    0ff0eh
  513.  
  514.  
  515. ;-------------------------------------------------------------------------------
  516. ;
  517. ;Release previously allocated block of memory. Is be used for memory allocated
  518. ;by either GetMem or GetMem32.
  519. ;
  520. ;
  521. ;On Entry:
  522. ;
  523. ;BX    - Selector for block to release.
  524. ;
  525. RelMem    equ    0ff0fh
  526.  
  527.  
  528. ;-------------------------------------------------------------------------------
  529. ;
  530. ;Release block of memory allocated via GetMemSO.
  531. ;
  532. ;On Entry:
  533. ;
  534. ;SI:DI    - Selector:offset for block to release.
  535. ;
  536. RelMemSO    equ    0ff2eh
  537.  
  538.  
  539. ;-------------------------------------------------------------------------------
  540. ;
  541. ;Allocate a block of memory without a selector.
  542. ;
  543. ;On Entry:
  544. ;
  545. ;CX:DX    - Size of block required in bytes.
  546. ;
  547. ;On Exit:
  548. ;
  549. ;Carry clear if OK &,
  550. ;
  551. ;SI:DI    - Linear address of block allocated.
  552. ;
  553. ;NOTES:
  554. ;
  555. ;Addresses returned by this function may be >16M
  556. ;
  557. GetMemLinear    equ    0ff10h
  558.  
  559.  
  560. ;-------------------------------------------------------------------------------
  561. ;
  562. ;Allocate a block of memory without a selector.
  563. ;
  564. ;On Entry:
  565. ;
  566. ;ECX    - Size of block required in bytes.
  567. ;
  568. ;On Exit:
  569. ;
  570. ;Carry clear if OK &,
  571. ;
  572. ;ESI    - Linear address of block allocated.
  573. ;
  574. ;NOTES:
  575. ;
  576. ;Addresses returned by this function may be >16M
  577. ;
  578. GetMemLinear32 equ    0ff11h
  579.  
  580.  
  581. ;-------------------------------------------------------------------------------
  582. ;
  583. ;Re-size a previously allocated block of memory without a selector.
  584. ;
  585. ;On Entry:
  586. ;
  587. ;SI:DI    - Linear address of block to re-size.
  588. ;CX:DX    - Size of block required in bytes.
  589. ;
  590. ;On Exit:
  591. ;
  592. ;Carry clear if OK &,
  593. ;
  594. ;SI:DI    - New linear address of block.
  595. ;
  596. ;NOTES:
  597. ;
  598. ;If the memory block cannot be expanded to the desired size, and a free block
  599. ;of sufficient size exists, the existing memory will be copied to the free
  600. ;block and released, the new block then being alocated in place of the old.
  601. ;
  602. ResMemLinear    equ    0ff12h
  603.  
  604.  
  605. ;-------------------------------------------------------------------------------
  606. ;
  607. ;Re-size a previously allocated block of memory without a selector.
  608. ;
  609. ;On Entry:
  610. ;
  611. ;ESI    - Linear address of block to re-size.
  612. ;ECX    - Size of block required in bytes.
  613. ;
  614. ;On Exit:
  615. ;
  616. ;Carry clear if OK &,
  617. ;
  618. ;ESI    - New linear address of block.
  619. ;
  620. ;NOTES:
  621. ;
  622. ;If the memory block cannot be expanded to the desired size, and a free block
  623. ;of sufficient size exists, the existing memory will be copied to the free
  624. ;block and released, the new block then being alocated in place of the old.
  625. ;
  626. ResMemLinear32 equ    0ff13h
  627.  
  628.  
  629. ;-------------------------------------------------------------------------------
  630. ;
  631. ;Release previously allocated block of memory (linear address).
  632. ;
  633. ;On Entry:
  634. ;
  635. ;SI:DI    - Linear address of block to release.
  636. ;
  637. ;On Exit:
  638. ;
  639. RelMemLinear    equ    0ff14h
  640.  
  641.  
  642. ;-------------------------------------------------------------------------------
  643. ;
  644. ;Release previously allocated block of memory (linear address).
  645. ;
  646. ;On Entry:
  647. ;
  648. ;ESI    - Linear address of block to release.
  649. ;
  650. ;On Exit:
  651. ;
  652. RelMemLinear32 equ    0ff15h
  653.  
  654.  
  655. ;-------------------------------------------------------------------------------
  656. ;
  657. ;Allocate an application relative block of memory.
  658. ;
  659. ;On Entry:
  660. ;
  661. ;EBX    - Size of block required in bytes.
  662. ;
  663. ;On Exit:
  664. ;
  665. ;Carry clear if OK &,
  666. ;
  667. ;ESI    - Application relative linear address of block allocated.
  668. ;
  669. ;NOTES:
  670. ;
  671. ;Addresses returned by this function are as an offset from the application.
  672. ;
  673. GetMemNear    equ    0ff16h
  674.  
  675.  
  676. ;-------------------------------------------------------------------------------
  677. ;
  678. ;Re-size a previously allocated application relative block of memory.
  679. ;
  680. ;On Entry:
  681. ;
  682. ;EBX    - Size of block required in bytes.
  683. ;ESI    - application relative linear address of block to re-size.
  684. ;
  685. ;On Exit:
  686. ;
  687. ;Carry clear if OK &,
  688. ;
  689. ;ESI    - New application relative linear address of block.
  690. ;
  691. ;NOTES:
  692. ;
  693. ;If the memory block cannot be expanded to the desired size, and a free block
  694. ;of sufficient size exists, the existing memory will be copied to the free
  695. ;block and released, the new block then being allocated in place of the old.
  696. ;
  697. ResMemNear    equ    0ff17h
  698.  
  699.  
  700. ;-------------------------------------------------------------------------------
  701. ;
  702. ;Release previously allocated application relative block of memory.
  703. ;
  704. ;On Entry:
  705. ;
  706. ;ESI    - Application relative linear address of block to release.
  707. ;
  708. ;On Exit:
  709. ;
  710. RelMemNear    equ    0ff18h
  711.  
  712.  
  713. ;-------------------------------------------------------------------------------
  714. ;
  715. ;Convert linear address to application relative address.
  716. ;
  717. ;On Entry:
  718. ;
  719. ;ESI    - Linear address to convert.
  720. ;
  721. ;On Exit:
  722. ;
  723. ;ESI    - Application relative linear address.
  724. ;
  725. Linear2Near    equ    0ff19h
  726.  
  727.  
  728. ;-------------------------------------------------------------------------------
  729. ;
  730. ;Convert application relative address to linear address.
  731. ;
  732. ;On Entry:
  733. ;
  734. ;ESI    - Application relative linear address.
  735. ;
  736. ;On Exit:
  737. ;
  738. ;ESI    - Linear address to convert.
  739. ;
  740. Near2Linear    equ    0ff1ah
  741.  
  742.  
  743. ;-------------------------------------------------------------------------------
  744. ;
  745. ;Lock a region of memory.
  746. ;
  747. ;On Entry:
  748. ;
  749. ;BX:CX    - Starting linear address of memory to lock.
  750. ;SI:DI    - Size of region to lock in bytes.
  751. ;
  752. ;On Exit:
  753. ;
  754. ;Carry set on error, none of the memory locked, else memory is locked.
  755. ;
  756. ;NOTES:
  757. ;
  758. ;Memory that is locked cannot be swapped to disk by the VMM. You should note
  759. ;that locking is applied to memory on 4k boundaries, so areas of memory below
  760. ;and above the memory being locked will also be locked if the specified region
  761. ;is not 4k aligned.
  762. ;
  763. LockMem    equ    0ff1bh
  764.  
  765.  
  766. ;-------------------------------------------------------------------------------
  767. ;
  768. ;Lock a region of memory.
  769. ;
  770. ;On Entry:
  771. ;
  772. ;ESI    - Starting linear address of memory to lock.
  773. ;ECX    - Size of region to lock in bytes.
  774. ;
  775. ;On Exit:
  776. ;
  777. ;Carry set on error, none of the memory locked, else memory is locked.
  778. ;
  779. ;NOTES:
  780. ;
  781. ;Memory that is locked cannot be swapped to disk by the VMM. You should note
  782. ;that locking is applied to memory on 4k boundaries, so areas of memory below
  783. ;and above the memory being locked will also be locked if the specified region
  784. ;is not 4k aligned.
  785. ;
  786. LockMem32    equ    0ff1ch
  787.  
  788.  
  789. ;-------------------------------------------------------------------------------
  790. ;
  791. ;Un-lock a region of memory.
  792. ;
  793. ;On Entry:
  794. ;
  795. ;BX:CX    - Starting linear address of memory to unlock
  796. ;SI:DI    - Size of region to unlock in bytes
  797. ;
  798. ;NOTES:
  799. ;
  800. ;This will allow the memory to be swapped to disk by the VMM if neccessary.
  801. ;Areas below and above the specified memory will also be un-locked if the
  802. ;specified region is not page aligned.
  803. ;
  804. UnLockMem    equ    0ff1dh
  805.  
  806.  
  807. ;-------------------------------------------------------------------------------
  808. ;
  809. ;Un-lock a region of memory.
  810. ;
  811. ;On Entry:
  812. ;
  813. ;ESI    - Starting linear address of memory to unlock
  814. ;ECX    - Size of region to unlock in bytes
  815. ;
  816. ;NOTES:
  817. ;
  818. ;This will allow the memory to be swapped to disk by the VMM if neccessary.
  819. ;Areas below and above the specified memory will also be un-locked if the
  820. ;specified region is not page aligned.
  821. ;
  822. UnLockMem32    equ    0ff1eh
  823.  
  824.  
  825. ;-------------------------------------------------------------------------------
  826. ;
  827. ;Lock a region of memory using application relative address.
  828. ;
  829. ;On Entry:
  830. ;
  831. ;ESI    - Starting linear address of memory to lock.
  832. ;EBX    - Size of region to lock in bytes.
  833. ;
  834. ;On Exit:
  835. ;
  836. ;Carry set on error, none of the memory locked, else memory is locked.
  837. ;
  838. ;NOTES:-
  839. ;
  840. ;Memory that is locked cannot be swapped to disk by the VMM. You should note
  841. ;that locking is applied to memory on 4k boundaries, so areas of memory below
  842. ;and above the memory being locked will also be locked if the specified region
  843. ;is not 4k aligned.
  844. ;
  845. LockMemNear    equ    0ff1fh
  846.  
  847.  
  848. ;-------------------------------------------------------------------------------
  849. ;
  850. ;Un-lock a region of memory using application relative address.
  851. ;
  852. ;On Entry:
  853. ;
  854. ;ESI    - Starting linear address of memory to unlock
  855. ;EBX    - Size of region to unlock in bytes
  856. ;
  857. ;NOTES:
  858. ;
  859. ;This will allow the memory to be swapped to disk by the VMM if neccessary.
  860. ;Areas below and above the specified memory will also be un-locked if the
  861. ;specified region is not page aligned.
  862. ;
  863. UnLockMemNear equ    0ff20h
  864.  
  865.  
  866. ;-------------------------------------------------------------------------------
  867. ;
  868. ;Allocate a region of DOS (conventional) memory.
  869. ;
  870. ;On Entry:
  871. ;
  872. ;BX    - Number of paragraphs (16 byte blocks) required.
  873. ;
  874. ;On Exit:
  875. ;
  876. ;If function was successful:
  877. ;Carry flag is clear.
  878. ;
  879. ;AX    - Initial real mode segment of allocated block
  880. ;DX    - Initial selector for allocated block
  881. ;
  882. ;If function was not successful:
  883. ;Carry flag is set.
  884. ;
  885. ;AX    - DOS error code.
  886. ;BX    - Size of largest available block in paragraphs.
  887. ;
  888. ;NOTES:
  889. ;
  890. ;If the size of the block requested is greater than 64K bytes (BX > 1000h) then
  891. ;contiguous descriptors will be allocated. If more than one descriptor is
  892. ;allocated under 32-bit applications, the limit of the first descriptor will be
  893. ;set to the size of the entire block. All subsequent descriptors will have a
  894. ;limit of 64K except for the final descriptor which will have a limit of Block
  895. ;size MOD 64K. 16-bit applications will always set the limit of the first
  896. ;descriptor to 64K.
  897. ;
  898. GetMemDOS    equ    0ff21h
  899.  
  900.  
  901. ;-------------------------------------------------------------------------------
  902. ;
  903. ;Re-size a block of DOS (conventional) memory previously allocated with
  904. ;GetMemDOS.
  905. ;
  906. ;On Entry:
  907. ;
  908. ;BX    - New block size in paragraphs
  909. ;DX    - Selector of block to modify
  910. ;
  911. ;On Exit:
  912. ;
  913. ;If function was successful:
  914. ;Carry flag is clear.
  915. ;
  916. ;If function was not successful:
  917. ;Carry flag is set.
  918. ;
  919. ;AX    - DOS error code:
  920. ;BX    - Maximum block size possible in paragraphs
  921. ;
  922. ;NOTES:
  923. ;
  924. ;Growing a memory block is often likely to fail since other DOS block
  925. ;allocations will prevent increasing the size of the block. Also, if the size of
  926. ;a block grows past a 64K boundary then the allocation will fail if the next
  927. ;descriptor in the LDT is not free.
  928. ;
  929. ResMemDOS    equ    0ff22h
  930.  
  931.  
  932. ;-------------------------------------------------------------------------------
  933. ;
  934. ;Release a block of DOS (conventional) memory previously allocated with
  935. ;GetMemDOS.
  936. ;
  937. ;On Entry:
  938. ;
  939. ;DX    - Selector of block to free.
  940. ;
  941. ;On Exit:
  942. ;
  943. ;If function was successful:
  944. ;Carry flag is clear.
  945. ;
  946. ;If function was not successful:
  947. ;Carry flag is set.
  948. ;
  949. ;AX    - DOS error code.
  950. ;
  951. ;NOTES:
  952. ;
  953. ;All descriptors allocated for the memory block are automatically freed and
  954. ;therefore should not be accessed once the block is freed by this function.
  955. ;
  956. RelMemDOS    equ    0ff23h
  957.  
  958.  
  959. ;-------------------------------------------------------------------------------
  960. ;
  961. ;Get current address and size of the buffer used for DOS memory transfers.
  962. ;
  963. ;On Exit:
  964. ;
  965. ;BX    - Real mode segment of buffer.
  966. ;DX    - Protected mode selector for buffer.
  967. ;ECX    - Buffer size.
  968. ;
  969. ;Notes:
  970. ;
  971. ;This buffer is used by the built in INT ?? API translation services,
  972. ;eg, INT 21h, AH=40h (write to file). The default buffer is 8k and uses memory
  973. ;that would otherwise be waisted. This default is sufficient for most file I/O
  974. ;but if you are writing a program that reads/writes large amounts of data you
  975. ;should consider allocateing your own larger buffer and pass the address to
  976. ;CauseWay to speed this file I/O.
  977. ;
  978. GetDOSTrans    equ    0ff25h
  979.  
  980.  
  981. ;-------------------------------------------------------------------------------
  982. ;
  983. ;Set new address and size of the buffer used for DOS memory transfers.
  984. ;
  985. ;On Entry:
  986. ;
  987. ;BX    - Real mode segment of buffer.
  988. ;DX    - Protected mode selector for buffer.
  989. ;ECX    - Buffer size.
  990. ;
  991. ;Notes:
  992. ;
  993. ;This buffer is used by the built in INT ?? API translation services,
  994. ;eg, INT 21h, AH=40h (write to file). The default buffer is 8k and uses memory
  995. ;that would otherwise be waisted. This default is sufficient for most file I/O
  996. ;but if you are writing a program that reads/writes large amounts of data you
  997. ;should consider allocateing your own larger buffer and pass the address to
  998. ;CauseWay to speed this file I/O.
  999. ;
  1000. ;The buffer must be in conventional memory and only the first 64k will be used
  1001. ;even if a bigger buffer is specified. CauseWay will automaticaly restore the
  1002. ;previous buffer setting when the application terminates but GetDOSTrans can
  1003. ;be used to get the current buffer's settings if you only want the change to
  1004. ;be temporary.
  1005. ;
  1006. ;You can still use the default buffer for your own puposes even after setting a
  1007. ;new address.
  1008. ;
  1009. SetDOSTrans    equ    0ff26h
  1010.  
  1011.  
  1012. ;-------------------------------------------------------------------------------
  1013. ;
  1014. ;Get current MCB memory allocation block size.
  1015. ;
  1016. ;On Exit:
  1017. ;
  1018. ;ECX    - Current threshold.
  1019. ;
  1020. GetMCBSize    equ    0ff27h
  1021.  
  1022.  
  1023. ;-------------------------------------------------------------------------------
  1024. ;
  1025. ;Set new MCB memory allocation block size.
  1026. ;
  1027. ;On Entry:
  1028. ;
  1029. ;ECX    - New value to set.
  1030. ;
  1031. ;On Exit:
  1032. ;
  1033. ;Carry set on error else new value will be used.
  1034. ;
  1035. ;Notes:
  1036. ;
  1037. ;The maximum block size that will be allocated from MCB memory is 16 bytes less
  1038. ;than the value set by this function. The default value is 16384.
  1039. ;
  1040. ;65536 is the maximum value this function will accept. Passing a value above
  1041. ;this will return with the carry set and the origional value still in force.
  1042. ;
  1043. ;The CauseWay API memory allocation functions allocate memory from two sources.
  1044. ;Allocation requests below the value returned by this function are allocated
  1045. ;from a memory pool controled via conventional style MCB's. Requests above this
  1046. ;value are allocated via the normal DPMI functions. Because DPMI memory is
  1047. ;always allocated in multiples of 4k it can become very inificient for any
  1048. ;program that needs to allocate small blocks of memory. The value set by this
  1049. ;function controls the size of memory chunks that will be allocated to and
  1050. ;managed by the MCB system.
  1051. ;
  1052. ;A value of zero can be passed to this function to disable the MCB allocation
  1053. ;system.
  1054. ;
  1055. ;The value passed will be rounded up to the nearest 4k.
  1056. ;
  1057. SetMCBMax    equ    0ff28h
  1058.  
  1059.  
  1060. ;-------------------------------------------------------------------------------
  1061. ;
  1062. ;Run another CauseWay program directly.
  1063. ;
  1064. ;On Entry:
  1065. ;
  1066. ;DS:EDX    - File name.
  1067. ;ES:ESI    - Command line. First byte is length, then real data.
  1068. ;CX    - Environment selector, 0 to use existing copy.
  1069. ;
  1070. ;On Exit:
  1071. ;
  1072. ;Carry set on error and AX = error code else AL=ErrorLevel
  1073. ;
  1074. ;Error codes:
  1075. ;
  1076. ;1    - DOS file access error.
  1077. ;2    - Not a 3P file.
  1078. ;3    - Not enough memory.
  1079. ;
  1080. ;NOTES:
  1081. ;
  1082. ;Only the first byte of the command line (length) has any significance to
  1083. ;CauseWay so you are not restricted to ASCII values. It is still stored in the
  1084. ;PSP at 80h though so the length is still limited to 127 bytes.
  1085. ;
  1086. cwExec    equ    0ff24h
  1087.  
  1088.  
  1089. ;-------------------------------------------------------------------------------
  1090. ;
  1091. ;Load another CauseWay program as an overlay, ie, do relocations etc but don't
  1092. ;actually execute it.
  1093. ;
  1094. ;On Entry:
  1095. ;
  1096. ;DS:EDX    - File name.
  1097. ;
  1098. ;On Exit:
  1099. ;
  1100. ;Carry set on error and AX = error code else,
  1101. ;
  1102. ;CX:EDX    - Entry CS:EIP
  1103. ;BX:EAX    - Entry SS:ESP
  1104. ;SI    - PSP.
  1105. ;
  1106. ;Error codes:
  1107. ;
  1108. ;1    - DOS file access error.
  1109. ;2    - Not a 3P file.
  1110. ;3    - Not enough memory.
  1111. ;
  1112. ;NOTES:
  1113. ;
  1114. ;The PSP returned in SI can be passed to RelMem to release the loaded programs
  1115. ;memory and selectors. Only the memory and selectors allocated during loading
  1116. ;will be released, it is the programs responsability to release any additional
  1117. ;memory etc allocated while the program is running. Alternatively, if you pass
  1118. ;the PSP value to INT 21h, AH=50h before makeing additional memory requests
  1119. ;and then reset to the origional PSP the memory allocated will be released
  1120. ;when the PSP is released.
  1121. ;
  1122. cwLoad    equ    0ff2ah
  1123.  
  1124.  
  1125. ;-------------------------------------------------------------------------------
  1126. ;
  1127. ;Validate and get expanded length of a CWC'd file.
  1128. ;
  1129. ;On Entry:
  1130. ;
  1131. ;BX    - File handle.
  1132. ;
  1133. ;On Exit:
  1134. ;
  1135. ;Carry set if not a CWC'd file else,
  1136. ;
  1137. ;ECX    - Expanded data size.
  1138. ;
  1139. ;NOTES:
  1140. ;
  1141. ;The file pointer is not altered by this function.
  1142. ;
  1143. cwcInfo    equ    0ff2bh
  1144.  
  1145.  
  1146. ;-------------------------------------------------------------------------------
  1147. ;
  1148. ;Load/Expand a CWC'd data file into memory.
  1149. ;
  1150. ;On Entry:
  1151. ;
  1152. ;BX    - Source file handle.
  1153. ;ES:EDI    - Destination memory.
  1154. ;
  1155. ;On Exit:
  1156. ;
  1157. ;Carry set on error and EAX is error code else,
  1158. ;
  1159. ;ECX    - Expanded data length.
  1160. ;
  1161. ;Error codes:
  1162. ;
  1163. ;    1 = Error during file access.
  1164. ;    2 = Bad data.
  1165. ;    3 = Not a CWC'd file.
  1166. ;
  1167. ;NOTES:
  1168. ;
  1169. ;The source file's file pointer doesn't have to be at zero. A single file might
  1170. ;be several CWC'd files lumped together and as long as the file pointer is moved
  1171. ;to the right place before calling this function.
  1172. ;
  1173. ;If error codes 1 or 2 are reported then the file pointer will be where ever it
  1174. ;was last moved to by this function. For error code 3 the file pointer will be
  1175. ;back at its origional position on entry to this function. If no error occures
  1176. ;then the file pointer will be moved to whatever comes after the compressed
  1177. ;data.
  1178. ;
  1179. cwcLoad    equ    0fffbh
  1180.  
  1181.  
  1182. ;-------------------------------------------------------------------------------
  1183. ;
  1184. ;Structure of parameter table for real mode interupt and procedure calling.
  1185. ;
  1186. ;NOTE:- For interupts, CS:IP,SS:SP & Flags are filled in by the extender.
  1187. ;       For far calls, SS:SP & Flags are filled in by the extender.
  1188. ;
  1189. RealRegsStruc struc
  1190. Real_EDI    dd ?    ;EDI
  1191. Real_ESI    dd ?    ;ESI
  1192. Real_EBP    dd ?    ;EBP
  1193.     dd ?    ;Reserved.
  1194. Real_EBX    dd ?    ;EBX
  1195. Real_EDX    dd ?    ;EDX
  1196. Real_ECX    dd ?    ;ECX
  1197. Real_EAX    dd ?    ;EAX
  1198. Real_Flags    dw ?    ;FLAGS
  1199. Real_ES    dw ?    ;ES
  1200. Real_DS    dw ?    ;DS
  1201. Real_FS    dw ?    ;FS
  1202. Real_GS    dw ?    ;GS
  1203. Real_IP    dw ?    ;IP
  1204. Real_CS    dw ?    ;CS
  1205. Real_SP    dw ?    ;SP
  1206. Real_SS    dw ?    ;SS
  1207. RealRegsStruc ends
  1208.  
  1209.  
  1210. ;-------------------------------------------------------------------------------
  1211. ;
  1212. ;Now the extended PSP structure.
  1213. ;
  1214. EPSP_Struc        struc
  1215.         db 256 dup (?)
  1216.  EPSP_Parent        dw ?        ;Selector of parent/previous PSP, 0 for none.
  1217.  EPSP_Next        dw ?        ;Next PSP.
  1218.  EPSP_Resource    dd ?        ;Linear address of resource tracking table. 0
  1219.                 ;for none.
  1220.  EPSP_mcbHead    dd ?        ;Linear address of MCB memory head. 0 for none.
  1221.  EPSP_mcbMaxAlloc    dd ?        ;Size of MCB chunks.
  1222.  EPSP_DTA        df ?        ;DTA address.
  1223.  EPSP_TransProt    dw ?        ;Transfer buffer address.
  1224.  EPSP_TransReal    dw ?        ;Transfer buffer real mode segment value.
  1225.  EPSP_TransSize    dd ?        ;Transfer buffer size.
  1226.  EPSP_SSESP        df ?        ;Return SS:ESP to use.
  1227.  EPSP_INTMem        dd ?        ;linear address of interrupt/exception vector
  1228.                 ;save buffer. 0 for none.
  1229.  EPSP_DPMIMem    dw ?        ;selector for DPMI state save buffer. 0 for
  1230.                 ;none.
  1231.  EPSP_MemBase    dd ?        ;Program linear load address.
  1232.  EPSP_MemSize    dd ?        ;Program memory size.
  1233.  EPSP_SegBase    dw ?        ;Base program selector.
  1234.  EPSP_SegSize    dw ?        ;Number of program selectors.
  1235.  
  1236.  EPSP_NearBase    dd ?        ;NEAR function address translation base.
  1237.  
  1238.  EPSP_RealENV    dw ?        ;Origional real mode environment SEGMENT.
  1239.  
  1240.  EPSP_NextPSP    dd ?        ;Pointer to next PSP
  1241.  EPSP_LastPSP    dd ?        ;Pointer to last PSP
  1242.  
  1243.  EPSP_Exports    dd ?        ;Pointer to export list.
  1244.  EPSP_Imports    dd ?        ;Pointer to import list.
  1245.  
  1246.  EPSP_Links        dd ?        ;Count of linked modules.
  1247.  
  1248.  EPSP_ExecCount    dd ?        ;PMode pointer to exec counter.
  1249.  
  1250.  EPSP_EntryCSEIP    df ?        ;Entry CS:EIP for DLL's
  1251.  
  1252.  EPSP_PSPSel        dw ?        ;This PSP's selector.
  1253.  
  1254. EPSP_Struc        ends
  1255.  
  1256.  
  1257.