execd.inc 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883
  1. {
  2. This file is part of the Free Pascal run time library.
  3. exec definitions (V50) for MorphOS/PowerPC
  4. Copyright (c) 2002 The MorphOS Development Team, All Rights Reserved.
  5. Free Pascal conversion
  6. Copyright (c) 2004 Karoly Balogh for Genesi S.a.r.l. <www.genesi.lu>
  7. AROS conversion
  8. Copyright (c) 2011 Marcus Sackrow
  9. See the file COPYING.FPC, included in this distribution,
  10. for details about the copyright.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. **********************************************************************}
  15. {include emuld.inc}
  16. {$include utild1.inc}
  17. { * aros spinlock definition
  18. *********************************************************************
  19. * }
  20. {$ifndef AROS_ABIv11}
  21. {$ifdef AROS_ABIv1}
  22. {$ifdef AROSPLATFORM_SMP}
  23. type
  24. TSpinLock =
  25. record
  26. case byte of
  27. 0: (slock:
  28. bitpacked record // ensure bits are packed. this is a volatile structure
  29. readcount: 0..$FFFFFF;
  30. _pad2: 0..$7;
  31. &write: 0..$1;
  32. _pad1: 0..$7;
  33. updating: 0..$1;
  34. end);
  35. 1: (block: packed array[0..3] of byte; lock: uint32); // both fields are volatile
  36. // The field s_Owner is set either to task owning the lock,
  37. // or NULL if the lock is free/read mode or was acquired in interrupt/supervisor mode
  38. 2: (_skip: packed array[0..7] of byte; s_Owner: Pointer); // skip block and lock because that occupies most space
  39. 3: (pad_align: packed array[0..128-1] of byte); // ensure 128 byte record size
  40. end;
  41. {$endif}
  42. {$endif}
  43. {$endif}
  44. { * exec node definitions
  45. *********************************************************************
  46. * }
  47. type // Checked OK 05.08.2011 ALB
  48. PNode = ^TNode;
  49. TNode = record
  50. ln_Succ: PNode;
  51. ln_Pred: PNode;
  52. {$ifdef AROS_BINCOMPAT}
  53. ln_Type: Byte;
  54. ln_Pri : ShortInt;
  55. ln_Name: PAnsiChar;
  56. {$else}
  57. ln_Name: PAnsiChar;
  58. ln_Type: Byte;
  59. ln_Pri : ShortInt;
  60. {$endif}
  61. end;
  62. type // Checked OK 05.08.2011 ALB
  63. PMinNode = ^TMinNode;
  64. TMinNode = record
  65. mln_Succ: PMinNode;
  66. mln_Pred: PMinNode;
  67. end;
  68. const // Checked OK 05.08.2011 ALB
  69. NT_UNKNOWN = 0;
  70. NT_TASK = 1;
  71. NT_INTERRUPT = 2;
  72. NT_DEVICE = 3;
  73. NT_MSGPORT = 4;
  74. NT_MESSAGE = 5;
  75. NT_FREEMSG = 6;
  76. NT_REPLYMSG = 7;
  77. NT_RESOURCE = 8;
  78. NT_LIBRARY = 9;
  79. NT_MEMORY = 10;
  80. NT_SOFTINT = 11;
  81. NT_FONT = 12;
  82. NT_PROCESS = 13;
  83. NT_SEMAPHORE = 14;
  84. NT_SIGNALSEM = 15;
  85. NT_BOOTNODE = 16;
  86. NT_KICKMEM = 17;
  87. NT_GRAPHICS = 18;
  88. NT_DEATHMESSAGE = 19;
  89. NT_HIDD = 20; // AROS specific
  90. NT_USER = 254;
  91. NT_EXTENDED = 255;
  92. { * exec list definitions
  93. *********************************************************************
  94. * }
  95. type // Checked OK 05.08.2011 ALB
  96. PList = ^TEList;
  97. TEList = record
  98. lh_Head : PNode;
  99. lh_Tail : PNode;
  100. lh_TailPred: PNode;
  101. lh_Type : Byte;
  102. lh_pad : Byte;
  103. end;
  104. type // Checked OK 05.08.2011 ALB
  105. PMinList = ^TMinList;
  106. TMinList = record
  107. mlh_Head : PMinNode;
  108. mlh_Tail : PMinNode;
  109. mlh_TailPred: PMinNode;
  110. end;
  111. { * exec alert definitions (V50)
  112. *********************************************************************
  113. * }
  114. const // Checked OK 04.08.2011 ALB
  115. // General Types
  116. AT_DeadEnd = $80000000; // Alert that crashes
  117. AT_Recovery = $00000000; // Alert that returns
  118. // General Errors
  119. AG_NoMemory = $00010000;
  120. AG_MakeLib = $00020000;
  121. AG_OpenLib = $00030000;
  122. AG_OpenDev = $00040000;
  123. AG_OpenRes = $00050000;
  124. AG_IOError = $00060000;
  125. AG_NoSignal = $00070000;
  126. AG_BadParm = $00080000;
  127. AG_CloseLib = $00090000;
  128. AG_CloseDev = $000A0000;
  129. AG_ProcCreate = $000B0000;
  130. // 680x0 Errors
  131. ACPU_BusErr = $80000002;
  132. ACPU_AddressErr = $80000003;
  133. ACPU_InstErr = $80000004;
  134. ACPU_DivZero = $80000005;
  135. ACPU_CHK = $80000006;
  136. ACPU_TRAPV = $80000007;
  137. ACPU_PrivErr = $80000008;
  138. ACPU_Trace = $80000009;
  139. ACPU_LineA = $8000000A;
  140. ACPU_LineF = $8000000B;
  141. ACPU_Format = $8000000E;
  142. ACPU_Spurious = $80000018;
  143. ACPU_AutoVec1 = $80000019;
  144. ACPU_AutoVec2 = $8000001A;
  145. ACPU_AutoVec3 = $8000001B;
  146. ACPU_AutoVec4 = $8000001C;
  147. ACPU_AutoVec5 = $8000001D;
  148. ACPU_AutoVec6 = $8000001E;
  149. ACPU_AutoVec7 = $8000001F;
  150. // Libraries
  151. AO_ExecLib = $00008001;
  152. AO_GraphicsLib = $00008002;
  153. AO_LayersLib = $00008003;
  154. AO_Intuition = $00008004;
  155. AO_MathLib = $00008005;
  156. AO_DOSLib = $00008007;
  157. AO_RAMLib = $00008008;
  158. AO_IconLib = $00008009;
  159. AO_ExpansionLib = $0000800A;
  160. AO_DiskfontLib = $0000800B;
  161. AO_UtilityLib = $0000800C;
  162. AO_KeyMapLib = $0000800D;
  163. // Devices
  164. AO_AudioDev = $00008010;
  165. AO_ConsoleDev = $00008011;
  166. AO_GamePortDev = $00008012;
  167. AO_KeyboardDev = $00008013;
  168. AO_TrackDiskDev = $00008014;
  169. AO_TimerDev = $00008015;
  170. // Resources
  171. AO_CIARsrc = $00008020;
  172. AO_DiskRsrc = $00008021;
  173. AO_MiscRsrc = $00008022;
  174. // Miscellaneous
  175. AO_BootStrap = $00008030;
  176. AO_Workbench = $00008031;
  177. AO_DiskCopy = $00008032;
  178. AO_GadTools = $00008033;
  179. AO_Unknown = $00008035;
  180. // AROS Additions, start at 0x40
  181. AO_ArosLib = $00008040;
  182. AO_OOPLib = $00008041;
  183. AO_HiddLib = $00008042;
  184. { *
  185. * exec.library
  186. * }
  187. const // Checked OK 04.08.2011 ALB
  188. AN_ExecLib = $01000000;
  189. AN_ExcptVect = $01000001;
  190. AN_BaseChkSum = $01000002;
  191. AN_LibChkSum = $01000003;
  192. AN_MemCorrupt = $81000005;
  193. AN_IntrMem = $81000006;
  194. AN_InitAPtr = $01000007;
  195. AN_SemCorrupt = $01000008;
  196. AN_FreeTwice = $01000009;
  197. AN_BogusExcpt = $8100000A;
  198. AN_IOUsedTwice = $0100000B;
  199. AN_MemoryInsane = $0100000C;
  200. AN_IOAfterClose = $0100000D;
  201. AN_StackProbe = $0100000E; // stack has wrong size
  202. AN_BadFreeAddr = $0100000F;
  203. AN_BadSemaphore = $01000010;
  204. { *
  205. * graphics.library
  206. * }
  207. const // Checked OK 04.08.2011 ALB
  208. AN_GraphicsLib = $02000000;
  209. AN_GfxNoMem = $82010000;
  210. AN_GfxNoMemMspc = $82010001;
  211. AN_LongFrame = $82010006;
  212. AN_ShortFrame = $82010007;
  213. AN_TextTmpRas = $02010009;
  214. AN_BltBitMap = $8201000A;
  215. AN_RegionMemory = $8201000B;
  216. AN_MakeVPort = $82010030;
  217. AN_GfxNewError = $0200000C;
  218. AN_GfxFreeError = $0200000D;
  219. AN_GfxNoLCM = $82011234;
  220. AN_ObsoleteFont = $02000401;
  221. { *
  222. * layers.library
  223. * }
  224. const // Checked OK 04.08.2011 ALB
  225. AN_LayersLib = $03000000;
  226. AN_LayersNoMem = $83010000;
  227. { *
  228. * intuition.library
  229. * }
  230. const // Checked OK 04.08.2011 ALB
  231. AN_Intuition = $04000000;
  232. AN_GadgetType = $84000001;
  233. AN_BadGadget = $04000001;
  234. AN_CreatePort = $84010002;
  235. AN_ItemAlloc = $04010003;
  236. AN_SubAlloc = $04010004;
  237. AN_PlaneAlloc = $84010005;
  238. AN_ItemBoxTop = $84000006;
  239. AN_OpenScreen = $84010007;
  240. AN_OpenScrnRast = $84010008;
  241. AN_SysScrnType = $84000009;
  242. AN_AddSWGadget = $8401000A;
  243. AN_OpenWindow = $8401000B;
  244. AN_BadState = $8400000C;
  245. AN_BadMessage = $8400000D;
  246. AN_WeirdEcho = $8400000E;
  247. AN_NoConsole = $8400000F;
  248. AN_NoISem = $04000010;
  249. AN_ISemOrder = $04000011;
  250. { *
  251. * math.library
  252. * }
  253. const // Checked OK 04.08.2011 ALB
  254. AN_MathLib = $05000000;
  255. { *
  256. * dos.library
  257. * }
  258. const // Checked OK 04.08.2011 ALB
  259. AN_DOSLib = $07000000;
  260. AN_StartMem = $07010001;
  261. AN_EndTask = $07000002;
  262. AN_QPktFail = $07000003;
  263. AN_AsyncPkt = $07000004;
  264. AN_FreeVec = $07000005;
  265. AN_DiskBlkSeq = $07000006;
  266. AN_BitMap = $07000007;
  267. AN_KeyFree = $07000008;
  268. AN_BadChkSum = $07000009;
  269. AN_DiskError = $0700000A;
  270. AN_KeyRange = $0700000B;
  271. AN_BadOverlay = $0700000C;
  272. AN_BadInitFunc = $0700000D;
  273. AN_FileReclosed = $0700000E;
  274. { *
  275. * ramlib.library
  276. * }
  277. const // Checked OK 04.08.2011 ALB
  278. AN_RAMLib = $08000000;
  279. AN_BadSegList = $08000001;
  280. { *
  281. * icon.library
  282. * }
  283. const // Checked OK 04.08.2011 ALB
  284. AN_IconLib = $09000000;
  285. { *
  286. * expansion.library
  287. * }
  288. const // Checked OK 04.08.2011 ALB
  289. AN_ExpansionLib = $0A000000;
  290. AN_BadExpansionFree = $0A000001;
  291. { *
  292. * diskfont.library
  293. * }
  294. const // Checked OK 04.08.2011 ALB
  295. AN_DiskfontLib = $0B000000;
  296. { *
  297. * audio.device
  298. * }
  299. const // Checked OK 04.08.2011 ALB
  300. AN_AudioDev = $10000000;
  301. { *
  302. * console.device
  303. * }
  304. const // Checked OK 04.08.2011 ALB
  305. AN_ConsoleDev = $11000000;
  306. AN_NoWindow = $11000001;
  307. { *
  308. * gameport.device
  309. * }
  310. const // Checked OK 04.08.2011 ALB
  311. AN_GamePortDev = $12000000;
  312. { *
  313. * keyboard.device
  314. * }
  315. const // Checked OK 04.08.2011 ALB
  316. AN_KeyboardDev = $13000000;
  317. { *
  318. * trackdisk.device
  319. * }
  320. const // Checked OK 04.08.2011 ALB
  321. AN_TrackDiskDev = $14000000;
  322. AN_TDCalibSeek = $14000001;
  323. AN_TDDelay = $14000002;
  324. { *
  325. * timer.device
  326. * }
  327. const // Checked OK 04.08.2011 ALB
  328. AN_TimerDev = $15000000;
  329. AN_TMBadReq = $15000001;
  330. AN_TMBadSupply = $15000002;
  331. { *
  332. * cia.resource
  333. * }
  334. const // Checked OK 04.08.2011 ALB
  335. AN_CIARsrc = $20000000;
  336. { *
  337. * disk.resource
  338. * }
  339. const // Checked OK 04.08.2011 ALB
  340. AN_DiskRsrc = $21000000;
  341. AN_DRHasDisk = $21000001;
  342. AN_DRIntNoAct = $21000002;
  343. { *
  344. * misc.resource
  345. * }
  346. const // Checked OK 04.08.2011 ALB
  347. AN_MiscRsrc = $22000000;
  348. { *
  349. * bootstrap
  350. * }
  351. const // Checked OK 04.08.2011 ALB
  352. AN_BootStrap = $30000000;
  353. AN_BootError = $30000001;
  354. { *
  355. * Workbench
  356. * }
  357. const // Checked OK 04.08.2011 ALB
  358. AN_Workbench = $31000000;
  359. AN_NoFonts = $B1000001;
  360. AN_WBBadStartupMsg1 = $31000001;
  361. AN_WBBadStartupMsg2 = $31000002;
  362. AN_WBBadIOMsg = $31000003;
  363. AN_WBReLayoutToolMenu = $B1010009;
  364. { *
  365. * DiskCopy
  366. * }
  367. const // Checked OK 04.08.2011 ALB
  368. AN_DiskCopy = $32000000;
  369. { *
  370. * toolkit for Intuition
  371. * }
  372. const // Checked OK 04.08.2011 ALB
  373. AN_GadTools = $33000000;
  374. { *
  375. * System utility library
  376. * }
  377. const // Checked OK 04.08.2011 ALB
  378. AN_UtilityLib = $34000000;
  379. { *
  380. * AROS Additions
  381. * }
  382. AN_Aros = $40000000;
  383. AN_OOP = $41000000;
  384. // Hidd Subsystem */
  385. AN_Hidd = $42000000;
  386. AN_HiddNoRoot = $C2000001; // Could not create root device
  387. { *
  388. * For use by any application that needs it
  389. * }
  390. const // Checked OK 04.08.2011 ALB
  391. AN_Unknown = $35000000;
  392. { * exec error definitions
  393. *********************************************************************
  394. * }
  395. const // Checked OK 04.08.2011 ALB
  396. IOERR_OPENFAIL = (-1);
  397. IOERR_ABORTED = (-2);
  398. IOERR_NOCMD = (-3);
  399. IOERR_BADLENGTH = (-4);
  400. IOERR_BADADDRESS = (-5);
  401. IOERR_UNITBUSY = (-6);
  402. IOERR_SELFTEST = (-7);
  403. { * exec resident definitions
  404. *********************************************************************
  405. * }
  406. type
  407. PResident = ^TResident;
  408. TResident = record
  409. rt_MatchWord: Word;
  410. rt_MatchTag : PResident;
  411. rt_EndSkip : Pointer;
  412. rt_Flags : Byte;
  413. rt_Version : Byte;
  414. rt_Type : Byte;
  415. rt_Pri : Byte;
  416. rt_Name : PAnsiChar;
  417. rt_IdString : PAnsiChar;
  418. rt_Init : Pointer;
  419. { * Only valid when RTF_EXTENDED is set
  420. * }
  421. rt_Revision : Word; { * Revision Entry * }
  422. rt_Tags : Pointer;
  423. end;
  424. const
  425. RTC_MATCHWORD = $4AFC;
  426. RTF_AUTOINIT = (1 Shl 7);
  427. RTF_EXTENDED = (1 Shl 6); { * structure extension is valid * }
  428. { * rt_Init points to a PPC function which must be defined as
  429. *
  430. * struct Library* LIB_Init(struct Library *MyLibBase,
  431. * BPTR SegList,
  432. * struct ExecBase *SysBase)
  433. * }
  434. RTF_PPC = (1 Shl 3);
  435. RTF_AFTERDOS = (1 Shl 2);
  436. RTF_SINGLETASK = (1 Shl 1);
  437. RTF_COLDSTART = (1 Shl 0);
  438. RTW_NEVER = 0;
  439. RTW_COLDSTART = 1;
  440. { * exec memory definitions
  441. *********************************************************************
  442. * }
  443. type // Checked OK 05.08.2011 ALB
  444. PMemChunk = ^TMemChunk;
  445. TMemChunk = record
  446. nc_Next : PMemChunk;
  447. nc_Bytes: PtrUInt;
  448. end;
  449. type // Checked OK 05.08.2011 ALB
  450. PMemHeader = ^TMemHeader;
  451. TMemHeader = record
  452. mh_Node : TNode;
  453. mh_Attributes: Word;
  454. mh_First : PMemChunk;
  455. mh_Lower : Pointer;
  456. mh_Upper : Pointer;
  457. mh_Free : PtrUInt;
  458. end;
  459. type // Checked OK 05.08.2011 ALB
  460. PMemEntry = ^TMemEntry;
  461. TMemEntry = record
  462. me_Un: record
  463. case Byte of
  464. 0 : (meu_Reqs: DWord);
  465. 1 : (meu_Addr: Pointer)
  466. end;
  467. me_Length: PtrUInt;
  468. end;
  469. type // Checked OK 05.08.2011 ALB
  470. PMemList = ^TMemList;
  471. TMemList = record
  472. ml_Node : TNode;
  473. ml_NumEntries: Word;
  474. ml_ME : array [0..0] of TMemEntry;
  475. end;
  476. const // Checked OK 05.08.2011 ALB
  477. MEMF_ANY = 0;
  478. MEMF_PUBLIC = (1 shl 0);
  479. MEMF_CHIP = (1 shl 1);
  480. MEMF_FAST = (1 shl 2);
  481. MEMF_LOCAL = (1 shl 8);
  482. MEMF_24BITDMA = (1 shl 9);
  483. MEMF_KICK = (1 shl 10);
  484. MEMF_SWAP = (1 shl 11); { * Memory that can be swapped out to disk * }
  485. MEMF_31BIT = (1 shl 12);
  486. MEMF_CLEAR = (1 Shl 16);
  487. MEMF_LARGEST = (1 Shl 17);
  488. MEMF_REVERSE = (1 Shl 18);
  489. MEMF_TOTAL = (1 Shl 19);
  490. MEMF_HWALIGNED = (1 Shl 20); // For AllocMem() - align address and size to physical page boundary
  491. MEMF_SEM_PROTECTED = (1 Shl 20); { * For CreatePool(): semaphore protection * }
  492. MEMF_NO_EXPUNGE = (1 Shl 31);
  493. MEM_BLOCKSIZE = 8;
  494. MEM_BLOCKMASK = (MEM_BLOCKSIZE - 1);
  495. type // Checked OK 05.08.2011 ALB
  496. PMemHandlerData = ^TMemHandlerData;
  497. TMemHandlerData = record
  498. memh_RequestSize : PtrUInt;
  499. memh_RequestFlags: DWord;
  500. memh_Flags : DWord;
  501. end;
  502. const // Checked OK 05.08.2011 ALB
  503. MEMHF_RECYCLE = (1 shl 0);
  504. MEM_DID_NOTHING = 0;
  505. MEM_ALL_DONE = -1;
  506. MEM_TRY_AGAIN = 1;
  507. { * exec port definitions
  508. *********************************************************************
  509. * }
  510. type // Checked OK 05.08.2011 ALB
  511. PMsgPort = ^TMsgPort;
  512. TMsgPort = record
  513. mp_Node : TNode;
  514. mp_Flags : Byte;
  515. mp_SigBit : Byte;
  516. mp_SigTask: Pointer;
  517. mp_MsgList: TEList;
  518. {$ifndef AROS_ABIv11}
  519. {$ifdef AROS_ABIv1}
  520. {$ifdef AROSPLATFORM_SMP}
  521. {$ifdef AROSEXEC_SMP}
  522. mp_SpinLock: TSpinLock;
  523. {$else}
  524. mp_pad: TSpinLock;
  525. {$endif}
  526. {$endif}
  527. {$endif}
  528. {$else}
  529. {$ifndef CPUM68K}
  530. mp_Private: array[0..1] of PtrUInt;
  531. {$endif}
  532. {$endif}
  533. end;
  534. const
  535. PF_ACTION = 3;
  536. PA_SIGNAL = 0;
  537. PA_SOFTINT = 1;
  538. PA_IGNORE = 2;
  539. type
  540. PMessage = ^TMessage;
  541. TMessage = record
  542. mn_Node : TNode;
  543. mn_ReplyPort: PMsgPort;
  544. mn_Length : Word;
  545. end;
  546. { * exec task definitions (V50)
  547. *********************************************************************
  548. * }
  549. type
  550. PTask = ^TTask;
  551. TTask = record
  552. tc_Node: TNode;
  553. tc_Flags: Byte;
  554. tc_State: Byte;
  555. tc_IDNestCnt: Shortint; // intr disabled nesting
  556. tc_TDNestCnt: Shortint; // task disabled nesting
  557. tc_SigAlloc: LongWord; // sigs allocated
  558. tc_SigWait: LongWord; // sigs we are waiting for
  559. tc_SigRecvd: LongWord; // sigs we have received
  560. tc_SigExcept: LongWord; // sigs we will take excepts for
  561. case boolean of
  562. True:(
  563. tc_TrapAlloc: Word; // traps allocated
  564. tc_TrapAble: Word;); // traps enabled
  565. False:(
  566. tc_ETask: Pointer; // Valid if TF_ETask is set
  567. tc_ExceptData: Pointer; // points to except data
  568. tc_ExceptCode: Pointer; // points to except code
  569. tc_TrapData: Pointer; // points to trap data
  570. tc_TrapCode: Pointer; // points to trap code
  571. tc_SPReg: Pointer; // stack pointer
  572. tc_SPLower: Pointer; // stack lower bound
  573. tc_SPUpper: Pointer; // stack upper bound + 2
  574. tc_Switch: Pointer; // task losing CPU
  575. tc_Launch: Pointer; // task getting CPU
  576. tc_MemEntry: TEList; // allocated memory
  577. tc_UserData: Pointer; // per task data
  578. );
  579. end;
  580. const
  581. TB_PROCTIME = 0;
  582. TB_ETASK = 3;
  583. TB_STACKCHK = 4;
  584. TB_EXCEPT = 5;
  585. TB_SWITCH = 6;
  586. TB_LAUNCH = 7;
  587. TF_PROCTIME = (1 Shl TB_PROCTIME);
  588. TF_ETASK = (1 Shl TB_ETASK);
  589. TF_STACKCHK = (1 Shl TB_STACKCHK);
  590. TF_EXCEPT = (1 Shl TB_EXCEPT);
  591. TF_SWITCH = (1 Shl TB_SWITCH);
  592. TF_LAUNCH = (1 Shl TB_LAUNCH);
  593. TS_INVALID = 0;
  594. TS_ADDED = 1;
  595. TS_RUN = 2;
  596. TS_READY = 3;
  597. TS_WAIT = 4;
  598. TS_EXCEPT = 5;
  599. TS_REMOVED = 6;
  600. SIGB_ABORT = 0;
  601. SIGB_CHILD = 1;
  602. SIGB_BLIT = 4;
  603. SIGB_SINGLE = 4;
  604. SIGB_INTUITION = 5;
  605. SIGB_NET = 7;
  606. SIGB_DOS = 8;
  607. SIGF_ABORT = (1 Shl SIGB_ABORT);
  608. SIGF_CHILD = (1 Shl SIGB_CHILD);
  609. SIGF_BLIT = (1 Shl SIGB_BLIT);
  610. SIGF_SINGLE = (1 Shl SIGB_SINGLE);
  611. SIGF_INTUITION = (1 Shl SIGB_INTUITION);
  612. SIGF_NET = (1 Shl SIGB_NET);
  613. SIGF_DOS = (1 Shl SIGB_DOS);
  614. type
  615. PTaskTrapMessage = ^TTaskTrapMessage;
  616. TTaskTrapMessage = record
  617. Message: TMessage; { * Message Header * }
  618. Task : TTask; { * connected Task * }
  619. Version: DWord; { * version of the structure * }
  620. TType : DWord; { * Exception Type * }
  621. DAR : DWord; { * Exception Address Register * }
  622. DSISR : DWord; { * Exception DSISR Reg * }
  623. { * This is undiscovered land...
  624. * never assume a size of this structure
  625. * }
  626. end;
  627. const
  628. VERSION_TASKTRAPMESSAGE = $0;
  629. type
  630. {$ifdef AROS_MORPHOS_COMPATIBLE}
  631. PETask = ^TETask;
  632. TETask = record
  633. Message : TMessage;
  634. Parent : PTask;
  635. UniqueID : DWord;
  636. Children : TMinList;
  637. TrapAlloc: Word;
  638. TrapAble : Word;
  639. Result1 : DWord;
  640. Result2 : Pointer;
  641. MsgPort : TMsgPort;
  642. { * Don't touch!!!!!!!!!..there'll be an interface
  643. * sooner than later.
  644. * New Entries...most of the above entries
  645. * are only their for structure compatability.
  646. * They have no meaning as the OS never supported
  647. * them.
  648. * }
  649. { * A Task Pool for the task.
  650. * }
  651. MemPool: Pointer;
  652. { * PPC's Stack Lower Ptr
  653. * The initial stack is allocated through
  654. * AllocVec, so a FreeVec(ETask^.PPCSPLower);
  655. * would work.
  656. * If you use PPCStackSwap you must allocate
  657. * your stack block with AllocVec();
  658. * }
  659. PPCSPLower: Pointer;
  660. { * PPC's Stack Upper Ptr
  661. * }
  662. PPCSPUpper : Pointer;
  663. PPCRegFrame: Pointer;
  664. PPCLibData : Pointer;
  665. { * On a PPC exception this msgport
  666. * is sent an exception msg...
  667. * the task is stopped until somebody
  668. * wakes it up again.
  669. * (asynchron exception interface)
  670. * If this Port is NULL the message is
  671. * sent to SysBase->ex_PPCTrapMsgPort.
  672. * }
  673. PPCTrapMsgPort: PMsgPort;
  674. PPCTrapMessage: PTaskTrapMessage;
  675. { * This is undiscovered land...
  676. * never assume a size of this structure
  677. * }
  678. end;
  679. {$else}
  680. TETask = record
  681. et_Message: TMessage;
  682. et_Parent: PTask; // Pointer to parent task
  683. et_UniqueID: DWord;
  684. et_Children: TMinList; // List of children
  685. et_TrapAlloc: Word;
  686. et_TrapAble: Word;
  687. et_Result1: DWord; // First result
  688. et_Result2: Pointer; // Result data pointer (AllocVec)
  689. et_TaskMsgPort: TMsgPort;
  690. {$IFDEF AROS_ABIv0}
  691. et_Compatibility: array[0..3] of Pointer; // Reserve this space for compiled software to access iet_startup and iet_acpd
  692. {$ENDIF}
  693. et_MemPool: Pointer; // Task's private memory pool
  694. {$ifdef aros}
  695. et_Reserved: array[0..0] of PtrUInt; // MorphOS Private
  696. et_TaskStorage: Pointer; // Task Storage Slots
  697. {$else}
  698. et_Reserved: array[0..1] of PtrUInt; // MorphOS Private
  699. {$endif}
  700. et_RegFrame: Pointer;
  701. // Internal fields follow
  702. end;
  703. {$endif}
  704. type
  705. PTaskInitExtension = ^TTaskInitExtension;
  706. TTaskInitExtension = record
  707. { * Must be filled with TRAP_PPCTASK
  708. * }
  709. Trap : Word;
  710. Extension: Word; { * Must be set to 0 * }
  711. Tags : Pointer;
  712. end;
  713. const
  714. TASKTAG_DUMMY = (TAG_USER + $100000);
  715. { * Ptr to an ULONG Errorfield where a better error description
  716. * can be stored.
  717. * }
  718. TASKTAG_ERROR = (TASKTAG_DUMMY + $0);
  719. { * Code type
  720. * can be stored.
  721. * }
  722. TASKTAG_CODETYPE = (TASKTAG_DUMMY + $1);
  723. { * Start PC
  724. * code must be of TASKTAG_CODETYPE
  725. * }
  726. TASKTAG_PC = (TASKTAG_DUMMY + $2);
  727. { * Final PC
  728. * code must be of TASKTAG_CODETYPE
  729. * }
  730. TASKTAG_FINALPC = (TASKTAG_DUMMY + $3);
  731. { * Stacksize...Default 8192
  732. * }
  733. TASKTAG_STACKSIZE = (TASKTAG_DUMMY + $4);
  734. { * Std Stacksize...
  735. * Default(use the stack defined by tc_SPLower..tc_SPUpper)
  736. * }
  737. TASKTAG_STACKSIZE_M68K = (TASKTAG_DUMMY + $5);
  738. { * specify task name, name is copied
  739. * }
  740. TASKTAG_NAME = (TASKTAG_DUMMY + $6);
  741. { * tc_UserData
  742. * }
  743. TASKTAG_USERDATA = (TASKTAG_DUMMY + $7);
  744. { * Task priority
  745. * }
  746. TASKTAG_PRI = (TASKTAG_DUMMY + $8);
  747. { * Pool's Puddlesize
  748. * }
  749. TASKTAG_POOLPUDDLE = (TASKTAG_DUMMY + $9);
  750. { * Pool's ThreshSize
  751. * }
  752. TASKTAG_POOLTHRESH = (TASKTAG_DUMMY + $a);
  753. { * PPC First Argument..gpr3
  754. * }
  755. TASKTAG_PPC_ARG1 = (TASKTAG_DUMMY + $10);
  756. { * PPC First Argument..gpr4
  757. * }
  758. TASKTAG_PPC_ARG2 = (TASKTAG_DUMMY + $11);
  759. { * PPC First Argument..gpr5
  760. * }
  761. TASKTAG_PPC_ARG3 = (TASKTAG_DUMMY + $12);
  762. { * PPC First Argument..gpr6
  763. * }
  764. TASKTAG_PPC_ARG4 = (TASKTAG_DUMMY + $13);
  765. { * PPC First Argument..gpr7
  766. * }
  767. TASKTAG_PPC_ARG5 = (TASKTAG_DUMMY + $14);
  768. { * PPC First Argument..gpr8
  769. * }
  770. TASKTAG_PPC_ARG6 = (TASKTAG_DUMMY + $15);
  771. { * PPC First Argument..gpr9
  772. * }
  773. TASKTAG_PPC_ARG7 = (TASKTAG_DUMMY + $16);
  774. { * PPC First Argument..gpr10
  775. * }
  776. TASKTAG_PPC_ARG8 = (TASKTAG_DUMMY + $17);
  777. { *
  778. * Startup message to be passed to task/process, ReplyMsg'd at RemTask()
  779. * ti_Data: struct Message *
  780. * }
  781. TASKTAG_STARTUPMSG = (TASKTAG_DUMMY + $18);
  782. { *
  783. * Create internal MsgPort for task/process, deleted at RemTask()
  784. * ti_Data: struct MsgPort **, can be NULL
  785. * }
  786. TASKTAG_TASKMSGPORT = (TASKTAG_DUMMY + $19);
  787. const
  788. CODETYPE_M68K = $0;
  789. { *
  790. * System V4 ABI
  791. * }
  792. CODETYPE_PPC = $1;
  793. const
  794. TASKERROR_OK = 0;
  795. TASKERROR_NOMEMORY = 1;
  796. { *
  797. * Stack swap structure as passed to StackSwap() and PPCStackSwap()
  798. * }
  799. type
  800. PStackSwapStruct = ^TStackSwapStruct;
  801. TStackSwapStruct = record
  802. stk_Lower : Pointer; { * Lowest byte of stack * }
  803. stk_Upper : Pointer; { * Upper end of stack (size + Lowert) * }
  804. stk_Pointer: Pointer; { * Stack pointer at switch point * }
  805. end;
  806. type
  807. PStackSwapArgs = ^TStackSwapArgs;
  808. TStackSwapArgs = record
  809. Args: Array[0..7] Of Pointer;
  810. end;
  811. { *
  812. * NewGetTaskAttrsA(), NewSetTaskAttrsA() tags
  813. * }
  814. const
  815. TASKINFOTYPE_ALLTASK = $0;
  816. TASKINFOTYPE_NAME = $1;
  817. TASKINFOTYPE_PRI = $2;
  818. TASKINFOTYPE_TYPE = $3;
  819. TASKINFOTYPE_STATE = $4;
  820. TASKINFOTYPE_FLAGS = $5;
  821. TASKINFOTYPE_SIGALLOC = $6;
  822. TASKINFOTYPE_SIGWAIT = $7;
  823. TASKINFOTYPE_SIGRECVD = $8;
  824. TASKINFOTYPE_SIGEXCEPT = $9;
  825. TASKINFOTYPE_EXCEPTDATA = $a;
  826. TASKINFOTYPE_EXCEPTCODE = $b;
  827. TASKINFOTYPE_TRAPDATA = $c;
  828. TASKINFOTYPE_TRAPCODE = $d;
  829. TASKINFOTYPE_STACKSIZE_M68K = $e;
  830. TASKINFOTYPE_STACKSIZE = $f;
  831. TASKINFOTYPE_USEDSTACKSIZE_M68K = $10;
  832. TASKINFOTYPE_USEDSTACKSIZE = $11;
  833. TASKINFOTYPE_TRAPMSGPORT = $12;
  834. TASKINFOTYPE_STARTUPMSG = $13;
  835. TASKINFOTYPE_TASKMSGPORT = $14;
  836. TASKINFOTYPE_POOLPTR = $15;
  837. TASKINFOTYPE_POOLMEMFLAGS = $16;
  838. TASKINFOTYPE_POOLPUDDLESIZE = $17;
  839. TASKINFOTYPE_POOLTHRESHSIZE = $18;
  840. { *
  841. * Task Scheduler statistics (exec 50.42)
  842. * }
  843. TASKINFOTYPE_NICE = $19;
  844. TASKINFOTYPE_AGETICKS = $1a;
  845. TASKINFOTYPE_CPUTIME = $1b;
  846. TASKINFOTYPE_LASTSECCPUTIME = $1c;
  847. TASKINFOTYPE_RECENTCPUTIME = $1d;
  848. TASKINFOTYPE_VOLUNTARYCSW = $1e;
  849. TASKINFOTYPE_INVOLUNTARYCSW = $1f;
  850. TASKINFOTYPE_LASTSECVOLUNTARYCSW = $20;
  851. TASKINFOTYPE_LASTSECINVOLUNTARYCSW = $21;
  852. { * Added in exec 50.45 * }
  853. TASKINFOTYPE_LAUNCHTIMETICKS = $22;
  854. TASKINFOTYPE_LAUNCHTIMETICKS1978 = $23;
  855. TASKINFOTYPE_PID = $24;
  856. TASKINFOTYPE_68K_NEWFRAME = $50;
  857. TASKINFOTYPE_PPC_SRR0 = $100;
  858. TASKINFOTYPE_PPC_SRR1 = $101;
  859. TASKINFOTYPE_PPC_LR = $102;
  860. TASKINFOTYPE_PPC_CTR = $103;
  861. TASKINFOTYPE_PPC_CR = $104;
  862. TASKINFOTYPE_PPC_XER = $105;
  863. TASKINFOTYPE_PPC_GPR = $106;
  864. TASKINFOTYPE_PPC_FPR = $107;
  865. TASKINFOTYPE_PPC_FPSCR = $108;
  866. TASKINFOTYPE_PPC_VSCR = $109;
  867. TASKINFOTYPE_PPC_VMX = $10a;
  868. TASKINFOTYPE_PPC_VSAVE = $10b;
  869. TASKINFOTYPE_PPC_FRAME = $10c;
  870. TASKINFOTYPE_PPC_FRAMESIZE = $10d;
  871. TASKINFOTYPE_PPC_NEWFRAME = $10e;
  872. TASKINFOTAG_DUMMY = (TAG_USER + $110000);
  873. { * Used with TASKINFOTYPE_ALLTASK
  874. * }
  875. TASKINFOTAG_HOOK = (TASKINFOTAG_DUMMY + $0);
  876. { * Used with TASKINFOTYPE_PPC_GPR,TASKINFOTYPE_PPC_FPR,TASKINFOTYPE_PPC_VMX
  877. * to define the copy area
  878. * }
  879. TASKINFOTAG_REGSTART = (TASKINFOTAG_DUMMY + $1);
  880. { * Used with TASKINFOTYPE_PPC_GPR,TASKINFOTYPE_PPC_FPR,TASKINFOTYPE_PPC_VMX
  881. * to define the copy area
  882. * }
  883. TASKINFOTAG_REGCOUNT = (TASKINFOTAG_DUMMY + $2);
  884. { *
  885. * NewSetTaskAttrsA(..,@TaskFrame68k,sizeof(TTaskFrame68k),TASKINFOTYPE_68K_NEWFRAME,...);
  886. * }
  887. type
  888. PTaskFrame68k = ^TTaskFrame68k;
  889. TTaskFrame68k = record
  890. PC: Pointer;
  891. SR: Word;
  892. Xn: Array[0..14] Of LongInt;
  893. end;
  894. { *
  895. * Don't depend on these
  896. * }
  897. const
  898. DEFAULT_PPCSTACKSIZE = 32768;
  899. DEFAULT_M68KSTACKSIZE = 2048;
  900. DEFAULT_TASKPUDDLESIZE = 4096;
  901. DEFAULT_TASKTHRESHSIZE = 4096;
  902. { * exec interrupt definitions
  903. *********************************************************************
  904. * }
  905. type // Checked OK 05.08.2011 ALB
  906. PInterrupt = ^TInterrupt;
  907. TInterrupt = record
  908. is_Node: TNode;
  909. is_Data: Pointer;
  910. is_Code: Pointer; // server code entry
  911. end;
  912. type // Checked OK 05.08.2011 ALB
  913. PIntVector = ^TIntVector;
  914. TIntVector = record
  915. iv_Data: Pointer;
  916. iv_Code: Pointer;
  917. iv_Node: PNode;
  918. end;
  919. type // Checked OK 05.08.2011 ALB
  920. PSoftIntList = ^TSoftIntList;
  921. TSoftIntList = record
  922. sh_List: TEList;
  923. sh_Pad : Word;
  924. end;
  925. const // Checked OK 05.08.2011 ALB
  926. SIH_PRIMASK = $f0;
  927. INTB_NMI = 15;
  928. INTF_NMI = (1 Shl INTB_NMI);
  929. { * exec semaphore definitions (V50)
  930. *********************************************************************
  931. * }
  932. { *
  933. * Shouldn't be available public..
  934. * }
  935. type
  936. PSemaphoreRequest = ^TSemaphoreRequest;
  937. TSemaphoreRequest = record
  938. sr_Link : TMinNode;
  939. sr_Waiter: PTask;
  940. {$ifndef AROS_ABIv11}
  941. {$ifdef AROS_ABIv1}
  942. {$ifdef AROSPLATFORM_SMP}
  943. {$ifdef AROSEXEC_SMP}
  944. sr_SpinLock: TSpinLock;
  945. {$else}
  946. sr_pad: TSpinLock;
  947. {$endif}
  948. {$endif}
  949. {$endif}
  950. {$endif}
  951. end;
  952. type
  953. PSignalSemaphore = ^TSignalSemaphore;
  954. TSignalSemaphore = record
  955. ss_Link : TNode;
  956. ss_NestCount : SmallInt;
  957. ss_WaitQueue : TMinList;
  958. ss_MultipleLink: TSemaphoreRequest;
  959. ss_Owner : PTask;
  960. ss_QueueCount : SmallInt;
  961. end;
  962. type
  963. PSemaphoreMessage = ^TSemaphoreMessage;
  964. TSemaphoreMessage = record
  965. ssm_Message : TMessage;
  966. ssm_Semaphore: PSignalSemaphore;
  967. end;
  968. const
  969. SM_SHARED = 1;
  970. SM_EXCLUSIVE = 0;
  971. { * exec machine definitions (V50)
  972. *********************************************************************
  973. * }
  974. const
  975. MACHINE_M68k = $0;
  976. MACHINE_PPC = $1;
  977. MACHINE_NO = $ffffffff;
  978. { * exec library definitions
  979. *********************************************************************
  980. * }
  981. const // Checked OK 05.08.2011 ALB
  982. LIB_VECTSIZE = 6;
  983. LIB_RESERVED = 4;
  984. LIB_BASE = (-LIB_VECTSIZE);
  985. LIB_USERDEF = (LIB_BASE - (LIB_RESERVED * LIB_VECTSIZE));
  986. LIB_NONSTD = (LIB_USERDEF);
  987. LIB_OPEN = (LIB_BASE * 1);
  988. LIB_CLOSE = (LIB_BASE * 2);
  989. LIB_EXPUNGE = (LIB_BASE * 3);
  990. LIB_EXTFUNC = (LIB_BASE * 4);
  991. type // Checked OK 05.08.2011 ALB
  992. PLibrary = ^TLibrary;
  993. TLibrary = record
  994. lib_Node : TNode;
  995. lib_Flags : Byte;
  996. lib_pad : Byte;
  997. lib_NegSize : Word;
  998. lib_PosSize : Word;
  999. lib_Version : Word;
  1000. lib_Revision: Word;
  1001. lib_IdString: PAnsiChar;
  1002. lib_Sum : DWord;
  1003. lib_OpenCnt : Word;
  1004. end;
  1005. const // Checked OK 05.08.2011 ALB
  1006. LIBF_SUMMING = (1 shl 0);
  1007. LIBF_CHANGED = (1 shl 1);
  1008. LIBF_SUMUSED = (1 shl 2);
  1009. LIBF_DELEXP = (1 shl 3);
  1010. const // Checked OK 05.08.2011 ALB
  1011. {* ID numbers for Exec/TaggedOpenLibrary
  1012. *}
  1013. TAGGEDOPEN_GRAPHICS = 1;
  1014. TAGGEDOPEN_LAYERS = 2;
  1015. TAGGEDOPEN_INTUITION = 3;
  1016. TAGGEDOPEN_DOS = 4;
  1017. TAGGEDOPEN_ICON = 5;
  1018. TAGGEDOPEN_EXPANSION = 6;
  1019. TAGGEDOPEN_UTILITY = 7;
  1020. TAGGEDOPEN_KEYMAP = 8;
  1021. TAGGEDOPEN_GADTOOLS = 9;
  1022. TAGGEDOPEN_WORKBENCH = 10;
  1023. const
  1024. SETFUNCTAG_Dummy = (TAG_USER +$01000000);
  1025. { * Set the machine type of the function
  1026. * Default is 68k
  1027. * }
  1028. SETFUNCTAG_MACHINE = (SETFUNCTAG_Dummy + $1);
  1029. { * Function type specifier
  1030. * }
  1031. SETFUNCTAG_TYPE = (SETFUNCTAG_Dummy + $2);
  1032. { * ID String
  1033. * }
  1034. SETFUNCTAG_IDNAME = (SETFUNCTAG_Dummy + $3);
  1035. { *
  1036. * Set to TRUE if the replaced function will never be used
  1037. * again.
  1038. * }
  1039. SETFUNCTAG_DELETE = (SETFUNCTAG_Dummy + $4);
  1040. { * See emul/emulinterface.h for more informations
  1041. * }
  1042. { * Save Emulation PPC Registers
  1043. * Call Function
  1044. * Restore Emulation PPC Registers
  1045. * REG_D0 = Result
  1046. * }
  1047. const
  1048. SETFUNCTYPE_NORMAL = 0;
  1049. { * Call Function
  1050. * Must use the global register settings of the emulation
  1051. * REG_D0 = Result
  1052. * }
  1053. SETFUNCTYPE_QUICK = 1;
  1054. { * Save Emulation PPC Registers
  1055. * Call Function
  1056. * Restore Emulation PPC Registers
  1057. * No Result
  1058. * Needed to replace functions like
  1059. * forbid,obtainsemaphores which are
  1060. * defined as trashing no registers
  1061. * }
  1062. SETFUNCTYPE_NORMALNR = 2;
  1063. { * Call Function
  1064. * Must use the global register settings of the emulation
  1065. * No Result
  1066. * Needed to replace functions like
  1067. * forbid,obtainsemaphores which are
  1068. * defined as trashing no registers
  1069. * }
  1070. SETFUNCTYPE_QUICKNR = 3;
  1071. SETFUNCTYPE_NORMALSR = 4;
  1072. SETFUNCTYPE_NORMALSRNR = 5;
  1073. SETFUNCTYPE_NORMALD0_D1 = 6;
  1074. SETFUNCTYPE_NORMALRESTORE = 7;
  1075. SETFUNCTYPE_SYSTEMV = 8;
  1076. SETFUNCTYPE_NORMALD0D1SR = 9;
  1077. SETFUNCTYPE_NORMALD0D1A0A1SR = 10;
  1078. { * CreateLibrary extensions
  1079. * }
  1080. LIBTAG_BASE = (TAG_USER + $01000100);
  1081. { *
  1082. * Function/Vector Array
  1083. * }
  1084. LIBTAG_FUNCTIONINIT = (LIBTAG_BASE+$0);
  1085. { *
  1086. * Struct Init
  1087. * }
  1088. LIBTAG_STRUCTINIT = (LIBTAG_BASE+$1);
  1089. { *
  1090. * Library Init
  1091. * }
  1092. LIBTAG_LIBRARYINIT = (LIBTAG_BASE+$2);
  1093. { *
  1094. * Init Code Type
  1095. * }
  1096. LIBTAG_MACHINE = (LIBTAG_BASE+$3);
  1097. { *
  1098. * Library Base Size
  1099. * }
  1100. LIBTAG_BASESIZE = (LIBTAG_BASE+$4);
  1101. { *
  1102. * SegList Ptr
  1103. * }
  1104. LIBTAG_SEGLIST = (LIBTAG_BASE+$5);
  1105. { *
  1106. * Library Priority
  1107. * }
  1108. LIBTAG_PRI = (LIBTAG_BASE+$6);
  1109. { *
  1110. * Library Type..Library,Device,Resource,whatever
  1111. * }
  1112. LIBTAG_TYPE = (LIBTAG_BASE+$7);
  1113. { *
  1114. * Library Version
  1115. * (UWORD)
  1116. * }
  1117. LIBTAG_VERSION = (LIBTAG_BASE+$8);
  1118. { *
  1119. * Library Flags
  1120. * }
  1121. LIBTAG_FLAGS = (LIBTAG_BASE+$9);
  1122. { *
  1123. * Library Name
  1124. * }
  1125. LIBTAG_NAME = (LIBTAG_BASE+$a);
  1126. { *
  1127. * Library IDString
  1128. * }
  1129. LIBTAG_IDSTRING = (LIBTAG_BASE+$b);
  1130. { *
  1131. * AddDevice(),AddLibrary(),AddResource()..
  1132. * depends on LibNode.ln_Type field which
  1133. * can be set by some Init function, Struct Scripts
  1134. * or LIBTAG_TYPE.
  1135. * If you set LIBTAG_PUBLIC the library
  1136. * is added to the right system list.
  1137. * }
  1138. LIBTAG_PUBLIC = (LIBTAG_BASE+$c);
  1139. { *
  1140. * Library Revision
  1141. * (UWORD)
  1142. * }
  1143. LIBTAG_REVISION = (LIBTAG_BASE+$d);
  1144. { *
  1145. * Library QueryInfo Flag
  1146. * (Boolean)
  1147. * }
  1148. LIBTAG_QUERYINFO = (LIBTAG_BASE+$e);
  1149. { * Private
  1150. * don`t touch...floating design
  1151. * }
  1152. {
  1153. type
  1154. PFuncEntry = ^TFuncEntry;
  1155. TFuncEntry = record
  1156. EmulLibEntry : TEmulLibEntry;
  1157. OldFunction : Pointer; { * Needed for bookkeeping * }
  1158. end;
  1159. PFuncOldEntry = ^TFuncOldEntry;
  1160. TFuncOldEntry = record
  1161. Command : Word;
  1162. FuncEntry: PFuncEntry;
  1163. end;
  1164. }
  1165. { *
  1166. * EmulLibEntry.Extension
  1167. * }
  1168. const
  1169. FUNCENTRYEXTF_LIBRARY = $1; { * Entry created by the OS * }
  1170. { *
  1171. * Functionarray first ULONG ID defines the format
  1172. * of the functionarray for MakeFunctions()/MakeLibrary().
  1173. *
  1174. * If there`s not such id the functionarray is a
  1175. * 32Bit 68k function ptr array.
  1176. * (ULONG) $ffffffff stops it
  1177. * }
  1178. { * 68k 16bit relative functionarray ptrs
  1179. * (UWORD) $ffff stops it
  1180. * }
  1181. FUNCARRAY_16BIT_OLD = $ffffffff;
  1182. { * PPC 32bit functionarray ptrs
  1183. * (ULONG) $ffff stops it
  1184. * }
  1185. FUNCARRAY_32BIT_NATIVE = $fffefffe;
  1186. { * Starts a functionarray block.
  1187. * This way it`s possible to mix 68k and PPC
  1188. * function definitions.
  1189. * BASE:
  1190. * FUNCTIONARRAY_BEGIN
  1191. * FUNCARRAY_32BIT_NATIVE
  1192. * FUNC0
  1193. * FUNC1
  1194. * .
  1195. * FUNCn
  1196. * $ffffffff
  1197. * FUNCn+1 (No ID->32Bit 68k)
  1198. * FUNCn+2
  1199. * .
  1200. * FUNCm
  1201. * $ffffffff
  1202. * FUNCARRAY_16BIT_OLD
  1203. * FUNCm+1-BASE
  1204. * FUNCm+2-BASE
  1205. * .
  1206. * FUNCo-BASE
  1207. * $ffff
  1208. * FUNCTIONARRAY_END
  1209. * }
  1210. FUNCARRAY_BEGIN = $fffdfffd;
  1211. { * Ends a functionarray block.
  1212. * }
  1213. FUNCARRAY_END = $fffcfffc;
  1214. { * PPC 32bit Quick functionarray ptrs.
  1215. * These functions must comply to the emulation's
  1216. * register layout which is defined inside the
  1217. * emul/emulregs.h. That means the register layout
  1218. * MUST also be valid during interrupts/task switches.
  1219. * You can't just destroy A7(r31), SR or PC.
  1220. *
  1221. * You shouldn't use this for any normal code
  1222. * as there's no real reason to do so. If you
  1223. * really think you need to use it please ask
  1224. * us first on the dev mailinglist.
  1225. * (ULONG) $ffffffff stops it
  1226. * }
  1227. FUNCARRAY_32BIT_QUICK_NATIVE = $fffbfffb;
  1228. { * PPC 32bit QuickNR(No Result) functionarray ptrs
  1229. * (ULONG) $ffffffff stops it
  1230. * }
  1231. FUNCARRAY_32BIT_QUICKNR_NATIVE = $fffafffa;
  1232. { * PPC 32bit no result functionarray ptrs
  1233. * (ULONG) $ffffffff stops it
  1234. * }
  1235. FUNCARRAY_32BIT_NR_NATIVE = $fff9fff9;
  1236. { * PPC 32bit SR functionarray ptrs
  1237. * (ULONG) $ffffffff stops it
  1238. * }
  1239. FUNCARRAY_32BIT_SR_NATIVE = $fff8fff8;
  1240. { * PPC 32bit SR(no result) functionarray ptrs
  1241. * (ULONG) $ffffffff stops it
  1242. * }
  1243. FUNCARRAY_32BIT_SRNR_NATIVE = $fff7fff7;
  1244. { * PPC 32bit D0_D1 functionarray ptrs
  1245. * (ULONG) $ffffffff stops it
  1246. * }
  1247. FUNCARRAY_32BIT_D0D1_NATIVE = $fff6fff6;
  1248. { * PPC 32bit Restore1 functionarray ptrs
  1249. * (ULONG) $ffffffff stops it
  1250. * }
  1251. FUNCARRAY_32BIT_RESTORE_NATIVE = $fff5fff5;
  1252. { * PPC 32bit SystemV ABI entry
  1253. * these function entries DON'T comply
  1254. * to the amiga register modell REG_D0-A6
  1255. * but comply to the PPC SystemV ABI so
  1256. * you can directly use PPC C Argument
  1257. * parsing. That way you're also not limited
  1258. * with the register count.
  1259. * Such library functions can't be used
  1260. * by 68k emulation, so you can only use
  1261. * them for new code.
  1262. * As we allow these new functions to be
  1263. * used with old functions we keep the
  1264. * 6 bytes function entry steps in the library.
  1265. * Layout is
  1266. *
  1267. * CODE_JMP, &FuncEntry ; Old Entry
  1268. * CODE_ILLEGAL, Function ; SystemV ABI Entry
  1269. *
  1270. *
  1271. * (ULONG) $ffffffff stops it
  1272. * }
  1273. FUNCARRAY_32BIT_SYSTEMV = $fff4fff4;
  1274. { * PPC 32bit D0D1SR functionarray ptrs
  1275. * (ULONG) $ffffffff stops it
  1276. * }
  1277. FUNCARRAY_32BIT_D0D1SR_NATIVE = $fff3fff3;
  1278. { * PPC 32bit D0D1A0A1SR functionarray ptrs
  1279. * (ULONG) $ffffffff stops it
  1280. * }
  1281. FUNCARRAY_32BIT_D0D1A0A1SR_NATIVE = $fff2fff2;
  1282. { * exec device definitions
  1283. *********************************************************************
  1284. * }
  1285. type // Checked OK 04.08.2011 ALB
  1286. PDevice = ^TDevice;
  1287. TDevice = record
  1288. dd_Library: TLibrary;
  1289. end;
  1290. type // Checked OK 04.08.2011 ALB
  1291. PUnit = ^TUnit;
  1292. TUnit = record
  1293. unit_MsgPort: TMsgPort;
  1294. unit_flags : Byte;
  1295. unit_pad : Byte;
  1296. unit_OpenCnt: Word;
  1297. end;
  1298. const // Checked OK 04.08.2011 ALB
  1299. UNITF_ACTIVE = (1 shl 0);
  1300. UNITF_INTASK = (1 shl 1);
  1301. { * exec io definitions
  1302. *********************************************************************
  1303. * }
  1304. type // Checked OK 05.08.2011 ALB
  1305. PIORequest = ^TIORequest;
  1306. TIORequest = record
  1307. io_Message: TMessage;
  1308. io_Device : PDevice;
  1309. io_Unit : PUnit;
  1310. io_Command: Word;
  1311. io_Flags : Byte;
  1312. io_Error : ShortInt;
  1313. end;
  1314. type // Checked OK 05.08.2011 ALB
  1315. PIOStdReq = ^TIOStdReq;
  1316. TIOStdReq = record
  1317. io_Message: TMessage;
  1318. io_Device : PDevice;
  1319. io_Unit : PUnit;
  1320. io_Command: Word;
  1321. io_Flags : Byte;
  1322. io_Error : ShortInt;
  1323. io_Actual : DWord;
  1324. io_Length : DWord;
  1325. io_Data : Pointer;
  1326. io_Offset : DWord;
  1327. end;
  1328. const // Checked OK 05.08.2011 ALB
  1329. DEV_BEGINIO = -30;
  1330. DEV_ABORTIO = -36;
  1331. IOB_QUICK = 0;
  1332. IOF_QUICK = (1 Shl IOB_QUICK);
  1333. CMD_INVALID = 0;
  1334. CMD_RESET = 1;
  1335. CMD_READ = 2;
  1336. CMD_WRITE = 3;
  1337. CMD_UPDATE = 4;
  1338. CMD_CLEAR = 5;
  1339. CMD_STOP = 6;
  1340. CMD_START = 7;
  1341. CMD_FLUSH = 8;
  1342. CMD_NONSTD = 9;
  1343. type
  1344. PArosSupportBase = ^TArosSupportBase;
  1345. TArosSupportBase = record
  1346. {$IFDEF AROS_ABIv0}
  1347. StdOut: Pointer;
  1348. {$ELSE}
  1349. _pad: PtrUInt;
  1350. {$ENDIF}
  1351. kPrintfPtr: Pointer;
  1352. rkPrintfPtr: Pointer;
  1353. vkPrintfPtr: Pointer;
  1354. {$IFDEF AROS_ABIv0}
  1355. DebugConfig: Pointer;
  1356. {$ENDIF}
  1357. end;
  1358. { * exec include
  1359. *********************************************************************
  1360. * }
  1361. type // Checked OK 05.08.2011 ALB
  1362. PExecBase = ^TExecBase;
  1363. TExecBase = record
  1364. // lib structure for Exec
  1365. LIbNode : TLibrary;
  1366. // system constants
  1367. SoftVer : Word; // obsolete
  1368. LowMemChkSum: SmallInt;
  1369. ChkBase : PtrUInt;
  1370. ColdCapture : Pointer;
  1371. CoolCapture : Pointer;
  1372. WarmCapture : Pointer;
  1373. SysStkUpper : Pointer; // System Stack Bounds
  1374. SysStkLower : Pointer;
  1375. MaxLocMem : PtrUInt; // Chip Memory Pointer
  1376. DebugEntry : Pointer;
  1377. DebugData : Pointer;
  1378. AlertData : Pointer;
  1379. MaxExtMem : Pointer; // Extended Memory Pointer (may be nil)
  1380. ChkSum : Word; // SoftVer to MaxExtMem
  1381. // interrupts
  1382. IntVects : Array[0..15] Of TIntVector;
  1383. // System Variables
  1384. ThisTask : PTask; // Pointer to currently running Task READONLY
  1385. IdleCount : DWord;
  1386. DispCount : DWord;
  1387. Quantum : Word; // # of ticks a task may run
  1388. Elapsed : Word; // # of ticks the current task has run
  1389. SysFlags : Word;
  1390. IDNestCnt : ShortInt;
  1391. TDNestCnt : ShortInt;
  1392. AttnFlags : Word; // Attention Flags .. se below
  1393. AttnResched : Word;
  1394. ResModules : Pointer;
  1395. TaskTrapCode : Pointer;
  1396. TaskExceptCode: Pointer;
  1397. TaskExitCode : Pointer;
  1398. TaskSigAlloc : DWord;
  1399. TaskTrapAlloc : Word;
  1400. // Private Lists
  1401. MemList : TEList;
  1402. ResourceList: TEList;
  1403. DeviceList : TEList;
  1404. IntrList : TEList;
  1405. LibList : TEList;
  1406. PortList : TEList;
  1407. TaskReady : TEList;
  1408. TaskWait : TEList;
  1409. SoftInts : Array[0..4] Of TSoftIntList;
  1410. //stuff
  1411. LastAlert : Array[0..3] Of LongInt;
  1412. VBlankFrequency : Byte;
  1413. PowerSupplyFrequency: Byte; // AROS PRIVATE: VBlankFreq * PowerSupplyFreq = Timer Tick Rate
  1414. SemaphoreList : TEList;
  1415. // Kickstart
  1416. KickMemPtr : Pointer;
  1417. KickTagPtr : Pointer;
  1418. KickCheckSum : Pointer;
  1419. // Miscellaneous stuff
  1420. ex_Pad0 : Word;
  1421. ex_LaunchPoint : PtrUInt;
  1422. ex_RamLibPrivate : Pointer;
  1423. ex_EClockFrequency : DWord;
  1424. ex_CacheControl : DWord;
  1425. ex_TaskID : DWord;
  1426. ex_Reserved1 : Array[0..4] Of PtrUInt;
  1427. ex_MMULock : Pointer;
  1428. ex_Reserved2 : Array[0..1] Of PtrUInt;
  1429. ex_DebugFlags : DWord; { * Exec Debug Flags..*private* * }
  1430. ex_MemHandlers : TMinList;
  1431. ex_MemHandler : Pointer;
  1432. // Additional field for AROS
  1433. DebugAROSBase : PArosSupportBase;
  1434. end;
  1435. { *
  1436. * Outdated 68k cpu informations
  1437. *
  1438. * }
  1439. const // Checked OK 05.08.2011 ALB
  1440. AFB_68010 = 0;
  1441. AFB_68020 = 1;
  1442. AFB_68030 = 2;
  1443. AFB_68040 = 3;
  1444. AFB_68881 = 4;
  1445. AFB_68882 = 5;
  1446. AFB_FPU40 = 6;
  1447. AFB_68060 = 7;
  1448. AFB_PRIVATE = 15;
  1449. AFF_68010 = (1 shl AFB_68010);
  1450. AFF_68020 = (1 shl AFB_68020);
  1451. AFF_68030 = (1 shl AFB_68030);
  1452. AFF_68040 = (1 shl AFB_68040);
  1453. AFF_68881 = (1 shl AFB_68881);
  1454. AFF_68882 = (1 shl AFB_68882);
  1455. AFF_FPU40 = (1 shl AFB_FPU40);
  1456. AFF_68060 = (1 shl AFB_68060);
  1457. AFF_PRIVATE = (1 shl AFB_PRIVATE);
  1458. { *
  1459. * Outdated 68k cache functionality
  1460. * Mostly without function.
  1461. * }
  1462. const // Checked OK 05.08.2011 ALB
  1463. CACRF_EnableI = (1 shl 0);
  1464. CACRF_FreezeI = (1 shl 1);
  1465. CACRF_ClearI = (1 shl 3);
  1466. CACRF_IBE = (1 shl 4);
  1467. CACRF_EnableD = (1 shl 8);
  1468. CACRF_FreezeD = (1 shl 9);
  1469. CACRF_ClearD = (1 shl 11);
  1470. CACRF_DBE = (1 shl 12);
  1471. CACRF_WriteAllocate = (1 shl 13);
  1472. CACRF_EnableE = (1 shl 30);
  1473. CACRF_CopyBack = (1 shl 31);
  1474. DMA_Continue = (1 shl 1);
  1475. DMA_NoModify = (1 shl 2);
  1476. DMA_ReadFromRAM = (1 shl 3);
  1477. (*
  1478. SB_SAR = 15;
  1479. SB_TQE = 14;
  1480. SB_SINT = 13;
  1481. SF_SAR = (1 shl SB_SAR);
  1482. SF_TQE = (1 shl SB_TQE);
  1483. SF_SINT = (1 shl SB_SINT);
  1484. *)
  1485. { ****** Debug Flags...(don`t depend on them) ********** }
  1486. const // Checked OK 05.08.2011 ALB
  1487. EXECDEBUGF_INITRESIDENT = $1;
  1488. EXECDEBUGF_INITCODE = $2;
  1489. EXECDEBUGF_FINDRESIDENT = $4;
  1490. EXECDEBUGF_CREATELIBRARY = $10;
  1491. EXECDEBUGF_SETFUNCTION = $20;
  1492. EXECDEBUGF_NEWSETFUNCTION = $40;
  1493. EXECDEBUGF_CHIPRAM = $80;
  1494. EXECDEBUGF_ADDTASK = $100;
  1495. EXECDEBUGF_REMTASK = $200;
  1496. EXECDEBUGF_GETTASKATTR = $400;
  1497. EXECDEBUGF_SETTASKATTR = $800;
  1498. EXECDEBUGF_EXCEPTHANDLER = $1000;
  1499. EXECDEBUGF_ADDDOSNODE = $2000;
  1500. EXECDEBUGF_PCI = $4000;
  1501. EXECDEBUGF_RAMLIB = $8000;
  1502. EXECDEBUGF_NOLOGSERVER = $10000;
  1503. EXECDEBUGF_NOLOGWINDOW = $20000;
  1504. { *
  1505. * "env:MorphOS/LogPath" contains the logfile path,
  1506. * If not specified it`s using "ram:.morphoslog"
  1507. * }
  1508. EXECDEBUGF_LOGFILE = $40000;
  1509. EXECDEBUGF_LOGKPRINTF = $80000;
  1510. { * Memory Tracking Flags
  1511. * }
  1512. EXECDEBUGF_PERMMEMTRACK = $100000;
  1513. EXECDEBUGF_MEMTRACK = $200000;
  1514. { * CyberGuardPPC Flags
  1515. * }
  1516. EXECDEBUGF_CYBERGUARDDEADLY = $400000;
  1517. { * PPCLib Flags
  1518. * }
  1519. EXECDEBUGF_LOADSEG = $01000000;
  1520. EXECDEBUGF_UNLOADSEG = $02000000;
  1521. EXECDEBUGF_PPCSTART = $04000000;
  1522. { * UserFlags
  1523. * }
  1524. { *
  1525. * Enables debug output for cybergraphx
  1526. * }
  1527. const // Checked OK 05.08.2011 ALB
  1528. EXECDEBUGF_CGXDEBUG = $08000000;
  1529. { *
  1530. * Should be used to control user LibInit/DevInit Debug output
  1531. * }
  1532. EXECDEBUGF_INIT = $40000000;
  1533. { *
  1534. * Should be used to control logging
  1535. * }
  1536. EXECDEBUGF_LOG = $80000000;
  1537. {*
  1538. * The following definitions are private!
  1539. *}
  1540. const // Checked OK 05.08.2011 ALB
  1541. // SysFlags
  1542. SFF_SoftInt = (1 shl 5); // There is a software interrupt
  1543. SFF_QuantumOver = (1 shl 13); // Task's time slice is over
  1544. // AttnFlags
  1545. ARF_AttnSwitch = (1 shl 7); // Delayed Switch() pending
  1546. ARF_AttnDispatch = (1 shl 15); // Delayed Dispatch() pending
  1547. const
  1548. { *
  1549. * Execbase list IDs
  1550. * }
  1551. EXECLIST_DEVICE = 0;
  1552. EXECLIST_INTERRUPT = 1;
  1553. EXECLIST_LIBRARY = 2;
  1554. EXECLIST_MEMHANDLER = 3;
  1555. EXECLIST_MEMHEADER = 4;
  1556. EXECLIST_PORT = 5;
  1557. EXECLIST_RESOURCE = 6;
  1558. EXECLIST_SEMAPHORE = 7;
  1559. EXECLIST_TASK = 8;
  1560. { *
  1561. * Execnotify hook message
  1562. * }
  1563. type
  1564. PExecNotifyMessage = ^TExecNotifyMessage;
  1565. TExecNotifyMessage = record
  1566. MType : DWord;
  1567. Flags : DWord;
  1568. Extra : DWord;
  1569. Extension: Pointer;
  1570. end;
  1571. const
  1572. EXECNOTIFYF_REMOVE = (1 Shl 0); { * if clear, is ADD * }
  1573. EXECNOTIFYF_POST = (1 Shl 1); { * if clear, is PRE * }
  1574. { *
  1575. * AddExecNodeTagList tags
  1576. * }
  1577. const
  1578. SAL_Dummy = (TAG_USER + 1000);
  1579. SAL_Type = (SAL_Dummy + 1);
  1580. SAL_Priority = (SAL_Dummy + 2);
  1581. SAL_Name = (SAL_Dummy + 3);
  1582. {$include utild2.inc}