execf.inc 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2006 Karoly Balogh
  4. exec functions for AROS/i386
  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. var
  12. LocalExecBase : Pointer; external name '_ExecBase';
  13. procedure Forbid; syscall AOS_ExecBase 22;
  14. procedure Permit; syscall AOS_ExecBase 23;
  15. function execAllocMem(byteSize: PtrUInt; requirements: Cardinal): Pointer; syscall LocalExecBase 33;
  16. procedure execFreeMem(memoryBlock: Pointer; byteSize: PtrUInt); syscall LocalExecBase 35;
  17. function FindTask(name: PAnsiChar): PTask; syscall LocalExecBase 49;
  18. function SetSignal(newSignals: Cardinal; signalSet : Cardinal): Cardinal; syscall LocalExecBase 51;
  19. function Wait(SignalSet: LongWord): LongWord; syscall AOS_ExecBase 53;
  20. procedure Signal(Task: PTask; SignalSet: LongWord); syscall AOS_ExecBase 54;
  21. function AllocSignal(signalNum: LongInt): ShortInt; syscall LocalExecBase 55;
  22. procedure FreeSignal(signalNum: LongInt); syscall LocalExecBase 56;
  23. procedure AddPort(port: PMsgPort); syscall LocalExecBase 59;
  24. procedure RemPort(port: PMsgPort); syscall LocalExecBase 60;
  25. procedure PutMsg(Port: PMsgPort; Message: PMessage); syscall AOS_ExecBase 61;
  26. function GetMsg(port: PMsgPort): PMessage; syscall LocalExecBase 62;
  27. procedure ReplyMsg(message : pMessage); syscall LocalExecBase 63;
  28. function WaitPort(port: PMsgPort): PMessage; syscall LocalExecBase 64;
  29. procedure CloseLibrary(libHandle: PLibrary); syscall LocalExecBase 69;
  30. function OpenDevice(devName: PAnsiChar; numunit: Cardinal; ioRequest: pIORequest; flags: Cardinal): ShortInt; syscall LocalExecBase 74;
  31. procedure CloseDevice(ioRequest: PIORequest); syscall LocalExecBase 75;
  32. function DoIO(ioRequest: PIORequest): ShortInt; syscall LocalExecBase 76;
  33. function OpenLibrary(libname: PAnsiChar; libver : Cardinal): Pointer; syscall LocalExecBase 92;
  34. procedure InitSemaphore(SigSem: PSignalSemaphore); syscall AOS_ExecBase 93;
  35. procedure ObtainSemaphore(SigSem: PSignalSemaphore); syscall AOS_ExecBase 94;
  36. procedure ReleaseSemaphore(SigSem: PSignalSemaphore); syscall AOS_ExecBase 95;
  37. function AttemptSemaphore(SigSem: PSignalSemaphore): LongWord; syscall AOS_ExecBase 96;
  38. function CreateMsgPort: PMsgPort; syscall AOS_ExecBase 111;
  39. procedure DeleteMsgPort(Port: PMsgPort); syscall AOS_ExecBase 112;
  40. procedure ObtainSemaphoreShared(SigSem: PSignalSemaphore); syscall AOS_ExecBase 113;
  41. function AllocVec(ByteSize: PtrUInt; Requirements: DWord): Pointer; syscall AOS_ExecBase 114;
  42. procedure FreeVec(MemoryBlock: Pointer); syscall AOS_ExecBase 115;
  43. function CreatePool(requirements: Cardinal; puddleSize: PtrUInt; threshSize: PtrUInt): Pointer; syscall LocalExecBase 116;
  44. procedure DeletePool(poolHeader: Pointer); syscall LocalExecBase 117;
  45. function AllocPooled(poolHeader: Pointer; memSize: PtrUInt): Pointer; syscall LocalExecBase 118;
  46. function FreePooled(poolHeader: Pointer; memory: Pointer; memSize: PtrUInt): Pointer; syscall LocalExecBase 119;
  47. procedure StackSwap(NewStack: PStackSwapStruct); syscall AOS_ExecBase 122;
  48. function NewStackSwap(NewStack: PStackSwapStruct; Function_: Pointer; Args: PStackSwapArgs): Pointer; syscall AOS_ExecBase 134;
  49. procedure RawPutChar(c: AnsiChar); syscall AOS_ExecBase 86;
  50. //function RawDoFmt(const formatString : PAnsiChar;const dataStream : POINTER; putChProc : tPROCEDURE; putChData : POINTER): pointer;
  51. function RawDoFmt(const formatString : PAnsiChar;const dataStream : POINTER; putChProc : POINTER; putChData : POINTER): pointer; syscall LocalExecBase 87;
  52. // Debugbase
  53. function DecodeLocation(Addr1: Pointer; Tags: Pointer): Integer; syscall SysDebugBase 7;
  54. function GetLibAdress(Base: Pointer; Offset: LongInt): Pointer; inline;
  55. begin
  56. if Base = nil then
  57. begin
  58. RawDoFmt('FPC_FILE_DEBUG: Error! Illegal library access with not opened library: %d !'+#10,@Offset,pointer(1),nil);
  59. Debugln('Illegal library access with not opened library');
  60. Halt(1);
  61. end;
  62. GetLibAdress := Pointer((Base -(Offset * SizeOf(Pointer)))^);
  63. end;
  64. procedure Debug(s: shortstring);
  65. type
  66. TkPrintf = function(Msg: PAnsiChar): Integer; cdecl;
  67. var
  68. kPrintf: TkPrintf;
  69. d: shortstring;
  70. i: Integer;
  71. begin
  72. if Assigned(AOS_ExecBase) then
  73. begin
  74. if Assigned(PExecBase(AOS_ExecBase)^.DebugArosBase) then
  75. begin
  76. kPrintf := TKPrintF(PExecBase(AOS_ExecBase)^.DebugArosBase^.kprintfPtr);
  77. if Assigned(kPrintf) then
  78. begin
  79. d := s + #0;
  80. i := kPrintf(@d[1]);
  81. end;
  82. end;
  83. end;
  84. end;
  85. procedure Debugln(s: shortstring);
  86. begin
  87. Debug(s + #10);
  88. end;