exec.pas 56 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558
  1. {
  2. This file is part of the Free Pascal run time library.
  3. A file in Amiga system run time library.
  4. Copyright (c) 1998-2000 by Nils Sjoholm
  5. member of the Amiga RTL development team.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. {
  13. History:
  14. Added overlay functions for Pchar->Strings, functions
  15. and procedures. Now you can mix PChar and Strings e.g
  16. OpenLibrary('whatis.library',37). No need to cast to
  17. a PChar.
  18. 12 Oct 1998.
  19. More missing functions added.
  20. Added BitMask,
  21. IsListEmpty and
  22. IsMsgPortEmpty.
  23. 22 Aug 2000.
  24. Bug found in
  25. AllocSignal,
  26. OpenDevice,
  27. SetTaskPri,
  28. WaitIO
  29. and DoIO.
  30. The stubs for this functions push a long for result,
  31. the result was defined as a shortint. If you tried
  32. to use any of those functions you get a big crash.
  33. Just changed the result to a longint.
  34. 06 Sep 2000.
  35. Fixed the above functions so that they return a
  36. shortint as they should. Made some changes to the
  37. stub.
  38. 20 Sep 2000.
  39. Put together exec.pp and exec.inc.
  40. 04 Feb 2003.
  41. Update for AmigaOS 3.9.
  42. Added some consts and a record.
  43. Functions added.
  44. PROCEDURE NewMinList
  45. FUNCTION AVL_AddNode
  46. FUNCTION AVL_RemNodeByAddress
  47. FUNCTION AVL_RemNodeByKey
  48. FUNCTION AVL_FindNode
  49. FUNCTION AVL_FindPrevNodeByAddress
  50. FUNCTION AVL_FindPrevNodeByKey
  51. FUNCTION AVL_FindNextNodeByAddress
  52. FUNCTION AVL_FindNextNodeByKey
  53. FUNCTION AVL_FindFirstNode
  54. FUNCTION AVL_FindLastNode
  55. 05 Feb 2003.
  56. Changed integer > smallint.
  57. Retyped ULONG to longword
  58. 09 Feb 2003.
  59. [email protected]
  60. }
  61. {$PACKRECORDS 2}
  62. UNIT EXEC;
  63. INTERFACE
  64. {
  65. History:
  66. Added BOOL = smallint, some libraries need that define
  67. (read triton, wizard)
  68. 25 Oct 1998
  69. Added UWORD, WORDBITS, LONGBITS, PLONGBITS,
  70. UBYTE, PULONG, PAPTR, PLONG.
  71. For use with MUI.
  72. 17 Jul 2000.
  73. [email protected]
  74. }
  75. TYPE
  76. STRPTR = PChar;
  77. ULONG = Longword;
  78. LONG = longint;
  79. APTR = Pointer;
  80. BPTR = Longint;
  81. BSTR = Longint;
  82. BOOL = smallint;
  83. UWORD = Word;
  84. WORDBITS = Word;
  85. LONGBITS = longword;
  86. PLONGBITS = ^LONGBITS;
  87. UBYTE = Byte;
  88. PULONG = ^longword;
  89. PAPTR = ^APTR;
  90. PLONG = ^LONG;
  91. const
  92. {There is a problem with boolean
  93. vaules in taglists, just use this
  94. for now instead}
  95. ltrue : longint = 1;
  96. lfalse : longint = 0;
  97. TYPE
  98. { * List Node Structure. Each member in a list starts with a Node * }
  99. pNode = ^tNode;
  100. tNode = Record
  101. ln_Succ, { * Pointer to next (successor) * }
  102. ln_Pred : pNode; { * Pointer to previous (predecessor) * }
  103. ln_Type : Byte;
  104. ln_Pri : Shortint; { * Priority, for sorting * }
  105. ln_Name : STRPTR; { * ID string, null terminated * }
  106. End; { * Note: smallint aligned * }
  107. { * minimal node -- no type checking possible * }
  108. pMinNode = ^tMinNode;
  109. tMinNode = Record
  110. mln_Succ,
  111. mln_Pred : pMinNode;
  112. End;
  113. { *
  114. ** Note: Newly initialized IORequests, and software interrupt structures
  115. ** used with Cause(), should have type NT_UNKNOWN. The OS will assign a type
  116. ** when they are first used.
  117. * }
  118. { *----- Node Types for LN_TYPE -----* }
  119. Const
  120. NT_UNKNOWN = 0;
  121. NT_TASK = 1; { * Exec task * }
  122. NT_INTERRUPT = 2;
  123. NT_DEVICE = 3;
  124. NT_MSGPORT = 4;
  125. NT_MESSAGE = 5; { * Indicates message currently pending * }
  126. NT_FREEMSG = 6;
  127. NT_REPLYMSG = 7; { * Message has been replied * }
  128. NT_RESOURCE = 8;
  129. NT_LIBRARY = 9;
  130. NT_MEMORY = 10;
  131. NT_SOFTINT = 11; { * Internal flag used by SoftInits * }
  132. NT_FONT = 12;
  133. NT_PROCESS = 13; { * AmigaDOS Process * }
  134. NT_SEMAPHORE = 14;
  135. NT_SIGNALSEM = 15; { * signal semaphores * }
  136. NT_BOOTNODE = 16;
  137. NT_KICKMEM = 17;
  138. NT_GRAPHICS = 18;
  139. NT_DEATHMESSAGE = 19;
  140. NT_USER = 254; { * User node types work down from here * }
  141. NT_EXTENDED = 255;
  142. {
  143. This file defines Exec system lists, which are used to link
  144. various things. Exec provides several routines to handle list
  145. processing (defined at the bottom of this file), so you can
  146. use these routines to save yourself the trouble of writing a list
  147. package.
  148. }
  149. Type
  150. { normal, full featured list }
  151. pList = ^tList;
  152. tList = record
  153. lh_Head : pNode;
  154. lh_Tail : pNode;
  155. lh_TailPred : pNode;
  156. lh_Type : Byte;
  157. l_pad : Byte;
  158. end;
  159. { minimum list -- no type checking possible }
  160. pMinList = ^tMinList;
  161. tMinList = record
  162. mlh_Head : pMinNode;
  163. mlh_Tail : pMinNode;
  164. mlh_TailPred : pMinNode;
  165. end;
  166. { ********************************************************************
  167. *
  168. * Format of the alert error number:
  169. *
  170. * +-+-------------+----------------+--------------------------------+
  171. * |D| SubSysId | General Error | SubSystem Specific Error |
  172. * +-+-------------+----------------+--------------------------------+
  173. * 1 7 bits 8 bits 16 bits
  174. *
  175. * D: DeadEnd alert
  176. * SubSysId: indicates ROM subsystem number.
  177. * General Error: roughly indicates what the error was
  178. * Specific Error: indicates more detail
  179. *********************************************************************}
  180. const
  181. {*********************************************************************
  182. *
  183. * Hardware/CPU specific alerts: They may show without the 8 at the
  184. * front of the number. These are CPU/68000 specific. See 68$0
  185. * programmer's manuals for more details.
  186. *
  187. *********************************************************************}
  188. ACPU_BusErr = $80000002; { Hardware bus fault/access error }
  189. ACPU_AddressErr = $80000003; { Illegal address access (ie: odd) }
  190. ACPU_InstErr = $80000004; { Illegal instruction }
  191. ACPU_DivZero = $80000005; { Divide by zero }
  192. ACPU_CHK = $80000006; { Check instruction error }
  193. ACPU_TRAPV = $80000007; { TrapV instruction error }
  194. ACPU_PrivErr = $80000008; { Privilege violation error }
  195. ACPU_Trace = $80000009; { Trace error }
  196. ACPU_LineA = $8000000A; { Line 1010 Emulator error }
  197. ACPU_LineF = $8000000B; { Line 1111 Emulator error }
  198. ACPU_Format = $8000000E; { Stack frame format error }
  199. ACPU_Spurious = $80000018; { Spurious interrupt error }
  200. ACPU_AutoVec1 = $80000019; { AutoVector Level 1 interrupt error }
  201. ACPU_AutoVec2 = $8000001A; { AutoVector Level 2 interrupt error }
  202. ACPU_AutoVec3 = $8000001B; { AutoVector Level 3 interrupt error }
  203. ACPU_AutoVec4 = $8000001C; { AutoVector Level 4 interrupt error }
  204. ACPU_AutoVec5 = $8000001D; { AutoVector Level 5 interrupt error }
  205. ACPU_AutoVec6 = $8000001E; { AutoVector Level 6 interrupt error }
  206. ACPU_AutoVec7 = $8000001F; { AutoVector Level 7 interrupt error }
  207. { ********************************************************************
  208. *
  209. * General Alerts
  210. *
  211. * For example: timer.device cannot open math.library would be $05038015
  212. *
  213. * Alert(AN_TimerDev|AG_OpenLib|AO_MathLib);
  214. *
  215. ********************************************************************}
  216. CONST
  217. { ------ alert types }
  218. AT_DeadEnd = $80000000;
  219. AT_Recovery = $00000000;
  220. { ------ general purpose alert codes }
  221. AG_NoMemory = $00010000;
  222. AG_MakeLib = $00020000;
  223. AG_OpenLib = $00030000;
  224. AG_OpenDev = $00040000;
  225. AG_OpenRes = $00050000;
  226. AG_IOError = $00060000;
  227. AG_NoSignal = $00070000;
  228. AG_BadParm = $00080000;
  229. AG_CloseLib = $00090000; { usually too many closes }
  230. AG_CloseDev = $000A0000; { or a mismatched close }
  231. AG_ProcCreate = $000B0000; { Process creation failed }
  232. { ------ alert objects: }
  233. AO_ExecLib = $00008001;
  234. AO_GraphicsLib = $00008002;
  235. AO_LayersLib = $00008003;
  236. AO_Intuition = $00008004;
  237. AO_MathLib = $00008005;
  238. AO_DOSLib = $00008007;
  239. AO_RAMLib = $00008008;
  240. AO_IconLib = $00008009;
  241. AO_ExpansionLib = $0000800A;
  242. AO_DiskfontLib = $0000800B;
  243. AO_UtilityLib = $0000800C;
  244. AO_KeyMapLib = $0000800D;
  245. AO_AudioDev = $00008010;
  246. AO_ConsoleDev = $00008011;
  247. AO_GamePortDev = $00008012;
  248. AO_KeyboardDev = $00008013;
  249. AO_TrackDiskDev = $00008014;
  250. AO_TimerDev = $00008015;
  251. AO_CIARsrc = $00008020;
  252. AO_DiskRsrc = $00008021;
  253. AO_MiscRsrc = $00008022;
  254. AO_BootStrap = $00008030;
  255. AO_Workbench = $00008031;
  256. AO_DiskCopy = $00008032;
  257. AO_GadTools = $00008033;
  258. AO_Unknown = $00008035;
  259. { ********************************************************************
  260. *
  261. * Specific Alerts:
  262. *
  263. ********************************************************************}
  264. { ------ exec.library }
  265. AN_ExecLib = $01000000;
  266. AN_ExcptVect = $01000001; { 68000 exception vector checksum (obs.) }
  267. AN_BaseChkSum = $01000002; { Execbase checksum (obs.) }
  268. AN_LibChkSum = $01000003; { Library checksum failure }
  269. AN_MemCorrupt = $81000005; { Corrupt memory list detected in FreeMem }
  270. AN_IntrMem = $81000006; { No memory for interrupt servers }
  271. AN_InitAPtr = $01000007; { InitStruct() of an APTR source (obs.) }
  272. AN_SemCorrupt = $01000008; { A semaphore is in an illegal state
  273. at ReleaseSempahore() }
  274. AN_FreeTwice = $01000009; { Freeing memory already freed }
  275. AN_BogusExcpt = $8100000A; { illegal 68k exception taken (obs.) }
  276. AN_IOUsedTwice = $0100000B; { Attempt to reuse active IORequest }
  277. AN_MemoryInsane = $0100000C; { Sanity check on memory list failed
  278. during AvailMem(MEMF_LARGEST) }
  279. AN_IOAfterClose = $0100000D; { IO attempted on closed IORequest }
  280. AN_StackProbe = $0100000E; { Stack appears to extend out of range }
  281. AN_BadFreeAddr = $0100000F; { Memory header not located. [ Usually an
  282. invalid address passed to FreeMem() ] }
  283. AN_BadSemaphore = $01000010; { An attempt was made to use the old
  284. message semaphores. }
  285. { ------ graphics.library }
  286. AN_GraphicsLib = $02000000;
  287. AN_GfxNoMem = $82010000; { graphics out of memory }
  288. AN_GfxNoMemMspc = $82010001; { MonitorSpec alloc, no memory }
  289. AN_LongFrame = $82010006; { long frame, no memory }
  290. AN_ShortFrame = $82010007; { short frame, no memory }
  291. AN_TextTmpRas = $02010009; { text, no memory for TmpRas }
  292. AN_BltBitMap = $8201000A; { BltBitMap, no memory }
  293. AN_RegionMemory = $8201000B; { regions, memory not available }
  294. AN_MakeVPort = $82010030; { MakeVPort, no memory }
  295. AN_GfxNewError = $0200000C;
  296. AN_GfxFreeError = $0200000D;
  297. AN_GfxNoLCM = $82011234; { emergency memory not available }
  298. AN_ObsoleteFont = $02000401; { unsupported font description used }
  299. { ------ layers.library }
  300. AN_LayersLib = $03000000;
  301. AN_LayersNoMem = $83010000; { layers out of memory }
  302. { ------ intuition.library }
  303. AN_Intuition = $04000000;
  304. AN_GadgetType = $84000001; { unknown gadget type }
  305. AN_BadGadget = $04000001; { Recovery form of AN_GadgetType }
  306. AN_CreatePort = $84010002; { create port, no memory }
  307. AN_ItemAlloc = $04010003; { item plane alloc, no memory }
  308. AN_SubAlloc = $04010004; { sub alloc, no memory }
  309. AN_PlaneAlloc = $84010005; { plane alloc, no memory }
  310. AN_ItemBoxTop = $84000006; { item box top < RelZero }
  311. AN_OpenScreen = $84010007; { open screen, no memory }
  312. AN_OpenScrnRast = $84010008; { open screen, raster alloc, no memory }
  313. AN_SysScrnType = $84000009; { open sys screen, unknown type }
  314. AN_AddSWGadget = $8401000A; { add SW gadgets, no memory }
  315. AN_OpenWindow = $8401000B; { open window, no memory }
  316. AN_BadState = $8400000C; { Bad State Return entering Intuition }
  317. AN_BadMessage = $8400000D; { Bad Message received by IDCMP }
  318. AN_WeirdEcho = $8400000E; { Weird echo causing incomprehension }
  319. AN_NoConsole = $8400000F; { couldn't open the Console Device }
  320. AN_NoISem = $04000010; { Intuition skipped obtaining a sem }
  321. AN_ISemOrder = $04000011; { Intuition obtained a sem in bad order }
  322. { ------ math.library }
  323. AN_MathLib = $05000000;
  324. { ------ dos.library }
  325. AN_DOSLib = $07000000;
  326. AN_StartMem = $07010001; { no memory at startup }
  327. AN_EndTask = $07000002; { EndTask didn't }
  328. AN_QPktFail = $07000003; { Qpkt failure }
  329. AN_AsyncPkt = $07000004; { Unexpected packet received }
  330. AN_FreeVec = $07000005; { Freevec failed }
  331. AN_DiskBlkSeq = $07000006; { Disk block sequence error }
  332. AN_BitMap = $07000007; { Bitmap corrupt }
  333. AN_KeyFree = $07000008; { Key already free }
  334. AN_BadChkSum = $07000009; { Invalid checksum }
  335. AN_DiskError = $0700000A; { Disk Error }
  336. AN_KeyRange = $0700000B; { Key out of range }
  337. AN_BadOverlay = $0700000C; { Bad overlay }
  338. AN_BadInitFunc = $0700000D; { Invalid init packet for cli/shell }
  339. AN_FileReclosed = $0700000E; { A filehandle was closed more than once }
  340. { ------ ramlib.library }
  341. AN_RAMLib = $08000000;
  342. AN_BadSegList = $08000001; { no overlays in library seglists }
  343. { ------ icon.library }
  344. AN_IconLib = $09000000;
  345. { ------ expansion.library }
  346. AN_ExpansionLib = $0A000000;
  347. AN_BadExpansionFree = $0A000001; { freeed free region }
  348. { ------ diskfont.library }
  349. AN_DiskfontLib = $0B000000;
  350. { ------ audio.device }
  351. AN_AudioDev = $10000000;
  352. { ------ console.device }
  353. AN_ConsoleDev = $11000000;
  354. AN_NoWindow = $11000001; { Console can't open initial window }
  355. { ------ gameport.device }
  356. AN_GamePortDev = $12000000;
  357. { ------ keyboard.device }
  358. AN_KeyboardDev = $13000000;
  359. { ------ trackdisk.device }
  360. AN_TrackDiskDev = $14000000;
  361. AN_TDCalibSeek = $14000001; { calibrate: seek error }
  362. AN_TDDelay = $14000002; { delay: error on timer wait }
  363. { ------ timer.device }
  364. AN_TimerDev = $15000000;
  365. AN_TMBadReq = $15000001; { bad request }
  366. AN_TMBadSupply = $15000002; { power supply -- no 50/60Hz ticks }
  367. { ------ cia.resource }
  368. AN_CIARsrc = $20000000;
  369. { ------ disk.resource }
  370. AN_DiskRsrc = $21000000;
  371. AN_DRHasDisk = $21000001; { get unit: already has disk }
  372. AN_DRIntNoAct = $21000002; { interrupt: no active unit }
  373. { ------ misc.resource }
  374. AN_MiscRsrc = $22000000;
  375. { ------ bootstrap }
  376. AN_BootStrap = $30000000;
  377. AN_BootError = $30000001; { boot code returned an error }
  378. { ------ Workbench }
  379. AN_Workbench = $31000000;
  380. AN_NoFonts = $B1000001;
  381. AN_WBBadStartupMsg1 = $31000001;
  382. AN_WBBadStartupMsg2 = $31000002;
  383. AN_WBBadIOMsg = $31000003;
  384. AN_WBReLayoutToolMenu = $B1010009;
  385. { ------ DiskCopy }
  386. AN_DiskCopy = $32000000;
  387. { ------ toolkit for Intuition }
  388. AN_GadTools = $33000000;
  389. { ------ System utility library }
  390. AN_UtilityLib = $34000000;
  391. { ------ For use by any application that needs it }
  392. AN_Unknown = $35000000;
  393. CONST
  394. IOERR_OPENFAIL = -1; { device/unit failed to open }
  395. IOERR_ABORTED = -2; { request terminated early [after AbortIO()] }
  396. IOERR_NOCMD = -3; { command not supported by device }
  397. IOERR_BADLENGTH = -4; { not a valid length (usually IO_LENGTH) }
  398. IOERR_BADADDRESS = -5; { invalid address (misaligned or bad range) }
  399. IOERR_UNITBUSY = -6; { device opens ok, but requested unit is busy }
  400. IOERR_SELFTEST = -7; { hardware failed self-test }
  401. type
  402. pResident = ^tResident;
  403. tResident = record
  404. rt_MatchWord : Word; { smallint to match on (ILLEGAL) }
  405. rt_MatchTag : pResident; { pointer to the above }
  406. rt_EndSkip : Pointer; { address to continue scan }
  407. rt_Flags : Byte; { various tag flags }
  408. rt_Version : Byte; { release version number }
  409. rt_Type : Byte; { type of module (NT_mumble) }
  410. rt_Pri : Shortint; { initialization priority }
  411. rt_Name : STRPTR; { pointer to node name }
  412. rt_IdString : STRPTR; { pointer to ident string }
  413. rt_Init : Pointer; { pointer to init code }
  414. end;
  415. const
  416. RTC_MATCHWORD = $4AFC;
  417. RTF_AUTOINIT = $80;
  418. RTF_AFTERDOS = $04;
  419. RTF_SINGLETASK = $02;
  420. RTF_COLDSTART = $01;
  421. { Compatibility: }
  422. RTM_WHEN = $03;
  423. RTW_COLDSTART = $01;
  424. RTW_NEVER = $00;
  425. TYPE
  426. { ****** MemChunk **************************************************** }
  427. pMemChunk = ^tMemChunk;
  428. tMemChunk = Record
  429. mc_Next : pMemChunk; { * pointer to next chunk * }
  430. mc_Bytes : ULONG; { * chunk byte size * }
  431. End;
  432. { ****** MemHeader *************************************************** }
  433. pMemHeader = ^tMemHeader;
  434. tMemHeader = Record
  435. mh_Node : tNode;
  436. mh_Attributes : Word; { * characteristics of this region * }
  437. mh_First : pMemChunk; { * first free region * }
  438. mh_Lower, { * lower memory bound * }
  439. mh_Upper : Pointer; { * upper memory bound+1 * }
  440. mh_Free : Ulong; { * total number of free bytes * }
  441. End;
  442. { ****** MemEntry **************************************************** }
  443. pMemEntry = ^tMemEntry;
  444. tMemEntry = record
  445. me_Un : record
  446. case longint of
  447. 0 : ( meu_Reqs : ULONG );
  448. 1 : ( meu_Addr : APTR );
  449. end;
  450. me_Length : ULONG;
  451. end;
  452. { ****** MemList ***************************************************** }
  453. { * Note: sizeof(struct MemList) includes the size of the first MemEntry! * }
  454. pMemList = ^tMemList;
  455. tMemList = Record
  456. ml_Node : tNode;
  457. ml_NumEntries : Word; { * number of entries in this struct * }
  458. ml_ME : Array [0..0] of tMemEntry; { * the first entry * }
  459. End;
  460. { *----- Memory Requirement Types ---------------------------* }
  461. { *----- See the AllocMem() documentation for details--------* }
  462. Const
  463. MEMF_ANY = %000000000000000000000000; { * Any type of memory will do * }
  464. MEMF_PUBLIC = %000000000000000000000001;
  465. MEMF_CHIP = %000000000000000000000010;
  466. MEMF_FAST = %000000000000000000000100;
  467. MEMF_LOCAL = %000000000000000100000000;
  468. MEMF_24BITDMA = %000000000000001000000000; { * DMAable memory within 24 bits of address * }
  469. MEMF_KICK = %000000000000010000000000; { Memory that can be used for KickTags }
  470. MEMF_CLEAR = %000000010000000000000000;
  471. MEMF_LARGEST = %000000100000000000000000;
  472. MEMF_REVERSE = %000001000000000000000000;
  473. MEMF_TOTAL = %000010000000000000000000; { * AvailMem: return total size of memory * }
  474. MEMF_NO_EXPUNGE = $80000000; {AllocMem: Do not cause expunge on failure }
  475. MEM_BLOCKSIZE = 8;
  476. MEM_BLOCKMASK = MEM_BLOCKSIZE-1;
  477. Type
  478. {***** MemHandlerData *********************************************}
  479. { Note: This structure is *READ ONLY* and only EXEC can create it!}
  480. pMemHandlerData = ^tMemHandlerData;
  481. tMemHandlerData = Record
  482. memh_RequestSize, { Requested allocation size }
  483. memh_RequestFlags, { Requested allocation flags }
  484. memh_Flags : ULONG; { Flags (see below) }
  485. end;
  486. const
  487. MEMHF_RECYCLE = 1; { 0==First time, 1==recycle }
  488. {***** Low Memory handler return values **************************}
  489. MEM_DID_NOTHING = 0; { Nothing we could do... }
  490. MEM_ALL_DONE = -1; { We did all we could do }
  491. MEM_TRY_AGAIN = 1; { We did some, try the allocation again }
  492. type
  493. pInterrupt = ^tInterrupt;
  494. tInterrupt = record
  495. is_Node : tNode;
  496. is_Data : Pointer; { Server data segment }
  497. is_Code : Pointer; { Server code entry }
  498. end;
  499. pIntVector = ^tIntVector;
  500. tIntVector = record { For EXEC use ONLY! }
  501. iv_Data : Pointer;
  502. iv_Code : Pointer;
  503. iv_Node : pNode;
  504. end;
  505. pSoftIntList = ^tSoftIntList;
  506. tSoftIntList = record { For EXEC use ONLY! }
  507. sh_List : tList;
  508. sh_Pad : Word;
  509. end;
  510. const
  511. SIH_PRIMASK = $F0;
  512. { this is a fake INT definition, used only for AddIntServer and the like }
  513. INTB_NMI = 15;
  514. INTF_NMI = $0080;
  515. {
  516. Every Amiga Task has one of these Task structures associated with it.
  517. To find yours, use FindTask(Nil). AmigaDOS processes tack a few more
  518. values on to the end of this structure, which is the difference between
  519. Tasks and Processes.
  520. }
  521. type
  522. pTask = ^tTask;
  523. tTask = record
  524. tc_Node : tNode;
  525. tc_Flags : Byte;
  526. tc_State : Byte;
  527. tc_IDNestCnt : Shortint; { intr disabled nesting }
  528. tc_TDNestCnt : Shortint; { task disabled nesting }
  529. tc_SigAlloc : ULONG; { sigs allocated }
  530. tc_SigWait : ULONG; { sigs we are waiting for }
  531. tc_SigRecvd : ULONG; { sigs we have received }
  532. tc_SigExcept : ULONG; { sigs we will take excepts for }
  533. tc_TrapAlloc : Word; { traps allocated }
  534. tc_TrapAble : Word; { traps enabled }
  535. tc_ExceptData : Pointer; { points to except data }
  536. tc_ExceptCode : Pointer; { points to except code }
  537. tc_TrapData : Pointer; { points to trap data }
  538. tc_TrapCode : Pointer; { points to trap code }
  539. tc_SPReg : Pointer; { stack pointer }
  540. tc_SPLower : Pointer; { stack lower bound }
  541. tc_SPUpper : Pointer; { stack upper bound + 2 }
  542. tc_Switch : Pointer; { task losing CPU }
  543. tc_Launch : Pointer; { task getting CPU }
  544. tc_MemEntry : tList; { allocated memory }
  545. tc_UserData : Pointer; { per task data }
  546. end;
  547. {
  548. * Stack swap structure as passed to StackSwap()
  549. }
  550. pStackSwapStruct = ^tStackSwapStruct;
  551. tStackSwapStruct = Record
  552. stk_Lower : Pointer; { Lowest byte of stack }
  553. stk_Upper : ULONG; { Upper end of stack (size + Lowest) }
  554. stk_Pointer : Pointer; { Stack pointer at switch point }
  555. end;
  556. {----- Flag Bits ------------------------------------------}
  557. const
  558. TB_PROCTIME = 0;
  559. TB_ETASK = 3;
  560. TB_STACKCHK = 4;
  561. TB_EXCEPT = 5;
  562. TB_SWITCH = 6;
  563. TB_LAUNCH = 7;
  564. TF_PROCTIME = 1;
  565. TF_ETASK = 8;
  566. TF_STACKCHK = 16;
  567. TF_EXCEPT = 32;
  568. TF_SWITCH = 64;
  569. TF_LAUNCH = 128;
  570. {----- Task States ----------------------------------------}
  571. TS_INVALID = 0;
  572. TS_ADDED = 1;
  573. TS_RUN = 2;
  574. TS_READY = 3;
  575. TS_WAIT = 4;
  576. TS_EXCEPT = 5;
  577. TS_REMOVED = 6;
  578. {----- Predefined Signals -------------------------------------}
  579. SIGB_ABORT = 0;
  580. SIGB_CHILD = 1;
  581. SIGB_BLIT = 4;
  582. SIGB_SINGLE = 4;
  583. SIGB_INTUITION = 5;
  584. SIGB_DOS = 8;
  585. SIGF_ABORT = 1;
  586. SIGF_CHILD = 2;
  587. SIGF_BLIT = 16;
  588. SIGF_SINGLE = 16;
  589. SIGF_INTUITION = 32;
  590. SIGF_DOS = 256;
  591. {
  592. This file defines ports and messages, which are used for inter-
  593. task communications using the routines defined toward the
  594. bottom of this file.
  595. }
  596. type
  597. {****** MsgPort *****************************************************}
  598. pMsgPort = ^tMsgPort;
  599. tMsgPort = record
  600. mp_Node : tNode;
  601. mp_Flags : Byte;
  602. mp_SigBit : Byte; { signal bit number }
  603. mp_SigTask : Pointer; { task to be signalled (TaskPtr) }
  604. mp_MsgList : tList; { message linked list }
  605. end;
  606. {****** Message *****************************************************}
  607. pMessage = ^tMessage;
  608. tMessage = record
  609. mn_Node : tNode;
  610. mn_ReplyPort : pMsgPort; { message reply port }
  611. mn_Length : Word; { message len in bytes }
  612. end;
  613. { mp_Flags: Port arrival actions (PutMsg) }
  614. CONST
  615. PF_ACTION = 3; { * Mask * }
  616. PA_SIGNAL = 0; { * Signal task in mp_SigTask * }
  617. PA_SOFTINT = 1; { * Signal SoftInt in mp_SoftInt/mp_SigTask * }
  618. PA_IGNORE = 2; { * Ignore arrival * }
  619. { Semaphore }
  620. type
  621. pSemaphore = ^tSemaphore;
  622. tSemaphore = record
  623. sm_MsgPort : tMsgPort;
  624. sm_Bids : smallint;
  625. end;
  626. { This is the structure used to request a signal semaphore }
  627. pSemaphoreRequest = ^tSemaphoreRequest;
  628. tSemaphoreRequest = record
  629. sr_Link : tMinNode;
  630. sr_Waiter : pTask;
  631. end;
  632. { The actual semaphore itself }
  633. pSignalSemaphore = ^tSignalSemaphore;
  634. tSignalSemaphore = record
  635. ss_Link : tNode;
  636. ss_NestCount : smallint;
  637. ss_WaitQueue : tMinList;
  638. ss_MultipleLink : tSemaphoreRequest;
  639. ss_Owner : pTask;
  640. ss_QueueCount : smallint;
  641. end;
  642. { ***** Semaphore procure message (for use in V39 Procure/Vacate *** }
  643. pSemaphoreMessage = ^tSemaphoreMessage;
  644. tSemaphoreMessage = Record
  645. ssm_Message : tMessage;
  646. ssm_Semaphore : pSignalSemaphore;
  647. end;
  648. const
  649. SM_SHARED = 1;
  650. SM_EXCLUSIVE = 0;
  651. CONST
  652. { ------ Special Constants --------------------------------------- }
  653. LIB_VECTSIZE = 6; { Each library entry takes 6 bytes }
  654. LIB_RESERVED = 4; { Exec reserves the first 4 vectors }
  655. LIB_BASE = (-LIB_VECTSIZE);
  656. LIB_USERDEF = (LIB_BASE-(LIB_RESERVED*LIB_VECTSIZE));
  657. LIB_NONSTD = (LIB_USERDEF);
  658. { ------ Standard Functions -------------------------------------- }
  659. LIB_OPEN = -6;
  660. LIB_CLOSE = -12;
  661. LIB_EXPUNGE = -18;
  662. LIB_EXTFUNC = -24; { for future expansion }
  663. TYPE
  664. { ------ Library Base Structure ---------------------------------- }
  665. { Also used for Devices and some Resources }
  666. pLibrary = ^tLibrary;
  667. tLibrary = record
  668. lib_Node : tNode;
  669. lib_Flags,
  670. lib_pad : Byte;
  671. lib_NegSize, { number of bytes before library }
  672. lib_PosSize, { number of bytes after library }
  673. lib_Version, { major }
  674. lib_Revision : Word; { minor }
  675. lib_IdString : STRPTR; { ASCII identification }
  676. lib_Sum : ULONG; { the checksum itself }
  677. lib_OpenCnt : Word; { number of current opens }
  678. end; { * Warning: size is not a longword multiple ! * }
  679. CONST
  680. { lib_Flags bit definitions (all others are system reserved) }
  681. LIBF_SUMMING = %00000001; { we are currently checksumming }
  682. LIBF_CHANGED = %00000010; { we have just changed the lib }
  683. LIBF_SUMUSED = %00000100; { set if we should bother to sum }
  684. LIBF_DELEXP = %00001000; { delayed expunge }
  685. {
  686. This file defines the constants and types required to use
  687. Amiga device IO routines, which are also defined here.
  688. }
  689. TYPE
  690. {***** Device *****************************************************}
  691. pDevice = ^tDevice;
  692. tDevice = record
  693. dd_Library : tLibrary;
  694. end;
  695. {***** Unit *******************************************************}
  696. pUnit = ^tUnit;
  697. tUnit = record
  698. unit_MsgPort : tMsgPort; { queue for unprocessed messages }
  699. { instance of msgport is recommended }
  700. unit_flags,
  701. unit_pad : Byte;
  702. unit_OpenCnt : Word; { number of active opens }
  703. end;
  704. Const
  705. UNITF_ACTIVE = %00000001;
  706. UNITF_INTASK = %00000010;
  707. type
  708. pIORequest = ^tIORequest;
  709. tIORequest = record
  710. io_Message : tMessage;
  711. io_Device : pDevice; { device node pointer }
  712. io_Unit : pUnit; { unit (driver private)}
  713. io_Command : Word; { device command }
  714. io_Flags : Byte;
  715. io_Error : Shortint; { error or warning num }
  716. end;
  717. pIOStdReq = ^tIOStdReq;
  718. tIOStdReq = record
  719. io_Message : tMessage;
  720. io_Device : pDevice; { device node pointer }
  721. io_Unit : pUnit; { unit (driver private)}
  722. io_Command : Word; { device command }
  723. io_Flags : Byte;
  724. io_Error : Shortint; { error or warning num }
  725. io_Actual : ULONG; { actual number of bytes transferred }
  726. io_Length : ULONG; { requested number bytes transferred}
  727. io_Data : Pointer; { points to data area }
  728. io_Offset : ULONG; { offset for block structured devices }
  729. end;
  730. { library vector offsets for device reserved vectors }
  731. const
  732. DEV_BEGINIO = -30;
  733. DEV_ABORTIO = -36;
  734. { io_Flags defined bits }
  735. IOB_QUICK = 0;
  736. IOF_QUICK = 1;
  737. CMD_INVALID = 0;
  738. CMD_RESET = 1;
  739. CMD_READ = 2;
  740. CMD_WRITE = 3;
  741. CMD_UPDATE = 4;
  742. CMD_CLEAR = 5;
  743. CMD_STOP = 6;
  744. CMD_START = 7;
  745. CMD_FLUSH = 8;
  746. CMD_NONSTD = 9;
  747. { Definition of the Exec library base structure (pointed to by location 4).
  748. ** Most fields are not to be viewed or modified by user programs. Use
  749. ** extreme caution.
  750. }
  751. type
  752. pExecBase = ^tExecBase;
  753. tExecBase = Record
  754. LibNode : tLibrary; { Standard library node }
  755. { ******* Static System Variables ******* }
  756. SoftVer : Word; { kickstart release number (obs.) }
  757. LowMemChkSum : smallint; { checksum of 68000 trap vectors }
  758. ChkBase : ULONG; { system base pointer complement }
  759. ColdCapture, { coldstart soft capture vector }
  760. CoolCapture, { coolstart soft capture vector }
  761. WarmCapture, { warmstart soft capture vector }
  762. SysStkUpper, { system stack base (upper bound) }
  763. SysStkLower : Pointer; { top of system stack (lower bound) }
  764. MaxLocMem : ULONG; { top of chip memory }
  765. DebugEntry, { global debugger entry point }
  766. DebugData, { global debugger data segment }
  767. AlertData, { alert data segment }
  768. MaxExtMem : Pointer; { top of extended mem, or null if none }
  769. ChkSum : Word; { for all of the above (minus 2) }
  770. { ***** Interrupt Related ************************************** }
  771. IntVects : Array[0..15] of tIntVector;
  772. { ***** Dynamic System Variables ************************************ }
  773. ThisTask : pTask; { pointer to current task (readable) }
  774. IdleCount, { idle counter }
  775. DispCount : ULONG; { dispatch counter }
  776. Quantum, { time slice quantum }
  777. Elapsed, { current quantum ticks }
  778. SysFlags : Word; { misc internal system flags }
  779. IDNestCnt, { interrupt disable nesting count }
  780. TDNestCnt : Shortint; { task disable nesting count }
  781. AttnFlags, { special attention flags (readable) }
  782. AttnResched : Word; { rescheduling attention }
  783. ResModules, { resident module array pointer }
  784. TaskTrapCode,
  785. TaskExceptCode,
  786. TaskExitCode : Pointer;
  787. TaskSigAlloc : ULONG;
  788. TaskTrapAlloc: Word;
  789. { ***** System Lists (private!) ******************************* }
  790. MemList,
  791. ResourceList,
  792. DeviceList,
  793. IntrList,
  794. LibList,
  795. PortList,
  796. TaskReady,
  797. TaskWait : tList;
  798. SoftInts : Array[0..4] of tSoftIntList;
  799. { ***** Other Globals ****************************************** }
  800. LastAlert : Array[0..3] of LONG;
  801. { these next two variables are provided to allow
  802. ** system developers to have a rough idea of the
  803. ** period of two externally controlled signals --
  804. ** the time between vertical blank interrupts and the
  805. ** external line rate (which is counted by CIA A's
  806. ** "time of day" clock). In general these values
  807. ** will be 50 or 60, and may or may not track each
  808. ** other. These values replace the obsolete AFB_PAL
  809. ** and AFB_50HZ flags.
  810. }
  811. VBlankFrequency, { (readable) }
  812. PowerSupplyFrequency : Byte; { (readable) }
  813. SemaphoreList : tList;
  814. { these next two are to be able to kickstart into user ram.
  815. ** KickMemPtr holds a singly linked list of MemLists which
  816. ** will be removed from the memory list via AllocAbs. If
  817. ** all the AllocAbs's succeeded, then the KickTagPtr will
  818. ** be added to the rom tag list.
  819. }
  820. KickMemPtr, { ptr to queue of mem lists }
  821. KickTagPtr, { ptr to rom tag queue }
  822. KickCheckSum : Pointer; { checksum for mem and tags }
  823. { ***** V36 Exec additions start here ************************************* }
  824. ex_Pad0 : Word;
  825. ex_LaunchPoint : ULONG;
  826. ex_RamLibPrivate : Pointer;
  827. { The next ULONG contains the system "E" clock frequency,
  828. ** expressed in Hertz. The E clock is used as a timebase for
  829. ** the Amiga's 8520 I/O chips. (E is connected to "02").
  830. ** Typical values are 715909 for NTSC, or 709379 for PAL.
  831. }
  832. ex_EClockFrequency, { (readable) }
  833. ex_CacheControl, { Private to CacheControl calls }
  834. ex_TaskID : ULONG; { Next available task ID }
  835. ex_Reserved1 : Array[0..4] of ULONG;
  836. ex_MMULock : Pointer; { private }
  837. ex_Reserved2 : Array[0..2] of ULONG;
  838. {***** V39 Exec additions start here *************************************}
  839. { The following list and data element are used
  840. * for V39 exec's low memory handler...
  841. }
  842. ex_MemHandlers : tMinList; { The handler list }
  843. ex_MemHandler : Pointer; { Private! handler pointer }
  844. end;
  845. { ***** Bit defines for AttnFlags (see above) ***************************** }
  846. { Processors and Co-processors: }
  847. CONST
  848. AFB_68010 = 0; { also set for 68020 }
  849. AFB_68020 = 1; { also set for 68030 }
  850. AFB_68030 = 2; { also set for 68040 }
  851. AFB_68040 = 3;
  852. AFB_68881 = 4; { also set for 68882 }
  853. AFB_68882 = 5;
  854. AFB_FPU40 = 6; { Set if 68040 FPU }
  855. AFB_68060 = 7;
  856. AFF_68010 = %00000001;
  857. AFF_68020 = %00000010;
  858. AFF_68030 = %00000100;
  859. AFF_68040 = %00001000;
  860. AFF_68881 = %00010000;
  861. AFF_68882 = %00100000;
  862. AFF_FPU40 = %01000000;
  863. AFF_68060 = (1 shl 7);
  864. { AFB_RESERVED8 = %000100000000; }
  865. { AFB_RESERVED9 = %001000000000; }
  866. { ***** Selected flag definitions for Cache manipulation calls ********* }
  867. CACRF_EnableI = %0000000000000001; { Enable instruction cache }
  868. CACRF_FreezeI = %0000000000000010; { Freeze instruction cache }
  869. CACRF_ClearI = %0000000000001000; { Clear instruction cache }
  870. CACRF_IBE = %0000000000010000; { Instruction burst enable }
  871. CACRF_EnableD = %0000000100000000; { 68030 Enable data cache }
  872. CACRF_FreezeD = %0000001000000000; { 68030 Freeze data cache }
  873. CACRF_ClearD = %0000100000000000; { 68030 Clear data cache }
  874. CACRF_DBE = %0001000000000000; { 68030 Data burst enable }
  875. CACRF_WriteAllocate = %0010000000000000; { 68030 Write-Allocate mode
  876. (must always be set!) }
  877. CACRF_EnableE = 1073741824; { Master enable for external caches }
  878. { External caches should track the }
  879. { state of the internal caches }
  880. { such that they do not cache anything }
  881. { that the internal cache turned off }
  882. { for. }
  883. CACRF_CopyBack = $80000000; { Master enable for copyback caches }
  884. DMA_Continue = 2; { Continuation flag for CachePreDMA }
  885. DMA_NoModify = 4; { Set if DMA does not update memory }
  886. DMA_ReadFromRAM = 8; { Set if DMA goes *FROM* RAM to device }
  887. { Don't even think about the contents of this structure. Just embed it
  888. * and reference it
  889. *}
  890. type
  891. PAVLNode = ^tAVLNode;
  892. tAVLNode = record
  893. reserved : array[0..3] of ULONG;
  894. end;
  895. ppAVLNode = ^pAVLNode;
  896. PAVLNODECOMP = ^AVLNODECOMP;
  897. AVLNODECOMP = APTR;
  898. PAVLKEYCOMP = ^AVLKEYCOMP;
  899. AVLKEYCOMP = APTR;
  900. PROCEDURE AbortIO(ioRequest : pIORequest location 'a1'); syscall _ExecBase 480;
  901. PROCEDURE AddDevice(device : pDevice location 'a1'); syscall _ExecBase 432;
  902. PROCEDURE AddHead(list : pList location 'a0'; node : pNode location 'a1'); syscall _ExecBase 240;
  903. PROCEDURE AddIntServer(intNumber : LONGINT location 'd0'; interrupt_ : pInterrupt location 'a1'); syscall _ExecBase 168;
  904. PROCEDURE AddLibrary(lib : pLibrary location 'a1'); syscall _ExecBase 396;
  905. PROCEDURE AddMemHandler(memhand : pInterrupt location 'a1'); syscall _ExecBase 774;
  906. PROCEDURE AddMemList(size : ULONG location 'd0'; attributes : ULONG location 'd1'; pri : LONGINT location 'd2'; base : POINTER location 'a0'; const name : pCHAR location 'a1'); syscall _ExecBase 618;
  907. PROCEDURE AddPort(port : pMsgPort location 'a1'); syscall _ExecBase 354;
  908. PROCEDURE AddResource(resource : POINTER location 'a1'); syscall _ExecBase 486;
  909. PROCEDURE AddSemaphore(sigSem : pSignalSemaphore location 'a1'); syscall _ExecBase 600;
  910. PROCEDURE AddTail(list : pList location 'a0'; node : pNode location 'a1'); syscall _ExecBase 246;
  911. FUNCTION AddTask(task : pTask location 'a1';const initPC : POINTER location 'a2';const finalPC : POINTER location 'a3') : POINTER; syscall _ExecBase 282;
  912. PROCEDURE Alert(alertNum : ULONG location 'd7'); syscall _ExecBase 108;
  913. FUNCTION AllocAbs(byteSize : ULONG location 'd0'; location : POINTER location 'a1') : POINTER; syscall _ExecBase 204;
  914. FUNCTION Allocate(freeList : pMemHeader location 'a0'; byteSize : ULONG location 'd0') : POINTER; syscall _ExecBase 186;
  915. FUNCTION AllocEntry(entry : pMemList location 'a0') : pMemList; syscall _ExecBase 222;
  916. FUNCTION ExecAllocMem(byteSize : ULONG location 'd0'; requirements : ULONG location 'd1') : POINTER; syscall _ExecBase 198;
  917. FUNCTION AllocPooled(poolHeader : POINTER location 'a0'; memSize : ULONG location 'd0') : POINTER; syscall _ExecBase 708;
  918. FUNCTION AllocSignal(signalNum : LONGINT location 'd0') : shortint; syscall _ExecBase 330;
  919. FUNCTION AllocTrap(trapNum : LONGINT location 'd0') : LONGINT; syscall _ExecBase 342;
  920. FUNCTION AllocVec(byteSize : ULONG location 'd0'; requirements : ULONG location 'd1') : POINTER; syscall _ExecBase 684;
  921. FUNCTION AttemptSemaphore(sigSem : pSignalSemaphore location 'a0') : LongBool; syscall _ExecBase 576;
  922. FUNCTION AttemptSemaphoreShared(sigSem : pSignalSemaphore location 'a0') : ULONG; syscall _ExecBase 720;
  923. FUNCTION AvailMem(requirements : ULONG location 'd1') : ULONG; syscall _ExecBase 216;
  924. PROCEDURE CacheClearE(address : POINTER location 'a0'; length : ULONG location 'd0'; caches : ULONG location 'd1'); syscall _ExecBase 642;
  925. PROCEDURE CacheClearU; syscall _ExecBase 636;
  926. FUNCTION CacheControl(cacheBits : ULONG location 'd0'; cacheMask : ULONG location 'd1') : ULONG; syscall _ExecBase 648;
  927. PROCEDURE CachePostDMA(const address : POINTER location 'a0'; VAR length : ULONG location 'a1'; flags : ULONG location 'd0'); syscall _ExecBase 768;
  928. FUNCTION CachePreDMA(const address : POINTER location 'a0'; VAR length : ULONG location 'a1'; flags : ULONG location 'd1') : POINTER; syscall _ExecBase 762;
  929. PROCEDURE Cause(interrupt_ : pInterrupt location 'a1'); syscall _ExecBase 180;
  930. FUNCTION CheckIO(ioRequest : pIORequest location 'a1') : pIORequest; syscall _ExecBase 468;
  931. PROCEDURE ChildFree(tid : POINTER location 'd0'); syscall _ExecBase 738;
  932. PROCEDURE ChildOrphan(tid : POINTER location 'd0'); syscall _ExecBase 744;
  933. PROCEDURE ChildStatus(tid : POINTER location 'd0'); syscall _ExecBase 750;
  934. PROCEDURE ChildWait(tid : POINTER location 'd0'); syscall _ExecBase 756;
  935. PROCEDURE CloseDevice(ioRequest : pIORequest location 'a1'); syscall _ExecBase 450;
  936. PROCEDURE CloseLibrary(lib : pLibrary location 'a1'); syscall _ExecBase 414;
  937. PROCEDURE ColdReboot; syscall _ExecBase 726;
  938. PROCEDURE CopyMem(const source : POINTER location 'a0'; dest : POINTER location 'a1'; size : ULONG location 'd0'); syscall _ExecBase 624;
  939. PROCEDURE CopyMemQuick(const source : POINTER location 'a0'; dest : POINTER location 'a1'; size : ULONG location 'd0'); syscall _ExecBase 630;
  940. FUNCTION CreateIORequest(const port : pMsgPort location 'a0'; size : ULONG location 'd0') : POINTER; syscall _ExecBase 654;
  941. FUNCTION CreateMsgPort : pMsgPort; syscall _ExecBase 666;
  942. FUNCTION CreatePool(requirements : ULONG location 'd0'; puddleSize : ULONG location 'd1'; threshSize : ULONG location 'd2') : POINTER; syscall _ExecBase 696;
  943. PROCEDURE Deallocate(freeList : pMemHeader location 'a0'; memoryBlock : POINTER location 'a1'; byteSize : ULONG location 'd1'); syscall _ExecBase 192;
  944. PROCEDURE Debug(flags : ULONG location 'd0'); syscall _ExecBase 114;
  945. PROCEDURE DeleteIORequest(iorequest : POINTER location 'a0'); syscall _ExecBase 660;
  946. PROCEDURE DeleteMsgPort(port : pMsgPort location 'a0'); syscall _ExecBase 672;
  947. PROCEDURE DeletePool(poolHeader : POINTER location 'a0'); syscall _ExecBase 702;
  948. PROCEDURE Disable; syscall _ExecBase 120;
  949. FUNCTION DoIO(ioRequest : pIORequest location 'a1') : shortint; syscall _ExecBase 456;
  950. PROCEDURE Enable; syscall _ExecBase 126;
  951. PROCEDURE Enqueue(list : pList location 'a0'; node : pNode location 'a1'); syscall _ExecBase 270;
  952. PROCEDURE ExecFreeMem(memoryBlock : POINTER location 'a1'; byteSize : ULONG location 'd0'); syscall _ExecBase 210;
  953. PROCEDURE ExecInsert(list : pList location 'a0'; node : pNode location 'a1'; pred : pNode location 'a2'); syscall _ExecBase 234;
  954. FUNCTION FindName(list : pList location 'a0'; const name : pCHAR location 'a1') : pNode; syscall _ExecBase 276;
  955. FUNCTION FindPort(const name : pCHAR location 'a1') : pMsgPort; syscall _ExecBase 390;
  956. FUNCTION FindResident(const name : pCHAR location 'a1') : pResident; syscall _ExecBase 096;
  957. FUNCTION FindSemaphore(const sigSem : pCHAR location 'a1') : pSignalSemaphore; syscall _ExecBase 594;
  958. FUNCTION FindTask(const name : pCHAR location 'a1') : pTask; syscall _ExecBase 294;
  959. PROCEDURE Forbid; syscall _ExecBase 132;
  960. PROCEDURE FreeEntry(entry : pMemList location 'a0'); syscall _ExecBase 228;
  961. PROCEDURE FreePooled(poolHeader : POINTER location 'a0'; memory : POINTER location 'a1'; memSize : ULONG location 'd0'); syscall _ExecBase 714;
  962. PROCEDURE FreeSignal(signalNum : LONGINT location 'd0'); syscall _ExecBase 336;
  963. PROCEDURE FreeTrap(trapNum : LONGINT location 'd0'); syscall _ExecBase 348;
  964. PROCEDURE FreeVec(memoryBlock : POINTER location 'a1'); syscall _ExecBase 690;
  965. FUNCTION GetCC : ULONG; syscall _ExecBase 528;
  966. FUNCTION GetMsg(port : pMsgPort location 'a0') : pMessage; syscall _ExecBase 372;
  967. PROCEDURE InitCode(startClass : ULONG location 'd0'; version : ULONG location 'd1'); syscall _ExecBase 072;
  968. FUNCTION InitResident(const resident_ : pResident location 'a1'; segList : ULONG location 'd0') : POINTER; syscall _ExecBase 102;
  969. PROCEDURE InitSemaphore(sigSem : pSignalSemaphore location 'a0'); syscall _ExecBase 558;
  970. PROCEDURE InitStruct(const initTable : POINTER location 'a1'; memory : POINTER location 'a2'; size : ULONG location 'd0'); syscall _ExecBase 078;
  971. PROCEDURE MakeFunctions(const target : POINTER location 'a0';const functionArray : POINTER location 'a1';const funcDispBase :pointer location 'a2'); syscall _ExecBase 090;
  972. FUNCTION MakeLibrary(const funcInit : POINTER location 'a0';const structInit : POINTER location 'a1'; libInit : tPROCEDURE location 'a2';dataSize : ULONG location 'd0'; segList : ULONG location 'd0') : pLibrary; syscall _ExecBase 084;
  973. FUNCTION ObtainQuickVector(interruptCode : POINTER location 'a0') : ULONG; syscall _ExecBase 786;
  974. PROCEDURE ObtainSemaphore(sigSem : pSignalSemaphore location 'a0'); syscall _ExecBase 564;
  975. PROCEDURE ObtainSemaphoreList(sigSem : pList location 'a0'); syscall _ExecBase 582;
  976. PROCEDURE ObtainSemaphoreShared(sigSem : pSignalSemaphore location 'a0'); syscall _ExecBase 678;
  977. FUNCTION OldOpenLibrary(const libName : pCHAR location 'a1') : pLibrary; syscall _ExecBase 408;
  978. FUNCTION OpenDevice(const devName : pCHAR location 'a0'; unite : ULONG location 'd0'; ioRequest : pIORequest location 'a1'; flags : ULONG location 'd1') : shortint; syscall _ExecBase 444;
  979. FUNCTION OpenLibrary(const libName : pCHAR location 'a1'; version : ULONG location 'd0') : pLibrary; syscall _ExecBase 552;
  980. FUNCTION OpenResource(const resName : pCHAR location 'a1') : POINTER; syscall _ExecBase 498;
  981. PROCEDURE Permit; syscall _ExecBase 138;
  982. FUNCTION Procure(sigSem : pSignalSemaphore location 'a0'; bidMsg : pSemaphoreMessage location 'a1') : LongBool; syscall _ExecBase 540;
  983. PROCEDURE PutMsg(port : pMsgPort location 'a0'; message : pMessage location 'a1'); syscall _ExecBase 366;
  984. function RawDoFmt(const formatString : pCHAR location 'a0';const dataStream : POINTER location 'a1'; putChProc : tPROCEDURE location 'a2'; putChData : POINTER location 'a3'): pointer; syscall _ExecBase 522;
  985. PROCEDURE ReleaseSemaphore(sigSem : pSignalSemaphore location 'a0'); syscall _ExecBase 570;
  986. PROCEDURE ReleaseSemaphoreList(sigSem : pList location 'a0'); syscall _ExecBase 588;
  987. PROCEDURE RemDevice(device : pDevice location 'a1'); syscall _ExecBase 438;
  988. FUNCTION RemHead(list : pList location 'a0') : pNode; syscall _ExecBase 258;
  989. PROCEDURE RemIntServer(intNumber : LONGINT location 'd0'; interrupt_ : pInterrupt location 'a1'); syscall _ExecBase 174;
  990. PROCEDURE RemLibrary(lib : pLibrary location 'a1'); syscall _ExecBase 402;
  991. PROCEDURE RemMemHandler(memhand : pInterrupt location 'a1'); syscall _ExecBase 780;
  992. PROCEDURE Remove(node : pNode location 'a1'); syscall _ExecBase 252;
  993. PROCEDURE RemPort(port : pMsgPort location 'a1'); syscall _ExecBase 360;
  994. PROCEDURE RemResource(resource : POINTER location 'a1'); syscall _ExecBase 492;
  995. PROCEDURE RemSemaphore(sigSem : pSignalSemaphore location 'a1'); syscall _ExecBase 606;
  996. FUNCTION RemTail(list : pList location 'a0') : pNode; syscall _ExecBase 264;
  997. PROCEDURE RemTask(task : pTask location 'a1'); syscall _ExecBase 288;
  998. PROCEDURE ReplyMsg(message : pMessage location 'a1'); syscall _ExecBase 378;
  999. PROCEDURE SendIO(ioRequest : pIORequest location 'a1'); syscall _ExecBase 462;
  1000. FUNCTION SetExcept(newSignals : ULONG location 'd0'; signalSet : ULONG location 'd1') : ULONG; syscall _ExecBase 312;
  1001. FUNCTION SetFunction(lib : pLibrary location 'a1'; funcOffset : LONGINT location 'a0'; newFunction : tPROCEDURE location 'd0') : POINTER; syscall _ExecBase 420;
  1002. FUNCTION SetIntVector(intNumber : LONGINT location 'd0';const interrupt_ : pInterrupt location 'a1') : pInterrupt; syscall _ExecBase 162;
  1003. FUNCTION SetSignal(newSignals : ULONG location 'd0'; signalSet : ULONG location 'd1') : ULONG; syscall _ExecBase 306;
  1004. FUNCTION SetSR(newSR : ULONG location 'd0'; mask : ULONG location 'd1') : ULONG; syscall _ExecBase 144;
  1005. FUNCTION SetTaskPri(task : pTask location 'a1'; priority : LONGINT location 'd0') : shortint; syscall _ExecBase 300;
  1006. PROCEDURE Signal(task : pTask location 'a1'; signalSet : ULONG location 'd0'); syscall _ExecBase 324;
  1007. PROCEDURE StackSwap(newStack : pStackSwapStruct location 'a0'); syscall _ExecBase 732;
  1008. PROCEDURE SumKickData; syscall _ExecBase 612;
  1009. PROCEDURE SumLibrary(lib : pLibrary location 'a1'); syscall _ExecBase 426;
  1010. FUNCTION SuperState : POINTER; syscall _ExecBase 150;
  1011. FUNCTION Supervisor(userFunction : tPROCEDURE location 'a5') : ULONG; syscall _ExecBase 030;
  1012. FUNCTION TypeOfMem(const address : POINTER location 'a1') : ULONG; syscall _ExecBase 534;
  1013. PROCEDURE UserState(sysStack : POINTER location 'd0'); syscall _ExecBase 156;
  1014. PROCEDURE Vacate(sigSem : pSignalSemaphore location 'a0'; bidMsg : pSemaphoreMessage location 'a1'); syscall _ExecBase 546;
  1015. FUNCTION Wait(signalSet : ULONG location 'd0') : ULONG; syscall _ExecBase 318;
  1016. FUNCTION WaitIO(ioRequest : pIORequest location 'a1') : shortint; syscall _ExecBase 474;
  1017. FUNCTION WaitPort(port : pMsgPort location 'a0') : pMessage; syscall _ExecBase 384;
  1018. PROCEDURE NewMinList(minlist : pMinList location 'a0'); syscall _ExecBase 828;
  1019. FUNCTION AVL_AddNode(root : ppAVLNode location 'a0'; node : pAVLNode location 'a1'; func : POINTER location 'a2') : pAVLNode; syscall _ExecBase 852;
  1020. FUNCTION AVL_RemNodeByAddress(root : ppAVLNode location 'a0'; node : pAVLNode location 'a1') : pAVLNode; syscall _ExecBase 858;
  1021. FUNCTION AVL_RemNodeByKey(root : ppAVLNode location 'a0'; key : POINTER location 'a1'; func : POINTER location 'a2') : pAVLNode; syscall _ExecBase 864;
  1022. FUNCTION AVL_FindNode(CONST root : pAVLNode location 'a0'; key : POINTER location 'a1'; func : POINTER location 'a2') : pAVLNode; syscall _ExecBase 870;
  1023. FUNCTION AVL_FindPrevNodeByAddress(CONST node : pAVLNode location 'a0') : pAVLNode; syscall _ExecBase 876;
  1024. FUNCTION AVL_FindPrevNodeByKey(CONST root : pAVLNode location 'a0'; key : POINTER location 'a1'; func : POINTER location 'a2') : pAVLNode; syscall _ExecBase 882;
  1025. FUNCTION AVL_FindNextNodeByAddress(CONST node : pAVLNode location 'a0') : pAVLNode; syscall _ExecBase 888;
  1026. FUNCTION AVL_FindNextNodeByKey(CONST root : pAVLNode location 'a0'; key : POINTER location 'a1'; func : POINTER location 'a2') : pAVLNode; syscall _ExecBase 894;
  1027. FUNCTION AVL_FindFirstNode(CONST root : pAVLNode location 'a0') : pAVLNode; syscall _ExecBase 900;
  1028. FUNCTION AVL_FindLastNode(CONST root : pAVLNode location 'a0') : pAVLNode; syscall _ExecBase 906;
  1029. FUNCTION FindName(list : pList; const name : String) : pNode;
  1030. FUNCTION FindPort(const name : String) : pMsgPort;
  1031. FUNCTION FindResident(const name : String) : pResident;
  1032. FUNCTION FindSemaphore(const sigSem : String) : pSignalSemaphore;
  1033. FUNCTION FindTask(const name : String) : pTask;
  1034. FUNCTION OldOpenLibrary(const libName : String) : pLibrary;
  1035. FUNCTION OpenDevice(const devName : String; unite : ULONG; ioRequest : pIORequest;flags : ULONG) : shortint;
  1036. FUNCTION OpenLibrary(const libName : String; version : ULONG) : pLibrary;
  1037. FUNCTION OpenResource(const resName : String) : POINTER;
  1038. function RawDoFmt(const formatString : String;const dataStream : POINTER; putChProc :tPROCEDURE; putChData : POINTER): pointer;
  1039. function BitMask(no :shortint): longint;
  1040. function IsListEmpty( list : pList): boolean;
  1041. function IsMsgPortEmpty( mp : pMsgPort): boolean;
  1042. procedure BeginIO(IORequest: PIORequest);
  1043. function CreateExtIO(Port: PMsgPort; Size: LongInt): PIORequest;
  1044. procedure DeleteExtIO(IOReq: PIORequest);
  1045. function CreateStdIO(Port: PMsgPort): PIOStdReq;
  1046. procedure DeleteStdIO(IOReq: PIOStdReq);
  1047. function CreatePort(Name: PChar; Pri: LongInt): PMsgPort;
  1048. procedure DeletePort(Port: PMsgPort);
  1049. function CreateTask(Name: STRPTR; Pri: LongInt; InitPC: Pointer; StackSize: LongWord): PTask;
  1050. procedure DeleteTask(Task: PTask);
  1051. procedure NewList(List: PList);
  1052. IMPLEMENTATION
  1053. function BitMask(no :shortint): longint; inline;
  1054. begin
  1055. BitMask := 1 shl no;
  1056. end;
  1057. function IsListEmpty( list : pList): boolean; inline;
  1058. begin
  1059. IsListEmpty := list^.lh_TailPred = pnode(list);
  1060. end;
  1061. function IsMsgPortEmpty( mp : pMsgPort): boolean; inline;
  1062. begin
  1063. with mp^ do
  1064. IsMsgPortEmpty := mp_MsgList.lh_TailPred = pNode(@mp_MsgList);
  1065. end;
  1066. FUNCTION FindName(list : pList; const name : String) : pNode;
  1067. BEGIN
  1068. FindName := FindName(list,PChar(RawByteString(name)));
  1069. END;
  1070. FUNCTION FindPort(const name : String) : pMsgPort;
  1071. BEGIN
  1072. FindPort := FindPort(PChar(RawByteString(name)));
  1073. END;
  1074. FUNCTION FindResident(const name : String) : pResident;
  1075. BEGIN
  1076. FindResident := FindResident(PChar(RawByteString(name)));
  1077. END;
  1078. FUNCTION FindSemaphore(const sigSem : String) : pSignalSemaphore;
  1079. BEGIN
  1080. FindSemaphore := FindSemaphore(PChar(RawByteString(sigSem)));
  1081. END;
  1082. FUNCTION FindTask(const name : String) : pTask;
  1083. BEGIN
  1084. FindTask := FindTask(PChar(RawByteString(name)));
  1085. END;
  1086. FUNCTION OldOpenLibrary(const libName : String) : pLibrary;
  1087. BEGIN
  1088. OldOpenLibrary := OldOpenLibrary(PChar(RawByteString(libName)));
  1089. END;
  1090. FUNCTION OpenDevice(const devName : String; unite : ULONG; ioRequest : pIORequest;
  1091. flags : ULONG) : shortint;
  1092. BEGIN
  1093. OpenDevice := OpenDevice(PChar(RawByteString(devName)),unite,ioRequest,flags);
  1094. END;
  1095. FUNCTION OpenLibrary(const libName : String; version : ULONG) : pLibrary;
  1096. BEGIN
  1097. OpenLibrary := OpenLibrary(PChar(RawByteString(libName)),version);
  1098. END;
  1099. FUNCTION OpenResource(const resName : String) : POINTER;
  1100. BEGIN
  1101. OpenResource := OpenResource(PChar(RawByteString(resName)));
  1102. END;
  1103. function RawDoFmt(const formatString : String;const dataStream : POINTER; putChProc : tPROCEDURE; putChData : POINTER): pointer;
  1104. BEGIN
  1105. RawDoFmt := RawDoFmt(PChar(RawByteString(formatString)),dataStream,putChProc,putChData);
  1106. END;
  1107. procedure BeginIO(IORequest: PIORequest);
  1108. begin
  1109. asm
  1110. move.l a6,-(a7)
  1111. move.l ioRequest,a1 ; get IO Request
  1112. move.l 20(a1),a6 ; extract Device ptr
  1113. jsr -30(a6) ; call BEGINIO directly
  1114. move.l (a7)+,a6
  1115. end;
  1116. end;
  1117. function CreateExtIO(Port: PMsgPort; Size: LongInt): PIORequest;
  1118. var
  1119. IOReq: PIORequest;
  1120. begin
  1121. IOReq := nil;
  1122. if port <> nil then
  1123. begin
  1124. IOReq := ExecAllocMem(Size, MEMF_CLEAR or MEMF_PUBLIC);
  1125. if IOReq <> nil then
  1126. begin
  1127. IOReq^.io_Message.mn_Node.ln_Type := NT_REPLYMSG;
  1128. IOReq^.io_Message.mn_Length := Size;
  1129. IOReq^.io_Message.mn_ReplyPort := Port;
  1130. end;
  1131. end;
  1132. CreateExtIO := IOReq;
  1133. end;
  1134. procedure DeleteExtIO(IOReq: PIORequest);
  1135. begin
  1136. if IOReq <> nil then
  1137. begin
  1138. IOReq^.io_Message.mn_Node.ln_Type := $FF;
  1139. IOReq^.io_Message.mn_ReplyPort := PMsgPort(-1);
  1140. IOReq^.io_Device := PDevice(-1);
  1141. ExecFreeMem(IOReq, IOReq^.io_Message.mn_Length);
  1142. end
  1143. end;
  1144. function CreateStdIO(Port: PMsgPort): PIOStdReq;
  1145. begin
  1146. CreateStdIO := PIOStdReq(CreateExtIO(Port, SizeOf(TIOStdReq)))
  1147. end;
  1148. procedure DeleteStdIO(IOReq: PIOStdReq);
  1149. begin
  1150. DeleteExtIO(PIORequest(IOReq))
  1151. end;
  1152. function CreatePort(Name: PChar; Pri: LongInt): PMsgPort;
  1153. var
  1154. SigBit: Byte;
  1155. Port: PMsgPort;
  1156. begin
  1157. SigBit := AllocSignal(-1);
  1158. if SigBit = -1 then
  1159. begin
  1160. CreatePort := nil;
  1161. Exit;
  1162. end;
  1163. Port := ExecAllocmem(SizeOf(TMsgPort), MEMF_CLEAR or MEMF_PUBLIC);
  1164. if Port = nil then
  1165. begin
  1166. FreeSignal(SigBit);
  1167. CreatePort := nil;
  1168. Exit;
  1169. end;
  1170. with Port^ do
  1171. begin
  1172. if Assigned(Name) then
  1173. mp_Node.ln_Name := Name
  1174. else
  1175. mp_Node.ln_Name := nil;
  1176. mp_Node.ln_Pri := Pri;
  1177. mp_Node.ln_Type := NT_MsgPort;
  1178. mp_Flags := PA_Signal;
  1179. mp_SigBit := SigBit;
  1180. mp_SigTask := FindTask(nil);
  1181. end;
  1182. if Assigned(Name) then
  1183. AddPort(Port)
  1184. else
  1185. NewList(Addr(Port^.mp_MsgList));
  1186. CreatePort := Port;
  1187. end;
  1188. procedure DeletePort(Port: PMsgPort);
  1189. begin
  1190. if Port <> nil then
  1191. begin
  1192. if Port^.mp_Node.ln_Name <> nil then
  1193. RemPort(port);
  1194. Port^.mp_Node.ln_Type := $FF;
  1195. Port^.mp_MsgList.lh_Head := PNode(-1);
  1196. FreeSignal(Port^.mp_SigBit);
  1197. ExecFreeMem(Port, SizeOf(TMsgPort));
  1198. end;
  1199. end;
  1200. function CreateTask(Name: STRPTR; Pri: LongInt; InitPC: Pointer; StackSize: LongWord): PTask;
  1201. var
  1202. Memlist: PMemList;
  1203. Task: PTask;
  1204. TotalSize: LongInt;
  1205. begin
  1206. task := nil;
  1207. StackSize := (StackSize + 3) and not 3;
  1208. TotalSize := SizeOf(TMemList) + SizeOf(TTask) + StackSize;
  1209. Memlist := ExecAllocMem(TotalSize, MEMF_PUBLIC + MEMF_CLEAR);
  1210. if MemList <> nil then
  1211. begin
  1212. MemList^.ml_NumEntries := 1;
  1213. MemList^.ml_ME[0].me_Un.meu_Addr := Pointer(MemList + 1);
  1214. MemList^.ml_ME[0].me_Length := TotalSize - SizeOf(TMemList);
  1215. Task := PTask(MemList + SizeOf(TMemList) + StackSize);
  1216. Task^.tc_Node.ln_Pri := Pri;
  1217. Task^.tc_Node.ln_Type := NT_TASK;
  1218. Task^.tc_Node.ln_Name := Name;
  1219. Task^.tc_SPLower := Pointer(MemList + SizeOf(TMemList));
  1220. Task^.tc_SPUpper := Pointer(Task^.tc_SPLower + StackSize);
  1221. Task^.tc_SPReg := Task^.tc_SPUpper;
  1222. NewList(@Task^.tc_MemEntry);
  1223. AddTail(@Task^.tc_MemEntry,@MemList^.ml_Node);
  1224. AddTask(Task, InitPC, nil)
  1225. end;
  1226. CreateTask := Task;
  1227. end;
  1228. procedure DeleteTask (task: pTask);
  1229. begin
  1230. RemTask(task)
  1231. end;
  1232. procedure NewList (list: pList);
  1233. begin
  1234. with list^ do
  1235. begin
  1236. lh_Head := pNode(@lh_Tail);
  1237. lh_Tail := NIL;
  1238. lh_TailPred := pNode(@lh_Head)
  1239. end
  1240. end;
  1241. END. (* UNIT EXEC *)