system.pp 6.9 KB

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