t_uefi.pas 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. {
  2. Copyright (c) 2014 by Olivier Coursière
  3. This unit implements support import,export,link routines
  4. for the uefi Target
  5. Based on Sven Barth's t_nativent
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  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. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. ****************************************************************************
  18. }
  19. unit t_uefi;
  20. {$i fpcdefs.inc}
  21. interface
  22. implementation
  23. uses
  24. SysUtils,
  25. cutils,
  26. ogbase,ogcoff,
  27. globtype,globals,systems,verbose,
  28. import,export,link,t_win,i_uefi;
  29. type
  30. TImportLibUEFI=class(TImportLibWin)
  31. end;
  32. TExportLibUEFI=class(TExportLibWin)
  33. end;
  34. TInternalLinkerUEFI = class(TInternalLinkerWin)
  35. constructor create;override;
  36. procedure ConcatEntryName; override;
  37. end;
  38. {****************************************************************************
  39. TInternalLinkerUEFI
  40. ****************************************************************************}
  41. constructor TInternalLinkerUEFI.create;
  42. begin
  43. inherited create;
  44. CExeoutput:=TPECoffexeoutput;
  45. CObjInput:=TPECoffObjInput;
  46. end;
  47. procedure TInternalLinkerUEFI.ConcatEntryName;
  48. begin
  49. with LinkScript do
  50. begin
  51. if IsSharedLibrary then
  52. begin
  53. // for now we use {$apptype native} for kernel mode code
  54. if apptype=app_native then
  55. Concat('ENTRYNAME EFI_MAIN')
  56. else
  57. Concat('ENTRYNAME EFI_MAIN')
  58. end
  59. else
  60. Concat('ENTRYNAME PASCALMAIN');
  61. end;
  62. end;
  63. {*****************************************************************************
  64. Initialize
  65. *****************************************************************************}
  66. initialization
  67. RegisterLinker(ld_int_uefi,TInternalLinkerUEFI);
  68. {$ifdef i386}
  69. { UEFI }
  70. RegisterImport(system_i386_uefi,TImportLibUEFI);
  71. RegisterExport(system_i386_uefi,TExportLibUEFI);
  72. RegisterTarget(system_i386_uefi_info);
  73. {$endif i386}
  74. {$ifdef x86_64}
  75. { UEFI 64}
  76. RegisterImport(system_x86_64_uefi,TImportLibUEFI);
  77. RegisterExport(system_x86_64_uefi,TExportLibUEFI);
  78. RegisterTarget(system_x86_64_uefi_info);
  79. {$endif x86_64}
  80. end.