* basic setup; derived from FreeBSD and Linux

This commit is contained in:
florian 2003-05-20 23:56:40 +00:00
parent f48b695397
commit 24a5d569cd
5 changed files with 1827 additions and 0 deletions

1365
rtl/darwin/Makefile Normal file

File diff suppressed because it is too large Load Diff

222
rtl/darwin/Makefile.fpc Normal file
View File

@ -0,0 +1,222 @@
#
# Makefile.fpc for Free Pascal FreeBSD RTL
#
[package]
main=rtl
[install]
fpcpackage=y
[target]
loaders=prt0 cprt0
units=$(SYSTEMUNIT) objpas strings baseunix \
$(LINUXUNIT) unix initc \
dos crt objects printer \
sysutils typinfo math varutils \
cpu mmx charset ucomplex getopts heaptrc lineinfo \
errors sockets gpm ipc terminfo \
video mouse keyboard console serial variants types systhrds sysctl
rsts=math varutils typinfo
[require]
nortl=y
[install]
fpcpackage=y
[default]
fpcdir=../..
target=freebsd
[compiler]
includedir=$(INC) $(PROCINC) $(UNIXINC) $(BSDINC) $(BSDPROCINC)
sourcedir=$(INC) $(PROCINC) $(UNIXINC) $(BSDINC)
targetdir=.
[lib]
libname=libfprtl.so
libversion=1.0
libunits=$(SYSTEMUNIT) objpas strings \
unix \
dos crt objects printer \
sysutils typinfo math \
cpu mmx getopts heaptrc \
errors sockets ipc
[prerules]
RTL=..
INC=$(RTL)/inc
PROCINC=$(RTL)/$(CPU_TARGET)
BSDINC=$(RTL)/bsd
BSDPROCINC=$(BSDINC)/$(CPU_TARGET)
UNIXINC=$(RTL)/unix
UNITPREFIX=rtl
ifeq ($(findstring 1.0.,$(FPC_VERSION)),)
SYSTEMUNIT=system
LINUXUNIT=
PRT0=prt0
else
SYSTEMUNIT=sysbsd
LINUXUNIT=linux
override FPCOPT+=-dUNIX
PRT0=prt0_10
endif
# Use new feature from 1.0.5 version
# that generates release PPU files
# which will not be recompiled
ifdef RELEASE
override FPCOPT+=-Ur
endif
# Paths
OBJPASDIR=$(RTL)/objpas
GRAPHDIR=$(INC)/graph
# Use new graph unit ?
# NEWGRAPH=YES
# Use LibGGI ?
# Use
#
ifndef USELIBGGI
USELIBGGI=NO
endif
[rules]
# 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
#
prt0$(OEXT) : $(CPU_TARGET)/$(PRT0).as
$(AS) -o prt0$(OEXT) $(CPU_TARGET)/$(PRT0).as
cprt0$(OEXT) : $(CPU_TARGET)/cprt0.as
$(AS) -o cprt0$(OEXT) $(CPU_TARGET)/cprt0.as
#
# System Units (System, Objpas, Strings)
#
$(SYSTEMUNIT)$(PPUEXT) : $(BSDINC)/$(SYSTEMUNIT).pp sysconst.inc systypes.inc syscalls.inc $(SYSDEPS)
$(COMPILER) -Us -Sg $(BSDINC)/$(SYSTEMUNIT).pp
objpas$(PPUEXT): $(OBJPASDIR)/objpas.pp $(INC)/except.inc $(SYSTEMUNIT)$(PPUEXT)
$(COMPILER) -I$(OBJPASDIR) $(OBJPASDIR)/objpas.pp
strings$(PPUEXT) : $(INC)/strings.pp $(INC)/stringsi.inc\
$(PROCINC)/strings.inc $(PROCINC)/stringss.inc\
$(SYSTEMUNIT)$(PPUEXT)
#
# System Dependent Units
#
baseunix$(PPUEXT) : $(UNIXINC)/errno.inc $(BSDINC)/bunxtype.inc ptypes.inc $(BSDINC)/ctypes.inc \
signal.inc $(UNIXINC)/bunxh.inc $(BSDINC)/bunxmain.inc $(BSDINC)/ostypes.inc \
$(BSDINC)/bunxfunc.inc $(BSDPROCINC)/syscallh.inc sysnr.inc \
$(BSDINC)/ostypes.inc $(BSDINC)/ossysch.inc $(BSDINC)/bunxmacr.inc $(UNIXINC)/gensigset.inc \
$(UNIXINC)/genfuncs.inc $(SYSTEMUNIT)$(PPUEXT)
unix$(PPUEXT) : $(UNIXINC)/unix.pp strings$(PPUEXT) $(INC)/textrec.inc $(INC)/filerec.inc \
syscalls.inc systypes.inc sysconst.inc $(UNIXINC)/timezone.inc \
unixsysc.inc baseunix$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
linux$(PPUEXT) : baseunix$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
#
# TP7 Compatible RTL Units
#
dos$(PPUEXT) : $(UNIXINC)/dos.pp $(INC)/filerec.inc $(INC)/textrec.inc strings$(PPUEXT) \
unix$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
crt$(PPUEXT) : $(UNIXINC)/crt.pp $(INC)/textrec.inc unix$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
objects$(PPUEXT) : $(INC)/objects.pp $(SYSTEMUNIT)$(PPUEXT)
printer$(PPUEXT) : $(UNIXINC)/printer.pp $(INC)/textrec.inc unix$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
#
# Graph
#
#
# Delphi Compatible Units
#
sysutils$(PPUEXT) : $(UNIXINC)/sysutils.pp $(wildcard $(OBJPASDIR)/*.inc) \
objpas$(PPUEXT) unix$(PPUEXT) errors$(PPUEXT)
$(COMPILER) -I$(OBJPASDIR) $(UNIXINC)/sysutils.pp
typinfo$(PPUEXT): $(OBJPASDIR)/typinfo.pp objpas$(PPUEXT)
$(COMPILER) -Sg $(OBJPASDIR)/typinfo.pp
math$(PPUEXT): $(OBJPASDIR)/math.pp objpas$(PPUEXT) sysutils$(PPUEXT)
$(COMPILER) $(OBJPASDIR)/math.pp
gettext$(PPUEXT): $(OBJPASDIR)/gettext.pp objpas$(PPUEXT) sysutils$(PPUEXT)
$(COMPILER) $(OBJPASDIR)/gettext.pp
varutils$(PPUEXT) : $(OBJPASDIR)/cvarutil.inc $(OBJPASDIR)/varutils.inc \
$(OBJPASDIR)/varutilh.inc varutils.pp
$(COMPILER) -I$(OBJPASDIR) $(UNIXINC)/varutils.pp
types$(PPUEXT) : $(OBJPASDIR/types.pp objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
$(COMPILER) $(OBJPASDIR)/types.pp
#
# Other system-independent RTL Units
#
cpu$(PPUEXT) : $(PROCINC)/cpu.pp $(SYSTEMUNIT)$(PPUEXT)
mmx$(PPUEXT) : $(PROCINC)/mmx.pp cpu$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
getopts$(PPUEXT) : $(INC)/getopts.pp $(SYSTEMUNIT)$(PPUEXT)
heaptrc$(PPUEXT) : $(INC)/heaptrc.pp $(SYSTEMUNIT)$(PPUEXT)
$(COMPILER) -Sg $(INC)/heaptrc.pp
lineinfo$(PPUEXT) : $(INC)/lineinfo.pp $(SYSTEMUNIT)$(PPUEXT)
charset$(PPUEXT) : $(INC)/charset.pp $(SYSTEMUNIT)$(PPUEXT)
ucomplex$(PPUEXT) : $(INC)/ucomplex.pp math$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
#
# Other system-dependent RTL Units
#
sockets$(PPUEXT) : $(UNIXINC)/sockets.pp $(INC)/textrec.inc $(INC)/filerec.inc \
unix$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
errors$(PPUEXT) : $(UNIXINC)/errors.pp strings$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
ipc$(PPUEXT) : $(UNIXINC)/ipc.pp unix$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
terminfo$(PPUEXT) : terminfo.pp unix$(PPUEXT)
callspec$(PPUEXT) : $(INC)/callspec.pp $(SYSTEMUNIT)$(PPUEXT)
sysctl$(PPUEXT) : $(BSDINC)/sysctl.pp $(SYSTEMUNIT)$(PPUEXT)

View File

@ -0,0 +1,18 @@
/*
$Id$
*/
/*
$Log$
Revision 1.1 2003-05-20 23:56:40 florian
* basic setup; derived from FreeBSD and Linux
Revision 1.3 2002/09/07 16:01:20 peter
* old logs removed and tabs fixed
Revision 1.2 2002/07/26 17:09:44 florian
* log fixed
Revision 1.1 2002/07/26 17:07:11 florian
+ dummy implementation to test the makefile
*/

View File

@ -0,0 +1,99 @@
/* Startup code for programs linked with GNU libc.
Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
.section ".text"
.globl _start
_start:
mr 26,1
/* Set up an initial stack frame, and clear the LR. */
clrrwi 1,1,4
li 0,0
stwu 1,-16(1)
mtlr 0
stw 0,0(1)
lwz 3,0(26) /* get argc */
lis 11,U_SYSTEM_ARGC@ha
stw 3,U_SYSTEM_ARGC@l(11);
addi 4,26,4 /* get argv */
lis 11,U_SYSTEM_ARGV@ha
stw 4,U_SYSTEM_ARGV@l(11);
addi 27,3,1 /* calculate argc + 1 into r27 */
slwi 27,27,2 /* calculate (argc + 1) * sizeof(char *) into r27 */
add 5,4,27 /* get address of env[0] */
lis 11,U_SYSTEM_ENVP@ha
stw 5,U_SYSTEM_ENVP@l(11);
bl PASCALMAIN
.globl _haltproc
.type _haltproc,@function
_haltproc:
li 0,1 /* exit call */
lis 3,U_SYSTEM_EXITCODE@h
stw 3,U_SYSTEM_EXITCODE@l(3)
sc
b _haltproc
/* Define a symbol for the first piece of initialized data. */
.section ".data"
.globl __data_start
__data_start:
data_start:
.globl ___fpc_brk_addr /* heap management */
.type ___fpc_brk_addr,@object
.size ___fpc_brk_addr,4
___fpc_brk_addr:
.long 0
/*
$Log$
Revision 1.1 2003-05-20 23:56:40 florian
* basic setup; derived from FreeBSD and Linux
Revision 1.10 2003/05/12 22:36:45 florian
+ added setup of argv, argc and envp
Revision 1.9 2002/09/07 16:01:20 peter
* old logs removed and tabs fixed
Revision 1.8 2002/08/31 21:29:57 florian
* several PC related fixes
Revision 1.7 2002/08/31 16:13:12 florian
* made _start global
Revision 1.6 2002/08/31 14:02:23 florian
* r3 renamed to 3
Revision 1.5 2002/08/31 14:01:28 florian
* _haltproc to prt0.as added (Linux/PPC)
Revision 1.4 2002/08/31 13:11:11 florian
* several fixes for Linux/PPC compilation
Revision 1.3 2002/08/19 21:19:15 florian
* small fixes
Revision 1.2 2002/07/26 17:09:44 florian
* log fixed
Revision 1.1 2002/07/26 16:57:40 florian
+ initial version, plain copy from glibc/sysdeps/powerpc/elf/start.S
*/

123
rtl/darwin/sysconst.inc Normal file
View File

@ -0,0 +1,123 @@
{
$Id$
This file is part of the Free Pascal run time library.
Copyright (c) 1999-2000 by Michael Van Canneyt,
member of 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.
**********************************************************************}
{BSD version, only the blocks with BSD in the comment are updated}
Const
{ Things for LSEEK call, same in linux and BSD }
Seek_set = 0;
Seek_Cur = 1;
Seek_End = 2;
{ Things for OPEN call - after include/sys/fcntl.h, BSD updated.
BSD specifies these constants in hex }
Open_Accmode = 3;
Open_RdOnly = 0;
Open_WrOnly = 1;
Open_RdWr = 2;
Open_NonBlock = 4;
Open_Append = 8;
Open_ShLock = $10;
Open_ExLock = $20;
Open_ASync = $40;
Open_FSync = $80;
Open_NoFollow = $100;
Open_Create = $200; {BSD convention}
Open_Creat = $200; {Linux convention}
Open_Trunc = $400;
Open_Excl = $800;
Open_NoCTTY = $8000;
{ The waitpid uses the following options:}
Wait_NoHang = 1;
Wait_UnTraced = 2;
Wait_Any = -1;
Wait_MyPGRP = 0;
{ Constants to check stat.mode - checked all STAT constants with BSD}
STAT_IFMT = $f000; {00170000 }
STAT_IFSOCK = $c000; {0140000 }
STAT_IFLNK = $a000; {0120000 }
STAT_IFREG = $8000; {0100000 }
STAT_IFBLK = $6000; {0060000 }
STAT_IFDIR = $4000; {0040000 }
STAT_IFCHR = $2000; {0020000 }
STAT_IFIFO = $1000; {0010000 }
STAT_ISUID = $0800; {0004000 }
STAT_ISGID = $0400; {0002000 }
STAT_ISVTX = $0200; {0001000}
{ Constants to check permissions all }
STAT_IRWXO = $7;
STAT_IROTH = $4;
STAT_IWOTH = $2;
STAT_IXOTH = $1;
STAT_IRWXG = STAT_IRWXO shl 3;
STAT_IRGRP = STAT_IROTH shl 3;
STAT_IWGRP = STAT_IWOTH shl 3;
STAT_IXGRP = STAT_IXOTH shl 3;
STAT_IRWXU = STAT_IRWXO shl 6;
STAT_IRUSR = STAT_IROTH shl 6;
STAT_IWUSR = STAT_IWOTH shl 6;
STAT_IXUSR = STAT_IXOTH shl 6;
{ Constants to test the type of filesystem }
fs_old_ext2 = $ef51;
fs_ext2 = $ef53;
fs_ext = $137d;
fs_iso = $9660;
fs_minix = $137f;
fs_minix_30 = $138f;
fs_minux_V2 = $2468;
fs_msdos = $4d44;
fs_nfs = $6969;
fs_proc = $9fa0;
fs_xia = $012FD16D;
{ Constansts for MMAP }
MAP_PRIVATE =2;
MAP_ANONYMOUS =$1000;
{Constansts Termios/Ioctl (used in Do_IsDevice) }
IOCtl_TCGETS=$5401; // TCGETS is also in termios.inc, but the sysunix needs only this
{Checked for BSD using Linuxthreads port}
{ cloning flags }
CSIGNAL = $000000ff; // signal mask to be sent at exit
CLONE_VM = $00000100; // set if VM shared between processes
CLONE_FS = $00000200; // set if fs info shared between processes
CLONE_FILES = $00000400; // set if open files shared between processes
CLONE_SIGHAND = $00000800; // set if signal handlers shared
CLONE_PID = $00001000; // set if pid shared
ITimer_Real =0;
ITimer_Virtual =1;
ITimer_Prof =2;
type
TCloneFunc=function(args:pointer):longint;cdecl;
{
$Log$
Revision 1.1 2003-05-20 23:56:40 florian
* basic setup; derived from FreeBSD and Linux
Revision 1.7 2002/09/07 16:01:17 peter
* old logs removed and tabs fixed
Revision 1.6 2002/05/06 09:35:09 marco
* Some stuff from 1.0.x ported
}