mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-11 12:46:06 +02:00
+ sysv style syscalls added for MorphOS
This commit is contained in:
parent
ddb2628712
commit
088575dc32
@ -271,6 +271,10 @@ interface
|
|||||||
palmos_applicationid : string[4] = 'FPCA';
|
palmos_applicationid : string[4] = 'FPCA';
|
||||||
{$endif m68k}
|
{$endif m68k}
|
||||||
|
|
||||||
|
{$ifdef powerpc}
|
||||||
|
{ default calling convention used on MorphOS }
|
||||||
|
syscall_convention : string = 'LEGACY';
|
||||||
|
{$endif powerpc}
|
||||||
|
|
||||||
procedure abstract;
|
procedure abstract;
|
||||||
|
|
||||||
@ -2169,7 +2173,10 @@ end;
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.156 2005-01-04 16:20:51 florian
|
Revision 1.157 2005-01-04 17:40:33 karoly
|
||||||
|
+ sysv style syscalls added for MorphOS
|
||||||
|
|
||||||
|
Revision 1.156 2005/01/04 16:20:51 florian
|
||||||
* fixed nan et al. handling on arm
|
* fixed nan et al. handling on arm
|
||||||
|
|
||||||
Revision 1.155 2004/12/28 20:43:01 hajny
|
Revision 1.155 2004/12/28 20:43:01 hajny
|
||||||
|
@ -1208,6 +1208,24 @@ begin
|
|||||||
{$ifdef powerpc}
|
{$ifdef powerpc}
|
||||||
if target_info.system in [system_powerpc_morphos,system_m68k_amiga] then
|
if target_info.system in [system_powerpc_morphos,system_m68k_amiga] then
|
||||||
begin
|
begin
|
||||||
|
if idtoken=_LEGACY then
|
||||||
|
begin
|
||||||
|
consume(_LEGACY);
|
||||||
|
include(pd.procoptions,po_syscall_legacy);
|
||||||
|
end
|
||||||
|
else if idtoken=_SYSV then
|
||||||
|
begin
|
||||||
|
consume(_SYSV);
|
||||||
|
include(pd.procoptions,po_syscall_sysv);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if syscall_convention='LEGACY' then
|
||||||
|
include(pd.procoptions,po_syscall_legacy)
|
||||||
|
else if syscall_convention='SYSV' then
|
||||||
|
include(pd.procoptions,po_syscall_sysv)
|
||||||
|
else
|
||||||
|
internalerror(2005010404);
|
||||||
|
|
||||||
if consume_sym(sym,symtable) then
|
if consume_sym(sym,symtable) then
|
||||||
begin
|
begin
|
||||||
if (sym.typ=globalvarsym) and
|
if (sym.typ=globalvarsym) and
|
||||||
@ -1217,13 +1235,16 @@ begin
|
|||||||
) then
|
) then
|
||||||
begin
|
begin
|
||||||
tprocdef(pd).libsym:=sym;
|
tprocdef(pd).libsym:=sym;
|
||||||
vs:=tparavarsym.create('$syscalllib',paranr_syscall,vs_value,tabstractvarsym(sym).vartype,[vo_is_syscall_lib,vo_is_hidden_para,vo_has_explicit_paraloc]);
|
if po_syscall_legacy in tprocdef(pd).procoptions then
|
||||||
paramanager.parseparaloc(vs,'A6');
|
begin
|
||||||
pd.parast.insert(vs);
|
vs:=tparavarsym.create('$syscalllib',paranr_syscall,vs_value,tabstractvarsym(sym).vartype,[vo_is_syscall_lib,vo_is_hidden_para,vo_has_explicit_paraloc]);
|
||||||
|
paramanager.parseparaloc(vs,'A6');
|
||||||
|
pd.parast.insert(vs);
|
||||||
|
end;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
Message(parser_e_32bitint_or_pointer_variable_expected);
|
Message(parser_e_32bitint_or_pointer_variable_expected);
|
||||||
end;
|
end;
|
||||||
(paramanager as tppcparamanager).create_funcretloc_info(pd,calleeside);
|
(paramanager as tppcparamanager).create_funcretloc_info(pd,calleeside);
|
||||||
(paramanager as tppcparamanager).create_funcretloc_info(pd,callerside);
|
(paramanager as tppcparamanager).create_funcretloc_info(pd,callerside);
|
||||||
end;
|
end;
|
||||||
@ -2344,7 +2365,10 @@ const
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.222 2004-12-27 17:32:06 peter
|
Revision 1.223 2005-01-04 17:40:33 karoly
|
||||||
|
+ sysv style syscalls added for MorphOS
|
||||||
|
|
||||||
|
Revision 1.222 2004/12/27 17:32:06 peter
|
||||||
* don't parse public,private,protected as procdirectives, leave
|
* don't parse public,private,protected as procdirectives, leave
|
||||||
procdirective parsing before any other check is done
|
procdirective parsing before any other check is done
|
||||||
|
|
||||||
|
@ -67,6 +67,7 @@ implementation
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure tppccallnode.do_syscall;
|
procedure tppccallnode.do_syscall;
|
||||||
var
|
var
|
||||||
tmpref: treference;
|
tmpref: treference;
|
||||||
@ -74,32 +75,61 @@ implementation
|
|||||||
case target_info.system of
|
case target_info.system of
|
||||||
system_powerpc_morphos:
|
system_powerpc_morphos:
|
||||||
begin
|
begin
|
||||||
cg.getcpuregister(exprasmlist,NR_R0);
|
if po_syscall_sysv in tprocdef(procdefinition).procoptions then
|
||||||
cg.getcpuregister(exprasmlist,NR_R3);
|
begin
|
||||||
|
cg.getcpuregister(exprasmlist,NR_R0);
|
||||||
|
cg.getcpuregister(exprasmlist,NR_R31);
|
||||||
|
|
||||||
|
reference_reset(tmpref);
|
||||||
|
tmpref.symbol := objectlibrary.newasmsymbol(tglobalvarsym(tprocdef(procdefinition).libsym).mangledname,AB_EXTERNAL,AT_DATA);
|
||||||
|
tmpref.refaddr := addr_hi;
|
||||||
|
exprasmlist.concat(taicpu.op_reg_ref(A_LIS,NR_R31,tmpref));
|
||||||
|
tmpref.base := NR_R31;
|
||||||
|
tmpref.refaddr := addr_lo;
|
||||||
|
exprasmlist.concat(taicpu.op_reg_ref(A_LWZ,NR_R31,tmpref));
|
||||||
|
|
||||||
|
exprasmlist.concat(taicpu.op_reg_reg_const(A_ADDI,NR_R0,NR_R31,-tprocdef(procdefinition).extnumber));
|
||||||
|
exprasmlist.concat(taicpu.op_reg(A_MTCTR,NR_R0));
|
||||||
|
exprasmlist.concat(taicpu.op_none(A_BCTRL));
|
||||||
|
|
||||||
{ store call offset into R3 }
|
cg.ungetcpuregister(exprasmlist,NR_R31);
|
||||||
exprasmlist.concat(taicpu.op_reg_const(A_LI,NR_R3,-tprocdef(procdefinition).extnumber));
|
cg.ungetcpuregister(exprasmlist,NR_R0);
|
||||||
|
end
|
||||||
|
else if po_syscall_legacy in tprocdef(procdefinition).procoptions then
|
||||||
|
begin
|
||||||
|
cg.getcpuregister(exprasmlist,NR_R0);
|
||||||
|
cg.getcpuregister(exprasmlist,NR_R3);
|
||||||
|
|
||||||
{ prepare LR, and call function }
|
{ store call offset into R3 }
|
||||||
reference_reset_base(tmpref,NR_R2,100); { 100 ($64) is EmulDirectCallOS offset }
|
exprasmlist.concat(taicpu.op_reg_const(A_LI,NR_R3,-tprocdef(procdefinition).extnumber));
|
||||||
exprasmlist.concat(taicpu.op_reg_ref(A_LWZ,NR_R0,tmpref));
|
|
||||||
exprasmlist.concat(taicpu.op_reg(A_MTLR,NR_R0));
|
|
||||||
exprasmlist.concat(taicpu.op_none(A_BLRL));
|
|
||||||
|
|
||||||
cg.ungetcpuregister(exprasmlist,NR_R0);
|
{ prepare LR, and call function }
|
||||||
cg.ungetcpuregister(exprasmlist,NR_R3);
|
reference_reset_base(tmpref,NR_R2,100); { 100 ($64) is EmulDirectCallOS offset }
|
||||||
|
exprasmlist.concat(taicpu.op_reg_ref(A_LWZ,NR_R0,tmpref));
|
||||||
|
exprasmlist.concat(taicpu.op_reg(A_MTLR,NR_R0));
|
||||||
|
exprasmlist.concat(taicpu.op_none(A_BLRL));
|
||||||
|
|
||||||
|
cg.ungetcpuregister(exprasmlist,NR_R0);
|
||||||
|
cg.ungetcpuregister(exprasmlist,NR_R3);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
internalerror(2005010403);
|
||||||
end;
|
end;
|
||||||
else
|
else
|
||||||
internalerror(2004042901);
|
internalerror(2004042901);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
ccallnode:=tppccallnode;
|
ccallnode:=tppccallnode;
|
||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.31 2004-12-06 18:06:37 jonas
|
Revision 1.32 2005-01-04 17:40:33 karoly
|
||||||
|
+ sysv style syscalls added for MorphOS
|
||||||
|
|
||||||
|
Revision 1.31 2004/12/06 18:06:37 jonas
|
||||||
* only set/clear bit 6 of cr in case of varargs for the sysv abi
|
* only set/clear bit 6 of cr in case of varargs for the sysv abi
|
||||||
|
|
||||||
Revision 1.30 2004/10/15 09:30:13 mazen
|
Revision 1.30 2004/10/15 09:30:13 mazen
|
||||||
|
@ -876,6 +876,23 @@ implementation
|
|||||||
do_message(scan_f_user_defined);
|
do_message(scan_f_user_defined);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{$ifdef powerpc}
|
||||||
|
procedure dir_syscall;
|
||||||
|
var
|
||||||
|
sctype : string;
|
||||||
|
begin
|
||||||
|
if not (target_info.system in [system_powerpc_morphos]) then
|
||||||
|
comment (V_Warning,'Syscall directive is useless on this target.');
|
||||||
|
current_scanner.skipspace;
|
||||||
|
|
||||||
|
sctype:=current_scanner.readid;
|
||||||
|
if (sctype='LEGACY') or (sctype='SYSV') then
|
||||||
|
syscall_convention:=sctype
|
||||||
|
else
|
||||||
|
comment (V_Warning,'Invalid Syscall directive ignored.');
|
||||||
|
end;
|
||||||
|
{$endif}
|
||||||
|
|
||||||
procedure dir_threading;
|
procedure dir_threading;
|
||||||
var
|
var
|
||||||
mac : tmacro;
|
mac : tmacro;
|
||||||
@ -1128,6 +1145,9 @@ implementation
|
|||||||
AddDirective('STACKFRAMES',directive_all, @dir_stackframes);
|
AddDirective('STACKFRAMES',directive_all, @dir_stackframes);
|
||||||
AddDirective('STATIC',directive_all, @dir_static);
|
AddDirective('STATIC',directive_all, @dir_static);
|
||||||
AddDirective('STOP',directive_all, @dir_stop);
|
AddDirective('STOP',directive_all, @dir_stop);
|
||||||
|
{$ifdef powerpc}
|
||||||
|
AddDirective('SYSCALL',directive_all, @dir_syscall);
|
||||||
|
{$endif powerpc}
|
||||||
AddDirective('THREADING',directive_all, @dir_threading);
|
AddDirective('THREADING',directive_all, @dir_threading);
|
||||||
AddDirective('THREADNAME',directive_all, @dir_threadname);
|
AddDirective('THREADNAME',directive_all, @dir_threadname);
|
||||||
AddDirective('TYPEDADDRESS',directive_all, @dir_typedaddress);
|
AddDirective('TYPEDADDRESS',directive_all, @dir_typedaddress);
|
||||||
@ -1149,7 +1169,10 @@ begin
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.48 2005-01-04 16:18:57 florian
|
Revision 1.49 2005-01-04 17:40:33 karoly
|
||||||
|
+ sysv style syscalls added for MorphOS
|
||||||
|
|
||||||
|
Revision 1.48 2005/01/04 16:18:57 florian
|
||||||
* prepared for fpu mode depended define
|
* prepared for fpu mode depended define
|
||||||
|
|
||||||
Revision 1.47 2004/11/06 17:58:10 peter
|
Revision 1.47 2004/11/06 17:58:10 peter
|
||||||
|
@ -249,7 +249,10 @@ type
|
|||||||
po_has_public_name,
|
po_has_public_name,
|
||||||
po_forward,
|
po_forward,
|
||||||
po_global,
|
po_global,
|
||||||
po_has_inlininginfo
|
po_has_inlininginfo,
|
||||||
|
{ The two different kind of syscalls on MorphOS }
|
||||||
|
po_syscall_legacy,
|
||||||
|
po_syscall_sysv
|
||||||
);
|
);
|
||||||
tprocoptions=set of tprocoption;
|
tprocoptions=set of tprocoption;
|
||||||
|
|
||||||
@ -429,7 +432,10 @@ initialization
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.96 2004-12-05 12:28:11 peter
|
Revision 1.97 2005-01-04 17:40:33 karoly
|
||||||
|
+ sysv style syscalls added for MorphOS
|
||||||
|
|
||||||
|
Revision 1.96 2004/12/05 12:28:11 peter
|
||||||
* procvar handling for tp procvar mode fixed
|
* procvar handling for tp procvar mode fixed
|
||||||
* proc to procvar moved from addrnode to typeconvnode
|
* proc to procvar moved from addrnode to typeconvnode
|
||||||
* inlininginfo is now allocated only for inline routines that
|
* inlininginfo is now allocated only for inline routines that
|
||||||
|
@ -226,7 +226,9 @@ type
|
|||||||
_UNIMPLEMENTED,
|
_UNIMPLEMENTED,
|
||||||
_IMPLEMENTATION,
|
_IMPLEMENTATION,
|
||||||
_INITIALIZATION,
|
_INITIALIZATION,
|
||||||
_RESOURCESTRING
|
_RESOURCESTRING,
|
||||||
|
_LEGACY,
|
||||||
|
_SYSV
|
||||||
);
|
);
|
||||||
|
|
||||||
const
|
const
|
||||||
@ -455,7 +457,9 @@ const
|
|||||||
(str:'UNIMPLEMENTED' ;special:false;keyword:m_all;op:NOTOKEN),
|
(str:'UNIMPLEMENTED' ;special:false;keyword:m_all;op:NOTOKEN),
|
||||||
(str:'IMPLEMENTATION';special:false;keyword:m_all;op:NOTOKEN),
|
(str:'IMPLEMENTATION';special:false;keyword:m_all;op:NOTOKEN),
|
||||||
(str:'INITIALIZATION';special:false;keyword:m_initfinal;op:NOTOKEN),
|
(str:'INITIALIZATION';special:false;keyword:m_initfinal;op:NOTOKEN),
|
||||||
(str:'RESOURCESTRING';special:false;keyword:m_class;op:NOTOKEN)
|
(str:'RESOURCESTRING';special:false;keyword:m_class;op:NOTOKEN),
|
||||||
|
(str:'LEGACY' ;special:false;keyword:m_none;op:NOTOKEN),
|
||||||
|
(str:'SYSV' ;special:false;keyword:m_none;op:NOTOKEN)
|
||||||
);
|
);
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -516,7 +520,10 @@ end;
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.32 2004-10-24 20:01:08 peter
|
Revision 1.33 2005-01-04 17:40:33 karoly
|
||||||
|
+ sysv style syscalls added for MorphOS
|
||||||
|
|
||||||
|
Revision 1.32 2004/10/24 20:01:08 peter
|
||||||
* remove saveregister calling convention
|
* remove saveregister calling convention
|
||||||
|
|
||||||
Revision 1.31 2004/07/05 23:25:34 olle
|
Revision 1.31 2004/07/05 23:25:34 olle
|
||||||
|
Loading…
Reference in New Issue
Block a user