+ basic system unit for avr-embedded

* fixed several compiler stuff to be able to start system unit compilation on avr

git-svn-id: trunk@10318 -
This commit is contained in:
florian 2008-02-13 20:35:16 +00:00
parent 8aa80c8262
commit c05d4912f4
18 changed files with 297 additions and 21 deletions

7
.gitattributes vendored
View File

@ -4731,6 +4731,13 @@ rtl/atari/prt0.as svneol=native#text/plain
rtl/atari/readme -text
rtl/atari/sysatari.pas svneol=native#text/plain
rtl/atari/system.pas svneol=native#text/plain
rtl/avr/avr.inc svneol=native#text/plain
rtl/avr/int64p.inc svneol=native#text/plain
rtl/avr/makefile.cpu svneol=native#text/plain
rtl/avr/math.inc svneol=native#text/plain
rtl/avr/set.inc svneol=native#text/plain
rtl/avr/setjump.inc svneol=native#text/plain
rtl/avr/setjumph.inc svneol=native#text/plain
rtl/beos/Makefile svneol=native#text/plain
rtl/beos/Makefile.fpc svneol=native#text/plain
rtl/beos/baseunix.pp svneol=native#text/plain

View File

@ -46,7 +46,7 @@ Const
{# Size of a multimedia register }
mmreg_size = 16;
{ target cpu string (used by compiler options) }
target_cpu_string = 'arm';
target_cpu_string = 'avr';
{ calling conventions supported by the code generator }
supported_calling_conventions : tproccalloptions = [

View File

@ -2270,6 +2270,15 @@ begin
def_system_macro('FPC_CURRENCY_IS_INT64');
def_system_macro('FPC_COMP_IS_INT64');
{$endif arm}
{$ifdef avr}
def_system_macro('CPUAVR');
def_system_macro('CPU16');
def_system_macro('FPC_HAS_TYPE_DOUBLE');
def_system_macro('FPC_HAS_TYPE_SINGLE');
def_system_macro('FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE');
def_system_macro('FPC_CURRENCY_IS_INT64');
def_system_macro('FPC_COMP_IS_INT64');
{$endif avr}
{ read configuration file }
if (not disable_configfile) and

View File

@ -191,17 +191,30 @@ implementation
s80floattype:=tfloatdef.create(s80real);
s64currencytype:=torddef.create(scurrency,low(int64),high(int64));
{$endif arm}
{$ifdef avr}
s32floattype:=tfloatdef.create(s32real);
s64floattype:=tfloatdef.create(s64real);
s80floattype:=tfloatdef.create(s80real);
s64currencytype:=torddef.create(scurrency,low(int64),high(int64));
{$endif avr}
{$ifdef cpu64bit}
uinttype:=u64inttype;
sinttype:=s64inttype;
ptruinttype:=u64inttype;
ptrsinttype:=s64inttype;
{$else cpu64bit}
{$endif cpu64bit}
{$ifdef cpu32bit}
uinttype:=u32inttype;
sinttype:=s32inttype;
ptruinttype:=u32inttype;
ptrsinttype:=s32inttype;
{$endif cpu64bit}
{$endif cpu32bit}
{$ifdef cpu16bit}
uinttype:=u16inttype;
sinttype:=s16inttype;
ptruinttype:=u16inttype;
ptrsinttype:=s16inttype;
{$endif cpu16bit}
{ some other definitions }
voidpointertype:=tpointerdef.create(voidtype);
charpointertype:=tpointerdef.create(cchartype);

View File

@ -51,7 +51,8 @@ interface
cpu_x86_64, { 8 }
cpu_mips, { 9 }
cpu_arm, { 10 }
cpu_powerpc64 { 11 }
cpu_powerpc64, { 11 }
cpu_avr { 12 }
);
tasmmode= (asmmode_none
@ -141,7 +142,8 @@ interface
system_powerpc64_embedded, { 58 }
system_i386_symbian, { 59 }
system_arm_symbian, { 60 }
system_x86_64_darwin { 61 }
system_x86_64_darwin, { 61 }
system_avr_embedded { 62 }
);
type
@ -410,7 +412,7 @@ interface
cpu2str : array[TSystemCpu] of string[10] =
('','i386','m68k','alpha','powerpc','sparc','vm','ia64','x86_64',
'mips','arm', 'powerpc64');
'mips','arm', 'powerpc64', 'avr');
abi2str : array[tabi] of string[10] =
('default','sysv','aix','eabi','armeb');
@ -923,6 +925,10 @@ begin
{$endif WINDOWS}
{$endif cpuarm}
{$endif arm}
{$ifdef avr}
default_target(system_avr_embedded);
{$endif avr}
end;

