3
This file is part of the Free Pascal run time library.
4
Copyright (c) 2003 by the Free Pascal development team.
6
Processor dependent implementation for the system unit for
9
See the file COPYING.FPC, included in this distribution,
10
for details about the copyright.
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
**********************************************************************}
21
cpu_has_edsp : boolean = false;
22
in_edsp_test : boolean = false;
24
procedure fpc_cpuinit;
26
{$if not(defined(wince)) and not(defined(gba)) and not(defined(nds)) and not(defined(FPUSOFT)) and not(defined(FPULIBGCC))}
27
{ Enable FPU exceptions, but disable INEXACT, UNDERFLOW, DENORMAL }
38
function _controlfp(new: DWORD; mask: DWORD): DWORD; cdecl; external 'coredll';
40
{$define FPC_SYSTEM_HAS_SYSRESETFPU}
41
Procedure SysResetFPU;{$ifdef SYSTEMINLINE}inline;{$endif}
43
softfloat_exception_flags:=0;
44
softfloat_exception_mask:=float_flag_underflow or float_flag_inexact or float_flag_denormal;
45
{ Enable FPU exceptions, but disable INEXACT, UNDERFLOW, DENORMAL }
46
{ FPU precision 64 bit, rounding to nearest, affine infinity }
47
_controlfp($000C0003, $030F031F);
51
{****************************************************************************
52
stack frame related stuff
53
****************************************************************************}
55
{$IFNDEF INTERNAL_BACKTRACE}
56
{$define FPC_SYSTEM_HAS_GET_FRAME}
57
function get_frame:pointer;assembler;nostackframe;{$ifdef SYSTEMINLINE}inline;{$endif}
61
{$ENDIF not INTERNAL_BACKTRACE}
63
{$define FPC_SYSTEM_HAS_GET_CALLER_ADDR}
64
function get_caller_addr(framebp:pointer):pointer;assembler;{$ifdef SYSTEMINLINE}inline;{$endif}
73
{$define FPC_SYSTEM_HAS_GET_CALLER_FRAME}
74
function get_caller_frame(framebp:pointer):pointer;assembler;{$ifdef SYSTEMINLINE}inline;{$endif}
83
{$define FPC_SYSTEM_HAS_SPTR}
84
Function Sptr : pointer;assembler;{$ifdef SYSTEMINLINE}inline;{$endif}
90
{$define FPC_SYSTEM_HAS_FILLCHAR}
91
Procedure FillChar(var x;count:longint;value:byte);assembler;nostackframe;
97
cmp r1,#8 // at least 8 bytes to do?
102
tst r3,#3 // aligned yet?
108
cmp r1,#8 // 8 bytes still to do?
112
cmp r1,#8 // 8 bytes still to do?
116
cmp r1,#8 // 8 bytes still to do?
120
cmp r1,#8 // 8 bytes still to do?
125
movs r1,r1 // anything left?
141
{$ifndef FPC_SYSTEM_HAS_MOVE}
142
{$define FPC_SYSTEM_HAS_MOVE}
143
{$define FPC_SYSTEM_FPC_MOVE}
144
procedure Move_pld(const source;var dest;count:longint);assembler;nostackframe;
157
// overlap, copy backward
165
// less then 16 bytes to copy?
167
// yes, the forget about the whole optimizations
168
// and do a bytewise copy
178
// alignment to 4 byte boundries is enough
183
bne .Ldifferentaligned
215
procedure Move_blended(const source;var dest;count:longint);assembler;nostackframe;
226
// overlap, copy backward
234
// less then 16 bytes to copy?
236
// yes, the forget about the whole optimizations
237
// and do a bytewise copy
247
// alignment to 4 byte boundries is enough
252
bne .Ldifferentaligned
281
moveproc : pointer = @move_blended;
283
procedure Move(const source;var dest;count:longint);[public, alias: 'FPC_MOVE'];assembler;nostackframe;
291
{$endif FPC_SYSTEM_HAS_MOVE}
294
fpc_system_lock: longint; export name 'fpc_system_lock';
296
function InterLockedDecrement (var Target: longint) : longint; assembler; nostackframe;
299
ldr r3, .Lfpc_system_lock
315
.long fpc_system_lock
319
function InterLockedIncrement (var Target: longint) : longint; assembler; nostackframe;
322
ldr r3, .Lfpc_system_lock
338
.long fpc_system_lock
342
function InterLockedExchange (var Target: longint;Source : longint) : longint; assembler; nostackframe;
348
function InterLockedExchangeAdd (var Target: longint;Source : longint) : longint; assembler; nostackframe;
351
ldr r3, .Lfpc_system_lock
368
.long fpc_system_lock
372
function InterlockedCompareExchange(var Target: longint; NewValue: longint; Comperand: longint): longint; assembler; nostackframe;
375
ldr r12, .Lfpc_system_lock
392
.long fpc_system_lock
395
{$define FPC_SYSTEM_HAS_DECLOCKED_LONGINT}
396
function declocked(var l: longint) : boolean; inline;
398
Result:=InterLockedDecrement(l) = 0;
401
{$define FPC_SYSTEM_HAS_INCLOCKED_LONGINT}
402
procedure inclocked(var l: longint); inline;
404
InterLockedIncrement(l);
407
procedure fpc_cpucodeinit;
415
{$ifdef FPC_SYSTEM_FPC_MOVE}
419
moveproc:=@move_blended;
420
{$endif FPC_SYSTEM_FPC_MOVE}