system.pp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2006 by Francesco Lombardi.
  4. System unit for Gameboy Advance
  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. unit System;
  12. interface
  13. {$define __ARM__} (* For future usage! *)
  14. {$define FPC_IS_SYSTEM}
  15. {$i gbabiosh.inc}
  16. {$I systemh.inc}
  17. {$define fpc_softfpu_interface}
  18. {$i softfpu.pp}
  19. {$undef fpc_softfpu_interface}
  20. const
  21. LineEnding = #10;
  22. LFNSupport = true;
  23. CtrlZMarksEOF: boolean = false;
  24. DirectorySeparator = '/';
  25. DriveSeparator = ':';
  26. PathSeparator = ';';
  27. FileNameCaseSensitive = false;
  28. maxExitCode = 255;
  29. MaxPathLen = 255;
  30. sLineBreak : string[1] = LineEnding;
  31. DefaultTextLineBreakStyle : TTextLineBreakStyle = tlbsCRLF;
  32. const
  33. UnusedHandle = $ffff;
  34. StdInputHandle = 0;
  35. StdOutputHandle = 1;
  36. StdErrorHandle = $ffff;
  37. var
  38. argc: LongInt = 0;
  39. argv: PPChar;
  40. envp: PPChar;
  41. errno: integer;
  42. fake_heap_start: pchar; cvar;
  43. fake_heap_end: pchar; cvar;
  44. implementation
  45. {$define fpc_softfpu_implementation}
  46. {$i softfpu.pp}
  47. {$undef fpc_softfpu_implementation}
  48. { we get these functions and types from the softfpu code }
  49. {$define FPC_SYSTEM_HAS_float64}
  50. {$define FPC_SYSTEM_HAS_float32}
  51. {$define FPC_SYSTEM_HAS_flag}
  52. {$define FPC_SYSTEM_HAS_extractFloat64Frac0}
  53. {$define FPC_SYSTEM_HAS_extractFloat64Frac1}
  54. {$define FPC_SYSTEM_HAS_extractFloat64Exp}
  55. {$define FPC_SYSTEM_HAS_extractFloat64Frac}
  56. {$define FPC_SYSTEM_HAS_extractFloat64Sign}
  57. {$define FPC_SYSTEM_HAS_ExtractFloat32Frac}
  58. {$define FPC_SYSTEM_HAS_extractFloat32Exp}
  59. {$define FPC_SYSTEM_HAS_extractFloat32Sign}
  60. {$I system.inc}
  61. {$i gbabios.inc}
  62. function GetProcessID: SizeUInt;
  63. begin
  64. end;
  65. {*****************************************************************************
  66. Misc. System Dependent Functions
  67. *****************************************************************************}
  68. procedure System_exit;
  69. begin
  70. end;
  71. {*****************************************************************************
  72. ParamStr/Randomize
  73. *****************************************************************************}
  74. { number of args }
  75. function paramcount : longint;
  76. begin
  77. paramcount:=0;
  78. end;
  79. { argument number l }
  80. function paramstr(l : longint) : string;
  81. begin
  82. paramstr:='';
  83. end;
  84. { set randseed to a new pseudo random value }
  85. procedure randomize;
  86. begin
  87. end;
  88. procedure SysInitStdIO;
  89. begin
  90. OpenStdIO(Input,fmInput,StdInputHandle);
  91. OpenStdIO(Output,fmOutput,StdOutputHandle);
  92. OpenStdIO(StdOut,fmOutput,StdOutputHandle);
  93. end;
  94. function CheckInitialStkLen(stklen : SizeUInt) : SizeUInt;
  95. begin
  96. result := stklen;
  97. end;
  98. procedure InitHeap;
  99. begin
  100. FillChar(freelists_fixed,sizeof(tfreelists),0);
  101. FillChar(freelists_free_chunk,sizeof(freelists_free_chunk),0);
  102. freelist_var:=nil;
  103. {The GBA has no operating system from which we ask memory, so we
  104. initialize the heap with a single block of memory.}
  105. freeoslistcount:=1;
  106. freeoslist:=pointer($2040000);
  107. fillchar(freeoslist^,sizeof(freeoslist^),0);
  108. freeoslist^.size:=$40000; {GBA heap is $40000 bytes.}
  109. fillchar(internal_status,sizeof(internal_status),0);
  110. end;
  111. begin
  112. StackLength := CheckInitialStkLen(InitialStkLen);
  113. ///StackBottom := Sptr - StackLength;
  114. StackBottom := StackTop - StackLength;
  115. { OS specific startup }
  116. fake_heap_start := pchar(0);
  117. fake_heap_end := pchar(0);
  118. { Set up signals handlers }
  119. { Setup heap }
  120. InitHeap;
  121. SysInitExceptions;
  122. { Setup stdin, stdout and stderr }
  123. SysInitStdIO;
  124. { Reset IO Error }
  125. InOutRes:=0;
  126. { Arguments }
  127. InitSystemThreads;
  128. initvariantmanager;
  129. initwidestringmanager;
  130. end.