home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / caway349.zip / BIN / CW.INC < prev    next >
Text File  |  1996-06-17  |  31KB  |  1,255 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 interrupts. 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 overwritten 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 interrupt.
  59. ;
  60. ;On Entry:
  61. ;
  62. ;BL    - Interrupt number.
  63. ;ES:[E]DI    - Parameter block.
  64. ;
  65. ;On Exit:
  66. ;
  67. ;Parameter block updated.
  68. ;
  69. ;NOTES:
  70. ;
  71. ;The parameter block referenced by ES:[E]DI should contain the register values
  72. ;you want passing to the real mode interrupt 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 interrupt
  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 interrupt handler address.
  140. ;
  141. ;On Entry:
  142. ;
  143. ;BL    - Interrupt 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 interrupt handler address.
  157. ;
  158. ;On Entry:
  159. ;
  160. ;BL    - Interrupt 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 interrupt handler address.
  173. ;
  174. ;On Entry:
  175. ;
  176. ;BL    - Interrupt 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 interrupt handler address.
  190. ;
  191. ;On Entry:
  192. ;
  193. ;BL    - Interrupt 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 initialized 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 initialized 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 selector's 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. ;Does not consume a selector per allocation as does GetMem call
  412. ;Handy for many small allocations where running out of selectors is a problem.
  413. ;
  414. ;On Entry:
  415. ;
  416. ;CX:DX    - Size of block required in bytes.
  417. ;
  418. ;On Exit:
  419. ;
  420. ;Carry set on error else,
  421. ;
  422. ;SI:DI    - selector:offset of allocated memory.
  423. ;
  424. GetMemSO    equ    0ff2ch
  425.  
  426.  
  427. ;-------------------------------------------------------------------------------
  428. ;
  429. ;Allocate a block of memory.
  430. ;
  431. ;On Entry:
  432. ;
  433. ;ECX    - Size of block required in bytes. (-1 to get maximum memory size)
  434. ;
  435. ;On Exit:
  436. ;
  437. ;Carry clear if OK &
  438. ;
  439. ;BX    - Selector to access the block with.
  440. ;
  441. ;Else if ECX was -1, ECX is size of largest block available.
  442. ;
  443. ;NOTES:
  444. ;
  445. ;This function allocates a block of extended (application) memory, and also a
  446. ;selector with a suitable base & limit.
  447. ;
  448. GetMem32    equ    0ff0ch
  449.  
  450.  
  451. ;-------------------------------------------------------------------------------
  452. ;
  453. ;Resize a previously allocated block of memory.
  454. ;
  455. ;On Entry:
  456. ;
  457. ;BX    - Selector for block.
  458. ;CX:DX    - New size of block required in bytes.
  459. ;
  460. ;On Exit:
  461. ;
  462. ;Carry clear if OK.
  463. ;
  464. ;NOTES:
  465. ;
  466. ;If the memory block can't be resized in its current location, but a free block
  467. ;of memory of the new size exists, the memory will be copied to a new block and
  468. ;the old one released. This is transparent to the application as long as only
  469. ;the selector originally allocated with GetMem is being used to access the
  470. ;memory.
  471. ;
  472. ResMem    equ    0ff0dh
  473.  
  474.  
  475. ;-------------------------------------------------------------------------------
  476. ;
  477. ;Resize a block of memory allocated via GetMemSO.
  478. ;
  479. ;On Entry:
  480. ;
  481. ;SI:DI    - Selector:offset for block.
  482. ;CX:DX    - New size of block required in bytes.
  483. ;
  484. ;On Exit:
  485. ;
  486. ;Carry set on error else,
  487. ;
  488. ;SI:DI    - selector:offset new block address.
  489. ;
  490. ResMemSO    equ    0ff2dh
  491.  
  492.  
  493. ;-------------------------------------------------------------------------------
  494. ;
  495. ;Resize a previously allocated block of memory.
  496. ;
  497. ;On Entry:
  498. ;
  499. ;BX    - Selector for block.
  500. ;ECX    - New size of block required in bytes.
  501. ;
  502. ;On Exit:
  503. ;
  504. ;Carry clear if OK.
  505. ;
  506. ;NOTES:
  507. ;
  508. ;If the memory block can't be resized in its current location, but a free block
  509. ;of memory of the new size exists, the memory will be copied to a new block and
  510. ;the old one released. This is transparent to the application as long as only
  511. ;the selector originally allocated with GetMem is being used to access the
  512. ;memory.
  513. ;
  514. ResMem32    equ    0ff0eh
  515.  
  516.  
  517. ;-------------------------------------------------------------------------------
  518. ;
  519. ;Release previously allocated block of memory. To be used for memory allocated
  520. ;by either GetMem or GetMem32.
  521. ;
  522. ;
  523. ;On Entry:
  524. ;
  525. ;BX    - Selector for block to release.
  526. ;
  527. RelMem    equ    0ff0fh
  528.  
  529.  
  530. ;-------------------------------------------------------------------------------
  531. ;
  532. ;Release block of memory allocated via GetMemSO.
  533. ;
  534. ;On Entry:
  535. ;
  536. ;SI:DI    - Selector:offset for block to release.
  537. ;
  538. RelMemSO    equ    0ff2eh
  539.  
  540.  
  541. ;-------------------------------------------------------------------------------
  542. ;
  543. ;Allocate a block of memory without a selector.
  544. ;
  545. ;On Entry:
  546. ;
  547. ;CX:DX    - Size of block required in bytes.
  548. ;
  549. ;On Exit:
  550. ;
  551. ;Carry clear if OK &,
  552. ;
  553. ;SI:DI    - Linear address of block allocated.
  554. ;
  555. ;NOTES:
  556. ;
  557. ;Addresses returned by this function may be >16M
  558. ;
  559. GetMemLinear    equ    0ff10h
  560.  
  561.  
  562. ;-------------------------------------------------------------------------------
  563. ;
  564. ;Allocate a block of memory without a selector.
  565. ;
  566. ;On Entry:
  567. ;
  568. ;ECX    - Size of block required in bytes.
  569. ;
  570. ;On Exit:
  571. ;
  572. ;Carry clear if OK &,
  573. ;
  574. ;ESI    - Linear address of block allocated.
  575. ;
  576. ;NOTES:
  577. ;
  578. ;Addresses returned by this function may be >16M
  579. ;
  580. GetMemLinear32 equ    0ff11h
  581.  
  582.  
  583. ;-------------------------------------------------------------------------------
  584. ;
  585. ;Resize a previously allocated block of memory without a selector.
  586. ;
  587. ;On Entry:
  588. ;
  589. ;SI:DI    - Linear address of block to resize.
  590. ;CX:DX    - Size of block required in bytes.
  591. ;
  592. ;On Exit:
  593. ;
  594. ;Carry clear if OK &,
  595. ;
  596. ;SI:DI    - New linear address of block.
  597. ;
  598. ;NOTES:
  599. ;
  600. ;If the memory block cannot be expanded to the desired size, and a free block
  601. ;of sufficient size exists, the existing memory will be copied to the free
  602. ;block and released, the new block then being allocated in place of the old.
  603. ;
  604. ResMemLinear    equ    0ff12h
  605.  
  606.  
  607. ;-------------------------------------------------------------------------------
  608. ;
  609. ;Resize a previously allocated block of memory without a selector.
  610. ;
  611. ;On Entry:
  612. ;
  613. ;ESI    - Linear address of block to resize.
  614. ;ECX    - Size of block required in bytes.
  615. ;
  616. ;On Exit:
  617. ;
  618. ;Carry clear if OK &,
  619. ;
  620. ;ESI    - New linear address of block.
  621. ;
  622. ;NOTES:
  623. ;
  624. ;If the memory block cannot be expanded to the desired size, and a free block
  625. ;of sufficient size exists, the existing memory will be copied to the free
  626. ;block and released, the new block then being allocated in place of the old.
  627. ;
  628. ResMemLinear32 equ    0ff13h
  629.  
  630.  
  631. ;-------------------------------------------------------------------------------
  632. ;
  633. ;Release previously allocated block of memory (linear address).
  634. ;
  635. ;On Entry:
  636. ;
  637. ;SI:DI    - Linear address of block to release.
  638. ;
  639. ;On Exit:
  640. ;
  641. RelMemLinear    equ    0ff14h
  642.  
  643.  
  644. ;-------------------------------------------------------------------------------
  645. ;
  646. ;Release previously allocated block of memory (linear address).
  647. ;
  648. ;On Entry:
  649. ;
  650. ;ESI    - Linear address of block to release.
  651. ;
  652. ;On Exit:
  653. ;
  654. RelMemLinear32 equ    0ff15h
  655.  
  656.  
  657. ;-------------------------------------------------------------------------------
  658. ;
  659. ;Allocate an application relative block of memory.
  660. ;
  661. ;On Entry:
  662. ;
  663. ;EBX    - Size of block required in bytes.
  664. ;
  665. ;On Exit:
  666. ;
  667. ;Carry clear if OK &,
  668. ;
  669. ;ESI    - Application relative linear address of block allocated.
  670. ;
  671. ;NOTES:
  672. ;
  673. ;Addresses returned by this function are as an offset from the application.
  674. ;
  675. GetMemNear    equ    0ff16h
  676.  
  677.  
  678. ;-------------------------------------------------------------------------------
  679. ;
  680. ;Resize a previously allocated application relative block of memory.
  681. ;
  682. ;On Entry:
  683. ;
  684. ;EBX    - Size of block required in bytes.
  685. ;ESI    - application relative linear address of block to resize.
  686. ;
  687. ;On Exit:
  688. ;
  689. ;Carry clear if OK &,
  690. ;
  691. ;ESI    - New application relative linear address of block.
  692. ;
  693. ;NOTES:
  694. ;
  695. ;If the memory block cannot be expanded to the desired size, and a free block
  696. ;of sufficient size exists, the existing memory will be copied to the free
  697. ;block and released, the new block then being allocated in place of the old.
  698. ;
  699. ResMemNear    equ    0ff17h
  700.  
  701.  
  702. ;-------------------------------------------------------------------------------
  703. ;
  704. ;Release previously allocated application relative block of memory.
  705. ;
  706. ;On Entry:
  707. ;
  708. ;ESI    - Application relative linear address of block to release.
  709. ;
  710. ;On Exit:
  711. ;
  712. RelMemNear    equ    0ff18h
  713.  
  714.  
  715. ;-------------------------------------------------------------------------------
  716. ;
  717. ;Convert linear address to application relative address.
  718. ;
  719. ;On Entry:
  720. ;
  721. ;ESI    - Linear address to convert.
  722. ;
  723. ;On Exit:
  724. ;
  725. ;ESI    - Application relative linear address.
  726. ;
  727. Linear2Near    equ    0ff19h
  728.  
  729.  
  730. ;-------------------------------------------------------------------------------
  731. ;
  732. ;Convert application relative address to linear address.
  733. ;
  734. ;On Entry:
  735. ;
  736. ;ESI    - Application relative linear address.
  737. ;
  738. ;On Exit:
  739. ;
  740. ;ESI    - Linear address to convert.
  741. ;
  742. Near2Linear    equ    0ff1ah
  743.  
  744.  
  745. ;-------------------------------------------------------------------------------
  746. ;
  747. ;Lock a region of memory.
  748. ;
  749. ;On Entry:
  750. ;
  751. ;BX:CX    - Starting linear address of memory to lock.
  752. ;SI:DI    - Size of region to lock in bytes.
  753. ;
  754. ;On Exit:
  755. ;
  756. ;Carry set on error, none of the memory locked, else memory is locked.
  757. ;
  758. ;NOTES:
  759. ;
  760. ;Memory that is locked cannot be swapped to disk by the VMM. You should note
  761. ;that locking is applied to memory on 4K boundaries, so areas of memory below
  762. ;and above the memory being locked will also be locked if the specified region
  763. ;is not 4K aligned.
  764. ;
  765. LockMem    equ    0ff1bh
  766.  
  767.  
  768. ;-------------------------------------------------------------------------------
  769. ;
  770. ;Lock a region of memory.
  771. ;
  772. ;On Entry:
  773. ;
  774. ;ESI    - Starting linear address of memory to lock.
  775. ;ECX    - Size of region to lock in bytes.
  776. ;
  777. ;On Exit:
  778. ;
  779. ;Carry set on error, none of the memory locked, else memory is locked.
  780. ;
  781. ;NOTES:
  782. ;
  783. ;Memory that is locked cannot be swapped to disk by the VMM. You should note
  784. ;that locking is applied to memory on 4K boundaries, so areas of memory below
  785. ;and above the memory being locked will also be locked if the specified region
  786. ;is not 4K aligned.
  787. ;
  788. LockMem32    equ    0ff1ch
  789.  
  790.  
  791. ;-------------------------------------------------------------------------------
  792. ;
  793. ;Unlock a region of memory.
  794. ;
  795. ;On Entry:
  796. ;
  797. ;BX:CX    - Starting linear address of memory to unlock
  798. ;SI:DI    - Size of region to unlock in bytes
  799. ;
  800. ;NOTES:
  801. ;
  802. ;This will allow the memory to be swapped to disk by the VMM if necessary.
  803. ;Areas below and above the specified memory will also be unlocked if the
  804. ;specified region is not page aligned.
  805. ;
  806. UnLockMem    equ    0ff1dh
  807.  
  808.  
  809. ;-------------------------------------------------------------------------------
  810. ;
  811. ;Unlock a region of memory.
  812. ;
  813. ;On Entry:
  814. ;
  815. ;ESI    - Starting linear address of memory to unlock
  816. ;ECX    - Size of region to unlock in bytes
  817. ;
  818. ;NOTES:
  819. ;
  820. ;This will allow the memory to be swapped to disk by the VMM if necessary.
  821. ;Areas below and above the specified memory will also be unlocked if the
  822. ;specified region is not page aligned.
  823. ;
  824. UnLockMem32    equ    0ff1eh
  825.  
  826.  
  827. ;-------------------------------------------------------------------------------
  828. ;
  829. ;Lock a region of memory using application relative address.
  830. ;
  831. ;On Entry:
  832. ;
  833. ;ESI    - Starting linear address of memory to lock.
  834. ;EBX    - Size of region to lock in bytes.
  835. ;
  836. ;On Exit:
  837. ;
  838. ;Carry set on error, none of the memory locked, else memory is locked.
  839. ;
  840. ;NOTES:-
  841. ;
  842. ;Memory that is locked cannot be swapped to disk by the VMM. You should note
  843. ;that locking is applied to memory on 4K boundaries, so areas of memory below
  844. ;and above the memory being locked will also be locked if the specified region
  845. ;is not 4K aligned.
  846. ;
  847. LockMemNear    equ    0ff1fh
  848.  
  849.  
  850. ;-------------------------------------------------------------------------------
  851. ;
  852. ;Unlock a region of memory using application relative address.
  853. ;
  854. ;On Entry:
  855. ;
  856. ;ESI    - Starting linear address of memory to unlock
  857. ;EBX    - Size of region to unlock in bytes
  858. ;
  859. ;NOTES:
  860. ;
  861. ;This will allow the memory to be swapped to disk by the VMM if necessary.
  862. ;Areas below and above the specified memory will also be unlocked if the
  863. ;specified region is not page aligned.
  864. ;
  865. UnLockMemNear equ    0ff20h
  866.  
  867.  
  868. ;-------------------------------------------------------------------------------
  869. ;
  870. ;Allocate a region of DOS (conventional) memory.
  871. ;
  872. ;On Entry:
  873. ;
  874. ;BX    - Number of paragraphs (16 byte blocks) required.
  875. ;
  876. ;On Exit:
  877. ;
  878. ;If function was successful:
  879. ;Carry flag is clear.
  880. ;
  881. ;AX    - Initial real mode segment of allocated block
  882. ;DX    - Initial selector for allocated block
  883. ;
  884. ;If function was not successful:
  885. ;Carry flag is set.
  886. ;
  887. ;AX    - DOS error code.
  888. ;BX    - Size of largest available block in paragraphs.
  889. ;
  890. ;NOTES:
  891. ;
  892. ;If the size of the block requested is greater than 64K bytes (BX > 1000h) then
  893. ;contiguous descriptors will be allocated. If more than one descriptor is
  894. ;allocated under 32-bit applications, the limit of the first descriptor will be
  895. ;set to the size of the entire block. All subsequent descriptors will have a
  896. ;limit of 64K except for the final descriptor which will have a limit of Block
  897. ;size MOD 64K. 16-bit applications will always set the limit of the first
  898. ;descriptor to 64K.
  899. ;
  900. GetMemDOS    equ    0ff21h
  901.  
  902.  
  903. ;-------------------------------------------------------------------------------
  904. ;
  905. ;Resize a block of DOS (conventional) memory previously allocated with
  906. ;GetMemDOS.
  907. ;
  908. ;On Entry:
  909. ;
  910. ;BX    - New block size in paragraphs
  911. ;DX    - Selector of block to modify
  912. ;
  913. ;On Exit:
  914. ;
  915. ;If function was successful:
  916. ;Carry flag is clear.
  917. ;
  918. ;If function was not successful:
  919. ;Carry flag is set.
  920. ;
  921. ;AX    - DOS error code:
  922. ;BX    - Maximum block size possible in paragraphs
  923. ;
  924. ;NOTES:
  925. ;
  926. ;Growing a memory block is often likely to fail since other DOS block
  927. ;allocations will prevent increasing the size of the block. Also, if the size of
  928. ;a block grows past a 64K boundary then the allocation will fail if the next
  929. ;descriptor in the LDT is not free.
  930. ;
  931. ResMemDOS    equ    0ff22h
  932.  
  933.  
  934. ;-------------------------------------------------------------------------------
  935. ;
  936. ;Release a block of DOS (conventional) memory previously allocated with
  937. ;GetMemDOS.
  938. ;
  939. ;On Entry:
  940. ;
  941. ;DX    - Selector of block to free.
  942. ;
  943. ;On Exit:
  944. ;
  945. ;If function was successful:
  946. ;Carry flag is clear.
  947. ;
  948. ;If function was not successful:
  949. ;Carry flag is set.
  950. ;
  951. ;AX    - DOS error code.
  952. ;
  953. ;NOTES:
  954. ;
  955. ;All descriptors allocated for the memory block are automatically freed and
  956. ;therefore should not be accessed once the block is freed by this function.
  957. ;
  958. RelMemDOS    equ    0ff23h
  959.  
  960.  
  961. ;-------------------------------------------------------------------------------
  962. ;
  963. ;Get current address and size of the buffer used for DOS memory transfers.
  964. ;
  965. ;On Exit:
  966. ;
  967. ;BX    - Real mode segment of buffer.
  968. ;DX    - Protected mode selector for buffer.
  969. ;ECX    - Buffer size.
  970. ;
  971. ;Notes:
  972. ;
  973. ;This buffer is used by the built-in INT API translation services,
  974. ;e.g. INT 21h, AH=40h (write to file). The default buffer is 8K and uses memory
  975. ;that would otherwise be wasted. This default is sufficient for most file I/O
  976. ;but if you are writing a program that reads/writes large amounts of data you
  977. ;should consider allocating your own larger buffer and pass the address to
  978. ;CauseWay to speed this file I/O.
  979. ;
  980. GetDOSTrans    equ    0ff25h
  981.  
  982.  
  983. ;-------------------------------------------------------------------------------
  984. ;
  985. ;Set new address and size of the buffer used for DOS memory transfers.
  986. ;
  987. ;On Entry:
  988. ;
  989. ;BX    - Real mode segment of buffer.
  990. ;DX    - Protected mode selector for buffer.
  991. ;ECX    - Buffer size.
  992. ;
  993. ;Notes:
  994. ;
  995. ;This buffer is used by the built-in INT API translation services,
  996. ;e.g. INT 21h, AH=40h (write to file). The default buffer is 8K and uses memory
  997. ;that would otherwise be wasted. This default is sufficient for most file I/O
  998. ;but if you are writing a program that reads/writes large amounts of data you
  999. ;should consider allocating your own larger buffer and pass the address to
  1000. ;CauseWay to speed this file I/O.
  1001. ;
  1002. ;The buffer must be in conventional memory and only the first 64K will be used
  1003. ;even if a bigger buffer is specified. CauseWay will automatically restore the
  1004. ;previous buffer setting when the application terminates but GetDOSTrans can
  1005. ;be used to get the current buffer's settings if you only want the change to
  1006. ;be temporary.
  1007. ;
  1008. ;You can still use the default buffer for your own purposes even after setting a
  1009. ;new address.
  1010. ;
  1011. SetDOSTrans    equ    0ff26h
  1012.  
  1013.  
  1014. ;-------------------------------------------------------------------------------
  1015. ;
  1016. ;Get current MCB memory allocation block size.
  1017. ;
  1018. ;On Exit:
  1019. ;
  1020. ;ECX    - Current threshold.
  1021. ;
  1022. GetMCBSize    equ    0ff27h
  1023.  
  1024.  
  1025. ;-------------------------------------------------------------------------------
  1026. ;
  1027. ;Set new MCB memory allocation block size.
  1028. ;
  1029. ;On Entry:
  1030. ;
  1031. ;ECX    - New value to set.
  1032. ;
  1033. ;On Exit:
  1034. ;
  1035. ;Carry set on error else new value will be used.
  1036. ;
  1037. ;Notes:
  1038. ;
  1039. ;The maximum block size that will be allocated from MCB memory is 16 bytes less
  1040. ;than the value set by this function. The default value is 16384.
  1041. ;
  1042. ;65536 is the maximum value this function will accept. Passing a value above
  1043. ;this will return with the carry set and the original value still in force.
  1044. ;
  1045. ;The CauseWay API memory allocation functions allocate memory from two sources.
  1046. ;Allocation requests below the value returned by this function are allocated
  1047. ;from a memory pool controlled via conventional style MCB's. Requests above this
  1048. ;value are allocated via the normal DPMI functions. Because DPMI memory is
  1049. ;always allocated in multiples of 4K it can become very inefficient for any
  1050. ;program that needs to allocate small blocks of memory. The value set by this
  1051. ;function controls the size of memory chunks that will be allocated to and
  1052. ;managed by the MCB system.
  1053. ;
  1054. ;A value of zero can be passed to this function to disable the MCB allocation
  1055. ;system.
  1056. ;
  1057. ;The value passed will be rounded up to the nearest 4K.
  1058. ;
  1059. SetMCBMax    equ    0ff28h
  1060.  
  1061.  
  1062. ;-------------------------------------------------------------------------------
  1063. ;
  1064. ;Run another CauseWay program directly.
  1065. ;
  1066. ;On Entry:
  1067. ;
  1068. ;DS:EDX    - File name.
  1069. ;ES:ESI    - Command line. First byte is length, then real data.
  1070. ;CX    - Environment selector, 0 to use existing copy.
  1071. ;
  1072. ;On Exit:
  1073. ;
  1074. ;Carry set on error and AX = error code else AL=ErrorLevel
  1075. ;
  1076. ;Error codes:
  1077. ;
  1078. ;1    - DOS file access error.
  1079. ;2    - Not a 3P file.
  1080. ;3    - Not enough memory.
  1081. ;
  1082. ;NOTES:
  1083. ;
  1084. ;Only the first byte of the command line (length) has any significance to
  1085. ;CauseWay so you are not restricted to ASCII values. It is still stored in the
  1086. ;PSP at 80h though so the length is still limited to 127 bytes.
  1087. ;
  1088. cwExec    equ    0ff24h
  1089.  
  1090.  
  1091. ;-------------------------------------------------------------------------------
  1092. ;
  1093. ;Load another CauseWay program as an overlay, i.e., do relocations etc. but don't
  1094. ;actually execute it.
  1095. ;
  1096. ;On Entry:
  1097. ;
  1098. ;DS:EDX    - File name.
  1099. ;
  1100. ;On Exit:
  1101. ;
  1102. ;Carry set on error and AX = error code else,
  1103. ;
  1104. ;CX:EDX    - Entry CS:EIP
  1105. ;BX:EAX    - Entry SS:ESP
  1106. ;SI    - PSP.
  1107. ;
  1108. ;Error codes:
  1109. ;
  1110. ;1    - DOS file access error.
  1111. ;2    - Not a 3P file.
  1112. ;3    - Not enough memory.
  1113. ;
  1114. ;NOTES:
  1115. ;
  1116. ;The PSP returned in SI can be passed to RelMem to release the loaded program's
  1117. ;memory and selectors. Only the memory and selectors allocated during loading
  1118. ;will be released, it is the program's responsibility to release any additional
  1119. ;memory etc. allocated while the program is running. Alternatively, if you pass
  1120. ;the PSP value to INT 21h, AH=50h before making additional memory requests
  1121. ;and then reset to the original PSP the memory allocated will be released
  1122. ;when the PSP is released.
  1123. ;
  1124. cwLoad    equ    0ff2ah
  1125.  
  1126.  
  1127. ;-------------------------------------------------------------------------------
  1128. ;
  1129. ;Validate and get expanded length of a CWC'ed file.
  1130. ;
  1131. ;On Entry:
  1132. ;
  1133. ;BX    - File handle.
  1134. ;
  1135. ;On Exit:
  1136. ;
  1137. ;Carry set if not a CWC'ed file else,
  1138. ;
  1139. ;ECX    - Expanded data size.
  1140. ;
  1141. ;NOTES:
  1142. ;
  1143. ;The file pointer is not altered by this function.
  1144. ;
  1145. cwcInfo    equ    0ff2bh
  1146.  
  1147.  
  1148. ;-------------------------------------------------------------------------------
  1149. ;
  1150. ;Load/Expand a CWC'ed data file into memory.
  1151. ;
  1152. ;On Entry:
  1153. ;
  1154. ;BX    - Source file handle.
  1155. ;ES:EDI    - Destination memory.
  1156. ;
  1157. ;On Exit:
  1158. ;
  1159. ;Carry set on error and EAX is error code else,
  1160. ;
  1161. ;ECX    - Expanded data length.
  1162. ;
  1163. ;Error codes:
  1164. ;
  1165. ;    1 = Error during file access.
  1166. ;    2 = Bad data.
  1167. ;    3 = Not a CWC'ed file.
  1168. ;
  1169. ;NOTES:
  1170. ;
  1171. ;The source file's file pointer doesn't have to be at zero. A single file might
  1172. ;be several CWC'ed files lumped together, as long as the file pointer is moved
  1173. ;to the right place before calling this function.
  1174. ;
  1175. ;If error codes 1 or 2 are reported then the file pointer will be wherever it
  1176. ;was last moved to by this function. For error code 3 the file pointer will be
  1177. ;back at its original position on entry to this function. If no error occurs
  1178. ;then the file pointer will be moved to whatever comes after the compressed
  1179. ;data.
  1180. ;
  1181. cwcLoad    equ    0fffbh
  1182.  
  1183.  
  1184. ;-------------------------------------------------------------------------------
  1185. ;
  1186. ;Structure of parameter table for real mode interrupt and procedure calling.
  1187. ;
  1188. ;NOTE:- For interrupts, CS:IP,SS:SP & Flags are filled in by the extender.
  1189. ;       For far calls, SS:SP & Flags are filled in by the extender.
  1190. ;
  1191. RealRegsStruc struc
  1192. Real_EDI    dd ?    ;EDI
  1193. Real_ESI    dd ?    ;ESI
  1194. Real_EBP    dd ?    ;EBP
  1195.     dd ?    ;Reserved.
  1196. Real_EBX    dd ?    ;EBX
  1197. Real_EDX    dd ?    ;EDX
  1198. Real_ECX    dd ?    ;ECX
  1199. Real_EAX    dd ?    ;EAX
  1200. Real_Flags    dw ?    ;FLAGS
  1201. Real_ES    dw ?    ;ES
  1202. Real_DS    dw ?    ;DS
  1203. Real_FS    dw ?    ;FS
  1204. Real_GS    dw ?    ;GS
  1205. Real_IP    dw ?    ;IP
  1206. Real_CS    dw ?    ;CS
  1207. Real_SP    dw ?    ;SP
  1208. Real_SS    dw ?    ;SS
  1209. RealRegsStruc ends
  1210.  
  1211.  
  1212. ;-------------------------------------------------------------------------------
  1213. ;
  1214. ;Now the extended PSP structure.
  1215. ;
  1216. EPSP_Struc        struc
  1217.         db 256 dup (?)        ;Standard PSP information/structure
  1218.  EPSP_Parent    dw ?        ;Selector of parent/previous PSP, 0 for none.
  1219.  EPSP_Next        dw ?        ;Next PSP.
  1220.  EPSP_Resource    dd ?        ;Linear address of resource tracking table. 0
  1221.                 ;for none.
  1222.  EPSP_mcbHead    dd ?        ;Linear address of MCB memory head. 0 for none.
  1223.  EPSP_mcbMaxAlloc    dd ?    ;Size of MCB chunks.
  1224.  EPSP_DTA        df ?        ;DTA address.
  1225.  EPSP_TransProt    dw ?        ;Transfer buffer address.
  1226.  EPSP_TransReal    dw ?        ;Transfer buffer real mode segment value.
  1227.  EPSP_TransSize    dd ?        ;Transfer buffer size.
  1228.  EPSP_SSESP        df ?        ;Return SS:ESP to use.
  1229.  EPSP_INTMem    dd ?        ;linear address of interrupt/exception vector
  1230.                 ;save buffer. 0 for none.
  1231.  EPSP_DPMIMem    dw ?        ;selector for DPMI state save buffer. 0 for
  1232.                 ;none.
  1233.  EPSP_MemBase    dd ?        ;Program linear load address.
  1234.  EPSP_MemSize    dd ?        ;Program memory size.
  1235.  EPSP_SegBase    dw ?        ;Base program selector.
  1236.  EPSP_SegSize    dw ?        ;Number of program selectors.
  1237.  
  1238.  EPSP_NearBase    dd ?        ;NEAR function address translation base.
  1239.  
  1240.  EPSP_RealENV    dw ?        ;Original real mode environment SEGMENT.
  1241.  
  1242.  EPSP_NextPSP    dd ?        ;Pointer to next PSP
  1243.  EPSP_LastPSP    dd ?        ;Pointer to last PSP
  1244.  
  1245.  EPSP_Exports    dd ?        ;Pointer to export list.
  1246.  EPSP_Imports    dd ?        ;Pointer to import list.
  1247.  
  1248.  EPSP_Links        dd ?        ;Count of linked modules.
  1249.  
  1250.  EPSP_ExecCount    dd ?        ;PMode pointer to exec counter.
  1251.  
  1252. EPSP_Struc        ends
  1253.  
  1254.  
  1255.