exec.pas 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2014 by Free Pascal development team
  4. exec.library functions
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. {
  12. missing:
  13. MemHeaderExt (difficult struct)
  14. ETask Substructure in TTask
  15. defines:
  16. AROS_NEED_LONG_ALIGN = ????
  17. AROS_FLAVOUR_BINCOMPAT = AROS_BINCOMPAT (Bincompat mode)
  18. AROS_MORPHOS_COMPATIBLE = ????
  19. }
  20. unit Exec;
  21. {$PACKRECORDS C}
  22. interface
  23. type
  24. APTR = Pointer;
  25. CONST_APTR = Pointer;
  26. LONG = LongInt;
  27. ULONG = LongWord;
  28. QUAD = Int64;
  29. UQUAD = QWord;
  30. IPTR = NativeUInt;
  31. SIPTR = NativeInt;
  32. PIPTR = ^IPTR;
  33. STRPTR = PChar;
  34. CONST_STRPTR = PChar;
  35. BPTR = Pointer;
  36. BSTR = Pointer;
  37. BOOL = SmallInt;
  38. UWORD = Word;
  39. WORDBITS = Word;
  40. LONGBITS = LongWord;
  41. PLONGBITS = ^LONGBITS;
  42. UBYTE = Byte;
  43. PULONG = PLongWord;
  44. PAPTR = ^APTR;
  45. PLONG = PLongInt;
  46. PaSmallInt = PSmallInt;
  47. // TagItem moved from Utilities to exec because needed for records
  48. { This data type may propagate through the system for more general use.
  49. In the meantime, it is used as a general mechanism of extensible data
  50. arrays for parameter specification and property inquiry (coming soon
  51. to a display controller near you).
  52. In practice, an array (or chain of arrays) of TagItems is used.}
  53. type
  54. Tag = LongWord;
  55. PTag = ^Tag;
  56. PTagItem = ^TTagItem;
  57. TTagItem = record
  58. ti_Tag: Tag;
  59. ti_Data: IPTR;
  60. end;
  61. PPTagItem = ^PTagItem;
  62. const
  63. TAG_USER = 1 shl 31; // differentiates user tags from system tags
  64. // END of part from utility move
  65. const
  66. // There is a problem with Boolean vaules in taglists, just use this for now instead
  67. LTrue : LongInt = 1;
  68. LFalse: LongInt = 0;
  69. type
  70. // List Node Structure. Each member in a list starts with a Node
  71. PNode = ^TNode;
  72. {$ifdef AROS_BINCOMPAT}
  73. TNode = record
  74. ln_Succ, // Pointer to next (successor)
  75. ln_Pred : PNode; // Pointer to previous (predecessor)
  76. ln_Type : Byte;
  77. ln_Pri : ShortInt; // Priority, for sorting
  78. ln_Name : STRPTR; // ID string, null terminated
  79. end; // Note: smallint aligned
  80. {$else}
  81. TNode = Record
  82. ln_Succ, // Pointer to next (successor)
  83. ln_Pred : PNode; // Pointer to previous (predecessor)
  84. ln_Name : STRPTR; // ID string, null terminated
  85. ln_Type : Byte;
  86. ln_Pri : ShortInt; // Priority, for sorting
  87. End; // Note: smallint aligned
  88. {$endif}
  89. // minimal node -- no type checking possible
  90. PMinNode = ^TMinNode;
  91. TMinNode = Record
  92. mln_Succ,
  93. mln_Pred : PMinNode;
  94. End;
  95. {
  96. Note: Newly initialized IORequests, and software interrupt structures
  97. used with Cause(), should have type NT_UNKNOWN. The OS will assign a type
  98. when they are first used.
  99. }
  100. // ----- Node Types for LN_TYPE -----
  101. Const
  102. NT_UNKNOWN = 0; // Unknown Node
  103. NT_TASK = 1; // Exec task
  104. NT_INTERRUPT = 2; // Interrupt
  105. NT_DEVICE = 3; // Device
  106. NT_MSGPORT = 4; // Message Port
  107. NT_MESSAGE = 5; // Indicates message currently pending
  108. NT_FREEMSG = 6;
  109. NT_REPLYMSG = 7; // Message has been replied
  110. NT_RESOURCE = 8;
  111. NT_LIBRARY = 9;
  112. NT_MEMORY = 10;
  113. NT_SOFTINT = 11; // Internal flag used by SoftInits
  114. NT_FONT = 12;
  115. NT_PROCESS = 13; // AmigaDOS Process
  116. NT_SEMAPHORE = 14;
  117. NT_SIGNALSEM = 15; // signal semaphores
  118. NT_BOOTNODE = 16;
  119. NT_KICKMEM = 17;
  120. NT_GRAPHICS = 18;
  121. NT_DEATHMESSAGE = 19;
  122. NT_HIDD = 20; // AROS Specific
  123. NT_USER = 254; // User node types work down from here
  124. NT_EXTENDED = 255;
  125. { This file defines Exec system lists, which are used to link
  126. various things. Exec provides several routines to handle list
  127. processing (defined at the bottom of this file), so you can
  128. use these routines to save yourself the trouble of writing a list
  129. package.}
  130. type
  131. // Normal, full featured list
  132. PList = ^TList;
  133. TList = record
  134. lh_Head: PNode;
  135. lh_Tail: PNode;
  136. lh_TailPred: PNode;
  137. lh_Type: Byte;
  138. l_pad: Byte;
  139. end;
  140. // minimum list -- no type checking possible
  141. PMinList = ^TMinList;
  142. TMinList = record
  143. mlh_Head: PMinNode;
  144. mlh_Tail: PMinNode;
  145. mlh_TailPred: PMinNode;
  146. end;
  147. {********************************************************************
  148. *
  149. * Format of the alert error number:
  150. *
  151. * +-+-------------+----------------+--------------------------------+
  152. * |D| SubSysId | General Error | SubSystem Specific Error |
  153. * +-+-------------+----------------+--------------------------------+
  154. * 1 7 bits 8 bits 16 bits
  155. *
  156. * D: DeadEnd alert
  157. * SubSysId: indicates ROM subsystem number.
  158. * General Error: roughly indicates what the error was
  159. * Specific Error: indicates more detail
  160. *********************************************************************}
  161. { ********************************************************************
  162. *
  163. * General Alerts
  164. *
  165. * For example: timer.device cannot open math.library would be $05038015
  166. *
  167. * Alert(AN_TimerDev|AG_OpenLib|AO_MathLib);
  168. *
  169. ********************************************************************}
  170. const
  171. // General Types
  172. AT_DeadEnd = $80000000; // Alert that crashes
  173. AT_Recovery = $00000000; // Alert that returns
  174. // General purpose alert codes }
  175. AG_NoMemory = $00010000;
  176. AG_MakeLib = $00020000;
  177. AG_OpenLib = $00030000;
  178. AG_OpenDev = $00040000;
  179. AG_OpenRes = $00050000;
  180. AG_IOError = $00060000;
  181. AG_NoSignal = $00070000;
  182. AG_BadParm = $00080000;
  183. AG_CloseLib = $00090000; // usually too many closes
  184. AG_CloseDev = $000A0000; // or a mismatched close
  185. AG_ProcCreate = $000B0000; // Process creation failed
  186. {*********************************************************************
  187. *
  188. * Hardware/CPU specific alerts: They may show without the 8 at the
  189. * front of the number. These are CPU/68000 specific. See 68$0
  190. * programmer's manuals for more details.
  191. *
  192. *********************************************************************}
  193. ACPU_BusErr = $80000002; // Hardware bus fault/access error
  194. ACPU_AddressErr = $80000003; // Illegal address access (ie: odd)
  195. ACPU_InstErr = $80000004; // Illegal instruction
  196. ACPU_DivZero = $80000005; // Divide by zero
  197. ACPU_CHK = $80000006; // Check instruction error
  198. ACPU_TRAPV = $80000007; // TrapV instruction error
  199. ACPU_PrivErr = $80000008; // Privilege violation error
  200. ACPU_Trace = $80000009; // Trace error
  201. ACPU_LineA = $8000000A; // Line 1010 Emulator error
  202. ACPU_LineF = $8000000B; // Line 1111 Emulator error
  203. ACPU_Format = $8000000E; // Stack frame format error
  204. ACPU_Spurious = $80000018; // Spurious interrupt error
  205. ACPU_AutoVec1 = $80000019; // AutoVector Level 1 interrupt error
  206. ACPU_AutoVec2 = $8000001A; // AutoVector Level 2 interrupt error
  207. ACPU_AutoVec3 = $8000001B; // AutoVector Level 3 interrupt error
  208. ACPU_AutoVec4 = $8000001C; // AutoVector Level 4 interrupt error
  209. ACPU_AutoVec5 = $8000001D; // AutoVector Level 5 interrupt error
  210. ACPU_AutoVec6 = $8000001E; // AutoVector Level 6 interrupt error
  211. ACPU_AutoVec7 = $8000001F; // AutoVector Level 7 interrupt error
  212. // alert libraries
  213. AO_ExecLib = $00008001;
  214. AO_GraphicsLib = $00008002;
  215. AO_LayersLib = $00008003;
  216. AO_Intuition = $00008004;
  217. AO_MathLib = $00008005;
  218. AO_DOSLib = $00008007;
  219. AO_RAMLib = $00008008;
  220. AO_IconLib = $00008009;
  221. AO_ExpansionLib = $0000800A;
  222. AO_DiskfontLib = $0000800B;
  223. AO_UtilityLib = $0000800C;
  224. AO_KeyMapLib = $0000800D;
  225. // alert devices
  226. AO_AudioDev = $00008010;
  227. AO_ConsoleDev = $00008011;
  228. AO_GamePortDev = $00008012;
  229. AO_KeyboardDev = $00008013;
  230. AO_TrackDiskDev = $00008014;
  231. AO_TimerDev = $00008015;
  232. // alert resources
  233. AO_CIARsrc = $00008020;
  234. AO_DiskRsrc = $00008021;
  235. AO_MiscRsrc = $00008022;
  236. // alert other
  237. AO_BootStrap = $00008030;
  238. AO_Workbench = $00008031;
  239. AO_DiskCopy = $00008032;
  240. AO_GadTools = $00008033;
  241. AO_Unknown = $00008035;
  242. // AROS Additions, start at $40
  243. AO_ArosLib = $00008040;
  244. AO_OOPLib = $00008041;
  245. AO_HiddLib = $00008042;
  246. {********************************************************************
  247. *
  248. * Specific Alerts:
  249. *
  250. ********************************************************************}
  251. // exec.library
  252. AN_ExecLib = $01000000;
  253. AN_ExcptVect = $01000001; // 68000 exception vector checksum (obs.)
  254. AN_BaseChkSum = $01000002; // Execbase checksum (obs.)
  255. AN_LibChkSum = $01000003; // Library checksum failure
  256. AN_MemCorrupt = $81000005; // Corrupt memory list detected in FreeMem
  257. AN_IntrMem = $81000006; // No memory for interrupt servers
  258. AN_InitAPtr = $01000007; // InitStruct() of an APTR source (obs.)
  259. AN_SemCorrupt = $01000008; // A semaphore is in an illegal state at ReleaseSempahore()
  260. AN_FreeTwice = $01000009; // Freeing memory already freed
  261. AN_BogusExcpt = $8100000A; // illegal 68k exception taken (obs.)
  262. AN_IOUsedTwice = $0100000B; // Attempt to reuse active IORequest
  263. AN_MemoryInsane = $0100000C; // Sanity check on memory list failed during AvailMem(MEMF_LARGEST)
  264. AN_IOAfterClose = $0100000D; // IO attempted on closed IORequest
  265. AN_StackProbe = $0100000E; // Stack appears to extend out of range
  266. AN_BadFreeAddr = $0100000F; // Memory header not located. [ Usually an invalid address passed to FreeMem() ]
  267. AN_BadSemaphore = $01000010; // An attempt was made to use the old message semaphores.
  268. // dos.library
  269. AN_DOSLib = $07000000;
  270. AN_StartMem = $07010001; // no memory at startup
  271. AN_EndTask = $07000002; // EndTask didn't
  272. AN_QPktFail = $07000003; // Qpkt failure
  273. AN_AsyncPkt = $07000004; // Unexpected packet received
  274. AN_FreeVec = $07000005; // Freevec failed
  275. AN_DiskBlkSeq = $07000006; // Disk block sequence error
  276. AN_BitMap = $07000007; // Bitmap corrupt
  277. AN_KeyFree = $07000008; // Key already free
  278. AN_BadChkSum = $07000009; // Invalid checksum
  279. AN_DiskError = $0700000A; // Disk Error
  280. AN_KeyRange = $0700000B; // Key out of range
  281. AN_BadOverlay = $0700000C; // Bad overlay
  282. AN_BadInitFunc = $0700000D; // Invalid init packet for cli/shell
  283. AN_FileReclosed = $0700000E; // A filehandle was closed more than once
  284. // graphics.library
  285. AN_GraphicsLib = $02000000;
  286. AN_GfxNoMem = $82010000; // graphics out of memory
  287. AN_GfxNoMemMspc = $82010001; // MonitorSpec alloc, no memory
  288. AN_LongFrame = $82010006; // long frame, no memory
  289. AN_ShortFrame = $82010007; // short frame, no memory
  290. AN_TextTmpRas = $02010009; // text, no memory for TmpRas
  291. AN_BltBitMap = $8201000A; // BltBitMap, no memory
  292. AN_RegionMemory = $8201000B; // regions, memory not available
  293. AN_MakeVPort = $82010030; // MakeVPort, no memory
  294. AN_GfxNewError = $0200000C;
  295. AN_GfxFreeError = $0200000D;
  296. AN_GfxNoLCM = $82011234; // emergency memory not available
  297. AN_ObsoleteFont = $02000401; // unsupported font description used
  298. // intuition.library
  299. AN_Intuition = $04000000;
  300. AN_GadgetType = $84000001; // unknown gadget type
  301. AN_BadGadget = $04000001; // Recovery form of AN_GadgetType
  302. AN_CreatePort = $84010002; // create port, no memory
  303. AN_ItemAlloc = $04010003; // item plane alloc, no memory
  304. AN_SubAlloc = $04010004; // sub alloc, no memory
  305. AN_PlaneAlloc = $84010005; // plane alloc, no memory
  306. AN_ItemBoxTop = $84000006; // item box top < RelZero
  307. AN_OpenScreen = $84010007; // open screen, no memory
  308. AN_OpenScrnRast = $84010008; // open screen, raster alloc, no memory
  309. AN_SysScrnType = $84000009; // open sys screen, unknown type
  310. AN_AddSWGadget = $8401000A; // add SW gadgets, no memory
  311. AN_OpenWindow = $8401000B; // open window, no memory
  312. AN_BadState = $8400000C; // Bad State Return entering Intuition
  313. AN_BadMessage = $8400000D; // Bad Message received by IDCMP
  314. AN_WeirdEcho = $8400000E; // Weird echo causing incomprehension
  315. AN_NoConsole = $8400000F; // couldn't open the Console Device
  316. AN_NoISem = $04000010; // Intuition skipped obtaining a sem
  317. AN_ISemOrder = $04000011; // Intuition obtained a sem in bad order
  318. // System utility library
  319. AN_UtilityLib = $34000000;
  320. // layers.library
  321. AN_LayersLib = $03000000;
  322. AN_LayersNoMem = $83010000; // layers out of memory
  323. // math.library
  324. AN_MathLib = $05000000;
  325. // expansion.library
  326. AN_ExpansionLib = $0A000000;
  327. AN_BadExpansionFree = $0A000001; // freeed free region
  328. // ramlib.library
  329. AN_RAMLib = $08000000;
  330. AN_BadSegList = $08000001; // no overlays in library seglists
  331. // diskfont.library
  332. AN_DiskfontLib = $0B000000;
  333. // icon.library
  334. AN_IconLib = $09000000;
  335. // Gadtools.library toolkit for Intuition
  336. AN_GadTools = $33000000;
  337. // audio.device
  338. AN_AudioDev = $10000000;
  339. // console.device
  340. AN_ConsoleDev = $11000000;
  341. AN_NoWindow = $11000001; // Console can't open initial window
  342. // gameport.device
  343. AN_GamePortDev = $12000000;
  344. // keyboard.device
  345. AN_KeyboardDev = $13000000;
  346. // ------ trackdisk.device
  347. AN_TrackDiskDev = $14000000;
  348. AN_TDCalibSeek = $14000001; // calibrate: seek error
  349. AN_TDDelay = $14000002; // delay: error on timer wait
  350. // timer.device
  351. AN_TimerDev = $15000000;
  352. AN_TMBadReq = $15000001; // bad request
  353. AN_TMBadSupply = $15000002; // power supply -- no 50/60Hz ticks
  354. // cia.resource
  355. AN_CIARsrc = $20000000;
  356. // disk.resource
  357. AN_DiskRsrc = $21000000;
  358. AN_DRHasDisk = $21000001; // get unit: already has disk
  359. AN_DRIntNoAct = $21000002; // interrupt: no active unit
  360. // misc.resource
  361. AN_MiscRsrc = $22000000;
  362. // bootstrap
  363. AN_BootStrap = $30000000;
  364. AN_BootError = $30000001; // boot code returned an error
  365. // Workbench
  366. AN_Workbench = $31000000;
  367. AN_NoFonts = $B1000001;
  368. AN_WBBadStartupMsg1 = $31000001;
  369. AN_WBBadStartupMsg2 = $31000002;
  370. AN_WBBadIOMsg = $31000003;
  371. AN_WBReLayoutToolMenu = $B1010009;
  372. // DiskCopy
  373. AN_DiskCopy = $32000000;
  374. // For use by any application that needs it
  375. AN_Unknown = $35000000;
  376. // AROS Additions
  377. AN_Aros = $40000000;
  378. AN_OOP = $41000000;
  379. // Hidd Subsystem
  380. AN_Hidd = $42000000;
  381. AN_HiddNoRoot = $C2000001;
  382. const
  383. IOERR_OPENFAIL = -1; // device/unit failed to open
  384. IOERR_ABORTED = -2; // request terminated early [after AbortIO()]
  385. IOERR_NOCMD = -3; // command not supported by device
  386. IOERR_BADLENGTH = -4; // not a valid length (usually IO_LENGTH)
  387. IOERR_BADADDRESS = -5; // invalid address (misaligned or bad range)
  388. IOERR_UNITBUSY = -6; // device opens ok, but requested unit is busy
  389. IOERR_SELFTEST = -7; // hardware failed self-test
  390. type
  391. PResident = ^TResident;
  392. TResident = record
  393. rt_MatchWord: Word; // smallint to match on (ILLEGAL)
  394. rt_MatchTag: PResident; // pointer to the above
  395. rt_EndSkip: APTR; // address to continue scan
  396. rt_Flags: Byte; // various tag flags
  397. rt_Version: Byte; // release version number
  398. rt_Type: Byte; // type of module (NT_mumble)
  399. rt_Pri: ShortInt; // initialization priority
  400. rt_Name: CONST_STRPTR; // pointer to node name
  401. rt_IdString: CONST_STRPTR;// pointer to ident string
  402. rt_Init: APTR; // pointer to init code
  403. rt_Revision: Word; // Extension taken over from MorphOS. Only valid if RTF_EXTENDED is set
  404. rt_Tags: PTagItem; // PTagItem
  405. end;
  406. const
  407. RTC_MATCHWORD = $4AFC;
  408. RTF_COLDSTART = $01;
  409. RTF_SINGLETASK = $02;
  410. RTF_AFTERDOS = $04;
  411. RTF_AUTOINIT = $80;
  412. RTF_EXTENDED = $40; // MorphOS extension: extended structure fields are valid
  413. // Compatibility:
  414. RTW_NEVER = $00;
  415. RTW_COLDSTART = $01;
  416. RTT_STARTUP = TAG_USER + $04AF1234;
  417. type
  418. //****** MemChunk ****************************************************
  419. PMemChunk = ^TMemChunk;
  420. TMemChunk = record
  421. mc_Next: PMemChunk; // pointer to next chunk
  422. mc_Bytes: IPTR; // chunk byte size
  423. end;
  424. //****** MemHeader ***************************************************
  425. PMemHeader = ^TMemHeader;
  426. TMemHeader = record
  427. mh_Node: TNode;
  428. mh_Attributes: Word; // characteristics of this region
  429. mh_First: PMemChunk; // first free region
  430. mh_Lower, // lower memory bound
  431. mh_Upper: APTR; // upper memory bound+1
  432. mh_Free: ULONG; // total number of free bytes
  433. end;
  434. //****** MemEntry ****************************************************
  435. PMemEntry = ^TMemEntry;
  436. TMemEntry = record
  437. me_Un: record
  438. case LongInt of
  439. 0: (meu_Reqs: ULONG);
  440. 1: (meu_Addr: APTR);
  441. end;
  442. me_Length: ULONG;
  443. end;
  444. //****** MemList *****************************************************
  445. // Note: sizeof(TMemList) includes the size of the first MemEntry
  446. PMemList = ^TMemList;
  447. TMemList = record
  448. ml_Node: TNode;
  449. ml_NumEntries: Word; // number of entries in this struct
  450. ml_ME: array [0..0] of TMemEntry; // the first entry
  451. End;
  452. // Memory Requirement Types
  453. // See the AllocMem() documentation for details
  454. const
  455. MEMF_ANY = $0; // Any type of memory will do
  456. MEMF_PUBLIC = 1 shl 0;
  457. MEMF_CHIP = 1 shl 1;
  458. MEMF_FAST = 1 shl 2;
  459. MEMF_EXECUTABLE = 1 shl 4; // AmigaOS 4 Compatible
  460. MEMF_LOCAL = 1 shl 8;
  461. MEMF_24BITDMA = 1 shl 9; // DMAable memory within 24 bits of address
  462. MEMF_KICK = 1 shl 10; // Memory that can be used for KickTags
  463. MEMF_31BIT = 1 shl 12; // Low address space (<2GB). Effective only on 64 bit machines.
  464. MEMF_CLEAR = 1 shl 16; // Explicitly clear memory after allocation
  465. MEMF_LARGEST = 1 shl 17;
  466. MEMF_REVERSE = 1 shl 18;
  467. MEMF_TOTAL = 1 shl 19; // AvailMem: return total size of memory
  468. MEMF_HWALIGNED = 1 shl 20; // For AllocMem() - align address and size to physical page boundary
  469. MEMF_SEM_PROTECTED = 1 shl 20; // For CreatePool() - add semaphore protection to the pool
  470. MEMF_NO_EXPUNGE = 1 shl 31; // AllocMem: Do not cause expunge on failure
  471. MEM_BLOCKSIZE = 8;
  472. MEM_BLOCKMASK = MEM_BLOCKSIZE-1;
  473. {$ifdef CPU64}
  474. MEMF_PHYSICAL_MASK = MEMF_PUBLIC or MEMF_CHIP or MEMF_FAST or MEMF_LOCAL or MEMF_24BITDMA or MEMF_KICK or MEMF_31BIT;
  475. {$else}
  476. MEMF_PHYSICAL_MASK = MEMF_PUBLIC or MEMF_CHIP or MEMF_FAST or MEMF_LOCAL or MEMF_24BITDMA or MEMF_KICK;
  477. {$endif}
  478. type
  479. //***** MemHandlerData *********************************************
  480. // Note: This structure is *READ ONLY* and only EXEC can create it!
  481. PMemHandlerData = ^TMemHandlerData;
  482. TMemHandlerData = record
  483. memh_RequestSize, // Requested allocation size
  484. memh_RequestFlags, // Requested allocation flags
  485. memh_Flags: ULONG; // Flags (see below)
  486. end;
  487. const
  488. MEMHF_RECYCLE = 1; // 0 = First time, 1 = recycle
  489. //***** Low Memory handler return values **************************
  490. MEM_ALL_DONE = -1; // We did all we could do
  491. MEM_DID_NOTHING = 0; // Nothing we could do...
  492. MEM_TRY_AGAIN = 1; // We did some, try the allocation again
  493. type
  494. PInterrupt = ^TInterrupt;
  495. TInterrupt = record
  496. is_Node: TNode;
  497. is_Data: APTR; // Server data segment
  498. is_Code: Pointer; // Server code entry
  499. end;
  500. // PRIVATE
  501. PIntVector = ^TIntVector;
  502. TIntVector = record // For EXEC use ONLY!
  503. iv_Data: APTR;
  504. iv_Code: Pointer;
  505. iv_Node: PNode;
  506. end;
  507. // PRIVATE
  508. PSoftIntList = ^TSoftIntList;
  509. TSoftIntList = record // For EXEC use ONLY!
  510. sh_List: TList;
  511. sh_Pad : Word;
  512. end;
  513. const
  514. SIH_PRIMASK = $F0;
  515. // this is a fake INT definition, used only for AddIntServer and the like
  516. INTB_NMI = 15;
  517. INTF_NMI = 1 shl 15;
  518. { Offset of kernel interrupt vectors.
  519. Usage:
  520. AddIntServer(INTB_KERNEL + irq, irq_handler);
  521. RemIntServer(INTB_KERNEL + irq, irq_handler); }
  522. INTB_KERNEL = 16;
  523. { This file defines ports and messages, which are used for inter-
  524. task communications using the routines defined toward the
  525. bottom of this file.}
  526. type
  527. //****** MsgPort *****************************************************
  528. PMsgPort = ^TMsgPort;
  529. TMsgPort = record
  530. mp_Node: TNode;
  531. mp_Flags: Byte;
  532. mp_SigBit: Byte; { signal bit number }
  533. mp_SigTask: Pointer; { task to be signalled (TaskPtr) }
  534. mp_MsgList: TList; { message linked list }
  535. end;
  536. //****** Message *****************************************************
  537. PMessage = ^TMessage;
  538. TMessage = record
  539. mn_Node: TNode;
  540. mn_ReplyPort: PMsgPort; // message reply port
  541. mn_Length: Word; // message len in bytes (include the size of the Message structure in the length)
  542. end;
  543. //****** MagicMessage ***********************************************
  544. PMagicMessage = ^TMagicMessage;
  545. TMagicMessage = record
  546. mn_Node: TNode;
  547. mn_ReplyPort: PMsgPort; // message reply port
  548. mn_Length: Word; // total message length, in bytes (include the size of the Message structure in the length)
  549. mn_Magic: ULONG; // can be used to figure out the message sender
  550. mn_Version: ULONG; // version can be used to extend a message in later versions
  551. end;
  552. { definition for entry Magic in Messages
  553. Magic is introduced to prevent Multiple Ports, for example if you´r using
  554. ScreenNotifications and DecorNotifications you must have two Ports as long
  555. as you cannot figure out which Messsage ist posted. With Magic this is no
  556. problem.}
  557. const
  558. MAGIC_DECORATOR = $8000001;
  559. MAGIC_SCREENNOTIFY = $8000002;
  560. { Every Amiga Task has one of these Task structures associated with it.
  561. To find yours, use FindTask(Nil). AmigaDOS processes tack a few more
  562. values on to the end of this structure, which is the difference between
  563. Tasks and Processes.}
  564. type
  565. PTask = ^TTask;
  566. TTask = record
  567. tc_Node: TNode;
  568. tc_Flags: Byte;
  569. tc_State: Byte;
  570. tc_IDNestCnt: Shortint; // intr disabled nesting
  571. tc_TDNestCnt: Shortint; // task disabled nesting
  572. tc_SigAlloc: ULONG; // sigs allocated
  573. tc_SigWait: ULONG; // sigs we are waiting for
  574. tc_SigRecvd: ULONG; // sigs we have received
  575. tc_SigExcept: ULONG; // sigs we will take excepts for
  576. case boolean of
  577. True:(
  578. tc_TrapAlloc: Word; // traps allocated
  579. tc_TrapAble: Word;); // traps enabled
  580. False:(
  581. tc_ETask: Pointer; // Valid if TF_ETask is set
  582. tc_ExceptData: APTR; // points to except data
  583. tc_ExceptCode: APTR; // points to except code
  584. tc_TrapData: APTR; // points to trap data
  585. tc_TrapCode: APTR; // points to trap code
  586. tc_SPReg: APTR; // stack pointer
  587. tc_SPLower: APTR; // stack lower bound
  588. tc_SPUpper: APTR; // stack upper bound + 2
  589. tc_Switch: Pointer; // task losing CPU
  590. tc_Launch: Pointer; // task getting CPU
  591. tc_MemEntry: TList; // allocated memory
  592. tc_UserData: APTR; // per task data
  593. );
  594. end;
  595. // Stack swap structure as passed to StackSwap()
  596. PStackSwapStruct = ^TStackSwapStruct;
  597. TStackSwapStruct = record
  598. stk_Lower: APTR; // Lowest byte of stack
  599. stk_Upper: APTR; // Upper end of stack (size + Lowest)
  600. stk_Pointer: APTR; // Stack pointer at switch point
  601. end;
  602. PStackSwapArgs = ^TStackSwapArgs;
  603. TStackSwapArgs = record
  604. Args: array[0..7] of IPTR;
  605. end;
  606. const
  607. //----- Flag Bits ------------------------------------------
  608. TB_PROCTIME = 0;
  609. TB_ETASK = 3;
  610. TB_STACKCHK = 4;
  611. TB_EXCEPT = 5;
  612. TB_SWITCH = 6;
  613. TB_LAUNCH = 7;
  614. TF_PROCTIME = 1;
  615. TF_ETASK = 8;
  616. TF_STACKCHK = 16;
  617. TF_EXCEPT = 32;
  618. TF_SWITCH = 64;
  619. TF_LAUNCH = 128;
  620. //----- Task States (tc_State) ---------------------------------
  621. TS_INVALID = 0;
  622. TS_ADDED = 1;
  623. TS_RUN = 2;
  624. TS_READY = 3;
  625. TS_WAIT = 4;
  626. TS_EXCEPT = 5;
  627. TS_REMOVED = 6;
  628. //----- Predefined Signals -------------------------------------
  629. SIGB_ABORT = 0;
  630. SIGB_CHILD = 1;
  631. SIGB_BLIT = 4; // Note: same as SIGB_SINGLE
  632. SIGB_SINGLE = 4; // Note: same as SIGB_BLIT
  633. SIGB_INTUITION = 5;
  634. SIGB_NET = 7;
  635. SIGB_DOS = 8;
  636. SIGF_ABORT = 1;
  637. SIGF_CHILD = 2;
  638. SIGF_BLIT = 16;
  639. SIGF_SINGLE = 16;
  640. SIGF_INTUITION = 32;
  641. SIGF_NET = 128;
  642. SIGF_DOS = 256;
  643. type
  644. {$ifdef AROS_MORPHOS_COMPATIBLE}
  645. TETask = record
  646. Message: TMessage;
  647. Parent: PTask; // Pointer to task
  648. UniqueID: ULONG;
  649. Children: TMinList; // List of children
  650. TrapAlloc: Word;
  651. TrapAble: Word;
  652. Result1: ULONG; // First result
  653. Result2: APTR; // Result data pointer (AllocVec)
  654. MsgPort: TMsgPort;
  655. MemPool: Pointer;
  656. Reserved: array[0..1] of Pointer;
  657. RegFrame: Pointer;
  658. // Internal fields follow
  659. end;
  660. {$else}
  661. // Extended Task structure
  662. TETask = record
  663. et_Message: TMessage;
  664. et_Parent: APTR; // Pointer to parent task
  665. et_UniqueID: ULONG;
  666. et_Children: TMinList; // List of children
  667. et_TrapAlloc: Word;
  668. et_TrapAble: Word;
  669. et_Result1: ULONG; // First result
  670. et_Result2: APTR; // Result data pointer (AllocVec)
  671. et_TaskMsgPort: TMsgPort;
  672. et_Compatibility: array[0..3] of APTR; // Reserve this space for compiled software to access iet_startup and iet_acpd
  673. et_MemPool: Pointer; // Task's private memory pool
  674. {$ifdef aros}
  675. et_Reserved: array[0..0] of IPTR; // MorphOS Private
  676. et_TaskStorage: Pointer; // Task Storage Slots
  677. {$else}
  678. et_Reserved: array[0..1] of IPTR; // MorphOS Private
  679. {$endif}
  680. et_RegFrame: Pointer;
  681. // Internal fields follow
  682. end;
  683. {$endif}
  684. const
  685. // Return codes from new child functions
  686. CHILD_NOTNEW = 1; // function not called from a new style task
  687. CHILD_NOTFOUND = 2; // Child not found
  688. CHILD_EXITED = 3; // Child has exited
  689. CHILD_ACTIVE = 4; // Child is currently active and running
  690. TASKTAG_Dummy = TAG_USER + $100000;
  691. TASKTAG_ERROR = TASKTAG_Dummy + 0;
  692. TASKTAG_CODETYPE = TASKTAG_Dummy + 1;
  693. TASKTAG_PC = TASKTAG_Dummy + 2;
  694. TASKTAG_FINALPC = TASKTAG_Dummy + 3;
  695. TASKTAG_STACKSIZE = TASKTAG_Dummy + 4;
  696. TASKTAG_NAME = TASKTAG_Dummy + 6;
  697. TASKTAG_USERDATA = TASKTAG_Dummy + 7;
  698. TASKTAG_PRI = TASKTAG_Dummy + 8;
  699. TASKTAG_POOLPUDDLE = TASKTAG_Dummy + 9;
  700. TASKTAG_POOLTHRESH = TASKTAG_Dummy + 10;
  701. TASKTAG_ARG1 = TASKTAG_Dummy + 16;
  702. TASKTAG_ARG2 = TASKTAG_Dummy + 17;
  703. TASKTAG_ARG3 = TASKTAG_Dummy + 18;
  704. TASKTAG_ARG4 = TASKTAG_Dummy + 19;
  705. TASKTAG_ARG5 = TASKTAG_Dummy + 20;
  706. TASKTAG_ARG6 = TASKTAG_Dummy + 21;
  707. TASKTAG_ARG7 = TASKTAG_Dummy + 22;
  708. TASKTAG_ARG8 = TASKTAG_Dummy + 23;
  709. TASKTAG_STARTUPMSG = TASKTAG_Dummy + 24;
  710. TASKTAG_TASKMSGPORT = TASKTAG_Dummy + 25;
  711. TASKTAG_FLAGS = TASKTAG_Dummy + 26;
  712. TASKTAG_TCBEXTRASIZE = TASKTAG_Dummy + 28;
  713. TASKERROR_OK = 0;
  714. TASKERROR_NOMEMORY = 1;
  715. // Actions for ShutdownA()
  716. SD_ACTION_POWEROFF = 0;
  717. SD_ACTION_COLDREBOOT = 1;
  718. // mp_Flags: Port arrival actions (PutMsg)
  719. const
  720. PF_ACTION = 7; // Mask
  721. PA_SIGNAL = 0; // Signal task in mp_SigTask
  722. PA_SOFTINT = 1; // Signal SoftInt in mp_SoftInt/mp_SigTask
  723. PA_IGNORE = 2; // Ignore arrival
  724. PA_CALL = 3; // Call function in mp_SigTask. This was never
  725. // documented on AmigaOS and was never defined
  726. // but would work for mp_Flags = 3
  727. PA_FASTCALL = 4; // AROS extension. Like PA_SOFTINT, calls an
  728. // Interrupt in mp_SoftInt, but passes the
  729. // message as the third argument without doesn't
  730. // add it to the message list and so doesn't
  731. // require any locking, task switching or
  732. // Disable()/Enable() pairs */
  733. // Semaphore
  734. type
  735. // This is the structure used to request a signal semaphore
  736. PSemaphoreRequest = ^TSemaphoreRequest;
  737. TSemaphoreRequest = record
  738. sr_Link: TMinNode;
  739. sr_Waiter: PTask;
  740. end;
  741. // The actual semaphore itself
  742. PSignalSemaphore = ^TSignalSemaphore;
  743. TSignalSemaphore = record
  744. ss_Link: TNode;
  745. ss_NestCount: SmallInt;
  746. ss_WaitQueue: TMinList;
  747. ss_MultipleLink: TSemaphoreRequest;
  748. ss_Owner: PTask;
  749. ss_QueueCount: SmallInt;
  750. end;
  751. // Semaphore procure message for Procure/Vacate
  752. PSemaphoreMessage = ^TSemaphoreMessage;
  753. TSemaphoreMessage = record
  754. ssm_Message: TMessage;
  755. ssm_Semaphore: PSignalSemaphore;
  756. end;
  757. { not in aros?
  758. PSemaphore = ^TSemaphore;
  759. TSemaphore = record
  760. sm_MsgPort: TMsgPort;
  761. sm_Bids: SmallInt;
  762. end;
  763. }
  764. const
  765. SM_SHARED = 1;
  766. SM_EXCLUSIVE = 0;
  767. //------ Special Constants ---------------------------------------
  768. LIB_RESERVED = 4; // Exec reserves the first 4 vectors
  769. LIB_VECTSIZE = 6; // Each library entry takes 6 bytes
  770. LIB_BASE = (-LIB_VECTSIZE);
  771. LIB_USERDEF = (LIB_BASE-(LIB_RESERVED*LIB_VECTSIZE));
  772. LIB_NONSTD = (LIB_USERDEF);
  773. //------ Standard functions --------------------------------------
  774. LIB_OPEN = LIB_BASE * 1;
  775. LIB_CLOSE = LIB_BASE * 2;
  776. LIB_EXPUNGE = LIB_BASE * 3;
  777. LIB_EXTFUNC = LIB_BASE * 4; // for future expansion
  778. type
  779. //------ Library Base Structure ----------------------------------
  780. // Also used for Devices and some Resources
  781. PLibrary = ^TLibrary;
  782. TLibrary = record
  783. lib_Node: TNode;
  784. lib_Flags,
  785. lib_pad: Byte;
  786. lib_NegSize, // number of bytes before library
  787. lib_PosSize, // number of bytes after library
  788. lib_Version, // major
  789. lib_Revision: Word; // minor
  790. {$ifdef AROS_NEED_LONG_ALIGN}
  791. lib_pad1: Word;
  792. {$endif}
  793. lib_IdString: STRPTR; // ASCII identification
  794. lib_Sum: ULONG; // the checksum itself
  795. lib_OpenCnt: Word; // number of current opens
  796. {$ifdef AROS_NEED_LONG_ALIGN}
  797. lib_pad2: Word;
  798. {$endif}
  799. end; // Warning: size is not a longword multiple!
  800. const
  801. // lib_Flags bit definitions (all others are system reserved)
  802. LIBF_SUMMING = 1 shl 0; // we are currently checksumming
  803. LIBF_CHANGED = 1 shl 1; // we have just changed the lib
  804. LIBF_SUMUSED = 1 shl 2; // set if we should bother to sum
  805. LIBF_DELEXP = 1 shl 3; // delayed expunge
  806. // ID numbers for Exec/TaggedOpenLibrary
  807. TAGGEDOPEN_GRAPHICS = 1;
  808. TAGGEDOPEN_LAYERS = 2;
  809. TAGGEDOPEN_INTUITION = 3;
  810. TAGGEDOPEN_DOS = 4;
  811. TAGGEDOPEN_ICON = 5;
  812. TAGGEDOPEN_EXPANSION = 6;
  813. TAGGEDOPEN_UTILITY = 7;
  814. TAGGEDOPEN_KEYMAP = 8;
  815. TAGGEDOPEN_GADTOOLS = 9;
  816. TAGGEDOPEN_WORKBENCH = 10;
  817. { This file defines the constants and types required to use
  818. Amiga device IO routines, which are also defined here.}
  819. type
  820. //***** Device ****************************************************
  821. PDevice = ^TDevice;
  822. TDevice = record
  823. dd_Library: TLibrary;
  824. end;
  825. //***** Unit ******************************************************
  826. PUnit = ^TUnit;
  827. TUnit = record
  828. unit_MsgPort: TMsgPort; // queue for unprocessed messages instance of msgport is recommended
  829. unit_flags,
  830. unit_pad : Byte;
  831. unit_OpenCnt: Word; // number of active opens
  832. end;
  833. const
  834. UNITF_ACTIVE = 1 shl 0;
  835. UNITF_INTASK = 1 shl 1;
  836. type
  837. PIORequest = ^TIORequest;
  838. TIORequest = record
  839. io_Message: TMessage;
  840. io_Device: PDevice; // device node pointer
  841. io_Unit: PUnit; // unit (driver private)
  842. io_Command: Word; // device command
  843. io_Flags: Byte;
  844. io_Error: ShortInt; // error or warning num
  845. end;
  846. PIOStdReq = ^TIOStdReq;
  847. TIOStdReq = record
  848. io_Message: TMessage;
  849. io_Device: PDevice; // device node pointe
  850. io_Unit: PUnit; // unit (driver private)
  851. io_Command: Word; // device command
  852. io_Flags: Byte;
  853. io_Error: ShortInt; // error or warning num
  854. io_Actual: ULONG; // actual number of bytes transferred
  855. io_Length: ULONG; // requested number bytes transferred
  856. io_Data: APTR; // points to data area
  857. io_Offset: ULONG; // offset for block structured devices
  858. end;
  859. // library vector offsets for device reserved vectors
  860. const
  861. DEV_BEGINIO = -30;
  862. DEV_ABORTIO = -36;
  863. { io_Flags defined bits }
  864. IOB_QUICK = 0;
  865. IOF_QUICK = 1;
  866. CMD_INVALID = 0;
  867. CMD_RESET = 1;
  868. CMD_READ = 2;
  869. CMD_WRITE = 3;
  870. CMD_UPDATE = 4;
  871. CMD_CLEAR = 5;
  872. CMD_STOP = 6;
  873. CMD_START = 7;
  874. CMD_FLUSH = 8;
  875. CMD_NONSTD = 9;
  876. { Definition of the Exec library base structure (pointed to by location 4).
  877. ** Most fields are not to be viewed or modified by user programs. Use
  878. ** extreme caution.
  879. }
  880. type
  881. PArosSupportBase = ^TArosSupportBase;
  882. TArosSupportBase = record
  883. StdOut: Pointer;
  884. kPrintfPtr: Pointer;
  885. rkPrintfPtr: Pointer;
  886. vkPrintfPtr: Pointer;
  887. DebugConfig: Pointer;
  888. end;
  889. PExecBase = ^TExecBase;
  890. TExecBase = record
  891. // Standard Library Structure
  892. LibNode: TLibrary; // Standard library node
  893. { ******* Static System Variables ******* }
  894. SoftVer: Word; // kickstart release number (obs.)
  895. LowMemChkSum: SmallInt; // checksum of 68000 trap vectors
  896. ChkBase: ULONG; // system base pointer complement
  897. ColdCapture, // coldstart soft capture vector
  898. CoolCapture, // coolstart soft capture vector
  899. WarmCapture, // warmstart soft capture vector
  900. SysStkUpper, // system stack base (upper bound)
  901. SysStkLower: APTR; // top of system stack (lower bound)
  902. MaxLocMem: IPTR; // top of chip memory
  903. DebugEntry, // global debugger entry point
  904. DebugData, // global debugger data segment
  905. AlertData, // alert data segment
  906. MaxExtMem: APTR; // top of extended mem, or null if none
  907. ChkSum: Word; // for all of the above (minus 2)
  908. //***** Interrupt Related *****************************************
  909. IntVects: array[0..15] of TIntVector;
  910. //***** Dynamic System Variables **********************************
  911. ThisTask: PTask; // pointer to current task (readable)
  912. IdleCount, // idle counter
  913. DispCount: ULONG; // dispatch coutner
  914. Quantum, // time slice quantum
  915. Elapsed, // current quantum ticks
  916. SysFlags: Word; // misc internal system flags
  917. IDNestCnt, // interrupt disable nesting count
  918. TDNestCnt: Shortint; // task disable nesting count
  919. AttnFlags, // special attention flags (readable)
  920. AttnResched : Word; // rescheduling attention
  921. ResModules, // resident module array pointer
  922. TaskTrapCode,
  923. TaskExceptCode,
  924. TaskExitCode: APTR;
  925. TaskSigAlloc: ULONG;
  926. TaskTrapAlloc: Word;
  927. //***** System Lists (private!) *******************************
  928. MemList,
  929. ResourceList,
  930. DeviceList,
  931. IntrList,
  932. LibList,
  933. PortList,
  934. TaskReady,
  935. TaskWait: TList;
  936. SoftInts: array[0..4] of TSoftIntList;
  937. //***** Other Globals ******************************************
  938. LastAlert: array[0..3] of LONG;
  939. { these next two variables are provided to allow
  940. ** system developers to have a rough idea of the
  941. ** period of two externally controlled signals --
  942. ** the time between vertical blank interrupts and the
  943. ** external line rate (which is counted by CIA A's
  944. ** "time of day" clock). In general these values
  945. ** will be 50 or 60, and may or may not track each
  946. ** other. These values replace the obsolete AFB_PAL
  947. ** and AFB_50HZ flags.}
  948. VBlankFrequency, // (readable)
  949. PowerSupplyFrequency: Byte; // (readable)
  950. SemaphoreList: TList;
  951. { these next two are to be able to kickstart into user ram.
  952. ** KickMemPtr holds a singly linked list of MemLists which
  953. ** will be removed from the memory list via AllocAbs. If
  954. ** all the AllocAbs's succeeded, then the KickTagPtr will
  955. ** be added to the rom tag list.}
  956. KickMemPtr, // ptr to queue of mem lists
  957. KickTagPtr, // ptr to rom tag queue
  958. KickCheckSum: APTR; // checksum for mem and tags
  959. //***** Miscellaneous Stuff *************************************
  960. ex_Pad0: Word;
  961. ex_LaunchPoint: IPTR;
  962. ex_RamLibPrivate: APTR;
  963. { The next ULONG contains the system "E" clock frequency,
  964. ** expressed in Hertz. The E clock is used as a timebase for
  965. ** the Amiga's 8520 I/O chips. (E is connected to "02").
  966. ** Typical values are 715909 for NTSC, or 709379 for PAL.}
  967. ex_EClockFrequency, // (readable)
  968. ex_CacheControl, // Private to CacheControl calls
  969. ex_TaskID: ULONG; // Next available task ID
  970. ex_Reserved1: array[0..4] of ULONG;
  971. ex_MMULock: Pointer; // private
  972. ex_Reserved2: array[0..1] of ULONG;
  973. ex_DebugFlags: ULONG;
  974. { The following list and data element are used
  975. exec's low memory handler...}
  976. ex_MemHandlers : tMinList; // The handler list
  977. ex_MemHandler : Pointer; // Private! handler pointer
  978. //***** Additional AROS fields **********************************
  979. DebugArosBase : PArosSupportBase;
  980. end;
  981. { ***** Bit defines for AttnFlags (see above) ***************************** }
  982. { Processors and Co-processors: }
  983. const
  984. AFB_68010 = 0; { also set for 68020 }
  985. AFB_68020 = 1; { also set for 68030 }
  986. AFB_68030 = 2; { also set for 68040 }
  987. AFB_68040 = 3;
  988. AFB_68881 = 4; { also set for 68882 }
  989. AFB_68882 = 5;
  990. AFB_FPU40 = 6; { Set if 68040 FPU }
  991. AFB_68060 = 7;
  992. AFB_ADDR32 = 14; // AROS extension, CPU has 32-bit addressing
  993. AFB_PRIVATE = 15; // see below
  994. AFF_68010 = 1 shl 0;
  995. AFF_68020 = 1 shl 1;
  996. AFF_68030 = 1 shl 2;
  997. AFF_68040 = 1 shl 3;
  998. AFF_68881 = 1 shl 4;
  999. AFF_68882 = 1 shl 5;
  1000. AFF_FPU40 = 1 shl 6;
  1001. AFF_68060 = 1 shl 7;
  1002. AFF_ADDR32 = 1 shl 14;
  1003. AFF_PRIVATE = 1 shl 15;
  1004. {*
  1005. * AFB_PRIVATE is actually FPU presence flag with architecture-specific meaning:
  1006. * m68k - Set if any FPU type detected. AmigaOS-compatible, however considered private.
  1007. * ARM - Set if VFP is present. Considered public.
  1008. * Others - not used.
  1009. *}
  1010. AFB_FPU = AFB_PRIVATE;
  1011. AFF_FPU = AFF_PRIVATE ;
  1012. //* SysFlags. Private and AROS-specific. */
  1013. SFF_SoftInt = 1 shl 5; // There is a software interrupt pending
  1014. SFF_QuantumOver = 1 shl 13; // Task's time slice is over
  1015. // AttnResched. AmigaOS(tm)-compatible, but private.
  1016. ARF_AttnSwitch = 1 shl 7; // Delayed task switch pending
  1017. { ***** Selected flag definitions for Cache manipulation calls ********* }
  1018. CACRF_EnableI = 1 shl 0; // Enable instruction cache
  1019. CACRF_FreezeI = 1 shl 1; // Freeze instruction cache
  1020. CACRF_ClearI = 1 shl 3; // Clear instruction cache
  1021. CACRF_IBE = 1 shl 4; // Instruction burst enable
  1022. CACRF_EnableD = 1 shl 8; // 68030 Enable data cache
  1023. CACRF_FreezeD = 1 shl 9; // 68030 Freeze data cache
  1024. CACRF_ClearD = 1 shl 11; // 68030 Clear data cache
  1025. CACRF_DBE = 1 shl 12; // 68030 Data burst enable
  1026. CACRF_WriteAllocate = 1 shl 13; // 68030 Write-Allocate mode (must always be set!)
  1027. CACRF_InvalidateD = 1 shl 15;
  1028. CACRF_EnableE = 1 shl 30;
  1029. CACRF_CopyBack = 1 shl 31;
  1030. DMA_Continue = 1 shl 1; // Continuation flag for CachePreDMA
  1031. DMA_NoModify = 1 shl 2; // Set if DMA does not update memory
  1032. DMA_ReadFromRAM = 1 shl 3; // Set if DMA goes *FROM* RAM to device
  1033. {*
  1034. * Runtime debug output flags, MorphOS-compatible.
  1035. * Most of them are reserved for now.
  1036. *}
  1037. EXECDEBUGF_INITRESIDENT = $00000001; // Single resident initialization
  1038. EXECDEBUGF_INITCODE = $00000002; // Kickstart initialization
  1039. EXECDEBUGF_FINDRESIDENT = $00000004; // Resident search
  1040. EXECDEBUGF_CREATELIBRARY = $00000010; // Library creation
  1041. EXECDEBUGF_SETfunction = $00000020; // Library function patching
  1042. EXECDEBUGF_NEWSETfunction = $00000040;
  1043. EXECDEBUGF_CHIPRAM = $00000080;
  1044. EXECDEBUGF_ADDTASK = $00000100; // Task creation
  1045. EXECDEBUGF_REMTASK = $00000200; // Task removal
  1046. EXECDEBUGF_GETTASKATTR = $00000400;
  1047. EXECDEBUGF_SETTASKATTR = $00000800;
  1048. EXECDEBUGF_EXCEPTHANDLER = $00001000;
  1049. EXECDEBUGF_ADDDOSNODE = $00002000;
  1050. EXECDEBUGF_PCI = $00004000;
  1051. EXECDEBUGF_RAMLIB = $00008000;
  1052. EXECDEBUGF_NOLOGSERVER = $00010000;
  1053. EXECDEBUGF_NOLOGWINDOW = $00020000;
  1054. EXECDEBUGF_LOGFILE = $00040000;
  1055. EXECDEBUGF_LOGKPRINTF = $00080000;
  1056. EXECDEBUGF_PERMMEMTRACK = $00100000;
  1057. EXECDEBUGF_MEMTRACK = $00200000;
  1058. EXECDEBUGF_CYBERGUARDDEADLY = $00400000;
  1059. EXECDEBUGF_LOGEXTENDED = $00800000;
  1060. EXECDEBUGF_LOADSEG = $01000000;
  1061. EXECDEBUGF_UNLOADSEG = $02000000;
  1062. EXECDEBUGF_PPCSTART = $04000000;
  1063. EXECDEBUGF_CGXDEBUG = $08000000;
  1064. EXECDEBUGF_INVZEROPAGE = $10000000;
  1065. EXECDEBUGF_INIT = $40000000; // Generic system startup
  1066. EXECDEBUGF_LOG = $80000000;
  1067. // The base node in an AVL tree. Embed this within your object a-la exec ListNode
  1068. type
  1069. PPAVLNode = ^PAVLNode;
  1070. PAVLNode = ^TAVLNode;
  1071. TAVLNode = record
  1072. avl_link: array[0..1] of PAVLNode;
  1073. avl_parent: PAVLNode;
  1074. avl_balance: LONG;
  1075. end;
  1076. AVLKey = Pointer;
  1077. PAVLNODECOMP = ^AVLNODECOMP;
  1078. AVLNODECOMP = APTR;
  1079. PAVLKEYCOMP = ^AVLKEYCOMP;
  1080. AVLKEYCOMP = APTR;
  1081. const
  1082. // Magic constants for RawDoFmt() anv VNewRawDoFmt() to be given as PutChProc
  1083. RAWFMTFUNC_STRING = 0; // Output to string given in PutChData
  1084. RAWFMTFUNC_SERIAL = 1; // Output to debug log (usually serial port)
  1085. RAWFMTFUNC_COUNT = 2; // Just count characters, PutChData is a pointer to the counter (ULONG *)
  1086. // function headers
  1087. function Supervisor(UserFunction: TProcedure): ULONG; syscall AOS_ExecBase 5;
  1088. procedure Reschedule(Task: PTask); syscall AOS_ExecBase 8;
  1089. procedure ExecException; syscall AOS_ExecBase 11;
  1090. procedure InitCode(StartClass: ULONG; Version: ULONG); syscall AOS_ExecBase 12;
  1091. procedure InitStruct(const InitTable: APTR; Memory: APTR; Size: ULONG); syscall AOS_ExecBase 13;
  1092. function MakeLibrary(const FuncInit: APTR; const StructInit: APTR; LibInit: TProcedure; DataSize: ULONG; SegList: ULONG): PLibrary; syscall AOS_ExecBase 14;
  1093. procedure MakeFunctions(const Target: APTR; const FunctionArray: CONST_APTR; const FuncDispBase: CONST_APTR); syscall AOS_ExecBase 15;
  1094. function FindResident(const Name: PChar): PResident; syscall AOS_ExecBase 16;
  1095. function InitResident(const Resident_: PResident; SegList: ULONG): PResident; syscall AOS_ExecBase 17;
  1096. procedure Alert(AlertNum: ULONG); syscall AOS_ExecBase 18;
  1097. procedure Debug(Flags: ULONG); syscall AOS_ExecBase 19;
  1098. procedure Disable; syscall AOS_ExecBase 20;
  1099. procedure Enable; syscall AOS_ExecBase 21;
  1100. procedure Forbid; syscall AOS_ExecBase 22;
  1101. procedure Permit; syscall AOS_ExecBase 23;
  1102. function SetSR(NewSR: ULONG; Mask: ULONG): ULONG; syscall AOS_ExecBase 24;
  1103. function SuperState: APTR; syscall AOS_ExecBase 25;
  1104. procedure UserState(SysStack: APTR); syscall AOS_ExecBase 26;
  1105. function SetIntVector(IntNumber: LongInt; const Interrupt_: PInterrupt): PInterrupt; syscall AOS_ExecBase 27;
  1106. procedure AddIntServer(IntNumber: ULONG; Interrupt_: PInterrupt); syscall AOS_ExecBase 28;
  1107. procedure RemIntServer(IntNumber: ULONG; Interrupt_: PInterrupt); syscall AOS_ExecBase 29;
  1108. procedure Cause(Interrupt_: PInterrupt); syscall AOS_ExecBase 30;
  1109. function Allocate(FreeList: PMemHeader; ByteSize: ULONG): PMemHeader; syscall AOS_ExecBase 31;
  1110. procedure Deallocate(FreeList: PMemHeader; MemoryBlock: APTR; ByteSize: ULONG); syscall AOS_ExecBase 32;
  1111. function ExecAllocMem(ByteSize: ULONG; Requirements: ULONG): APTR; syscall AOS_ExecBase 33;
  1112. function AllocAbs(ByteSize: ULONG; Location: APTR): APTR; syscall AOS_ExecBase 34;
  1113. procedure ExecFreeMem(MemoryBlock: APTR; ByteSize: ULONG); syscall AOS_ExecBase 35;
  1114. function AvailMem(Requirements: ULONG): ULONG; syscall AOS_ExecBase 36;
  1115. function AllocEntry(Entry: PMemList): PMemList; syscall AOS_ExecBase 37;
  1116. procedure FreeEntry(Entry: PMemList); syscall AOS_ExecBase 38;
  1117. procedure ExecInsert(List: PList; Node: PNode; Pred: PNode); syscall AOS_ExecBase 39;
  1118. procedure AddHead(List: PList; Node: PNode); syscall AOS_ExecBase 40;
  1119. procedure AddTail(List: PList; Node: PNode); syscall AOS_ExecBase 41;
  1120. procedure Remove(Node: PNode); syscall AOS_ExecBase 42;
  1121. function RemHead(List: PList): PNode; syscall AOS_ExecBase 43;
  1122. function RemTail(List: PList): PNode; syscall AOS_ExecBase 44;
  1123. procedure Enqueue(List: PList; Node: PNode); syscall AOS_ExecBase 45;
  1124. function FindName(List: PList; const Name: PChar): PNode; syscall AOS_ExecBase 46;
  1125. function AddTask(Task: PTask; const InitialPC: APTR; const FinalPC: APTR): PTask; syscall AOS_ExecBase 47; deprecated;
  1126. procedure RemTask(Task: PTask); syscall AOS_ExecBase 48;
  1127. function FindTask(const Name: STRPTR): PTask; syscall AOS_ExecBase 49;
  1128. function SetTaskPri(Task: PTask; Priority: LongInt): ShortInt; syscall AOS_ExecBase 50;
  1129. function SetSignal(NewSignals: ULONG; SignalSet: ULONG): ULONG; syscall AOS_ExecBase 51;
  1130. function SetExcept(NewSignals: ULONG; SignalSet: ULONG): ULONG; syscall AOS_ExecBase 52;
  1131. function Wait(SignalSet: ULONG): ULONG; syscall AOS_ExecBase 53;
  1132. procedure Signal(Task: PTask; SignalSet: ULONG); syscall AOS_ExecBase 54;
  1133. function AllocSignal(SignalNum: LongInt): ShortInt; syscall AOS_ExecBase 55;
  1134. procedure FreeSignal(SignalNum: LongInt); syscall AOS_ExecBase 56;
  1135. function AllocTrap(TrapNum: LongInt): LongInt; syscall AOS_ExecBase 57;
  1136. procedure FreeTrap(TrapNum: LongInt); syscall AOS_ExecBase 58;
  1137. procedure AddPort(Port: PMsgPort); syscall AOS_ExecBase 59;
  1138. procedure RemPort(Port: PMsgPort); syscall AOS_ExecBase 60;
  1139. procedure PutMsg(Port: PMsgPort; Message: PMessage); syscall AOS_ExecBase 61;
  1140. function GetMsg(Port: PMsgPort): PMessage; syscall AOS_ExecBase 62;
  1141. procedure ReplyMsg(Message: PMessage); syscall AOS_ExecBase 63;
  1142. function WaitPort(Port: PMsgPort): PMessage; syscall AOS_ExecBase 64;
  1143. function FindPort(const Name: STRPTR): PMsgPort; syscall AOS_ExecBase 65;
  1144. procedure AddLibrary(Library_: PLibrary); syscall AOS_ExecBase 66;
  1145. procedure RemLibrary(Library_: PLibrary); syscall AOS_ExecBase 67;
  1146. function OldOpenLibrary(const LibName: STRPTR): PLibrary; syscall AOS_ExecBase 68; deprecated;
  1147. procedure CloseLibrary(Library_: PLibrary); syscall AOS_ExecBase 69;
  1148. function SetFunction(Library_: PLibrary; FuncOffset: LongInt; NewFunction: TProcedure): APTR; syscall AOS_ExecBase 70;
  1149. procedure SumLibrary(Library_: PLibrary); syscall AOS_ExecBase 71;
  1150. procedure AddDevice(Device: PDevice); syscall AOS_ExecBase 72;
  1151. procedure RemDevice(Device: PDevice); syscall AOS_ExecBase 73;
  1152. function OpenDevice(const DevName: STRPTR; UnitNumber: ULONG; IORequest: PIORequest; Flags: ULONG): LongInt; syscall AOS_ExecBase 74;
  1153. procedure CloseDevice(IORequest: PIORequest); syscall AOS_ExecBase 75;
  1154. function DoIO(IORequest: PIORequest): LongInt; syscall AOS_ExecBase 76;
  1155. procedure SendIO(IORequest: PIORequest); syscall AOS_ExecBase 77;
  1156. function CheckIO(IORequest: PIORequest): PIORequest; syscall AOS_ExecBase 78;
  1157. function WaitIO(IORequest: PIORequest): LongInt; syscall AOS_ExecBase 79;
  1158. function AbortIO(IORequest: PIORequest): LongInt; syscall AOS_ExecBase 80;
  1159. procedure AddResource(Resource: APTR); syscall AOS_ExecBase 81;
  1160. procedure RemResource(Resource: APTR); syscall AOS_ExecBase 82;
  1161. function OpenResource(const ResName: STRPTR): APTR; syscall AOS_ExecBase 83;
  1162. procedure RawIOInit; syscall AOS_ExecBase 84;
  1163. function RawMayGetChar: LongInt; syscall AOS_ExecBase 85;
  1164. procedure RawMayPutChar(Cha: Byte); syscall AOS_ExecBase 86;
  1165. function RawDoFmt(const FormatString: STRPTR; const DataStream: APTR; PutChProc: TProcedure; PutChData: APTR): APTR; syscall AOS_ExecBase 87;
  1166. function GetCC: Word; syscall AOS_ExecBase 88;
  1167. function TypeOfMem(const Address: APTR): ULONG; syscall AOS_ExecBase 89;
  1168. function Procure(SigSem: PSignalSemaphore; BidMsg: PSemaphoreMessage): ULONG; syscall AOS_ExecBase 90;
  1169. procedure Vacate(SigSem: PSignalSemaphore; BidMsg: PSemaphoreMessage); syscall AOS_ExecBase 91;
  1170. function OpenLibrary(const LibName: STRPTR; Version: ULONG): PLibrary; syscall AOS_ExecBase 92;
  1171. procedure InitSemaphore(SigSem: PSignalSemaphore); syscall AOS_ExecBase 93;
  1172. procedure ObtainSemaphore(SigSem: PSignalSemaphore); syscall AOS_ExecBase 94;
  1173. procedure ReleaseSemaphore(SigSem: PSignalSemaphore); syscall AOS_ExecBase 95;
  1174. function AttemptSemaphore(SigSem: PSignalSemaphore): ULONG; syscall AOS_ExecBase 96;
  1175. procedure ObtainSemaphoreList(SigSem: PList); syscall AOS_ExecBase 97;
  1176. procedure ReleaseSemaphoreList(SigSem: PList); syscall AOS_ExecBase 98;
  1177. function FindSemaphore(const SigSem: STRPTR): PSignalSemaphore; syscall AOS_ExecBase 99;
  1178. procedure AddSemaphore(SigSem: PSignalSemaphore); syscall AOS_ExecBase 100;
  1179. procedure RemSemaphore(SigSem: PSignalSemaphore); syscall AOS_ExecBase 101;
  1180. procedure SumKickData; syscall AOS_ExecBase 102;
  1181. procedure AddMemList(Size: ULONG; Attributes: ULONG; Pri: LongInt; Base: APTR; const Name: STRPTR); syscall AOS_ExecBase 103;
  1182. procedure CopyMem(const Source: APTR; Dest: APTR; Size: ULONG); syscall AOS_ExecBase 104;
  1183. procedure CopyMemQuick(const Source: APTR; Dest: APTR; Size: ULONG); syscall AOS_ExecBase 105;
  1184. procedure CacheClearU;syscall AOS_ExecBase 106;
  1185. procedure CacheClearE(Address: APTR; Length: ULONG; Caches: ULONG); syscall AOS_ExecBase 107;
  1186. function CacheControl(CacheBits: ULONG; CacheMask: ULONG): ULONG; syscall AOS_ExecBase 108;
  1187. function CreateIORequest(const IOReplyPort: PMsgPort; Size: ULONG): APTR; syscall AOS_ExecBase 109;
  1188. procedure DeleteIORequest(IORequest: APTR); syscall AOS_ExecBase 110;
  1189. function CreateMsgPort: PMsgPort; syscall AOS_ExecBase 111;
  1190. procedure DeleteMsgPort(Port: PMsgPort); syscall AOS_ExecBase 112;
  1191. procedure ObtainSemaphoreShared(SigSem: PSignalSemaphore); syscall AOS_ExecBase 113;
  1192. function AllocVec(ByteSize: ULONG; Requirements: ULONG): APTR; syscall AOS_ExecBase 114;
  1193. procedure FreeVec(MemoryBlock: APTR); syscall AOS_ExecBase 115;
  1194. function CreatePool(Requirements: ULONG; PuddleSize: ULONG; ThreshSize: ULONG): APTR; syscall AOS_ExecBase 116;
  1195. procedure DeletePool(PoolHeader: APTR); syscall AOS_ExecBase 117;
  1196. function AllocPooled(PoolHeader: APTR; MemSize: ULONG): APTR; syscall AOS_ExecBase 118;
  1197. procedure FreePooled(PoolHeader: APTR; Memory: APTR; MemSize: ULONG); syscall AOS_ExecBase 119;
  1198. function AttemptSemaphoreShared(SigSem: PSignalSemaphore): ULONG; syscall AOS_ExecBase 120;
  1199. procedure ColdReboot; syscall AOS_ExecBase 121;
  1200. procedure StackSwap(NewStack: PStackSwapStruct); syscall AOS_ExecBase 122; deprecated;
  1201. procedure ChildFree(Tid: ULONG); syscall AOS_ExecBase 123;
  1202. function ChildOrphan(Tid: ULONG): ULONG; syscall AOS_ExecBase 124;
  1203. function ChildStatus(Tid: ULONG): ULONG; syscall AOS_ExecBase 125;
  1204. function ChildWait(Tid: ULONG): IPTR; syscall AOS_ExecBase 126;
  1205. function CachePreDMA(const Address: APTR; var Length: ULONG; Flags: ULONG): APTR; syscall AOS_ExecBase 127;
  1206. procedure CachePostDMA(const Address: APTR; var Length: ULONG; Flags: ULONG); syscall AOS_ExecBase 128;
  1207. procedure AddMemHandler(MemHandler: PInterrupt); syscall AOS_ExecBase 129;
  1208. procedure RemMemHandler(MemHandler: PInterrupt); syscall AOS_ExecBase 130;
  1209. function ObtainQuickVector(InterruptCode: APTR): ULONG; syscall AOS_ExecBase 131;
  1210. function NewStackSwap(NewStack: PStackSwapStruct; Function_: APTR; Args: PStackSwapArgs): IPTR; syscall AOS_ExecBase 134;
  1211. function TaggedOpenLibrary(Tag: LongInt): APTR; syscall AOS_ExecBase 135;
  1212. function ReadGayle: ULONG; syscall AOS_ExecBase 136;
  1213. function VNewRawDoFmt(const FormatString: STRPTR; PutChProc: TProcedure; PutChData: APTR; VaListStream: PChar): STRPTR; syscall AOS_ExecBase 137;
  1214. function NewAddTaskA(TagList: PTagItem): APTR; syscall AOS_ExecBase 153;
  1215. function AddResetCallback(ResetCallback: PInterrupt): LongBool; syscall AOS_ExecBase 167;
  1216. procedure RemResetCallback(ResetCallback: PInterrupt); syscall AOS_ExecBase 168;
  1217. function ShutdownA(Action: ULONG): ULONG; syscall AOS_ExecBase 173;
  1218. {$ifdef AROS_ABIv0}
  1219. function PrepareContext(Task: PTask; EntryPoint: APTR; FallBack: APTR; TagList: PTagItem): LongBool; syscall AOS_ExecBase 6;
  1220. procedure Switch; syscall AOS_ExecBase 9;
  1221. procedure Dispatch; syscall AOS_ExecBase 10;
  1222. function AVL_AddNode(Root: PPAVLNode; Node: PAVLNode; Func: PAVLNODECOMP): PAVLNode; syscall AOS_ExecBase 139;
  1223. function AVL_RemNodeByAddress(Root: PPAVLNode; Node: PAVLNode): PAVLNode; syscall AOS_ExecBase 140;
  1224. function AVL_RemNodeByKey(Root: PPAVLNode; Key: AVLKey; Func: PAVLNODECOMP): PAVLNode; syscall AOS_ExecBase 141;
  1225. function AVL_FindNode(Root: PPAVLNode; Key: AVLKey; Func: PAVLNODECOMP): PAVLNode; syscall AOS_ExecBase 142;
  1226. function AVL_FindPrevNodeByAddress(Node: PAVLNode): PAVLNode; syscall AOS_ExecBase 143;
  1227. function AVL_FindPrevNodeByKey(Node: PAVLNode; Key: AVLKey): PAVLNode; syscall AOS_ExecBase 144;
  1228. function AVL_FindNextNodeByAddress(Node: PAVLNode): PAVLNode; syscall AOS_ExecBase 145;
  1229. function AVL_FindNextNodeByKey(Node: PAVLNode; Key: AVLKey): PAVLNode; syscall AOS_ExecBase 146;
  1230. function AVL_FindFirstNode(Root: PAVLNode): PAVLNode; syscall AOS_ExecBase 147;
  1231. function AVL_FindLastNode(Root: PAVLNode): PAVLNode; syscall AOS_ExecBase 148;
  1232. function NewAddTask(Task: PTask; InitialPC: APTR; FinalPC: APTR; TagList: PTagItem): APTR; syscall AOS_ExecBase 152;
  1233. function AllocVecPooled(Pool: APTR; Size: ULONG): APTR; syscall AOS_ExecBase 149;
  1234. procedure FreeVecPooled(Pool: APTR; Memory: APTR); syscall AOS_ExecBase 150;
  1235. function NewAllocEntry(Entry: PMemList; var Return_Entry: PMemList; var Return_Flags: ULONG): LongBool; syscall AOS_ExecBase 151;
  1236. {$endif}
  1237. {$ifdef AROS_ABIv1}
  1238. procedure NewMinList(Ml: PMinList); syscall AOS_ExecBase 138;
  1239. function AVL_AddNode(Root: PPAVLNode; Node: PAVLNode; Func: PAVLNODECOMP): PAVLNode; syscall AOS_ExecBase 142;
  1240. function AVL_RemNodeByAddress(Root: PPAVLNode; Node: PAVLNode): PAVLNode; syscall AOS_ExecBase 143;
  1241. function AVL_RemNodeByKey(Root: PPAVLNode; Key: AVLKey; Func: PAVLNODECOMP): PAVLNode; syscall AOS_ExecBase 144;
  1242. function AVL_FindNode(Root: PPAVLNode; Key: AVLKey; Func: PAVLNODECOMP): PAVLNode; syscall AOS_ExecBase 145;
  1243. function AVL_FindPrevNodeByAddress(Node: PAVLNode): PAVLNode; syscall AOS_ExecBase 146;
  1244. function AVL_FindPrevNodeByKey(Node: PAVLNode; Key: AVLKey): PAVLNode; syscall AOS_ExecBase 147;
  1245. function AVL_FindNextNodeByAddress(Node: PAVLNode): PAVLNode; syscall AOS_ExecBase 148;
  1246. function AVL_FindNextNodeByKey(Node: PAVLNode; Key: AVLKey): PAVLNode; syscall AOS_ExecBase 149;
  1247. function AVL_FindFirstNode(Root: PAVLNode): PAVLNode; syscall AOS_ExecBase 150;
  1248. function AVL_FindLastNode(Root: PAVLNode): PAVLNode; syscall AOS_ExecBase 151;
  1249. function FindTaskByPID(ProcessID: LongWord): PTask; syscall AOS_ExecBase 166;
  1250. function AllocVecPooled(Pool: APTR; Size: ULONG): APTR; syscall AOS_ExecBase 169;
  1251. procedure FreeVecPooled(Pool: APTR; Memory: APTR); syscall AOS_ExecBase 170;
  1252. function NewAllocEntry(Entry: PMemList; var Return_Entry: PMemList; var Return_Flags: ULONG): LongBool; syscall AOS_ExecBase 174;
  1253. function NewAddTask(Task: PTask; InitialPC: APTR; FinalPC: APTR; TagList: PTagItem): APTR; syscall AOS_ExecBase 176;
  1254. function AllocTaskStorage: LongInt; syscall AOS_ExecBase 180;
  1255. procedure FreeTaskStorage(Slot: LongInt); syscall AOS_ExecBase 181;
  1256. function SaveTaskStorage: APTR; syscall AOS_ExecBase 182;
  1257. procedure RestoreTaskStorage(Id: APTR); syscall AOS_ExecBase 183;
  1258. function SetTaskStorageSlot(Id: LongInt; Value: IPTR): LongBool; syscall AOS_ExecBase 184;
  1259. function GetTaskStorageSlot(Id: LongInt): IPTR; syscall AOS_ExecBase 185;
  1260. function GetParentTaskStorageSlot(Id: LongInt): IPTR; syscall AOS_ExecBase 186;
  1261. {$endif}
  1262. function BitMask(no :ShortInt): LongInt;
  1263. // C Macros
  1264. procedure SetNodeName(Node: PNode; Name: PChar);
  1265. function GetNodeName(Node: PNode): PChar;
  1266. procedure NewList(List: PList);
  1267. function GetHead(List: PList): PNode; inline;
  1268. function GetTail(List: PList): PNode; inline;
  1269. function GetSucc(Node: PNode): PNode; inline;
  1270. function GetPred(Node: PNode): PNode; inline;
  1271. function ListLength(List: PList): Integer;
  1272. function IsListEmpty(List: PList): Boolean;
  1273. function IsMinListEmpty(List: PMinList): Boolean;
  1274. function IsMsgPortEmpty( mp: pMsgPort): Boolean;
  1275. type
  1276. TNodeProcedure = procedure(Node:PNode); // Procedure for ForEachNode;
  1277. procedure ForEachNode(List:PList; NodeProc: TNodeProcedure);
  1278. procedure ForEachNodeSafe(List:PList; NodeProc: TNodeProcedure);
  1279. implementation
  1280. // C Macros
  1281. procedure SetNodeName(Node: PNode; Name: PChar); inline;
  1282. begin
  1283. if Assigned(Node) then
  1284. Node^.ln_Name := Name;
  1285. end;
  1286. function GetNodeName(Node: PNode): PChar; inline;
  1287. begin
  1288. if Assigned(Node) then
  1289. GetNodeName := Node^.ln_Name;
  1290. end;
  1291. procedure NewList(List: PList); inline;
  1292. begin
  1293. if Assigned(List) then
  1294. begin
  1295. List^.lh_TailPred := PNode(List);
  1296. List^.lh_Tail := nil;
  1297. List^.lh_Head := @List^.lh_Tail;
  1298. end;
  1299. end;
  1300. function GetHead(List: PList): PNode; inline;
  1301. begin
  1302. GetHead := nil;
  1303. if Assigned(List) then
  1304. begin
  1305. if Assigned(List^.lh_Head^.ln_Succ) then
  1306. GetHead := List^.lh_Head;
  1307. end;
  1308. end;
  1309. function GetTail(List: PList): PNode; inline;
  1310. begin
  1311. GetTail := nil;
  1312. if Assigned(List) then
  1313. begin
  1314. if Assigned(List^.lh_TailPred^.ln_Pred) then
  1315. GetTail := List^.lh_TailPred;
  1316. end;
  1317. end;
  1318. function GetSucc(Node: PNode): PNode; inline;
  1319. begin
  1320. GetSucc := nil;
  1321. if Assigned(Node) then
  1322. if Assigned(Node^.ln_Succ) then
  1323. if Assigned(Node^.ln_Succ^.ln_Succ) then
  1324. GetSucc := Node^.ln_Succ;
  1325. end;
  1326. function GetPred(Node: PNode): PNode; inline;
  1327. begin
  1328. GetPred := nil;
  1329. if Assigned(Node) then
  1330. if Assigned(Node^.ln_Pred) then
  1331. if Assigned(Node^.ln_Pred^.ln_Pred) then
  1332. GetPred := Node^.ln_Pred;
  1333. end;
  1334. procedure ForEachNode(List:PList; NodeProc: TNodeProcedure);
  1335. var
  1336. i: Integer;
  1337. Node: PNode;
  1338. begin
  1339. if not Assigned(List) or not Assigned(NodeProc) then
  1340. Exit;
  1341. Node := GetHead(List);
  1342. for i := 0 to ListLength(List) do
  1343. begin
  1344. if not Assigned(Node) then
  1345. Exit;
  1346. NodeProc(Node);
  1347. Node := GetSucc(Node);
  1348. end;
  1349. end;
  1350. procedure ForEachNodeSafe(List:PList; NodeProc: TNodeProcedure);
  1351. var
  1352. i: Integer;
  1353. Node: PNode;
  1354. NextNode: PNode;
  1355. begin
  1356. if not Assigned(List) or not Assigned(NodeProc) then
  1357. Exit;
  1358. Node := GetHead(List);
  1359. if not Assigned(Node) then
  1360. Exit;
  1361. while Assigned(Node) do
  1362. begin
  1363. if not Assigned(Node) then
  1364. Exit;
  1365. NextNode := GetSucc(Node);
  1366. NodeProc(Node);
  1367. Node := NextNode;
  1368. end;
  1369. end;
  1370. function ListLength(List: PList): Integer;
  1371. var
  1372. Current: PNode;
  1373. Next: PNode;
  1374. begin
  1375. Current := List^.lh_Head;
  1376. Next := Current^.ln_Succ;
  1377. ListLength := 0;
  1378. if Assigned(Current) and Assigned(Next) then
  1379. while Next = Current^.ln_Succ do
  1380. begin
  1381. Current := Next;
  1382. Next := Current^.ln_Succ;
  1383. Inc(ListLength);
  1384. if (not Assigned(Current)) or (not Assigned(Next)) then
  1385. Exit;
  1386. end;
  1387. end;
  1388. function IsListEmpty(List: PList): Boolean; inline;
  1389. begin
  1390. IsListEmpty := True;
  1391. if Assigned(List) then
  1392. IsListEmpty := List^.lh_TailPred = PNode(List);
  1393. end;
  1394. function IsMinListEmpty(List: PMinList): Boolean;
  1395. begin
  1396. IsMinListEmpty := True;
  1397. if Assigned(List) then
  1398. IsMinListEmpty := List^.mlh_TailPred = PMinNode(List);
  1399. end;
  1400. function IsMsgPortEmpty(Mp: PMsgPort): Boolean;
  1401. begin
  1402. IsMsgPortEmpty := True;
  1403. if Assigned(mp) then
  1404. IsMsgPortEmpty := mp^.mp_MsgList.lh_TailPred = PNode(@(mp^.mp_MsgList));
  1405. end;
  1406. function BitMask(no :ShortInt): LongInt;
  1407. begin
  1408. BitMask := 1 shl no;
  1409. end;
  1410. end. (* UNIT EXEC *)