View File

@ -86,12 +86,77 @@ unit i_embed;
abi : abi_default
);
system_avr_embedded_info : tsysteminfo =
(
system : system_avr_embedded;
name : 'Embedded';
shortname : 'embedded';
flags : [tf_needs_symbol_size,tf_files_case_sensitive,tf_use_function_relative_addresses
,tf_smartlink_sections];
cpu : cpu_avr;
unit_env : '';
extradefines : '';
exeext : '';
defext : '.def';
scriptext : '.sh';
smartext : '.sl';
unitext : '.ppu';
unitlibext : '.ppl';
asmext : '.s';
objext : '.o';
resext : '.res';
resobjext : '.or';
sharedlibext : '.so';
staticlibext : '.a';
staticlibprefix : 'libp';
sharedlibprefix : 'lib';
sharedClibext : '.so';
staticClibext : '.a';
staticClibprefix : 'lib';
sharedClibprefix : 'lib';
Cprefix : '';
newline : #10;
dirsep : '/';
assem : as_gas;
assemextern : as_gas;
link : nil;
linkextern : nil;
ar : ar_gnu_ar;
res : res_none;
dbg : dbg_stabs;
script : script_unix;
endian : endian_little;
alignment :
(
procalign : 4;
loopalign : 4;
jumpalign : 0;
constalignmin : 0;
constalignmax : 4;
varalignmin : 0;
varalignmax : 4;
localalignmin : 4;
localalignmax : 8;
recordalignmin : 0;
recordalignmax : 4;
maxCrecordalign : 4
);
first_parm_offset : 0;
stacksize : 1024;
abi : abi_default
);
implementation
initialization
{$ifdef arm}
{$ifdef CPUARM}
{$ifdef embedded}
set_source_info(system_arm_embedded_info);
{$endif embedded}
{$endif arm}
{$endif CPUARM}
{$ifdef CPUAVR}
{$ifdef embedded}
set_source_info(system_avr_embedded_info);
{$endif embedded}
{$endif CPUAVR}
end.

View File

@ -284,6 +284,13 @@ end;
*****************************************************************************}
initialization
{$ifdef arm}
RegisterExternalLinker(system_arm_embedded_info,TlinkerEmbedded);
RegisterTarget(system_arm_embedded_info);
{$endif arm}
{$ifdef avr}
RegisterExternalLinker(system_avr_embedded_info,TlinkerEmbedded);
RegisterTarget(system_avr_embedded_info);
{$endif avr}
end.

23
rtl/avr/avr.inc Normal file
View File

@ -0,0 +1,23 @@
{
This file is part of the Free Pascal run time library.
Copyright (c) 2008 by the Free Pascal development team.
Processor dependent implementation for the system unit for
AVR
See the file COPYING.FPC, included in this distribution,
for details about the copyright.
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.
**********************************************************************}
{$asmmode gas}
procedure fpc_cpuinit;
begin
SysInitFPU;
end;

14
rtl/avr/int64p.inc Normal file
View File

@ -0,0 +1,14 @@
{
This file is part of the Free Pascal run time library.
Copyright (c) 2008 by the Free Pascal development team
This file contains some helper routines for int64 and qword
See the file COPYING.FPC, included in this distribution,
for details about the copyright.
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.
**********************************************************************}

