diff --git a/.gitattributes b/.gitattributes index 29c23a91c8..5e6773b19d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -8206,6 +8206,7 @@ rtl/embedded/arm/stm32f10x_md.pp svneol=native#text/pascal rtl/embedded/arm/stm32f10x_xl.pp svneol=native#text/pascal rtl/embedded/arm/xmc4500.pp svneol=native#text/pascal rtl/embedded/avr/atmega128.pp svneol=native#text/plain +rtl/embedded/avr/avrsim.pp svneol=native#text/plain rtl/embedded/avr/start.inc svneol=native#text/plain rtl/embedded/buildrtl.lpi svneol=native#text/plain rtl/embedded/buildrtl.pp svneol=native#text/plain diff --git a/compiler/avr/cpuinfo.pas b/compiler/avr/cpuinfo.pas index eec89b73a2..8d17884ce9 100644 --- a/compiler/avr/cpuinfo.pas +++ b/compiler/avr/cpuinfo.pas @@ -56,6 +56,8 @@ Type tcontrollertype = (ct_none, + ct_avrsim, + ct_atmega16, ct_atmega32, ct_atmega48, @@ -120,6 +122,16 @@ Const eeprombase:0; eepromsize:0 ), + ( + controllertypestr:'AVRSIM'; + controllerunitstr:'AVRSIM'; + flashbase:0; + flashsize:$20000; + srambase:0; + sramsize:4096; + eeprombase:0; + eepromsize:4096; + ), ( controllertypestr:'ATMEGA16'; controllerunitstr:'ATMEGA16'; diff --git a/rtl/embedded/Makefile b/rtl/embedded/Makefile index 58484fb1b4..038cadce91 100644 --- a/rtl/embedded/Makefile +++ b/rtl/embedded/Makefile @@ -369,7 +369,7 @@ CPU_UNITS=allwinner_a20 endif endif ifeq ($(ARCH),avr) -CPU_UNITS=atmega128 +CPU_UNITS=atmega128 avrsim endif ifeq ($(ARCH),i386) CPU_SPECIFIC_COMMON_UNITS=sysutils math classes fgl macpas typinfo types rtlconsts diff --git a/rtl/embedded/Makefile.fpc b/rtl/embedded/Makefile.fpc index a3bc844b3d..d6a5ee6974 100644 --- a/rtl/embedded/Makefile.fpc +++ b/rtl/embedded/Makefile.fpc @@ -84,7 +84,7 @@ endif endif ifeq ($(ARCH),avr) -CPU_UNITS=atmega128 +CPU_UNITS=atmega128 avrsim endif ifeq ($(ARCH),i386) diff --git a/rtl/embedded/avr/avrsim.pp b/rtl/embedded/avr/avrsim.pp new file mode 100644 index 0000000000..5fc4a241e2 --- /dev/null +++ b/rtl/embedded/avr/avrsim.pp @@ -0,0 +1,57 @@ +{****************************************************************************** +Startup code for an avr simulator + +******************************************************************************} +unit avrsim; + +{$goto on} +{$macro on} + + interface + var + OUTPUTREG : byte absolute $20; + EXITCODEREG : byte absolute $21; + HALTREQUEST : byte absolute $22; + + {$define DOCALL:=call} + {$define DOJMP:=jmp} + + implementation + + procedure PASCALMAIN; external name 'PASCALMAIN'; + + procedure _FPC_haltproc(exitcode : longint); public name '_haltproc'; noreturn; + + begin + EXITCODEREG:=exitcode; + HALTREQUEST:=1; + { really stop } + while true do + ; + end; + + var + _data: record end; external name '__data_start'; + _edata: record end; external name '__data_end'; + _etext: record end; external name '_etext'; + _bss_start: record end; external name '__bss_start'; + _bss_end: record end; external name '__bss_end'; + _stack_top: record end; external name '_stack_top'; + + procedure _FPC_start; assembler; nostackframe; + label + _start; + asm + .init + .globl _start + jmp _start + + { + all ATMEL MCUs use the same startup code, the details are + governed by defines + } + {$i start.inc} + end; + +end. +