si_prc.pp 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2016 by the Free Pascal development team
  4. System Entry point for Human 68k (Sharp X68000)
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. unit si_prc;
  12. interface
  13. {$.define FPC_HUMAN68K_USE_TINYHEAP}
  14. implementation
  15. {$include h68kdos.inc}
  16. var
  17. stacktop: pointer; public name '__stktop';
  18. stklen: longint; external name '__stklen';
  19. {$ifdef FPC_HUMAN68K_USE_TINYHEAP}
  20. initial_heap_start: pointer; external name '__initial_heap_start';
  21. initial_heap_end: pointer; external name '__initial_heap_end';
  22. {$endif FPC_HUMAN68K_USE_TINYHEAP}
  23. var
  24. h68k_startup: Th68kdos_startup; public name '_h68k_startup';
  25. h68k_psp: Ph68kdos_psp; public name '_h68k_psp';
  26. procedure PascalMain; external name 'PASCALMAIN';
  27. procedure PascalStart(const startparams: Ph68kdos_startup); noreturn; forward;
  28. { this function must be the first in this unit which contains code }
  29. procedure _FPC_proc_start; assembler; nostackframe; noreturn; public name '_start';
  30. asm
  31. move.l a1,sp
  32. add.l stklen,sp
  33. movem.l a0-a5,-(sp)
  34. move.l sp,a0
  35. jbsr PascalStart
  36. end;
  37. procedure PascalStart(const startparams: Ph68kdos_startup); noreturn;
  38. var
  39. bss_start: pbyte;
  40. blocksize: longint;
  41. begin
  42. with startparams^ do
  43. begin
  44. { clear BSS }
  45. bss_start:=pbyte(pdword(@mcb[$30])^);
  46. fillchar(bss_start^,bss_end-bss_start,0);
  47. h68k_psp:=pointer(@mcb[$10]);
  48. {$ifdef FPC_HUMAN68K_USE_TINYHEAP}
  49. blocksize:=bss_end-pointer(h68k_psp)+stklen+heapsize;
  50. {$else FPC_HUMAN68K_USE_TINYHEAP}
  51. blocksize:=bss_end-pointer(h68k_psp)+stklen;
  52. {$endif FPC_HUMAN68K_USE_TINYHEAP}
  53. h68kdos_setblock(h68k_psp,blocksize);
  54. stacktop:=bss_end+stklen;
  55. {$ifdef FPC_HUMAN68K_USE_TINYHEAP}
  56. initial_heap_start:=stacktop;
  57. initial_heap_end:=initial_heap_start+heapsize;
  58. {$endif FPC_HUMAN68K_USE_TINYHEAP}
  59. end;
  60. h68k_startup:=startparams^;
  61. PASCALMAIN;
  62. end;
  63. procedure _FPC_proc_halt(_ExitCode: longint); noreturn; public name '_haltproc';
  64. begin
  65. h68kdos_exit2(_ExitCode);
  66. end;
  67. end.