sysos2.pas 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895
  1. {****************************************************************************
  2. Free Pascal -- OS/2 runtime library
  3. Copyright (c) 1999-2000 by Florian Klaempfl
  4. Copyright (c) 1999-2000 by Daniel Mantione
  5. Free Pascal is distributed under the GNU Public License v2. So is this unit.
  6. The GNU Public License requires you to distribute the source code of this
  7. unit with any product that uses it. We grant you an exception to this, and
  8. that is, when you compile a program with the Free Pascal Compiler, you do not
  9. need to ship source code with that program, AS LONG AS YOU ARE USING
  10. UNMODIFIED CODE! If you modify this code, you MUST change the next line:
  11. <This an official, unmodified Free Pascal source code file.>
  12. Send us your modified files, we can work together if you want!
  13. Free Pascal is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. Library GNU General Public License for more details.
  17. You should have received a copy of the Library GNU General Public License
  18. along with Free Pascal; see the file COPYING.LIB. If not, write to
  19. the Free Software Foundation, 59 Temple Place - Suite 330,
  20. Boston, MA 02111-1307, USA.
  21. ****************************************************************************}
  22. unit sysos2;
  23. {Changelog:
  24. People:
  25. DM - Daniel Mantione
  26. Date: Description of change: Changed by:
  27. - First released version 0.1. DM
  28. Coding style:
  29. My coding style is a bit unusual for Pascal. Nevertheless I friendly ask
  30. you to try to make your changes not look all to different. In general,
  31. set your IDE to use tab characters, optimal fill on and a tabsize of 4.}
  32. interface
  33. {Link the startup code.}
  34. {$l prt1.oo2}
  35. {$I SYSTEMH.INC}
  36. {$I heaph.inc}
  37. type Tos=(osDOS,osOS2,osDPMI);
  38. var os_mode:Tos;
  39. first_meg:pointer;
  40. type Psysthreadib=^Tsysthreadib;
  41. Pthreadinfoblock=^Tthreadinfoblock;
  42. Pprocessinfoblock=^Tprocessinfoblock;
  43. Tbytearray=array[0..$ffff] of byte;
  44. Pbytearray=^Tbytearray;
  45. Tsysthreadib=record
  46. tid,
  47. priority,
  48. version:longint;
  49. MCcount,
  50. MCforceflag:word;
  51. end;
  52. Tthreadinfoblock=record
  53. pexchain,
  54. stack,
  55. stacklimit:pointer;
  56. tib2:Psysthreadib;
  57. version,
  58. ordinal:longint;
  59. end;
  60. Tprocessinfoblock=record
  61. pid,
  62. parentpid,
  63. hmte:longint;
  64. cmd,
  65. env:Pbytearray;
  66. flstatus,
  67. ttype:longint;
  68. end;
  69. const UnusedHandle=$ffff;
  70. StdInputHandle=0;
  71. StdOutputHandle=1;
  72. StdErrorHandle=2;
  73. FileNameCaseSensitive : boolean = false;
  74. var
  75. { C-compatible arguments and environment }
  76. argc : longint;external name '_argc';
  77. argv : ppchar;external name '_argv';
  78. envp : ppchar;external name '_environ';
  79. implementation
  80. {$I SYSTEM.INC}
  81. procedure DosGetInfoBlocks (var Atib: PThreadInfoBlock;
  82. var Apib: PProcessInfoBlock); cdecl;
  83. external 'DOSCALLS' index 312;
  84. function DosSetRelMaxFH (var ReqCount, CurMaxFH: longint): longint; cdecl;
  85. external 'DOSCALLS' index 382;
  86. {This is the correct way to call external assembler procedures.}
  87. procedure syscall; external name '___SYSCALL';
  88. {***************************************************************************
  89. Runtime error checking related routines.
  90. ***************************************************************************}
  91. {$S-}
  92. procedure st1(stack_size:longint);[public,alias: 'STACKCHECK'];
  93. begin
  94. { called when trying to get local stack }
  95. { if the compiler directive $S is set }
  96. {$ASMMODE DIRECT}
  97. asm
  98. movl stack_size,%ebx
  99. movl %esp,%eax
  100. subl %ebx,%eax
  101. {$ifdef SYSTEMDEBUG}
  102. movl U_SYSOS2_LOWESTSTACK,%ebx
  103. cmpl %eax,%ebx
  104. jb Lis_not_lowest
  105. movl %eax,U_SYSOS2_LOWESTSTACK
  106. Lis_not_lowest:
  107. {$endif SYSTEMDEBUG}
  108. cmpb $2,U_SYSOS2_OS_MODE
  109. jne Lrunning_in_dos
  110. movl U_SYSOS2_STACKBOTTOM,%ebx
  111. jmp Lrunning_in_os2
  112. Lrunning_in_dos:
  113. movl __heap_brk,%ebx
  114. Lrunning_in_os2:
  115. cmpl %eax,%ebx
  116. jae Lshort_on_stack
  117. leave
  118. ret $4
  119. Lshort_on_stack:
  120. end ['EAX','EBX'];
  121. {$ASMMODE ATT}
  122. { this needs a local variable }
  123. { so the function called itself !! }
  124. { Writeln('low in stack ');}
  125. HandleError(202);
  126. end;
  127. {no stack check in system }
  128. {****************************************************************************
  129. Miscellaneous related routines.
  130. ****************************************************************************}
  131. procedure system_exit; assembler;
  132. asm
  133. movb $0x4c,%ah
  134. movb exitcode,%al
  135. call syscall
  136. end;
  137. {$asmmode direct}
  138. function paramcount:longint;assembler;
  139. asm
  140. movl _argc,%eax
  141. decl %eax
  142. end ['EAX'];
  143. function paramstr(l:longint):string;
  144. function args:pointer;assembler;
  145. asm
  146. movl _argv,%eax
  147. end ['EAX'];
  148. var p:^Pchar;
  149. begin
  150. if (l>=0) and (l<=paramcount) then
  151. begin
  152. p:=args;
  153. paramstr:=strpas(p[l]);
  154. end
  155. else paramstr:='';
  156. end;
  157. {$asmmode att}
  158. procedure randomize;
  159. var hl:longint;
  160. begin
  161. asm
  162. movb $0x2c,%ah
  163. call syscall
  164. movw %cx,-4(%ebp)
  165. movw %dx,-2(%ebp)
  166. end;
  167. randseed:=hl;
  168. end;
  169. {****************************************************************************
  170. Heap management releated routines.
  171. ****************************************************************************}
  172. { this function allows to extend the heap by calling
  173. syscall $7f00 resizes the brk area}
  174. function sbrk(size:longint):longint; assembler;
  175. asm
  176. movl size,%edx
  177. movw $0x7f00,%ax
  178. call syscall
  179. end;
  180. {$ASMMODE direct}
  181. function getheapstart:pointer;assembler;
  182. asm
  183. movl __heap_base,%eax
  184. end ['EAX'];
  185. function getheapsize:longint;assembler;
  186. asm
  187. movl HEAPSIZE,%eax
  188. end ['EAX'];
  189. {$ASMMODE ATT}
  190. {$i heap.inc}
  191. {****************************************************************************
  192. Low Level File Routines
  193. ****************************************************************************}
  194. procedure allowslash(p:Pchar);
  195. {Allow slash as backslash.}
  196. var i:longint;
  197. begin
  198. for i:=0 to strlen(p) do
  199. if p[i]='/' then p[i]:='\';
  200. end;
  201. procedure do_close(h:longint);
  202. begin
  203. { Only three standard handles under real OS/2 }
  204. if (h > 4) or
  205. (os_MODE = osOS2) and (h > 2) then
  206. begin
  207. asm
  208. movb $0x3e,%ah
  209. mov h,%ebx
  210. call syscall
  211. end;
  212. end;
  213. end;
  214. procedure do_erase(p:Pchar);
  215. begin
  216. allowslash(p);
  217. asm
  218. movl P,%edx
  219. movb $0x41,%ah
  220. call syscall
  221. jnc .LERASE1
  222. movw %ax,inoutres;
  223. .LERASE1:
  224. end;
  225. end;
  226. procedure do_rename(p1,p2:Pchar);
  227. begin
  228. allowslash(p1);
  229. allowslash(p2);
  230. asm
  231. movl P1, %edx
  232. movl P2, %edi
  233. movb $0x56,%ah
  234. call syscall
  235. jnc .LRENAME1
  236. movw %ax,inoutres;
  237. .LRENAME1:
  238. end;
  239. end;
  240. function do_read(h,addr,len:longint):longint; assembler;
  241. asm
  242. movl len,%ecx
  243. movl addr,%edx
  244. movl h,%ebx
  245. movb $0x3f,%ah
  246. call syscall
  247. jnc .LDOSREAD1
  248. movw %ax,inoutres;
  249. xorl %eax,%eax
  250. .LDOSREAD1:
  251. end;
  252. function do_write(h,addr,len:longint) : longint; assembler;
  253. asm
  254. movl len,%ecx
  255. movl addr,%edx
  256. movl h,%ebx
  257. movb $0x40,%ah
  258. call syscall
  259. jnc .LDOSWRITE1
  260. movw %ax,inoutres;
  261. .LDOSWRITE1:
  262. end;
  263. function do_filepos(handle:longint): longint; assembler;
  264. asm
  265. movw $0x4201,%ax
  266. movl handle,%ebx
  267. xorl %edx,%edx
  268. call syscall
  269. jnc .LDOSFILEPOS
  270. movw %ax,inoutres;
  271. xorl %eax,%eax
  272. .LDOSFILEPOS:
  273. end;
  274. procedure do_seek(handle,pos:longint); assembler;
  275. asm
  276. movw $0x4200,%ax
  277. movl handle,%ebx
  278. movl pos,%edx
  279. call syscall
  280. jnc .LDOSSEEK1
  281. movw %ax,inoutres;
  282. .LDOSSEEK1:
  283. end;
  284. function do_seekend(handle:longint):longint; assembler;
  285. asm
  286. movw $0x4202,%ax
  287. movl handle,%ebx
  288. xorl %edx,%edx
  289. call syscall
  290. jnc .Lset_at_end1
  291. movw %ax,inoutres;
  292. xorl %eax,%eax
  293. .Lset_at_end1:
  294. end;
  295. function do_filesize(handle:longint):longint;
  296. var aktfilepos:longint;
  297. begin
  298. aktfilepos:=do_filepos(handle);
  299. do_filesize:=do_seekend(handle);
  300. do_seek(handle,aktfilepos);
  301. end;
  302. procedure do_truncate(handle,pos:longint); assembler;
  303. asm
  304. (* DOS function 40h isn't safe for this according to EMX documentation
  305. movl $0x4200,%eax
  306. movl 8(%ebp),%ebx
  307. movl 12(%ebp),%edx
  308. call syscall
  309. jc .LTruncate1
  310. movl 8(%ebp),%ebx
  311. movl 12(%ebp),%edx
  312. movl %ebp,%edx
  313. xorl %ecx,%ecx
  314. movb $0x40,%ah
  315. call syscall
  316. *)
  317. movl $0x7F25,%eax
  318. movl Handle,%ebx
  319. movl Pos,%edx
  320. call syscall
  321. inc %eax
  322. movl %ecx, %eax
  323. jnz .LTruncate1
  324. (* File position is undefined after truncation, move to the end. *)
  325. movl $0x4202,%eax
  326. movl Handle,%ebx
  327. movl $0,%edx
  328. call syscall
  329. jnc .LTruncate2
  330. .LTruncate1:
  331. movw %ax,inoutres;
  332. .LTruncate2:
  333. end;
  334. const
  335. FileHandleCount: longint = 20;
  336. function Increase_File_Handle_Count: boolean;
  337. var Err: word;
  338. L1, L2: longint;
  339. begin
  340. if os_mode = osOS2 then
  341. begin
  342. L1 := 10;
  343. if DosSetRelMaxFH (L1, L2) <> 0 then
  344. Increase_File_Handle_Count := false
  345. else
  346. if L2 > FileHandleCount then
  347. begin
  348. FileHandleCount := L2;
  349. Increase_File_Handle_Count := true;
  350. end
  351. else
  352. Increase_File_Handle_Count := false;
  353. end
  354. else
  355. begin
  356. Inc (FileHandleCount, 10);
  357. Err := 0;
  358. asm
  359. movl $0x6700, %eax
  360. movl FileHandleCount, %ebx
  361. call syscall
  362. jnc .LIncFHandles
  363. movw %ax, Err
  364. .LIncFHandles:
  365. end;
  366. if Err <> 0 then
  367. begin
  368. Increase_File_Handle_Count := false;
  369. Dec (FileHandleCount, 10);
  370. end
  371. else
  372. Increase_File_Handle_Count := true;
  373. end;
  374. procedure do_open(var f;p:pchar;flags:longint);
  375. {
  376. filerec and textrec have both handle and mode as the first items so
  377. they could use the same routine for opening/creating.
  378. when (flags and $100) the file will be append
  379. when (flags and $1000) the file will be truncate/rewritten
  380. when (flags and $10000) there is no check for close (needed for textfiles)
  381. }
  382. (* var oflags:byte;
  383. *)
  384. var Action: longint;
  385. begin
  386. allowslash(p);
  387. { close first if opened }
  388. if ((flags and $10000)=0) then
  389. begin
  390. case filerec(f).mode of
  391. fminput,fmoutput,fminout : Do_Close(filerec(f).handle);
  392. fmclosed:;
  393. else
  394. begin
  395. inoutres:=102; {not assigned}
  396. exit;
  397. end;
  398. end;
  399. end;
  400. { reset file handle }
  401. filerec(f).handle := UnusedHandle;
  402. Action := 0;
  403. (* oflags:=2;
  404. *)
  405. { convert filemode to filerec modes }
  406. case (flags and 3) of
  407. 0 : filerec(f).mode:=fminput;
  408. 1 : filerec(f).mode:=fmoutput;
  409. 2 : filerec(f).mode:=fminout;
  410. end;
  411. if (flags and $1000)<>0 then
  412. Action := $500; (* Create / replace *)
  413. (* begin
  414. filerec(f).mode:=fmoutput;
  415. oflags:=2;
  416. end
  417. else
  418. if (flags and $100)<>0 then
  419. begin
  420. filerec(f).mode:=fmoutput;
  421. oflags:=2;
  422. end;
  423. *)
  424. { empty name is special }
  425. if p[0]=#0 then
  426. begin
  427. case FileRec(f).mode of
  428. fminput :
  429. FileRec(f).Handle:=StdInputHandle;
  430. fminout, { this is set by rewrite }
  431. fmoutput :
  432. FileRec(f).Handle:=StdOutputHandle;
  433. fmappend :
  434. begin
  435. FileRec(f).Handle:=StdOutputHandle;
  436. FileRec(f).mode:=fmoutput; {fool fmappend}
  437. end;
  438. end;
  439. exit;
  440. end;
  441. Action := Action or (Flags and $FF);
  442. asm
  443. movl $0x7f2b, %eax
  444. movl Action, %ecx
  445. movl p, %edx
  446. call syscall
  447. jnc .LOPEN1
  448. movw %ax, InOutRes;
  449. movw UnusedHandle, %ax
  450. .LOPEN1:
  451. movl f,%edx
  452. movw %ax,(%edx)
  453. end;
  454. if (InOutRes = 4) and Increase_File_Handle_Count then
  455. (* Trying again after increasing amount of file handles *)
  456. asm
  457. movl $0x7f2b, %eax
  458. movl Action, %ecx
  459. movl p, %edx
  460. call syscall
  461. jnc .LOPEN2
  462. movw %ax, InOutRes;
  463. movw UnusedHandle, %ax
  464. .LOPEN2:
  465. movl f,%edx
  466. movw %ax,(%edx)
  467. end;
  468. (*
  469. if (flags and $1000)<>0 then
  470. {Use create function.}
  471. asm
  472. movb $0x3c,%ah
  473. movl p,%edx
  474. xorw %cx,%cx
  475. call syscall
  476. jnc .LOPEN1
  477. movw %ax,inoutres;
  478. movw $0xffff,%ax
  479. .LOPEN1:
  480. movl f,%edx
  481. movw %ax,(%edx)
  482. end
  483. else
  484. {Use open function.}
  485. asm
  486. movb $0x3d,%ah
  487. movb oflags,%al
  488. movl p,%edx
  489. call syscall
  490. jnc .LOPEN2
  491. movw %ax,inoutres;
  492. movw $0xffff,%ax
  493. .LOPEN2:
  494. movl f,%edx
  495. movw %ax,(%edx)
  496. end;
  497. *)
  498. { for systems that have more handles }
  499. if FileRec (F).Handle > FileHandleCount then
  500. FileHandleCount := FileRec (F).Handle;
  501. if (flags and $100)<>0 then
  502. begin
  503. do_seekend(filerec(f).handle);
  504. FileRec (F).Mode := fmOutput; {fool fmappend}
  505. end;
  506. end;
  507. {$ASMMODE INTEL}
  508. function do_isdevice (Handle: longint): boolean; assembler;
  509. (*
  510. var HT, Attr: longint;
  511. begin
  512. if os_mode = osOS2 then
  513. begin
  514. if DosQueryHType (Handle, HT, Attr) <> 0 then HT := 1;
  515. end
  516. else
  517. *)
  518. asm
  519. mov ebx, Handle
  520. mov eax, 4400h
  521. call syscall
  522. mov eax, 1
  523. jc @IsDevEnd
  524. test edx, 80h
  525. jnz @IsDevEnd
  526. dec eax
  527. @IsDevEnd:
  528. end;
  529. (* do_isdevice := (Handle <= 5);*)
  530. {$ASMMODE ATT}
  531. {*****************************************************************************
  532. UnTyped File Handling
  533. *****************************************************************************}
  534. {$i file.inc}
  535. {*****************************************************************************
  536. Typed File Handling
  537. *****************************************************************************}
  538. {$i typefile.inc}
  539. {*****************************************************************************
  540. Text File Handling
  541. *****************************************************************************}
  542. {$DEFINE EOF_CTRLZ}
  543. {$i text.inc}
  544. {****************************************************************************
  545. Directory related routines.
  546. ****************************************************************************}
  547. {*****************************************************************************
  548. Directory Handling
  549. *****************************************************************************}
  550. procedure dosdir(func:byte;const s:string);
  551. var buffer:array[0..255] of char;
  552. begin
  553. move(s[1],buffer,length(s));
  554. buffer[length(s)]:=#0;
  555. allowslash(Pchar(@buffer));
  556. asm
  557. leal buffer,%edx
  558. movb func,%ah
  559. call syscall
  560. jnc .LDOS_DIRS1
  561. movw %ax,inoutres;
  562. .LDOS_DIRS1:
  563. end;
  564. end;
  565. procedure mkdir(const s : string);
  566. begin
  567. DosDir($39,s);
  568. end;
  569. procedure rmdir(const s : string);
  570. begin
  571. DosDir($3a,s);
  572. end;
  573. procedure chdir(const s : string);
  574. begin
  575. DosDir($3b,s);
  576. end;
  577. procedure getdir(drivenr : byte;var dir : shortstring);
  578. {Written by Michael Van Canneyt.}
  579. var temp:array[0..255] of char;
  580. sof:Pchar;
  581. i:byte;
  582. begin
  583. sof:=pchar(@dir[4]);
  584. { dir[1..3] will contain '[drivenr]:\', but is not }
  585. { supplied by DOS, so we let dos string start at }
  586. { dir[4] }
  587. { Get dir from drivenr : 0=default, 1=A etc... }
  588. asm
  589. movb drivenr,%dl
  590. movl sof,%esi
  591. mov $0x47,%ah
  592. call syscall
  593. end;
  594. { Now Dir should be filled with directory in ASCIIZ, }
  595. { starting from dir[4] }
  596. dir[0]:=#3;
  597. dir[2]:=':';
  598. dir[3]:='\';
  599. i:=4;
  600. {Conversion to Pascal string }
  601. while (dir[i]<>#0) do
  602. begin
  603. { convert path name to DOS }
  604. if dir[i]='/' then
  605. dir[i]:='\';
  606. dir[0]:=char(i);
  607. inc(i);
  608. end;
  609. { upcase the string (FPC function) }
  610. if not (FileNameCaseSensitive) then dir:=upcase(dir);
  611. if drivenr<>0 then { Drive was supplied. We know it }
  612. dir[1]:=char(65+drivenr-1)
  613. else
  614. begin
  615. { We need to get the current drive from DOS function 19H }
  616. { because the drive was the default, which can be unknown }
  617. asm
  618. movb $0x19,%ah
  619. call syscall
  620. addb $65,%al
  621. movb %al,i
  622. end;
  623. dir[1]:=char(i);
  624. end;
  625. end;
  626. {****************************************************************************
  627. System unit initialization.
  628. ****************************************************************************}
  629. function GetFileHandleCount: longint;
  630. var L1, L2: longint;
  631. begin
  632. L1 := 0; (* Don't change the amount, just check. *)
  633. if DosSetRelMaxFH (L1, L2) <> 0 then GetFileHandleCount := 50
  634. else GetFileHandleCount := L2;
  635. end;
  636. var pib:Pprocessinfoblock;
  637. tib:Pthreadinfoblock;
  638. begin
  639. {Determine the operating system we are running on.}
  640. asm
  641. movl $0,os_mode
  642. movw $0x7f0a,%ax
  643. call syscall
  644. testw $512,%bx {Bit 9 is OS/2 flag.}
  645. setnzb os_mode
  646. testw $4096,%bx
  647. jz .LnoRSX
  648. movl $2,os_mode
  649. .LnoRSX:
  650. end;
  651. {$ASMMODE DIRECT}
  652. {Enable the brk area by initializing it with the initial heap size.}
  653. asm
  654. movw $0x7f01,%ax
  655. movl HEAPSIZE,%edx
  656. addl __heap_base,%edx
  657. call ___SYSCALL
  658. cmpl $-1,%eax
  659. jnz Lheapok
  660. pushl $204
  661. {call RUNERROR$$WORD}
  662. Lheapok:
  663. end;
  664. {$ASMMODE ATT}
  665. {Now request, if we are running under DOS,
  666. read-access to the first meg. of memory.}
  667. if os_mode in [osDOS,osDPMI] then
  668. asm
  669. movw $0x7f13,%ax
  670. xorl %ebx,%ebx
  671. movl $0xfff,%ecx
  672. xorl %edx,%edx
  673. call syscall
  674. movl %eax,first_meg
  675. end
  676. else
  677. begin
  678. first_meg := nil;
  679. (* Initialize the amount of file handles *)
  680. FileHandleCount := GetFileHandleCount;
  681. end;
  682. {At 0.9.2, case for enumeration does not work.}
  683. case os_mode of
  684. osDOS:
  685. stackbottom:=0; {In DOS mode, heap_brk is also the
  686. stack bottom.}
  687. osOS2:
  688. begin
  689. dosgetinfoblocks(tib,pib);
  690. stackbottom:=longint(tib^.stack);
  691. end;
  692. osDPMI:
  693. stackbottom:=0; {Not sure how to get it, but seems to be
  694. always zero.}
  695. end;
  696. exitproc:=nil;
  697. {Initialize the heap.}
  698. initheap;
  699. { ... and exceptions }
  700. InitExceptions;
  701. { to test stack depth }
  702. loweststack:=maxlongint;
  703. OpenStdIO(Input,fmInput,StdInputHandle);
  704. OpenStdIO(Output,fmOutput,StdOutputHandle);
  705. OpenStdIO(StdOut,fmOutput,StdOutputHandle);
  706. OpenStdIO(StdErr,fmOutput,StdErrorHandle);
  707. { no I/O-Error }
  708. inoutres:=0;
  709. end.
  710. {
  711. $Log$
  712. Revision 1.31 2000-06-05 18:53:30 hajny
  713. * FileHandleCount handling for OS/2 added
  714. Revision 1.30 2000/06/04 14:14:01 hajny
  715. * do_truncate corrected, do_open might work under W9x now
  716. Revision 1.29 2000/05/28 18:17:39 hajny
  717. do_isdevice corrected
  718. Revision 1.28 2000/05/21 15:58:50 hajny
  719. + FileNameCaseSensitive added
  720. Revision 1.27 2000/04/07 17:47:34 hajny
  721. * got rid of os.inc
  722. Revision 1.26 2000/02/09 16:59:34 peter
  723. * truncated log
  724. Revision 1.25 2000/02/09 12:39:11 peter
  725. * halt moved to system.inc
  726. Revision 1.24 2000/01/20 23:38:02 peter
  727. * support fm_inout as stdoutput for assign(f,'');rewrite(f,1); becuase
  728. rewrite opens always with filemode 2
  729. Revision 1.23 2000/01/16 23:10:15 peter
  730. * handle check fixed
  731. Revision 1.22 2000/01/16 22:25:38 peter
  732. * check handle for file closing
  733. Revision 1.21 2000/01/09 20:45:58 hajny
  734. * FPK changed to FPC
  735. Revision 1.20 2000/01/07 16:41:50 daniel
  736. * copyright 2000
  737. Revision 1.19 2000/01/07 16:32:33 daniel
  738. * copyright 2000 added
  739. Revision 1.18 2000/01/02 17:45:25 hajny
  740. * cdecl added for doscalls routines
  741. Revision 1.17 1999/09/10 15:40:35 peter
  742. * fixed do_open flags to be > $100, becuase filemode can be upto 255
  743. }