system.pp 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2000 by the Free Pascal development team.
  5. This is a prototype file to show all function that need to be implemented
  6. for a new operating system (provided the processor specific
  7. function are already implemented !)
  8. See the file COPYING.FPC, included in this distribution,
  9. for details about the copyright.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. **********************************************************************}
  14. { no stack check in system }
  15. {$S-}
  16. unit system;
  17. interface
  18. { include system-independent routine headers }
  19. {$I systemh.inc}
  20. type
  21. THandle = longint;
  22. { include heap support headers }
  23. {$I heaph.inc}
  24. {Platform specific information}
  25. const
  26. LineEnding = #13#10;
  27. LFNSupport = true;
  28. DirectorySeparator = '\';
  29. DriveSeparator = ':';
  30. PathSeparator = ';';
  31. FileNameCaseSensitive = false;
  32. {The highest exit code which can be returned to the operating system.
  33. Should be at least 255.}
  34. maxExitCode = 255;
  35. const
  36. UnusedHandle = -1;
  37. StdInputHandle = 0;
  38. StdOutputHandle = 1;
  39. StdErrorHandle = 2;
  40. sLineBreak : string[1] = LineEnding;
  41. DefaultTextLineBreakStyle : TTextLineBreakStyle = tlbsLF;
  42. var
  43. argc : longint;
  44. argv : ppchar;
  45. envp : ppchar;
  46. implementation
  47. { include system independent routines }
  48. {$I system.inc}
  49. procedure setup_arguments;
  50. begin
  51. end;
  52. procedure setup_environment;
  53. begin
  54. end;
  55. {*****************************************************************************
  56. System Dependent Exit code
  57. *****************************************************************************}
  58. Procedure system_exit;
  59. begin
  60. end;
  61. {*****************************************************************************
  62. ParamStr/Randomize
  63. *****************************************************************************}
  64. { number of args }
  65. function paramcount : longint;
  66. begin
  67. {paramcount := argc - 1;}
  68. paramcount:=0;
  69. end;
  70. { argument number l }
  71. function paramstr(l : longint) : string;
  72. begin
  73. {if (l>=0) and (l+1<=argc) then
  74. paramstr:=strpas(argv[l])
  75. else}
  76. paramstr:='';
  77. end;
  78. { set randseed to a new pseudo random value }
  79. procedure randomize;
  80. begin
  81. {regs.realeax:=$2c00;
  82. sysrealintr($21,regs);
  83. hl:=regs.realedx and $ffff;
  84. randseed:=hl*$10000+ (regs.realecx and $ffff);}
  85. randseed:=0;
  86. end;
  87. {*****************************************************************************
  88. OS Memory allocation / deallocation
  89. ****************************************************************************}
  90. function SysOSAlloc(size: ptrint): pointer;
  91. begin
  92. // code to allocate memory block
  93. end;
  94. // If the OS is capable of freeing memory, define HAS_SYSOSFREE and implement
  95. // the SysOSFree function properly
  96. //{$define HAS_SYSOSFREE}
  97. {
  98. procedure SysOSFree(p: pointer; size: ptrint);
  99. begin
  100. // code to release memory block
  101. end;
  102. }
  103. { include standard heap management }
  104. {$I heap.inc}
  105. {****************************************************************************
  106. Low level File Routines
  107. All these functions can set InOutRes on errors
  108. ****************************************************************************}
  109. { close a file from the handle value }
  110. procedure do_close(handle : longint);
  111. begin
  112. InOutRes:=1;
  113. end;
  114. procedure do_erase(p : pchar);
  115. begin
  116. InOutRes:=1;
  117. end;
  118. procedure do_rename(p1,p2 : pchar);
  119. begin
  120. InOutRes:=1;
  121. end;
  122. function do_write(h,addr,len : longint) : longint;
  123. begin
  124. InOutRes:=1;
  125. end;
  126. function do_read(h,addr,len : longint) : longint;
  127. begin
  128. InOutRes:=1;
  129. end;
  130. function do_filepos(handle : longint) : longint;
  131. begin
  132. InOutRes:=1;
  133. end;
  134. procedure do_seek(handle,pos : longint);
  135. begin
  136. InOutRes:=1;
  137. end;
  138. function do_seekend(handle:longint):longint;
  139. begin
  140. InOutRes:=1;
  141. end;
  142. function do_filesize(handle : longint) : longint;
  143. begin
  144. InOutRes:=1;
  145. end;
  146. { truncate at a given position }
  147. procedure do_truncate (handle,pos:longint);
  148. begin
  149. InOutRes:=1;
  150. end;
  151. procedure do_open(var f;p:pchar;flags:longint);
  152. {
  153. filerec and textrec have both handle and mode as the first items so
  154. they could use the same routine for opening/creating.
  155. when (flags and $10) the file will be append
  156. when (flags and $100) the file will be truncate/rewritten
  157. when (flags and $1000) there is no check for close (needed for textfiles)
  158. }
  159. begin
  160. InOutRes:=1;
  161. end;
  162. function do_isdevice(handle:longint):boolean;
  163. begin
  164. do_isdevice:=false;
  165. end;
  166. {*****************************************************************************
  167. UnTyped File Handling
  168. *****************************************************************************}
  169. {$i file.inc}
  170. {*****************************************************************************
  171. Typed File Handling
  172. *****************************************************************************}
  173. {$i typefile.inc}
  174. {*****************************************************************************
  175. Text File Handling
  176. *****************************************************************************}
  177. { should we consider #26 as the end of a file ? }
  178. {?? $DEFINE EOF_CTRLZ}
  179. {$i text.inc}
  180. {*****************************************************************************
  181. Directory Handling
  182. *****************************************************************************}
  183. procedure mkdir(const s : string);[IOCheck];
  184. begin
  185. InOutRes:=1;
  186. end;
  187. procedure rmdir(const s : string);[IOCheck];
  188. begin
  189. InOutRes:=1;
  190. end;
  191. procedure chdir(const s : string);[IOCheck];
  192. begin
  193. InOutRes:=1;
  194. end;
  195. procedure GetDir (DriveNr: byte; var Dir: ShortString);
  196. begin
  197. InOutRes := 1;
  198. end;
  199. {*****************************************************************************
  200. SystemUnit Initialization
  201. *****************************************************************************}
  202. Begin
  203. { To be set if this is a GUI or console application }
  204. IsConsole := TRUE;
  205. { To be set if this is a library and not a program }
  206. IsLibrary := FALSE;
  207. StackBottom := SPtr - StackLength;
  208. ExitCode := 0;
  209. { Setup heap }
  210. InitHeap;
  211. { Setup stdin, stdout and stderr }
  212. OpenStdIO(Input,fmInput,StdInputHandle);
  213. OpenStdIO(Output,fmOutput,StdOutputHandle);
  214. OpenStdIO(ErrOutput,fmOutput,StdErrorHandle);
  215. OpenStdIO(StdOut,fmOutput,StdOutputHandle);
  216. OpenStdIO(StdErr,fmOutput,StdErrorHandle);
  217. { Setup environment and arguments }
  218. Setup_Environment;
  219. Setup_Arguments;
  220. { Reset IO Error }
  221. InOutRes:=0;
  222. (* This should be changed to a real value during *)
  223. (* thread driver initialization if appropriate. *)
  224. ThreadID := 1;
  225. End.
  226. {
  227. $Log$
  228. Revision 1.14 2004-11-04 09:32:31 peter
  229. ErrOutput added
  230. Revision 1.13 2004/10/25 15:38:59 peter
  231. * compiler defined HEAP and HEAPSIZE removed
  232. Revision 1.12 2004/09/03 19:26:57 olle
  233. + added maxExitCode to all System.pp
  234. * constrained error code to be below maxExitCode in RunError et. al.
  235. Revision 1.11 2004/06/17 16:16:14 peter
  236. * New heapmanager that releases memory back to the OS, donated
  237. by Micha Nelissen
  238. Revision 1.10 2004/01/20 23:12:49 hajny
  239. * ExecuteProcess fixes, ProcessID and ThreadID added
  240. Revision 1.9 2003/09/27 11:52:36 peter
  241. * sbrk returns pointer
  242. Revision 1.8 2002/09/07 16:01:27 peter
  243. * old logs removed and tabs fixed
  244. Revision 1.7 2002/04/21 15:55:14 carl
  245. + initialize some global variables
  246. }