summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorolivier <olivier@3ad0048d-3df7-0310-abae-a5850022a9f2>2017-05-01 21:31:59 +0000
committerolivier <olivier@3ad0048d-3df7-0310-abae-a5850022a9f2>2017-05-01 21:31:59 +0000
commit1d99c184cf91143e5d410053b3f70f1289fbcd6c (patch)
treeb3e16fe3d9bd3095ffd5a3a4b5e8599745e21178
parentde50a4f0abd49b26aef7c02add6cbe19d7112e6a (diff)
downloadfpc-1d99c184cf91143e5d410053b3f70f1289fbcd6c.tar.gz
+ Declare UEFI target in the compiler
git-svn-id: https://svn.freepascal.org/svn/fpc/branches/olivier@36054 3ad0048d-3df7-0310-abae-a5850022a9f2
-rw-r--r--uefi/compiler/compiler.pas3
-rw-r--r--uefi/compiler/i386/cputarg.pas3
-rw-r--r--uefi/compiler/msg/errore.msg1
-rw-r--r--uefi/compiler/ogcoff.pas2
-rw-r--r--uefi/compiler/systems.inc6
-rw-r--r--uefi/compiler/systems/i_uefi.pas189
-rw-r--r--uefi/compiler/systems/t_uefi.pas104
-rw-r--r--uefi/compiler/utils/ppuutils/ppudump.pp3
8 files changed, 307 insertions, 4 deletions
diff --git a/uefi/compiler/compiler.pas b/uefi/compiler/compiler.pas
index d29b014c55..a823b8679e 100644
--- a/uefi/compiler/compiler.pas
+++ b/uefi/compiler/compiler.pas
@@ -132,6 +132,9 @@ uses
{$ifdef aix}
,i_aix
{$endif aix}
+{$ifdef uefi}
+ ,i_uefi
+{$endif uefi}
,globtype;
function Compile(const cmd:TCmdStr):longint;
diff --git a/uefi/compiler/i386/cputarg.pas b/uefi/compiler/i386/cputarg.pas
index 427cc1196b..2b66cbb065 100644
--- a/uefi/compiler/i386/cputarg.pas
+++ b/uefi/compiler/i386/cputarg.pas
@@ -89,6 +89,9 @@ implementation
{$ifndef NOTARGETAROS}
,t_aros
{$endif}
+ {$ifndef NOTTARGETUEFI}
+ ,t_uefi
+ {$endif NOTTARGETUEFI}
{**************************************
Assemblers
diff --git a/uefi/compiler/msg/errore.msg b/uefi/compiler/msg/errore.msg
index 9cf454fd40..3f8be60895 100644
--- a/uefi/compiler/msg/errore.msg
+++ b/uefi/compiler/msg/errore.msg
@@ -3955,6 +3955,7 @@ p*2Tlinux_Linux
S*2Tsolaris_Solaris
S*2Tlinux_Linux
V*2Tembedded_Embedded
+3*2Tuefi_UEFI
**1u<x>_Undefines the symbol <x>
**1U_Unit options:
**2Un_Do not check where the unit name matches the file name
diff --git a/uefi/compiler/ogcoff.pas b/uefi/compiler/ogcoff.pas
index 75baa47b9e..79be8bd5c1 100644
--- a/uefi/compiler/ogcoff.pas
+++ b/uefi/compiler/ogcoff.pas
@@ -3217,7 +3217,7 @@ const pemagic : array[0..3] of byte = (
idtxt : 'PECOFF';
asmbin : '';
asmcmd : '';
- supported_targets : [system_i386_win32,system_i386_nativent];
+ supported_targets : [system_i386_win32,system_i386_nativent,system_i386_uefi];
flags : [af_outputbinary,af_smartlink_sections];
labelprefix : '.L';
comment : '';
diff --git a/uefi/compiler/systems.inc b/uefi/compiler/systems.inc
index 57bd22295f..bb4cf3c353 100644
--- a/uefi/compiler/systems.inc
+++ b/uefi/compiler/systems.inc
@@ -175,7 +175,8 @@
system_i8086_win16, { 89 }
system_i8086_embedded, { 90 }
system_arm_aros, { 91 }
- system_wasm_wasm32 { 92 }
+ system_wasm_wasm32, { 92 }
+ system_i386_uefi { 93 }
);
type
@@ -265,7 +266,8 @@
ld_int_nativent,
ld_int_netware,
ld_int_windows,
- ld_int_msdos
+ ld_int_msdos,
+ ld_int_uefi
);
tar = (ar_none
diff --git a/uefi/compiler/systems/i_uefi.pas b/uefi/compiler/systems/i_uefi.pas
new file mode 100644
index 0000000000..2da0517b1f
--- /dev/null
+++ b/uefi/compiler/systems/i_uefi.pas
@@ -0,0 +1,189 @@
+{
+ Copyright (c) 2014 by Olivier Coursière
+
+ This unit implements support information structures for uefi,
+ Based on Sven Barth's i_nativent
+ Based on Peter Vreman's i_win
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ ****************************************************************************
+}
+{ This unit implements support information structures for uefi. }
+unit i_uefi;
+
+{$i fpcdefs.inc}
+
+ interface
+
+ uses
+ systems;
+
+ const
+ system_i386_uefi_info : tsysteminfo =
+ (
+ system : system_i386_uefi;
+ name : 'UEFI for i386';
+ shortname : 'uefi';
+ flags : [tf_files_case_aware,tf_use_function_relative_addresses,tf_smartlink_library
+ ,tf_smartlink_sections{,tf_section_threadvars}{,tf_needs_dwarf_cfi},
+ tf_no_generic_stackcheck{,tf_has_winlike_resources},tf_under_development,
+ tf_dwarf_only_local_labels{,tf_pic_uses_got}];
+ cpu : cpu_i386;
+ unit_env : 'UEFIUNITS';
+ extradefines : 'UEFI,FPC_OS_UNICODE';
+ exeext : '.efi';
+ defext : '.def';
+ scriptext : '.bat';
+ smartext : '.sl';
+ unitext : '.ppu';
+ unitlibext : '.ppl';
+ asmext : '.s';
+ objext : '.o';
+ resext : '.res';
+ resobjext : '.or';
+ sharedlibext : '.efi';
+ staticlibext : '.a';
+ staticlibprefix : 'libp';
+ sharedlibprefix : '';
+ sharedClibext : '.efi';
+ staticClibext : '.a';
+ staticClibprefix : 'lib';
+ sharedClibprefix : '';
+ importlibprefix : 'libimp';
+ importlibext : '.a';
+ Cprefix : '_';
+ newline : #13#10;
+ dirsep : '\';
+ assem : as_i386_pecoff;
+ assemextern : as_gas;
+ link : ld_int_uefi;
+ linkextern : ld_none;
+ ar : ar_gnu_ar;
+ res : res_gnu_windres;
+ dbg : dbg_stabs;
+ script : script_dos;
+ endian : endian_little;
+ alignment :
+ (
+ procalign : 16;
+ loopalign : 4;
+ jumpalign : 0;
+ constalignmin : 0;
+ constalignmax : 16;
+ varalignmin : 0;
+ varalignmax : 16;
+ localalignmin : 4;
+ localalignmax : 8;
+ recordalignmin : 0;
+ recordalignmax : 4;
+ maxCrecordalign : 16
+ );
+ first_parm_offset : 8;
+ stacksize : 16*1024*1024;
+ stackalign : 16;
+ abi : abi_default;
+ { note: default LLVM stack alignment is 16 bytes for this target }
+ { TODO : check this... Took from Haiku, but should probably come from Windows ? }
+ llvmdatalayout : 'e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32-S32';
+ );
+
+(* system_x64_uefi64_info : tsysteminfo =
+ (
+ system : system_x86_64_uefi64;
+ name : 'UEFI for x86_64';
+ shortname : 'uefi64';
+ flags : [tf_files_case_aware,tf_use_function_relative_addresses,tf_smartlink_library
+ ,tf_smartlink_sections{,tf_section_threadvars}{,tf_needs_dwarf_cfi},
+ tf_no_generic_stackcheck{,tf_has_winlike_resources},tf_under_development,
+ tf_dwarf_only_local_labels{,tf_pic_uses_got}];
+ cpu : cpu_x86_64;
+ unit_env : 'UEFIUNITS';
+ extradefines : 'UEFI64,FPC_OS_UNICODE';
+ exeext : '.exe';
+ defext : '.def';
+ scriptext : '.bat';
+ smartext : '.sl';
+ unitext : '.ppu';
+ unitlibext : '.ppl';
+ asmext : '.s';
+ objext : '.o';
+ resext : '.res';
+ resobjext : '.or';
+ sharedlibext : '.efi';
+ staticlibext : '.a';
+ staticlibprefix : 'libp';
+ sharedlibprefix : '';
+ sharedClibext : '.efi';
+ staticClibext : '.a';
+ staticClibprefix : 'lib';
+ sharedClibprefix : '';
+ importlibprefix : 'libimp';
+ importlibext : '.a';
+ Cprefix : '_';
+ newline : #13#10;
+ dirsep : '\';
+ assem : as_x86_64_pecoff;
+ assemextern : as_gas;
+ link : ld_int_uefi;
+ linkextern : ld_none;
+ ar : ar_gnu_ar;
+ res : res_gnu_windres;
+ dbg : dbg_stabs;
+ script : script_dos;
+ endian : endian_little;
+ alignment :
+ (
+ procalign : 16;
+ loopalign : 8;
+ jumpalign : 0;
+ constalignmin : 0;
+ constalignmax : 16;
+ varalignmin : 0;
+ varalignmax : 16;
+ localalignmin : 8;
+ localalignmax : 16;
+ recordalignmin : 0;
+ recordalignmax : 8;
+ maxCrecordalign : 16
+ );
+ first_parm_offset : 16;
+ stacksize : 16*1024*1024;
+ stackalign : 16;
+ abi : abi_default;
+ { note: default LLVM stack alignment is 16 bytes for this target }
+ { TODO : check this... Took from Haiku, but should probably come from Windows ? }
+ llvmdatalayout : 'e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32-S32';
+ );*)
+
+ implementation
+
+initialization
+{$ifdef CPUI386}
+// WriteLn('CPUI386 defined');
+ {$ifdef UEFI}
+// WriteLn('UEFI defined');
+ set_source_info(system_i386_uefi_info);
+ {$endif UEFI}
+{$endif CPUI386}
+{$ifdef CPUX86_64}
+{ $ifdef x86_64}
+// WriteLn('CPUX86_64 defined');
+ {$ifdef UEFI64}
+// WriteLn('UEFI64 defined');
+ set_source_info(system_x64_uefi64_info);
+ {$endif UEFI}
+{$endif CPUX86_64}
+
+end.
diff --git a/uefi/compiler/systems/t_uefi.pas b/uefi/compiler/systems/t_uefi.pas
new file mode 100644
index 0000000000..b70a6f5703
--- /dev/null
+++ b/uefi/compiler/systems/t_uefi.pas
@@ -0,0 +1,104 @@
+{
+ Copyright (c) 2014 by Olivier Coursière
+
+ This unit implements support import,export,link routines
+ for the uefi Target
+ Based on Sven Barth's t_nativent
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ ****************************************************************************
+}
+unit t_uefi;
+
+{$i fpcdefs.inc}
+
+interface
+
+
+implementation
+
+ uses
+ SysUtils,
+ cutils,
+ ogbase,ogcoff,
+ globtype,globals,systems,verbose,
+ import,export,link,t_win,i_uefi;
+
+
+ type
+ TImportLibUEFI=class(TImportLibWin)
+ end;
+
+ TExportLibUEFI=class(TExportLibWin)
+ end;
+
+ TInternalLinkerUEFI = class(TInternalLinkerWin)
+ constructor create;override;
+ procedure ConcatEntryName; override;
+ end;
+
+{****************************************************************************
+ TInternalLinkerUEFI
+****************************************************************************}
+
+ constructor TInternalLinkerUEFI.create;
+ begin
+ inherited create;
+ CExeoutput:=TPECoffexeoutput;
+ CObjInput:=TPECoffObjInput;
+ end;
+
+ procedure TInternalLinkerUEFI.ConcatEntryName;
+ begin
+ with LinkScript do
+ begin
+ if IsSharedLibrary then
+ begin
+ // for now we use {$apptype native} for kernel mode code
+ if apptype=app_native then
+ Concat('ENTRYNAME EFI_MAIN')
+ else
+ Concat('ENTRYNAME EFI_MAIN')
+ end
+ else
+ Concat('ENTRYNAME PASCALMAIN');
+ end;
+ end;
+
+
+
+{*****************************************************************************
+ Initialize
+*****************************************************************************}
+
+initialization
+ RegisterLinker(ld_int_uefi,TInternalLinkerUEFI);
+{$ifdef i386}
+ { UEFI }
+// WriteLn('32 UEFI');
+ RegisterImport(system_i386_uefi,TImportLibUEFI);
+ RegisterExport(system_i386_uefi,TExportLibUEFI);
+ RegisterTarget(system_i386_uefi_info);
+{$endif i386}
+{$ifdef x86_64}
+{ $ifdef UEFI64}
+ { UEFI }
+// WriteLn('64 UEFI');
+ RegisterImport(system_x86_64_uefi64,TImportLibUEFI);
+ RegisterExport(system_x86_64_uefi64,TExportLibUEFI);
+ RegisterTarget(system_x64_uefi64_info);
+{ $endif}
+{$endif x86_64}
+end.
diff --git a/uefi/compiler/utils/ppuutils/ppudump.pp b/uefi/compiler/utils/ppuutils/ppudump.pp
index 63af98d9de..f9be8e4422 100644
--- a/uefi/compiler/utils/ppuutils/ppudump.pp
+++ b/uefi/compiler/utils/ppuutils/ppudump.pp
@@ -177,7 +177,8 @@ const
{ 89 } 'Win16',
{ 90 } 'Embedded-i8086',
{ 91 } 'AROS-arm',
- { 92 } 'WebAssembly-wasm'
+ { 92 } 'WebAssembly-wasm',
+ { 93 } 'UEFI-i386'
);
const