cpuwin.inc 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 1999-2006 by Florian Klaempfl and Pavel Ozerski
  4. member of the Free Pascal development team.
  5. FPC Pascal system unit aarch64 specific part for the Win64 API.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. {$define FPC_SYSTEM_HAS_STACKTOP}
  13. function StackTop: pointer; // assembler;nostackframe;
  14. begin
  15. result:=pointer($ffffffffffffffff);
  16. end;
  17. function main_wrapper(arg: Pointer; proc: Pointer): ptrint; assembler; nostackframe;
  18. asm
  19. stp fp,lr,[sp, #-16]!
  20. .seh_savefplr_x -16
  21. .seh_endprologue
  22. blr x1 // { "arg" is passed in x0 }
  23. nop // { this nop is critical for exception handling }
  24. ldp fp,lr,[sp], #16
  25. .seh_handler __FPC_default_handler,@except,@unwind
  26. end;
  27. procedure Exe_entry(constref info: TEntryInformation);[public,alias:'_FPC_EXE_Entry'];
  28. begin
  29. SetupEntryInformation(info);
  30. IsLibrary:=false;
  31. { install the handlers for exe only ?
  32. or should we install them for DLL also ? (PM) }
  33. ExitCode:=0;
  34. asm
  35. mov x0,#0
  36. adrp x1,EntryInformation@PAGE
  37. add x1,x1,EntryInformation@PAGEOFF
  38. ldr x1,[x1,TEntryInformation.PascalMain]
  39. adrp x8,main_wrapper@PAGE
  40. add x8,x8,main_wrapper@PAGEOFF
  41. blr x8
  42. end ['X8'];
  43. { if we pass here there was no error ! }
  44. system_exit;
  45. end;