+ initial FreeRTOS RTL support, largely based on the Embedded target, limited to Xtensa so far

git-svn-id: trunk@44400 -
This commit is contained in:
florian 2020-03-29 17:13:45 +00:00
parent f6b6622569
commit 391512546e
32 changed files with 8343 additions and 10 deletions

21
.gitattributes vendored
View File

@ -832,6 +832,7 @@ compiler/systems/i_beos.pas svneol=native#text/plain
compiler/systems/i_bsd.pas svneol=native#text/plain
compiler/systems/i_embed.pas svneol=native#text/plain
compiler/systems/i_emx.pas svneol=native#text/plain
compiler/systems/i_freertos.pas svneol=native#text/pascal
compiler/systems/i_gba.pas svneol=native#text/plain
compiler/systems/i_go32v2.pas svneol=native#text/plain
compiler/systems/i_haiku.pas svneol=native#text/plain
@ -863,6 +864,7 @@ compiler/systems/t_beos.pas svneol=native#text/plain
compiler/systems/t_bsd.pas svneol=native#text/plain
compiler/systems/t_embed.pas svneol=native#text/plain
compiler/systems/t_emx.pas svneol=native#text/plain
compiler/systems/t_freertos.pas svneol=native#text/pascal
compiler/systems/t_gba.pas svneol=native#text/plain
compiler/systems/t_go32v2.pas svneol=native#text/plain
compiler/systems/t_haiku.pas svneol=native#text/plain
@ -10680,6 +10682,25 @@ rtl/freebsd/x86_64/prt0.as svneol=native#text/plain
rtl/freebsd/x86_64/reloc.inc svneol=native#text/plain
rtl/freebsd/x86_64/si_c.inc svneol=native#text/plain
rtl/freebsd/x86_64/sighnd.inc svneol=native#text/plain
rtl/freertos/Makefile svneol=native#text/plain
rtl/freertos/Makefile.fpc svneol=native#text/plain
rtl/freertos/check.inc svneol=native#text/plain
rtl/freertos/classes.pp svneol=native#text/pascal
rtl/freertos/consoleio.pp svneol=native#text/pascal
rtl/freertos/dos.pp svneol=native#text/pascal
rtl/freertos/heapmgr.pp svneol=native#text/pascal
rtl/freertos/rtldefs.inc svneol=native#text/plain
rtl/freertos/sysdir.inc svneol=native#text/plain
rtl/freertos/sysfile.inc svneol=native#text/plain
rtl/freertos/sysheap.inc svneol=native#text/plain
rtl/freertos/sysos.inc svneol=native#text/plain
rtl/freertos/sysosh.inc svneol=native#text/plain
rtl/freertos/system.cfg svneol=native#text/plain
rtl/freertos/system.pp svneol=native#text/pascal
rtl/freertos/systhrd.inc svneol=native#text/plain
rtl/freertos/sysutils.pp svneol=native#text/pascal
rtl/freertos/tthread.inc svneol=native#text/plain
rtl/freertos/xtensa/esp32.pp svneol=native#text/pascal
rtl/gba/Makefile svneol=native#text/plain
rtl/gba/Makefile.fpc svneol=native#text/plain
rtl/gba/classes.pp svneol=native#text/plain

View File

@ -1547,7 +1547,7 @@ implementation
tcb.free;
{ allocate an initial heap on embedded systems }
if target_info.system in systems_embedded then
if target_info.system in (systems_embedded+systems_freertos) then
begin
{ tai_datablock cannot yet be handled via the high level typed const
builder, because it implies the generation of a symbol, while this

View File

@ -2538,7 +2538,7 @@ begin
begin
{$push}
{$warn 6018 off} { Unreachable code due to compile time evaluation }
if (target_info.system in systems_embedded) and
if ((target_info.system in systems_embedded) or (target_info.system in systems_freertos)) and
ControllerSupport then
begin
s:=upper(copy(more,j+1,length(more)-j));
@ -4634,7 +4634,7 @@ begin
{$push}
{$warn 6018 off} { Unreachable code due to compile time evaluation }
if ControllerSupport and (target_info.system in systems_embedded) and
if ControllerSupport and (target_info.system in (systems_embedded+systems_freertos)) and
(init_settings.controllertype<>ct_none) then
begin
with embedded_controllers[init_settings.controllertype] do

View File

@ -408,7 +408,7 @@ implementation
{$push}
{$warn 6018 off} { Unreachable code due to compile time evaluation }
{ CPU targets with microcontroller support can add a controller specific unit }
if ControllerSupport and (target_info.system in systems_embedded) and
if ControllerSupport and (target_info.system in (systems_embedded+systems_freertos)) and
(current_settings.controllertype<>ct_none) and
(embedded_controllers[current_settings.controllertype].controllerunitstr<>'') then
AddUnit(embedded_controllers[current_settings.controllertype].controllerunitstr);

View File

@ -191,7 +191,8 @@
system_aarch64_android, { 100 }
system_x86_64_android, { 101 }
system_x86_64_haiku, { 102 }
system_xtensa_embedded { 103 }
system_xtensa_embedded, { 103 }
system_xtensa_freertos { 104 }
);
type
@ -284,7 +285,8 @@
ld_int_netware,
ld_int_windows,
ld_int_msdos,
ld_int_win16
ld_int_win16,
ld_freertos
);
tar = (ar_none

View File

@ -301,6 +301,9 @@ interface
system_i8086_embedded,system_riscv32_embedded,system_riscv64_embedded,
system_xtensa_embedded];
{ all FreeRTOS systems }
systems_freertos = [system_xtensa_freertos];
{ all systems that allow section directive }
systems_allow_section = systems_embedded;

View File