6
rtl/avr/makefile.cpu Normal file
View File

@ -0,0 +1,6 @@
#
# Here we set processor dependent include file names.
#
CPUNAMES=
CPUINCNAMES=$(addsuffix .inc,$(CPUNAMES))

15
rtl/avr/math.inc Normal file
View File

@ -0,0 +1,15 @@
{
This file is part of the Free Pascal run time library.
Copyright (c) 2008 by the Free Pascal development team.
Implementation of mathematical Routines (only for real)
See the file COPYING.FPC, included in this distribution,
for details about the copyright.
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.
**********************************************************************}

15
rtl/avr/set.inc Normal file
View File

@ -0,0 +1,15 @@
{
This file is part of the Free Pascal run time library.
Copyright (c) 2008 by the Free Pascal development team.
Include file with set operations called by the compiler
See the file COPYING.FPC, included in this distribution,
for details about the copyright.
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.
**********************************************************************}

26
rtl/avr/setjump.inc Normal file
View File

@ -0,0 +1,26 @@
{
This file is part of the Free Pascal run time library.
Copyright (c) 2008 by the Free Pascal development team.
SetJmp and LongJmp implementation for exception handling
See the file COPYING.FPC, included in this distribution,
for details about the copyright.
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.
**********************************************************************}
function setjmp(var S : jmp_buf) : longint;assembler;[Public, alias : 'FPC_SETJMP'];nostackframe;
asm
end;
procedure longjmp(var S : jmp_buf;value : longint);assembler;[Public, alias : 'FPC_LONGJMP'];
asm
end;

25
rtl/avr/setjumph.inc Normal file
View File

@ -0,0 +1,25 @@
{
This file is part of the Free Pascal run time library.
Copyright (c) 2008 by the Free Pascal development team.
SetJmp/Longjmp declarations
See the file COPYING.FPC, included in this distribution,
for details about the copyright.
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.
**********************************************************************}
type
jmp_buf = packed record
end;
pjmp_buf = ^jmp_buf;
function setjmp(var S : jmp_buf) : longint;
procedure longjmp(var S : jmp_buf;value : longint);

View File

@ -1,8 +1,8 @@
#
# Don't edit, this file is generated by FPCMake Version 2.0.0 [2007/11/08]
# Don't edit, this file is generated by FPCMake Version 2.0.0 [2008/02/12]
#
default: all
MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded
MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded
BSDs = freebsd netbsd openbsd darwin
UNIXs = linux $(BSDs) solaris qnx
LIMIT83fs = go32v2 os2 emx watcom
@ -249,8 +249,7 @@ COMMON=$(RTL)/common
PROCINC=$(RTL)/$(CPU_TARGET)
UNITPREFIX=rtl
SYSTEMUNIT=system
override FPCOPT+=
rtl.cfg
override FPCOPT+=@rtl.cfg
ifdef RELEASE
override FPCOPT+=-Ur
endif
@ -415,6 +414,9 @@ endif
ifeq ($(FULL_TARGET),powerpc64-embedded)
override TARGET_UNITS+=$(SYSTEMUNIT) # objpas macpas strings
endif
ifeq ($(FULL_TARGET),avr-embedded)
override TARGET_UNITS+=$(SYSTEMUNIT) # objpas macpas strings
endif
override INSTALL_FPCPACKAGE=y
ifeq ($(FULL_TARGET),i386-linux)
override COMPILER_INCLUDEDIR+=$(INC) $(PROCINC)
@ -575,6 +577,9 @@ endif
ifeq ($(FULL_TARGET),powerpc64-embedded)
override COMPILER_INCLUDEDIR+=$(INC) $(PROCINC)
endif
ifeq ($(FULL_TARGET),avr-embedded)
override COMPILER_INCLUDEDIR+=$(INC) $(PROCINC)
endif
ifeq ($(FULL_TARGET),i386-linux)
override COMPILER_SOURCEDIR+=$(INC) $(PROCINC) $(COMMON)
endif
@ -734,6 +739,9 @@ endif
ifeq ($(FULL_TARGET),powerpc64-embedded)
override COMPILER_SOURCEDIR+=$(INC) $(PROCINC) $(COMMON)
endif
ifeq ($(FULL_TARGET),avr-embedded)
override COMPILER_SOURCEDIR+=$(INC) $(PROCINC) $(COMMON)
endif
ifdef REQUIRE_UNITSDIR
override UNITSDIR+=$(REQUIRE_UNITSDIR)
endif
@ -1635,7 +1643,7 @@ endif
endif
endif
.PHONY: fpc_units
ifneq ($(TARGET_UNITS),)
ifneq ($(TARGET_UNITS)$(TARGET_IMPLICITUNITS),)
override ALLTARGET+=fpc_units
override UNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_UNITS))
override IMPLICITUNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_IMPLICITUNITS))

