system.pp 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  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. const
  33. UnusedHandle = -1;
  34. StdInputHandle = 0;
  35. StdOutputHandle = 1;
  36. StdErrorHandle = 2;
  37. sLineBreak : string[1] = LineEnding;
  38. DefaultTextLineBreakStyle : TTextLineBreakStyle = tlbsLF;
  39. var
  40. argc : longint;
  41. argv : ppchar;
  42. envp : ppchar;
  43. implementation
  44. { include system independent routines }
  45. {$I system.inc}
  46. procedure setup_arguments;
  47. begin
  48. end;
  49. procedure setup_environment;
  50. begin
  51. end;
  52. {*****************************************************************************
  53. System Dependent Exit code
  54. *****************************************************************************}
  55. Procedure system_exit;
  56. begin
  57. end;
  58. {*****************************************************************************
  59. ParamStr/Randomize
  60. *****************************************************************************}
  61. { number of args }
  62. function paramcount : longint;
  63. begin
  64. {paramcount := argc - 1;}
  65. paramcount:=0;
  66. end;
  67. { argument number l }
  68. function paramstr(l : longint) : string;
  69. begin
  70. {if (l>=0) and (l+1<=argc) then
  71. paramstr:=strpas(argv[l])
  72. else}
  73. paramstr:='';
  74. end;
  75. { set randseed to a new pseudo random value }
  76. procedure randomize;
  77. begin
  78. {regs.realeax:=$2c00;
  79. sysrealintr($21,regs);
  80. hl:=regs.realedx and $ffff;
  81. randseed:=hl*$10000+ (regs.realecx and $ffff);}
  82. randseed:=0;
  83. end;
  84. {*****************************************************************************
  85. Heap Management
  86. *****************************************************************************}
  87. { first address of heap }
  88. function getheapstart:pointer;{assembler;
  89. asm
  90. leal HEAP,%eax
  91. end ['EAX'];}
  92. begin
  93. getheapstart:=0;
  94. end;
  95. { current length of heap }
  96. function getheapsize:longint;{assembler;
  97. asm
  98. movl HEAPSIZE,%eax
  99. end ['EAX'];}
  100. begin
  101. getheapsize:=0;
  102. end;
  103. { function to allocate size bytes more for the program }
  104. { must return the first address of new data space or nil if fail }
  105. function Sbrk(size : longint):pointer;{assembler;
  106. asm
  107. movl size,%eax
  108. pushl %eax
  109. call ___sbrk
  110. addl $4,%esp
  111. end;}
  112. begin
  113. Sbrk:=nil;
  114. end;
  115. { include standard heap management }
  116. {$I heap.inc}
  117. {****************************************************************************
  118. Low level File Routines
  119. All these functions can set InOutRes on errors
  120. ****************************************************************************}
  121. { close a file from the handle value }
  122. procedure do_close(handle : longint);
  123. begin
  124. InOutRes:=1;
  125. end;
  126. procedure do_erase(p : pchar);
  127. begin
  128. InOutRes:=1;
  129. end;
  130. procedure do_rename(p1,p2 : pchar);
  131. begin
  132. InOutRes:=1;
  133. end;
  134. function do_write(h,addr,len : longint) : longint;
  135. begin
  136. InOutRes:=1;
  137. end;
  138. function do_read(h,addr,len : longint) : longint;
  139. begin
  140. InOutRes:=1;
  141. end;
  142. function do_filepos(handle : longint) : longint;
  143. begin
  144. InOutRes:=1;
  145. end;
  146. procedure do_seek(handle,pos : longint);
  147. begin
  148. InOutRes:=1;
  149. end;
  150. function do_seekend(handle:longint):longint;
  151. begin
  152. InOutRes:=1;
  153. end;
  154. function do_filesize(handle : longint) : longint;
  155. begin
  156. InOutRes:=1;
  157. end;
  158. { truncate at a given position }
  159. procedure do_truncate (handle,pos:longint);
  160. begin
  161. InOutRes:=1;
  162. end;
  163. procedure do_open(var f;p:pchar;flags:longint);
  164. {
  165. filerec and textrec have both handle and mode as the first items so
  166. they could use the same routine for opening/creating.
  167. when (flags and $10) the file will be append
  168. when (flags and $100) the file will be truncate/rewritten
  169. when (flags and $1000) there is no check for close (needed for textfiles)
  170. }
  171. begin
  172. InOutRes:=1;
  173. end;
  174. function do_isdevice(handle:longint):boolean;
  175. begin
  176. do_isdevice:=false;
  177. end;
  178. {*****************************************************************************
  179. UnTyped File Handling
  180. *****************************************************************************}
  181. {$i file.inc}
  182. {*****************************************************************************
  183. Typed File Handling
  184. *****************************************************************************}
  185. {$i typefile.inc}
  186. {*****************************************************************************
  187. Text File Handling
  188. *****************************************************************************}
  189. { should we consider #26 as the end of a file ? }
  190. {?? $DEFINE EOF_CTRLZ}
  191. {$i text.inc}
  192. {*****************************************************************************
  193. Directory Handling
  194. *****************************************************************************}
  195. procedure mkdir(const s : string);[IOCheck];
  196. begin
  197. InOutRes:=1;
  198. end;
  199. procedure rmdir(const s : string);[IOCheck];
  200. begin
  201. InOutRes:=1;
  202. end;
  203. procedure chdir(const s : string);[IOCheck];
  204. begin
  205. InOutRes:=1;
  206. end;
  207. procedure GetDir (DriveNr: byte; var Dir: ShortString);
  208. begin
  209. InOutRes := 1;
  210. end;
  211. {*****************************************************************************
  212. SystemUnit Initialization
  213. *****************************************************************************}
  214. Begin
  215. { To be set if this is a GUI or console application }
  216. IsConsole := TRUE;
  217. { To be set if this is a library and not a program }
  218. IsLibrary := FALSE;
  219. StackBottom := SPtr - StackLength;
  220. ExitCode := 0;
  221. { Setup heap }
  222. InitHeap;
  223. { Setup stdin, stdout and stderr }
  224. OpenStdIO(Input,fmInput,StdInputHandle);
  225. OpenStdIO(Output,fmOutput,StdOutputHandle);
  226. OpenStdIO(StdOut,fmOutput,StdOutputHandle);
  227. OpenStdIO(StdErr,fmOutput,StdErrorHandle);
  228. { Setup environment and arguments }
  229. Setup_Environment;
  230. Setup_Arguments;
  231. { Reset IO Error }
  232. InOutRes:=0;
  233. (* This should be changed to a real value during *)
  234. (* thread driver initialization if appropriate. *)
  235. ThreadID := 1;
  236. End.
  237. {
  238. $Log$
  239. Revision 1.10 2004-01-20 23:12:49 hajny
  240. * ExecuteProcess fixes, ProcessID and ThreadID added
  241. Revision 1.9 2003/09/27 11:52:36 peter
  242. * sbrk returns pointer
  243. Revision 1.8 2002/09/07 16:01:27 peter
  244. * old logs removed and tabs fixed
  245. Revision 1.7 2002/04/21 15:55:14 carl
  246. + initialize some global variables
  247. }