@ -0,0 +1,775 @@
{
This unit implements support information structures for the FPC FreeRTOS target
Copyright (c) 1998-2006 by Peter Vreman
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 i_freertos;
{$i fpcdefs.inc}
{$ifdef go32v2}
{ As wlib uses a different Dos-Extender, long-command line
encoding for DJGPP does not work here.
Put all inside a script file instead }
{$define USE_SCRIPTED_WLIB}
{$endif}
interface
uses
systems;
const
{$ifdef dummy}
system_arm_embedded_info : tsysteminfo =
(
system : system_arm_embedded;
name : 'Embedded';
shortname : 'embedded';
flags : [tf_needs_symbol_size,tf_files_case_sensitive,tf_requires_proper_alignment,
tf_smartlink_sections,tf_init_final_units_by_calls];
cpu : cpu_arm;
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';
importlibprefix : 'libimp';
importlibext : '.a';
Cprefix : '';
newline : #10;
dirsep : '/';
assem : as_gas;
assemextern : as_gas;
link : ld_none;
linkextern : ld_embedded;
ar : ar_gnu_ar;
res : res_none;
dbg : dbg_dwarf2;
script : script_unix;
endian : endian_little;
alignment :
(
procalign : 4;
loopalign : 4;
jumpalign : 0;
jumpalignskipmax : 0;
coalescealign : 0;
coalescealignskipmax: 0;
constalignmin : 0;
constalignmax : 4;
varalignmin : 0;
varalignmax : 4;
localalignmin : 4;
localalignmax : 4;
recordalignmin : 0;
recordalignmax : 4;
maxCrecordalign : 4
);
first_parm_offset : 8;
stacksize : 262144;
stackalign : 4;
abi : abi_default;
llvmdatalayout : 'e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:64:128-a0:0:64-n32-S32';
);
system_avr_embedded_info : tsysteminfo =
(
system : system_avr_embedded;
name : 'Embedded';
shortname : 'embedded';
flags : [tf_needs_symbol_size,tf_files_case_sensitive,
tf_smartlink_sections,tf_init_final_units_by_calls];
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';
importlibprefix : 'libimp';
importlibext : '.a';
Cprefix : '';
newline : #10;
dirsep : '/';
assem : as_gas;
assemextern : as_gas;
link : ld_none;
linkextern : ld_embedded;
ar : ar_gnu_ar;
res : res_none;
dbg : dbg_dwarf3;
script : script_unix;
endian : endian_little;
alignment :
(
procalign : 1;
loopalign : 1;
jumpalign : 0;
jumpalignskipmax : 0;
coalescealign : 0;
coalescealignskipmax: 0;
constalignmin : 0;
constalignmax : 1;
varalignmin : 0;
varalignmax : 1;
localalignmin : 0;
localalignmax : 1;
recordalignmin : 0;
recordalignmax : 1;
maxCrecordalign : 1
);
first_parm_offset : 0;
stacksize : 1024;
stackalign : 1;
abi : abi_default;
llvmdatalayout : 'todo';
);
system_mipsel_embedded_info : tsysteminfo =
(
system : system_mipsel_embedded;
name : 'Embedded';
shortname : 'embedded';
flags : [tf_needs_symbol_size,tf_needs_symbol_type,tf_files_case_sensitive,
tf_smartlink_sections];
cpu : cpu_mipsel;
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';
importlibprefix : 'libimp';
importlibext : '.a';
Cprefix : '';
newline : #10;
dirsep : '/';
assem : as_gas;
assemextern : as_gas;
link : ld_none;
linkextern : ld_embedded;
ar : ar_gnu_ar;
res : res_none;
dbg : dbg_dwarf2;
script : script_unix;
endian : endian_little;
alignment :
(
procalign : 4;
loopalign : 4;
jumpalign : 0;
jumpalignskipmax : 0;
coalescealign : 0;
coalescealignskipmax: 0;
constalignmin : 0;
constalignmax : 4;
varalignmin : 0;
varalignmax : 4;
localalignmin : 4;
localalignmax : 8;
recordalignmin : 0;
recordalignmax : 8;
maxCrecordalign : 4
);
first_parm_offset : 0;
stacksize : 262144;
stackalign : 8;
abi : abi_default;
llvmdatalayout : 'todo';
);
system_i386_embedded_info : tsysteminfo =
(
system : system_i386_embedded;
name : 'Embedded';
shortname : 'embedded';
flags : [tf_needs_symbol_size,tf_files_case_sensitive,
tf_smartlink_sections];
cpu : cpu_i386;
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';
importlibprefix : 'libimp';
importlibext : '.a';
Cprefix : '';
newline : #10;
dirsep : '/';
assem : as_i386_elf32;
assemextern : as_gas;
link : ld_none;
linkextern : ld_embedded;
ar : ar_gnu_ar;
res : res_none;
dbg : dbg_stabs;
script : script_unix;
endian : endian_little;
alignment :
(
procalign : 16;
loopalign : 4;
jumpalign : 0;
jumpalignskipmax : 0;
coalescealign : 0;
coalescealignskipmax: 0;
constalignmin : 0;
constalignmax : 16;
varalignmin : 0;
varalignmax : 16;
localalignmin : 4;
localalignmax : 8;
recordalignmin : 0;
recordalignmax : 16;
maxCrecordalign : 4
);
first_parm_offset : 8;
stacksize : 4096;
stackalign : 4;
abi : abi_default;
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_x86_64_embedded_info : tsysteminfo =
(
system : system_x86_64_embedded;
name : 'Embedded';
shortname : 'embedded';
flags : [tf_needs_symbol_size,tf_files_case_sensitive,
tf_smartlink_sections];
cpu : cpu_x86_64;
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';
importlibprefix : 'libimp';
importlibext : '.a';
Cprefix : '';
newline : #10;
dirsep : '/';
assem : as_x86_64_elf64;
assemextern : as_gas;
link : ld_none;
linkextern : ld_embedded;
ar : ar_gnu_ar;
res : res_none;
dbg : dbg_stabs;
script : script_unix;
endian : endian_little;
alignment :
(
procalign : 16;
loopalign : 8;
jumpalign : 0;
jumpalignskipmax : 0;
coalescealign : 0;
coalescealignskipmax: 0;
constalignmin : 0;
constalignmax : 16;
varalignmin : 0;
varalignmax : 16;
localalignmin : 4;
localalignmax : 16;
recordalignmin : 0;
recordalignmax : 16;
maxCrecordalign : 16
);
first_parm_offset : 16;
stacksize : 8*1024*1024;
stackalign : 16;
abi : abi_default;
llvmdatalayout : 'e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128';
);
system_i8086_embedded_info : tsysteminfo =
(
system : system_i8086_embedded;
name : 'Embedded';
shortname : 'embedded';
flags : [tf_use_8_3,
{$ifdef I8086_SMARTLINK_SECTIONS}
tf_smartlink_sections,
{$else I8086_SMARTLINK_SECTIONS}
tf_smartlink_library,
tf_no_objectfiles_when_smartlinking,
{$endif I8086_SMARTLINK_SECTIONS}
tf_cld,
tf_no_generic_stackcheck,tf_emit_stklen];
cpu : cpu_i8086;
unit_env : '';
extradefines : '';
exeext : '.exe';
defext : '.def';
scriptext : '.bat';
smartext : '.sl';
unitext : '.ppu';
unitlibext : '.ppl';
asmext : '.s';
objext : '.o';
resext : '.res';
resobjext : '.or';
sharedlibext : '.dll';
staticlibext : '.a';
staticlibprefix : '';
sharedlibprefix : '';
sharedClibext : '.dll';
staticClibext : '.a';
staticClibprefix : 'lib';
sharedClibprefix : '';
importlibprefix : '';
importlibext : '.al';
Cprefix : '_';
newline : #13#10;
dirsep : '\';
assem : as_i8086_omf;
assemextern : as_i8086_nasmobj;
link : ld_int_msdos;
linkextern : ld_msdos;
{$ifdef USE_SCRIPTED_WLIB}
ar : ar_watcom_wlib_omf_scripted;
{$else}
ar : ar_watcom_wlib_omf;
{$endif}
res : res_none;
dbg : dbg_dwarf2;
script : script_dos;
endian : endian_little;
alignment :
(
procalign : 1;
loopalign : 1;
jumpalign : 0;
jumpalignskipmax : 0;
coalescealign : 0;
coalescealignskipmax: 0;
constalignmin : 0;
constalignmax : 2;
varalignmin : 0;
varalignmax : 2;
localalignmin : 0;
localalignmax : 2;
recordalignmin : 0;
recordalignmax : 2;
maxCrecordalign : 2
);
first_parm_offset : 4;
stacksize : 0;
stackalign : 2;
abi : abi_default;
llvmdatalayout : 'todo';
);
system_m68k_embedded_info : tsysteminfo =
(
system : system_m68k_embedded;
name : 'Embedded';
shortname : 'embedded';
flags : [tf_under_development,tf_needs_symbol_size,tf_files_case_sensitive,tf_requires_proper_alignment,
tf_smartlink_sections];
cpu : cpu_m68k;
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';
importlibprefix : 'libimp';
importlibext : '.a';
Cprefix : '';
newline : #10;
dirsep : '/';
assem : as_gas;
assemextern : as_gas;
link : ld_none;
linkextern : ld_embedded;
ar : ar_gnu_ar;
res : res_none;
dbg : dbg_dwarf2;
script : script_unix;
endian : endian_big;
alignment :
(
procalign : 4;
loopalign : 4;
jumpalign : 0;
jumpalignskipmax : 0;
coalescealign : 0;
coalescealignskipmax: 0;
constalignmin : 0;
constalignmax : 4;
varalignmin : 0;
varalignmax : 4;
localalignmin : 4;
localalignmax : 4;
recordalignmin : 0;
recordalignmax : 4;
maxCrecordalign : 4
);
first_parm_offset : 8;
stacksize : 32768;
stackalign : 4;
abi : abi_default;
llvmdatalayout : 'TODO';
);
system_riscv32_embedded_info : tsysteminfo =
(
system : system_riscv32_embedded;
name : 'Embedded';
shortname : 'embedded';
flags : [tf_needs_symbol_size,tf_files_case_sensitive,tf_requires_proper_alignment,
tf_smartlink_sections];
cpu : cpu_riscv32;
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';
importlibprefix : 'libimp';
importlibext : '.a';
Cprefix : '';
newline : #10;
dirsep : '/';
assem : as_gas;
assemextern : as_gas;
link : ld_none;
linkextern : ld_embedded;
ar : ar_gnu_ar;
res : res_none;
dbg : dbg_dwarf2;
script : script_unix;
endian : endian_little;
alignment :
(
procalign : 4;
loopalign : 4;
jumpalign : 0;
jumpalignskipmax : 0;
coalescealign : 0;
coalescealignskipmax: 0;
constalignmin : 0;
constalignmax : 4;
varalignmin : 0;
varalignmax : 4;
localalignmin : 4;
localalignmax : 4;
recordalignmin : 0;
recordalignmax : 4;
maxCrecordalign : 4
);
first_parm_offset : 8;
stacksize : 262144;
stackalign : 4;
abi : abi_default;
llvmdatalayout : 'e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:64:128-a0:0:64-n32-S32';
);
system_riscv64_embedded_info : tsysteminfo =
(
system : system_riscv64_embedded;
name : 'Embedded';
shortname : 'embedded';
flags : [tf_needs_symbol_size,tf_files_case_sensitive,tf_requires_proper_alignment,
tf_smartlink_sections];
cpu : cpu_riscv64;
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';
importlibprefix : 'libimp';
importlibext : '.a';
Cprefix : '';
newline : #10;
dirsep : '/';
assem : as_gas;
assemextern : as_gas;
link : ld_none;
linkextern : ld_embedded;
ar : ar_gnu_ar;
res : res_none;
dbg : dbg_dwarf2;
script : script_unix;
endian : endian_little;
alignment :
(
procalign : 4;
loopalign : 4;
jumpalign : 0;
jumpalignskipmax : 0;
coalescealign : 0;
coalescealignskipmax: 0;
constalignmin : 0;
constalignmax : 4;
varalignmin : 0;
varalignmax : 4;
localalignmin : 4;
localalignmax : 4;
recordalignmin : 0;
recordalignmax : 4;
maxCrecordalign : 4
);
first_parm_offset : 16;
stacksize : 262144;
stackalign : 8;
abi : abi_default;
llvmdatalayout : 'e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:64:128-a0:0:64-n32-S32';
);
{$endif dummy}
system_xtensa_freertos_info : tsysteminfo =
(
system : system_xtensa_freertos;
name : 'FreeRTOS';
shortname : 'freertos';
flags : [tf_needs_symbol_size,tf_files_case_sensitive,tf_requires_proper_alignment,
tf_smartlink_sections,tf_init_final_units_by_calls];
cpu : cpu_xtensa;
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';
importlibprefix : 'libimp';
importlibext : '.a';
Cprefix : '';
newline : #10;
dirsep : '/';
assem : as_gas;
assemextern : as_gas;
link : ld_none;
linkextern : ld_freertos;
ar : ar_gnu_ar;
res : res_none;
dbg : dbg_dwarf2;
script : script_unix;
endian : endian_little;
alignment :
(
procalign : 4;
loopalign : 4;
jumpalign : 0;
jumpalignskipmax : 0;
coalescealign : 0;
coalescealignskipmax: 0;
constalignmin : 0;
constalignmax : 4;
varalignmin : 0;
varalignmax : 4;
localalignmin : 4;
localalignmax : 16;
recordalignmin : 0;
recordalignmax : 4;
maxCrecordalign : 4
);
first_parm_offset : 8;
stacksize : 65536;
stackalign : 16;
abi : abi_default;
llvmdatalayout : 'e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:64:128-a0:0:64-n32-S32';
);
implementation
initialization
{$ifdef CPUARM}
{$ifdef embedded}
set_source_info(system_arm_freertos_info);
{$endif embedded}
{$endif CPUARM}
{$ifdef CPUAVR}
{$ifdef embedded}
set_source_info(system_avr_freertosd_info);
{$endif embedded}
{$endif CPUAVR}
{$ifdef CPUMIPSEL}
{$ifdef embedded}
set_source_info(system_mipsel_freertos_info);
{$endif embedded}
{$endif CPUMIPSEL}
{$ifdef CPUI386}
{$ifdef embedded}
set_source_info(system_i386_freertos_info);
{$endif embedded}
{$endif CPUI386}
{$ifdef CPUX86_64}
{$ifdef embedded}
set_source_info(system_x86_64_freertos_info);
{$endif embedded}
{$endif CPUX86_64}
{$ifdef cpu8086}
{$ifdef embedded}
set_source_info(system_i8086_freertos_info);
{$endif embedded}
{$endif cpu8086}
{$ifdef cpum68k}
{$ifdef embedded}
set_source_info(system_m68k_freertos_info);
{$endif embedded}
{$endif cpum68k}
{$ifdef cpuriscv32}
{$ifdef embedded}
set_source_info(system_riscv32_freertos_info);
{$endif embedded}
{$endif cpuriscv32}
{$ifdef cpuriscv64}
{$ifdef embedded}
set_source_info(system_riscv64_freertos_info);
{$endif embedded}
{$endif cpuriscv64}
{$ifdef cpuxtensa}
{$ifdef embedded}
set_source_info(system_xtensa_freertos_info);
{$endif embedded}
{$endif cpuxtensa}
end.

File diff suppressed because it is too large Load Diff

View File

@ -52,6 +52,7 @@ Type
tcontrollertype =
(ct_none,
ct_esp8266,
ct_esp32,
ct_esp32_d0wd,
ct_esp32_d2wd,
ct_esp32_sOwd
@ -108,6 +109,7 @@ Const
(
(controllertypestr:''; controllerunitstr:''; cputype:cpu_none; fputype:fpu_none; abi: abi_default; flashbase:0),
(controllertypestr:'ESP8266'; controllerunitstr:'ESP8266'; cputype:cpu_lx106; fputype:fpu_none; abi: abi_xtensa_call0; { flashbase:$40000000; flashsize:448*1024; srambase:$40070000; sramsize: 520*1024 }),
(controllertypestr:'ESP32'; controllerunitstr:'ESP32'; cputype:cpu_lx6; fputype:fpu_none; abi: abi_xtensa_windowed),
(controllertypestr:'ESP32_D0WD'; controllerunitstr:'ESP32_D0WD'; cputype:cpu_lx6; fputype:fpu_none; abi: abi_xtensa_windowed; flashbase:$40000000; flashsize:448*1024; srambase:$40070000; sramsize: 520*1024),
(controllertypestr:'ESP32_D2WD'; controllerunitstr:'ESP32_D2WD'; cputype:cpu_lx6; fputype:fpu_none; abi: abi_xtensa_windowed; flashbase:$40000000; flashsize:448*1024; srambase:$40070000; sramsize: 520*1024),
(controllertypestr:'ESP32_S0WD'; controllerunitstr:'ESP32_S0WD'; cputype:cpu_lx6; fputype:fpu_none; abi: abi_xtensa_windowed; flashbase:$40000000; flashsize:448*1024; srambase:$40070000; sramsize: 520*1024)

View File

@ -36,7 +36,7 @@ implementation
**************************************}
{$ifndef NOTARGETEMBEDDED}
,t_embed
,t_embed,t_freertos
{$endif}
{**************************************

2969
rtl/freertos/Makefile Normal file

File diff suppressed because it is too large Load Diff

437
rtl/freertos/Makefile.fpc Normal file
View File

@ -0,0 +1,437 @@
#
# Makefile.fpc for Free Pascal FreeRTOS RTL
#
[package]
main=rtl
[target]
loaders=$(LOADERS)
# not all targets include enough features to build all units so
# the common units which are not compiled for all CPUs are stored in
# CPU_SPECIFIC_COMMON_UNITS
units=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings heapmgr consoleio sortbase $(CPU_SPECIFIC_COMMON_UNITS) \
# macpas iso7185 strings
dos \
ctypes \
charset cpall \
sysconst
#implicitunits=exeinfo \
# cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 \
# cp437 cp646 cp737 cp775 cp850 cp852 cp855 cp856 cp857 cp860 cp861 cp862 \
# cp863 cp864 cp865 cp866 cp869 cp874 cp3021 cp8859_1 cp8859_2 cp8859_3 cp8859_4 \
# cp8859_5 cp8859_6 cp8859_7 cp8859_8 cp8859_9 cp8859_10 cp8859_11 \
# cp8859_13 cp8859_14 cp8859_15 cp8859_16 cpkoi8_r cpkoi8_u
#rsts=math rtlconsts varutils typinfo variants classes sysconst dateutil
[require]
nortl=y
[install]
fpcpackage=y
[default]
fpcdir=../..
target=embedded
[compiler]
includedir=$(INC) $(PROCINC)
sourcedir=$(INC) $(PROCINC) $(COMMON) $(ARCH)
[prerules]
RTL=..
INC=$(RTL)/inc
COMMON=$(RTL)/common
PROCINC=$(RTL)/$(CPU_TARGET)
UNITPREFIX=rtl
SYSTEMUNIT=system
LOADERS=
ifeq ($(ARCH),mipsel)
ifeq ($(SUBARCH),pic32mx)
override LOADERS=startup
endif
endif
ifdef RELEASE
override FPCOPT+=-Ur
endif
# Always include rtl.cfg config file for i8086
ifeq ($(ARCH),i8086)
override FPCOPT+=@rtl.cfg
endif
CPU_UNITS=
SYSINIT_UNITS=
CPU_SPECIFIC_COMMON_UNITS=
ifeq ($(ARCH),arm)
CPU_SPECIFIC_COMMON_UNITS=sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo
ifeq ($(SUBARCH),armv7m)
CPU_UNITS=lm3fury lm3tempest stm32f10x_ld stm32f10x_md stm32f10x_hd stm32f10x_xl stm32f10x_conn stm32f10x_cl lpc13xx lpc1768 lm4f120 sam3x8e xmc4500 cortexm3 cortexm4 # thumb2_bare
CPU_UNITS_DEFINED=1
endif
ifeq ($(SUBARCH),armv7em)
CPU_UNITS=lm4f120 xmc4500 mk20d5 mk20d7 mk22f51212 mk64f12 stm32f401xx stm32f407xx stm32f411xe stm32f429xx stm32f446xx stm32f745 stm32f746 stm32f756 nrf52 cortexm3 cortexm4 cortexm7 # thumb2_bare
CPU_UNITS_DEFINED=1
endif
ifeq ($(SUBARCH),armv4t)
CPU_UNITS=lpc21x4 at91sam7x256 sc32442b
CPU_UNITS_DEFINED=1
endif
ifeq ($(SUBARCH),armv4)
CPU_UNITS=lpc21x4 at91sam7x256 sc32442b
CPU_UNITS_DEFINED=1
endif
ifeq ($(SUBARCH),armv6m)
CPU_UNITS=lpc8xx lpc11xx lpc122x stm32f0xx nrf51 cortexm0
CPU_UNITS_DEFINED=1
endif
ifeq ($(SUBARCH),armv7a)
CPU_UNITS=allwinner_a20 raspi2
CPU_UNITS_DEFINED=1
endif
ifeq ($(CPU_UNITS_DEFINED),)
$(error No CPUs enabled for given SUBARCH, pass either a SUBARCH or set CPU_UNITS_DEFINED=1 if you know what you are doing)
endif
endif
ifeq ($(ARCH),avr)
CPU_SPECIFIC_COMMON_UNITS=intrinsics
ifeq ($(SUBARCH),avrtiny)
CPU_UNITS=attiny4 attiny5 attiny9 attiny10 attiny20 attiny40 attiny102 attiny104
CPU_UNITS_DEFINED=1
endif
ifeq ($(SUBARCH),avr1)
CPU_UNITS=attiny11 attiny12 attiny15 attiny28
CPU_UNITS_DEFINED=1
endif
ifeq ($(SUBARCH),avr2)
CPU_UNITS=attiny26
CPU_UNITS_DEFINED=1
endif
ifeq ($(SUBARCH),avr25)
CPU_UNITS=attiny13 attiny13a attiny24 attiny24a attiny25 attiny43u \
attiny44 attiny44a attiny45 attiny48 attiny84a attiny84 attiny85 \
attiny87 attiny88 attiny261 attiny261a attiny441 attiny461 attiny461a attiny828 \
attiny841 attiny861 attiny861a attiny2313 attiny2313a attiny4313
CPU_UNITS_DEFINED=1
endif
ifeq ($(SUBARCH),avr35)
CPU_UNITS=at90usb82 at90usb162 atmega8u2 atmega16u2 atmega32u2 attiny167 attiny1634
CPU_UNITS_DEFINED=1
endif
ifeq ($(SUBARCH),avr4)
CPU_UNITS=at90pwm1 at90pwm2b at90pwm3b at90pwm81 ata6285 ata6286 atmega8 \
atmega8a atmega8hva atmega48 atmega48a atmega48p atmega48pa \
atmega48pb atmega88 atmega88a atmega88p atmega88pa atmega88pb \
atmega8515 atmega8535
CPU_UNITS_DEFINED=1
endif
ifeq ($(SUBARCH),avr5)
CPU_UNITS=avrsim at90can32 at90can64 at90pwm161 at90pwm216 at90pwm316 \
at90usb646 at90usb647 atmega16 atmega16a atmega16hva atmega16hvb atmega16hvbrevb atmega16m1 \
atmega16u4 atmega32 atmega32a atmega32c1 atmega32hvb atmega32hvbrevb atmega32m1 \
atmega32u4 atmega64 atmega64a atmega64c1 atmega64hve2 atmega64m1 atmega64rfr2 atmega162 \
atmega164a atmega164p atmega164pa atmega165a atmega165p atmega165pa \
atmega168 atmega168a atmega168p atmega168pa atmega168pb atmega169a atmega169p \
atmega169pa atmega324a atmega324p atmega324pa atmega324pb atmega325 atmega325a \
atmega325p atmega325pa atmega328 atmega328p atmega328pb atmega329 atmega329a \
atmega329p atmega329pa atmega406 atmega640 atmega644 atmega644a atmega644p \
atmega644pa atmega644rfr2 atmega645 atmega645a atmega645p atmega649 atmega649a \
atmega649p atmega3250 atmega3250a atmega3250p atmega3250pa atmega3290 \
atmega3290a atmega3290p atmega3290pa atmega6450 atmega6450a \
atmega6450p atmega6490 atmega6490a atmega6490p
CPU_UNITS_DEFINED=1
endif
ifeq ($(SUBARCH),avr51)
CPU_UNITS=at90can128 at90usb1286 at90usb1287 atmega128 atmega128a atmega128rfa1 atmega128rfr2 \
atmega1280 atmega1281 atmega1284 atmega1284p atmega1284rfr2
CPU_UNITS_DEFINED=1
endif
ifeq ($(SUBARCH),avr6)
CPU_UNITS=avrsim atmega256rfr2 atmega2560 atmega2561 atmega2564rfr2
CPU_UNITS_DEFINED=1
endif
ifeq ($(SUBARCH),avrxmega3)
CPU_UNITS=atmega808 atmega809 atmega1608 atmega1609 atmega3208 atmega3209 \
atmega4808 atmega4809 attiny202 attiny204 attiny212 attiny214 \
attiny402 attiny404 attiny406 attiny412 attiny414 attiny416 \
attiny416auto attiny417 attiny804 attiny806 attiny807 attiny814 \
attiny816 attiny817 attiny1604 attiny1606 attiny1607 attiny1614 \
attiny1616 attiny1617 attiny1624 attiny1626 attiny1627 attiny3214 attiny3216 attiny3217
CPU_UNITS_DEFINED=1
endif
ifeq ($(CPU_UNITS_DEFINED),)
$(error No CPUs enabled for given SUBARCH, pass either a SUBARCH or set CPU_UNITS_DEFINED=1 if you know what you are doing)
endif
endif
ifeq ($(ARCH),i386)
CPU_SPECIFIC_COMMON_UNITS=sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo
CPU_UNITS=multiboot
CPU_UNITS_DEFINED=1
ifeq ($(CPU_UNITS_DEFINED),)
$(error No CPUs enabled for given SUBARCH, pass either a SUBARCH or set CPU_UNITS_DEFINED=1 if you know what you are doing)
endif
endif
ifeq ($(ARCH),x86_64)
CPU_SPECIFIC_COMMON_UNITS=sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo
# CPU_UNITS=multiboot
endif
ifeq ($(ARCH),m68k)
CPU_SPECIFIC_COMMON_UNITS=sysutils math
# CPU_UNITS=multiboot
endif
ifeq ($(ARCH),mipsel)
CPU_SPECIFIC_COMMON_UNITS=sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo
ifeq ($(SUBARCH),pic32mx)
CPU_UNITS=pic32mx1xxfxxxb pic32mx2xxfxxxb pic32mx1xxfxxxc pic32mx2xxfxxxc pic32mx1xxfxxxd pic32mx2xxfxxxd pic32mx7x5fxxxl pic32mx7x5fxxxh
CPU_UNITS_DEFINED=1
endif
ifeq ($(CPU_UNITS_DEFINED),)
$(error No CPUs enabled for given SUBARCH, pass either a SUBARCH or set CPU_UNITS_DEFINED=1 if you know what you are doing)
endif
endif
ifeq ($(ARCH),riscv32)
CPU_SPECIFIC_COMMON_UNITS=sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo
ifeq ($(SUBARCH),rv32imac)
override FPCOPT+=-Cprv32imac
CPU_UNITS=fe310g000 fe310g002 gd32vf103xx
CPU_UNITS_DEFINED=1
endif
ifeq ($(CPU_UNITS_DEFINED),)
$(error No CPUs enabled for given SUBARCH, pass either a SUBARCH or set CPU_UNITS_DEFINED=1 if you know what you are doing)
endif
endif
ifeq ($(ARCH),riscv64)
CPU_SPECIFIC_COMMON_UNITS=sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo
CPU_UNITS=
CPU_UNITS_DEFINED=1
ifeq ($(CPU_UNITS_DEFINED),)
$(error No CPUs enabled for given SUBARCH, pass either a SUBARCH or set CPU_UNITS_DEFINED=1 if you know what you are doing)
endif
endif
ifeq ($(ARCH),xtensa)
CPU_SPECIFIC_COMMON_UNITS=sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo
CPU_UNITS=esp32
CPU_UNITS_DEFINED=1
ifeq ($(CPU_UNITS_DEFINED),)
$(error No CPUs enabled for given SUBARCH, pass either a SUBARCH or set CPU_UNITS_DEFINED=1 if you know what you are doing)
endif
endif
# Paths
OBJPASDIR=$(RTL)/objpas
GRAPHDIR=$(INC)/graph
[rules]
# .NOTPARALLEL:
# Get the system independent include file names.
# This will set the following variables :
# SYSINCNAMES
include $(INC)/makefile.inc
SYSINCDEPS=$(addprefix $(INC)/,$(SYSINCNAMES))
# Get the processor dependent include file names.
# This will set the following variables :
# CPUINCNAMES
include $(PROCINC)/makefile.cpu
SYSCPUDEPS=$(addprefix $(PROCINC)/,$(CPUINCNAMES))
# Put system unit dependencies together.
SYSDEPS=$(SYSINCDEPS) $(SYSCPUDEPS)
#
# Loaders
#
startup$(OEXT) : $(CPU_TARGET)/startup.s
$(AS) $(ASTARGET) -o $(UNITTARGETDIRPREFIX)startup$(OEXT) $(CPU_TARGET)/startup.s -mabi=32 -march=pic32mx -mtune=pic32mx -W -EL -msym32
#
# Base Units (System, strings, os-dependent-base-unit)
#
$(SYSTEMUNIT)$(PPUEXT) : $(SYSTEMUNIT).pp $(SYSDEPS) $(INC)/softfpu.pp
$(COMPILER) $(FPC_SYSTEM_OPT) -Us -Sg $(SYSTEMUNIT).pp @system.cfg $(REDIR)
uuchar$(PPUEXT): $(INC)/uuchar.pp $(SYSTEMUNIT)$(PPUEXT)
$(COMPILER) $<
objpas$(PPUEXT): $(OBJPASDIR)/objpas.pp $(INC)/except.inc $(SYSTEMUNIT)$(PPUEXT)
$(COMPILER) -I$(OBJPASDIR) $(OBJPASDIR)/objpas.pp $(REDIR)
strings$(PPUEXT) : $(INC)/strings.pp $(INC)/stringsi.inc \
$(PROCINC)/strings.inc $(PROCINC)/stringss.inc \
$(SYSTEMUNIT)$(PPUEXT)
$(COMPILER) $<
#
# System Dependent Units
#
#ports$(PPUEXT) : ports.pas objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
# $(COMPILER) $<
#doscalls$(PPUEXT) : doscalls.pas strings$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
# $(COMPILER) $<
consoleio$(PPUEXT) : consoleio.pp $(SYSTEMUNIT)$(PPUEXT)
$(COMPILER) $<
heapmgr$(PPUEXT) : heapmgr.pp $(SYSTEMUNIT)$(PPUEXT)
$(COMPILER) $<
#
# TP7 Compatible RTL Units
#
dos$(PPUEXT) : dos.pp $(INC)/fexpand.inc $(INC)/filerec.inc $(INC)/textrec.inc $(INC)/dosh.inc $(INC)/dos.inc objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
$(COMPILER) $<
#crt$(PPUEXT) : crt.pas $(INC)/textrec.inc $(SYSTEMUNIT)$(PPUEXT)
# $(COMPILER) $<
objects$(PPUEXT) : $(INC)/objects.pp dos$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
$(COMPILER) $<
#printer$(PPUEXT) : printer.pas $(INC)/textrec.inc $(SYSTEMUNIT)$(PPUEXT)
# $(COMPILER) $<
#graph$(PPUEXT) : graph.pp
# $(COMPILER) $<
#
# Delphi Compatible Units
#
sysutils$(PPUEXT) : sysutils.pp $(wildcard $(OBJPASDIR)/sysutils/*.inc) \
objpas$(PPUEXT) sysconst$(PPUEXT) heapmgr$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
$(COMPILER) -Fi$(OBJPASDIR)/sysutils sysutils.pp
classes$(PPUEXT) : classes.pp $(wildcard $(OBJPASDIR)/classes/*.inc) \
sysutils$(PPUEXT) typinfo$(PPUEXT) rtlconsts$(PPUEXT) types$(PPUEXT) sortbase$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
$(COMPILER) -Fi$(OBJPASDIR)/classes classes.pp
typinfo$(PPUEXT): $(OBJPASDIR)/typinfo.pp objpas$(PPUEXT) sysutils$(PPUEXT) rtlconsts$(PPUEXT)
$(COMPILER) -Sg $(OBJPASDIR)/typinfo.pp $(REDIR)
math$(PPUEXT): $(OBJPASDIR)/math.pp objpas$(PPUEXT) sysutils$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
$(COMPILER) $(OBJPASDIR)/math.pp $(REDIR)
varutils$(PPUEXT) : $(OBJPASDIR)/cvarutil.inc $(OBJPASDIR)/varutils.inc \
$(OBJPASDIR)/varutilh.inc varutils.pp $(SYSTEMUNIT)$(PPUEXT)
$(COMPILER) -I$(OBJPASDIR) varutils.pp $(REDIR)
fmtbcd$(PPUEXT) : $(OBJPASDIR)/fmtbcd.pp objpas$(PPUEXT) sysutils$(PPUEXT) variants$(PPUEXT) classes$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
$(COMPILER) $(OBJPASDIR)/fmtbcd.pp
types$(PPUEXT) : $(OBJPASDIR)/types.pp math$(PPUEXT) objpas$(PPUEXT) math$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
$(COMPILER) $(OBJPASDIR)/types.pp
rtlconsts$(PPUEXT) : $(OBJPASDIR)/rtlconsts.pp $(OBJPASDIR)/rtlconst.inc objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
$(COMPILER) $(OBJPASDIR)/rtlconsts.pp
sysconst$(PPUEXT) : $(OBJPASDIR)/sysconst.pp objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
$(COMPILER) $(OBJPASDIR)/sysconst.pp
fgl$(PPUEXT): $(OBJPASDIR)/fgl.pp objpas$(PPUEXT) types$(PPUEXT) system$(PPUEXT) sysutils$(PPUEXT) sortbase$(PPUEXT)
$(COMPILER) -Sg $(OBJPASDIR)/fgl.pp $(REDIR)
dateutil$(PPUEXT) : $(OBJPASDIR)/dateutil.pp $(SYSTEMUNIT)$(PPUEXT)
$(COMPILER) -I$(OBJPASDIR) $(OBJPASDIR)/dateutil.pp
#
# Mac Pascal Model
#
macpas$(PPUEXT) : $(INC)/macpas.pp objpas$(PPUEXT) math$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
$(COMPILER) $(INC)/macpas.pp $(REDIR)
#
# Other system-independent RTL Units
#
ucomplex$(PPUEXT): $(INC)/ucomplex.pp math$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
$(COMPILER) $<
getopts$(PPUEXT) : $(INC)/getopts.pp $(SYSTEMUNIT)$(PPUEXT)
$(COMPILER) $<
heaptrc$(PPUEXT) : $(INC)/heaptrc.pp $(SYSTEMUNIT)$(PPUEXT)
$(COMPILER) -Sg $(INC)/heaptrc.pp $(REDIR)
lineinfo$(PPUEXT) : $(INC)/lineinfo.pp strings$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
$(COMPILER) $(INC)/lineinfo.pp
charset$(PPUEXT) : $(INC)/charset.pp objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
$(COMPILER) $<
cpall$(PPUEXT): $(RTL)/charmaps/cpall.pas system$(PPUEXT) charset$(PPUEXT)
$(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cpall.pas
iso7185$(PPUEXT) : $(INC)/iso7185.pp $(SYSTEMUNIT)$(PPUEXT)
$(COMPILER) $(INC)/iso7185.pp
extpas$(PPUEXT) : $(INC)/extpas.pp dos$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
$(COMPILER) $(INC)/extpas.pp
#
# Unit specific rules
#
define CPU_UNITS_RULE
ifeq ($(ARCH),avr)
$(1)$(PPUEXT): $(ARCH)/$(1).pp intrinsics$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
else
$(1)$(PPUEXT): $(ARCH)/$(1).pp $(SYSTEMUNIT)$(PPUEXT)
endif
endef
$(foreach unit,$(CPU_UNITS),$(eval $(call CPU_UNITS_RULE,$(unit))))
$(addsuffix $(PPUEXT),$(CPU_UNITS)):
$(COMPILER) -g $<
#
# Other $(SYSTEMUNIT)-dependent RTL Units
#
errors$(PPUEXT) : $(UNIXINC)/errors.pp strings$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
$(COMPILER) $(UNIXINC)/errors.pp
callspec$(PPUEXT) : $(INC)/callspec.pp $(SYSTEMUNIT)$(PPUEXT)
$(COMPILER) $(INC)/callspec.pp
cmem$(PPUEXT) : $(INC)/cmem.pp $(SYSTEMUNIT)$(PPUEXT)
$(COMPILER) $(INC)/cmem.pp
cthreads$(PPUEXT) : $(UNIXINC)/cthreads.pp $(SYSTEMUNIT)$(PPUEXT) unix$(PPUEXT) sysutils$(PPUEXT) baseunix$(PPUEXT) initc$(PPUEXT) dl$(PPUEXT)
$(COMPILER) $(UNIXINC)/cthreads.pp
cwstring$(PPUEXT) : $(UNIXINC)/cwstring.pp $(SYSTEMUNIT)$(PPUEXT) sysutils$(PPUEXT) baseunix$(PPUEXT) unix$(PPUEXT) unixtype$(PPUEXT) ctypes$(PPUEXT) dynlibs$(PPUEXT) unixcp$(PPUEXT)
$(COMPILER) $(UNIXINC)/cwstring.pp
ctypes$(PPUEXT) : $(INC)/ctypes.pp $(SYSTEMUNIT)$(PPUEXT)
$(COMPILER) $(INC)/ctypes.pp
fpcylix$(PPUEXT) : fpcylix.pp cthreads$(PPUEXT) cwstring$(PPUEXT) dynlibs$(PPUEXT) objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
$(COMPILER) fpcylix.pp
intrinsics$(PPUEXT) : $(PROCINC)/intrinsics.pp $(SYSTEMUNIT)$(PPUEXT)
$(COMPILER) $(PROCINC)/intrinsics.pp
sortbase$(PPUEXT) : $(INC)/sortbase.pp objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
$(COMPILER) $(INC)/sortbase.pp

83
rtl/freertos/check.inc Normal file
View File

@ -0,0 +1,83 @@
{
This file checks feature dependencies, so the compiler
exits with a proper error message before a bunch of errors
confuse the user.
}
{$ifdef FPC_HAS_FEATURE_COMMANDARGS}
{$ifndef FPC_HAS_FEATURE_HEAP}
{$fatal Using commandline arguments requires a heap manager }
{$endif FPC_HAS_FEATURE_HEAP}
{$endif FPC_HAS_FEATURE_COMMANDARGS}
{$ifdef FPC_HAS_FEATURE_OBJECTS}
{$ifndef FPC_HAS_FEATURE_HEAP}
{$fatal Using objects requires a heap manager }
{$endif FPC_HAS_FEATURE_HEAP}
{$endif FPC_HAS_FEATURE_OBJECTS}
{$ifdef FPC_HAS_FEATURE_EXCEPTIONS}
{$ifndef FPC_HAS_FEATURE_HEAP}
{$fatal Using exceptions requires a heap manager }
{$endif FPC_HAS_FEATURE_HEAP}
{$endif FPC_HAS_FEATURE_EXCEPTIONS}
{$ifdef FPC_HAS_FEATURE_WIDESTRINGS}
{$ifndef FPC_HAS_FEATURE_HEAP}
{$fatal Using widestrings requires a heap manager }
{$endif FPC_HAS_FEATURE_HEAP}
{$ifndef FPC_HAS_FEATURE_RTTI}
{$fatal Using widestrings requires rtti }
{$endif FPC_HAS_FEATURE_RTTI}
{$endif FPC_HAS_FEATURE_WIDESTRINGS}
{$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
{$ifndef FPC_HAS_FEATURE_HEAP}
{$fatal Using ansistrings requires a heap manager }
{$endif FPC_HAS_FEATURE_HEAP}
{$ifndef FPC_HAS_FEATURE_RTTI}
{$fatal Using ansistrings requires rtti }
{$endif FPC_HAS_FEATURE_RTTI}
{$endif FPC_HAS_FEATURE_ANSISTRINGS}
{$ifdef FPC_HAS_FEATURE_DYNARRAYS}
{$ifndef FPC_HAS_FEATURE_HEAP}
{$fatal Using dyn. arrays requires a heap manager }
{$endif FPC_HAS_FEATURE_HEAP}
{$ifndef FPC_HAS_FEATURE_RTTI}
{$fatal Using dyn. arrays requires rtti }
{$endif FPC_HAS_FEATURE_RTTI}
{$endif FPC_HAS_FEATURE_DYNARRAYS}
{$ifdef FPC_HAS_FEATURE_CLASSES}
{$ifndef FPC_HAS_FEATURE_HEAP}
{$fatal Using classes requires a heap manager }
{$endif FPC_HAS_FEATURE_HEAP}
{$ifndef FPC_HAS_FEATURE_RTTI}
{$fatal Using classes requires rtti }
{$endif FPC_HAS_FEATURE_RTTI}
{$ifndef FPC_HAS_FEATURE_EXCEPTIONS}
{$fatal Using classes requires exceptions }
{$endif FPC_HAS_FEATURE_EXCEPTIONS}
{$endif FPC_HAS_FEATURE_CLASSES}
{$ifdef FPC_HAS_FEATURE_VARIANTS}
{$ifndef FPC_HAS_FEATURE_HEAP}
{$fatal Using variants requires a heap manager }
{$endif FPC_HAS_FEATURE_HEAP}
{$ifndef FPC_HAS_FEATURE_ANSISTRINGS}
{$fatal Using variants requires ansistrings }
{$endif FPC_HAS_FEATURE_ANSISTRRING}
{$ifndef FPC_HAS_FEATURE_WIDESTRINGS}
{$fatal Using variants requires widestrings }
{$endif FPC_HAS_FEATURE_WIDESTRINGS}
{$ifndef FPC_HAS_FEATURE_CLASSES}
{$fatal Using variants requires classes }
{$endif FPC_HAS_FEATURE_CLASSES}
{$endif FPC_HAS_FEATURE_VARIANTS}

47
rtl/freertos/classes.pp Normal file
View File

@ -0,0 +1,47 @@
{
This file is part of the Free Component Library (FCL)
Copyright (c) 1999-2002 by the Free Pascal development team
Classes unit for FreeRTOS target
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.
**********************************************************************}
{$mode objfpc}
unit Classes;
interface
uses
sysutils,
rtlconsts,
types,
sortbase,
{$ifdef FPC_TESTGENERICS}
fgl,
{$endif}
typinfo;
{$i classesh.inc}
implementation
{ OS - independent class implementations are in /inc directory. }
{$i classes.inc}
initialization
CommonInit;
finalization
CommonCleanup;
end.

179
rtl/freertos/consoleio.pp Normal file
View File

@ -0,0 +1,179 @@
{
This file is part of the Free Pascal run time library.
Copyright (c) 2011 by the Free Pascal development team.
Console i/o for the FPC FreeRTOS target
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.
**********************************************************************}
Unit consoleio;
interface
type
TWriteCharFunc = function(ACh: char; AUserData: pointer): boolean;
TReadCharFunc = function(var ACh: char; AUserData: pointer): boolean;
procedure OpenIO(var f: Text; AWrite: TWriteCharFunc; ARead: TReadCharFunc; AMode: word; AUserData: pointer);
implementation
{$i textrec.inc}
type
PUserData = ^TUserData;
TUserData = record
WriteChar: TWriteCharFunc;
ReadChar: TReadCharFunc;
UserData: Pointer;
end;
function EmptyWrite(ACh: char; AUserData: pointer): boolean;
begin
EmptyWrite:=true;
end;
function EmptyRead(var ACh: char; AUserData: pointer): boolean;
begin
EmptyRead:=true;
ACh:=#0;
end;
procedure Console_Close(var t:TextRec);
begin
end;
function ReadData(Func: TReadCharFunc; UserData: pointer; Buffer: pchar; count: SizeInt): SizeInt;
var
c: char;
got_linechar: boolean;
begin
ReadData:=0;
got_linechar:=false;
while (ReadData < count) and (not got_linechar) do
begin
if Func(c, UserData) then
begin
if c = #10 then
got_linechar:=true;
buffer^:=c;
inc(buffer);
inc(ReadData);
end;
end;
end;
Procedure Console_Read(var t:TextRec);
var
userdata: PUserData;
begin
userdata:=@t.UserData[1];
InOutRes:=0;
t.bufend:=ReadData(userdata^.ReadChar,userdata^.UserData,pchar(t.bufptr),t.bufsize);
t.bufpos:=0;
end;
Procedure Console_Write(var t:TextRec);
var
userdata: PUserData;
p: pchar;
i: SizeInt;
begin
if t.BufPos=0 then exit;
userdata:=@t.UserData[1];
i := 0;
p := pchar(t.bufptr);
while i < t.bufpos do
begin
if not userdata^.WriteChar(p^, userdata^.UserData) then
break;
inc(p);
inc(i);
end;
if i<>t.BufPos then
InOutRes:=101
else
InOutRes:=0;
t.BufPos:=0;
end;
procedure OpenIO(var f: Text; AWrite: TWriteCharFunc; ARead: TReadCharFunc; AMode: word; AUserData: pointer);
var
userdata: PUserData;
begin
{ Essentially just init everything, more or less what Assign(f,'');
does }
FillChar(f,SizeOf(TextRec),0);
{ only set things that are not zero }
TextRec(f).Handle:=UnusedHandle;
TextRec(f).BufSize:=TextRecBufSize;
TextRec(f).Bufptr:=@TextRec(f).Buffer;
TextRec(f).OpenFunc:=nil;
TextRec(f).LineEnd := #13#10;
userdata:=@TextRec(f).UserData[1];
TextRec(f).Mode:=AMode;
case AMode of
fmInput: TextRec(f).Handle:=StdInputHandle;
fmOutput: TextRec(f).Handle:=StdOutputHandle;
end;
TextRec(f).CloseFunc:=@Console_Close;
TextRec(f).FlushFunc:=nil;
case AMode of
fmInput: TextRec(f).InOutFunc:=@Console_Read;
fmOutput:
begin
TextRec(f).InOutFunc:=@Console_Write;
TextRec(f).FlushFunc:=@Console_Write;
end;
end;
userdata^.WriteChar := AWrite;
userdata^.ReadChar := ARead;
userdata^.UserData := AUserData;
end;
procedure SysInitStdIO;
begin
OpenIO(Input, @EmptyWrite, @EmptyRead, fmInput, nil);
OpenIO(Output, @EmptyWrite, @EmptyRead, fmOutput, nil);
OpenIO(ErrOutput, @EmptyWrite, @EmptyRead, fmOutput, nil);
OpenIO(StdOut, @EmptyWrite, @EmptyRead, fmOutput, nil);
OpenIO(StdErr, @EmptyWrite, @EmptyRead, fmOutput, nil);
end;
procedure SysFlushStdIO;
begin
end;
var
ErrorBase : Pointer;external name 'FPC_ERRORBASE';
var
pstdout : ^Text;
{$ifndef CPUAVR}
initialization
{ Setup stdin, stdout and stderr }
SysInitStdIO;
finalization
{ Show runtime error and exit }
pstdout:=@stdout;
If erroraddr<>nil Then
Begin
Writeln(pstdout^,'Runtime error ',Errorcode,' at $',hexstr(erroraddr));
{ to get a nice symify }
Writeln(pstdout^,BackTraceStrFunc(Erroraddr));
dump_stack(pstdout^,ErrorBase);
Writeln(pstdout^,'');
End;
SysFlushStdIO;
{$endif CPUAVR}
end.

280
rtl/freertos/dos.pp Normal file
View File

@ -0,0 +1,280 @@
{
This file is part of the Free Pascal run time library.
Copyright (c) 2004 by Karoly Balogh for Genesi S.a.r.l.
Heavily based on the Commodore Amiga/m68k RTL by Nils Sjoholm and
Carl Eric Codere
MorphOS port was done on a free Pegasos II/G4 machine
provided by Genesi S.a.r.l. <www.genesi.lu>
This unit is based on the MorphOS one and is adapted for Gameboy Advance
simply by stripping out all stuff inside funcs and procs.
Copyright (c) 2006 by Francesco Lombardi
Adapted to FPC FreeRTOS by Florian Klämpfl
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.
**********************************************************************}
unit Dos;
interface
{$MODE objfpc}
type
SearchRec = Packed Record
AnchorPtr : Pointer; { Pointer to the Anchorpath structure }
Fill: Array[1..15] of Byte; {future use}
{End of replacement for fill}
Attr : BYTE; {attribute of found file}
Time : LongInt; {last modify date of found file}
Size : LongInt; {file size of found file}
Name : String[255]; {name of found file}
End;
{$I dosh.inc}
implementation
{$define HAS_GETMSCOUNT}
{$I dos.inc}
{******************************************************************************
--- Internal routines ---
******************************************************************************}
function dosLock(const name: String; accessmode: Longint) : LongInt;
begin
result := -1;
end;
function IsLeapYear(Source : Word) : Boolean;
begin
result := false;
end;
function dosSetProtection(const name: string; mask:longint): Boolean;
begin
result := false;
end;
function dosSetFileDate(name: string): Boolean;
begin
result := false;
end;
{******************************************************************************
--- Info / Date / Time ---
******************************************************************************}
function DosVersion: Word;
begin
result := 0;
end;
procedure NewList ();
begin
end;
function CreateExtIO (size: Longint): integer;
begin
result := -1;
end;
procedure DeleteExtIO ();
begin
end;
function Createport(name : PChar; pri : longint): integer;
begin
result := -1;
end;
procedure DeletePort ();
begin
end;
function Create_Timer(theUnit : longint) : integer;
begin
result := -1;
end;
Procedure Delete_Timer();
begin
end;
function set_new_time(secs, micro : longint): longint;
begin
result := -1;
end;
function get_sys_time(): longint;
begin
result := -1;
end;
procedure GetDate(Var Year, Month, MDay, WDay: Word);
begin
Year := 0;
Month := 0;
MDay := 0;
WDay := 0;
end;
procedure SetDate(Year, Month, Day: Word);
begin
end;
procedure GetTime(Var Hour, Minute, Second, Sec100: Word);
begin
Hour := 0;
Minute := 0;
Second := 0;
Sec100 := 0;
end;
Procedure SetTime(Hour, Minute, Second, Sec100: Word);
begin
end;
function GetMsCount: int64;
begin
result:=0;
end;
{******************************************************************************
--- Exec ---
******************************************************************************}
procedure Exec(const Path: PathStr; const ComLine: ComStr);
begin
end;
{******************************************************************************
--- Disk ---
******************************************************************************}
Function DiskFree(Drive: Byte): int64;
Begin
result := -1;
end;
Function DiskSize(Drive: Byte): int64;
Begin
result := -1;
end;
procedure FindFirst(const Path: PathStr; Attr: Word; Var f: SearchRec);
begin
DosError:=18;
end;
procedure FindNext(Var f: SearchRec);
begin
DosError:=18;
end;
procedure FindClose(Var f: SearchRec);
begin
DosError:=18;
end;
{******************************************************************************
--- File ---
******************************************************************************}
function FSearch(path: PathStr; dirlist: String) : PathStr;
begin
result := '';
end;
Procedure getftime (var f; var time : longint);
begin
end;
Procedure setftime(var f; time : longint);
Begin
End;
procedure getfattr(var f; var attr : word);
begin
End;
procedure setfattr(var f; attr : word);
begin
end;
{******************************************************************************
--- Environment ---
******************************************************************************}
function getpathstring: string;
begin
result := '';
end;
function EnvCount: Longint;
begin
result := -1;
end;
function EnvStr(Index: LongInt): String;
begin
result := '';
end;
function GetEnv(envvar : String): String;
begin
result := '';
end;
procedure AddDevice(str : String);
begin
end;
function MakeDeviceName(str : pchar): string;
begin
result := '';
end;
function IsInDeviceList(str : string): boolean;
begin
result := false;
end;
procedure ReadInDevices;
begin
end;
begin
// DosError:=0;
// numberofdevices := 0;
// StrOfPaths := '';
// ReadInDevices;
end.

297
rtl/freertos/heapmgr.pp Normal file
View File

@ -0,0 +1,297 @@
{
This file is part of the Free Pascal run time library.
Copyright (c) 2011 by the Free Pascal development team.
Tiny heap manager for the FPC FreeRTOS target
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.
**********************************************************************}
{$modeswitch result}
Unit heapmgr;
interface
procedure RegisterHeapBlock(AAddress: pointer; ASize: ptruint);
function GetAlignedMem(Size, Alignment: ptruint): pointer;
implementation
const
MinBlock = 16;
type
PHeapBlock = ^THeapBlock;
THeapBlock = record
Size: ptruint;
Next: PHeapBlock;
EndAddr: pointer;
end;
var
Blocks: PHeapBlock = nil;
procedure InternalFreeMem(Addr: Pointer; Size: ptruint); forward;
function FindSize(p: pointer): ptruint; inline;
begin
FindSize := PPtrUInt(p)[-1];
end;
function SysGetMem(Size: ptruint): pointer;
var
p, prev: PHeapBlock;
AllocSize, RestSize: ptruint;
begin
if size+sizeof(PtrUInt)<MinBlock then
AllocSize := MinBlock
else
AllocSize := align(size+sizeof(PtrUInt), sizeof(pointer));
p := Blocks;
prev := nil;
while assigned(p) and (p^.Size < AllocSize) do
begin
prev := p;
p := p^.Next;
end;
if assigned(p) then
begin
result := @pptruint(p)[1];
if (p^.size > AllocSize) and
(p^.Size-AllocSize >= MinBlock) then
RestSize := p^.Size-AllocSize
else
begin
AllocSize := p^.Size;
RestSize := 0;
end;
if prev = nil then
Blocks := p^.Next
else
prev^.next := p^.next;
pptruint(p)^ := size;
InternalFreemem(pointer(ptruint(p)+AllocSize), RestSize);
end
else
begin
if ReturnNilIfGrowHeapFails then
Result := nil
else
RunError(203);
end;
end;
function GetAlignedMem(Size, Alignment: ptruint): pointer;
var
mem: Pointer;
memp: ptruint;
begin
if alignment <= sizeof(pointer) then
result := GetMem(size)
else
begin
mem := GetMem(Size+Alignment-1+MinBlock);
memp := align(ptruint(mem)+MinBlock, Alignment);
InternalFreemem(mem, ptruint(memp)-ptruint(mem));
result := pointer(memp);
end;
end;
procedure InternalFreeMem(Addr: Pointer; Size: ptruint);
var
b, p, prev: PHeapBlock;
concatenated: boolean;
begin
if size<=0 then
exit;
concatenated := true;
while concatenated do
begin
concatenated := false;
b := addr;
b^.Next := Blocks;
b^.Size := Size;
b^.EndAddr := pointer(ptruint(addr)+size);
if Blocks = nil then
Blocks := b
else
begin
p := Blocks;
prev := nil;
while assigned(p) do
begin
if p^.EndAddr = addr then
begin
addr:=p;
size:=p^.size+size;
if prev = nil then
blocks:=p^.next
else
prev^.next:=p^.next;
concatenated:=true;
break;
end
else if p = b^.EndAddr then
begin
size:=p^.size+size;
if prev = nil then
blocks:=p^.next
else
prev^.next:=p^.next;
concatenated:=true;
break;
end;
prev := p;
p := p^.next;
end;
if not concatenated then
begin
p := Blocks;
prev := nil;
while assigned(p) and (p^.Size < size) do
begin
prev := p;
p := p^.Next;
end;
if assigned(prev) then
begin
b^.Next := p;
prev^.Next := b;
end
else
Blocks := b;
end;
end;
end;
end;
function SysFreeMem(Addr: Pointer): ptruint;
var
sz: ptruint;
begin
if addr=nil then
begin
result:=0;
exit;
end;
sz := Align(FindSize(addr)+SizeOf(pointer), sizeof(pointer));
InternalFreeMem(@pptruint(addr)[-1], sz);
result := sz;
end;
function SysFreeMemSize(Addr: Pointer; Size: Ptruint): ptruint;
begin
result := SysFreeMem(addr);
end;
function SysMemSize(p: pointer): ptruint;
begin
result := findsize(p);
end;
function SysAllocMem(size: ptruint): pointer;
begin
result := SysGetMem(size);
if result<>nil then
FillChar(pbyte(result)^,size,0);
end;
function SysReAllocMem(var p: pointer; size: ptruint):pointer;
var
sz: ptruint;
begin
if size=0 then
begin
SysFreeMem(p);
result := nil;
p := nil;
end
else if p=nil then
begin
result := AllocMem(size);
p := result;
end
else
begin
result := AllocMem(size);
if result <> nil then
begin
if p <> nil then
begin
sz := FindSize(p);
if sz > size then
sz := size;
move(pbyte(p)^, pbyte(result)^, sz);
end;
end;
SysFreeMem(p);
p := result;
end;
end;
procedure RegisterHeapBlock(AAddress: pointer; ASize: ptruint);
begin
InternalFreeMem(AAddress, ASize);
end;
{ avoid that programs crash due to a heap status request }
function SysGetFPCHeapStatus : TFPCHeapStatus;
begin
FillChar(Result,SizeOf(Result),0);
end;
{ avoid that programs crash due to a heap status request }
function SysGetHeapStatus : THeapStatus;
begin
FillChar(Result,SizeOf(Result),0);
end;
const
MyMemoryManager: TMemoryManager = (
NeedLock: false; // Obsolete
GetMem: @SysGetMem;
FreeMem: @SysFreeMem;
FreeMemSize: @SysFreeMemSize;
AllocMem: @SysAllocMem;
ReAllocMem: @SysReAllocMem;
MemSize: @SysMemSize;
InitThread: nil;
DoneThread: nil;
RelocateHeap: nil;
GetHeapStatus: @SysGetHeapStatus;
GetFPCHeapStatus: @SysGetFPCHeapStatus;
);
var
initialheap : record end; external name '__fpc_initialheap';
heapsize : PtrInt; external name '__heapsize';
initialization
SetMemoryManager(MyMemoryManager);
RegisterHeapBlock(@initialheap,heapsize);
finalization
//FinalizeHeap;
end.

29
rtl/freertos/rtldefs.inc Normal file
View File

@ -0,0 +1,29 @@
{
This file is part of the Free Pascal run time library.
Copyright (c) 2012 by Free Pascal development team
This file contains platform-specific defines that are used in
multiple RTL units.
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.
**********************************************************************}
{ the single byte OS APIs always use UTF-8 }
{ define FPCRTL_FILESYSTEM_UTF8}
{ The OS supports a single byte file system operations API that we use }
{$define FPCRTL_FILESYSTEM_SINGLE_BYTE_API}
{ The OS supports a two byte file system operations API that we use }
{ define FPCRTL_FILESYSTEM_TWO_BYTE_API}
{ Use the shortstring version of do_getdir (should be converted to rawbytestring or
unicodestring for all but the OSes that don't support code pages and/or are
resource limited) }
{$define FPCRTL_DO_GETDIR_SHORTSTRING}

67
rtl/freertos/sysdir.inc Normal file
View File

@ -0,0 +1,67 @@
{
This file is part of the Free Pascal run time library.
Copyright (c) 2006 by Free Pascal development team
Low level directory functions
GBA does not have any drive, so no directory handling is needed.
Copyright (c) 2006 by Francesco Lombardi
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.
**********************************************************************}
{*****************************************************************************
Directory Handling
*****************************************************************************}
{$if defined(FPC_HAS_FEATURE_ANSISTRINGS)}
procedure do_mkdir(const s: rawbytestring);
begin
InOutRes:=3;
end;
procedure do_rmdir(const s: rawbytestring);
begin
InOutRes:=3;
end;
procedure do_chdir(const s: rawbytestring);
begin
InOutRes:=3;
end;
procedure do_GetDir (DriveNr: byte; var Dir: RawByteString);
begin
InOutRes:=3;
end;
{$else FPC_HAS_FEATURE_ANSISTRINGS}
procedure mkdir(const s: shortstring);
begin
InOutRes:=3;
end;
procedure rmdir(const s: shortstring);
begin
InOutRes:=3;
end;
procedure chdir(const s: shortstring);
begin
InOutRes:=3;
end;
procedure GetDir (DriveNr: byte; var Dir: ShortString);
begin
InOutRes:=3;
end;
{$endif FPC_HAS_FEATURE_ANSISTRINGS}

115
rtl/freertos/sysfile.inc Normal file
View File

@ -0,0 +1,115 @@
{
This file is part of the Free Pascal run time library.
Copyright (c) 2005 by Free Pascal development team
Low level file functions
GBA does not have any drive, so no file handling is needed.
Copyright (c) 2006 by Francesco Lombardi
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.
**********************************************************************}
{****************************************************************************
Low level File Routines
All these functions can set InOutRes on errors
****************************************************************************}
{ close a file from the handle value }
procedure do_close(handle : longint);
begin
end;
procedure do_erase(p : pchar; pchangeable: boolean);
begin
if assigned (@rtl_do_erase) then
rtl_do_erase(p);
end;
procedure do_rename(p1,p2 : pchar; p1changeable, p2changeable: boolean);
begin
if assigned (@rtl_do_rename) then
rtl_do_rename(p1, p2);
end;
function do_write(h: longint; addr: pointer; len: longint) : longint;
begin
if assigned (rtl_do_write) then
result := rtl_do_write(h, addr, len)
else
result := -1;
end;
function do_read(h: longint; addr: pointer; len: longint) : longint;
begin
if assigned (rtl_do_read) then
result := rtl_do_read(h, addr, len)
else
result := -1;
end;
function do_filepos(handle: longint) : longint;
begin
if assigned (rtl_do_filepos) then
result := rtl_do_filepos(handle)
else
result := -1;
end;
procedure do_seek(handle, pos: longint);
begin
if assigned (rtl_do_seek) then
rtl_do_seek(handle, pos);
end;
function do_seekend(handle: longint):longint;
begin
if assigned (rtl_do_seekend) then
result := rtl_do_seekend(handle)
else
result := -1;
end;
function do_filesize(handle : longint) : longint;
begin
result := -1;
if assigned (rtl_do_filesize) then
result := rtl_do_filesize(handle);
end;
{ truncate at a given position }
procedure do_truncate(handle, pos: longint);
begin
if assigned (rtl_do_truncate) then
rtl_do_truncate(handle, pos);
end;
procedure do_open(var f;p:PFileTextRecChar;flags:longint; pchangeable: boolean);
begin
if assigned (rtl_do_open) then
rtl_do_open(f, p, flags);
end;
function do_isdevice(handle: THandle): boolean;
begin
result := false;
if assigned (rtl_do_isdevice) then
result := rtl_do_isdevice(handle);
end;

15
rtl/freertos/sysheap.inc Normal file
View File

@ -0,0 +1,15 @@
{
This file is part of the Free Pascal run time library.
Copyright (c) 2005 by Free Pascal development team
Low level memory functions
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.
**********************************************************************}

12
rtl/freertos/sysos.inc Normal file
View File

@ -0,0 +1,12 @@
{
This file is part of the Free Pascal run time library.
Copyright (c) 2006 by Free Pascal development team
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.
**********************************************************************}

44
rtl/freertos/sysosh.inc Normal file
View File

@ -0,0 +1,44 @@
{
This file is part of the Free Pascal run time library.
Copyright (c) 2001 by Free Pascal development team
This file implements all the base types and limits required
for a minimal POSIX compliant subset required to port the compiler
to a new OS.
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.
**********************************************************************}
{Platform specific information}
type
{ fd are int in C also for 64bit targets (x86_64) }
THandle = SizeInt;
{ pthread_t is defined as an "unsigned long" }
{$ifdef CPU64}
TThreadID = QWord;
{$else}
TThreadID = THandle;
{$endif}
TOSTimestamp = Int64;
{ pthread_mutex_t }
PRTLCriticalSection = ^TRTLCriticalSection;
TRTLCriticalSection = record
__m_reserved: longint;
__m_count: longint;
__m_owner: pointer;
__m_kind: longint;
__m_lock: record
__status: sizeint;
__spinlock: longint;
end;
end;

266
rtl/freertos/system.cfg Normal file
View File

@ -0,0 +1,266 @@
# first, disable all
-Sf-
# enable required ones
# they don't add much additional code or data
-SfTEXTIO
-SfFILEIO
-SfHEAP
# uncomment to enable the stuff you want to use
# include full heap management into the rtl
# -SfHEAP
# include support for init final code of units into the rtl
# -SfINITFINAL
# -SfCLASSES
# -SfEXCEPTIONS
# -SfEXITCODE
# -SfANSISTRINGS
# -SfWIDESTRINGS
# -SfTEXTIO
# -SfCONSOLEIO
# -SfFILEIO
# -SfRANDOM
# -SfVARIANTS
# -SfOBJECTS
# -SfDYNARRAYS
# -SfTHREADING
# -SfCOMMANDARGS
# -SfPROCESSES
# -SfSTACKCHECK
# -SfDYNLIBS
# include exit code support
-SfEXITCODE
# i386 is powerful enough to handle most object pascal constructs
# it is only a matter of size
#ifdef CPUI386
-SfSOFTFPU
-SfCLASSES
-SfEXCEPTIONS
-SfANSISTRINGS
-SfRTTI
-SfWIDESTRINGS
-SfDYNARRAYS
-SfTHREADING
-SfVARIANTS
-SfOBJECTS
-SfCOMMANDARGS
-SfRANDOM
-SfRESOURCES
#endif CPUI386
# x86_64 is powerful enough to handle most object pascal constructs
# it is only a matter of size
#ifdef CPUX86_64
-SfSOFTFPU
-SfCLASSES
-SfEXCEPTIONS
-SfANSISTRINGS
-SfRTTI
-SfWIDESTRINGS
-SfDYNARRAYS
-SfTHREADING
-SfVARIANTS
-SfOBJECTS
-SfCOMMANDARGS
-SfRANDOM
-SfRESOURCES
#endif CPUX86_64
# arm is powerful enough to handle most object pascal constructs
# it is only a matter of size
#ifdef CPUARM
-SfSOFTFPU
-SfCLASSES
-SfEXCEPTIONS
-SfANSISTRINGS
-SfRTTI
-SfWIDESTRINGS
-SfDYNARRAYS
-SfTHREADING
-SfVARIANTS
-SfOBJECTS
-SfCOMMANDARGS
-SfRANDOM
-SfRESOURCES
#endif CPUARM
# mipsel is powerful enough to handle most object pascal constructs
# it is only a matter of size
#ifdef CPUMIPSEL
-SfSOFTFPU
-SfCLASSES
-SfEXCEPTIONS
-SfANSISTRINGS
-SfRTTI
-SfWIDESTRINGS
-SfDYNARRAYS
-SfTHREADING
-SfVARIANTS
-SfOBJECTS
-SfCOMMANDARGS
-SfRANDOM
-SfRESOURCES
#endif CPUMIPSEL
# mips is powerful enough to handle most object pascal constructs
# it is only a matter of size
#ifdef CPUMIPS
-SfSOFTFPU
-SfCLASSES
-SfEXCEPTIONS
-SfANSISTRINGS
-SfRTTI
-SfWIDESTRINGS
-SfDYNARRAYS
-SfTHREADING
-SfVARIANTS
-SfOBJECTS
-SfCOMMANDARGS
-SfRANDOM
-SfRESOURCES
#endif CPUMIPS
# powerpc is powerful enough to handle most object pascal constructs
# it is only a matter of size
#ifdef CPUPOWERPC
-SfSOFTFPU
-SfCLASSES
-SfEXCEPTIONS
-SfANSISTRINGS
-SfRTTI
-SfWIDESTRINGS
-SfDYNARRAYS
-SfTHREADING
-SfVARIANTS
-SfOBJECTS
-SfCOMMANDARGS
-SfRANDOM
-SfRESOURCES
#endif CPUPOWERPC
# powerpc64 is powerful enough to handle most object pascal constructs
# it is only a matter of size
#ifdef CPUPOWERPC64
-SfSOFTFPU
-SfCLASSES
-SfEXCEPTIONS
-SfANSISTRINGS
-SfRTTI
-SfWIDESTRINGS
-SfDYNARRAYS
-SfTHREADING
-SfVARIANTS
-SfOBJECTS
-SfCOMMANDARGS
-SfRANDOM
-SfRESOURCES
#endif CPUPOWERPC64
# does not require extra memory, neither code nor data
# in programs not using e. g. writeln based I/O which is the common case for AVR
#ifdef CPUAVR
-SfOBJECTS
-SfEXCEPTIONS
-SfCLASSES
-SfRTTI
# AVR6 has normally more memory, so enable more functions
#ifdef CPUAVR6
-SfANSISTRINGS
-SfWIDESTRINGS
-SfDYNARRAYS
-SfTHREADING
-SfVARIANTS
-SfOBJECTS
-SfCOMMANDARGS
-SfRANDOM
-SfRESOURCES
#endif
#endif
# Minimal set for m68k, copied from AVR above
# does not require extra memory, neither code nor data
# in programs not using e. g. writeln based I/O
#ifdef CPUM68K
-SfSOFTFPU
-SfOBJECTS
-SfEXCEPTIONS
-SfCLASSES
-SfRTTI
-SfANSISTRINGS
-SfWIDESTRINGS
-SfDYNARRAYS
-SfTHREADING
-SfVARIANTS
-SfOBJECTS
-SfCOMMANDARGS
-SfRANDOM
-SfRESOURCES
#endif
# Minimal set for i8086, copied from AVR above
# does not require extra memory, neither code nor data
# in programs not using e. g. writeln based I/OR
#ifdef CPUI8086
-SfOBJECTS
-SfEXCEPTIONS
-SfCLASSES
-SfRTTI
-Cs2048
-CX
-XX
#endif
#ifdef CPURISCV32
-SfSOFTFPU
-SfCLASSES
-SfEXCEPTIONS
-SfANSISTRINGS
-SfRTTI
-SfWIDESTRINGS
-SfDYNARRAYS
-SfTHREADING
-SfVARIANTS
-SfOBJECTS
-SfCOMMANDARGS
-SfRANDOM
-SfRESOURCES
#endif CPURISCV32
#ifdef CPURISCV64
-SfSOFTFPU
-SfCLASSES
-SfEXCEPTIONS
-SfANSISTRINGS
-SfRTTI
-SfWIDESTRINGS
-SfDYNARRAYS
-SfTHREADING
-SfVARIANTS
-SfOBJECTS
-SfCOMMANDARGS
-SfRANDOM
-SfRESOURCES
#endif CPURISCV64
# Xtensa is powerful enough to handle most object pascal constructs
# it is only a matter of size
#ifdef CPUXTENSA
-SfSOFTFPU
-SfCLASSES
-SfEXCEPTIONS
-SfANSISTRINGS
-SfRTTI
-SfWIDESTRINGS
-SfDYNARRAYS
-SfTHREADING
-SfVARIANTS
-SfOBJECTS
-SfCOMMANDARGS
-SfRANDOM
-SfRESOURCES
#endif CPUXTENSA

337
rtl/freertos/system.pp Normal file
View File

@ -0,0 +1,337 @@
{
This file is part of the Free Pascal run time library.
Copyright (c) 2006 by Florian Klaempfl
member of the Free Pascal development team.
System unit for FreeRTOS systems
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.
**********************************************************************}
Unit System;
{*****************************************************************************}
interface
{*****************************************************************************}
{$define FPC_SYSTEM_HAS_STACKTOP}
{$define FPC_IS_SYSTEM}
{$define HAS_CMDLINE}
{ currently, the avr compiler cannot compile complex procedures especially dealing with int64
which are probably anyways rarely used on avr
meanwhile, the avr compiler can deal with them (FK) }
{$ifdef CPUAVR}
{ $define EXCLUDE_COMPLEX_PROCS}
{$endif CPUAVR}
{ $define USE_NOTHREADMANAGER}
{$define DISABLE_NO_THREAD_MANAGER}
{ Do not use standard memory manager }
{$define HAS_MEMORYMANAGER}
{$define FPC_NO_DEFAULT_HEAP}
{$define FPC_ANSI_TEXTFILEREC}
{ make output and stdout as well as input and stdin equal to save memory }
{$define FPC_STDOUT_TRUE_ALIAS}
{$ifdef CPUI8086}
{$DEFINE FPC_INCLUDE_SOFTWARE_MUL}
{$DEFINE FPC_INCLUDE_SOFTWARE_MOD_DIV}
{$endif CPUI8086}
{$I check.inc}
{$I systemh.inc}
const
{$ifdef FPC_HAS_FEATURE_TEXTIO}
LineEnding = #10;
{$endif FPC_HAS_FEATURE_TEXTIO}
{$ifdef FPC_HAS_FEATURE_FILEIO}
LFNSupport = true;
DirectorySeparator = '/';
DriveSeparator = ':';
ExtensionSeparator = '.';
PathSeparator = ':';
AllowDirectorySeparators : set of char = ['\','/'];
AllowDriveSeparators : set of char = [':'];
{$endif FPC_HAS_FEATURE_FILEIO}
{ FileNameCaseSensitive and FileNameCasePreserving are defined below! }
{$ifdef FPC_HAS_FEATURE_EXITCODE}
maxExitCode = 255;
{$endif FPC_HAS_FEATURE_EXITCODE}
{$ifdef FPC_HAS_FEATURE_FILEIO}
MaxPathLen = 1024; // BSDs since 1993, Solaris 10, Darwin
AllFilesMask = '*';
UnusedHandle = -1;
StdInputHandle = 0;
StdOutputHandle = 1;
StdErrorHandle = 2;
FileNameCaseSensitive : boolean = true;
FileNameCasePreserving: boolean = true;
{$endif FPC_HAS_FEATURE_FILEIO}
{$ifdef FPC_HAS_FEATURE_TEXTIO}
CtrlZMarksEOF: boolean = false; (* #26 not considered as end of file *)
sLineBreak = LineEnding;
DefaultTextLineBreakStyle : TTextLineBreakStyle = tlbsCrLF;
{$endif FPC_HAS_FEATURE_TEXTIO}
{$ifdef CPUI8086}
{ The value that needs to be added to the segment to move the pointer by
64K bytes (BP7 compatibility) }
SelectorInc: Word = $1000;
{$endif CPUI8086}
type
trtl_do_close = procedure (handle : longint);
trtl_do_erase = procedure (p : pchar);
trtl_do_rename = procedure (p1,p2 : pchar);
trtl_do_write = function (h: longint; addr: pointer; len: longint) : longint;
trtl_do_read = function (h: longint; addr: pointer; len: longint) : longint;
trtl_do_filepos = function (handle: longint) : longint;
trtl_do_seek = procedure (handle, pos: longint);
trtl_do_seekend = function (handle: longint):longint;
trtl_do_filesize = function (handle : longint) : longint;
trtl_do_truncate = procedure (handle, pos: longint);
trtl_do_open = procedure (var f;p:pchar;flags:longint);
trtl_do_isdevice = function (handle: longint): boolean;
var
rtl_do_close : trtl_do_close = nil;
rtl_do_erase : trtl_do_erase = nil;
rtl_do_rename : trtl_do_rename = nil;
rtl_do_write : trtl_do_write = nil;
rtl_do_read : trtl_do_read = nil;
rtl_do_filepos : trtl_do_filepos = nil;
rtl_do_seek : trtl_do_seek = nil;
rtl_do_seekend : trtl_do_seekend = nil;
rtl_do_filesize : trtl_do_filesize = nil;
rtl_do_truncate : trtl_do_truncate = nil;
rtl_do_open : trtl_do_open = nil;
rtl_do_isdevice : trtl_do_isdevice = nil;
{$ifdef FPC_HAS_FEATURE_COMMANDARGS}
var
argc: LongInt = 0;
argv: PPChar = nil;
envp: PPChar = nil;
cmdline: PChar = nil;
{$endif FPC_HAS_FEATURE_COMMANDARGS}
{$ifndef FPUNONE}
{$ifdef FPC_HAS_FEATURE_SOFTFPU}
{$define fpc_softfpu_interface}
{$i softfpu.pp}
{$undef fpc_softfpu_interface}
{$endif FPC_HAS_FEATURE_SOFTFPU}
{$endif FPUNONE}
{$ifdef CPUI8086}
var
{ Mem[] support }
mem : array[0..$7fff-1] of byte absolute $0:$0;
memw : array[0..($7fff div sizeof(word))-1] of word absolute $0:$0;
meml : array[0..($7fff div sizeof(longint))-1] of longint absolute $0:$0;
__stkbottom : pointer;public name '__stkbottom';
{$endif CPUI8086}
{*****************************************************************************}
implementation
{*****************************************************************************}
{$ifdef CPUI8086}
{ used for an offset fixup for accessing the proc parameters in asm routines
that use nostackframe. We can't use the parameter name directly, because
i8086 doesn't support sp relative addressing. }
const
{$ifdef FPC_X86_CODE_FAR}
extra_param_offset = 2;
{$else FPC_X86_CODE_FAR}
extra_param_offset = 0;
{$endif FPC_X86_CODE_FAR}
{$if defined(FPC_X86_DATA_FAR) or defined(FPC_X86_DATA_HUGE)}
extra_data_offset = 2;
{$else}
extra_data_offset = 0;
{$endif}
{$endif CPUI8086}
{ Include ELF resources }
const calculated_cmdline:Pchar=nil;
{$ifndef FPUNONE}
{$ifdef FPC_HAS_FEATURE_SOFTFPU}
{$define fpc_softfpu_implementation}
{$i softfpu.pp}
{$undef fpc_softfpu_implementation}
{ we get these functions and types from the softfpu code }
{$define FPC_SYSTEM_HAS_float64}
{$define FPC_SYSTEM_HAS_float32}
{$define FPC_SYSTEM_HAS_flag}
{$define FPC_SYSTEM_HAS_extractFloat64Frac0}
{$define FPC_SYSTEM_HAS_extractFloat64Frac1}
{$define FPC_SYSTEM_HAS_extractFloat64Exp}
{$define FPC_SYSTEM_HAS_extractFloat64Frac}
{$define FPC_SYSTEM_HAS_extractFloat64Sign}
{$define FPC_SYSTEM_HAS_ExtractFloat32Frac}
{$define FPC_SYSTEM_HAS_extractFloat32Exp}
{$define FPC_SYSTEM_HAS_extractFloat32Sign}
{$endif FPC_HAS_FEATURE_SOFTFPU}
{$endif FPUNONE}
{$define FPC_SYSTEM_EXIT_NO_RETURN}
{$I system.inc}
{*****************************************************************************
Misc. System Dependent Functions
*****************************************************************************}
var
_stack_top: record end; external name '_stack_top';
function StackTop: pointer;
begin
StackTop:=@_stack_top;
end;
procedure haltproc;cdecl;external name '_haltproc';
procedure System_exit;noreturn;external name '_haltproc';
{$ifdef FPC_HAS_FEATURE_PROCESSES}
function GetProcessID: SizeUInt;
begin
GetProcessID := 0;
end;
{$endif}
{$ifdef FPC_HAS_FEATURE_COMMANDARGS}
Function ParamCount: Longint;
Begin
Paramcount:=argc-1
End;
function paramstr(l: longint) : string;
begin
paramstr := '';
end;
{$endif FPC_HAS_FEATURE_COMMANDARGS}
const
QRAN_SHIFT = 15;
QRAN_MASK = ((1 shl QRAN_SHIFT) - 1);
QRAN_MAX = QRAN_MASK;
QRAN_A = 1664525;
QRAN_C = 1013904223;
{$ifdef FPC_HAS_FEATURE_RANDOM}
procedure randomize();
begin
RandSeed := 63458;
end;
procedure randomize(value: integer);
begin
RandSeed := value;
end;
function random(): integer;
begin
RandSeed := QRAN_A * RandSeed + QRAN_C;
random := (RandSeed shr 16) and QRAN_MAX;
end;
function random(value: integer): integer;
var
a: integer;
begin
RandSeed := QRAN_A * RandSeed + QRAN_C;
a := (RandSeed shr 16) and QRAN_MAX;
random := (a * value) shr 15;
end;
{$endif FPC_HAS_FEATURE_RANDOM}
{*****************************************************************************
SystemUnit Initialization
*****************************************************************************}
{$ifdef FPC_HAS_FEATURE_STACKCHECK}
function CheckInitialStkLen(stklen : SizeUInt) : SizeUInt;inline;
begin
result := stklen;
end;
var
initialstkptr : record end; external name '_stack_top';
{$endif FPC_HAS_FEATURE_STACKCHECK}
begin
{ FPU (hard or soft) is initialized from fpc_cpuinit, which is included
per-cpu unconditionally.
SysResetFPU;
if not(IsLibrary) then
SysInitFPU;
}
{$ifdef FPC_HAS_FEATURE_CONSOLEIO}
IsConsole := TRUE;
{$endif FPC_HAS_FEATURE_CONSOLEIO}
{$ifdef FPC_HAS_FEATURE_STACKCHECK}
StackLength := CheckInitialStkLen(initialStkLen);
StackBottom := @initialstkptr - StackLength;
{$endif FPC_HAS_FEATURE_STACKCHECK}
{$ifdef FPC_HAS_FEATURE_EXCEPTIONS}
{ SysInitExceptions initializes only ExceptObjectstack and ExceptAddrStack
with nil since both are located in the bss section, they are zeroed at startup
anyways so not calling SysInitExceptions saves some bytes for simple programs. Even for threaded
programs this does not matter because in the main thread, the variables are located
in bss
SysInitExceptions;
}
{$endif FPC_HAS_FEATURE_EXCEPTIONS}
{$ifdef FPC_HAS_FEATURE_CONSOLEIO}
{ Reset IO Error }
InOutRes:=0;
{$endif FPC_HAS_FEATURE_CONSOLEIO}
{$ifdef FPC_HAS_FEATURE_THREADING}
{ threading }
//InitSystemThreads; // Empty call for embedded anyway
{$endif FPC_HAS_FEATURE_THREADING}
{$ifdef FPC_HAS_FEATURE_WIDESTRINGS}
// initunicodestringmanager;
{$endif FPC_HAS_FEATURE_WIDESTRINGS}
end.

21
rtl/freertos/systhrd.inc Normal file
View File

@ -0,0 +1,21 @@
{
This file is part of the Free Pascal run time library.
Copyright (c) 2002 by Peter Vreman,
member of the Free Pascal development team.
Embedded empty threading support implementation
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.
**********************************************************************}
Procedure InitSystemThreads;
begin
end;

296
rtl/freertos/sysutils.pp Normal file
View File

@ -0,0 +1,296 @@
{
This file is part of the Free Pascal run time library.
Copyright (c) 2004 by the Free Pascal development team
Sysutils unit for the FreeRTOS target.
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.
**********************************************************************}
{$MODE objfpc}
{$MODESWITCH OUT}
{$H+}
unit sysutils;
interface
{$DEFINE HAS_SLEEP}
{$DEFINE HAS_OSERROR}
{$modeswitch typehelpers}
{$modeswitch advancedrecords}
{ used OS file system APIs use ansistring }
{$define SYSUTILS_HAS_ANSISTR_FILEUTIL_IMPL}
{ OS has an ansistring/single byte environment variable API }
{$define SYSUTILS_HAS_ANSISTR_ENVVAR_IMPL}
{ Include platform independent interface part }
{$i sysutilh.inc}
var
SleepHandler: procedure(ms: cardinal) = nil;
implementation
uses
sysconst,heapmgr;
{ Include platform independent implementation part }
{$i sysutils.inc}
{****************************************************************************
File Functions
****************************************************************************}
function FileOpen(const FileName: RawByteString; Mode: Integer): THandle;
begin
result := -1;
end;
function FileGetDate(Handle: THandle) : TOSTimestamp;
begin
result := -1;
end;
function FileSetDate(Handle: THandle; Age: TOSTimestamp) : Longint;
begin
result := -1;
end;
function FileCreate(const FileName: RawByteString) : THandle;
begin
result := -1;
end;
function FileCreate(const FileName: RawByteString; Rights: integer): THandle;
begin
result := -1;
end;
function FileCreate(const FileName: RawByteString; ShareMode: integer; rights : integer): THandle;
begin
result := -1;
end;
function FileRead(Handle: THandle; Out Buffer; Count: LongInt): LongInt;
begin
result := -1;
end;
function FileWrite(Handle: THandle; const Buffer; Count: LongInt): LongInt;
begin
result := -1;
end;
function FileSeek(Handle: THandle; FOffset, Origin: LongInt) : LongInt;
begin
result := -1;
end;
function FileSeek(Handle: THandle; FOffset: Int64; Origin: Longint): Int64;
begin
result := -1;
end;
procedure FileClose(Handle: THandle);
begin
end;
function FileTruncate(Handle: THandle; Size: Int64): Boolean;
begin
result := false;
end;
function DeleteFile(const FileName: RawByteString) : Boolean;
begin
result := false;
end;
function RenameFile(const OldName, NewName: RawByteString): Boolean;
begin
result := false;
end;
Function FileAge (Const FileName : RawByteString): TOSTimestamp;
begin
result := -1;
end;
function FileGetSymLinkTarget(const FileName: RawByteString; out SymLinkRec: TRawbyteSymLinkRec): Boolean;
begin
Result := False;
end;
Function FileExists (Const FileName : RawByteString; FollowLink : Boolean) : Boolean;
Begin
result := false;
end;
Function InternalFindFirst (Const Path : RawByteString; Attr : Longint; out Rslt : TAbstractSearchRec; var Name: RawByteString) : Longint;
begin
result := -1;
end;
Function InternalFindNext (var Rslt : TAbstractSearchRec; var Name : RawByteString) : Longint;
begin
result := -1;
end;
Procedure InternalFindClose(var Handle: THandle);
begin
end;
Function FileGetAttr (Const FileName : RawByteString) : Longint;
begin
result := -1;
end;
Function FileSetAttr (Const Filename : RawByteString; Attr: longint) : Longint;
begin
result := -1;
end;
{****************************************************************************
Disk Functions
****************************************************************************}
Procedure AddDisk(const path:string);
begin
end;
Function DiskFree(Drive: Byte): int64;
Begin
result := -1;
End;
Function DiskSize(Drive: Byte): int64;
Begin
result := -1;
End;
function DirectoryExists(const Directory: RawByteString; FollowLink : Boolean): Boolean;
begin
result := false;
end;
{****************************************************************************
Misc Functions
****************************************************************************}
procedure sysBeep;
begin
end;
Procedure Sleep(Milliseconds : Cardinal);
begin
if assigned(SleepHandler) then
SleepHandler(Milliseconds);
end;
Function GetLastOSError : Integer;
begin
Result:=-1;
end;
{****************************************************************************
Locale Functions
****************************************************************************}
Procedure GetLocalTime(var SystemTime: TSystemTime);
begin
end ;
function SysErrorMessage(ErrorCode: Integer): String;
begin
{ Result:=StrError(ErrorCode);}
result := '';
end;
{****************************************************************************
OS utility functions
****************************************************************************}
Function GetEnvironmentVariable(Const EnvVar : String) : String;
begin
result := '';
end;
Function GetEnvironmentVariableCount : Integer;
begin
result := -1;
end;
Function GetEnvironmentString(Index : Integer) : {$ifdef FPC_RTL_UNICODE}UnicodeString{$else}AnsiString{$endif};
begin
result := '';
end;
function ExecuteProcess (const Path: RawByteString; const ComLine: RawByteString;Flags:TExecuteFlags=[]): integer;
begin
result := -1;
end;
function ExecuteProcess (const Path: RawByteString;
const ComLine: array of RawByteString;Flags:TExecuteFlags=[]): integer;
begin
result := -1;
end;
function ExecuteProcess (const Path: UnicodeString; const ComLine: UnicodeString;Flags:TExecuteFlags=[]): integer;
begin
result := -1;
end;
function ExecuteProcess (const Path: UnicodeString;
const ComLine: array of UnicodeString;Flags:TExecuteFlags=[]): integer;
begin
result := -1;
end;
{****************************************************************************
Initialization code
****************************************************************************}
Initialization
InitExceptions;
Finalization
FreeTerminateProcs;
DoneExceptions;
end.

111
rtl/freertos/tthread.inc Normal file
View File

@ -0,0 +1,111 @@
{
This file is part of the Free Component Library (FCL)
Copyright (c) 1999-2002 by the Free Pascal development team
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.
**********************************************************************}
{****************************************************************************}
{* TThread *}
{****************************************************************************}
{$WARNING This file is only a stub, and will not work!}
const
ThreadCount: longint = 0;
(* Implementation of exported functions *)
procedure AddThread (T: TThread);
begin
Inc (ThreadCount);
end;
procedure RemoveThread (T: TThread);
begin
Dec (ThreadCount);
end;
procedure TThread.CallOnTerminate;
begin
FOnTerminate (Self);
end;
function TThread.GetPriority: TThreadPriority;
begin
result := tpNormal;
end;
procedure TThread.SetPriority(Value: TThreadPriority);
begin
end;
procedure TThread.SetSuspended(Value: Boolean);
begin
if Value <> FSuspended then
begin
if Value then Suspend else Resume;
end;
end;
procedure TThread.DoTerminate;
begin
if Assigned (FOnTerminate) then Synchronize (@CallOnTerminate);
end;
procedure TThread.SysCreate(CreateSuspended: Boolean;
const StackSize: SizeUInt);
var
Flags: cardinal;
begin
AddThread (Self);
end;
procedure TThread.SysDestroy;
begin
if not FFinished and not Suspended then
begin
Terminate;
WaitFor;
end;
end;
procedure TThread.Resume;
begin
end;
procedure TThread.Suspend;
begin
end;
procedure TThread.Terminate;
begin
FTerminated := true;
end;
function TThread.WaitFor: Integer;
begin
result := -1;
end;

View File

@ -0,0 +1,58 @@
{******************************************************************************
Startup code for xtensa-esp32 using idf
******************************************************************************}
unit esp32;
{$goto on}
{$macro on}
interface
implementation
uses
consoleio,heapmgr;
var
_stack_top: record end; public name '_stack_top';
procedure PASCALMAIN; external name 'PASCALMAIN';
procedure esp_deep_sleep_start;external;
procedure putchar(c : char);external;
function getchar : char;external;
procedure _FPC_haltproc; public name '_haltproc';noreturn;
begin
while true do
esp_deep_sleep_start;
end;
procedure app_main;public name 'app_main';noreturn;
begin
PASCALMAIN;
_FPC_haltproc;
end;
function WriteChar(ACh: char; AUserData: pointer): boolean;
begin
WriteChar:=true;
putchar(ACh);
end;
function ReadChar(var ACh: char; AUserData: pointer): boolean;
begin
ReadChar:=true;
ACh:=getchar;
end;
begin
OpenIO(Input, @WriteChar, @ReadChar, fmInput, nil);
OpenIO(Output, @WriteChar, @ReadChar, fmOutput, nil);
OpenIO(ErrOutput, @WriteChar, @ReadChar, fmOutput, nil);
OpenIO(StdOut, @WriteChar, @ReadChar, fmOutput, nil);
OpenIO(StdErr, @WriteChar, @ReadChar, fmOutput, nil);
end.

View File

@ -69,6 +69,10 @@ var
{$define FPC_NO_DEFAULT_MEMORYMANAGER}
{$endif EMBEDDED}
{$ifdef FREERTOS}
{$define FPC_NO_DEFAULT_MEMORYMANAGER}
{$endif FREERTOS}
{$ifndef FPC_NO_DEFAULT_MEMORYMANAGER}
{ Default MemoryManager functions }
Function SysGetmem(Size:ptruint):Pointer;

View File

@ -1582,10 +1582,12 @@ Procedure Halt;{$ifdef SYSTEMINLINE}inline;{$endif}noreturn;
Procedure SysInitExceptions;
{$endif FPC_HAS_FEATURE_EXCEPTIONS}
{$ifdef FPC_HAS_FEATURE_CONSOLEIO}
{$ifndef EMBEDDED}
{$if not(defined(EMBEDDED)) and not(defined(FREERTOS))}
procedure SysInitStdIO;
procedure SysFlushStdIO;
{$endif EMBEDDED}
{$endif not(defined(EMBEDDED)) and not(defined(FREERTOS))}
{$endif FPC_HAS_FEATURE_CONSOLEIO}
{$ifndef FPUNONE}
Procedure SysResetFPU;

View File

@ -101,7 +101,7 @@ interface
'palmos','macos','darwin','emx','watcom','morphos','netwlibc',
'win64','wince','gba','nds','embedded','symbian','nativent',
'iphonesim', 'wii', 'aix', 'java', 'android', 'msdos', 'aros',
'dragonfly', 'win16', 'wasm', 'FreeRTOS'
'dragonfly', 'win16', 'wasm', 'freertos'
);
OSSuffix : array[TOS] of string=(