View File

@ -39,8 +39,7 @@ COMMON=$(RTL)/common
PROCINC=$(RTL)/$(CPU_TARGET)
UNITPREFIX=rtl
SYSTEMUNIT=system
override FPCOPT+=
rtl.cfg
override FPCOPT+=@rtl.cfg
ifdef RELEASE
override FPCOPT+=-Ur

View File

@ -25,13 +25,15 @@
{$i filerec.inc}
{$i textrec.inc}
{$ifdef FPC_OBJFPC_EXTENDED_IF}
{$if High(errorcode)<>maxExitCode}
{$ifdef FPC_HAS_FEATURE_EXITCODE}
{$ifdef FPC_OBJFPC_EXTENDED_IF}
{$if High(errorcode)<>maxExitCode}
{$define FPC_LIMITED_EXITCODE}
{$endif}
{$else}
{$define FPC_LIMITED_EXITCODE}
{$endif}
{$else}
{$define FPC_LIMITED_EXITCODE}
{$endif FPC_OBJFPC_EXTENDED_IF}
{$endif FPC_OBJFPC_EXTENDED_IF}
{$endif FPC_HAS_FEATURE_EXITCODE}
Procedure HandleError (Errno : Longint); forward;
Procedure HandleErrorFrame (Errno : longint;frame : Pointer); forward;
@ -174,6 +176,14 @@ function do_isdevice(handle:thandle):boolean;forward;
{$define SYSPROCDEFINED}
{$endif cpuarm}
{$ifdef cpuavr}
{$ifdef SYSPROCDEFINED}
{$Error Can't determine processor type !}
{$endif}
{$i avr.inc} { Case dependent, don't change }
{$define SYSPROCDEFINED}
{$endif cpuavr}
procedure fillchar(var x;count : SizeInt;value : boolean);{$ifdef SYSTEMINLINE}inline;{$endif}
begin

View File

@ -195,6 +195,25 @@ Type
FarPointer = Pointer;
{$endif CPUARM}
{$ifdef CPUAVR}
{$define DEFAULT_SINGLE}
{$define SUPPORT_SINGLE}
{$define SUPPORT_DOUBLE}
{$define FPC_INCLUDE_SOFTWARE_MOD_DIV}
{$define FPC_INCLUDE_SOFTWARE_SHIFT_INT64}
{$define FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE}
ValReal = Real;
{ map comp to int64, but this doesn't mean we compile the comp support in! }
Comp = Int64;
PComp = ^Comp;
FarPointer = Pointer;
{$endif CPUARM}
{$ifdef CPU64}
SizeInt = Int64;
SizeUInt = QWord;
@ -213,6 +232,15 @@ Type
ValUInt = Cardinal;
{$endif CPU32}
{$ifdef CPU16}
SizeInt = Integer;
SizeUInt = Word;
PtrInt = Integer;
PtrUInt = Word;
ValSInt = Integer;
ValUInt = Word;
{$endif CPU16}
{ Zero - terminated strings }
PChar = ^Char;
PPChar = ^PChar;