go32.tex 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525
  1. \chapter{The GO32 unit}
  2. This chapter of the documentation describe the GO32 unit for the Free Pascal
  3. compiler under DOS.
  4. This unit was first written for DOS by Florian Klämpfl.
  5. This chapter is divided in three sections. The first section is an
  6. introduction to the GO32 unit. The second section lists the pre-defined
  7. constants, types and variables. The third section describes the functions
  8. which appear in the interface part of the GO32 unit.
  9. A lot of function descriptions were made by Thomas Schatzl, for which my
  10. thanks.
  11. \section{Introduction}
  12. These docs contain information about the GO32 unit. Only the GO32V2 DPMI
  13. mode is discussed by me here due to the fact that new applications shouldn't
  14. be created with the older GO32V1 model. The former is much more advanced and
  15. better. Additionally a lot of functions only work in DPMI mode anyway.
  16. I hope the following explanations and introductions aren't too confusing at
  17. all. If you notice an error or bug send it to the FPC mailing list or
  18. directly to me.
  19. So let's get started and happy and error free coding I wish you....
  20. \hfill Thomas Schatzl, 25. August 1998
  21. \section{Protected mode memory organization}
  22. \subsection{What is DPMI}
  23. The DOS Protected Mode Interface helps you with various aspects of protected
  24. mode programming. These are roughly divided into descriptor handling, access
  25. to DOS memory, management of interrupts and exceptions, calls to real mode
  26. functions and other stuff. Additionally it automatically provides swapping
  27. to disk for memory intensive applications.
  28. A DPMI host (either a Windows DOS box or CWSDPMI.EXE) provides these
  29. functions for your programs.
  30. \subsection{Selectors and descriptors}
  31. Descriptors are a bit like real mode segments; they describe (as the name
  32. implies) a memory area in protected mode. A descriptor contains information
  33. about segment length, its base address and the attributes of it (i.e. type,
  34. access rights, ...).
  35. These descriptors are stored internally in a so-called descriptor table,
  36. which is basically an array of such descriptors.
  37. Selectors are roughly an index into this table.
  38. Because these 'segments' can be up to 4 GB in size, 32 bits aren't
  39. sufficient anymore to describe a single memory location like in real mode.
  40. 48 bits are now needed to do this, a 32 bit address and a 16 bit sized
  41. selector. The GO32 unit provides the tseginfo record to store such a
  42. pointer.
  43. But due to the fact that most of the time data is stored and accessed in the
  44. \%ds selector, FPC assumes that all pointers point to a memory location of
  45. this selector. So a single pointer is still only 32 bits in size. This value
  46. represents the offset from the data segment base address to this memory
  47. location.
  48. \subsection{FPC specialities}
  49. The \%ds and \%es selector MUST always contain the same value or some system
  50. routines may crash when called. The \%fs selector is preloaded with the
  51. DOSMEMSELECTOR variable at startup, and it MUST be restored after use,
  52. because again FPC relys on this for some functions. Luckily we asm
  53. programmers can still use the \%gs selector for our own purposes, but for how
  54. long ?
  55. See also:
  56. % tseginfo, dosmemselector, DOS memory access,
  57. \seefl{get\_cs}{getcs},
  58. \seefl{get\_ds}{getds},
  59. \seefl{gett\_ss}{getss},
  60. \seefl{allocate\_ldt\_descriptors}{allocateldtdescriptors},
  61. \seefl{free\_ldt\_descriptor}{freeldtdescriptor},
  62. \seefl{segment\_to\_descriptor}{segmenttodescriptor},
  63. \seefl{get\_next\_selector\_increment\_value}{getnextselectorincrementvalue},
  64. \seefl{get\_segment\_base\_address}{getsegmentbaseaddress},
  65. \seefl{set\_segment\_base\_address}{setsegmentbaseaddress},
  66. \seefl{set\_segment\_limit}{setsegmentlimit},
  67. \seefl{create\_code\_segment\_alias\_descriptor}{createcodesegmentaliasdescriptor}
  68. \subsection{DOS memory access}
  69. DOS memory is accessed by the predefined DOSmemselector selector; the GO32
  70. unit additionally provides some functions to help you with standard tasks,
  71. like copying memory from heap to DOS memory and the likes. Because of this
  72. it is strongly recommened to use them, but you are still free to use the
  73. provided standard memory accessing functions which use 48 bit pointers. The
  74. third, but only thought for compatibility purposes, is using the
  75. mem[]-arrays. These arrays map the whole 1 Mb DOS space. They shouldn't be
  76. used within new programs.
  77. To convert a segment:offset real mode address to a protected mode linear
  78. address you have to multiply the segment by 16 and add its offset. This
  79. linear address can be used in combination with the DOSMEMSELECTOR variable.
  80. See also:
  81. \seep{dosmemget},
  82. \seepl{dosmemput}{dosmemput},
  83. \seepl{dosmemmove}{dosmemmove},
  84. \seepl{dosmemfillchar}{dosmemfillchar},
  85. \seepl{dosmemfillword}{dosmemfillword},
  86. mem[]-arrays,
  87. \seepl{seg\_move}{segmove},
  88. \seepl{seg\_fillchar}{segfillchar},
  89. \seepl{seg\_fillword}{segfillword}.
  90. \subsection{I/O port access}
  91. The I/O port access is done via the various \seef{inportb}, \seep{outportb}
  92. functions
  93. which are available. Additionally Free Pascal supports the Turbo Pascal
  94. PORT[]-arrays but it is by no means recommened to use them, because they're
  95. only for compatibility purposes.
  96. See also: \seep{outportb}, \seef{inportb}, PORT[]-arrays
  97. \subsection{Processor access}
  98. These are some functions to access various segment registers (\%cs, \%ds, \%ss)
  99. which makes your work a bit easier.
  100. See also: \seefl{get\_cs}{getcs}, \seefl{get\_ds}{getds},
  101. \seefl{get\_ss}{getss}
  102. \subsection{Interrupt redirection}
  103. Interrupts are program interruption requests, which in one or another way
  104. get to the processor; there's a distinction between software and hardware
  105. interrupts. The former are explicitely called by an 'int' instruction and
  106. are a bit comparable to normal functions. Hardware interrupts come from
  107. external devices like the keyboard or mouse. These functions are called
  108. handlers.
  109. \subsection{Handling interrupts with DPMI}
  110. The interrupt functions are real-mode procedures; they normally can't be
  111. called in protected mode without the risk of an protection fault. So the
  112. DPMI host creates an interrupt descriptor table for the application.
  113. Initially all software interrupts (except for int 31h, 2Fh and 21h function
  114. 4Ch) or external hardware interrupts are simply directed to a handler that
  115. reflects the interrupt in real-mode, i.e. the DPMI host's default handlers
  116. switch the CPU to real-mode, issue the interrupt and switch back to
  117. protected mode. The contents of general registers and flags are passed to
  118. the real mode handler and the modified registers and flags are returned to
  119. the protected mode handler. Segment registers and stack pointer are not
  120. passed between modes.
  121. \subsection{Protected mode interrupts vs. Real mode interrupts}
  122. As mentioned before, there's a distinction between real mode interrupts and
  123. protected mode interrupts; the latter are protected mode programs, while the
  124. former must be real mode programs. To call a protected mode interrupt
  125. handler, an assembly 'int' call must be issued, while the other is called
  126. via the realintr() or intr() function. Consequently, a real mode interrupt
  127. then must either reside in DOS memory (<1MB) or the application must
  128. allocate a real mode callback address via the get\_rm\_callback() function.
  129. \subsection{Creating own interrupt handlers}
  130. Interrupt redirection with FPC pascal is done via the set\_pm\_interrupt() for
  131. protected mode interrupts or via the set\_rm\_interrupt() for real mode
  132. interrupts.
  133. \subsection{Disabling interrupts}
  134. The GO32 unit provides the two procedures disable() and enable() to disable
  135. and enable all interrupts.
  136. \subsection{Hardware interrupts}
  137. Hardware interrupts are generated by hardware devices when something unusual
  138. happens; this could be a keypress or a mouse move or any other action. This
  139. is done to minimize CPU time, else the CPU would have to check all installed
  140. hardware for data in a big loop (this method is called 'polling') and this
  141. would take much time.
  142. A standard IBM-PC has two interrupt controllers, that are responsible for
  143. these hardware interrupts: both allow up to 8 different interrupt sources
  144. (IRQs, interrupt requests). The second controller is connected to the first
  145. through IRQ 2 for compatibility reasons, e.g. if controller 1 gets an IRQ 2,
  146. he hands the IRQ over to controller 2. Because of this up to 15 different
  147. hardware interrupt sources can be handled.
  148. IRQ 0 through IRQ 7 are mapped to interrupts 8h to Fh and the second
  149. controller (IRQ 8 to 15) is mapped to interrupt 70h to 77h.
  150. All of the code and data touched by these handlers MUST be locked (via the
  151. various locking functions) to avoid page faults at interrupt time. Because
  152. hardware interrupts are called (as in real mode) with interrupts disabled,
  153. the handler has to enable them before it returns to normal program
  154. execution. Additionally a hardware interrupt must send an EOI (end of
  155. interrupt) command to the responsible controller; this is acomplished by
  156. sending the value 20h to port 20h (for the first controller) or A0h (for the
  157. second controller).
  158. The following example shows how to redirect the keyboard interrupt.
  159. \input{go32ex/keyclick.tex}
  160. \subsection{Software interrupts}
  161. Ordinarily, a handler installed with
  162. \seefl{set\_pm\_interrupt}{setpminterrupt} only services software
  163. interrupts that are executed in protected mode; real mode software
  164. interrupts can be redirected by \seefl{set\_rm\_interrupt}{setrminterrupt}.
  165. See also \seefl{set\_rm\_interrupt}{setrminterrupt},
  166. \seefl{get\_rm\_interrupt}{getrminterrupt},
  167. \seefl{set\_pm\_interrupt}{setpminterrupt},
  168. \seefl{get\_pm\_interrupt}{getpminterrupt},
  169. \seefl{lock\_data}{lockdata},
  170. \seefl{lock\_code}{lockcode},
  171. \seep{enable},
  172. \seep{disable},
  173. \seepl{outportb}{outportb}
  174. The following examples illustrate the use of software interrupts.
  175. \input{go32ex/softint.tex}
  176. \input{go32ex/rmpm_int.tex}
  177. \subsection{Real mode callbacks}
  178. The callback mechanism can be thought of as the converse of calling a real
  179. mode procedure (i.e. interrupt), which allows your program to pass
  180. information to a real mode program, or obtain services from it in a manner
  181. that's transparent to the real mode program.
  182. In order to make a real mode callback available, you must first get the real
  183. mode callback address of your procedure and the selector and offset of a
  184. register data structure. This real mode callback address (this is a
  185. segment:offset address) can be passed to a real mode program via a software
  186. interrupt, a DOS memory block or any other convenient mechanism.
  187. When the real mode program calls the callback (via a far call), the DPMI
  188. host saves the registers contents in the supplied register data structure,
  189. switches into protected mode, and enters the callback routine with the
  190. following conditions:
  191. \begin{itemize}
  192. \item interrupts disabled
  193. \item \var{\%CS:\%EIP} = 48 bit pointer specified in the original call to
  194. \seefl{get\_rm\_callback}{getrmcallback}
  195. \item \var{\%DS:\%ESI} = 48 bit pointer to to real mode \var{SS:SP}
  196. \item \var{\%ES:\%EDI} = 48 bit pointer of real mode register data
  197. structure.
  198. \item \var{\%SS:\%ESP} = locked protected mode stack
  199. \item All other registers undefined
  200. \end{itemize}
  201. The callback procedure can then extract its parameters from the real mode
  202. register data structure and/or copy parameters from the real mode stack to
  203. the protected mode stack. Recall that the segment register fields of the
  204. real mode register data structure contain segment or paragraph addresses
  205. that are not valid in protected mode. Far pointers passed in the real mode
  206. register data structure must be translated to virtual addresses before they
  207. can be used with a protected mode program.
  208. The callback procedure exits by executing an IRET with the address of the
  209. real mode register data structure in \var{\%ES:\%EDI}, passing information back to
  210. the real mode caller by modifying the contents of the real mode register
  211. data structure and/or manipulating the contents of the real mode stack. The
  212. callback procedure is responsible for setting the proper address for
  213. resumption of real mode execution into the real mode register data
  214. structure; typically, this is accomplished by extracting the return address
  215. from the real mode stack and placing it into the \var{\%CS:\%EIP} fields of the real
  216. mode register data structure. After the IRET, the DPMI host switches the CPU
  217. back into real mode, loads ALL registers with the contents of the real mode
  218. register data structure, and finally returns control to the real mode
  219. program.
  220. All variables and code touched by the callback procedure MUST be locked to
  221. prevent page faults.
  222. See also: \seefl{get\_rm\_callback}{getrmcallback},
  223. \seefl{free\_rm\_callback}{freermcallback},
  224. \seefl{lock\_code}{lockcode},
  225. \seefl{lock\_data}{lockdata}
  226. \section{Types, Variables and Constants}
  227. \subsection{Constants}
  228. \subsubsection{Constants returned by get\_run\_mode}
  229. Tells you under what memory environment (e.g. memory manager) the program
  230. currently runs.
  231. \begin{verbatim}
  232. rm_unknown = 0; { unknown }
  233. rm_raw = 1; { raw (without HIMEM) }
  234. rm_xms = 2; { XMS (for example with HIMEM, without EMM386) }
  235. rm_vcpi = 3; { VCPI (for example HIMEM and EMM386) }
  236. rm_dpmi = 4; { DPMI (for example DOS box or 386Max) }
  237. \end{verbatim}
  238. Note: GO32V2 {\em always} creates DPMI programs, so you need a suitable DPMI
  239. host like \file{CWSDPMI.EXE} or a Windows DOS box. So you don't need to check it,
  240. these constants are only useful in GO32V1 mode.
  241. \subsubsection{Processor flags constants}
  242. They are provided for a simple check with the flags identifier in the
  243. trealregs type. To check a single flag, simply do an AND operation with the
  244. flag you want to check. It's set if the result is the same as the flag
  245. value.
  246. \begin{verbatim}
  247. const carryflag = $001;
  248. parityflag = $004;
  249. auxcarryflag = $010;
  250. zeroflag = $040;
  251. signflag = $080;
  252. trapflag = $100;
  253. interruptflag = $200;
  254. directionflag = $400;
  255. overflowflag = $800;
  256. \end{verbatim}
  257. \subsection{Predefined types}
  258. \begin{verbatim}
  259. type tmeminfo = record
  260. available_memory : Longint;
  261. available_pages : Longint;
  262. available_lockable_pages : Longint;
  263. linear_space : Longint;
  264. unlocked_pages : Longint;
  265. available_physical_pages : Longint;
  266. total_physical_pages : Longint;
  267. free_linear_space : Longint;
  268. max_pages_in_paging_file : Longint;
  269. reserved : array[0..2] of Longint;
  270. end;
  271. \end{verbatim}
  272. Holds information about the memory allocation, etc.
  273. \begin{tabular}{ll}
  274. Record entry & Description \\ \hline
  275. \var{available\_memory} & Largest available free block in bytes. \\
  276. \var{available\_pages} & Maximum unlocked page allocation in pages \\
  277. \var{available\_lockable\_pages} & Maximum locked page allocation in pages. \\
  278. \var{linear\_space} & Linear address space size in pages. \\
  279. \var{unlocked\_pages} & Total number of unlocked pages. \\
  280. \var{available\_physical\_pages} & Total number of free pages.\\
  281. \var{total\_physical\_pages} & Total number of physical pages. \\
  282. \var{free\_linear\_space} & Free linear address space in pages.\\
  283. \var{max\_pages\_in\_paging\_file} & Size of paging file/partition in
  284. pages. \\
  285. \end{tabular}
  286. NOTE: The value of a field is -1 (0ffffffffh) if the value is unknown, it's
  287. only guaranteed, that \var{available\_memory} contains a valid value.
  288. The size of the pages can be determined by the get\_page\_size() function.
  289. \begin{verbatim}
  290. type
  291. trealregs = record
  292. case Integer of
  293. 1: { 32-bit }
  294. (EDI, ESI, EBP, Res, EBX, EDX, ECX, EAX: Longint;
  295. Flags, ES, DS, FS, GS, IP, CS, SP, SS: Word);
  296. 2: { 16-bit }
  297. (DI, DI2, SI, SI2, BP, BP2, R1, R2: Word;
  298. BX, BX2, DX, DX2, CX, CX2, AX, AX2: Word);
  299. 3: { 8-bit }
  300. (stuff: array[1..4] of Longint;
  301. BL, BH, BL2, BH2, DL, DH, DL2, DH2, CL,
  302. CH, CL2, CH2, AL, AH, AL2, AH2: Byte);
  303. 4: { Compat }
  304. (RealEDI, RealESI, RealEBP, RealRES, RealEBX,
  305. RealEDX, RealECX, RealEAX: Longint;
  306. RealFlags, RealES, RealDS, RealFS, RealGS,
  307. RealIP, RealCS, RealSP, RealSS: Word);
  308. end;
  309. registers = trealregs;
  310. \end{verbatim}
  311. These two types contain the data structure to pass register values to a
  312. interrupt handler or real mode callback.
  313. \begin{verbatim}
  314. type tseginfo = record
  315. offset : Pointer; segment : Word; end;
  316. \end{verbatim}
  317. This record is used to store a full 48-bit pointer. This may be either a
  318. protected mode selector:offset address or in real mode a segment:offset
  319. address, depending on application.
  320. See also: Selectors and descriptors, DOS memory access, Interrupt
  321. redirection
  322. \subsection{Variables.}
  323. \begin{verbatim}
  324. var dosmemselector : Word;
  325. \end{verbatim}
  326. Selector to the DOS memory. The whole DOS memory is automatically mapped to
  327. this single descriptor at startup. This selector is the recommened way to
  328. access DOS memory.
  329. \begin{verbatim}
  330. var int31error : Word;
  331. \end{verbatim}
  332. This variable holds the result of a DPMI interrupt call. Any nonzero value
  333. must be treated as a critical failure.
  334. \section{Functions and Procedures}
  335. \functionl{allocate\_ldt\_descriptors}{allocateldtdescriptors}{(count : Word)}{Word}
  336. {
  337. Allocates a number of new descriptors.
  338. Parameters:
  339. \begin{description}
  340. \item[count:\ ] specifies the number of requested unique descriptors
  341. \end{description}
  342. Return value: Base selector
  343. Notes: The descriptors allocated must be initialized by the application with
  344. other function calls. This function returns descriptors with a limit and
  345. size value set to zero. If more than one descriptor was requested, the
  346. function returns a base selector referencing the first of a contiguous array
  347. of descriptors. The selector values for subsequent descriptors in the array
  348. can be calculated by adding the value returned by the
  349. get\_next\_selector\_increment\_value() function.
  350. }
  351. {
  352. Check int31error variable
  353. }
  354. {
  355. \seefl{free\_ldt\_descriptor}{freeldtdescriptor},
  356. \seefl{get\_next\_selector\_increment\_value}{getnextselectorincrementvalue},
  357. \seefl{segment\_to\_descriptor}{segmenttodescriptor},
  358. \seefl{create\_code\_segment\_alias\_descriptor}{createcodesegmentaliasdescriptor},
  359. \seefl{set\_segment\_limit}{setsegmentlimit},
  360. \seefl{set\_segment\_base\_address}{setsegmentbaseaddress}
  361. }
  362. \input{go32ex/sel_des.tex}
  363. \functionl{free\_ldt\_descriptor}{freeldtdescriptor}{(des : Word)}{boolean}
  364. {
  365. Frees a previously allocated descriptor.
  366. Parameters:
  367. \begin{description}
  368. \item[des:\ ] The descriptor to be freed
  369. \end{description}
  370. Return value: True if successful, false otherwise.
  371. Notes: After this call this selector is invalid and must not be used for any
  372. memory operations anymore. Each descriptor allocated with
  373. allocate\_ltd\_descriptor() must be freed individually with this function,
  374. even if it was previously allocated as a part of a contiguous array of
  375. descriptors.
  376. }{
  377. Check int31error variable}{
  378. \seefl{allocate\_ldt\_descriptors}{allocateldtdescriptors},
  379. \seefl{get\_next\_selector\_increment\_value}{getnextselectorincrementvalue}
  380. }
  381. For an example, see
  382. \seefl{allocate\_ldt\_descriptors}{allocateldtdescriptors}.
  383. \functionl{segment\_to\_descriptor}{segmenttodescriptor}{(seg : Word)}{Word}
  384. {
  385. Maps a real mode segment (paragraph) address onto an descriptor that can be
  386. used by a protected mode program to access the same memory.
  387. Parameters:
  388. \begin{description}
  389. \item [seg:\ ] the real mode segment you want the descriptor to
  390. \end{description}
  391. Return values: Descriptor to real mode segment address.
  392. Notes: The returned descriptors limit will be set to 64 kB. Multiple calls
  393. to this function with the same segment address will return the same
  394. selector. Descriptors created by this function can never be modified or
  395. freed. Programs which need to examine various real mode addresses using the
  396. same selector should use the function allocate\_ldt\_descriptors() and change
  397. the base address as necessary.
  398. }{
  399. Check int31error variable.
  400. }
  401. {\seefl{allocate\_ldt\_descriptors}{allocateldtdescriptors},
  402. \seefl{free\_ldt\_descriptor}{freeldtdescriptor},
  403. \seefl{set\_segment\_base\_address}{setsegmentbaseaddress}
  404. }
  405. For an example, see \seepl{seg\_fillchar}{segfillchar}.
  406. \Functionl{get\_next\_selector\_increment\_value}
  407. {getnextselectorincrementvalue}{Word}
  408. {
  409. Returns the selector increment value when allocating multiple subsequent
  410. descriptors via \seefl{allocate\_ldt\_descriptors}{allocateldtdescriptors} .
  411. Parameters: none
  412. Return value: Selector increment value
  413. Notes: Because \seefl{allocate\_ldt\_descriptors}{allocateldtdescriptors} only returns the selector for the
  414. first descriptor and so the value returned by this function can be used to
  415. calculate the selectors for subsequent descriptors in the array.
  416. }
  417. {
  418. Check int31error variable
  419. }
  420. {
  421. \seefl{allocate\_ldt\_descriptors}{allocateldtdescriptors},
  422. \seefl{free\_ldt\_descriptor}{freeldtdescriptor}
  423. }
  424. \functionl{get\_segment\_base\_address}{getsegmentbaseaddress}{
  425. (d : Word)}{Longint}{
  426. Returns the 32-bit linear base address from the descriptor table for the
  427. specified segment.
  428. Parameters:
  429. \begin{description}
  430. \item[d:\ ] selector of the descriptor you want the base address
  431. \end{description}
  432. Return values: Linear base address of specified descriptor
  433. }
  434. {
  435. Check int31error variable.
  436. }
  437. {
  438. \seefl{allocate\_ldt\_descriptors}{allocateldtdescriptors},
  439. \seefl{set\_segment\_base\_address}{setsegmentbaseaddress},
  440. \seefl{allocate\_ldt\_descriptors}{allocateldtdescriptors},
  441. \seefl{set\_segment\_limit}{setsegmentlimit},
  442. \seefl{get\_segment\_limit}{getsegmentlimit}
  443. }
  444. For an example, see
  445. \seefl{allocate\_ldt\_descriptors}{allocateldtdescriptors}.
  446. \functionl{set\_segment\_base\_address}{setsegmentbaseaddress}
  447. {(d : Word; s : Longint)}{boolean}{
  448. Sets the 32-bit linear base address of a descriptor.
  449. Parameters:
  450. \begin{description}
  451. \item[d:\ ] selector s - new base address of the descriptor
  452. \end{description}
  453. }
  454. { Check int31error variable}
  455. {
  456. \seefl{allocate\_ldt\_descriptors}{allocateldtdescriptors},
  457. \seefl{get\_segment\_base\_address}{getsegmentbaseaddress},
  458. \seefl{allocate\_ldt\_descriptors}{allocateldtdescriptors},
  459. \seefl{set\_segment\_limit}{setsegmentlimit},
  460. \seefl{get\_segment\_base\_address}{getsegmentbaseaddress},
  461. \seefl{get\_segment\_limit}{getsegmentlimit}
  462. }
  463. For an example, see
  464. \seefl{allocate\_ldt\_descriptors}{allocateldtdescriptors}.
  465. \functionl{get\_segment\_limit}{getsegmentlimit}{(d : Word)}{Longint}{
  466. Returns a descriptors segment limit
  467. Parameters:
  468. \begin{description}
  469. \item [d:\ ] selector
  470. \end{description}
  471. Return value: Limit of the descriptor in bytes
  472. }{
  473. Returns zero if descriptor is invalid
  474. }
  475. {\seefl{allocate\_ldt\_descriptors}{allocateldtdescriptors},
  476. \seefl{set\_segment\_limit}{setsegmentlimit},
  477. \seefl{set\_segment\_base\_address}{setsegmentbaseaddress},
  478. \seefl{get\_segment\_base\_address}{getsegmentbaseaddress},
  479. }
  480. For an example, see
  481. \seefl{allocate\_ldt\_descriptors}{allocateldtdescriptors}.
  482. \functionl{set\_segment\_limit}{setsegmentlimit}{(d : Word; s : Longint)}{boolean}
  483. {
  484. Sets the limit of a descriptor.
  485. Parameters:
  486. \begin{description}
  487. \item[d:\ ] selector s - new limit of the descriptor
  488. \end{description}
  489. Return values: Returns true if successful, else false.
  490. Notes: The new limit specified must be the byte length of the segment - 1.
  491. Segment limits bigger than or equal to 1MB must be page aligned, they must
  492. have the lower 12 bits set.
  493. }
  494. {
  495. Check int31error variable
  496. }
  497. {\seefl{allocate\_ldt\_descriptors}{allocateldtdescriptors},
  498. \seefl{set\_segment\_base\_address}{setsegmentbaseaddress},
  499. \seefl{get\_segment\_limit}{getsegmentlimit},
  500. \seefl{set\_segment\_limit}{setsegmentlimit}
  501. }
  502. For an example, see
  503. \seefl{allocate\_ldt\_descriptors}{allocateldtdescriptors}.
  504. \functionl{set\_descriptor\_access\_rights}{setdescriptoraccessrights}
  505. {(d : Word; w : Word)}{Longint}
  506. {
  507. Sets the access rights of a descriptor
  508. Parameters:
  509. \begin{description}
  510. \item[d:\ ] selector w - new descriptor access rights
  511. \end{description}
  512. Return values: This function doesn't return anything useful.
  513. }
  514. { Check int31error variable}
  515. {
  516. \seefl{get\_descriptor\_access\_rights}{getdescriptoraccessrights} }
  517. \functionl{get\_descriptor\_access\_rights}{getdescriptoraccessrights}
  518. {(d : Word)}{Longint}
  519. {
  520. Gets the access rights of a descriptor
  521. Parameters:
  522. \begin{description}
  523. \item{d} selector to descriptor
  524. \end{description}
  525. }{
  526. Return value: Access rights bit field
  527. }
  528. {Check int31error variable}{
  529. \seefl{set\_descriptor\_access\_rights}{setdescriptoraccessrights}}
  530. \functionl{create\_code\_segment\_alias\_descriptor}
  531. {createcodesegmentaliasdescriptor}{(seg : Word)}{Word}
  532. {
  533. Creates a new descriptor that has the same base and limit as the specified
  534. descriptor.
  535. Parameters:
  536. \begin{description}
  537. \item[seg:\ ] selector
  538. \end{description}
  539. Return values: Data selector (alias)
  540. Notes: In effect, the function returns a copy of the descriptor. The
  541. descriptor alias returned by this function will not track changes to the
  542. original descriptor. In other words, if an alias is created with this
  543. function, and the base or limit of the original segment is then changed, the
  544. two descriptors will no longer map the same memory.
  545. }
  546. { Check int31error variable}
  547. {
  548. \seefl{allocate\_ldt\_descriptors}{allocateldtdescriptors},
  549. \seefl{set\_segment\_limit}{setsegmentlimit},
  550. \seefl{set\_segment\_base\_address}{setsegmentbaseaddress} }
  551. \functionl{get\_meminfo}{getmeminfo}
  552. {(var meminfo : tmeminfo)}
  553. {boolean}{
  554. Returns information about the amount of available physical memory, linear
  555. address space, and disk space for page swapping.
  556. Parameters:
  557. \begin{description}
  558. \item[meminfo:\ ] buffer to fill memory information into
  559. \end{description}
  560. Return values: Due to an implementation bug this function always returns
  561. false, but it always succeeds.
  562. Notes: Only the first field of the returned structure is guaranteed to
  563. contain a valid value. Any fields that are not supported by the DPMI host
  564. will be set by the host to -1 (0FFFFFFFFH) to indicate that the information
  565. is not available. The size of the pages used by the DPMI host can be
  566. obtained with the \seefl{get\_page\_size}{getpagesize} function.
  567. }
  568. {Check the int31error variable}
  569. {\seefl{get\_page\_size}{getpagesize} }
  570. \input{go32ex/meminfo.tex}
  571. \functionl{allocate\_memory\_block}{allocatememoryblock}
  572. {(size:Longint)}{Longint}{
  573. Allocates a block of linear memory.
  574. Parameters:
  575. \begin{description}
  576. \item[size:\ ] Size of requested linear memory block in bytes
  577. \end{description}
  578. Returned values: blockhandle - the memory handle to this memory block Linear
  579. ?? address of
  580. the requested memory.
  581. Notes: WARNING: According to my DPMI docs this function is not implemented
  582. correctly. Normally you should also get a blockhandle to this block after
  583. successful operation. This handle is used to free the memory block
  584. afterwards or use this handle for other purposes. So this block can't be
  585. deallocated and is henceforth unusuable !
  586. This function doesn't allocate any descriptors for this block, it's the
  587. applications resposibility to allocate and initialize for accessing this
  588. memory.
  589. }{ Check int31error variable}{
  590. \seefl{free\_memory\_block}{freememoryblock} }
  591. \functionl{free\_memory\_block}{freememoryblock}{(blockhandle :
  592. Longint)}{boolean}{
  593. Frees a previously allocated memory block
  594. Parameters:
  595. \begin{description}
  596. \item{blockhandle:} the handle to the memory area to free
  597. \end{description}
  598. Return value: True if successful, false otherwise.
  599. Notes: Frees memory that was previously allocated with
  600. \seefl{allocate\_memory\_block}{allocatememoryblock} . This function doesn't free any descriptors mapped
  601. to this block, it's the application's responsibility.
  602. }
  603. { Check int31error variable}
  604. {\seefl{allocate\_memory\_block}{allocatememoryblock} }
  605. %\functionl{request\_linear\_region}{requestlinearregion}
  606. %{(linearaddr, size : Longint; var blockhandle : Longint)}{boolean}
  607. %{
  608. %DOESN'T WORK AT ALL, AND WON'T IN THE FUTURE BECAUSE IT IS A DPMI 1.0
  609. %FUNCTION !!!!!!! (a good reason to skip this description)
  610. %
  611. %\functionl{map\_device\_in\_memory\_block}{mapdeviceinmemoryblock}{(handle, offset, pagecount, device :}
  612. %Longint) : boolean;
  613. %
  614. %!!!!!! DOESN'T WORK AT ALL, AND WON'T IN THE FUTURE BECAUSE IT IS A DPMI 1.0
  615. %!!!!!! FUNCTION !!!!!!! (a good reason to skip this description)
  616. \functionl{get\_linear\_addr}{getlinearaddr}
  617. {(phys\_addr : Longint; size : Longint)}{Longint}
  618. {
  619. Converts a physical address into a linear address.
  620. Parameters:
  621. \begin{description}
  622. \item [phys\_addr:\ ] - physical address of device size - size of region to
  623. map in bytes
  624. \end{description}
  625. Return value: Linear address that can be used to access the physical memory.
  626. Notes: It's the applications resposibility to allocate and set up a
  627. descriptor for access to the memory. This function shouldn't be used to map
  628. real mode addresses.
  629. }
  630. { Check int31error variable.}
  631. {
  632. \seefl{allocate\_ldt\_descriptors}{allocateldtdescriptors}, \seefl{set\_segment\_limit}{setsegmentlimit},
  633. \seefl{set\_segment\_base\_address}{setsegmentbaseaddress} }
  634. \functionl{global\_dos\_alloc}{globaldosalloc}
  635. {(bytes : Longint)}{Longint}
  636. {
  637. Allocates a block of DOS real mode memory
  638. Parameters:
  639. \begin{description}
  640. \item [bytes:\ ] size of requested real mode memory
  641. \end{description}
  642. Return values: The high word of the returned value contains the selector to
  643. the allocated DOS memory block, the low word the corresponding real mode
  644. segment value. The offset value is always zero.
  645. This function allocates memory from DOS memory pool, i.e. memory below the 1
  646. MB boundary that is controlled by DOS. Such memory blocks are typically used
  647. to exchange data with real mode programs, TSRs, or device drivers. The
  648. function returns both the real mode segment base address of the block and
  649. one descriptor that can be used by protected mode applications to access the
  650. block. This function should only used for temporary buffers to get real mode
  651. information (e.g. interrupts that need a data structure in ES:(E)DI),
  652. because every single block needs an unique selector. The returned selector
  653. should only be freed by a \seefl{global\_dos\_free}{globaldosfree} call.
  654. }{ Check int31error variable}
  655. { \seefl{global\_dos\_free}{globaldosfree} }
  656. \input{go32ex/buffer.tex}
  657. \functionl{global\_dos\_free}{globaldosfree}{(selector :
  658. Word)}{boolean}{
  659. Frees a previously allocated DOS memory block
  660. Parameters:
  661. \begin{description}
  662. \item[selector:\ ] selector to the DOS memory block
  663. \end{description}
  664. Return value: True if successful, false otherwise
  665. Notes: The descriptor allocated for the memory block is automatically freed
  666. and hence invalid for further use. This function should only be used for
  667. memory allocated by \seefl{global\_dos\_alloc}{globaldosalloc} .
  668. }
  669. { Check int31error variable}
  670. {\seefl{global\_dos\_alloc}{globaldosalloc} }
  671. For an example, see \seefl{global\_dos\_alloc}{globaldosalloc}.
  672. \procedure{dosmemput}{(seg : Word; ofs : Word; var data; count : Longint)}{
  673. Copies heap data to DOS real mode memory.
  674. Parameters:
  675. \begin{description}
  676. \item[seg:\ ] destination real mode segment
  677. \item[ofs:\ ] destination real mode offset
  678. \item[data:\ ] source
  679. \item[count:\ ] number of bytes to copy
  680. \end{description}
  681. Return value: none
  682. Notes: No range checking is performed.
  683. }{ none }
  684. {\seep{dosmemget},
  685. \seep{dosmemmove},
  686. \seep{dosmemfillchar},
  687. \seep{dosmemfillword},
  688. \seepl{seg\_move}{segmove},
  689. \seepl{seg\_fillchar}{segfillchar},
  690. \seepl{seg\_fillword}{segfillword} }
  691. For an example, see \seefl{global\_dos\_alloc}{globaldosalloc}.
  692. \procedure{dosmemget}{(seg : Word; ofs : Word; var data; count : Longint)}{
  693. Copies data from the DOS memory onto the heap.
  694. Parameters:
  695. \begin{description}
  696. \item[seg:\ ] source real mode segment
  697. \item[ofs:\ ] source real mode offset
  698. \item[data:\ ] destination
  699. \item[count:\ ] number of bytes to copy
  700. \end{description}
  701. Notes: No range checking is performed.
  702. }{ none }
  703. {
  704. \seep{dosmemput},
  705. \seep{dosmemmove},
  706. \seep{dosmemfillchar},
  707. \seep{dosmemfillword},
  708. \seepl{seg\_move}{segmove},
  709. \seepl{seg\_fillchar}{segfillchar},
  710. \seepl{seg\_fillword}{segfillword} }
  711. For an example, see \seefl{global\_dos\_alloc}{globaldosalloc}.
  712. \procedure{dosmemmove}{(sseg, sofs, dseg, dofs : Word; count : Longint)}
  713. {
  714. Copies count bytes of data between two DOS real mode memory locations.
  715. Parameters:
  716. \begin{description}
  717. \item[sseg:\ ] source real mode segment
  718. \item[sofs:\ ] source real mode offset
  719. \item[dseg:\ ] destination real mode segment
  720. \item[dofs:\ ] destination real mode offset
  721. \item[count:\ ] number of bytes to copy
  722. \end{description}
  723. Return values: none
  724. Notes: No range check is performed in any way.
  725. }
  726. { none}
  727. {
  728. \seep{dosmemput},
  729. \seep{dosmemget},
  730. \seep{dosmemfillchar},
  731. \seep{dosmemfillword}
  732. \seepl{seg\_move}{segmove},
  733. \seepl{seg\_fillchar}{segfillchar},
  734. \seepl{seg\_fillword}{segfillword} }
  735. For an example, see \seepl{seg\_fillchar}{segfillchar}.
  736. \procedure{dosmemfillchar}{(seg, ofs : Word; count : Longint; c : char)}{
  737. Sets a region of DOS memory to a specific byte value
  738. Parameters:
  739. \begin{description}
  740. \item[seg:\ ] real mode segment
  741. \item[ofs:\ ] real mode offset
  742. \item[count:\ ] number of bytes to set
  743. \item[c:\ ] value to set memory to
  744. \end{description}
  745. Return values: none
  746. Notes: No range check is performed.
  747. }
  748. { none
  749. }{
  750. \seep{dosmemput},
  751. \seep{dosmemget},
  752. \seep{dosmemmove}{dosmemmove},
  753. \seepl{dosmemfillword}{dosmemfillword},
  754. \seepl{seg\_move}{segmove},
  755. \seepl{seg\_fillchar}{segfillchar},
  756. \seepl{seg\_fillword}{segfillword} }
  757. \input{go32ex/textmess.tex}
  758. \procedure{dosmemfillword}{(seg,ofs : Word; count : Longint; w : Word)}
  759. {
  760. Sets a region of DOS memory to a specific word value
  761. Parameters:
  762. \begin{description}
  763. \item[seg:\ ] real mode segment
  764. \item[ofs:\ ] real mode offset
  765. \item[count:\ ] number of words to set
  766. \item[w:\ ] value to set memory to
  767. \end{description}
  768. Return values: none
  769. Notes: No range check is performed.
  770. }
  771. { none}{
  772. \seep{dosmemput},
  773. \seepl{dosmemget}{dosmemget},
  774. \seepl{dosmemmove}{dosmemmove},
  775. \seepl{dosmemfillchar}{dosmemfillchar},
  776. \seepl{seg\_move}{segmove},
  777. \seepl{seg\_fillchar}{segfillchar},
  778. \seepl{seg\_fillword}{segfillword} }
  779. \functionl{get\_rm\_interrupt}{getrminterrupt}{(vector : byte; var intaddr :
  780. tseginfo)}{boolean}
  781. {
  782. Returns the contents of the current machine's real mode interrupt vector for
  783. the specified interrupt.
  784. Parameters:
  785. \begin{description}
  786. \item[vector:\ ] interrupt vector number
  787. \item[intaddr:\ ] buffer to store real mode segment:offset address
  788. \end{description}
  789. Return values: True if successful, false otherwise
  790. Notes: The returned address is a real mode segment address, which isn't
  791. valid in protected mode.
  792. }
  793. { Check int31error variable
  794. }{
  795. \seefl{set\_rm\_interrupt}{setrminterrupt},
  796. \seefl{set\_pm\_interrupt}{setpminterrupt},
  797. \seefl{get\_pm\_interrupt}{getpminterrupt} }
  798. \functionl{set\_rm\_interrupt}{setrminterrupt}{(vector : byte; const intaddr :
  799. tseginfo)}{boolean}{
  800. Sets a real mode interrupt handler
  801. Parameters:
  802. \begin{description}
  803. \item[vector:\ ] the interrupt vector number to set
  804. \item[intaddr:\ ] address of new interrupt vector
  805. \end{description}
  806. Return values: True if successful, otherwise false.
  807. Notes: The address supplied MUST be a real mode segment address, not a
  808. selector:offset address. So the interrupt handler must either reside in DOS
  809. memory (below 1 Mb boundary) or the application must allocate a real mode
  810. callback address with \seefl{get\_rm\_callback}{getrmcallback} .
  811. }
  812. { Check int31error variable }
  813. {
  814. \seefl{get\_rm\_interrupt}{getrminterrupt},
  815. \seefl{set\_pm\_interrupt}{setpminterrupt}, \seefl{get\_pm\_interrupt}{getpminterrupt},
  816. \seefl{get\_rm\_callback}{getrmcallback} }
  817. \functionl{get\_pm\_interrupt}{getpminterrupt}
  818. {(vector : byte; var intaddr : tseginfo)}{boolean}{
  819. Returns the address of a current protected mode interrupt handler
  820. Parameters:
  821. \begin{description}
  822. \item[vector:\ ] interrupt handler number you want the address to
  823. \item[intaddr:\ ] buffer to store address
  824. \end{description}
  825. Return values: True if successful, false if not.
  826. Notes: The returned address is a protected mode selector:offset address.
  827. }
  828. { Check int31error variable}
  829. { \seefl{set\_pm\_interrupt}{setpminterrupt},
  830. \seefl{set\_rm\_interrupt}{setrminterrupt}, \seefl{get\_rm\_interrupt}{getrminterrupt} }
  831. For an example, see \seefl{set\_pm\_interrupt}{setpminterrupt}.
  832. \functionl{set\_pm\_interrupt}{setpminterrupt}
  833. {(vector : byte; const intaddr : tseginfo)}{boolean}{
  834. Sets the address of the protected mode handler for an interrupt
  835. Parameters:
  836. \begin{description}
  837. \item[vector:\ ] number of protected mode interrupt to set
  838. \item[intaddr:\ ] selector:offset address to the interrupt vector
  839. \end{description}
  840. Return values: True if successful, false otherwise.
  841. Notes: The address supplied must be a valid selector:offset protected mode
  842. address.
  843. }
  844. { Check int31error variable
  845. }{\seefl{get\_pm\_interrupt}{getpminterrupt},
  846. \seefl{set\_rm\_interrupt}{setrminterrupt},
  847. \seefl{get\_rm\_interrupt}{getrminterrupt} }
  848. \input{go32ex/int_pm.tex}
  849. \Procedure{disable}{
  850. Disables all hardware interrupts by execution a CLI instruction.
  851. Parameters: none
  852. Return values: none
  853. }{none }
  854. {\seep{enable} }
  855. \Procedure{enable}{
  856. Enables all hardware interrupts by executing a STI instruction.
  857. Parameters: none
  858. Return values: none
  859. }{None}
  860. { \seep{disable} }
  861. \function{realintr}{(intnr: Word; var regs : trealregs)}{ boolean}{
  862. Simulates an interrupt in real mode
  863. Parameters:
  864. \begin{description}
  865. \item[intnr:\ ] interrupt number to issue in real mode
  866. \item[regs:\ ] registers data structure
  867. \end{description}
  868. Return values: The supplied registers data structure contains the values
  869. that were returned by the real mode interrupt. True if successful, false if
  870. not.
  871. Notes: The function transfers control to the address specified by the real
  872. mode interrupt vector of intnr. The real mode handler must return by
  873. executing an IRET.
  874. }
  875. { Check int31error variable
  876. }{}
  877. %For an example, see \seefl{global\_dos\_alloc}{globaldosalloc}.
  878. \input{go32ex/flags.tex}
  879. \functionl{get\_rm\_callback}{getrmcallback}
  880. {(pm\_func : pointer; const reg : trealregs; var rmcb: tseginfo)}{boolean}
  881. {
  882. Returns a unique real mode segment:offset address, known as a "real mode
  883. callback," that will transfer control from real mode to a protected mode
  884. procedure.
  885. Parameters:
  886. \begin{description}
  887. \item[pm\_func:\ ] pointer to the protected mode callback function
  888. \item[reg:\ ] supplied registers structure
  889. \item[rmcb:\ ] buffer to real mode address of callback function
  890. \end{description}
  891. Return values: True if successful, otherwise false.
  892. Notes: Callback addresses obtained with this function can be passed by a
  893. protected mode program for example to an interrupt handler, device driver,
  894. or TSR, so that the real mode program can call procedures within the
  895. protected mode program or notify the protected mode program of an event. The
  896. contents of the supplied regs structure is not valid after function call,
  897. but only at the time of the actual callback.
  898. }{Check int31error variable}
  899. {\seefl{free\_rm\_callback}{freermcallback} }
  900. \input{go32ex/callback.tex}
  901. \functionl{free\_rm\_callback}{freermcallback}{(var intaddr : tseginfo)}{boolean}
  902. {
  903. Releases a real mode callback address that was previously allocated with the
  904. \seefl{get\_rm\_callback}{getrmcallback} function.
  905. Parameters:
  906. \begin{description}
  907. \item[intaddr:\ ] real mode address buffer returned by
  908. \seefl{get\_rm\_callback}{getrmcallback}
  909. \end{description}
  910. Return values: True if successful, false if not
  911. }{ Check int31error variable }
  912. {
  913. \seefl{set\_rm\_interrupt}{setrminterrupt},
  914. \seefl{get\_rm\_callback}{getrmcallback}
  915. }
  916. For an example, see \seefl{get\_rm\_callback}{getrmcallback}.
  917. \functionl{lock\_linear\_region}{locklinearregion}{(linearaddr, size : Longint)}{boolean}
  918. {
  919. Locks a memory region to prevent swapping of it
  920. Parameters:
  921. \begin{description}
  922. \item[linearaddr:\ ] the linear address of the memory are to be locked
  923. \item[size:\ ] size in bytes to be locked
  924. \end{description}
  925. Return value: True if successful, False otherwise
  926. }
  927. { Check int31error variable}
  928. {
  929. \seefl{lock\_data}{lockdata},
  930. \seefl{lock\_code}{lockcode},
  931. \seefl{unlock\_linear\_region}{unlocklinearregion},
  932. \seefl{unlock\_data}{unlockdata},
  933. \seefl{unlock\_code}{unlockcode}}
  934. \functionl{lock\_data}{lockdata}{(var data; size : Longint)}{boolean}
  935. {
  936. Locks a memory range which resides in the data segment selector
  937. Parameters:
  938. \begin{description}
  939. \item[data:\ ] address of data to be locked
  940. \item[size:\ ] length of data to be locked
  941. \end{description}
  942. Return values: True if successful, false otherwise
  943. }
  944. { Check int31error variable}{
  945. \seefl{lock\_linear\_region}{locklinearregion},
  946. \seefl{lock\_code}{lockcode},
  947. \seefl{unlock\_linear\_region}{unlocklinearregion},
  948. \seefl{unlock\_data}{unlockdata},
  949. \seefl{unlock\_code}{unlockcode} }
  950. For an example, see \seefl{get\_rm\_callback}{getrmcallback}.
  951. \functionl{lock\_code}{lockcode}{(functionaddr : pointer; size : Longint)}
  952. {boolean}{
  953. Locks a memory range which is in the code segment selector.
  954. Parameters:
  955. \begin{description}
  956. \item[functionaddr:\ ] address of the function to be lockd
  957. \item[size:\ ] size in bytes to be locked
  958. \end{description}
  959. Return values: True if successful, false otherwise
  960. }{Check int31error variable}{
  961. \seefl{lock\_linear\_region}{locklinearregion},
  962. \seefl{lock\_data}{lockdata},
  963. \seefl{unlock\_linear\_region}{unlocklinearregion},
  964. \seefl{unlock\_data}{unlockdata},
  965. \seefl{unlock\_code}{unlockcode} }
  966. For an example, see \seefl{get\_rm\_callback}{getrmcallback}.
  967. \functionl{unlock\_linear\_region}{unlocklinearregion}
  968. {(linearaddr, size : Longint)}{boolean}{
  969. Unlocks a previously locked linear region range to allow it to be swapped
  970. out again if needed.
  971. Parameters:
  972. \begin{description}
  973. \item[linearaddr:\ ] linear address of the memory to be unlocked
  974. \item[size:\ ] size bytes to be unlocked
  975. \end{description}
  976. Return values: True if successful, false otherwise
  977. }
  978. { Check int31error variable}{
  979. \seefl{unlock\_data}{unlockdata},
  980. \seefl{unlock\_code}{unlockcode},
  981. \seefl{lock\_linear\_region}{locklinearregion},
  982. \seefl{lock\_data}{lockdata},
  983. \seefl{lock\_code}{lockcode}}
  984. \functionl{unlock\_data}{unlockdata}{(var data; size : Longint)}{boolean}
  985. {
  986. Unlocks a memory range which resides in the data segment selector.
  987. Paramters:
  988. \begin{description}
  989. \item[data:\ ] address of memory to be unlocked
  990. \item[size:\ ] size bytes to be unlocked
  991. \end{description}
  992. Return values: True if successful, false otherwise
  993. }
  994. { Check int31error variable
  995. }{
  996. \seefl{unlock\_linear\_region}{unlocklinearregion},
  997. \seefl{unlock\_code}{unlockcode},
  998. \seefl{lock\_linear\_region}{locklinearregion},
  999. \seefl{lock\_data}{lockdata},
  1000. \seefl{lock\_code}{lockcode} }
  1001. For an example, see \seefl{get\_rm\_callback}{getrmcallback}.
  1002. \functionl{unlock\_code}{unlockcode}
  1003. {(functionaddr : pointer; size : Longint)}{boolean}
  1004. {
  1005. Unlocks a memory range which resides in the code segment selector.
  1006. Parameters:
  1007. \begin{description}
  1008. \item[functionaddr:\ ] address of function to be unlocked
  1009. \item[size:\ ] size bytes to be unlocked
  1010. \end{description}
  1011. Return value: True if successful, false otherwise
  1012. }
  1013. { Check int31error variable }
  1014. {\seefl{unlock\_linear\_region}{unlocklinearregion},
  1015. \seefl{unlock\_data}{unlockdata},
  1016. \seefl{lock\_linear\_region}{locklinearregion},
  1017. \seefl{lock\_data}{lockdata},
  1018. \seefl{lock\_code}{lockcode} }
  1019. For an example, see \seefl{get\_rm\_callback}{getrmcallback}.
  1020. \Functionl{get\_page\_size}{getpagesize}{ Longint}
  1021. {
  1022. Returns the size of a single memory page
  1023. Return value: Size of a single page in bytes
  1024. Notes: The returned size is typically 4096 bytes.
  1025. }
  1026. { Check int31error variable
  1027. }{ \seefl{get\_meminfo}{getmeminfo} }
  1028. For an example, see \seefl{get\_meminfo}{getmeminfo}.
  1029. \procedurel{seg\_move}{segmove}{(sseg : Word; source : Longint; dseg : Word; dest :
  1030. Longint; count : Longint)}{
  1031. Copies data between two memory locations
  1032. Parameters:
  1033. \begin{description}
  1034. \item[sseg:\ ] source selector
  1035. \item[source:\ ] source offset
  1036. \item[dseg:\ ] destination selector
  1037. \item[dest:\ ] destination offset
  1038. \item[count:\ ] size in bytes to copy
  1039. \end{description}
  1040. Return values: none
  1041. Notes: Overlapping is only checked if the source selector is equal to the
  1042. destination selector. No range check is done.
  1043. }
  1044. { none}
  1045. {
  1046. \seepl{seg\_fillchar}{segfillchar},
  1047. \seepl{seg\_fillword}{segfillword},
  1048. \seepl{dosmemfillchar}{dosmemfillchar},
  1049. \seepl{dosmemfillword}{dosmemfillword},
  1050. \seepl{dosmemget}{dosmemget},
  1051. \seepl{dosmemput}{dosmemput},
  1052. \seepl{dosmemmove}{dosmemmove} }
  1053. For an example, see
  1054. \seefl{allocate\_ldt\_descriptors}{allocateldtdescriptors}.
  1055. \procedurel{seg\_fillchar}{segfillchar}
  1056. {(seg : Word; ofs : Longint; count : Longint; c : char)}{
  1057. Sets a memory area to a specific value.
  1058. Parameters:
  1059. \begin{description}
  1060. \item[seg:\ ] selector to memory area
  1061. \item[ofs:\ ] offset to memory
  1062. \item[count:\ ] number of bytes to set
  1063. \item[c:\ ] byte data which is set
  1064. \end{description}
  1065. Return values: none
  1066. Notes: No range check is done in any way.
  1067. }{ none }
  1068. {\seepl{seg\_move}{segmove},
  1069. \seepl{seg\_fillword}{segfillword},
  1070. \seepl{dosmemfillchar}{dosmemfillchar},
  1071. \seepl{dosmemfillword}{dosmemfillword},
  1072. \seepl{dosmemget}{dosmemget},
  1073. \seepl{dosmemput}{dosmemput},
  1074. \seepl{dosmemmove}{dosmemmove} }
  1075. \input{go32ex/vgasel.tex}
  1076. \procedurel{seg\_fillword}{segfillword}
  1077. {(seg : Word; ofs : Longint; count : Longint; w :Word)}
  1078. {
  1079. Sets a memory area to a specific value.
  1080. Parameters:
  1081. \begin{description}
  1082. \item[seg:\ ] selector to memory area
  1083. \item[ofs:\ ] offset to memory
  1084. \item[count:\ ] number of words to set
  1085. \item[w:\ ] word data which is set
  1086. \end{description}
  1087. Return values: none
  1088. Notes: No range check is done in any way.
  1089. }{none }
  1090. {
  1091. \seepl{seg\_move}{segmove},
  1092. \seepl{seg\_fillchar}{segfillchar},
  1093. \seepl{dosmemfillchar}{dosmemfillchar},
  1094. \seepl{dosmemfillword}{dosmemfillword},
  1095. \seepl{dosmemget}{dosmemget},
  1096. \seepl{dosmemput}{dosmemput},
  1097. \seepl{dosmemmove}{dosmemmove} }
  1098. For an example, see
  1099. \seefl{allocate\_ldt\_descriptors}{allocateldtdescriptors}.
  1100. \Functionl{get\_cs}{getcs}{Word}{
  1101. Returns the cs selector
  1102. Parameters: none
  1103. Return values: The content of the cs segment register
  1104. }{none}{ \seefl{get\_ds}{getds}, \seefl{get\_ss}{getss}}
  1105. For an example, see \seefl{set\_pm\_interrupt}{setpminterrupt}.
  1106. \Functionl{get\_ds}{getds}{Word}
  1107. {
  1108. Returns the ds selector
  1109. Parameters: none
  1110. Return values: The content of the ds segment register
  1111. }{ none}{ \seefl{get\_cs}{getcs}, \seefl{get\_ss}{getss}}
  1112. \Functionl{get\_ss}{getss}{Word}{
  1113. Returns the ss selector
  1114. Parameters: none
  1115. Return values: The content of the ss segment register
  1116. }{ none}{ \seefl{get\_ds}{getds}, \seefl{get\_cs}{getcs}}
  1117. \function{inportb}{(port : Word)}{byte}{
  1118. Reads data from the selected I/O port
  1119. Parameters:
  1120. \begin{description}
  1121. \item[port:\ ] the I/O port number which is read
  1122. \end{description}
  1123. Return values: Current I/O port value
  1124. Notes: The returned data is either be byte, word or longint sized, dependant
  1125. of the function.
  1126. }{ none }{\seep{outportb}, \seef{inportw}, \seef{inportl}}
  1127. \function{inportw}{(port : Word)}{Word}{
  1128. Reads data from the selected I/O port
  1129. Parameters:
  1130. \begin{description}
  1131. \item[port:\ ] the I/O port number which is read
  1132. \end{description}
  1133. Return values: Current I/O port value
  1134. Notes: The returned data is either be byte, word or longint sized, dependant
  1135. of the function.
  1136. }{ none }{\seep{outportw} \seef{inportb}, \seef{inportl} }
  1137. \function{inportl}{(port : Word)}{Longint}{
  1138. Reads data from the selected I/O port
  1139. Parameters:
  1140. \begin{description}
  1141. \item[port:\ ] the I/O port number which is read
  1142. \end{description}
  1143. Return values: Current I/O port value
  1144. Notes: The returned data is either be byte, word or longint sized, dependant
  1145. of the function.
  1146. }{none }{\seep{outportb}, \seef{inportb}, \seef{inportw} }
  1147. \procedure{outportb}{(port : Word; data : byte)}{
  1148. Sends data to the specified I/O port
  1149. Parameters:
  1150. \begin{description}
  1151. \item[port:\ ] the I/O port number to send data to
  1152. \item[data:\ ] value sent to I/O port
  1153. \end{description}
  1154. Return values: none
  1155. }{ none }{\seef{inportb}, \seep{outportl}, \seep{outportw} }
  1156. input{go32ex/outport.tex}
  1157. \procedure{outportw}{(port : Word; data : Word)}{
  1158. Sends data to the specified I/O port
  1159. Parameters:
  1160. \begin{description}
  1161. \item[port:\ ] the I/O port number to send data to
  1162. \item[data:\ ] value sent to I/O port
  1163. \end{description}
  1164. Return values: none
  1165. }{ none }
  1166. {\seef{inportw}, \seep{outportl}, \seep{outportb}}
  1167. For an example, see \seep{outportb}.
  1168. \procedure{outportl}{(port : Word; data : Longint)}{
  1169. Sends data to the specified I/O port
  1170. Parameters:
  1171. \begin{description}
  1172. \item[port:\ ] the I/O port number to send data to
  1173. \item[data:\ ] value sent to I/O port
  1174. \end{description}
  1175. Return values: none
  1176. }{none }{\seef{inportl}, \seep{outportw}, \seep{outportb}}
  1177. For an example, see \seep{outportb}.
  1178. \Functionl{get\_run\_mode}{getrunmode}{Word}{
  1179. Returns the current mode your application runs with
  1180. Return values: One of the constants used by this function
  1181. }
  1182. {none }
  1183. { constants returned by \seefl{get\_run\_mode}{getrunmode} }
  1184. \input{go32ex/getrunmd.tex}