system.pp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2006 by Francesco Lombardi.
  4. System unit for Nintendo DS
  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 FPC_IS_SYSTEM}
  14. {$i ndsbiosh.inc}
  15. {$i systemh.inc}
  16. {$define fpc_softfpu_interface}
  17. {$i softfpu.pp}
  18. {$undef fpc_softfpu_interface}
  19. function IsARM9(): boolean;
  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. AllFilesMask = '*';
  31. sLineBreak: string[1] = LineEnding;
  32. DefaultTextLineBreakStyle: TTextLineBreakStyle = tlbsCRLF;
  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_end: ^byte; cvar;
  43. implementation
  44. {$define fpc_softfpu_implementation}
  45. {$i softfpu.pp}
  46. {$undef fpc_softfpu_implementation}
  47. { we get these functions and types from the softfpu code }
  48. {$define FPC_SYSTEM_HAS_float64}
  49. {$define FPC_SYSTEM_HAS_float32}
  50. {$define FPC_SYSTEM_HAS_flag}
  51. {$define FPC_SYSTEM_HAS_extractFloat64Frac0}
  52. {$define FPC_SYSTEM_HAS_extractFloat64Frac1}
  53. {$define FPC_SYSTEM_HAS_extractFloat64Exp}
  54. {$define FPC_SYSTEM_HAS_extractFloat64Sign}
  55. {$define FPC_SYSTEM_HAS_ExtractFloat32Frac}
  56. {$define FPC_SYSTEM_HAS_extractFloat32Exp}
  57. {$define FPC_SYSTEM_HAS_extractFloat32Sign}
  58. {$i system.inc}
  59. {$i ndsbios.inc}
  60. {
  61. NDS CPU detecting function (thanks to 21o6):
  62. --------------------------------------------
  63. "You see, the ARM7 can't write to bank A of VRAM, but it doesn't give any
  64. error ... it just doesn't write there... so it's easily determinable what
  65. CPU is running the code"
  66. ARM946E-S processor can handle dsp extensions extensions, but ARM7TDMI does
  67. not. FPC can't retrieve the CPU target at compiling time, so this small
  68. function takes care to check if the code is running on an ARM9 or on an ARM7
  69. CPU. It works on Nintendo DS only, I guess :)
  70. }
  71. function IsARM9(): boolean;
  72. var
  73. Dummy : pword absolute $06800000;
  74. tmp: word;
  75. begin
  76. tmp := Dummy^;
  77. Dummy^ := $C0DE;
  78. IsARM9 := Dummy^ = $C0DE;
  79. Dummy^ := tmp;
  80. end;
  81. {$ifdef FPC_HAS_FEATURE_PROCESSES}
  82. function GetProcessID: SizeUInt;
  83. begin
  84. GetProcessID := 0;
  85. end;
  86. {$endif}
  87. {*****************************************************************************
  88. Misc. System Dependent Functions
  89. *****************************************************************************}
  90. procedure System_exit;
  91. begin
  92. // Boo!
  93. end;
  94. {*****************************************************************************
  95. ParamStr/Randomize
  96. *****************************************************************************}
  97. { number of args }
  98. function paramcount : longint;
  99. begin
  100. paramcount := 0;
  101. end;
  102. { argument number l }
  103. function paramstr(l : longint) : string;
  104. begin
  105. paramstr := '';
  106. end;
  107. { set randseed to a new pseudo random value }
  108. procedure randomize;
  109. begin
  110. // Boo!
  111. end;
  112. {$ifdef FPC_HAS_FEATURE_TEXTIO}
  113. procedure SysInitStdIO;
  114. begin
  115. OpenStdIO(Input,fmInput,StdInputHandle);
  116. OpenStdIO(Output,fmOutput,StdOutputHandle);
  117. OpenStdIO(StdOut,fmOutput,StdOutputHandle);
  118. end;
  119. {$endif}
  120. function CheckInitialStkLen(stklen : SizeUInt) : SizeUInt;
  121. begin
  122. result := stklen;
  123. end;
  124. begin
  125. StackLength := CheckInitialStkLen(InitialStkLen);
  126. StackBottom := StackTop - StackLength;
  127. { OS specific startup }
  128. { Set up signals handlers }
  129. if IsARM9 then
  130. fpc_cpucodeinit;
  131. { Setup heap }
  132. InitHeap;
  133. SysInitExceptions;
  134. { Setup stdin, stdout and stderr }
  135. SysInitStdIO;
  136. { Reset IO Error }
  137. InOutRes:=0;
  138. { Arguments }
  139. InitSystemThreads;
  140. initvariantmanager;
  141. end.