syscinfo.pas 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. {
  2. Copyright (c) 2016 by Karoly Balogh
  3. Contains information on syscalls
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  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. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. unit syscinfo;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. systems, tokens, symconst;
  22. type
  23. tsyscallinfo = record
  24. token: ttoken;
  25. procoption: tprocoption;
  26. validon: set of tsystem;
  27. end;
  28. psyscallinfo = ^tsyscallinfo;
  29. const
  30. syscall_conventions: array[1..10] of tsyscallinfo = (
  31. ( token: NOTOKEN; procoption: po_syscall; validon: [system_m68k_atari,system_m68k_palmos,system_arm_palmos] ),
  32. ( token: _LEGACY; procoption: po_syscall_legacy; validon: [system_powerpc_morphos,system_m68k_amiga] ),
  33. // old sysv naming, for compatibility only (on MorphOS/OS4)
  34. ( token: _SYSV; procoption: po_syscall_basenone; validon: [system_powerpc_morphos] ),
  35. ( token: _SYSVBASE; procoption: po_syscall_baselast; validon: [system_powerpc_morphos] ),
  36. ( token: _BASESYSV; procoption: po_syscall_basefirst; validon: [system_powerpc_morphos,system_powerpc_amiga] ),
  37. ( token: _R12BASE; procoption: po_syscall_basereg; validon: [system_powerpc_morphos] ),
  38. // new base naming, which should cover all "next-gen" Amiga-like systems
  39. ( token: _BASENONE; procoption: po_syscall_basenone; validon: [system_powerpc_morphos] ),
  40. ( token: _BASEFIRST; procoption: po_syscall_basefirst; validon: [system_powerpc_morphos,system_powerpc_amiga] ),
  41. ( token: _BASELAST; procoption: po_syscall_baselast; validon: [system_powerpc_morphos,system_i386_aros,system_x86_64_aros,system_arm_aros] ),
  42. ( token: _BASEREG; procoption: po_syscall_basereg; validon: [system_powerpc_morphos,system_i386_aros,system_x86_64_aros] ));
  43. function get_syscall_by_token(const token: ttoken): psyscallinfo;
  44. function get_syscall_by_name(const name: string): psyscallinfo;
  45. function get_default_syscall: tprocoption;
  46. procedure set_default_syscall(sc: tprocoption);
  47. implementation
  48. uses
  49. verbose;
  50. const
  51. syscall_conventions_po = [ po_syscall, po_syscall_legacy, po_syscall_basenone,
  52. po_syscall_baselast, po_syscall_basefirst, po_syscall_basereg ];
  53. type
  54. tsyscalldefaultinfo = record
  55. system: tsystem;
  56. procoption: tprocoption;
  57. end;
  58. const
  59. default_syscall_conventions: array[0..8] of tsyscalldefaultinfo = (
  60. ( system: system_arm_palmos; procoption: po_syscall ),
  61. ( system: system_m68k_palmos; procoption: po_syscall ),
  62. ( system: system_m68k_atari; procoption: po_syscall ),
  63. ( system: system_m68k_amiga; procoption: po_syscall_legacy ),
  64. ( system: system_powerpc_amiga; procoption: po_syscall_basefirst ),
  65. ( system: system_powerpc_morphos; procoption: po_syscall_legacy ),
  66. ( system: system_arm_aros; procoption: po_syscall_baselast ),
  67. ( system: system_i386_aros; procoption: po_syscall_baselast ),
  68. ( system: system_x86_64_aros; procoption: po_syscall_basereg ));
  69. var
  70. default_syscall_convention: tprocoption = po_none;
  71. function get_syscall_by_token(const token: ttoken): psyscallinfo;
  72. var
  73. i: longint;
  74. begin
  75. result:=nil;
  76. for i:=low(syscall_conventions) to high(syscall_conventions) do
  77. if syscall_conventions[i].token = token then
  78. begin
  79. result:=@syscall_conventions[i];
  80. break;
  81. end;
  82. end;
  83. function get_syscall_by_name(const name: string): psyscallinfo;
  84. var
  85. i: longint;
  86. begin
  87. result:=nil;
  88. for i:=low(syscall_conventions) to high(syscall_conventions) do
  89. if arraytokeninfo[syscall_conventions[i].token].str = name then
  90. begin
  91. result:=@syscall_conventions[i];
  92. break;
  93. end;
  94. end;
  95. function get_default_syscall: tprocoption;
  96. var
  97. i: longint;
  98. begin
  99. if not (default_syscall_convention in syscall_conventions_po) then
  100. begin
  101. for i:=low(default_syscall_conventions) to high(default_syscall_conventions) do
  102. if default_syscall_conventions[i].system = target_info.system then
  103. default_syscall_convention:=default_syscall_conventions[i].procoption;
  104. if not (default_syscall_convention in syscall_conventions_po) then
  105. internalerror(2016090302);
  106. end;
  107. result:=default_syscall_convention;
  108. end;
  109. procedure set_default_syscall(sc: tprocoption);
  110. begin
  111. if not (sc in syscall_conventions_po) then
  112. internalerror(2016090301);
  113. default_syscall_convention:=sc;
  114. end;
  115. end.