system.pp 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  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. Stack check code
  58. *****************************************************************************}
  59. procedure int_stackcheck(stack_size:longint);[public,alias:'FPC_STACKCHECK'];
  60. {
  61. called when trying to get local stack if the compiler directive $S
  62. is set this function must preserve esi !!!! because esi is set by
  63. the calling proc for methods it must preserve all registers !!
  64. With a 2048 byte safe area used to write to StdIo without crossing
  65. the stack boundary
  66. }
  67. begin
  68. end;
  69. {*****************************************************************************
  70. ParamStr/Randomize
  71. *****************************************************************************}
  72. { number of args }
  73. function paramcount : longint;
  74. begin
  75. {paramcount := argc - 1;}
  76. paramcount:=0;
  77. end;
  78. { argument number l }
  79. function paramstr(l : longint) : string;
  80. begin
  81. {if (l>=0) and (l+1<=argc) then
  82. paramstr:=strpas(argv[l])
  83. else}
  84. paramstr:='';
  85. end;
  86. { set randseed to a new pseudo random value }
  87. procedure randomize;
  88. begin
  89. {regs.realeax:=$2c00;
  90. sysrealintr($21,regs);
  91. hl:=regs.realedx and $ffff;
  92. randseed:=hl*$10000+ (regs.realecx and $ffff);}
  93. randseed:=0;
  94. end;
  95. {*****************************************************************************
  96. Heap Management
  97. *****************************************************************************}
  98. { first address of heap }
  99. function getheapstart:pointer;{assembler;
  100. asm
  101. leal HEAP,%eax
  102. end ['EAX'];}
  103. begin
  104. getheapstart:=0;
  105. end;
  106. { current length of heap }
  107. function getheapsize:longint;{assembler;
  108. asm
  109. movl HEAPSIZE,%eax
  110. end ['EAX'];}
  111. begin
  112. getheapsize:=0;
  113. end;
  114. { function to allocate size bytes more for the program }
  115. { must return the first address of new data space or -1 if fail }
  116. function Sbrk(size : longint):longint;{assembler;
  117. asm
  118. movl size,%eax
  119. pushl %eax
  120. call ___sbrk
  121. addl $4,%esp
  122. end;}
  123. begin
  124. Sbrk:=-1;
  125. end;
  126. { include standard heap management }
  127. {$I heap.inc}
  128. {****************************************************************************
  129. Low level File Routines
  130. All these functions can set InOutRes on errors
  131. ****************************************************************************}
  132. { close a file from the handle value }
  133. procedure do_close(handle : longint);
  134. begin
  135. InOutRes:=1;
  136. end;
  137. procedure do_erase(p : pchar);
  138. begin
  139. InOutRes:=1;
  140. end;
  141. procedure do_rename(p1,p2 : pchar);
  142. begin
  143. InOutRes:=1;
  144. end;
  145. function do_write(h,addr,len : longint) : longint;
  146. begin
  147. InOutRes:=1;
  148. end;
  149. function do_read(h,addr,len : longint) : longint;
  150. begin
  151. InOutRes:=1;
  152. end;
  153. function do_filepos(handle : longint) : longint;
  154. begin
  155. InOutRes:=1;
  156. end;
  157. procedure do_seek(handle,pos : longint);
  158. begin
  159. InOutRes:=1;
  160. end;
  161. function do_seekend(handle:longint):longint;
  162. begin
  163. InOutRes:=1;
  164. end;
  165. function do_filesize(handle : longint) : longint;
  166. begin
  167. InOutRes:=1;
  168. end;
  169. { truncate at a given position }
  170. procedure do_truncate (handle,pos:longint);
  171. begin
  172. InOutRes:=1;
  173. end;
  174. procedure do_open(var f;p:pchar;flags:longint);
  175. {
  176. filerec and textrec have both handle and mode as the first items so
  177. they could use the same routine for opening/creating.
  178. when (flags and $10) the file will be append
  179. when (flags and $100) the file will be truncate/rewritten
  180. when (flags and $1000) there is no check for close (needed for textfiles)
  181. }
  182. begin
  183. InOutRes:=1;
  184. end;
  185. function do_isdevice(handle:longint):boolean;
  186. begin
  187. do_isdevice:=false;
  188. end;
  189. {*****************************************************************************
  190. UnTyped File Handling
  191. *****************************************************************************}
  192. {$i file.inc}
  193. {*****************************************************************************
  194. Typed File Handling
  195. *****************************************************************************}
  196. {$i typefile.inc}
  197. {*****************************************************************************
  198. Text File Handling
  199. *****************************************************************************}
  200. { should we consider #26 as the end of a file ? }
  201. {?? $DEFINE EOF_CTRLZ}
  202. {$i text.inc}
  203. {*****************************************************************************
  204. Directory Handling
  205. *****************************************************************************}
  206. procedure mkdir(const s : string);[IOCheck];
  207. begin
  208. InOutRes:=1;
  209. end;
  210. procedure rmdir(const s : string);[IOCheck];
  211. begin
  212. InOutRes:=1;
  213. end;
  214. procedure chdir(const s : string);[IOCheck];
  215. begin
  216. InOutRes:=1;
  217. end;
  218. procedure GetDir (DriveNr: byte; var Dir: ShortString);
  219. begin
  220. InOutRes := 1;
  221. end;
  222. {*****************************************************************************
  223. SystemUnit Initialization
  224. *****************************************************************************}
  225. Begin
  226. { Setup heap }
  227. InitHeap;
  228. { Setup stdin, stdout and stderr }
  229. OpenStdIO(Input,fmInput,StdInputHandle);
  230. OpenStdIO(Output,fmOutput,StdOutputHandle);
  231. OpenStdIO(StdOut,fmOutput,StdOutputHandle);
  232. OpenStdIO(StdErr,fmOutput,StdErrorHandle);
  233. { Setup environment and arguments }
  234. Setup_Environment;
  235. Setup_Arguments;
  236. { Reset IO Error }
  237. InOutRes:=0;
  238. End.
  239. {
  240. $Log$
  241. Revision 1.6 2001-06-19 20:46:56 hajny
  242. * platform specific constants moved after systemh.inc, BeOS omission corrected
  243. Revision 1.5 2001/06/13 22:21:53 hajny
  244. + platform specific information
  245. Revision 1.4 2001/03/25 11:06:35 hajny
  246. * GetDir fixed
  247. Revision 1.3 2001/03/16 20:42:44 hajny
  248. * universal FExpand
  249. Revision 1.2 2000/07/13 11:33:56 michael
  250. + removed logs
  251. }