human68k: more work on getting tinyheap right. still doesn't seem to work, sadly, so still disabled

This commit is contained in:
Karoly Balogh 2023-12-03 12:12:27 +01:00
parent b81b818a75
commit a4c94c8b44
3 changed files with 39 additions and 3 deletions
compiler
rtl/human68k

View File

@ -125,6 +125,12 @@ implementation
system_powerpc_morphos,
system_x86_64_aros:
include(supported_calling_conventions,pocall_syscall);
system_m68k_human68k:
begin
include(supported_calling_conventions,pocall_syscall);
if heapsize=0 then
heapsize:=65536;
end;
{$ifdef i8086}
system_i8086_embedded:
begin

View File

@ -17,6 +17,8 @@ unit si_prc;
interface
{$.define FPC_HUMAN68K_USE_TINYHEAP}
implementation
{$include h68kdos.inc}
@ -24,6 +26,10 @@ implementation
var
stacktop: pointer; public name '__stktop';
stklen: longint; external name '__stklen';
{$ifdef FPC_HUMAN68K_USE_TINYHEAP}
initial_heap_start: pointer; external name '__initial_heap_start';
initial_heap_end: pointer; external name '__initial_heap_end';
{$endif FPC_HUMAN68K_USE_TINYHEAP}
var
h68k_startup: Th68kdos_startup; public name '_h68k_startup';
@ -45,6 +51,7 @@ end;
procedure PascalStart(const startparams: Ph68kdos_startup); noreturn;
var
bss_start: pbyte;
blocksize: longint;
begin
with startparams^ do
begin
@ -53,8 +60,17 @@ begin
fillchar(bss_start^,bss_end-bss_start,0);
h68k_psp:=pointer(@mcb[$10]);
h68kdos_setblock(h68k_psp,bss_end-pointer(h68k_psp)+stklen);
{$ifdef FPC_HUMAN68K_USE_TINYHEAP}
blocksize:=bss_end-pointer(h68k_psp)+stklen+heapsize;
{$else FPC_HUMAN68K_USE_TINYHEAP}
blocksize:=bss_end-pointer(h68k_psp)+stklen;
{$endif FPC_HUMAN68K_USE_TINYHEAP}
h68kdos_setblock(h68k_psp,blocksize);
stacktop:=bss_end+stklen;
{$ifdef FPC_HUMAN68K_USE_TINYHEAP}
initial_heap_start:=stacktop;
initial_heap_end:=initial_heap_start+heapsize;
{$endif FPC_HUMAN68K_USE_TINYHEAP}
end;
h68k_startup:=startparams^;

View File

@ -112,6 +112,11 @@ var
h68k_startup: Th68kdos_startup; external name '_h68k_startup';
h68k_psp: Ph68kdos_psp; external name '_h68k_psp';
{$ifdef FPC_HUMAN68K_USE_TINYHEAP}
initial_heap_start: pointer; public name '__initial_heap_start';
initial_heap_end: pointer; public name '__initial_heap_end';
{$endif FPC_HUMAN68K_USE_TINYHEAP}
{*****************************************************************************
ParamStr
@ -242,6 +247,17 @@ end;
System Unit Initialization
*****************************************************************************}
{$ifdef FPC_HUMAN68K_USE_TINYHEAP}
procedure InitHeap;
var
aligned_heap_start: pointer;
begin
aligned_heap_start:=align(initial_heap_start,sizeof(ttinyheapblock));
RegisterTinyHeapBlock_Simple_Prealigned(aligned_heap_start, ptruint(initial_heap_end - aligned_heap_start));
end;
{$endif FPC_HUMAN68K_USE_TINYHEAP}
procedure SysInitStdIO;
begin
OpenStdIO(Input,fmInput,StdInputHandle);
@ -263,10 +279,8 @@ begin
StackLength := CheckInitialStkLen (InitialStkLen);
{ Initialize ExitProc }
ExitProc:=Nil;
{$ifndef FPC_HUMAN68K_USE_TINYHEAP}
{ Setup heap }
InitHeap;
{$endif FPC_HUMAN68K_USE_TINYHEAP}
SysInitExceptions;
{$ifdef FPC_HAS_FEATURE_UNICODESTRINGS}
InitUnicodeStringManager;