m68k: Test68000/Test68881 support boilerplate and special support for Amiga

git-svn-id: trunk@35194 -
This commit is contained in:
Károly Balogh 2016-12-24 21:11:06 +00:00
parent 568048d8ac
commit 7d2360eb0c
4 changed files with 52 additions and 9 deletions

View File

@ -28,12 +28,18 @@
AmigaOS functions AmigaOS functions
*****************************************************************************} *****************************************************************************}
{ exec.library functions }
{$include execf.inc} {$include execf.inc}
{$include doslibf.inc} {$include doslibf.inc}
{*****************************************************************************
CPU specific
*****************************************************************************}
{$ifdef cpum68k}
{$include m68kamiga.inc}
{$endif}
{***************************************************************************** {*****************************************************************************
System Dependent Structures/Consts System Dependent Structures/Consts
*****************************************************************************} *****************************************************************************}

View File

@ -1,9 +1,9 @@
{ {
This file is part of the Free Pascal run time library. This file is part of the Free Pascal run time library.
Copyright (c) 2015 by Karoly Balogh, Copyright (c) 2015-2016 by Karoly Balogh,
member of the Free Pascal development team. member of the Free Pascal development team.
m68k/Amiga atomic operations implementation Amiga specific m68k functions
See the file COPYING.FPC, included in this distribution, See the file COPYING.FPC, included in this distribution,
for details about the copyright. for details about the copyright.
@ -20,6 +20,7 @@
the ops themselves. It of course won't be hardware-atomic, but should the ops themselves. It of course won't be hardware-atomic, but should
be safe for multithreading. (KB) } be safe for multithreading. (KB) }
{$DEFINE FPC_SYSTEM_HAS_INTERLOCKEDFUNCS}
function InterLockedDecrement (var Target: longint) : longint; function InterLockedDecrement (var Target: longint) : longint;
begin begin
Forbid; Forbid;
@ -64,3 +65,25 @@ function InterlockedCompareExchange(var Target: longint; NewValue: longint; Comp
Target := NewValue; Target := NewValue;
Permit; Permit;
end; end;
{ AmigaOS tells us what CPU we run on, so just use that }
{$DEFINE FPC_SYSTEM_HAS_TEST68K}
procedure Test68k(var CPU: byte; var FPU: byte);
var
flags: DWord;
begin
flags:=PExecBase(AOS_ExecBase)^.AttnFlags;
CPU:=0;
if (flags and AFF_68010) > 0 then CPU:=1;
if (flags and AFF_68020) > 0 then CPU:=2;
if (flags and AFF_68030) > 0 then CPU:=3;
if (flags and AFF_68040) > 0 then CPU:=4;
if (flags and AFF_68060) > 0 then CPU:=6;
FPU:=0;
if (flags and AFF_68881) > 0 then FPU:=1;
if (flags and AFF_68882) > 0 then FPU:=2;
if (flags and AFF_FPU40) > 0 then FPU:=CPU; // 040 or 060 with FPU
end;

View File

@ -115,9 +115,6 @@ implementation
{$I system.inc} {$I system.inc}
{$I osdebug.inc} {$I osdebug.inc}
{$ifdef cpum68k}
{$I m68kamiga.inc}
{$endif}
{$IFDEF AMIGAOS4} {$IFDEF AMIGAOS4}
// Required to allow opening of utility library interface... // Required to allow opening of utility library interface...
@ -318,6 +315,9 @@ begin
{ Setup heap } { Setup heap }
InitHeap; InitHeap;
SysInitExceptions; SysInitExceptions;
{$ifdef cpum68k}
fpc_cpucodeinit;
{$endif}
initunicodestringmanager; initunicodestringmanager;
{ Setup stdin, stdout and stderr } { Setup stdin, stdout and stderr }
SysInitStdIO; SysInitStdIO;

View File

@ -371,7 +371,7 @@ asm
end; end;
{$endif} {$endif}
{$IFNDEF HASAMIGA} {$IFNDEF FPC_SYSTEM_HAS_INTERLOCKEDFUNCS}
function InterLockedDecrement (var Target: longint) : longint; function InterLockedDecrement (var Target: longint) : longint;
begin begin
{$warning FIX ME} {$warning FIX ME}
@ -411,7 +411,16 @@ function InterlockedCompareExchange(var Target: longint; NewValue: longint; Comp
if Target = Comperand then if Target = Comperand then
Target := NewValue; Target := NewValue;
end; end;
{$ENDIF HASAMIGA} {$ENDIF FPC_SYSTEM_HAS_INTERLOCKEDFUNCS}
{$ifndef FPC_SYSTEM_HAS_TEST68K}
procedure Test68k(var CPU: byte; var FPU: byte);
begin
{$warning Implement me!}
CPU:=0;
FPU:=0;
end;
{$endif}
{$if defined(CPUM68K_HAS_BYTEREV) or defined(CPUM68K_HAS_ROLROR)} {$if defined(CPUM68K_HAS_BYTEREV) or defined(CPUM68K_HAS_ROLROR)}
{ Disabled for now, because not all cases below were tested. (KB) } { Disabled for now, because not all cases below were tested. (KB) }
@ -585,3 +594,8 @@ asm
{$endif} {$endif}
end; end;
{$endif FPC_SYSTEM_HAS_SWAPENDIAN} {$endif FPC_SYSTEM_HAS_SWAPENDIAN}
procedure fpc_cpucodeinit;
begin
Test68k(Test68000,Test68881);
end;