浏览代码

* first working version of the Darwin/Mac OS X (for PowerPC) RTL
Several non-essential units are still missing, but make cycle works

Jonas Maebe 21 年之前
父节点
当前提交
82343a6dc6

+ 29 - 44
rtl/darwin/Makefile

@@ -1,8 +1,8 @@
 #
-# Don't edit, this file is generated by FPCMake Version 1.1 [2003/10/28]
+# Don't edit, this file is generated by FPCMake Version 1.1 [2004/01/08]
 #
 default: all
-MAKEFILETARGETS=linux go32v2 win32 os2 freebsd beos netbsd amiga atari sunos qnx netware openbsd wdosx palmos macos darwin emx watcom
+MAKEFILETARGETS=darwin
 override PATH:=$(subst \,/,$(PATH))
 ifeq ($(findstring ;,$(PATH)),)
 inUnix=1
@@ -91,7 +91,7 @@ endif
 endif
 export ECHO
 endif
-override OS_TARGET_DEFAULT=freebsd
+override OS_TARGET_DEFAULT=darwin
 override DEFAULT_FPCDIR=../..
 ifndef FPC
 ifdef PP
@@ -211,31 +211,28 @@ INC=$(RTL)/inc
 PROCINC=$(RTL)/$(CPU_TARGET)
 BSDINC=$(RTL)/bsd
 BSDPROCINC=$(BSDINC)/$(CPU_TARGET)
+OSPROCINC=$(RTL)/darwin/$(CPU_TARGET)
 UNIXINC=$(RTL)/unix
 UNITPREFIX=rtl
 ifeq ($(findstring 1.0.,$(FPC_VERSION)),)
 SYSTEMUNIT=system
-LINUXUNIT=
-PRT0=prt0
+override FPCOPT+=-dNOMOUSE
 else
-SYSTEMUNIT=sysbsd
-LINUXUNIT=linux
-override FPCOPT+=-dUNIX
-PRT0=prt0_10
+SYSTEMUNIT="Error: Darwin is not supported for 1.0"
 endif
 ifdef RELEASE
 override FPCOPT+=-Ur
 endif
+override FPCOPT+=-dFPC_USE_LIBC
 OBJPASDIR=$(RTL)/objpas
 GRAPHDIR=$(INC)/graph
 ifndef USELIBGGI
 USELIBGGI=NO
 endif
-override TARGET_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
-override TARGET_LOADERS+=prt0 cprt0
-override TARGET_RSTS+=math varutils typinfo
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas strings sysctl baseunix unixutil unix initc   dos dl objects printer sysutils typinfo systhrds classes math varutils charset ucomplex getopts heaptrc lineinfo errors terminfo variants types sysctl dateutils sysconst cthreads
+override TARGET_RSTS+=math varutils typinfo classes variants dateutils sysconst
 override INSTALL_FPCPACKAGE=y y
-override COMPILER_INCLUDEDIR+=$(INC) $(PROCINC) $(UNIXINC) $(BSDINC) $(BSDPROCINC)
+override COMPILER_INCLUDEDIR+=$(INC) $(PROCINC) $(UNIXINC) $(BSDINC) $(BSDPROCINC) $(OSPROCINC)
 override COMPILER_SOURCEDIR+=$(INC) $(PROCINC) $(UNIXINC) $(BSDINC)
 override COMPILER_TARGETDIR+=.
 ifdef REQUIRE_UNITSDIR
@@ -1047,21 +1044,6 @@ ifeq ($(FULL_SOURCE),$(FULL_TARGET))
 EXECPPAS:=@$(PPAS)
 endif
 endif
-.PHONY: fpc_loaders
-ifdef TARGET_LOADERS
-override ALLTARGET+=fpc_loaders
-override CLEANTARGET+=fpc_loaders_clean
-override INSTALLTARGET+=fpc_loaders_install
-override LOADEROFILES:=$(addsuffix $(OEXT),$(TARGET_LOADERS))
-endif
-%$(OEXT): %$(LOADEREXT)
-	$(AS) -o $*$(OEXT) $<
-fpc_loaders: $(LOADEROFILES)
-fpc_loaders_clean:
-	-$(DEL) $(LOADEROFILES)
-fpc_loaders_install:
-	$(MKDIR) $(INSTALL_UNITDIR)
-	$(INSTALL) $(LOADEROFILES) $(INSTALL_UNITDIR)
 .PHONY: fpc_units
 ifdef TARGET_UNITS
 override ALLTARGET+=fpc_units
@@ -1349,34 +1331,34 @@ SYSINCDEPS=$(addprefix $(INC)/,$(SYSINCNAMES))
 include $(PROCINC)/makefile.cpu
 SYSCPUDEPS=$(addprefix $(PROCINC)/,$(CPUINCNAMES))
 SYSDEPS=$(SYSINCDEPS) $(SYSCPUDEPS)
-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
-$(SYSTEMUNIT)$(PPUEXT) : $(BSDINC)/$(SYSTEMUNIT).pp sysconst.inc systypes.inc syscalls.inc $(SYSDEPS)
+$(SYSTEMUNIT)$(PPUEXT) : $(BSDINC)/$(SYSTEMUNIT).pp sysconst.inc $(SYSDEPS)
 	$(COMPILER) -Us -Sg $(BSDINC)/$(SYSTEMUNIT).pp
 objpas$(PPUEXT): $(OBJPASDIR)/objpas.pp $(INC)/except.inc $(SYSTEMUNIT)$(PPUEXT)
 	$(COMPILER) -I$(OBJPASDIR) $(OBJPASDIR)/objpas.pp
+dateutils$(PPUEXT): $(OBJPASDIR)/dateutils.pp baseunix$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
+	$(COMPILER) -I$(OBJPASDIR) $(OBJPASDIR)/dateutils.pp
 strings$(PPUEXT) : $(INC)/strings.pp $(INC)/stringsi.inc\
 		   $(PROCINC)/strings.inc $(PROCINC)/stringss.inc\
 		   $(SYSTEMUNIT)$(PPUEXT)
-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)
+baseunix$(PPUEXT) : errno.inc $(BSDINC)/bunxtype.inc ptypes.inc $(BSDINC)/ctypes.inc \
+  signal.inc $(UNIXINC)/bunxh.inc $(BSDINC)/bunxmain.inc $(BSDINC)/ostypes.inc \
+  $(BSDINC)/bunxfunc.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 \
+		 sysconst.inc $(UNIXINC)/timezone.inc \
 		 unixsysc.inc baseunix$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
-linux$(PPUEXT) : baseunix$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 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)
-sysutils$(PPUEXT) : $(UNIXINC)/sysutils.pp $(wildcard $(OBJPASDIR)/*.inc) \
-		    objpas$(PPUEXT) unix$(PPUEXT) errors$(PPUEXT)
-	$(COMPILER) -I$(OBJPASDIR) $(UNIXINC)/sysutils.pp
+sysutils$(PPUEXT) : $(UNIXINC)/sysutils.pp $(wildcard $(OBJPASDIR)/sysutils/*.inc) \
+		    objpas$(PPUEXT) unix$(PPUEXT) errors$(PPUEXT) $(OBJPASDIR)/sysconst$(PPUEXT) 
+	$(COMPILER) -Fi$(OBJPASDIR)/sysutils $(UNIXINC)/sysutils.pp
+classes$(PPUEXT) : classes.pp $(wildcard $(OBJPASDIR)/classes/*.inc) \
+		   sysutils$(PPUEXT) typinfo$(PPUEXT)
+	$(COMPILER) -Fi$(OBJPASDIR)/classes classes.pp
 typinfo$(PPUEXT): $(OBJPASDIR)/typinfo.pp objpas$(PPUEXT)
 	$(COMPILER) -Sg $(OBJPASDIR)/typinfo.pp
 math$(PPUEXT): $(OBJPASDIR)/math.pp objpas$(PPUEXT) sysutils$(PPUEXT)
@@ -1386,8 +1368,10 @@ gettext$(PPUEXT): $(OBJPASDIR)/gettext.pp objpas$(PPUEXT) sysutils$(PPUEXT)
 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)
+types$(PPUEXT) : $(OBJPASDIR)/types.pp objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 	$(COMPILER) $(OBJPASDIR)/types.pp
+sysconst$(PPUEXT) : $(OBJPASDIR)/sysconst.pp objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
+	$(COMPILER) $(OBJPASDIR)/sysconst.pp
 cpu$(PPUEXT) : $(PROCINC)/cpu.pp $(SYSTEMUNIT)$(PPUEXT)
 mmx$(PPUEXT) : $(PROCINC)/mmx.pp cpu$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 getopts$(PPUEXT) : $(INC)/getopts.pp $(SYSTEMUNIT)$(PPUEXT)
@@ -1403,3 +1387,4 @@ 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)
+cthreads$(PPUEXT) : $(UNIXINC)/cthreads.pp systhrds$(PPUEXT)

+ 45 - 37
rtl/darwin/Makefile.fpc

@@ -1,5 +1,5 @@
 #
-#   Makefile.fpc for Free Pascal FreeBSD RTL
+#   Makefile.fpc for Free Pascal Darwin RTL
 #
 
 [package]
@@ -8,16 +8,19 @@ main=rtl
 [install]
 fpcpackage=y
 
+# disabled units: termio crt video keyboard serial sockets ipc mouse console
 [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 sysconst
-rsts=math varutils typinfo sysconst
+loaders=
+units=$(SYSTEMUNIT) objpas strings sysctl baseunix unixutil \
+      unix initc   \
+      dos dl objects printer \
+      sysutils typinfo systhrds classes math varutils \
+      charset ucomplex getopts heaptrc lineinfo \
+      errors terminfo \
+      variants types sysctl dateutils \
+      sysconst cthreads
+
+rsts=math varutils typinfo classes variants dateutils sysconst
 
 [require]
 nortl=y
@@ -27,10 +30,10 @@ fpcpackage=y
 
 [default]
 fpcdir=../..
-target=freebsd
+target=darwin
 
 [compiler]
-includedir=$(INC) $(PROCINC) $(UNIXINC) $(BSDINC) $(BSDPROCINC)
+includedir=$(INC) $(PROCINC) $(UNIXINC) $(BSDINC) $(BSDPROCINC) $(OSPROCINC)
 sourcedir=$(INC) $(PROCINC) $(UNIXINC) $(BSDINC)
 targetdir=.
 
@@ -50,18 +53,15 @@ INC=$(RTL)/inc
 PROCINC=$(RTL)/$(CPU_TARGET)
 BSDINC=$(RTL)/bsd
 BSDPROCINC=$(BSDINC)/$(CPU_TARGET)
+OSPROCINC=$(RTL)/darwin/$(CPU_TARGET)
 UNIXINC=$(RTL)/unix
 UNITPREFIX=rtl
 
 ifeq ($(findstring 1.0.,$(FPC_VERSION)),)
 SYSTEMUNIT=system
-LINUXUNIT=
-PRT0=prt0
+override FPCOPT+=-dNOMOUSE
 else
-SYSTEMUNIT=sysbsd
-LINUXUNIT=linux
-override FPCOPT+=-dUNIX
-PRT0=prt0_10
+SYSTEMUNIT="Error: Darwin is not supported for 1.0"
 endif
 
 # Use new feature from 1.0.5 version
@@ -71,6 +71,9 @@ ifdef RELEASE
 override FPCOPT+=-Ur
 endif
 
+# Darwin requires libc, no syscalls
+override FPCOPT+=-dFPC_USE_LIBC
+
 # Paths
 OBJPASDIR=$(RTL)/objpas
 GRAPHDIR=$(INC)/graph
@@ -102,26 +105,21 @@ SYSCPUDEPS=$(addprefix $(PROCINC)/,$(CPUINCNAMES))
 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)
+$(SYSTEMUNIT)$(PPUEXT) : $(BSDINC)/$(SYSTEMUNIT).pp sysconst.inc $(SYSDEPS)
         $(COMPILER) -Us -Sg $(BSDINC)/$(SYSTEMUNIT).pp
 
 objpas$(PPUEXT): $(OBJPASDIR)/objpas.pp $(INC)/except.inc $(SYSTEMUNIT)$(PPUEXT)
         $(COMPILER) -I$(OBJPASDIR) $(OBJPASDIR)/objpas.pp
 
+
+dateutils$(PPUEXT): $(OBJPASDIR)/dateutils.pp baseunix$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
+	$(COMPILER) -I$(OBJPASDIR) $(OBJPASDIR)/dateutils.pp
+
+
 strings$(PPUEXT) : $(INC)/strings.pp $(INC)/stringsi.inc\
                    $(PROCINC)/strings.inc $(PROCINC)/stringss.inc\
                    $(SYSTEMUNIT)$(PPUEXT)
@@ -130,18 +128,17 @@ strings$(PPUEXT) : $(INC)/strings.pp $(INC)/stringsi.inc\
 # System Dependent Units
 #
 
-baseunix$(PPUEXT) : $(UNIXINC)/errno.inc $(BSDINC)/bunxtype.inc ptypes.inc $(BSDINC)/ctypes.inc \
+baseunix$(PPUEXT) : 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)/bunxfunc.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 \
+                 sysconst.inc $(UNIXINC)/timezone.inc \
                  unixsysc.inc baseunix$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 
-linux$(PPUEXT) : baseunix$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 
 #
 # TP7 Compatible RTL Units
@@ -164,9 +161,13 @@ printer$(PPUEXT) : $(UNIXINC)/printer.pp $(INC)/textrec.inc unix$(PPUEXT) $(SYST
 # Delphi Compatible Units
 #
 
-sysutils$(PPUEXT) : $(UNIXINC)/sysutils.pp $(wildcard $(OBJPASDIR)/*.inc) \
-                    objpas$(PPUEXT) unix$(PPUEXT) errors$(PPUEXT) sysconst$(PPUEXT)
-        $(COMPILER) -I$(OBJPASDIR) $(UNIXINC)/sysutils.pp
+sysutils$(PPUEXT) : $(UNIXINC)/sysutils.pp $(wildcard $(OBJPASDIR)/sysutils/*.inc) \
+                    objpas$(PPUEXT) unix$(PPUEXT) errors$(PPUEXT) $(OBJPASDIR)/sysconst$(PPUEXT) 
+        $(COMPILER) -Fi$(OBJPASDIR)/sysutils $(UNIXINC)/sysutils.pp
+
+classes$(PPUEXT) : classes.pp $(wildcard $(OBJPASDIR)/classes/*.inc) \
+                   sysutils$(PPUEXT) typinfo$(PPUEXT)
+        $(COMPILER) -Fi$(OBJPASDIR)/classes classes.pp
 
 typinfo$(PPUEXT): $(OBJPASDIR)/typinfo.pp objpas$(PPUEXT)
         $(COMPILER) -Sg $(OBJPASDIR)/typinfo.pp
@@ -181,9 +182,12 @@ 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)
+types$(PPUEXT) : $(OBJPASDIR)/types.pp objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
         $(COMPILER) $(OBJPASDIR)/types.pp
 
+sysconst$(PPUEXT) : $(OBJPASDIR)/sysconst.pp objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
+        $(COMPILER) $(OBJPASDIR)/sysconst.pp
+
 #
 # Other system-independent RTL Units
 #
@@ -218,4 +222,8 @@ terminfo$(PPUEXT) : terminfo.pp unix$(PPUEXT)
 
 callspec$(PPUEXT) : $(INC)/callspec.pp $(SYSTEMUNIT)$(PPUEXT)
 
+
 sysctl$(PPUEXT) : $(BSDINC)/sysctl.pp $(SYSTEMUNIT)$(PPUEXT)
+
+cthreads$(PPUEXT) : $(UNIXINC)/cthreads.pp systhrds$(PPUEXT)
+

+ 80 - 0
rtl/darwin/classes.pp

@@ -0,0 +1,80 @@
+{
+    $Id$
+    This file is part of the Free Component Library (FCL)
+    Copyright (c) 1999-2000 by Michael Van Canneyt and Florian Klaempfl
+
+    Classes unit for linux
+
+    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.
+
+ **********************************************************************}
+
+{$mode objfpc}
+
+{ determine the type of the resource/form file }
+{$define Win16Res}
+
+unit Classes;
+
+interface
+
+uses
+  sysutils,
+  typinfo;
+
+{$i classesh.inc}
+
+implementation
+
+uses
+  baseunix,unix,Systhrds
+  ;
+
+{ OS - independent class implementations are in /inc directory. }
+{$i classes.inc}
+
+
+initialization
+  CommonInit;
+
+finalization
+  CommonCleanup;
+
+  if ThreadsInited then
+     DoneThreads;
+end.
+{
+  $Log$
+  Revision 1.1  2004-01-04 20:05:38  jonas
+    * first working version of the Darwin/Mac OS X (for PowerPC) RTL
+      Several non-essential units are still missing, but make cycle works
+
+  Revision 1.4  2003/12/22 16:16:33  marco
+   * small 1.0 compat fix
+
+  Revision 1.3  2003/11/17 10:05:51  marco
+   * threads for FreeBSD. Not working tho
+
+  Revision 1.2  2003/10/09 10:55:20  marco
+   * fix for moving classes to rtl while cycling with 1.0 start
+
+  Revision 1.1  2003/10/06 21:01:06  peter
+    * moved classes unit to rtl
+
+  Revision 1.1  2003/10/06 20:33:58  peter
+    * classes moved to rtl for 1.1
+    * classes .inc and classes.pp files moved to fcl/classes for
+      backwards 1.0.x compatiblity to have it in the fcl
+
+  Revision 1.6  2003/09/20 12:38:29  marco
+   * FCL now compiles for FreeBSD with new 1.1. Now Linux.
+
+  Revision 1.5  2002/09/07 15:15:24  peter
+    * old logs removed and tabs fixed
+
+}

+ 3475 - 0
rtl/darwin/console.pp

@@ -0,0 +1,3475 @@
+{  $Id$
+   This file is part of the Free Pascal run time library.
+   (c) 2000 by Marco van de Voort
+   member of the Free Pascal development team.
+
+   See the file COPYING.FPC, included in this distribution,
+   for details about the copyright.
+
+   Header conversions (with FpIoctl macro expansion) for FreeBSD 4.2's
+   sys/fbio.h sys/consio.h sys/kbdio.h (together these three form
+        machine/console.h) and
+   machine/mouse.h
+
+   Converted to use in a future FreeBSD API to get the IDE running on
+   the physical console with mousesupport.
+
+   As soon as cross unit inlining is ready, all functions should be made
+    inline. (so the FpIoctl and the other very small macro's)
+
+   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.
+}
+
+unit console;
+
+{$packrecords C}
+
+interface
+
+{I tried to keep original types as much as possible, only "int" is converted
+to longint because INT is a standard function in TP/FPC}
+
+TYPE
+     uchar = char;
+     uint  = dword;
+     u_int = uint;
+     ushort= word;
+     short = integer;
+     long  = dword;             {?}
+     size_t= longint;           {Dunno sure, but it is 32-bit}
+     caddr_t= longint;          {idem}
+     vm_offset_t=dword;         {idem}
+
+{----------------------------- sys/fbio.h ----------------------------------}
+
+{
+ * Copyright (c) 1992, 1993
+ *      The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software developed by the Computer Systems
+ * Engineering group at Lawrence Berkeley Laboratory under DARPA
+ * contract BG 91-66 and contributed to Berkeley.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by the University of
+ *      California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *      @(#)fbio.h      8.2 (Berkeley) 10/30/93
+ *
+ * $FreeBSD: src/sys/sys/fbio.h,v 1.9.2.1 2000/05/05 09:16:16 nyan Exp $
+ }
+
+{
+ * Frame buffer FpIoctls (from Sprite, trimmed to essentials for X11).
+ }
+
+{
+ * Frame buffer type codes.
+ }
+
+CONST
+
+                FBTYPE_SUN1BW           =0;     { multibus mono }
+                FBTYPE_SUN1COLOR        =1;     { multibus color }
+                FBTYPE_SUN2BW           =2;     { memory mono }
+                FBTYPE_SUN2COLOR        =3;     { color w/rasterop chips }
+                FBTYPE_SUN2GP           =4;     { GP1/GP2 }
+                FBTYPE_SUN5COLOR        =5;     { RoadRunner accelerator }
+                FBTYPE_SUN3COLOR        =6;     { memory color }
+                FBTYPE_MEMCOLOR         =7;     { memory 24-bit }
+                FBTYPE_SUN4COLOR        =8;     { memory color w/overlay }
+
+                FBTYPE_NOTSUN1          =9;     { reserved for customer }
+                FBTYPE_NOTSUN2          =10;    { reserved for customer }
+                FBTYPE_NOTSUN3          =11;    { reserved for customer }
+
+                FBTYPE_SUNFAST_COLOR    =12;    { accelerated 8bit }
+                FBTYPE_SUNROP_COLOR     =13;    { MEMCOLOR with rop h/w }
+                FBTYPE_SUNFB_VIDEO      =14;    { Simple video mixing }
+                FBTYPE_RESERVED5        =15;    { reserved, do not use }
+                FBTYPE_RESERVED4        =16;    { reserved, do not use }
+                FBTYPE_RESERVED3        =17;    { reserved, do not use }
+                FBTYPE_RESERVED2        =18;    { reserved, do not use }
+                FBTYPE_RESERVED1        =19;    { reserved, do not use }
+
+                FBTYPE_MDA              =20;
+                FBTYPE_HERCULES         =21;
+                FBTYPE_CGA              =22;
+                FBTYPE_EGA              =23;
+                FBTYPE_VGA              =24;
+                FBTYPE_PC98             =25;
+                FBTYPE_TGA              =26;
+
+                FBTYPE_LASTPLUSONE      =27;    { max number of fbs (change as add) }
+
+{
+ * Frame buffer descriptor as returned by FBIOGTYPE.
+ }
+
+type fbtype = record
+                fb_type   : longint;    { as defined above }
+                fb_height : longint;    { in pixels }
+                fb_width  : longint;    { in pixels }
+                fb_depth  : longint;    { bits per pixel }
+                fb_cmsize : longint;    { size of color map (entries) }
+                fb_size   : longint;    { total size in bytes }
+               end;
+
+Function FBIOGTYPE(fd:longint;var param1 : fbtype):boolean;
+
+{
+ * General purpose structure for passing info in and out of frame buffers
+ * (used for gp1) -- unsupported.
+ }
+type  fbinfo = record
+                fb_physaddr   : longint;        { physical frame buffer address }
+                fb_hwwidth    : longint;        { fb board width }
+                fb_hwheight   : longint;        { fb board height }
+                fb_addrdelta  : longint;        { phys addr diff between boards }
+                fb_ropaddr    : ^uchar;         { fb virtual addr }
+                fb_unit       : longint;        { minor devnum of fb }
+                end;
+
+Function FBIOGINFO(fd:longint;var param1 : fbinfo):boolean;
+
+type
+{
+ * Color map I/O.
+ }
+       fbcmap = record
+                index   : longint;              { first element (0 origin) }
+                count   : longint;              { number of elements }
+                red     : ^uchar;               { red color map elements }
+                green   : ^uchar;               { green color map elements }
+                blue    : ^uchar;               { blue color map elements }
+                end;
+
+Function FBIOPUTCMAP(fd:longint;var param1 : fbcmap):boolean;
+Function FBIOGETCMAP(fd:longint;var param1 : fbcmap):boolean;
+
+{
+ * Set/get attributes.
+ }
+const
+                FB_ATTR_NDEVSPECIFIC    =8;     { no. of device specific values }
+                FB_ATTR_NEMUTYPES       =4;     { no. of emulation types }
+
+type  fbsattr = record
+                flags:longint;                  { flags; see below }
+                emu_type : longint;             { emulation type (-1 if unused) }
+                dev_specific : array[0..FB_ATTR_NDEVSPECIFIC-1] of longint;     { catchall }
+               end;
+const
+                FB_ATTR_AUTOINIT        =1;     { emulation auto init flag }
+                FB_ATTR_DEVSPECIFIC     =2;     { dev. specific stuff valid flag }
+
+type   fbgattr = record
+                real_type : longint;            { real device type }
+                owner     : longint;                    { PID of owner, 0 if myself }
+                _fbtype   : fbtype;             { fbtype info for real device }
+                sattr     : fbsattr;            { see above }
+                emu_types : array [0..FB_ATTR_NEMUTYPES-1] OF Longint;  { possible emulations }
+                                                { (-1 if unused) }
+                end;
+
+{       FBIOSATTR       _IOW('F', 5, struct fbsattr) -- unsupported }
+
+Function FBIOGATTR(fd:longint;var param1 : fbgattr):boolean;
+
+{
+ * Video control.
+ }
+
+const
+                FBVIDEO_OFF             =0;
+                FBVIDEO_ON              =1;
+
+Function FBIOSVIDEO(fd:longint;var param1 : longint):boolean;
+Function FBIOGVIDEO(fd:longint;var param1 : longint):boolean;
+
+{
+ * Hardware cursor control (for, e.g., CG6).  A rather complex and icky
+ * interface that smells like VMS, but there it is....
+ }
+type fbcurpos = record
+                x : short;
+                y : short;
+                end;
+
+
+
+     fbcursor = record
+                _set     : short;               { flags; see below }
+                enable  : short;                { nonzero => cursor on, 0 => cursor off }
+                _pos     : fbcurpos;    { position on display }
+                hot     : fbcurpos;     { hot-spot within cursor }
+                cmap    : fbcmap;       { cursor color map }
+                _size   : fbcurpos;     { number of valid bits in image & mask }
+                image   : caddr_t;              { cursor image bits }
+                mask    : caddr_t;              { cursor mask bits }
+               end;
+
+const
+                FB_CUR_SETCUR   =$01;   { set on/off (i.e., obey fbcursor.enable) }
+                FB_CUR_SETPOS   =$02;   { set position }
+                FB_CUR_SETHOT   =$04;   { set hot-spot }
+                FB_CUR_SETCMAP  =$08;   { set cursor color map }
+                FB_CUR_SETSHAPE =$10;   { set size & bits }
+                FB_CUR_SETALL   =(FB_CUR_SETCUR OR FB_CUR_SETPOS OR FB_CUR_SETHOT OR
+                         FB_CUR_SETCMAP OR FB_CUR_SETSHAPE);
+
+{ controls for cursor attributes & shape (including position) }
+Function FBIOSCURSOR(fd:longint;var param1 : fbcursor):boolean;
+Function FBIOGCURSOR(fd:longint;var param1 : fbcursor):boolean;
+
+{ controls for cursor position only }
+Function FBIOSCURPOS(fd:longint;var param1 : fbcurpos):boolean;
+Function FBIOGCURPOS(fd:longint;var param1 : fbcurpos):boolean;
+
+{ get maximum cursor size }
+Function FBIOGCURMAX(fd:longint;var param1 : fbcurpos):boolean;
+
+{ The new style frame buffer FpIoctls. }
+
+CONST
+         V_INFO_COLOR   =(1 SHL 0);
+         V_INFO_GRAPHICS        =(1 SHL 1);
+         V_INFO_LINEAR  =(1 SHL 2);
+         V_INFO_VESA    =(1 SHL 3);
+         V_INFO_MM_OTHER  =(-1);
+         V_INFO_MM_TEXT  =0;
+         V_INFO_MM_PLANAR =1;
+         V_INFO_MM_PACKED =2;
+         V_INFO_MM_DIRECT =3;
+         V_INFO_MM_CGA   =100;
+         V_INFO_MM_HGC   =101;
+         V_INFO_MM_VGAX  =102;
+
+TYPE
+{ video mode information block }
+  video_info = record
+                        vi_mode         : longint;      { mode number, see below }
+                        vi_flags        : longint;
+                        vi_width        : longint;
+                        vi_height       : longint;
+                        vi_cwidth       : longint;
+                        vi_cheight      : longint;
+                        vi_depth        : longint;
+                        vi_planes       : longint;
+                        vi_window       : uint; { physical address }
+                        vi_window_size  : size_t;
+                        vi_window_gran  : size_t;
+                        vi_buffer       : uint; { physical address }
+                        vi_buffer_size  : size_t;
+                        vi_mem_model    : longint;
+    { for MM_PACKED and MM_DIRECT only }
+                        vi_pixel_size   : longint;      { in bytes }
+    { for MM_DIRECT only }
+                        vi_pixel_fields : array[0..3] of longint;       { RGB and reserved fields }
+                        vi_pixel_fsizes : array[0..3] of longint;
+    { reserved }
+                        vi_reserved     : array[0..63] of uchar;
+                        end;
+
+        video_info_t = video_info;
+const
+         KD_OTHER       =0;             { unknown }
+         KD_MONO                =1;             { monochrome adapter }
+         KD_HERCULES    =2;             { hercules adapter }
+         KD_CGA         =3;             { color graphics adapter }
+         KD_EGA         =4;             { enhanced graphics adapter }
+         KD_VGA         =5;             { video graphics adapter }
+         KD_PC98                =6;             { PC-98 display }
+         KD_TGA         =7;             { TGA }
+         V_ADP_COLOR    =(1 SHL 0);
+         V_ADP_MODECHANGE=(1 SHL 1);
+         V_ADP_STATESAVE        =(1 SHL 2);
+         V_ADP_STATELOAD        =(1 SHL 3);
+         V_ADP_FONT     =(1 SHL 4);
+         V_ADP_PALETTE  =(1 SHL 5);
+         V_ADP_BORDER   =(1 SHL 6);
+         V_ADP_VESA     =(1 SHL 7);
+         V_ADP_PROBED   =(1 SHL 16);
+         V_ADP_INITIALIZED=(1 SHL 17);
+         V_ADP_REGISTERED =(1 SHL 18);
+
+{ adapter infromation block }
+type  video_adapter  = record
+                        va_index                : longint;
+                        va_type                 : longint;
+                        va_name                 : pchar;
+                        va_unit                 : longint;
+                        va_minor                : longint;
+                        va_flags                : longint;
+                        va_io_base              : longint;
+                        va_io_size              : longint;
+                        va_crtc_addr            : longint;
+                        va_mem_base             : longint;
+                        va_mem_size             : longint;
+                        va_window               : vm_offset_t;  { virtual address }
+                        va_window_size          : size_t;
+                        va_window_gran          : size_t;
+                        va_window_orig          : uint;
+                        va_buffer               : vm_offset_t;  { virtual address }
+                        va_buffer_size          : size_t;
+                        va_initial_mode         : longint;
+                        va_initial_bios_mode    : longint;
+                        va_mode                 : longint;
+                        va_info                 : video_info;
+                        va_line_width           : longint;
+                        va_disp_start : record
+                                          x : longint;
+                                          y : longint;
+                                         end;
+                        va_token      : pointer;
+                        end;
+
+        video_adapter_t = video_adapter;
+
+       video_adapter_info = record
+                        va_index                : longint;
+                        va_type                 : longint;
+                        va_name                 : array[0..15] of char;
+                        va_unit                 : longint;
+                        va_flags                : longint;
+                        va_io_base              : longint;
+                        va_io_size              : longint;
+                        va_crtc_addr            : longint;
+                        va_mem_base             : longint;
+                        va_mem_size             : longint;
+                        va_window               : uint;         { virtual address }
+                        va_window_size          : size_t;
+                        va_window_gran          : size_t;
+                        va_unused0              : uint;
+                        va_buffer_size          : size_t;
+                        va_initial_mode         : longint;
+                        va_initial_bios_mode    : longint;
+                        va_mode                 : longint;
+                        va_line_width           : longint;
+                        va_disp_start : record
+                                          x : longint;
+                                          y : longint;
+                                         end;
+                        va_window_orig :  uint;
+    { reserved }
+                        va_reserved : array[0..63] OF uchar;
+                        end;
+        video_adapter_info_t = video_adapter_info;
+
+CONST
+{ some useful video adapter index }
+         V_ADP_PRIMARY  =0;
+         V_ADP_SECONDARY        =1;
+
+{ video mode numbers }
+
+         M_B40x25       =0;     { black & white 40 columns }
+         M_C40x25       =1;     { color 40 columns }
+         M_B80x25       =2;     { black & white 80 columns }
+         M_C80x25       =3;     { color 80 columns }
+         M_BG320                =4;     { black & white graphics 320x200 }
+         M_CG320                =5;     { color graphics 320x200 }
+         M_BG640                =6;     { black & white graphics 640x200 hi-res }
+         M_EGAMONO80x25  =7;       { ega-mono 80x25 }
+         M_CG320_D      =13;    { ega mode D }
+         M_CG640_E      =14;    { ega mode E }
+         M_EGAMONOAPA   =15;    { ega mode F }
+         M_CG640x350    =16;    { ega mode 10 }
+         M_ENHMONOAPA2  =17;    { ega mode F with extended memory }
+         M_ENH_CG640    =18;    { ega mode 10* }
+         M_ENH_B40x25    =19;      { ega enhanced black & white 40 columns }
+         M_ENH_C40x25    =20;      { ega enhanced color 40 columns }
+         M_ENH_B80x25    =21;      { ega enhanced black & white 80 columns }
+         M_ENH_C80x25    =22;      { ega enhanced color 80 columns }
+         M_VGA_C40x25   =23;    { vga 8x16 font on color }
+         M_VGA_C80x25   =24;    { vga 8x16 font on color }
+         M_VGA_M80x25   =25;    { vga 8x16 font on mono }
+
+         M_VGA11                =26;    { vga 640x480 2 colors }
+         M_BG640x480    =26;
+         M_VGA12                =27;    { vga 640x480 16 colors }
+         M_CG640x480    =27;
+         M_VGA13                =28;    { vga 320x200 256 colors }
+         M_VGA_CG320    =28;
+
+         M_VGA_C80x50   =30;    { vga 8x8 font on color }
+         M_VGA_M80x50   =31;    { vga 8x8 font on color }
+         M_VGA_C80x30   =32;    { vga 8x16 font on color }
+         M_VGA_M80x30   =33;    { vga 8x16 font on color }
+         M_VGA_C80x60   =34;    { vga 8x8 font on color }
+         M_VGA_M80x60   =35;    { vga 8x8 font on color }
+         M_VGA_CG640    =36;    { vga 640x400 256 color }
+         M_VGA_MODEX    =37;    { vga 320x240 256 color }
+
+         M_VGA_C90x25   =40;    { vga 8x16 font on color }
+         M_VGA_M90x25   =41;    { vga 8x16 font on mono }
+         M_VGA_C90x30   =42;    { vga 8x16 font on color }
+         M_VGA_M90x30   =43;    { vga 8x16 font on mono }
+         M_VGA_C90x43   =44;    { vga 8x8 font on color }
+         M_VGA_M90x43   =45;    { vga 8x8 font on mono }
+         M_VGA_C90x50   =46;    { vga 8x8 font on color }
+         M_VGA_M90x50   =47;    { vga 8x8 font on mono }
+         M_VGA_C90x60   =48;    { vga 8x8 font on color }
+         M_VGA_M90x60   =49;    { vga 8x8 font on mono }
+
+         M_ENH_B80x43   =$70;   { ega black & white 80x43 }
+         M_ENH_C80x43   =$71;   { ega color 80x43 }
+
+         M_PC98_80x25           =98;    { PC98 text 80x25 }
+         M_PC98_80x30           =99;    { PC98 text 80x30 }
+         M_PC98_EGC640x400      =100;   { PC98 graphic 640x400 16 colors }
+         M_PC98_PEGC640x400     =101;   { PC98 graphic 640x400 256 colors }
+         M_PC98_PEGC640x480     =102;   { PC98 graphic 640x480 256 colors }
+
+         M_HGC_P0       =$e0;   { hercules graphics - page 0 @ B0000 }
+         M_HGC_P1       =$e1;   { hercules graphics - page 1 @ B8000 }
+         M_MCA_MODE     =$ff;   { monochrome adapter mode }
+
+         M_TEXT_80x25   =200;   { generic text modes }
+         M_TEXT_80x30   =201;
+         M_TEXT_80x43   =202;
+         M_TEXT_80x50   =203;
+         M_TEXT_80x60   =204;
+         M_TEXT_132x25  =205;
+         M_TEXT_132x30  =206;
+         M_TEXT_132x43  =207;
+         M_TEXT_132x50  =208;
+         M_TEXT_132x60  =209;
+
+         M_VESA_BASE            =$100;  { VESA mode number base }
+         M_VESA_CG640x400       =$100;  { 640x400, 256 color }
+         M_VESA_CG640x480       =$101;  { 640x480, 256 color }
+         M_VESA_800x600         =$102;  { 800x600, 16 color }
+         M_VESA_CG800x600       =$103;  { 800x600, 256 color }
+         M_VESA_1024x768                =$104;  { 1024x768, 16 color }
+         M_VESA_CG1024x768      =$105;  { 1024x768, 256 color }
+         M_VESA_1280x1024       =$106;  { 1280x1024, 16 color }
+         M_VESA_CG1280x1024     =$107;  { 1280x1024, 256 color }
+         M_VESA_C80x60          =$108;  { 8x8 font }
+         M_VESA_C132x25         =$109;  { 8x16 font }
+         M_VESA_C132x43         =$10a;  { 8x14 font }
+         M_VESA_C132x50         =$10b;  { 8x8 font }
+         M_VESA_C132x60         =$10c;  { 8x8 font }
+         M_VESA_32K_320         =$10d;  { 320x200, 5:5:5 }
+         M_VESA_64K_320         =$10e;  { 320x200, 5:6:5 }
+         M_VESA_FULL_320                =$10f;  { 320x200, 8:8:8 }
+         M_VESA_32K_640         =$110;  { 640x480, 5:5:5 }
+         M_VESA_64K_640         =$111;  { 640x480, 5:6:5 }
+         M_VESA_FULL_640                =$112;  { 640x480, 8:8:8 }
+         M_VESA_32K_800         =$113;  { 800x600, 5:5:5 }
+         M_VESA_64K_800         =$114;  { 800x600, 5:6:5 }
+         M_VESA_FULL_800                =$115;  { 800x600, 8:8:8 }
+         M_VESA_32K_1024                =$116;  { 1024x768, 5:5:5 }
+         M_VESA_64K_1024                =$117;  { 1024x768, 5:6:5 }
+         M_VESA_FULL_1024       =$118;  { 1024x768, 8:8:8 }
+         M_VESA_32K_1280                =$119;  { 1280x1024, 5:5:5 }
+         M_VESA_64K_1280                =$11a;  { 1280x1024, 5:6:5 }
+         M_VESA_FULL_1280       =$11b;  { 1280x1024, 8:8:8 }
+         M_VESA_MODE_MAX                =$1ff;
+
+type
+        video_display_start = record
+                        x  :longint;
+                        y : longint;
+                        end;
+
+        video_display_start_t= video_display_start;
+
+        video_color_palette = record
+                        index : longint;                { first element (zero-based) }
+                        count : longint;                { number of elements }
+                        red   : ^uchar;         { red }
+                        green : ^uchar;         { green }
+                        blue  : ^uchar;         { blue }
+                        transparent : ^uchar;   { may be NULL }
+                        end;
+
+        video_color_palette_t = video_color_palette;
+
+{ adapter info. }
+Function FBIO_ADAPTER(fd:longint;var param1 : longint):boolean;
+Function FBIO_ADPTYPE(fd:longint;var param1 : longint):boolean;
+Function FBIO_ADPINFO(fd:longint;var param1 : video_adapter_info):boolean;
+
+{ video mode control }
+Function FBIO_MODEINFO(fd:longint;var param1 : video_info):boolean;
+Function FBIO_FINDMODE(fd:longint;var param1 : video_info):boolean;
+Function FBIO_GETMODE(fd:longint;var param1 : longint):boolean;
+Function FBIO_SETMODE(fd:longint;var param1 : longint):boolean;
+
+{ get/set frame buffer window origin }
+Function FBIO_GETWINORG(fd:longint;var param1 : u_int):boolean;
+Function FBIO_SETWINORG(fd:longint;var param1 : u_int):boolean;
+
+{ get/set display start address }
+Function FBIO_GETDISPSTART(fd:longint;var param1 : video_display_start_t):boolean;
+Function FBIO_SETDISPSTART(fd:longint;var param1 : video_display_start_t):boolean;
+
+{ get/set scan line width }
+Function FBIO_GETLINEWIDTH(fd:longint;var param1 : u_int):boolean;
+Function FBIO_SETLINEWIDTH(fd:longint;var param1 : u_int):boolean;
+
+{ color palette control }
+Function FBIO_GETPALETTE(fd:longint;var param1 : video_color_palette_t):boolean;
+Function FBIO_SETPALETTE(fd:longint;var param1 : video_color_palette_t):boolean;
+
+{----------------------------- sys/consio.h ----------------------------------}
+
+{ version packaged with FreeBSD 4.2-RELEASE
+Translation to FreePascal by Marco van de Voort. (2000-2001), original
+copyright follows:
+
+ * Copyright (c) 1991-1996 Søren Schmidt
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer
+ *    in this position and unchanged.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD: src/sys/sys/consio.h,v 1.5.2.1 2000/05/05 09:16:15 nyan Exp $
+
+}
+
+{$define definconsole}
+
+{
+ * Console FpIoctl commands.  Some commands are named as KDXXXX, GIO_XXX, and
+ * PIO_XXX, rather than CONS_XXX, for historical and compatibility reasons.
+ * Some other CONS_XXX commands are works as wrapper around frame buffer
+ * FpIoctl commands FBIO_XXX.  Do not try to change all these commands,
+ * otherwise we shall have compatibility problems.
+ }
+
+const
+
+{ get/set video mode }
+        KD_TEXT     =0;         { set text mode restore fonts  }
+        KD_TEXT0    =0;         { ditto            }
+        KD_GRAPHICS =1;         { set graphics mode        }
+        KD_TEXT1    =2;         { set text mode !restore fonts }
+        KD_PIXEL    =3;         { set pixel mode       }
+
+Function KDGETMODE(fd:longint;var param1 : longint):boolean;
+Function KDSETMODE(fd:longint;param1 : longint):boolean;
+
+{ set border color }
+Function KDSBORDER(fd:longint;param1 : longint):boolean;
+
+{ set up raster(pixel) text mode }
+type
+        scr_size        = record
+                          _scrsize : array[0..2] of longint;
+                          end;
+        scr_size_t      = scr_size;
+
+Function KDRASTER(fd:longint;var param1 : scr_size_t):boolean;
+
+type
+
+{ get/set screen char map }
+
+        scrmap   = record
+                    _scrmap : array[0..255] of char;
+                    end;
+        scrmap_t =  scrmap;
+
+Function GIO_SCRNMAP(fd:longint;var param1 : scrmap_t):boolean;
+Function PIO_SCRNMAP(fd:longint;var param1 : scrmap_t):boolean;
+
+{ get the current text attribute }
+Function GIO_ATTR(fd:longint;var param1 : longint):boolean;
+
+{ get the current text color }
+Function GIO_COLOR(fd:longint;var param1 : longint):boolean;
+
+{ get the adapter type (equivalent to FBIO_ADPTYPE) }
+Function CONS_CURRENT(fd:longint;var param1 : longint):boolean;
+
+{ get the current video mode (equivalent to FBIO_GETMODE) }
+Function CONS_GET(fd:longint;var param1 : longint):boolean;
+
+{ not supported? }
+Function CONS_IO(fd:longint):boolean;
+
+{ set blank time interval }
+Function CONS_BLANKTIME(fd:longint;var param1 : longint):boolean;
+
+{ set/get the screen saver (these FpIoctls are current noop) }
+CONST        maxsaver=16;
+
+type ssaver =record
+                name : array[0..maxsaver-1] of char;
+                num  : Longint;
+                time : Long;
+                end;
+     ssaver_t =   ssaver;
+
+Function CONS_SSAVER(fd:longint;var param1 : ssaver_t):boolean;
+Function CONS_GSAVER(fd:longint;var param1 : ssaver_t):boolean;
+
+{ set the text cursor shape }
+
+CONST
+        CONS_BLINK_CURSOR  = (1  shl  0);
+        CONS_CHAR_CURSOR   = (1  shl  1);
+
+Function CONS_CURSORTYPE(fd:longint;var param1 : longint):boolean;
+
+{ set the bell type to audible or visual }
+CONST
+        CONS_VISUAL_BELL   =(1  shl  0);
+        CONS_QUIET_BELL    =(1  shl  1);
+
+Function CONS_BELLTYPE(fd:longint;var param1 : longint):boolean;
+
+{ set the history (scroll back) buffer size (in lines) }
+Function CONS_HISTORY(fd:longint;var param1 : longint):boolean;
+
+{ mouse cursor FpIoctl }
+type
+        mouse_data      = record
+                            x       : longint;
+                            y       : Longint;
+                            z       : longint;
+                            buttons : longint;
+                           end;
+
+        mouse_data_t    = mouse_data;
+
+        mouse_mode      = record
+                            mode    : longint;
+                            signal  : longint;
+                           end;
+
+        mouse_mode_t    = mouse_mode;
+
+        mouse_event     = record
+                            id    : Longint;   { one based }
+                            value : longint;
+                           end;
+
+        mouse_event_t   = mouse_event;
+
+CONST
+        MOUSE_SHOW           =$01;
+        MOUSE_HIDE           =$02;
+        MOUSE_MOVEABS        =$03;
+        MOUSE_MOVEREL        =$04;
+        MOUSE_GETINFO        =$05;
+        _MOUSE_MODE           =$06;
+        MOUSE_ACTION         =$07;
+        MOUSE_MOTION_EVENT   =$08;
+        MOUSE_BUTTON_EVENT   =$09;
+        MOUSE_MOUSECHAR      =$0a;
+
+TYPE
+        mouse_info = record
+                       operation : longint;
+                       u : record
+                            case integer of
+                               0:  (data : mouse_data_t);
+                               1:  (mode : mouse_mode_t);
+                               2:  (event: mouse_event_t);
+                               3:  (mouse_char : longint);
+                               end;
+                      end;
+        mouse_info_t = mouse_info;
+
+Function CONS_MOUSECTL(fd:longint;var param1 : mouse_info_t):boolean;
+
+{ see if the vty has been idle }
+Function CONS_IDLE(fd:longint;var param1 : longint):boolean;
+
+{ set the screen saver mode }
+CONST
+        CONS_LKM_SAVER = 0;
+        CONS_USR_SAVER =  1;
+
+Function CONS_SAVERMODE(fd:longint;var param1 : longint):boolean;
+
+{ start the screen saver }
+Function CONS_SAVERSTART(fd:longint;var param1 : longint):boolean;
+
+TYPE
+{ set/get font data }
+        fnt8        = record
+                        fnt8x8 : array[0..8*256-1] of char;
+                      end;
+
+        fnt8_t      = fnt8;
+
+        fnt14       = record
+                        fnt8x14: array[0..14*256-1] of char;
+                      end;
+
+        fnt14_t     = fnt14;
+
+        fnt16       = record
+                        fnt8x16: array[0..16*256-1] of char;
+                       end;
+        fnt16_t     = fnt16;
+
+Function PIO_FONT8x8(fd:longint;var param1 : fnt8_t):boolean;
+Function GIO_FONT8x8(fd:longint;var param1 : fnt8_t):boolean;
+Function PIO_FONT8x14(fd:longint;var param1 : fnt14_t):boolean;
+Function GIO_FONT8x14(fd:longint;var param1 : fnt14_t):boolean;
+Function PIO_FONT8x16(fd:longint;var param1 : fnt16_t):boolean;
+Function GIO_FONT8x16(fd:longint;var param1 : fnt16_t):boolean;
+
+
+{ get video mode information }
+type        colors = record
+                       fore : char;
+                       back : char;
+                      end;
+
+            vid_info = record
+                        _size         : short;
+                        m_num         : short;
+                        mv_row,
+                        mv_col        : ushort;
+                        mv_rsz,
+                        mv_csz        : ushort;
+                        mv_norm,
+                        mv_rev,
+                        mv_grfc       : colors;
+                        mv_ovscan     : uchar;
+                        mk_keylock    : uchar;
+                       end;
+        vid_info_t   = vid_info;
+
+Function CONS_GETINFO(fd:longint;var param1 : vid_info_t):boolean;
+
+{ get version }
+
+Function CONS_GETVERS(fd:longint;var param1 : longint):boolean;
+
+{ get the video adapter index (equivalent to FBIO_ADAPTER) }
+Function CONS_CURRENTADP(fd:longint;var param1 : longint):boolean;
+
+{ get the video adapter information (equivalent to FBIO_ADPINFO) }
+Function CONS_ADPINFO(fd:longint;var param1 : video_adapter_info_t):boolean;
+
+{ get the video mode information (equivalent to FBIO_MODEINFO) }
+Function CONS_MODEINFO(fd:longint;var param1 : video_info_t):boolean;
+
+{ find a video mode (equivalent to FBIO_FINDMODE) }
+Function CONS_FINDMODE(fd:longint;var param1 : video_info_t):boolean;
+
+{ set the frame buffer window origin (equivalent to FBIO_SETWINORG) }
+Function CONS_SETWINORG(fd:longint;param1 : longint):boolean;
+
+{ use the specified keyboard }
+Function CONS_SETKBD(fd:longint;param1 : longint):boolean;
+
+{ release the current keyboard }
+Function CONS_RELKBD(fd:longint):boolean;
+
+{ get/set the current terminal emulator info. }
+CONST
+        TI_NAME_LEN   = 32;
+        TI_DESC_LEN   = 64;
+
+TYPE
+        term_info     = record
+                          ti_index    : Longint;
+                          ti_flags    : longint;
+                          ti_name     : array[0..TI_NAME_LEN-1] of uchar;
+                          ti_desc     : array[0..TI_DESC_LEN-1] of uchar;
+                         end;
+        term_info_t   = term_info;
+
+Function CONS_GETTERM(fd:longint;var param1 : term_info_t):boolean;
+Function CONS_SETTERM(fd:longint;var param1 : term_info_t):boolean;
+
+{$ifdef PC98}
+Function ADJUST_CLOCK(fd:longint):boolean;
+{$endif}
+
+{
+* Vty switching FpIoctl commands.
+}
+
+{ get the next available vty }
+Function VT_OPENQRY(fd:longint;var param1 : longint):boolean;
+
+{ set/get vty switching mode }
+const
+        VT_AUTO     =0;       { switching is automatic   }
+        VT_PROCESS  =1;       { switching controlled by prog }
+        VT_KERNEL   =255;     { switching controlled in kernel }
+
+TYPE
+        vt_mode    = record
+                       mode     :   Char;
+                       waitv    :   char;    { not implemented yet  SOS }
+                       relsig   :   short;
+                       acqsig   :   short;
+                       frsig    :   short;   { not implemented yet  SOS }
+                      end;
+
+        vtmode_t  = vt_mode;
+
+
+Function VT_SETMODE(fd:longint;var param1 : vtmode_t):boolean;
+Function VT_GETMODE(fd:longint;var param1 : vtmode_t):boolean;
+
+
+{ acknowledge release or acquisition of a vty }
+const
+        VT_FALSE      = 0;
+        VT_TRUE       = 1;
+        VT_ACKACQ     = 2;
+
+Function VT_RELDISP(fd:longint;param1 : longint):boolean;
+
+{ activate the specified vty }
+Function VT_ACTIVATE(fd:longint;param1 : longint):boolean;
+
+{ wait until the specified vty is activate }
+Function VT_WAITACTIVE(fd:longint;param1 : longint):boolean;
+
+{ get the currently active vty }
+Function VT_GETACTIVE(fd:longint;var param1 : longint):boolean;
+
+{ get the index of the vty }
+Function VT_GETINDEX(fd:longint;var param1 : longint):boolean;
+
+{
+* Video mode switching FpIoctl.  See sys/fbio.h for mode numbers.
+}
+
+Function SW_B40x25(fd:longint):boolean;
+Function SW_C40x25(fd:longint):boolean;
+Function SW_B80x25(fd:longint):boolean;
+Function SW_C80x25(fd:longint):boolean;
+Function SW_BG320(fd:longint):boolean;
+Function SW_CG320(fd:longint):boolean;
+Function SW_BG640(fd:longint):boolean;
+Function SW_EGAMONO80x25(fd:longint):boolean;
+Function SW_CG320_D(fd:longint):boolean;
+Function SW_CG640_E(fd:longint):boolean;
+Function SW_EGAMONOAPA(fd:longint):boolean;
+Function SW_CG640x350(fd:longint):boolean;
+Function SW_ENH_MONOAPA2(fd:longint):boolean;
+Function SW_ENH_CG640(fd:longint):boolean;
+Function SW_ENH_B40x25(fd:longint):boolean;
+Function SW_ENH_C40x25(fd:longint):boolean;
+Function SW_ENH_B80x25(fd:longint):boolean;
+Function SW_ENH_C80x25(fd:longint):boolean;
+Function SW_ENH_B80x43(fd:longint):boolean;
+Function SW_ENH_C80x43(fd:longint):boolean;
+Function SW_MCAMODE(fd:longint):boolean;
+Function SW_VGA_C40x25(fd:longint):boolean;
+Function SW_VGA_C80x25(fd:longint):boolean;
+Function SW_VGA_C80x30(fd:longint):boolean;
+Function SW_VGA_C80x50(fd:longint):boolean;
+Function SW_VGA_C80x60(fd:longint):boolean;
+Function SW_VGA_M80x25(fd:longint):boolean;
+Function SW_VGA_M80x30(fd:longint):boolean;
+Function SW_VGA_M80x50(fd:longint):boolean;
+Function SW_VGA_M80x60(fd:longint):boolean;
+Function SW_VGA11(fd:longint):boolean;
+Function SW_BG640x480(fd:longint):boolean;
+Function SW_VGA12(fd:longint):boolean;
+Function SW_CG640x480(fd:longint):boolean;
+Function SW_VGA13(fd:longint):boolean;
+Function SW_VGA_CG320(fd:longint):boolean;
+Function SW_VGA_CG640(fd:longint):boolean;
+Function SW_VGA_MODEX(fd:longint):boolean;
+Function SW_PC98_80x25(fd:longint):boolean;
+Function SW_PC98_80x30(fd:longint):boolean;
+Function SW_PC98_EGC640x400(fd:longint):boolean;
+Function SW_PC98_PEGC640x400(fd:longint):boolean;
+Function SW_PC98_PEGC640x480(fd:longint):boolean;
+Function SW_VGA_C90x25(fd:longint):boolean;
+Function SW_VGA_M90x25(fd:longint):boolean;
+Function SW_VGA_C90x30(fd:longint):boolean;
+Function SW_VGA_M90x30(fd:longint):boolean;
+Function SW_VGA_C90x43(fd:longint):boolean;
+Function SW_VGA_M90x43(fd:longint):boolean;
+Function SW_VGA_C90x50(fd:longint):boolean;
+Function SW_VGA_M90x50(fd:longint):boolean;
+Function SW_VGA_C90x60(fd:longint):boolean;
+Function SW_VGA_M90x60(fd:longint):boolean;
+Function SW_TEXT_80x25(fd:longint):boolean;
+Function SW_TEXT_80x30(fd:longint):boolean;
+Function SW_TEXT_80x43(fd:longint):boolean;
+Function SW_TEXT_80x50(fd:longint):boolean;
+Function SW_TEXT_80x60(fd:longint):boolean;
+Function SW_TEXT_132x25(fd:longint):boolean;
+Function SW_TEXT_132x30(fd:longint):boolean;
+Function SW_TEXT_132x43(fd:longint):boolean;
+Function SW_TEXT_132x50(fd:longint):boolean;
+Function SW_TEXT_132x60(fd:longint):boolean;
+Function SW_VESA_CG640x400(fd:longint):boolean;
+Function SW_VESA_CG640x480(fd:longint):boolean;
+Function SW_VESA_800x600(fd:longint):boolean;
+Function SW_VESA_CG800x600(fd:longint):boolean;
+Function SW_VESA_1024x768(fd:longint):boolean;
+Function SW_VESA_CG1024x768(fd:longint):boolean;
+Function SW_VESA_1280x1024(fd:longint):boolean;
+Function SW_VESA_CG1280x1024(fd:longint):boolean;
+Function SW_VESA_C80x60(fd:longint):boolean;
+Function SW_VESA_C132x25(fd:longint):boolean;
+Function SW_VESA_C132x43(fd:longint):boolean;
+Function SW_VESA_C132x50(fd:longint):boolean;
+Function SW_VESA_C132x60(fd:longint):boolean;
+Function SW_VESA_32K_320(fd:longint):boolean;
+Function SW_VESA_64K_320(fd:longint):boolean;
+Function SW_VESA_FULL_320(fd:longint):boolean;
+Function SW_VESA_32K_640(fd:longint):boolean;
+Function SW_VESA_64K_640(fd:longint):boolean;
+Function SW_VESA_FULL_640(fd:longint):boolean;
+Function SW_VESA_32K_800(fd:longint):boolean;
+Function SW_VESA_64K_800(fd:longint):boolean;
+Function SW_VESA_FULL_800(fd:longint):boolean;
+Function SW_VESA_32K_1024(fd:longint):boolean;
+Function SW_VESA_64K_1024(fd:longint):boolean;
+Function SW_VESA_FULL_1024(fd:longint):boolean;
+Function SW_VESA_32K_1280(fd:longint):boolean;
+Function SW_VESA_64K_1280(fd:longint):boolean;
+Function SW_VESA_FULL_1280(fd:longint):boolean;
+
+{----------------------------- sys/kbio.h ----------------------------------}
+
+{ version packaged with FreeBSD 4.2-RELEASE
+Translation to FreePascal by Marco van de Voort. (2000-2001), original
+copyright follows: ( I assume BSD licensed)
+
+Based on
+ * $FreeBSD: src/sys/sys/kbio.h,v 1.5.2.1 2000/10/29 16:59:32 dwmalone Exp $
+}
+
+{ get/set keyboard I/O mode}
+const   K_RAW           =0;             { keyboard returns scancodes}
+        K_XLATE         =1;             { keyboard returns ascii}
+        K_CODE          =2;             { keyboard returns keycodes}
+
+{After each FpIoctl value, I've put the type of the parameters to be passed:
+     @int -> pass a pointer to an int.
+      int -> pass pointer(int)
+      -   -> nothing
+@keymap_t -> pass a pointer to a keymap_t
+ etc.
+}
+
+Function KDGKBMODE(fd:longint;var param1 : longint):boolean;
+Function KDSKBMODE(fd:longint;param1 : longint):boolean;
+
+
+{ make tone}
+Function KDMKTONE(fd:longint;param1 : longint):boolean;
+
+{ see console.h for the definitions of the following FpIoctls}
+{$ifndef definconsole}
+Function KDGETMODE(fd:longint;var param1 : longint):boolean;
+Function KDSETMODE(fd:longint;param1 : longint):boolean;
+Function KDSBORDER(fd:longint;param1 : longint):boolean;
+
+{$endif}
+const
+{ get/set keyboard lock state}
+        CLKED           =1;             { Caps locked}
+        NLKED           =2;             { Num locked}
+        SLKED           =4;             { Scroll locked}
+        ALKED           =8;             { AltGr locked}
+        LOCK_MASK       =CLKED or NLKED or SLKED or ALKED;
+
+Function KDGKBSTATE(fd:longint;var param1 : longint):boolean;
+Function KDSKBSTATE(fd:longint;param1 : longint):boolean;
+
+{ enable/disable I/O access}
+Function KDENABIO(fd:longint):boolean;
+Function KDDISABIO(fd:longint):boolean;
+
+{ make sound}
+Function KIOCSOUND(fd:longint;param1 : longint):boolean;
+
+Const
+{ get keyboard model}
+        KB_OTHER        =0;             { keyboard not known}
+        KB_84           =1;             { 'old' 84 key AT-keyboard}
+        KB_101          =2;             { MF-101 or MF-102 keyboard}
+Function KDGKBTYPE(fd:longint;var param1 : longint):boolean;
+
+const
+{ get/set keyboard LED state}
+        LED_CAP         =1;             { Caps lock LED}
+        LED_NUM         =2;             { Num lock LED}
+        LED_SCR         =4;             { Scroll lock LED}
+        LED_MASK        =LED_CAP or LED_NUM or LED_SCR;
+Function KDGETLED(fd:longint;var param1 : longint):boolean;
+Function KDSETLED(fd:longint;param1 : longint):boolean;
+
+{ set keyboard repeat rate (obsolete, use KDSETREPEAT below)}
+Function KDSETRAD(fd:longint;param1 : longint):boolean;
+
+{ see console.h for the definition of the following FpIoctl}
+{$ifndef definconsole}
+Function KDRASTER(fd:longint;var param1 : scr_size_t):boolean;
+
+{$endif}
+
+TYPE
+{ get keyboard information}
+  keyboard_info = Record
+                        kb_index : longint;     { kbdio index#}
+                        kb_name  : array[0..15] of char;        { driver name}
+                        kb_unit  : longint;     { unit#}
+                        kb_type  : longint;     { KB_84, KB_101, KB_OTHER,...}
+                        kb_config: longint;     { device configuration flags}
+                        kb_flags : longint;     { internal flags}
+                 end;
+  keyboard_info_t=keyboard_info;
+
+Function KDGKBINFO(fd:longint;var param1 : keyboard_info_t):boolean;
+
+Type
+{ set/get keyboard repeat rate (new interface)}
+ keyboard_repeat = record
+                    kb_repeat: array[0..1] of longint;
+                   end;
+
+keyboard_repeat_t = keyboard_repeat;
+
+Function KDSETREPEAT(fd:longint;var param1 : keyboard_repeat_t):boolean;
+Function KDGETREPEAT(fd:longint;var param1 : keyboard_repeat_t):boolean;
+
+{ get/set key map/accent map/function key strings}
+
+const
+        NUM_KEYS        =256;           { number of keys in table}
+        NUM_STATES      =8;             { states per key}
+        ALTGR_OFFSET    =128;           { offset for altlock keys}
+
+        NUM_DEADKEYS    =15;            { number of accent keys}
+        NUM_ACCENTCHARS =52;            { max number of accent chars}
+
+        NUM_FKEYS       =96;            { max number of function keys}
+        MAXFK           =16;            { max length of a function key str}
+
+type
+        keyent_t = record
+                        map  : array[0..NUM_STATES-1] of uchar;
+                        spcl : uchar;
+                        flgs : uchar;
+                   end;
+
+const
+        FLAG_LOCK_O     =0;
+        FLAG_LOCK_C     =1;
+        FLAG_LOCK_N     =2;
+
+type keymap = record
+                        n_keys : ushort;
+                        key    : array[0..NUM_KEYS-1] OF keyent_t;
+              end;
+
+     keymap_t= keymap;
+
+CONST
+{ defines for "special" keys (spcl bit set in keymap)}
+        NOP             =$00;           { nothing (dead key)}
+        LSH             =$02;           { left shift key}
+        RSH             =$03;           { right shift key}
+        CLK             =$04;           { caps lock key}
+        NLK             =$05;           { num lock key}
+        SLK             =$06;           { scroll lock key}
+        LALT            =$07;           { left alt key}
+        BTAB            =$08;           { backwards tab}
+        LCTR            =$09;           { left control key}
+        NEXT            =$0a;           { switch to next screen}
+        F_SCR           =$0b;           { switch to first screen}
+        L_SCR           =$1a;           { switch to last screen}
+        F_FN            =$1b;           { first function key}
+        L_FN            =$7a;           { last function key}
+{                        $7b-$7f          reserved do not use !}
+        RCTR            =$80;           { right control key}
+        RALT            =$81;           { right alt (altgr) key}
+        ALK             =$82;           { alt lock key}
+        ASH             =$83;           { alt shift key}
+        META            =$84;           { meta key}
+        RBT             =$85;           { boot machine}
+        DBG             =$86;           { call debugger}
+        SUSP            =$87;           { suspend power (APM)}
+        SPSC            =$88;           { toggle splash/text screen}
+
+        DGRA            =$89;           { grave}
+        F_ACC           =DGRA;          { first accent key}
+
+        DACU            =$8a;           { acute}
+        DCIR            =$8b;           { circumflex}
+        DTIL            =$8c;           { tilde}
+        DMAC            =$8d;           { macron}
+        DBRE            =$8e;           { breve}
+        DDOT            =$8f;           { dot}
+        DUML            =$90;           { umlaut/diaresis}
+        DDIA            =$90;           { diaresis}
+        DSLA            =$91;           { slash}
+        DRIN            =$92;           { ring}
+        DCED            =$93;           { cedilla}
+        DAPO            =$94;           { apostrophe}
+        DDAC            =$95;           { double acute}
+        DOGO            =$96;           { ogonek}
+        DCAR            =$97;           { caron}
+        L_ACC           =DCAR;          { last accent key}
+
+        STBY            =$98;           { Go into standby mode (apm)}
+        PREV            =$99;           { switch to previous screen}
+        PNC             =$9a;           { force system panic}
+        LSHA            =$9b;           { left shift key / alt lock}
+        RSHA            =$9c;           { right shift key / alt lock}
+        LCTRA           =$9d;           { left ctrl key / alt lock}
+        RCTRA           =$9e;           { right ctrl key / alt lock}
+        LALTA           =$9f;           { left alt key / alt lock}
+        RALTA           =$a0;           { right alt key / alt lock}
+        HALT            =$a1;           { halt machine}
+        PDWN            =$a2;           { halt machine and power down}
+
+function kbio_F(x:longint):longint;
+function kbio_S(x:longint):longint;
+function kbio_ACC(x:longint):longint;
+
+type acc_t           = record
+                        accchar : uchar;
+                        map : array[0..NUM_ACCENTCHARS-1,0..1] of uchar;
+                       end;
+
+   accentmap       = record
+                        n_accs : ushort;
+                        acc    : array[0..NUM_DEADKEYS-1] of acc_t
+                       end;
+
+      accentmap_t     =  accentmap ;
+
+     keyarg         = record
+                        keynum : ushort;
+                        key : keyent_t;
+                        end;
+
+       keyarg_t = keyarg;
+
+             fkeytab = record
+                        str : array [0..MAXFK-1] of uchar;
+                        len : uchar;
+                       end;
+             fkeytab_t = fkeytab;
+
+             fkeyarg =record
+                        keynum : ushort;
+                        keydef : array[0..MAXFK-1] of char;
+                        flen :char;
+                        end;
+
+         fkeyarg_t       = fkeyarg;
+
+Function GETFKEY(fd:longint;var param1 : fkeyarg_t):boolean;
+Function SETFKEY(fd:longint;var param1 : fkeyarg_t):boolean;
+
+{$ifndef definconsole}
+Function GIO_SCRNMAP(fd:longint;var param1 : scrmap_t):boolean;
+Function PIO_SCRNMAP(fd:longint;var param1 : scrmap_t):boolean;
+{$endif}
+Function GIO_KEYMAP(fd:longint;var param1 : keymap_t):boolean;
+Function PIO_KEYMAP(fd:longint;var param1 : keymap_t):boolean;
+Function GIO_DEADKEYMAP(fd:longint;var param1 : accentmap_t):boolean;
+Function PIO_DEADKEYMAP(fd:longint;var param1 : accentmap_t):boolean;
+Function GIO_KEYMAPENT(fd:longint;var param1 : keyarg_t):boolean;
+Function PIO_KEYMAPENT(fd:longint;var param1 : keyarg_t):boolean;
+
+{ flags set to the return value in the KD_XLATE mode}
+Const
+        NOKEY           =$100;          { no key pressed marker}
+        FKEY            =$200;          { function key marker}
+        MKEY            =$400;          { meta key marker (prepend ESC)}
+        BKEY            =$800;          { backtab (ESC [ Z)}
+
+        SPCLKEY         =$8000;         { special key}
+        RELKEY          =$4000;         { key released}
+        ERRKEY          =$2000;         { error}
+
+
+function KEYCHAR(c:longint):longint;
+
+function KEYFLAGS(c:longint):longint;
+
+{----------------------------- machine/mouse.h -------------------------------}
+
+{ Based on machine/mouse.h from FreeBSD release 4.2
+
+ * Copyright (c) 1992, 1993 Erik Forsberg.
+ * Copyright (c) 1996, 1997 Kazutaka YOKOTA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ * NO EVENT SHALL I BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD: src/sys/i386/include/mouse.h,v 1.15.2.1 2000/03/21 14:44:10 yokota Exp $
+ }
+
+
+{ FpIoctls }
+
+
+{ mouse status block }
+
+type
+ mousestatus = record
+                 flags    : longint;            { state change flags }
+                 button   : longint;            { button status }
+                 obutton  : longint;            { previous button status }
+                 dx       : longint;            { x movement }
+                 dy       : longint;            { y movement }
+                 dz       : longint;            { z movement }
+                end;
+
+ mousestatus_t = mousestatus;
+
+CONST
+
+{ button }
+       MOUSE_BUTTON1DOWN        =$0001; { left }
+       MOUSE_BUTTON2DOWN        =$0002; { middle }
+       MOUSE_BUTTON3DOWN        =$0004; { right }
+       MOUSE_BUTTON4DOWN        =$0008;
+       MOUSE_BUTTON5DOWN        =$0010;
+       MOUSE_BUTTON6DOWN        =$0020;
+       MOUSE_BUTTON7DOWN        =$0040;
+       MOUSE_BUTTON8DOWN        =$0080;
+       MOUSE_MAXBUTTON          =31;
+       MOUSE_STDBUTTONS         =$0007;         { buttons 1-3 }
+       MOUSE_EXTBUTTONS         =$7ffffff8;     { the others (28 of them!) }
+       MOUSE_BUTTONS            =(MOUSE_STDBUTTONS or MOUSE_EXTBUTTONS);
+
+{ flags }
+       MOUSE_STDBUTTONSCHANGED  =MOUSE_STDBUTTONS;
+       MOUSE_EXTBUTTONSCHANGED  =MOUSE_EXTBUTTONS;
+       MOUSE_BUTTONSCHANGED     =MOUSE_BUTTONS;
+       MOUSE_POSCHANGED         =$80000000;
+
+type
+  mousehw =record
+         buttons : longint;             { -1 if unknown }
+         iftype  : longint;             { MOUSE_IF_XXX }
+         _type    : longint;            { mouse/track ball/pad... }
+         model   : longint;             { I/F dependent model ID: MOUSE_MODEL_XXX }
+         hwid    : longint;             { I/F dependent hardware ID}
+                                 { for the PS/2 mouse, it will be PSM_XXX_ID  }
+          end;
+
+   mousehw_t  = mousehw;
+
+const
+
+{ iftype }
+       MOUSE_IF_UNKNOWN         =(-1);
+       MOUSE_IF_SERIAL          =0;
+       MOUSE_IF_BUS             =1;
+       MOUSE_IF_INPORT          =2;
+       MOUSE_IF_PS2             =3;
+       MOUSE_IF_SYSMOUSE        =4;
+       MOUSE_IF_USB             =5;
+
+{ type }
+       MOUSE_UNKNOWN            =(-1);  { should be treated as a mouse }
+       MOUSE_MOUSE              =0;
+       MOUSE_TRACKBALL          =1;
+       MOUSE_STICK              =2;
+       MOUSE_PAD                =3;
+
+{ model }
+       MOUSE_MODEL_UNKNOWN              =(-1);
+       MOUSE_MODEL_GENERIC              =0;
+       MOUSE_MODEL_GLIDEPOINT           =1;
+       MOUSE_MODEL_NETSCROLL            =2;
+       MOUSE_MODEL_NET                  =3;
+       MOUSE_MODEL_INTELLI              =4;
+       MOUSE_MODEL_THINK                =5;
+       MOUSE_MODEL_EASYSCROLL           =6;
+       MOUSE_MODEL_MOUSEMANPLUS         =7;
+       MOUSE_MODEL_KIDSPAD              =8;
+       MOUSE_MODEL_VERSAPAD             =9;
+       MOUSE_MODEL_EXPLORER             =10;
+       MOUSE_MODEL_4D                   =11;
+       MOUSE_MODEL_4DPLUS               =12;
+
+type  mousemode = record
+                    protocol    : longint;              { MOUSE_PROTO_XXX }
+                    rate        : longint;              { report rate (per sec), -1 if unknown }
+                    resolution  : longint;              { MOUSE_RES_XXX, -1 if unknown }
+                    accelfactor : longint;              { accelation factor (must be 1 or greater) }
+                    level       : longint;              { driver operation level }
+                    packetsize  : longint;              { the length of the data packet }
+                    syncmask    : array[0..1] of uchar; { sync. data bits in the header byte }
+                  end;
+
+type mousemode_t = mousemode;
+
+{ protocol }
+{
+ * Serial protocols:
+ *   Microsoft, MouseSystems, Logitech, MM series, MouseMan, Hitachi Tablet,
+ *   GlidePoint, IntelliMouse, Thinking Mouse, MouseRemote, Kidspad,
+ *   VersaPad
+ * Bus mouse protocols:
+ *   bus, InPort
+ * PS/2 mouse protocol:
+ *   PS/2
+ }
+ const
+
+       MOUSE_PROTO_UNKNOWN      =(-1);
+       MOUSE_PROTO_MS           =0;     { Microsoft Serial, 3 bytes }
+       MOUSE_PROTO_MSC          =1;     { Mouse Systems, 5 bytes }
+       MOUSE_PROTO_LOGI         =2;     { Logitech, 3 bytes }
+       MOUSE_PROTO_MM           =3;     { MM series, 3 bytes }
+       MOUSE_PROTO_LOGIMOUSEMAN =4;     { Logitech MouseMan 3/4 bytes }
+       MOUSE_PROTO_BUS          =5;     { MS/Logitech bus mouse }
+       MOUSE_PROTO_INPORT       =6;     { MS/ATI InPort mouse }
+       MOUSE_PROTO_PS2          =7;     { PS/2 mouse, 3 bytes }
+       MOUSE_PROTO_HITTAB       =8;     { Hitachi Tablet 3 bytes }
+       MOUSE_PROTO_GLIDEPOINT   =9;     { ALPS GlidePoint, 3/4 bytes }
+       MOUSE_PROTO_INTELLI      =10;    { MS IntelliMouse, 4 bytes }
+       MOUSE_PROTO_THINK        =11;    { Kensignton Thinking Mouse, 3/4 bytes }
+       MOUSE_PROTO_SYSMOUSE     =12;    { /dev/sysmouse }
+       MOUSE_PROTO_X10MOUSEREM  =13;    { X10 MouseRemote, 3 bytes }
+       MOUSE_PROTO_KIDSPAD      =14;    { Genius Kidspad }
+       MOUSE_PROTO_VERSAPAD     =15;    { Interlink VersaPad, 6 bytes }
+
+       MOUSE_RES_UNKNOWN        =(-1);
+       MOUSE_RES_DEFAULT        =0;
+       MOUSE_RES_LOW            =(-2);
+       MOUSE_RES_MEDIUMLOW      =(-3);
+       MOUSE_RES_MEDIUMHIGH     =(-4);
+       MOUSE_RES_HIGH           =(-5);
+
+type  mousedata = record
+        len : longint;          { # of data in the buffer }
+        buf : array [0..15] of longint;         { data buffer }
+        end;
+
+ mousedata_t=mousedata;
+
+ mousevar  = record
+               _var : array[0..15] of longint;
+               end;
+
+type mousevar_t = mousevar;
+
+Function MOUSE_GETSTATUS(fd:longint;var param1 : mousestatus_t):boolean;
+Function MOUSE_GETHWINFO(fd:longint;var param1 : mousehw_t):boolean;
+Function MOUSE_GETMODE(fd:longint;var param1 : mousemode_t):boolean;
+Function MOUSE_SETMODE(fd:longint;var param1 : mousemode_t):boolean;
+Function MOUSE_GETLEVEL(fd:longint;var param1 : longint):boolean;
+Function MOUSE_SETLEVEL(fd:longint;var param1 : longint):boolean;
+Function MOUSE_GETVARS(fd:longint;var param1 : mousevar_t):boolean;
+Function MOUSE_SETVARS(fd:longint;var param1 : mousevar_t):boolean;
+Function MOUSE_READSTATE(fd:longint;var param1 : mousedata_t):boolean;
+Function MOUSE_READDATA(fd:longint;var param1 : mousedata_t):boolean;
+
+Function MOUSE_SETRESOLUTION(fd:longint;var param1 : longint):boolean;
+Function MOUSE_SETSCALING(fd:longint;var param1 : longint):boolean;
+Function MOUSE_SETRATE(fd:longint;var param1 : longint):boolean;
+Function MOUSE_GETHWID(fd:longint;var param1 : longint):boolean;
+
+
+
+const
+
+{ magic numbers in var[0] }
+       MOUSE_VARS_PS2_SIG       = $00325350;    { 'PS2' }
+       MOUSE_VARS_BUS_SIG       = $00535542;    { 'BUS' }
+       MOUSE_VARS_INPORT_SIG    = $00504e49;    { 'INP' }
+
+{ Microsoft Serial mouse data packet }
+       MOUSE_MSS_PACKETSIZE     = 3;
+       MOUSE_MSS_SYNCMASK       = $40;
+       MOUSE_MSS_SYNC           = $40;
+       MOUSE_MSS_BUTTONS        = $30;
+       MOUSE_MSS_BUTTON1DOWN    = $20;  { left }
+       MOUSE_MSS_BUTTON2DOWN    = $00;  { no middle button }
+       MOUSE_MSS_BUTTON3DOWN    = $10;  { right }
+
+{ Logitech MouseMan data packet (M+ protocol) }
+       MOUSE_LMAN_BUTTON2DOWN   = $20;  { middle button, the 4th byte }
+
+{ ALPS GlidePoint extention (variant of M+ protocol) }
+       MOUSE_ALPS_BUTTON2DOWN   = $20;  { middle button, the 4th byte }
+       MOUSE_ALPS_TAP           = $10;  { `tapping' action, the 4th byte }
+
+{ Kinsington Thinking Mouse extention (variant of M+ protocol) }
+       MOUSE_THINK_BUTTON2DOWN = $20;   { lower-left button, the 4th byte }
+       MOUSE_THINK_BUTTON4DOWN = $10;   { lower-right button, the 4th byte }
+
+{ MS IntelliMouse (variant of MS Serial) }
+       MOUSE_INTELLI_PACKETSIZE  = 4;
+       MOUSE_INTELLI_BUTTON2DOWN = $10; { middle button in the 4th byte }
+
+{ Mouse Systems Corp. mouse data packet }
+       MOUSE_MSC_PACKETSIZE     = 5;
+       MOUSE_MSC_SYNCMASK       = $f8;
+       MOUSE_MSC_SYNC           = $80;
+       MOUSE_MSC_BUTTONS        = $07;
+       MOUSE_MSC_BUTTON1UP      = $04;  { left }
+       MOUSE_MSC_BUTTON2UP      = $02;  { middle }
+       MOUSE_MSC_BUTTON3UP      = $01;  { right }
+       MOUSE_MSC_MAXBUTTON      = 3;
+
+{ MM series mouse data packet }
+       MOUSE_MM_PACKETSIZE      = 3;
+       MOUSE_MM_SYNCMASK        = $e0;
+       MOUSE_MM_SYNC            = $80;
+       MOUSE_MM_BUTTONS         = $07;
+       MOUSE_MM_BUTTON1DOWN     = $04;  { left }
+       MOUSE_MM_BUTTON2DOWN     = $02;  { middle }
+       MOUSE_MM_BUTTON3DOWN     = $01;  { right }
+       MOUSE_MM_XPOSITIVE       = $10;
+       MOUSE_MM_YPOSITIVE       = $08;
+
+{ PS/2 mouse data packet }
+       MOUSE_PS2_PACKETSIZE     = 3;
+       MOUSE_PS2_SYNCMASK       = $c8;
+       MOUSE_PS2_SYNC           = $08;
+       MOUSE_PS2_BUTTONS        = $07;  { = $03 for 2 button mouse }
+       MOUSE_PS2_BUTTON1DOWN    = $01;  { left }
+       MOUSE_PS2_BUTTON2DOWN    = $04;  { middle }
+       MOUSE_PS2_BUTTON3DOWN    = $02;  { right }
+       MOUSE_PS2_TAP            = MOUSE_PS2_SYNC; { GlidePoint (PS/2) `tapping'
+                                                * Yes! this is the same bit
+                                                * as SYNC!
+                                                }
+
+       MOUSE_PS2_XNEG           = $10;
+       MOUSE_PS2_YNEG           = $20;
+       MOUSE_PS2_XOVERFLOW      = $40;
+       MOUSE_PS2_YOVERFLOW      = $80;
+
+{ Logitech MouseMan+ (PS/2) data packet (PS/2++ protocol) }
+       MOUSE_PS2PLUS_SYNCMASK   = $48;
+       MOUSE_PS2PLUS_SYNC       = $48;
+       MOUSE_PS2PLUS_ZNEG       = $08;  { sign bit }
+       MOUSE_PS2PLUS_BUTTON4DOWN = $10; { 4th button on MouseMan+ }
+       MOUSE_PS2PLUS_BUTTON5DOWN = $20;
+
+{ IBM ScrollPoint (PS/2) also uses PS/2++ protocol }
+       MOUSE_SPOINT_ZNEG        = $80;  { sign bits }
+       MOUSE_SPOINT_WNEG        = $08;
+
+{ MS IntelliMouse (PS/2) data packet }
+       MOUSE_PS2INTELLI_PACKETSIZE = 4;
+{ some compatible mice have additional buttons }
+       MOUSE_PS2INTELLI_BUTTON4DOWN = $40;
+       MOUSE_PS2INTELLI_BUTTON5DOWN = $80;
+
+{ MS IntelliMouse Explorer (PS/2) data packet (variation of IntelliMouse) }
+       MOUSE_EXPLORER_ZNEG        = $08;        { sign bit }
+{ IntelliMouse Explorer has additional button data in the fourth byte }
+       MOUSE_EXPLORER_BUTTON4DOWN = $10;
+       MOUSE_EXPLORER_BUTTON5DOWN = $20;
+
+{ Interlink VersaPad (serial I/F) data packet }
+       MOUSE_VERSA_PACKETSIZE   = 6;
+       MOUSE_VERSA_IN_USE       = $04;
+       MOUSE_VERSA_SYNCMASK     = $c3;
+       MOUSE_VERSA_SYNC         = $c0;
+       MOUSE_VERSA_BUTTONS      = $30;
+       MOUSE_VERSA_BUTTON1DOWN  = $20;  { left }
+       MOUSE_VERSA_BUTTON2DOWN  = $00;  { middle }
+       MOUSE_VERSA_BUTTON3DOWN  = $10;  { right }
+       MOUSE_VERSA_TAP          = $08;
+
+{ Interlink VersaPad (PS/2 I/F) data packet }
+       MOUSE_PS2VERSA_PACKETSIZE        = 6;
+       MOUSE_PS2VERSA_IN_USE            = $10;
+       MOUSE_PS2VERSA_SYNCMASK          = $e8;
+       MOUSE_PS2VERSA_SYNC              = $c8;
+       MOUSE_PS2VERSA_BUTTONS           = $05;
+       MOUSE_PS2VERSA_BUTTON1DOWN       = $04;  { left }
+       MOUSE_PS2VERSA_BUTTON2DOWN       = $00;  { middle }
+       MOUSE_PS2VERSA_BUTTON3DOWN       = $01;  { right }
+       MOUSE_PS2VERSA_TAP               = $02;
+
+{ A4 Tech 4D Mouse (PS/2) data packet }
+       MOUSE_4D_PACKETSIZE              = 3;
+       MOUSE_4D_WHEELBITS               = $f0;
+
+{ A4 Tech 4D+ Mouse (PS/2) data packet }
+       MOUSE_4DPLUS_PACKETSIZE          = 3;
+       MOUSE_4DPLUS_ZNEG                = $04;  { sign bit }
+       MOUSE_4DPLUS_BUTTON4DOWN         = $08;
+
+{ sysmouse extended data packet }
+{
+ * /dev/sysmouse sends data in two formats, depending on the protocol
+ * level.  At the level 0, format is exactly the same as MousSystems'
+ * five byte packet.  At the level 1, the first five bytes are the same
+ * as at the level 0.  There are additional three bytes which shows
+ * `dz' and the states of additional buttons.  `dz' is expressed as the
+ * sum of the byte 5 and 6 which contain signed seven bit values.
+ * The states of the button 4 though 10 are in the bit 0 though 6 in
+ * the byte 7 respectively: 1 indicates the button is up.
+ }
+       MOUSE_SYS_PACKETSIZE     = 8;
+       MOUSE_SYS_SYNCMASK       = $f8;
+       MOUSE_SYS_SYNC           = $80;
+       MOUSE_SYS_BUTTON1UP      = $04;  { left, 1st byte }
+       MOUSE_SYS_BUTTON2UP      = $02;  { middle, 1st byte }
+       MOUSE_SYS_BUTTON3UP      = $01;  { right, 1st byte }
+       MOUSE_SYS_BUTTON4UP      = $0001;        { 7th byte }
+       MOUSE_SYS_BUTTON5UP      = $0002;
+       MOUSE_SYS_BUTTON6UP      = $0004;
+       MOUSE_SYS_BUTTON7UP      = $0008;
+       MOUSE_SYS_BUTTON8UP      = $0010;
+       MOUSE_SYS_BUTTON9UP      = $0020;
+       MOUSE_SYS_BUTTON10UP     = $0040;
+       MOUSE_SYS_MAXBUTTON      = 10;
+       MOUSE_SYS_STDBUTTONS     = $07;
+       MOUSE_SYS_EXTBUTTONS     = $7f;  { the others }
+
+{ Mouse remote socket }
+       _PATH_MOUSEREMOTE        ='/var/run/MouseRemote';
+
+
+{fbio FpIoctl numbers}
+           nr_FBIOGTYPE     =$40184600;
+           nr_FBIOGINFO     =$40184602;
+           nr_FBIOPUTCMAP     =$80144603;
+           nr_FBIOGETCMAP     =$80144604;
+           nr_FBIOGATTR     =$40584606;
+           nr_FBIOSVIDEO     =$80044607;
+           nr_FBIOGVIDEO     =$40044608;
+           nr_FBIOSCURSOR     =$802c4618;
+           nr_FBIOGCURSOR     =$c02c4619;
+           nr_FBIOSCURPOS     =$8004461a;
+           nr_FBIOGCURPOS     =$8004461b;
+           nr_FBIOGCURMAX     =$4004461c;
+           nr_FBIO_ADAPTER     =$40044664;
+           nr_FBIO_ADPTYPE     =$40044665;
+           nr_FBIO_ADPINFO     =$40a44666;
+           nr_FBIO_MODEINFO     =$c09c4667;
+           nr_FBIO_FINDMODE     =$c09c4668;
+           nr_FBIO_GETMODE     =$40044669;
+           nr_FBIO_SETMODE     =$8004466a;
+           nr_FBIO_GETWINORG     =$4004466b;
+           nr_FBIO_SETWINORG     =$8004466c;
+           nr_FBIO_GETDISPSTART     =$4008466d;
+           nr_FBIO_SETDISPSTART     =$8008466e;
+           nr_FBIO_GETLINEWIDTH     =$4004466f;
+           nr_FBIO_SETLINEWIDTH     =$80044670;
+           nr_FBIO_GETPALETTE     =$80184671;
+           nr_FBIO_SETPALETTE     =$80184672;
+
+{consio FpIoctl numbers}
+
+           nr_KDGETMODE     =$40044b09;
+           nr_KDSETMODE     =$20004b0a;
+           nr_KDSBORDER     =$20004b0d;
+           nr_KDRASTER     =$800c4b64;
+           nr_GIO_SCRNMAP     =$41006b02;
+           nr_PIO_SCRNMAP     =$81006b03;
+           nr_GIO_ATTR     =$40046100;
+           nr_GIO_COLOR     =$40046300;
+           nr_CONS_CURRENT     =$40046301;
+           nr_CONS_GET     =$40046302;
+           nr_CONS_IO     =$20006303;
+           nr_CONS_BLANKTIME     =$80046304;
+           nr_CONS_SSAVER     =$80186305;
+           nr_CONS_GSAVER     =$c0186306;
+           nr_CONS_CURSORTYPE     =$80046307;
+           nr_CONS_BELLTYPE     =$80046308;
+           nr_CONS_HISTORY     =$80046309;
+           nr_CONS_MOUSECTL     =$c014630a;
+           nr_CONS_IDLE     =$4004630b;
+           nr_CONS_SAVERMODE     =$8004630c;
+           nr_CONS_SAVERSTART     =$8004630d;
+           nr_PIO_FONT8x8     =$88006340;
+           nr_GIO_FONT8x8     =$48006341;
+           nr_PIO_FONT8x14     =$8e006342;
+           nr_GIO_FONT8x14     =$4e006343;
+           nr_PIO_FONT8x16     =$90006344;
+           nr_GIO_FONT8x16     =$50006345;
+           nr_CONS_GETINFO     =$c0146349;
+           nr_CONS_GETVERS     =$4004634a;
+           nr_CONS_CURRENTADP     =$40046364;
+           nr_CONS_ADPINFO     =$c0a46365;
+           nr_CONS_MODEINFO     =$c09c6366;
+           nr_CONS_FINDMODE     =$c09c6367;
+           nr_CONS_SETWINORG     =$20006368;
+           nr_CONS_SETKBD     =$2000636e;
+           nr_CONS_RELKBD     =$2000636f;
+           nr_CONS_GETTERM     =$c0686370;
+           nr_CONS_SETTERM     =$80686371;
+           nr_ADJUST_CLOCK     =$20007464;
+           nr_VT_OPENQRY     =$40047601;
+           nr_VT_SETMODE     =$80087602;
+           nr_VT_GETMODE     =$40087603;
+           nr_VT_RELDISP     =$20007604;
+           nr_VT_ACTIVATE     =$20007605;
+           nr_VT_WAITACTIVE     =$20007606;
+           nr_VT_GETACTIVE     =$40047607;
+           nr_VT_GETINDEX     =$40047608;
+           nr_SW_B40x25     =$20005300;
+           nr_SW_C40x25     =$20005301;
+           nr_SW_B80x25     =$20005302;
+           nr_SW_C80x25     =$20005303;
+           nr_SW_BG320     =$20005304;
+           nr_SW_CG320     =$20005305;
+           nr_SW_BG640     =$20005306;
+           nr_SW_EGAMONO80x25     =$20005307;
+           nr_SW_CG320_D     =$2000530d;
+           nr_SW_CG640_E     =$2000530e;
+           nr_SW_EGAMONOAPA     =$2000530f;
+           nr_SW_CG640x350     =$20005310;
+           nr_SW_ENH_MONOAPA2     =$20005311;
+           nr_SW_ENH_CG640     =$20005312;
+           nr_SW_ENH_B40x25     =$20005313;
+           nr_SW_ENH_C40x25     =$20005314;
+           nr_SW_ENH_B80x25     =$20005315;
+           nr_SW_ENH_C80x25     =$20005316;
+           nr_SW_ENH_B80x43     =$20005370;
+           nr_SW_ENH_C80x43     =$20005371;
+           nr_SW_MCAMODE     =$200053ff;
+           nr_SW_VGA_C40x25     =$20005317;
+           nr_SW_VGA_C80x25     =$20005318;
+           nr_SW_VGA_C80x30     =$20005320;
+           nr_SW_VGA_C80x50     =$2000531e;
+           nr_SW_VGA_C80x60     =$20005322;
+           nr_SW_VGA_M80x25     =$20005319;
+           nr_SW_VGA_M80x30     =$20005321;
+           nr_SW_VGA_M80x50     =$2000531f;
+           nr_SW_VGA_M80x60     =$20005323;
+           nr_SW_VGA11     =$2000531a;
+           nr_SW_BG640x480     =$2000531a;
+           nr_SW_VGA12     =$2000531b;
+           nr_SW_CG640x480     =$2000531b;
+           nr_SW_VGA13     =$2000531c;
+           nr_SW_VGA_CG320     =$2000531c;
+           nr_SW_VGA_CG640     =$20005324;
+           nr_SW_VGA_MODEX     =$20005325;
+           nr_SW_PC98_80x25     =$20005362;
+           nr_SW_PC98_80x30     =$20005363;
+           nr_SW_PC98_EGC640x400     =$20005364;
+           nr_SW_PC98_PEGC640x400     =$20005365;
+           nr_SW_PC98_PEGC640x480     =$20005366;
+           nr_SW_VGA_C90x25     =$20005328;
+           nr_SW_VGA_M90x25     =$20005329;
+           nr_SW_VGA_C90x30     =$2000532a;
+           nr_SW_VGA_M90x30     =$2000532b;
+           nr_SW_VGA_C90x43     =$2000532c;
+           nr_SW_VGA_M90x43     =$2000532d;
+           nr_SW_VGA_C90x50     =$2000532e;
+           nr_SW_VGA_M90x50     =$2000532f;
+           nr_SW_VGA_C90x60     =$20005330;
+           nr_SW_VGA_M90x60     =$20005331;
+           nr_SW_TEXT_80x25     =$200053c8;
+           nr_SW_TEXT_80x30     =$200053c9;
+           nr_SW_TEXT_80x43     =$200053ca;
+           nr_SW_TEXT_80x50     =$200053cb;
+           nr_SW_TEXT_80x60     =$200053cc;
+           nr_SW_TEXT_132x25     =$200053cd;
+           nr_SW_TEXT_132x30     =$200053ce;
+           nr_SW_TEXT_132x43     =$200053cf;
+           nr_SW_TEXT_132x50     =$200053d0;
+           nr_SW_TEXT_132x60     =$200053d1;
+           nr_SW_VESA_CG640x400     =$20005600;
+           nr_SW_VESA_CG640x480     =$20005601;
+           nr_SW_VESA_800x600     =$20005602;
+           nr_SW_VESA_CG800x600     =$20005603;
+           nr_SW_VESA_1024x768     =$20005604;
+           nr_SW_VESA_CG1024x768     =$20005605;
+           nr_SW_VESA_1280x1024     =$20005606;
+           nr_SW_VESA_CG1280x1024     =$20005607;
+           nr_SW_VESA_C80x60     =$20005608;
+           nr_SW_VESA_C132x25     =$20005609;
+           nr_SW_VESA_C132x43     =$2000560a;
+           nr_SW_VESA_C132x50     =$2000560b;
+           nr_SW_VESA_C132x60     =$2000560c;
+           nr_SW_VESA_32K_320     =$2000560d;
+           nr_SW_VESA_64K_320     =$2000560e;
+           nr_SW_VESA_FULL_320     =$2000560f;
+           nr_SW_VESA_32K_640     =$20005610;
+           nr_SW_VESA_64K_640     =$20005611;
+           nr_SW_VESA_FULL_640     =$20005612;
+           nr_SW_VESA_32K_800     =$20005613;
+           nr_SW_VESA_64K_800     =$20005614;
+           nr_SW_VESA_FULL_800     =$20005615;
+           nr_SW_VESA_32K_1024     =$20005616;
+           nr_SW_VESA_64K_1024     =$20005617;
+           nr_SW_VESA_FULL_1024     =$20005618;
+           nr_SW_VESA_32K_1280     =$20005619;
+           nr_SW_VESA_64K_1280     =$2000561a;
+           nr_SW_VESA_FULL_1280     =$2000561b;
+
+{kbdsio FpIoctl numbers}
+
+           nr_KDGKBMODE     =$40044b06;
+           nr_KDSKBMODE     =$20004b07;
+           nr_KDMKTONE     =$20004b08;
+{$ifndef definconsole}
+           nr_KDGETMODE     =$40044b09;
+           nr_KDSETMODE     =$20004b0a;
+           nr_KDSBORDER     =$20004b0d;
+{$endif}
+           nr_KDGKBSTATE     =$40044b13;
+           nr_KDSKBSTATE     =$20004b14;
+           nr_KDENABIO     =$20004b3c;
+           nr_KDDISABIO     =$20004b3d;
+           nr_KIOCSOUND     =$20004b3f;
+           nr_KDGKBTYPE     =$40044b40;
+           nr_KDGETLED     =$40044b41;
+           nr_KDSETLED     =$20004b42;
+           nr_KDSETRAD     =$20004b43;
+{$ifndef definconsole}
+           nr_KDRASTER     =$800c4b64;
+{$endif}
+           nr_KDGKBINFO     =$40244b65;
+           nr_KDSETREPEAT     =$80084b66;
+           nr_KDGETREPEAT     =$40084b67;
+           nr_GETFKEY     =$c0146b00;
+           nr_SETFKEY     =$c0146b01;
+{$ifndef definconsole}
+           nr_GIO_SCRNMAP     =$41006b02;
+           nr_PIO_SCRNMAP     =$81006b03;
+{$endif}
+           nr_GIO_KEYMAP     =$4a026b06;
+           nr_PIO_KEYMAP     =$8a026b07;
+           nr_GIO_DEADKEYMAP     =$462a6b08;
+           nr_PIO_DEADKEYMAP     =$862a6b09;
+           nr_GIO_KEYMAPENT     =$c00c6b0a;
+           nr_PIO_KEYMAPENT     =$800c6b0b;
+
+
+
+{mouse FpIoctl numbers}
+           nr_MOUSE_GETSTATUS     =$40184d00;
+           nr_MOUSE_GETHWINFO     =$40144d01;
+           nr_MOUSE_GETMODE     =$401c4d02;
+           nr_MOUSE_SETMODE     =$801c4d03;
+           nr_MOUSE_GETLEVEL     =$40044d04;
+           nr_MOUSE_SETLEVEL     =$80044d05;
+           nr_MOUSE_GETVARS     =$40404d06;
+           nr_MOUSE_SETVARS     =$80404d07;
+           nr_MOUSE_READSTATE     =$c0444d08;
+           nr_MOUSE_READDATA     =$c0444d09;
+           nr_MOUSE_SETRESOLUTION     =$80044d0a;
+           nr_MOUSE_SETSCALING     =$80044d0b;
+           nr_MOUSE_SETRATE     =$80044d0c;
+           nr_MOUSE_GETHWID     =$40044d0d;
+
+{------------- Added procedures ---------------}
+
+function physicalconsole(fd:longint) : boolean;
+
+IMPLEMENTATION
+
+Uses BaseUnix,termio;
+
+function physicalconsole(fd:longint) : boolean;
+
+var name:string;
+
+begin
+ if (isatty(fd)<>-1) then
+  begin
+   name:=ttyname(fd);
+   if Copy(name,1,8)<>'/dev/tty' then
+    physicalconsole:=false              {isatty is true, but not /dev/tty.
+                                           Could be /dev/pts support, but
+                                           I reserve the case}
+   else
+    begin
+     if name[9]='v' then                        {ttyv is phys console. see /etc/ttys}
+      physicalconsole:=true
+     else
+      physicalconsole:=false;
+    end;
+  end
+ else
+  physicalconsole:=false;       {Not a tty, then I don't know what it is}
+end;
+
+{other macros (not FpIoctl)}
+
+function KEYCHAR(c:longint):longint;
+
+begin
+  c:=c and $FF;
+end;
+
+function KEYFLAGS(c:longint):longint;
+
+begin
+  c:=c and NOT $FF;
+end;
+
+function kbio_F(x:longint):longint;
+begin
+ kbio_f:=x+F_FN-1;
+end;
+
+function kbio_S(x:longint):longint;
+begin
+ kbio_S:=x+F_SCR-1;
+end;
+
+function kbio_ACC(x:longint):longint;
+begin
+ kbio_ACC:=x+F_ACC;
+end;
+
+{fbio.h FpIoctl's}
+
+Function FBIOGTYPE(fd:longint;var param1 : fbtype):boolean;
+{IOR('F',0,sizeof(struct fbtype) }
+
+Begin
+ FBIOGTYPE:=FpIoctl(fd,nr_FBIOGTYPE,@param1)=0;
+end;
+
+Function FBIOGINFO(fd:longint;var param1 : fbinfo):boolean;
+{IOR('F',2,sizeof(struct fbinfo) }
+
+Begin
+ FBIOGINFO:=FpIoctl(fd,nr_FBIOGINFO,@param1)=0;
+end;
+
+Function FBIOPUTCMAP(fd:longint;var param1 : fbcmap):boolean;
+{IOW('F',3,sizeof(struct fbcmap) }
+
+Begin
+ FBIOPUTCMAP:=FpIoctl(fd,nr_FBIOPUTCMAP,@param1)=0;
+end;
+
+Function FBIOGETCMAP(fd:longint;var param1 : fbcmap):boolean;
+{IOW('F',4,sizeof(struct fbcmap) }
+
+Begin
+ FBIOGETCMAP:=FpIoctl(fd,nr_FBIOGETCMAP,@param1)=0;
+end;
+
+Function FBIOGATTR(fd:longint;var param1 : fbgattr):boolean;
+{IOR('F',6,sizeof(struct fbgattr) }
+
+Begin
+ FBIOGATTR:=FpIoctl(fd,nr_FBIOGATTR,@param1)=0;
+end;
+
+Function FBIOSVIDEO(fd:longint;var param1 : longint):boolean;
+{IOW('F',7,sizeof(int) }
+
+Begin
+ FBIOSVIDEO:=FpIoctl(fd,nr_FBIOSVIDEO,@param1)=0;
+end;
+
+Function FBIOGVIDEO(fd:longint;var param1 : longint):boolean;
+{IOR('F',8,sizeof(int) }
+
+Begin
+ FBIOGVIDEO:=FpIoctl(fd,nr_FBIOGVIDEO,@param1)=0;
+end;
+
+Function FBIOSCURSOR(fd:longint;var param1 : fbcursor):boolean;
+{IOW('F',24,sizeof(struct fbcursor) }
+
+Begin
+ FBIOSCURSOR:=FpIoctl(fd,nr_FBIOSCURSOR,@param1)=0;
+end;
+
+Function FBIOGCURSOR(fd:longint;var param1 : fbcursor):boolean;
+{IOWR('F',25,sizeof(struct fbcursor) }
+
+Begin
+ FBIOGCURSOR:=FpIoctl(fd,nr_FBIOGCURSOR,@param1)=0;
+end;
+
+Function FBIOSCURPOS(fd:longint;var param1 : fbcurpos):boolean;
+{IOW('F',26,sizeof(struct fbcurpos) }
+
+Begin
+ FBIOSCURPOS:=FpIoctl(fd,nr_FBIOSCURPOS,@param1)=0;
+end;
+
+Function FBIOGCURPOS(fd:longint;var param1 : fbcurpos):boolean;
+{IOW('F',27,sizeof(struct fbcurpos) }
+
+Begin
+ FBIOGCURPOS:=FpIoctl(fd,nr_FBIOGCURPOS,@param1)=0;
+end;
+
+Function FBIOGCURMAX(fd:longint;var param1 : fbcurpos):boolean;
+{IOR('F',28,sizeof(struct fbcurpos) }
+
+Begin
+ FBIOGCURMAX:=FpIoctl(fd,nr_FBIOGCURMAX,@param1)=0;
+end;
+
+Function FBIO_ADAPTER(fd:longint;var param1 : longint):boolean;
+{IOR('F',100,sizeof(int) }
+
+Begin
+ FBIO_ADAPTER:=FpIoctl(fd,nr_FBIO_ADAPTER,@param1)=0;
+end;
+
+Function FBIO_ADPTYPE(fd:longint;var param1 : longint):boolean;
+{IOR('F',101,sizeof(int) }
+
+Begin
+ FBIO_ADPTYPE:=FpIoctl(fd,nr_FBIO_ADPTYPE,@param1)=0;
+end;
+
+Function FBIO_ADPINFO(fd:longint;var param1 : video_adapter_info):boolean;
+{IOR('F',102,sizeof(struct video_adapter_info) }
+
+Begin
+ FBIO_ADPINFO:=FpIoctl(fd,nr_FBIO_ADPINFO,@param1)=0;
+end;
+
+Function FBIO_MODEINFO(fd:longint;var param1 : video_info):boolean;
+{IOWR('F',103,sizeof(struct video_info) }
+
+Begin
+ FBIO_MODEINFO:=FpIoctl(fd,nr_FBIO_MODEINFO,@param1)=0;
+end;
+
+Function FBIO_FINDMODE(fd:longint;var param1 : video_info):boolean;
+{IOWR('F',104,sizeof(struct video_info) }
+
+Begin
+ FBIO_FINDMODE:=FpIoctl(fd,nr_FBIO_FINDMODE,@param1)=0;
+end;
+
+Function FBIO_GETMODE(fd:longint;var param1 : longint):boolean;
+{IOR('F',105,sizeof(int) }
+
+Begin
+ FBIO_GETMODE:=FpIoctl(fd,nr_FBIO_GETMODE,@param1)=0;
+end;
+
+Function FBIO_SETMODE(fd:longint;var param1 : longint):boolean;
+{IOW('F',106,sizeof(int) }
+
+Begin
+ FBIO_SETMODE:=FpIoctl(fd,nr_FBIO_SETMODE,@param1)=0;
+end;
+
+Function FBIO_GETWINORG(fd:longint;var param1 : u_int):boolean;
+{IOR('F',107,sizeof(u_int) }
+
+Begin
+ FBIO_GETWINORG:=FpIoctl(fd,nr_FBIO_GETWINORG,@param1)=0;
+end;
+
+Function FBIO_SETWINORG(fd:longint;var param1 : u_int):boolean;
+{IOW('F',108,sizeof(u_int) }
+
+Begin
+ FBIO_SETWINORG:=FpIoctl(fd,nr_FBIO_SETWINORG,@param1)=0;
+end;
+
+Function FBIO_GETDISPSTART(fd:longint;var param1 : video_display_start_t):boolean;
+{IOR('F',109,sizeof(video_display_start_t) }
+
+Begin
+ FBIO_GETDISPSTART:=FpIoctl(fd,nr_FBIO_GETDISPSTART,@param1)=0;
+end;
+
+Function FBIO_SETDISPSTART(fd:longint;var param1 : video_display_start_t):boolean;
+{IOW('F',110,sizeof(video_display_start_t) }
+
+Begin
+ FBIO_SETDISPSTART:=FpIoctl(fd,nr_FBIO_SETDISPSTART,@param1)=0;
+end;
+
+Function FBIO_GETLINEWIDTH(fd:longint;var param1 : u_int):boolean;
+{IOR('F',111,sizeof(u_int) }
+
+Begin
+ FBIO_GETLINEWIDTH:=FpIoctl(fd,nr_FBIO_GETLINEWIDTH,@param1)=0;
+end;
+
+Function FBIO_SETLINEWIDTH(fd:longint;var param1 : u_int):boolean;
+{IOW('F',112,sizeof(u_int) }
+
+Begin
+ FBIO_SETLINEWIDTH:=FpIoctl(fd,nr_FBIO_SETLINEWIDTH,@param1)=0;
+end;
+
+Function FBIO_GETPALETTE(fd:longint;var param1 : video_color_palette_t):boolean;
+{IOW('F',113,sizeof(video_color_palette_t) }
+
+Begin
+ FBIO_GETPALETTE:=FpIoctl(fd,nr_FBIO_GETPALETTE,@param1)=0;
+end;
+
+Function FBIO_SETPALETTE(fd:longint;var param1 : video_color_palette_t):boolean;
+{IOW('F',114,sizeof(video_color_palette_t) }
+
+Begin
+ FBIO_SETPALETTE:=FpIoctl(fd,nr_FBIO_SETPALETTE,@param1)=0;
+end;
+
+
+{consio.h FpIoctl's}
+
+Function KDGETMODE(fd:longint;var param1 : longint):boolean;
+{IOR('K',9,sizeof(int) }
+
+Begin
+ KDGETMODE:=FpIoctl(fd,nr_KDGETMODE,@param1)=0;
+end;
+
+Function KDSETMODE(fd:longint;param1 : longint):boolean;
+{IO('K',10 /* int */));
+ }
+
+Begin
+ KDSETMODE:=FpIoctl(fd,nr_KDSETMODE,pointer(param1))=0;
+end;
+
+Function KDSBORDER(fd:longint;param1 : longint):boolean;
+{IO('K',13 /* int */));
+ }
+
+Begin
+ KDSBORDER:=FpIoctl(fd,nr_KDSBORDER,pointer(param1))=0;
+end;
+
+Function KDRASTER(fd:longint;var param1 : scr_size_t):boolean;
+{IOW('K',100,sizeof(scr_size_t) }
+
+Begin
+ KDRASTER:=FpIoctl(fd,nr_KDRASTER,@param1)=0;
+end;
+
+Function GIO_SCRNMAP(fd:longint;var param1 : scrmap_t):boolean;
+{IOR('k',2,sizeof(scrmap_t) }
+
+Begin
+ GIO_SCRNMAP:=FpIoctl(fd,nr_GIO_SCRNMAP,@param1)=0;
+end;
+
+Function PIO_SCRNMAP(fd:longint;var param1 : scrmap_t):boolean;
+{IOW('k',3,sizeof(scrmap_t) }
+
+Begin
+ PIO_SCRNMAP:=FpIoctl(fd,nr_PIO_SCRNMAP,@param1)=0;
+end;
+
+Function GIO_ATTR(fd:longint;var param1 : longint):boolean;
+{IOR('a',0,sizeof(int) }
+
+Begin
+ GIO_ATTR:=FpIoctl(fd,nr_GIO_ATTR,@param1)=0;
+end;
+
+Function GIO_COLOR(fd:longint;var param1 : longint):boolean;
+{IOR('c',0,sizeof(int) }
+
+Begin
+ GIO_COLOR:=FpIoctl(fd,nr_GIO_COLOR,@param1)=0;
+end;
+
+Function CONS_CURRENT(fd:longint;var param1 : longint):boolean;
+{IOR('c',1,sizeof(int) }
+
+Begin
+ CONS_CURRENT:=FpIoctl(fd,nr_CONS_CURRENT,@param1)=0;
+end;
+
+Function CONS_GET(fd:longint;var param1 : longint):boolean;
+{IOR('c',2,sizeof(int) }
+
+Begin
+ CONS_GET:=FpIoctl(fd,nr_CONS_GET,@param1)=0;
+end;
+
+Function CONS_IO(fd:longint):boolean;
+{IO('c',3));
+ }
+
+Begin
+ CONS_IO:=FpIoctl(fd,nr_CONS_IO,nil)=0;
+end;
+
+Function CONS_BLANKTIME(fd:longint;var param1 : longint):boolean;
+{IOW('c',4,sizeof(int) }
+
+Begin
+ CONS_BLANKTIME:=FpIoctl(fd,nr_CONS_BLANKTIME,@param1)=0;
+end;
+
+Function CONS_SSAVER(fd:longint;var param1 : ssaver_t):boolean;
+{IOW('c',5,sizeof(ssaver_t) }
+
+Begin
+ CONS_SSAVER:=FpIoctl(fd,nr_CONS_SSAVER,@param1)=0;
+end;
+
+Function CONS_GSAVER(fd:longint;var param1 : ssaver_t):boolean;
+{IOWR('c',6,sizeof(ssaver_t) }
+
+Begin
+ CONS_GSAVER:=FpIoctl(fd,nr_CONS_GSAVER,@param1)=0;
+end;
+
+Function CONS_CURSORTYPE(fd:longint;var param1 : longint):boolean;
+{IOW('c',7,sizeof(int) }
+
+Begin
+ CONS_CURSORTYPE:=FpIoctl(fd,nr_CONS_CURSORTYPE,@param1)=0;
+end;
+
+Function CONS_BELLTYPE(fd:longint;var param1 : longint):boolean;
+{IOW('c',8,sizeof(int) }
+
+Begin
+ CONS_BELLTYPE:=FpIoctl(fd,nr_CONS_BELLTYPE,@param1)=0;
+end;
+
+Function CONS_HISTORY(fd:longint;var param1 : longint):boolean;
+{IOW('c',9,sizeof(int) }
+
+Begin
+ CONS_HISTORY:=FpIoctl(fd,nr_CONS_HISTORY,@param1)=0;
+end;
+
+Function CONS_MOUSECTL(fd:longint;var param1 : mouse_info_t):boolean;
+{IOWR('c',10,sizeof(mouse_info_t) }
+
+Begin
+ CONS_MOUSECTL:=FpIoctl(fd,nr_CONS_MOUSECTL,@param1)=0;
+end;
+
+Function CONS_IDLE(fd:longint;var param1 : longint):boolean;
+{IOR('c',11,sizeof(int) }
+
+Begin
+ CONS_IDLE:=FpIoctl(fd,nr_CONS_IDLE,@param1)=0;
+end;
+
+Function CONS_SAVERMODE(fd:longint;var param1 : longint):boolean;
+{IOW('c',12,sizeof(int) }
+
+Begin
+ CONS_SAVERMODE:=FpIoctl(fd,nr_CONS_SAVERMODE,@param1)=0;
+end;
+
+Function CONS_SAVERSTART(fd:longint;var param1 : longint):boolean;
+{IOW('c',13,sizeof(int) }
+
+Begin
+ CONS_SAVERSTART:=FpIoctl(fd,nr_CONS_SAVERSTART,@param1)=0;
+end;
+
+Function PIO_FONT8x8(fd:longint;var param1 : fnt8_t):boolean;
+{IOW('c',64,sizeof(fnt8_t) }
+
+Begin
+ PIO_FONT8x8:=FpIoctl(fd,nr_PIO_FONT8x8,@param1)=0;
+end;
+
+Function GIO_FONT8x8(fd:longint;var param1 : fnt8_t):boolean;
+{IOR('c',65,sizeof(fnt8_t) }
+
+Begin
+ GIO_FONT8x8:=FpIoctl(fd,nr_GIO_FONT8x8,@param1)=0;
+end;
+
+Function PIO_FONT8x14(fd:longint;var param1 : fnt14_t):boolean;
+{IOW('c',66,sizeof(fnt14_t) }
+
+Begin
+ PIO_FONT8x14:=FpIoctl(fd,nr_PIO_FONT8x14,@param1)=0;
+end;
+
+Function GIO_FONT8x14(fd:longint;var param1 : fnt14_t):boolean;
+{IOR('c',67,sizeof(fnt14_t) }
+
+Begin
+ GIO_FONT8x14:=FpIoctl(fd,nr_GIO_FONT8x14,@param1)=0;
+end;
+
+Function PIO_FONT8x16(fd:longint;var param1 : fnt16_t):boolean;
+{IOW('c',68,sizeof(fnt16_t) }
+
+Begin
+ PIO_FONT8x16:=FpIoctl(fd,nr_PIO_FONT8x16,@param1)=0;
+end;
+
+Function GIO_FONT8x16(fd:longint;var param1 : fnt16_t):boolean;
+{IOR('c',69,sizeof(fnt16_t) }
+
+Begin
+ GIO_FONT8x16:=FpIoctl(fd,nr_GIO_FONT8x16,@param1)=0;
+end;
+
+Function CONS_GETINFO(fd:longint;var param1 : vid_info_t):boolean;
+{IOWR('c',73,sizeof(vid_info_t) }
+
+Begin
+ CONS_GETINFO:=FpIoctl(fd,nr_CONS_GETINFO,@param1)=0;
+end;
+
+Function CONS_GETVERS(fd:longint;var param1 : longint):boolean;
+{IOR('c',74,sizeof(int) }
+
+Begin
+ CONS_GETVERS:=FpIoctl(fd,nr_CONS_GETVERS,@param1)=0;
+end;
+
+Function CONS_CURRENTADP(fd:longint;var param1 : longint):boolean;
+{IOR('c',100,sizeof(int) }
+
+Begin
+ CONS_CURRENTADP:=FpIoctl(fd,nr_CONS_CURRENTADP,@param1)=0;
+end;
+
+Function CONS_ADPINFO(fd:longint;var param1 : video_adapter_info_t):boolean;
+{IOWR('c',101,sizeof(video_adapter_info_t) }
+
+Begin
+ CONS_ADPINFO:=FpIoctl(fd,nr_CONS_ADPINFO,@param1)=0;
+end;
+
+Function CONS_MODEINFO(fd:longint;var param1 : video_info_t):boolean;
+{IOWR('c',102,sizeof(video_info_t) }
+
+Begin
+ CONS_MODEINFO:=FpIoctl(fd,nr_CONS_MODEINFO,@param1)=0;
+end;
+
+Function CONS_FINDMODE(fd:longint;var param1 : video_info_t):boolean;
+{IOWR('c',103,sizeof(video_info_t) }
+
+Begin
+ CONS_FINDMODE:=FpIoctl(fd,nr_CONS_FINDMODE,@param1)=0;
+end;
+
+Function CONS_SETWINORG(fd:longint;param1 : longint):boolean;
+{IO('c',104 /* int */));
+ }
+
+Begin
+ CONS_SETWINORG:=FpIoctl(fd,nr_CONS_SETWINORG,pointer(param1))=0;
+end;
+
+Function CONS_SETKBD(fd:longint;param1 : longint):boolean;
+{IO('c',110 /* int */));
+ }
+
+Begin
+ CONS_SETKBD:=FpIoctl(fd,nr_CONS_SETKBD,pointer(param1))=0;
+end;
+
+Function CONS_RELKBD(fd:longint):boolean;
+{IO('c',111));
+ }
+
+Begin
+ CONS_RELKBD:=FpIoctl(fd,nr_CONS_RELKBD,nil)=0;
+end;
+
+Function CONS_GETTERM(fd:longint;var param1 : term_info_t):boolean;
+{IOWR('c',112,sizeof(term_info_t) }
+
+Begin
+ CONS_GETTERM:=FpIoctl(fd,nr_CONS_GETTERM,@param1)=0;
+end;
+
+Function CONS_SETTERM(fd:longint;var param1 : term_info_t):boolean;
+{IOW('c',113,sizeof(term_info_t) }
+
+Begin
+ CONS_SETTERM:=FpIoctl(fd,nr_CONS_SETTERM,@param1)=0;
+end;
+
+Function ADJUST_CLOCK(fd:longint):boolean;
+{IO('t',100));
+ }
+
+Begin
+ ADJUST_CLOCK:=FpIoctl(fd,nr_ADJUST_CLOCK,nil)=0;
+end;
+
+Function VT_OPENQRY(fd:longint;var param1 : longint):boolean;
+{IOR('v',1,sizeof(int) }
+
+Begin
+ VT_OPENQRY:=FpIoctl(fd,nr_VT_OPENQRY,@param1)=0;
+end;
+
+Function VT_SETMODE(fd:longint;var param1 : vtmode_t):boolean;
+{IOW('v',2,sizeof(vtmode_t) }
+
+Begin
+ VT_SETMODE:=FpIoctl(fd,nr_VT_SETMODE,@param1)=0;
+end;
+
+Function VT_GETMODE(fd:longint;var param1 : vtmode_t):boolean;
+{IOR('v',3,sizeof(vtmode_t) }
+
+Begin
+ VT_GETMODE:=FpIoctl(fd,nr_VT_GETMODE,@param1)=0;
+end;
+
+Function VT_RELDISP(fd:longint;param1 : longint):boolean;
+{IO('v',4 /* int */));
+ }
+
+Begin
+ VT_RELDISP:=FpIoctl(fd,nr_VT_RELDISP,pointer(param1))=0;
+end;
+
+Function VT_ACTIVATE(fd:longint;param1 : longint):boolean;
+{IO('v',5 /* int */));
+ }
+
+Begin
+ VT_ACTIVATE:=FpIoctl(fd,nr_VT_ACTIVATE,pointer(param1))=0;
+end;
+
+Function VT_WAITACTIVE(fd:longint;param1 : longint):boolean;
+{IO('v',6 /* int */));
+ }
+
+Begin
+ VT_WAITACTIVE:=FpIoctl(fd,nr_VT_WAITACTIVE,pointer(param1))=0;
+end;
+
+Function VT_GETACTIVE(fd:longint;var param1 : longint):boolean;
+{IOR('v',7,sizeof(int) }
+
+Begin
+ VT_GETACTIVE:=FpIoctl(fd,nr_VT_GETACTIVE,@param1)=0;
+end;
+
+Function VT_GETINDEX(fd:longint;var param1 : longint):boolean;
+{IOR('v',8,sizeof(int) }
+
+Begin
+ VT_GETINDEX:=FpIoctl(fd,nr_VT_GETINDEX,@param1)=0;
+end;
+
+Function SW_B40x25(fd:longint):boolean;
+{IO('S',M_B40x25));
+ }
+
+Begin
+ SW_B40x25:=FpIoctl(fd,nr_SW_B40x25,nil)=0;
+end;
+
+Function SW_C40x25(fd:longint):boolean;
+{IO('S',M_C40x25));
+ }
+
+Begin
+ SW_C40x25:=FpIoctl(fd,nr_SW_C40x25,nil)=0;
+end;
+
+Function SW_B80x25(fd:longint):boolean;
+{IO('S',M_B80x25));
+ }
+
+Begin
+ SW_B80x25:=FpIoctl(fd,nr_SW_B80x25,nil)=0;
+end;
+
+Function SW_C80x25(fd:longint):boolean;
+{IO('S',M_C80x25));
+ }
+
+Begin
+ SW_C80x25:=FpIoctl(fd,nr_SW_C80x25,nil)=0;
+end;
+
+Function SW_BG320(fd:longint):boolean;
+{IO('S',M_BG320));
+ }
+
+Begin
+ SW_BG320:=FpIoctl(fd,nr_SW_BG320,nil)=0;
+end;
+
+Function SW_CG320(fd:longint):boolean;
+{IO('S',M_CG320));
+ }
+
+Begin
+ SW_CG320:=FpIoctl(fd,nr_SW_CG320,nil)=0;
+end;
+
+Function SW_BG640(fd:longint):boolean;
+{IO('S',M_BG640));
+ }
+
+Begin
+ SW_BG640:=FpIoctl(fd,nr_SW_BG640,nil)=0;
+end;
+
+Function SW_EGAMONO80x25(fd:longint):boolean;
+{IO('S',M_EGAMONO80x25));
+ }
+
+Begin
+ SW_EGAMONO80x25:=FpIoctl(fd,nr_SW_EGAMONO80x25,nil)=0;
+end;
+
+Function SW_CG320_D(fd:longint):boolean;
+{IO('S',M_CG320_D));
+ }
+
+Begin
+ SW_CG320_D:=FpIoctl(fd,nr_SW_CG320_D,nil)=0;
+end;
+
+Function SW_CG640_E(fd:longint):boolean;
+{IO('S',M_CG640_E));
+ }
+
+Begin
+ SW_CG640_E:=FpIoctl(fd,nr_SW_CG640_E,nil)=0;
+end;
+
+Function SW_EGAMONOAPA(fd:longint):boolean;
+{IO('S',M_EGAMONOAPA));
+ }
+
+Begin
+ SW_EGAMONOAPA:=FpIoctl(fd,nr_SW_EGAMONOAPA,nil)=0;
+end;
+
+Function SW_CG640x350(fd:longint):boolean;
+{IO('S',M_CG640x350));
+ }
+
+Begin
+ SW_CG640x350:=FpIoctl(fd,nr_SW_CG640x350,nil)=0;
+end;
+
+Function SW_ENH_MONOAPA2(fd:longint):boolean;
+{IO('S',M_ENHMONOAPA2));
+ }
+
+Begin
+ SW_ENH_MONOAPA2:=FpIoctl(fd,nr_SW_ENH_MONOAPA2,nil)=0;
+end;
+
+Function SW_ENH_CG640(fd:longint):boolean;
+{IO('S',M_ENH_CG640));
+ }
+
+Begin
+ SW_ENH_CG640:=FpIoctl(fd,nr_SW_ENH_CG640,nil)=0;
+end;
+
+Function SW_ENH_B40x25(fd:longint):boolean;
+{IO('S',M_ENH_B40x25));
+ }
+
+Begin
+ SW_ENH_B40x25:=FpIoctl(fd,nr_SW_ENH_B40x25,nil)=0;
+end;
+
+Function SW_ENH_C40x25(fd:longint):boolean;
+{IO('S',M_ENH_C40x25));
+ }
+
+Begin
+ SW_ENH_C40x25:=FpIoctl(fd,nr_SW_ENH_C40x25,nil)=0;
+end;
+
+Function SW_ENH_B80x25(fd:longint):boolean;
+{IO('S',M_ENH_B80x25));
+ }
+
+Begin
+ SW_ENH_B80x25:=FpIoctl(fd,nr_SW_ENH_B80x25,nil)=0;
+end;
+
+Function SW_ENH_C80x25(fd:longint):boolean;
+{IO('S',M_ENH_C80x25));
+ }
+
+Begin
+ SW_ENH_C80x25:=FpIoctl(fd,nr_SW_ENH_C80x25,nil)=0;
+end;
+
+Function SW_ENH_B80x43(fd:longint):boolean;
+{IO('S',M_ENH_B80x43));
+ }
+
+Begin
+ SW_ENH_B80x43:=FpIoctl(fd,nr_SW_ENH_B80x43,nil)=0;
+end;
+
+Function SW_ENH_C80x43(fd:longint):boolean;
+{IO('S',M_ENH_C80x43));
+ }
+
+Begin
+ SW_ENH_C80x43:=FpIoctl(fd,nr_SW_ENH_C80x43,nil)=0;
+end;
+
+Function SW_MCAMODE(fd:longint):boolean;
+{IO('S',M_MCA_MODE));
+ }
+
+Begin
+ SW_MCAMODE:=FpIoctl(fd,nr_SW_MCAMODE,nil)=0;
+end;
+
+Function SW_VGA_C40x25(fd:longint):boolean;
+{IO('S',M_VGA_C40x25));
+ }
+
+Begin
+ SW_VGA_C40x25:=FpIoctl(fd,nr_SW_VGA_C40x25,nil)=0;
+end;
+
+Function SW_VGA_C80x25(fd:longint):boolean;
+{IO('S',M_VGA_C80x25));
+ }
+
+Begin
+ SW_VGA_C80x25:=FpIoctl(fd,nr_SW_VGA_C80x25,nil)=0;
+end;
+
+Function SW_VGA_C80x30(fd:longint):boolean;
+{IO('S',M_VGA_C80x30));
+ }
+
+Begin
+ SW_VGA_C80x30:=FpIoctl(fd,nr_SW_VGA_C80x30,nil)=0;
+end;
+
+Function SW_VGA_C80x50(fd:longint):boolean;
+{IO('S',M_VGA_C80x50));
+ }
+
+Begin
+ SW_VGA_C80x50:=FpIoctl(fd,nr_SW_VGA_C80x50,nil)=0;
+end;
+
+Function SW_VGA_C80x60(fd:longint):boolean;
+{IO('S',M_VGA_C80x60));
+ }
+
+Begin
+ SW_VGA_C80x60:=FpIoctl(fd,nr_SW_VGA_C80x60,nil)=0;
+end;
+
+Function SW_VGA_M80x25(fd:longint):boolean;
+{IO('S',M_VGA_M80x25));
+ }
+
+Begin
+ SW_VGA_M80x25:=FpIoctl(fd,nr_SW_VGA_M80x25,nil)=0;
+end;
+
+Function SW_VGA_M80x30(fd:longint):boolean;
+{IO('S',M_VGA_M80x30));
+ }
+
+Begin
+ SW_VGA_M80x30:=FpIoctl(fd,nr_SW_VGA_M80x30,nil)=0;
+end;
+
+Function SW_VGA_M80x50(fd:longint):boolean;
+{IO('S',M_VGA_M80x50));
+ }
+
+Begin
+ SW_VGA_M80x50:=FpIoctl(fd,nr_SW_VGA_M80x50,nil)=0;
+end;
+
+Function SW_VGA_M80x60(fd:longint):boolean;
+{IO('S',M_VGA_M80x60));
+ }
+
+Begin
+ SW_VGA_M80x60:=FpIoctl(fd,nr_SW_VGA_M80x60,nil)=0;
+end;
+
+Function SW_VGA11(fd:longint):boolean;
+{IO('S',M_VGA11));
+ }
+
+Begin
+ SW_VGA11:=FpIoctl(fd,nr_SW_VGA11,nil)=0;
+end;
+
+Function SW_BG640x480(fd:longint):boolean;
+{IO('S',M_VGA11));
+ }
+
+Begin
+ SW_BG640x480:=FpIoctl(fd,nr_SW_BG640x480,nil)=0;
+end;
+
+Function SW_VGA12(fd:longint):boolean;
+{IO('S',M_VGA12));
+ }
+
+Begin
+ SW_VGA12:=FpIoctl(fd,nr_SW_VGA12,nil)=0;
+end;
+
+Function SW_CG640x480(fd:longint):boolean;
+{IO('S',M_VGA12));
+ }
+
+Begin
+ SW_CG640x480:=FpIoctl(fd,nr_SW_CG640x480,nil)=0;
+end;
+
+Function SW_VGA13(fd:longint):boolean;
+{IO('S',M_VGA13));
+ }
+
+Begin
+ SW_VGA13:=FpIoctl(fd,nr_SW_VGA13,nil)=0;
+end;
+
+Function SW_VGA_CG320(fd:longint):boolean;
+{IO('S',M_VGA13));
+ }
+
+Begin
+ SW_VGA_CG320:=FpIoctl(fd,nr_SW_VGA_CG320,nil)=0;
+end;
+
+Function SW_VGA_CG640(fd:longint):boolean;
+{IO('S',M_VGA_CG640));
+ }
+
+Begin
+ SW_VGA_CG640:=FpIoctl(fd,nr_SW_VGA_CG640,nil)=0;
+end;
+
+Function SW_VGA_MODEX(fd:longint):boolean;
+{IO('S',M_VGA_MODEX));
+ }
+
+Begin
+ SW_VGA_MODEX:=FpIoctl(fd,nr_SW_VGA_MODEX,nil)=0;
+end;
+
+Function SW_PC98_80x25(fd:longint):boolean;
+{IO('S',M_PC98_80x25));
+ }
+
+Begin
+ SW_PC98_80x25:=FpIoctl(fd,nr_SW_PC98_80x25,nil)=0;
+end;
+
+Function SW_PC98_80x30(fd:longint):boolean;
+{IO('S',M_PC98_80x30));
+ }
+
+Begin
+ SW_PC98_80x30:=FpIoctl(fd,nr_SW_PC98_80x30,nil)=0;
+end;
+
+Function SW_PC98_EGC640x400(fd:longint):boolean;
+{IO('S',M_PC98_EGC640x400));
+ }
+
+Begin
+ SW_PC98_EGC640x400:=FpIoctl(fd,nr_SW_PC98_EGC640x400,nil)=0;
+end;
+
+Function SW_PC98_PEGC640x400(fd:longint):boolean;
+{IO('S',M_PC98_PEGC640x400));
+ }
+
+Begin
+ SW_PC98_PEGC640x400:=FpIoctl(fd,nr_SW_PC98_PEGC640x400,nil)=0;
+end;
+
+Function SW_PC98_PEGC640x480(fd:longint):boolean;
+{IO('S',M_PC98_PEGC640x480));
+ }
+
+Begin
+ SW_PC98_PEGC640x480:=FpIoctl(fd,nr_SW_PC98_PEGC640x480,nil)=0;
+end;
+
+Function SW_VGA_C90x25(fd:longint):boolean;
+{IO('S',M_VGA_C90x25));
+ }
+
+Begin
+ SW_VGA_C90x25:=FpIoctl(fd,nr_SW_VGA_C90x25,nil)=0;
+end;
+
+Function SW_VGA_M90x25(fd:longint):boolean;
+{IO('S',M_VGA_M90x25));
+ }
+
+Begin
+ SW_VGA_M90x25:=FpIoctl(fd,nr_SW_VGA_M90x25,nil)=0;
+end;
+
+Function SW_VGA_C90x30(fd:longint):boolean;
+{IO('S',M_VGA_C90x30));
+ }
+
+Begin
+ SW_VGA_C90x30:=FpIoctl(fd,nr_SW_VGA_C90x30,nil)=0;
+end;
+
+Function SW_VGA_M90x30(fd:longint):boolean;
+{IO('S',M_VGA_M90x30));
+ }
+
+Begin
+ SW_VGA_M90x30:=FpIoctl(fd,nr_SW_VGA_M90x30,nil)=0;
+end;
+
+Function SW_VGA_C90x43(fd:longint):boolean;
+{IO('S',M_VGA_C90x43));
+ }
+
+Begin
+ SW_VGA_C90x43:=FpIoctl(fd,nr_SW_VGA_C90x43,nil)=0;
+end;
+
+Function SW_VGA_M90x43(fd:longint):boolean;
+{IO('S',M_VGA_M90x43));
+ }
+
+Begin
+ SW_VGA_M90x43:=FpIoctl(fd,nr_SW_VGA_M90x43,nil)=0;
+end;
+
+Function SW_VGA_C90x50(fd:longint):boolean;
+{IO('S',M_VGA_C90x50));
+ }
+
+Begin
+ SW_VGA_C90x50:=FpIoctl(fd,nr_SW_VGA_C90x50,nil)=0;
+end;
+
+Function SW_VGA_M90x50(fd:longint):boolean;
+{IO('S',M_VGA_M90x50));
+ }
+
+Begin
+ SW_VGA_M90x50:=FpIoctl(fd,nr_SW_VGA_M90x50,nil)=0;
+end;
+
+Function SW_VGA_C90x60(fd:longint):boolean;
+{IO('S',M_VGA_C90x60));
+ }
+
+Begin
+ SW_VGA_C90x60:=FpIoctl(fd,nr_SW_VGA_C90x60,nil)=0;
+end;
+
+Function SW_VGA_M90x60(fd:longint):boolean;
+{IO('S',M_VGA_M90x60));
+ }
+
+Begin
+ SW_VGA_M90x60:=FpIoctl(fd,nr_SW_VGA_M90x60,nil)=0;
+end;
+
+Function SW_TEXT_80x25(fd:longint):boolean;
+{IO('S',M_TEXT_80x25));
+ }
+
+Begin
+ SW_TEXT_80x25:=FpIoctl(fd,nr_SW_TEXT_80x25,nil)=0;
+end;
+
+Function SW_TEXT_80x30(fd:longint):boolean;
+{IO('S',M_TEXT_80x30));
+ }
+
+Begin
+ SW_TEXT_80x30:=FpIoctl(fd,nr_SW_TEXT_80x30,nil)=0;
+end;
+
+Function SW_TEXT_80x43(fd:longint):boolean;
+{IO('S',M_TEXT_80x43));
+ }
+
+Begin
+ SW_TEXT_80x43:=FpIoctl(fd,nr_SW_TEXT_80x43,nil)=0;
+end;
+
+Function SW_TEXT_80x50(fd:longint):boolean;
+{IO('S',M_TEXT_80x50));
+ }
+
+Begin
+ SW_TEXT_80x50:=FpIoctl(fd,nr_SW_TEXT_80x50,nil)=0;
+end;
+
+Function SW_TEXT_80x60(fd:longint):boolean;
+{IO('S',M_TEXT_80x60));
+ }
+
+Begin
+ SW_TEXT_80x60:=FpIoctl(fd,nr_SW_TEXT_80x60,nil)=0;
+end;
+
+Function SW_TEXT_132x25(fd:longint):boolean;
+{IO('S',M_TEXT_132x25));
+ }
+
+Begin
+ SW_TEXT_132x25:=FpIoctl(fd,nr_SW_TEXT_132x25,nil)=0;
+end;
+
+Function SW_TEXT_132x30(fd:longint):boolean;
+{IO('S',M_TEXT_132x30));
+ }
+
+Begin
+ SW_TEXT_132x30:=FpIoctl(fd,nr_SW_TEXT_132x30,nil)=0;
+end;
+
+Function SW_TEXT_132x43(fd:longint):boolean;
+{IO('S',M_TEXT_132x43));
+ }
+
+Begin
+ SW_TEXT_132x43:=FpIoctl(fd,nr_SW_TEXT_132x43,nil)=0;
+end;
+
+Function SW_TEXT_132x50(fd:longint):boolean;
+{IO('S',M_TEXT_132x50));
+ }
+
+Begin
+ SW_TEXT_132x50:=FpIoctl(fd,nr_SW_TEXT_132x50,nil)=0;
+end;
+
+Function SW_TEXT_132x60(fd:longint):boolean;
+{IO('S',M_TEXT_132x60));
+ }
+
+Begin
+ SW_TEXT_132x60:=FpIoctl(fd,nr_SW_TEXT_132x60,nil)=0;
+end;
+
+Function SW_VESA_CG640x400(fd:longint):boolean;
+{IO('V',M_VESA_CG640x400 - M_VESA_BASE));
+ }
+
+Begin
+ SW_VESA_CG640x400:=FpIoctl(fd,nr_SW_VESA_CG640x400,nil)=0;
+end;
+
+Function SW_VESA_CG640x480(fd:longint):boolean;
+{IO('V',M_VESA_CG640x480 - M_VESA_BASE));
+ }
+
+Begin
+ SW_VESA_CG640x480:=FpIoctl(fd,nr_SW_VESA_CG640x480,nil)=0;
+end;
+
+Function SW_VESA_800x600(fd:longint):boolean;
+{IO('V',M_VESA_800x600 - M_VESA_BASE));
+ }
+
+Begin
+ SW_VESA_800x600:=FpIoctl(fd,nr_SW_VESA_800x600,nil)=0;
+end;
+
+Function SW_VESA_CG800x600(fd:longint):boolean;
+{IO('V',M_VESA_CG800x600 - M_VESA_BASE));
+ }
+
+Begin
+ SW_VESA_CG800x600:=FpIoctl(fd,nr_SW_VESA_CG800x600,nil)=0;
+end;
+
+Function SW_VESA_1024x768(fd:longint):boolean;
+{IO('V',M_VESA_1024x768 - M_VESA_BASE));
+ }
+
+Begin
+ SW_VESA_1024x768:=FpIoctl(fd,nr_SW_VESA_1024x768,nil)=0;
+end;
+
+Function SW_VESA_CG1024x768(fd:longint):boolean;
+{IO('V',M_VESA_CG1024x768 - M_VESA_BAS));
+ }
+
+Begin
+ SW_VESA_CG1024x768:=FpIoctl(fd,nr_SW_VESA_CG1024x768,nil)=0;
+end;
+
+Function SW_VESA_1280x1024(fd:longint):boolean;
+{IO('V',M_VESA_1280x1024 - M_VESA_BASE));
+ }
+
+Begin
+ SW_VESA_1280x1024:=FpIoctl(fd,nr_SW_VESA_1280x1024,nil)=0;
+end;
+
+Function SW_VESA_CG1280x1024(fd:longint):boolean;
+{IO('V',M_VESA_CG1280x1024 - M_VESA_BA));
+ }
+
+Begin
+ SW_VESA_CG1280x1024:=FpIoctl(fd,nr_SW_VESA_CG1280x1024,nil)=0;
+end;
+
+Function SW_VESA_C80x60(fd:longint):boolean;
+{IO('V',M_VESA_C80x60 - M_VESA_BASE));
+ }
+
+Begin
+ SW_VESA_C80x60:=FpIoctl(fd,nr_SW_VESA_C80x60,nil)=0;
+end;
+
+Function SW_VESA_C132x25(fd:longint):boolean;
+{IO('V',M_VESA_C132x25 - M_VESA_BASE));
+ }
+
+Begin
+ SW_VESA_C132x25:=FpIoctl(fd,nr_SW_VESA_C132x25,nil)=0;
+end;
+
+Function SW_VESA_C132x43(fd:longint):boolean;
+{IO('V',M_VESA_C132x43 - M_VESA_BASE));
+ }
+
+Begin
+ SW_VESA_C132x43:=FpIoctl(fd,nr_SW_VESA_C132x43,nil)=0;
+end;
+
+Function SW_VESA_C132x50(fd:longint):boolean;
+{IO('V',M_VESA_C132x50 - M_VESA_BASE));
+ }
+
+Begin
+ SW_VESA_C132x50:=FpIoctl(fd,nr_SW_VESA_C132x50,nil)=0;
+end;
+
+Function SW_VESA_C132x60(fd:longint):boolean;
+{IO('V',M_VESA_C132x60 - M_VESA_BASE));
+ }
+
+Begin
+ SW_VESA_C132x60:=FpIoctl(fd,nr_SW_VESA_C132x60,nil)=0;
+end;
+
+Function SW_VESA_32K_320(fd:longint):boolean;
+{IO('V',M_VESA_32K_320 - M_VESA_BASE));
+ }
+
+Begin
+ SW_VESA_32K_320:=FpIoctl(fd,nr_SW_VESA_32K_320,nil)=0;
+end;
+
+Function SW_VESA_64K_320(fd:longint):boolean;
+{IO('V',M_VESA_64K_320 - M_VESA_BASE));
+ }
+
+Begin
+ SW_VESA_64K_320:=FpIoctl(fd,nr_SW_VESA_64K_320,nil)=0;
+end;
+
+Function SW_VESA_FULL_320(fd:longint):boolean;
+{IO('V',M_VESA_FULL_320 - M_VESA_BASE));
+ }
+
+Begin
+ SW_VESA_FULL_320:=FpIoctl(fd,nr_SW_VESA_FULL_320,nil)=0;
+end;
+
+Function SW_VESA_32K_640(fd:longint):boolean;
+{IO('V',M_VESA_32K_640 - M_VESA_BASE));
+ }
+
+Begin
+ SW_VESA_32K_640:=FpIoctl(fd,nr_SW_VESA_32K_640,nil)=0;
+end;
+
+Function SW_VESA_64K_640(fd:longint):boolean;
+{IO('V',M_VESA_64K_640 - M_VESA_BASE));
+ }
+
+Begin
+ SW_VESA_64K_640:=FpIoctl(fd,nr_SW_VESA_64K_640,nil)=0;
+end;
+
+Function SW_VESA_FULL_640(fd:longint):boolean;
+{IO('V',M_VESA_FULL_640 - M_VESA_BASE));
+ }
+
+Begin
+ SW_VESA_FULL_640:=FpIoctl(fd,nr_SW_VESA_FULL_640,nil)=0;
+end;
+
+Function SW_VESA_32K_800(fd:longint):boolean;
+{IO('V',M_VESA_32K_800 - M_VESA_BASE));
+ }
+
+Begin
+ SW_VESA_32K_800:=FpIoctl(fd,nr_SW_VESA_32K_800,nil)=0;
+end;
+
+Function SW_VESA_64K_800(fd:longint):boolean;
+{IO('V',M_VESA_64K_800 - M_VESA_BASE));
+ }
+
+Begin
+ SW_VESA_64K_800:=FpIoctl(fd,nr_SW_VESA_64K_800,nil)=0;
+end;
+
+Function SW_VESA_FULL_800(fd:longint):boolean;
+{IO('V',M_VESA_FULL_800 - M_VESA_BASE));
+ }
+
+Begin
+ SW_VESA_FULL_800:=FpIoctl(fd,nr_SW_VESA_FULL_800,nil)=0;
+end;
+
+Function SW_VESA_32K_1024(fd:longint):boolean;
+{IO('V',M_VESA_32K_1024 - M_VESA_BASE));
+ }
+
+Begin
+ SW_VESA_32K_1024:=FpIoctl(fd,nr_SW_VESA_32K_1024,nil)=0;
+end;
+
+Function SW_VESA_64K_1024(fd:longint):boolean;
+{IO('V',M_VESA_64K_1024 - M_VESA_BASE));
+ }
+
+Begin
+ SW_VESA_64K_1024:=FpIoctl(fd,nr_SW_VESA_64K_1024,nil)=0;
+end;
+
+Function SW_VESA_FULL_1024(fd:longint):boolean;
+{IO('V',M_VESA_FULL_1024 - M_VESA_BASE));
+ }
+
+Begin
+ SW_VESA_FULL_1024:=FpIoctl(fd,nr_SW_VESA_FULL_1024,nil)=0;
+end;
+
+Function SW_VESA_32K_1280(fd:longint):boolean;
+{IO('V',M_VESA_32K_1280 - M_VESA_BASE));
+ }
+
+Begin
+ SW_VESA_32K_1280:=FpIoctl(fd,nr_SW_VESA_32K_1280,nil)=0;
+end;
+
+Function SW_VESA_64K_1280(fd:longint):boolean;
+{IO('V',M_VESA_64K_1280 - M_VESA_BASE));
+ }
+
+Begin
+ SW_VESA_64K_1280:=FpIoctl(fd,nr_SW_VESA_64K_1280,nil)=0;
+end;
+
+Function SW_VESA_FULL_1280(fd:longint):boolean;
+{IO('V',M_VESA_FULL_1280 - M_VESA_BASE));
+ }
+
+Begin
+ SW_VESA_FULL_1280:=FpIoctl(fd,nr_SW_VESA_FULL_1280,nil)=0;
+end;
+
+{----------------------------- kbio.h FpIoctl's ---------------------------}
+
+Function KDGKBMODE(fd:longint;var param1 : longint):boolean;
+{IOR('K',6,sizeof(int) }
+
+Begin
+ KDGKBMODE:=FpIoctl(fd,nr_KDGKBMODE,@param1)=0;
+end;
+
+Function KDSKBMODE(fd:longint;param1 : longint):boolean;
+{IO('K',7 /* int */));
+ }
+
+Begin
+ KDSKBMODE:=FpIoctl(fd,nr_KDSKBMODE,pointer(param1))=0;
+end;
+
+Function KDMKTONE(fd:longint;param1 : longint):boolean;
+{IO('K',8 /* int */));
+ }
+
+Begin
+ KDMKTONE:=FpIoctl(fd,nr_KDMKTONE,pointer(param1))=0;
+end;
+
+{$ifndef definconsole}
+Function KDGETMODE(fd:longint;var param1 : longint):boolean;
+{IOR('K',9,sizeof(int) }
+
+Begin
+ KDGETMODE:=FpIoctl(fd,nr_KDGETMODE,@param1)=0;
+end;
+
+Function KDSETMODE(fd:longint;param1 : longint):boolean;
+{IO('K',10 /* int */));
+ }
+
+Begin
+ KDSETMODE:=FpIoctl(fd,nr_KDSETMODE,pointer(param1))=0;
+end;
+
+Function KDSBORDER(fd:longint;param1 : longint):boolean;
+{IO('K',13 /* int */));
+ }
+
+Begin
+ KDSBORDER:=FpIoctl(fd,nr_KDSBORDER,pointer(param1))=0;
+end;
+{$endif}
+Function KDGKBSTATE(fd:longint;var param1 : longint):boolean;
+{IOR('K',19,sizeof(int) }
+
+Begin
+ KDGKBSTATE:=FpIoctl(fd,nr_KDGKBSTATE,@param1)=0;
+end;
+
+Function KDSKBSTATE(fd:longint;param1 : longint):boolean;
+{IO('K',20 /* int */));
+ }
+
+Begin
+ KDSKBSTATE:=FpIoctl(fd,nr_KDSKBSTATE,pointer(param1))=0;
+end;
+
+Function KDENABIO(fd:longint):boolean;
+{IO('K',60));
+ }
+
+Begin
+ KDENABIO:=FpIoctl(fd,nr_KDENABIO,nil)=0;
+end;
+
+Function KDDISABIO(fd:longint):boolean;
+{IO('K',61));
+ }
+
+Begin
+ KDDISABIO:=FpIoctl(fd,nr_KDDISABIO,nil)=0;
+end;
+
+Function KIOCSOUND(fd:longint;param1 : longint):boolean;
+{IO('K',63 /* int */));
+ }
+
+Begin
+ KIOCSOUND:=FpIoctl(fd,nr_KIOCSOUND,pointer(param1))=0;
+end;
+
+Function KDGKBTYPE(fd:longint;var param1 : longint):boolean;
+{IOR('K',64,sizeof(int) }
+
+Begin
+ KDGKBTYPE:=FpIoctl(fd,nr_KDGKBTYPE,@param1)=0;
+end;
+
+Function KDGETLED(fd:longint;var param1 : longint):boolean;
+{IOR('K',65,sizeof(int) }
+
+Begin
+ KDGETLED:=FpIoctl(fd,nr_KDGETLED,@param1)=0;
+end;
+
+Function KDSETLED(fd:longint;param1 : longint):boolean;
+{IO('K',66 /* int */));
+ }
+
+Begin
+ KDSETLED:=FpIoctl(fd,nr_KDSETLED,pointer(param1))=0;
+end;
+
+Function KDSETRAD(fd:longint;param1 : longint):boolean;
+{IO('K',67 /* int */));
+ }
+
+Begin
+ KDSETRAD:=FpIoctl(fd,nr_KDSETRAD,pointer(param1))=0;
+end;
+{$ifndef definconsole}
+
+Function KDRASTER(fd:longint;var param1 : scr_size_t):boolean;
+{IOW('K',100,sizeof(scr_size_t) }
+
+Begin
+ KDRASTER:=FpIoctl(fd,nr_KDRASTER,@param1)=0;
+end;
+{$endif}
+Function KDGKBINFO(fd:longint;var param1 : keyboard_info_t):boolean;
+{IOR('K',101,sizeof(keyboard_info_t) }
+
+Begin
+ KDGKBINFO:=FpIoctl(fd,nr_KDGKBINFO,@param1)=0;
+end;
+
+Function KDSETREPEAT(fd:longint;var param1 : keyboard_repeat_t):boolean;
+{IOW('K',102,sizeof(keyboard_repeat_t) }
+
+Begin
+ KDSETREPEAT:=FpIoctl(fd,nr_KDSETREPEAT,@param1)=0;
+end;
+
+Function KDGETREPEAT(fd:longint;var param1 : keyboard_repeat_t):boolean;
+{IOR('K',103,sizeof(keyboard_repeat_t) }
+
+Begin
+ KDGETREPEAT:=FpIoctl(fd,nr_KDGETREPEAT,@param1)=0;
+end;
+
+Function GETFKEY(fd:longint;var param1 : fkeyarg_t):boolean;
+{IOWR('k',0,sizeof(fkeyarg_t) }
+
+Begin
+ GETFKEY:=FpIoctl(fd,nr_GETFKEY,@param1)=0;
+end;
+
+Function SETFKEY(fd:longint;var param1 : fkeyarg_t):boolean;
+{IOWR('k',1,sizeof(fkeyarg_t) }
+
+Begin
+ SETFKEY:=FpIoctl(fd,nr_SETFKEY,@param1)=0;
+end;
+{$ifndef definconsole}
+Function GIO_SCRNMAP(fd:longint;var param1 : scrmap_t):boolean;
+{IOR('k',2,sizeof(scrmap_t) }
+
+Begin
+ GIO_SCRNMAP:=FpIoctl(fd,nr_GIO_SCRNMAP,@param1)=0;
+end;
+
+Function PIO_SCRNMAP(fd:longint;var param1 : scrmap_t):boolean;
+{IOW('k',3,sizeof(scrmap_t) }
+
+Begin
+ PIO_SCRNMAP:=FpIoctl(fd,nr_PIO_SCRNMAP,@param1)=0;
+end;
+{$endif}
+Function GIO_KEYMAP(fd:longint;var param1 : keymap_t):boolean;
+{IOR('k',6,sizeof(keymap_t) }
+
+Begin
+ GIO_KEYMAP:=FpIoctl(fd,nr_GIO_KEYMAP,@param1)=0;
+end;
+
+Function PIO_KEYMAP(fd:longint;var param1 : keymap_t):boolean;
+{IOW('k',7,sizeof(keymap_t) }
+
+Begin
+ PIO_KEYMAP:=FpIoctl(fd,nr_PIO_KEYMAP,@param1)=0;
+end;
+
+Function GIO_DEADKEYMAP(fd:longint;var param1 : accentmap_t):boolean;
+{IOR('k',8,sizeof(accentmap_t) }
+
+Begin
+ GIO_DEADKEYMAP:=FpIoctl(fd,nr_GIO_DEADKEYMAP,@param1)=0;
+end;
+
+Function PIO_DEADKEYMAP(fd:longint;var param1 : accentmap_t):boolean;
+{IOW('k',9,sizeof(accentmap_t) }
+
+Begin
+ PIO_DEADKEYMAP:=FpIoctl(fd,nr_PIO_DEADKEYMAP,@param1)=0;
+end;
+
+Function GIO_KEYMAPENT(fd:longint;var param1 : keyarg_t):boolean;
+{IOWR('k',10,sizeof(keyarg_t) }
+
+Begin
+ GIO_KEYMAPENT:=FpIoctl(fd,nr_GIO_KEYMAPENT,@param1)=0;
+end;
+
+Function PIO_KEYMAPENT(fd:longint;var param1 : keyarg_t):boolean;
+{IOW('k',11,sizeof(keyarg_t) }
+
+Begin
+ PIO_KEYMAPENT:=FpIoctl(fd,nr_PIO_KEYMAPENT,@param1)=0;
+end;
+
+
+
+{----------------------------- mouse.h FpIoctl's ---------------------------}
+
+Function MOUSE_GETSTATUS(fd:longint;var param1 : mousestatus_t):boolean;
+{IOR('M',0,sizeof(mousestatus_t)));
+}
+
+Begin
+ MOUSE_GETSTATUS:=FpIoctl(fd,nr_MOUSE_GETSTATUS,@param1)=0;
+end;
+
+Function MOUSE_GETHWINFO(fd:longint;var param1 : mousehw_t):boolean;
+{IOR('M',1,sizeof(mousehw_t)));
+}
+
+Begin
+ MOUSE_GETHWINFO:=FpIoctl(fd,nr_MOUSE_GETHWINFO,@param1)=0;
+end;
+
+Function MOUSE_GETMODE(fd:longint;var param1 : mousemode_t):boolean;
+{IOR('M',2,sizeof(mousemode_t)));
+}
+
+Begin
+ MOUSE_GETMODE:=FpIoctl(fd,nr_MOUSE_GETMODE,@param1)=0;
+end;
+
+Function MOUSE_SETMODE(fd:longint;var param1 : mousemode_t):boolean;
+{IOW('M',3,sizeof(mousemode_t)));
+}
+
+Begin
+ MOUSE_SETMODE:=FpIoctl(fd,nr_MOUSE_SETMODE,@param1)=0;
+end;
+
+Function MOUSE_GETLEVEL(fd:longint;var param1 : longint):boolean;
+{IOR('M',4,sizeof(int)));
+}
+
+Begin
+ MOUSE_GETLEVEL:=FpIoctl(fd,nr_MOUSE_GETLEVEL,@param1)=0;
+end;
+
+Function MOUSE_SETLEVEL(fd:longint;var param1 : longint):boolean;
+{IOW('M',5,sizeof(int)));
+}
+
+Begin
+ MOUSE_SETLEVEL:=FpIoctl(fd,nr_MOUSE_SETLEVEL,@param1)=0;
+end;
+
+Function MOUSE_GETVARS(fd:longint;var param1 : mousevar_t):boolean;
+{IOR('M',6,sizeof(mousevar_t)));
+}
+
+Begin
+ MOUSE_GETVARS:=FpIoctl(fd,nr_MOUSE_GETVARS,@param1)=0;
+end;
+
+Function MOUSE_SETVARS(fd:longint;var param1 : mousevar_t):boolean;
+{IOW('M',7,sizeof(mousevar_t)));
+}
+
+Begin
+ MOUSE_SETVARS:=FpIoctl(fd,nr_MOUSE_SETVARS,@param1)=0;
+end;
+
+Function MOUSE_READSTATE(fd:longint;var param1 : mousedata_t):boolean;
+{IOWR('M',8,sizeof(mousedata_t)));
+}
+
+Begin
+ MOUSE_READSTATE:=FpIoctl(fd,nr_MOUSE_READSTATE,@param1)=0;
+end;
+
+Function MOUSE_READDATA(fd:longint;var param1 : mousedata_t):boolean;
+{IOWR('M',9,sizeof(mousedata_t)));
+}
+
+Begin
+ MOUSE_READDATA:=FpIoctl(fd,nr_MOUSE_READDATA,@param1)=0;
+end;
+
+Function MOUSE_SETRESOLUTION(fd:longint;var param1 : longint):boolean;
+{IOW('M',10,sizeof(int)));
+}
+
+Begin
+ MOUSE_SETRESOLUTION:=FpIoctl(fd,nr_MOUSE_SETRESOLUTION,@param1)=0;
+end;
+
+Function MOUSE_SETSCALING(fd:longint;var param1 : longint):boolean;
+{IOW('M',11,sizeof(int)));
+}
+
+Begin
+ MOUSE_SETSCALING:=FpIoctl(fd,nr_MOUSE_SETSCALING,@param1)=0;
+end;
+
+Function MOUSE_SETRATE(fd:longint;var param1 : longint):boolean;
+{IOW('M',12,sizeof(int)));
+}
+
+Begin
+ MOUSE_SETRATE:=FpIoctl(fd,nr_MOUSE_SETRATE,@param1)=0;
+end;
+
+Function MOUSE_GETHWID(fd:longint;var param1 : longint):boolean;
+{IOR('M',13,sizeof(int)));
+}
+
+Begin
+ MOUSE_GETHWID:=FpIoctl(fd,nr_MOUSE_GETHWID,@param1)=0;
+end;
+
+
+end.

+ 110 - 0
rtl/darwin/powerpc/sig_cpu.inc

@@ -0,0 +1,110 @@
+  {
+     $Id$
+     Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+
+     @APPLE_LICENSE_HEADER_START@
+
+     The contents of this file constitute Original Code as defined in and
+     are subject to the Apple Public Source License Version 1.1 (the
+     "License").  You may not use this file except in compliance with the
+     License.  Please obtain a copy of the License at
+     http://www.apple.com/publicsource and read it before using this file.
+
+     This Original Code and all software distributed under the License are
+     distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+     EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+     INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+     FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
+     License for the specific language governing rights and limitations
+     under the License.
+
+     @APPLE_LICENSE_HEADER_END@
+    }
+  {
+     Copyright (c) 1992, 1993 NeXT Computer, Inc.
+
+     HISTORY
+
+        Machine specific signal information.
+
+     HISTORY
+     25-MAR-97  Umesh Vaishampayan ([email protected])
+        Ported from m98k and hppa.
+
+     13-Jan-92  Peter King (king) at NeXT Computer, Inc.
+        Filled out struct sigcontext to hold all registers.
+        Added regs_saved_t to specify which regs stored in the
+        sigcontext are valid.
+
+     09-Nov-92  Ben Fathi (benf) at NeXT, Inc.
+        Ported to m98k.
+
+     09-May-91  Mike DeMoney (mike) at NeXT, Inc.
+        Ported to m88k.
+    }
+  const
+     _PPC_SIGNAL_ = 1;
+
+  type
+
+     sig_atomic_t = longint;
+  {
+     Machine-dependant flags used in sigvec call.
+    }
+  { Save all regs in sigcontext  }
+
+  const
+     SV_SAVE_REGS = $1000;
+  {
+     regs_saved_t -- Describes which registers beyond what the kernel cares
+                   about are saved to and restored from this sigcontext.
+
+     The default is REGS_SAVED_CALLER, only the caller saved registers
+     are saved.  If the SV_SAVE_REGS flag was set when the signal
+     handler was registered with sigvec() then all the registers will be
+     saved in the sigcontext, and REGS_SAVED_ALL will be set.  The C
+     library uses REGS_SAVED_NONE in order to quickly restore kernel
+     state during a longjmp().
+    }
+  { Only kernel managed regs restored  }
+  { "Caller saved" regs: rpc, a0-a7,
+                                           t0-t4, at, lk0-lk1, xt1-xt20,
+                                           xr0-xr1  }
+  { All registers  }
+
+  type
+
+     regs_saved_t = (REGS_SAVED_NONE,REGS_SAVED_CALLER,REGS_SAVED_ALL
+       );
+  {
+     Information pushed on stack when a signal is delivered.
+     This is used by the kernel to restore state following
+     execution of the signal handler.  It is also made available
+     to the handler to allow it to properly restore state if
+     a non-standard exit is performed.
+    }
+     sigcontextrec = record
+  { sigstack state to restore  }
+          sc_onstack : longint;
+  { signal mask to restore  }
+          sc_mask : longint;
+  { pc  }
+          sc_ir : longint;
+  { processor status word  }
+          sc_psw : longint;
+  { stack pointer if sc_regs == NULL  }
+          sc_sp : longint;
+  { (kernel private) saved state  }
+          sc_regs : pointer;
+       end;
+
+{
+  $Log$
+  Revision 1.1  2004-01-04 20:05:38  jonas
+    * first working version of the Darwin/Mac OS X (for PowerPC) RTL
+      Several non-essential units are still missing, but make cycle works
+
+  Revision 1.1  2002/09/08 09:01:48  jonas
+    + initial revision
+
+}

+ 63 - 0
rtl/darwin/powerpc/sighnd.inc

@@ -0,0 +1,63 @@
+{  
+   $Id$
+   This file is part of the Free Pascal run time library.
+   (c) 2000-2003 by Marco van de Voort
+   member of the Free Pascal development team.
+
+   See the file COPYING.FPC, included in this distribution,
+   for details about the copyright.
+
+   Signalhandler for FreeBSD/i386
+
+   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.
+}
+
+procedure SignalToRunerror(Sig: cint; var info : tsiginfo_t;Var SigContext:SigContextRec); cdecl;
+
+var
+  res : word;
+
+begin
+  res:=0;
+  { have to verify whether this is necessary }
+  fpc_enable_ppc_fpu_exceptions;
+  case sig of
+    SIGFPE :
+      begin
+        Case Info.si_code Of
+          FPE_INTDIV : Res:=200;  {integer divide fault. Div0?}
+          FPE_FLTOVF : Res:=205;  {Overflow trap}
+          FPE_FLTUND : Res:=206;  {Stack over/underflow}
+          FPE_FLTRES : Res:=208;  {Device not available}
+          FPE_FLTINV : Res:=207;  {Invalid floating point operation}
+          Else
+              Res:=208; {coprocessor error}
+        end;
+      end;
+    SIGILL,
+    SIGBUS,
+    SIGSEGV :
+        res:=216;
+  end;
+  {$ifdef FPC_USE_SIGPROCMASK}
+   reenable_signal(sig);
+  {$endif }
+{ give runtime error at the position where the signal was raised }
+  if res<>0 then
+   begin
+     HandleErrorAddrFrame(res,Pointer(SigContext.sc_ir),pointer(SigContext.sc_sp));
+   end;
+end;
+
+{
+  $Log$
+  Revision 1.1  2004-01-04 20:05:38  jonas
+    * first working version of the Darwin/Mac OS X (for PowerPC) RTL
+      Several non-essential units are still missing, but make cycle works
+
+  Revision 1.1  2004/01/03 12:29:36  marco
+   * now separately.
+
+}

+ 72 - 0
rtl/darwin/pthread.inc

@@ -0,0 +1,72 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 1999-2000 by Peter Vreman
+    member of the Free Pascal development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This file contains a pthread.h headerconversion,
+    and should contain an interface to the threading library to be
+    used by systhrd, preferably in a somewhat compatible notation
+    (compared to the other OSes).
+
+    As a start, I simply used libc_r
+
+    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.
+
+ **********************************************************************}
+
+CONST PTHREAD_EXPLICIT_SCHED       = 0;
+      PTHREAD_CREATE_DETACHED      = 1;
+      PTHREAD_SCOPE_PROCESS        = 0;
+
+ TYPE
+    pthread_t       = pointer;
+    ppthread_t      = ^pthread_t;
+    pthread_key_t   = cint;
+    ppthread_key_t  = ^pthread_key_t;
+    pthread_mutex_t = TRTLCriticalSection;
+    ppthread_mutex_t= PRTLCriticalSection;
+    pthread_attr_t  = pointer; // opague
+    ppthread_attr_t = ^pthread_attr_t; // opague
+    __destr_func_t  = procedure (p :pointer);cdecl;
+    __startroutine_t= function (p :pointer):pointer;cdecl;
+    pthread_mutex_attr_t  = pointer;
+    ppthread_mutex_attr_t = ^pthread_mutex_t;
+
+function  pthread_getspecific      (t : pthread_key_t):pointer; cdecl; external 'c';
+function  pthread_setspecific      (t : pthread_key_t;p:pointer):cint; cdecl; external 'c';
+function  pthread_key_create       (p : ppthread_key_t;f: __destr_func_t):cint; cdecl;external 'c';
+function  pthread_attr_init           (p : ppthread_key_t):cint; cdecl; external 'c';
+function  pthread_attr_setinheritsched(p : ppthread_attr_t;i:cint):cint; cdecl; external 'c';
+function  pthread_attr_setscope      (p : ppthread_attr_t;i:cint):cint;cdecl;external 'c';
+function  pthread_attr_setdetachstate (p : ppthread_attr_t;i:cint):cint;cdecl;external 'c';
+function  pthread_create ( p: ppthread_t;attr : ppthread_attr_t;f:__startroutine_t;arg:pointer):cint;cdecl;external 'c';
+procedure pthread_exit  ( p: pointer); cdecl;external 'c';
+function  pthread_self:cint; cdecl;external 'c';
+function  pthread_mutex_init (p:ppthread_mutex_t;o:ppthread_mutex_attr_t):cint; cdecl;external 'c';
+function  pthread_mutex_destroy (p:ppthread_mutex_attr_t):cint; cdecl;external 'c';
+function  pthread_mutex_lock    (p:ppthread_mutex_attr_t):cint; cdecl;external 'c';
+function  pthread_mutex_unlock  (p:ppthread_mutex_attr_t):cint; cdecl;external 'c';
+function  pthread_cancel(_para1:pthread_t):cint;cdecl;external 'c';
+function  pthread_detach(_para1:pthread_t):cint;cdecl;external 'c';
+function  pthread_join(_para1:pthread_t; _para2:Ppointer):cint;cdecl;external 'c';
+
+{
+  $Log$
+  Revision 1.1  2004-01-04 20:05:38  jonas
+    * first working version of the Darwin/Mac OS X (for PowerPC) RTL
+      Several non-essential units are still missing, but make cycle works
+
+  Revision 1.2  2003/11/27 20:24:10  michael
+  + Redefined ppthread_mutex_t
+
+  Revision 1.1  2003/11/18 22:33:42  marco
+   * moved from systhrds.pp
+
+
+}

+ 59 - 2
rtl/darwin/ptypes.inc

@@ -55,7 +55,7 @@ type
     pPid     = ^pid_t;
 
     size_t   = cuint32;         { as definied in the C standard}
-   TSize    = size_t;
+    TSize    = size_t;
     pSize    = ^size_t;         
 
     ssize_t  = cint32;          { used by function for returning number of bytes }
@@ -73,11 +73,28 @@ type
     time_t   = clong;           { used for returning the time  }
     TTime    = time_t; 
     pTime    = ^time_t;
+    ptime_t =  ^time_t;
 
     socklen_t= cuint32;
     TSocklen = socklen_t;
     pSocklen = ^socklen_t;
 
+    timeval = record
+        tv_sec: cint;
+        tv_usec: cint;
+    end;
+    ptimeval = ^timeval;
+    TTimeVal = timeval;
+
+  timespec = packed record
+    tv_sec   : time_t;
+    tv_nsec  : clong;
+  end;
+  ptimespec= ^timespec;
+  Ttimespec= timespec;
+
+
+
 CONST
    { System limits, POSIX value in parentheses, used for buffer and stack allocation }
     ARG_MAX  = 65536;   {4096}  { Maximum number of argument size     }
@@ -86,9 +103,49 @@ CONST
 
     SYS_NMLN = 32;              {BSD utsname struct limit}
 
+    SIG_MAXSIG      = 32;	// highest signal version
+    wordsinsigset   = 1;		// words in sigset_t
+
+
+    MFSNAMELEN = 15;
+    MNAMELEN   = 90;
+
+  type
+     fsid_t = record
+          val: array[0..1] of cint32;
+     end;
+
+     tstatfs = record
+          otype : cint16;
+          oflags : cint16;
+          bsize : cint32;
+          iosize : cint32;
+          blocks : cint32;
+          bfree : cint32;
+          bavail : cint32;
+          files : cint32;
+          ffree : cint32;
+          fsid : fsid_t;
+          fowner : uid_t;
+          reserved1 : cint16;
+          ftype : cint16;
+          fflags : cint32;
+          reserved2 : array[0..1] of cint32;
+          fstypename : array[0..(MFSNAMELEN)-1] of char;
+          mountpoint : array[0..(MNAMELEN)-1] of char;
+          mntfromname : array[0..(MNAMELEN)-1] of char;
+       end;
+    pstatfs = ^tstatfs;
+
+
+
 {
   $Log$
-  Revision 1.2  2003-05-25 12:59:57  jonas
+  Revision 1.3  2004-01-04 20:05:38  jonas
+    * first working version of the Darwin/Mac OS X (for PowerPC) RTL
+      Several non-essential units are still missing, but make cycle works
+
+  Revision 1.2  2003/05/25 12:59:57  jonas
     * several fixes, addition of Mach trap numbers (thye are simply syscalls
       with a negative number)
 

+ 65 - 22
rtl/darwin/signal.inc

@@ -64,10 +64,10 @@
     }
 
 {$ifdef cpupowerpc}
-{$include powerpc/signal.inc}    { sigcontext }
+{$include powerpc/sig_cpu.inc}    { sigcontext }
 {$else cpupowerpc}
 {$ifdef cpui386}
-{$include i386/signal.inc}    { sigcontext }
+{$include i386/sig_cpu.inc}       { sigcontext }
 {$else cpui386}
 {$error Unsupported cpu type!}
 {$endif cpui386}
@@ -75,6 +75,15 @@
 
 
   const
+    SA_NOCLDSTOP = 8;
+    SA_ONSTACK   = $001; { take signal on signal stack }
+    SA_RESTART   = $002; { restart system call on signal return }
+    SA_RESETHAND = $004; { reset to SIG_DFL when taking signal }
+    SA_NODEFER   = $010; { don't mask the signal we're delivering }
+    SA_NOCLDWAIT = $020; { don't keep zombies around }
+    SA_SIGINFO   = $040; { signal handler with SA_SIGINFO args }
+    SA_USERTRAMP = $100; { SUNOS compat: Do not bounce off kernel's sigtramp }
+
   { hangup  }
      SIGHUP = 1;
   { interrupt  }
@@ -144,16 +153,43 @@
      SIG_ERR = -1;
 
   type
-     sigset_t = dword;
+     sigset_t = array[0..0] of cuint;
+
+  Sigval = Record
+            Case Boolean OF
+        { Members as suggested by Annex C of POSIX 1003.1b. }
+                false : (sigval_int : cint);
+                True  : (sigval_ptr : Pointer);
+            End;
+
+  TSigInfo_t = record
+                si_signo,                       { signal number }
+                si_errno,                       { errno association }
+        {
+         * Cause of signal, one of the SI_ macros or signal-specific
+         * values, i.e. one of the FPE_... values for SIGFPE. This
+         * value is equivalent to the second argument to an old-style
+         * FreeBSD signal handler.
+         }
+                si_code,                        { signal code }
+                si_pid          : cint;         { sending process }
+                si_uid          : cuint;        { sender's ruid }
+                si_status       : cint;         { exit value }
+                si_addr         : Pointer;      { faulting instruction }
+                si_value        : SigVal;       { signal value }
+                si_band         : cuint;        { band event for SIGPOLL }
+                pad             : array[0..6] of cint; { Reserved for Future Use }
+               end;
 
     SignalHandler   = Procedure(Sig : Longint);cdecl;
     PSignalHandler  = ^SignalHandler;
     SignalRestorer  = Procedure;cdecl;
     PSignalRestorer = ^SignalRestorer;
-    TSigAction = procedure(Sig: Longint; SigContext: SigContextRec;someptr:pointer);cdecl;
+    TSigAction = procedure (Sig: cint; var info : tsiginfo_t;Var SigContext:SigContextRec); cdecl;
 
+    TSigset=sigset_t;
     Sigset=sigset_t;
-    PSigSet = ^SigSet;
+    PSigSet = ^TSigSet;
 
     SigActionRec = packed record
 {
@@ -161,24 +197,16 @@
         0: (Sh: SignalHandler; Sa_Flags: longint; Sa_Mask: SigSet);
         1: (sa_handler: TSigAction);
 }
-      Sa_Handler: SignalHandler;
+      Sa_Handler: TSigAction;
       Sa_Flags: longint;
-      Sa_Mask: SigSet;
+      Sa_Mask: TSigSet;
    end;
+   PSigActionRec = ^SigActionRec;
 
-  const
-     SA_ONSTACK = $0001;
-  { restart system on signal return  }
-     SA_RESTART = $0002;
-  { disable taking signals on alternate stack  }
-     SA_DISABLE = $0004;
-  { do not bounce off kernel's sigtramp  }
-     SA_USERTRAMP = $0100;
-  { do not generate SIGCHLD on child stop  }
-     SA_NOCLDSTOP = $0008;
   {
      Flags for sigprocmask:
     }
+const
   { block specified signal set  }
      SIG_BLOCK = 1;
   { unblock specified signal set  }
@@ -205,19 +233,20 @@
   const
      MINSIGSTKSZ = 8192;
   { recommended stack size  }
-     SIGSTKSZ = MINSIGSTKSZ + 32768;
+  { already defined in another BSD include file }
+//     SIGSTKSZ = MINSIGSTKSZ + 32768;
   {
      4.3 compatibility:
      Signal vector "template" used in sigvec call.
     }
-  { signal handler  }
-  { signal mask to apply  }
-  { see signal options below  }
 
   type
      sigvec = record
+  { signal handler  }
           sv_handler : procedure ;
+  { signal mask to apply  }
           sv_mask : longint;
+  { see signal options below  }
           sv_flags : longint;
        end;
 
@@ -227,6 +256,16 @@
   { same bit, opposite sense  }
      SV_INTERRUPT = SA_RESTART;
 
+{ Codes for SIGFPE }
+     FPE_NOOP      =  0;       { if only I knew... }
+     FPE_FLTDIV    =  1;       { floating point divide by zero }
+     FPE_INTDIV    =  FPE_FLTDIV;
+     FPE_FLTOVF    =  2;       { floating point overflow }
+     FPE_FLTUND    =  3;       { floating point underflow }
+     FPE_FLTRES    =  4;       { floating point inexact result }
+     FPE_FLTINV    =  5;       { invalid floating point operation }
+
+
 (*
   {
      Structure used in sigstack call.
@@ -243,7 +282,11 @@
 
 {
   $Log$
-  Revision 1.3  2003-08-21 22:25:17  olle
+  Revision 1.4  2004-01-04 20:05:38  jonas
+    * first working version of the Darwin/Mac OS X (for PowerPC) RTL
+      Several non-essential units are still missing, but make cycle works
+
+  Revision 1.3  2003/08/21 22:25:17  olle
     - removed parameter from fpc_iocheck
 
   Revision 1.2  2003/05/25 12:59:57  jonas

+ 543 - 0
rtl/darwin/sysctlh.inc

@@ -0,0 +1,543 @@
+{
+    $Id$
+}
+
+{$PACKRECORDS C}
+
+  {
+     Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved.
+    
+     @APPLE_LICENSE_HEADER_START@
+     
+     The contents of this file constitute Original Code as defined in and
+     are subject to the Apple Public Source License Version 1.1 (the
+     "License").  You may not use this file except in compliance with the
+     License.  Please obtain a copy of the License at
+     http://www.apple.com/publicsource and read it before using this file.
+     
+     This Original Code and all software distributed under the License are
+     distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+     EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+     INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+     FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
+     License for the specific language governing rights and limitations
+     under the License.
+     
+     @APPLE_LICENSE_HEADER_END@
+    }
+  { Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved  }
+  {
+     Copyright (c) 1989, 1993
+    	The Regents of the University of California.  All rights reserved.
+    
+     This code is derived from software contributed to Berkeley by
+     Mike Karels at Berkeley Software Design, Inc.
+    
+     Redistribution and use in source and binary forms, with or without
+     modification, are permitted provided that the following conditions
+     are met:
+     1. Redistributions of source code must retain the above copyright
+        notice, this list of conditions and the following disclaimer.
+     2. Redistributions in binary form must reproduce the above copyright
+        notice, this list of conditions and the following disclaimer in the
+        documentation and/or other materials provided with the distribution.
+     3. All advertising materials mentioning features or use of this software
+        must display the following acknowledgement:
+    	This product includes software developed by the University of
+    	California, Berkeley and its contributors.
+     4. Neither the name of the University nor the names of its contributors
+        may be used to endorse or promote products derived from this software
+        without specific prior written permission.
+    
+     THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+     ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+     IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+     ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+     FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+     DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+     OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+     HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+     LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+     OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+     SUCH DAMAGE.
+    
+    	@(#)sysctl.h	8.1 (Berkeley) 6/2/93
+    }
+  {
+     These are for the eproc structure defined below.
+    }
+  {
+     Definitions for sysctl call.  The sysctl call uses a hierarchical name
+     for objects that can be examined or modified.  The name is expressed as
+     a sequence of integers.  Like a file path name, the meaning of each
+     component depends on its place in the hierarchy.  The top-level and kern
+     identifiers are defined here, and other identifiers are defined in the
+     respective subsystem header files.
+    }
+  { largest number of components supported  }
+
+  const
+     CTL_MAXNAME = 12;
+  {
+     Each subsystem defined by sysctl defines a list of variables
+     for that subsystem. Each name is either a node with further 
+     levels defined below it, or it is a leaf of some particular
+     type given below. Each sysctl level defines a set of name/type
+     pairs to be used by sysctl(1) in manipulating the subsystem.
+    }
+  { subsystem name  }
+  { type of name  }
+
+  type
+     ctlname = record
+          ctl_name : ^char;
+          ctl_type : longint;
+       end;
+
+  { Mask for the type  }
+
+  const
+     CTLTYPE = $f;
+  { name is a node  }
+     CTLTYPE_NODE = 1;
+  { name describes an integer  }
+     CTLTYPE_INT = 2;
+  { name describes a string  }
+     CTLTYPE_STRING = 3;
+  { name describes a 64-bit number  }
+     CTLTYPE_QUAD = 4;
+  { name describes a structure  }
+     CTLTYPE_OPAQUE = 5;
+  { name describes a structure  }
+     CTLTYPE_STRUCT = CTLTYPE_OPAQUE;
+  { Allow reads of variable  }
+     CTLFLAG_RD = $80000000;
+  { Allow writes to the variable  }
+     CTLFLAG_WR = $40000000;
+     CTLFLAG_RW = CTLFLAG_RD or CTLFLAG_WR;
+  { XXX Don't Lock  }
+     CTLFLAG_NOLOCK = $20000000;
+  { All users can set this var  }
+     CTLFLAG_ANYBODY = $10000000;
+  { Permit set only if securelevel<=0  }
+     CTLFLAG_SECURE = $08000000;
+  { deprecated variable, do not display  }
+     CTLFLAG_MASKED = $04000000;
+  { do not auto-register  }
+     CTLFLAG_NOAUTO = $02000000;
+  { valid inside the kernel  }
+     CTLFLAG_KERN = $01000000;
+  {
+     USE THIS instead of a hardwired number from the categories below
+     to get dynamically assigned sysctl entries using the linker-set
+     technology. This is the way nearly all new sysctl variables should
+     be implemented.
+     e.g. SYSCTL_INT(_parent, OID_AUTO, name, CTLFLAG_RW, &variable, 0, "");
+    }
+     OID_AUTO = -(1);
+  {
+     Top-level identifiers
+    }
+  { unused  }
+     CTL_UNSPEC = 0;
+  { "high kernel": proc, limits  }
+     CTL_KERN = 1;
+  { virtual memory  }
+     CTL_VM = 2;
+  { file system, mount type is next  }
+     CTL_VFS = 3;
+  { network, see socket.h  }
+     CTL_NET = 4;
+  { debugging parameters  }
+     CTL_DEBUG = 5;
+  { generic cpu/io  }
+     CTL_HW = 6;
+  { machine dependent  }
+     CTL_MACHDEP = 7;
+  { user-level  }
+     CTL_USER = 8;
+  { number of valid top-level ids  }
+     CTL_MAXID = 9;
+    {
+       CTL_KERN identifiers
+      }
+    { string: system version  }
+       KERN_OSTYPE = 1;
+    { string: system release  }
+       KERN_OSRELEASE = 2;
+    { int: system revision  }
+       KERN_OSREV = 3;
+    { string: compile time info  }
+       KERN_VERSION = 4;
+    { int: max vnodes  }
+       KERN_MAXVNODES = 5;
+    { int: max processes  }
+       KERN_MAXPROC = 6;
+    { int: max open files  }
+       KERN_MAXFILES = 7;
+    { int: max arguments to exec  }
+       KERN_ARGMAX = 8;
+    { int: system security level  }
+       KERN_SECURELVL = 9;
+    { string: hostname  }
+       KERN_HOSTNAME = 10;
+    { int: host identifier  }
+       KERN_HOSTID = 11;
+    { struct: struct clockrate  }
+       KERN_CLOCKRATE = 12;
+    { struct: vnode structures  }
+       KERN_VNODE = 13;
+    { struct: process entries  }
+       KERN_PROC = 14;
+    { struct: file entries  }
+       KERN_FILE = 15;
+    { node: kernel profiling info  }
+       KERN_PROF = 16;
+    { int: POSIX.1 version  }
+       KERN_POSIX1 = 17;
+    { int: # of supplemental group ids  }
+       KERN_NGROUPS = 18;
+    { int: is job control available  }
+       KERN_JOB_CONTROL = 19;
+    { int: saved set-user/group-ID  }
+       KERN_SAVED_IDS = 20;
+    { struct: time kernel was booted  }
+       KERN_BOOTTIME = 21;
+    { string: YP domain name  }
+       KERN_NISDOMAINNAME = 22;
+       KERN_DOMAINNAME = KERN_NISDOMAINNAME;
+    { int: number of partitions/disk  }
+       KERN_MAXPARTITIONS = 23;
+    { int: kernel trace points  }
+       KERN_KDEBUG = 24;
+    { int: update process sleep time  }
+       KERN_UPDATEINTERVAL = 25;
+    { int: OS release date  }
+       KERN_OSRELDATE = 26;
+    { node: NTP PLL control  }
+       KERN_NTP_PLL = 27;
+    { string: name of booted kernel  }
+       KERN_BOOTFILE = 28;
+    { int: max open files per proc  }
+       KERN_MAXFILESPERPROC = 29;
+    { int: max processes per uid  }
+       KERN_MAXPROCPERUID = 30;
+    { dev_t: device to dump on  }
+       KERN_DUMPDEV = 31;
+    { node: anything related to IPC  }
+       KERN_IPC = 32;
+    { unused  }
+       KERN_DUMMY = 33;
+    { int: address of PS_STRINGS  }
+       KERN_PS_STRINGS = 34;
+    { int: address of USRSTACK  }
+       KERN_USRSTACK = 35;
+    { int: do we log sigexit procs?  }
+       KERN_LOGSIGEXIT = 36;
+    { string: kernel symbol filename  }
+       KERN_SYMFILE = 37;
+       KERN_PROCARGS = 38;
+    { node: pc sampling  }
+       KERN_PCSAMPLES = 39;
+    { int: are we netbooted? 1=yes,0=no  }
+       KERN_NETBOOT = 40;
+    { node: panic UI information  }
+       KERN_PANICINFO = 41;
+    { node: panic UI information  }
+       KERN_SYSV = 42;
+    { xxx  }
+       KERN_AFFINITY = 43;
+    { xxx  }
+       KERN_CLASSIC = 44;
+    { xxx  }
+       KERN_CLASSICHANDLER = 45;
+    { int: max aio requests  }
+       KERN_AIOMAX = 46;
+    { int: max aio requests per process  }
+       KERN_AIOPROCMAX = 47;
+    { int: max aio worker threads  }
+       KERN_AIOTHREADS = 48;
+    { __APPLE_API_UNSTABLE  }
+    { number of valid kern ids  }
+
+    const
+       KERN_MAXID = 50;
+    { KERN_KDEBUG types  }
+       KERN_KDEFLAGS = 1;
+       KERN_KDDFLAGS = 2;
+       KERN_KDENABLE = 3;
+       KERN_KDSETBUF = 4;
+       KERN_KDGETBUF = 5;
+       KERN_KDSETUP = 6;
+       KERN_KDREMOVE = 7;
+       KERN_KDSETREG = 8;
+       KERN_KDGETREG = 9;
+       KERN_KDREADTR = 10;
+       KERN_KDPIDTR = 11;
+       KERN_KDTHRMAP = 12;
+    { Don't use 13 as it is overloaded with KERN_VNODE  }
+       KERN_KDPIDEX = 14;
+       KERN_KDSETRTCDEC = 15;
+       KERN_KDGETENTROPY = 16;
+    { KERN_PCSAMPLES types  }
+       KERN_PCDISABLE = 1;
+       KERN_PCSETBUF = 2;
+       KERN_PCGETBUF = 3;
+       KERN_PCSETUP = 4;
+       KERN_PCREMOVE = 5;
+       KERN_PCREADBUF = 6;
+       KERN_PCSETREG = 7;
+       KERN_PCCOMM = 8;
+    { KERN_PANICINFO types  }
+    { quad: panic UI image size limit  }
+       KERN_PANICINFO_MAXSIZE = 1;
+    { string: path to the panic UI (16 bit)  }
+       KERN_PANICINFO_IMAGE16 = 2;
+    { string: path to the panic UI (32 bit)  }
+       KERN_PANICINFO_IMAGE32 = 3;
+    {
+       KERN_SYSV identifiers
+      }
+    { int: max shared memory segment size (bytes)  }
+       KSYSV_SHMMAX = 1;
+    { int: min shared memory segment size (bytes)  }
+       KSYSV_SHMMIN = 2;
+    { int: max number of shared memory identifiers  }
+       KSYSV_SHMMNI = 3;
+    { int: max shared memory segments per process  }
+       KSYSV_SHMSEG = 4;
+    { int: max amount of shared memory (pages)  }
+       KSYSV_SHMALL = 5;
+    { int: max num of semaphore identifiers   }
+       KSYSV_SEMMNI = 6;
+    { int: max num of semaphores in system  }
+       KSYSV_SEMMNS = 7;
+    { int: max num of undo structures in system   }
+       KSYSV_SEMMNU = 8;
+    { int: max num of semaphores per id   }
+       KSYSV_SEMMSL = 9;
+    { int: max num of undo entries per process  }
+       KSYSV_SEMUNE = 10;
+       error1 = 1;
+    { 
+       KERN_PROC subtypes
+      }
+    { everything  }
+       KERN_PROC_ALL = 0;
+    { by process id  }
+       KERN_PROC_PID = 1;
+    { by process group id  }
+       KERN_PROC_PGRP = 2;
+    { by session of pid  }
+       KERN_PROC_SESSION = 3;
+    { by controlling tty  }
+       KERN_PROC_TTY = 4;
+    { by effective uid  }
+       KERN_PROC_UID = 5;
+    { by real uid  }
+       KERN_PROC_RUID = 6;
+    { 
+       KERN_PROC subtype ops return arrays of augmented proc structures:
+      }
+    {
+       KERN_IPC identifiers
+      }
+    { int: max size of a socket buffer  }
+
+    const
+       KIPC_MAXSOCKBUF = 1;
+    { int: wastage factor in sockbuf  }
+       KIPC_SOCKBUF_WASTE = 2;
+    { int: max length of connection q  }
+       KIPC_SOMAXCONN = 3;
+    { int: max length of link header  }
+       KIPC_MAX_LINKHDR = 4;
+    { int: max length of network header  }
+       KIPC_MAX_PROTOHDR = 5;
+    { int: max total length of headers  }
+       KIPC_MAX_HDR = 6;
+    { int: max length of data?  }
+       KIPC_MAX_DATALEN = 7;
+    { struct: mbuf usage statistics  }
+       KIPC_MBSTAT = 8;
+    { int: maximum mbuf clusters  }
+       KIPC_NMBCLUSTERS = 9;
+    {
+       CTL_VM identifiers
+      }
+    { struct vmmeter  }
+       VM_METER = 1;
+    { struct loadavg  }
+       VM_LOADAVG = 2;
+    { number of valid vm ids  }
+       VM_MAXID = 3;
+    { struct loadavg with mach factor }
+       VM_MACHFACTOR = 4;
+    {
+       CTL_HW identifiers
+      }
+    { string: machine class  }
+       HW_MACHINE = 1;
+    { string: specific machine model  }
+       HW_MODEL = 2;
+    { int: number of cpus  }
+       HW_NCPU = 3;
+    { int: machine byte order  }
+       HW_BYTEORDER = 4;
+    { int: total memory  }
+       HW_PHYSMEM = 5;
+    { int: non-kernel memory  }
+       HW_USERMEM = 6;
+    { int: software page size  }
+       HW_PAGESIZE = 7;
+    { strings: disk drive names  }
+       HW_DISKNAMES = 8;
+    { struct: diskstats[]  }
+       HW_DISKSTATS = 9;
+    { int: 0 for Legacy, else NewWorld  }
+       HW_EPOCH = 10;
+    { int: has HW floating point?  }
+       HW_FLOATINGPT = 11;
+    { string: machine architecture  }
+       HW_MACHINE_ARCH = 12;
+    { int: has HW vector unit?  }
+       HW_VECTORUNIT = 13;
+    { int: Bus Frequency  }
+       HW_BUS_FREQ = 14;
+    { int: CPU Frequency  }
+       HW_CPU_FREQ = 15;
+    { int: Cache Line Size in Bytes  }
+       HW_CACHELINE = 16;
+    { int: L1 I Cache Size in Bytes  }
+       HW_L1ICACHESIZE = 17;
+    { int: L1 D Cache Size in Bytes  }
+       HW_L1DCACHESIZE = 18;
+    { int: L2 Cache Settings  }
+       HW_L2SETTINGS = 19;
+    { int: L2 Cache Size in Bytes  }
+       HW_L2CACHESIZE = 20;
+    { int: L3 Cache Settings  }
+       HW_L3SETTINGS = 21;
+    { int: L3 Cache Size in Bytes  }
+       HW_L3CACHESIZE = 22;
+    { int: Bus Frequency  }
+       HW_TB_FREQ = 23;
+    { uint64_t: physical ram size  }
+       HW_MEMSIZE = 24;
+    { int: number of available CPUs  }
+       HW_AVAILCPU = 25;
+    { number of valid hw ids  }
+       HW_MAXID = 26;
+
+    {
+       These are the support HW selectors for sysctlbyname.  Parameters that are byte count or frequencies are 64 bit numbers.
+       All other parameters are 32 bit numbers.
+      
+         hw.memsize                - The number of bytes of physical memory in the system.
+      
+         hw.ncpu                   - The number maximum number of processor that could be available this boot.
+                                     Use this value for sizing of static per processor arrays; i.e. processor load statistics.
+      
+         hw.activecpu              - The number of cpus currently available for executing threads.
+                                     Use this number to determine the number threads to create in SMP aware applications.
+                                     This number can change when power management modes are changed.
+         
+         hw.tbfrequency            - This gives the time base frequency used by the OS and is the basis of all timing services.
+                                     In general is is better to use mach's or higher level timing services, but this value
+                                     is needed to convert the PPC Time Base registers to real time.
+      
+         hw.cpufrequency           - These values provide the current, min and max cpu frequency.  The min and max are for
+         hw.cpufrequency_max       - all power management modes.  The current frequency is the max frequency in the current mode.
+         hw.cpufrequency_min       - All frequencies are in Hz.
+      
+         hw.busfrequency           - These values provide the current, min and max bus frequency.  The min and max are for
+         hw.busfrequency_max       - all power management modes.  The current frequency is the max frequency in the current mode.
+         hw.busfrequency_min       - All frequencies are in Hz.
+      
+         hw.cputype                - These values provide the mach-o cpu type and subtype.  A complete list is in <mach/machine.h>
+         hw.cpusubtype             - These values should be used to determine what processor family the running cpu is from so that
+                                     the best binary can be chosen, or the best dynamic code generated.  They should not be used
+                                     to determine if a given processor feature is available.
+      
+         hw.byteorder              - Gives the byte order of the processor.  4321 for big endian, 1234 for little.
+      
+         hw.pagesize               - Gives the size in bytes of the pages used by the processor and VM system.
+      
+         hw.cachelinesize          - Gives the size in bytes of the processor's cache lines.
+                                     This value should be use to control the strides of loops that use cache control instructions
+                                     like dcbz, dcbt or dcbst.
+      
+         hw.l1dcachesize           - These values provide the size in bytes of the L1, L2 and L3 caches.  If a cache is not present
+         hw.l1icachesize           - then the selector will return and error.
+         hw.l2cachesize            -
+         hw.l3cachesize            -
+      
+      
+       These are the selectors for optional processor features.  Selectors that return errors are not support on the system.
+       Supported features will return 1 if they are recommended or 0 if they are supported but are not expected to help performance.
+       Future versions of these selectors may return larger values as necessary so it is best to test for non zero.
+      
+         hw.optional.floatingpoint - Floating Point Instructions
+         hw.optional.altivec       - AltiVec Instructions
+         hw.optional.graphicsops   - Graphics Operations
+         hw.optional.64bitops      - 64-bit Instructions
+         hw.optional.fsqrt         - HW Floating Point Square Root Instruction
+         hw.optional.stfiwx        - Store Floating Point as Integer Word Indexed Instructions
+         hw.optional.dcba          - Data Cache Block Allocate Instruction
+         hw.optional.datastreams   - Data Streams Instructions
+         hw.optional.dcbtstreams   - Data Cache Block Touch Steams Instruction Form
+      
+      }
+    {
+       CTL_USER definitions
+      }
+    { string: _CS_PATH  }
+    { int: BC_BASE_MAX  }
+       USER_BC_BASE_MAX = 2;
+    { int: BC_DIM_MAX  }
+       USER_BC_DIM_MAX = 3;
+    { int: BC_SCALE_MAX  }
+       USER_BC_SCALE_MAX = 4;
+    { int: BC_STRING_MAX  }
+       USER_BC_STRING_MAX = 5;
+    { int: COLL_WEIGHTS_MAX  }
+       USER_COLL_WEIGHTS_MAX = 6;
+    { int: EXPR_NEST_MAX  }
+       USER_EXPR_NEST_MAX = 7;
+    { int: LINE_MAX  }
+       USER_LINE_MAX = 8;
+    { int: RE_DUP_MAX  }
+       USER_RE_DUP_MAX = 9;
+    { int: POSIX2_VERSION  }
+       USER_POSIX2_VERSION = 10;
+    { int: POSIX2_C_BIND  }
+       USER_POSIX2_C_BIND = 11;
+    { int: POSIX2_C_DEV  }
+       USER_POSIX2_C_DEV = 12;
+    { int: POSIX2_CHAR_TERM  }
+       USER_POSIX2_CHAR_TERM = 13;
+    { int: POSIX2_FORT_DEV  }
+       USER_POSIX2_FORT_DEV = 14;
+    { int: POSIX2_FORT_RUN  }
+       USER_POSIX2_FORT_RUN = 15;
+    { int: POSIX2_LOCALEDEF  }
+       USER_POSIX2_LOCALEDEF = 16;
+    { int: POSIX2_SW_DEV  }
+       USER_POSIX2_SW_DEV = 17;
+    { int: POSIX2_UPE  }
+       USER_POSIX2_UPE = 18;
+    { int: POSIX2_STREAM_MAX  }
+       USER_STREAM_MAX = 19;
+    { int: POSIX2_TZNAME_MAX  }
+       USER_TZNAME_MAX = 20;
+    { number of valid user ids  }
+       USER_MAXID = 21;
+
+{
+  $Log$
+  Revision 1.1  2004-01-04 20:05:38  jonas
+    * first working version of the Darwin/Mac OS X (for PowerPC) RTL
+      Several non-essential units are still missing, but make cycle works
+
+
+}

+ 54 - 0
rtl/darwin/termio.pp

@@ -0,0 +1,54 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 1999-2000 by Peter Vreman
+    member of the Free Pascal development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This file contains the termios interface.
+
+    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.
+
+ **********************************************************************}
+
+unit termio;
+
+interface
+
+Uses BaseUnix;		// load base unix typing
+
+// load types + consts
+
+{$i termios.inc}
+
+// load default prototypes from unix dir.
+
+{$i termiosh.inc}
+
+implementation
+
+{$i textrec.inc}
+
+// load implementation for prototypes from current dir.
+{$i termiosproc.inc}
+
+// load ttyname from unix dir.
+{$i ttyname.inc}
+
+end.
+
+{
+  $Log$
+  Revision 1.1  2004-01-04 20:05:38  jonas
+    * first working version of the Darwin/Mac OS X (for PowerPC) RTL
+      Several non-essential units are still missing, but make cycle works
+
+  Revision 1.1  2003/11/19 17:15:31  marco
+   * termio new includefile
+
+
+}

+ 465 - 0
rtl/darwin/termios.inc

@@ -0,0 +1,465 @@
+{
+    $Id$
+}
+
+
+{$PACKRECORDS C}
+
+  {
+     Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+    
+     @APPLE_LICENSE_HEADER_START@
+     
+     The contents of this file constitute Original Code as defined in and
+     are subject to the Apple Public Source License Version 1.1 (the
+     "License").  You may not use this file except in compliance with the
+     License.  Please obtain a copy of the License at
+     http://www.apple.com/publicsource and read it before using this file.
+     
+     This Original Code and all software distributed under the License are
+     distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+     EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+     INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+     FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
+     License for the specific language governing rights and limitations
+     under the License.
+     
+     @APPLE_LICENSE_HEADER_END@
+    }
+  { Copyright (c) 1997 Apple Computer, Inc. All Rights Reserved  }
+  {
+     Copyright (c) 1988, 1989, 1993, 1994
+    	The Regents of the University of California.  All rights reserved.
+    
+     Redistribution and use in source and binary forms, with or without
+     modification, are permitted provided that the following conditions
+     are met:
+     1. Redistributions of source code must retain the above copyright
+        notice, this list of conditions and the following disclaimer.
+     2. Redistributions in binary form must reproduce the above copyright
+        notice, this list of conditions and the following disclaimer in the
+        documentation and/or other materials provided with the distribution.
+     3. All advertising materials mentioning features or use of this software
+        must display the following acknowledgement:
+          This product includes software developed by the University of
+          California, Berkeley and its contributors.
+     4. Neither the name of the University nor the names of its contributors
+        may be used to endorse or promote products derived from this software
+        without specific prior written permission.
+    
+     THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+     ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+     IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+     ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+     FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+     DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+     OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+     HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+     LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+     OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+     SUCH DAMAGE.
+    
+    	@(#)termios.h	8.3 (Berkeley) 3/28/94
+    }
+{$ifndef _SYS_TERMIOS_H_}
+{$define _SYS_TERMIOS_H_}
+  {
+     Special Control Characters
+    
+     Index into c_cc[] character array.
+    
+    	Name	     Subscript	Enabled by
+    }
+  { ICANON  }
+
+  const
+     VEOF = 0;
+  { ICANON  }
+     VEOL = 1;
+{$ifndef _POSIX_SOURCE}
+  { ICANON together with IEXTEN  }
+
+  const
+     VEOL2 = 2;
+{$endif}
+  { ICANON  }
+
+  const
+     VERASE = 3;
+{$ifndef _POSIX_SOURCE}
+  { ICANON together with IEXTEN  }
+
+  const
+     VWERASE = 4;
+{$endif}
+  { ICANON  }
+
+  const
+     VKILL = 5;
+{$ifndef _POSIX_SOURCE}
+  { ICANON together with IEXTEN  }
+
+  const
+     VREPRINT = 6;
+{$endif}
+  {			7	   spare 1  }
+  { ISIG  }
+
+  const
+     VINTR = 8;
+  { ISIG  }
+     VQUIT = 9;
+  { ISIG  }
+     VSUSP = 10;
+{$ifndef _POSIX_SOURCE}
+  { ISIG together with IEXTEN  }
+
+  const
+     VDSUSP = 11;
+{$endif}
+  { IXON, IXOFF  }
+
+  const
+     VSTART = 12;
+  { IXON, IXOFF  }
+     VSTOP = 13;
+{$ifndef _POSIX_SOURCE}
+  { IEXTEN  }
+
+  const
+     VLNEXT = 14;
+  { IEXTEN  }
+     VDISCARD = 15;
+{$endif}
+  { !ICANON  }
+
+  const
+     VMIN = 16;
+  { !ICANON  }
+     VTIME = 17;
+{$ifndef _POSIX_SOURCE}
+  { ICANON together with IEXTEN  }
+
+  const
+     VSTATUS = 18;
+  {			19	   spare 2  }
+{$endif}
+
+  const
+     NCCS = 20;
+{$ifndef _POSIX_VDISABLE}
+
+  const
+     _POSIX_VDISABLE = $ff;
+{$endif}
+{$ifndef _POSIX_SOURCE}
+  { was #define dname(params) para_def_expr }
+  { argument types are unknown }
+  { return type might be wrong }   
+  function CCEQ(val,c : longint) : longint;
+
+{$endif}
+  {
+     Input flags - software input processing
+    }
+  { ignore BREAK condition  }
+
+  const
+     IGNBRK = $00000001;
+  { map BREAK to SIGINTR  }
+     BRKINT = $00000002;
+  { ignore (discard) parity errors  }
+     IGNPAR = $00000004;
+  { mark parity and framing errors  }
+     PARMRK = $00000008;
+  { enable checking of parity errors  }
+     INPCK = $00000010;
+  { strip 8th bit off chars  }
+     ISTRIP = $00000020;
+  { map NL into CR  }
+     INLCR = $00000040;
+  { ignore CR  }
+     IGNCR = $00000080;
+  { map CR to NL (ala CRMOD)  }
+     ICRNL = $00000100;
+  { enable output flow control  }
+     IXON = $00000200;
+  { enable input flow control  }
+     IXOFF = $00000400;
+{$ifndef _POSIX_SOURCE}
+  { any char will restart after stop  }
+
+  const
+     IXANY = $00000800;
+  { ring bell on input queue full  }
+     IMAXBEL = $00002000;
+{$endif}
+  {_POSIX_SOURCE  }
+  {
+     Output flags - software output processing
+    }
+  { enable following output processing  }
+
+  const
+     OPOST = $00000001;
+{$ifndef _POSIX_SOURCE}
+  { map NL to CR-NL (ala CRMOD)  }
+
+  const
+     ONLCR = $00000002;
+  { expand tabs to spaces  }
+     OXTABS = $00000004;
+  { discard EOT's (^D) on output)  }
+     ONOEOT = $00000008;
+{$endif}
+  {_POSIX_SOURCE  }
+  {
+     Control flags - hardware control of terminal
+    }
+{$ifndef _POSIX_SOURCE}
+  { ignore control flags  }
+
+  const
+     CIGNORE = $00000001;
+{$endif}
+  { character size mask  }
+
+  const
+     CSIZE = $00000300;
+  { 5 bits (pseudo)  }
+     CS5 = $00000000;
+  { 6 bits  }
+     CS6 = $00000100;
+  { 7 bits  }
+     CS7 = $00000200;
+  { 8 bits  }
+     CS8 = $00000300;
+  { send 2 stop bits  }
+     CSTOPB = $00000400;
+  { enable receiver  }
+     CREAD = $00000800;
+  { parity enable  }
+     PARENB = $00001000;
+  { odd parity, else even  }
+     PARODD = $00002000;
+  { hang up on last close  }
+     HUPCL = $00004000;
+  { ignore modem status lines  }
+     CLOCAL = $00008000;
+{$ifndef _POSIX_SOURCE}
+  { CTS flow control of output  }
+
+  const
+     CCTS_OFLOW = $00010000;
+  { RTS flow control of input  }
+     CRTS_IFLOW = $00020000;
+     CRTSCTS = CCTS_OFLOW or CRTS_IFLOW;
+  { DTR flow control of input  }
+     CDTR_IFLOW = $00040000;
+  { DSR flow control of output  }
+     CDSR_OFLOW = $00080000;
+  { DCD flow control of output  }
+     CCAR_OFLOW = $00100000;
+  { old name for CCAR_OFLOW  }
+     MDMBUF = $00100000;
+{$endif}
+  {
+     "Local" flags - dumping ground for other state
+    
+     Warning: some flags in this structure begin with
+     the letter "I" and look like they belong in the
+     input flag.
+    }
+{$ifndef _POSIX_SOURCE}
+  { visual erase for line kill  }
+
+  const
+     ECHOKE = $00000001;
+{$endif}
+  {_POSIX_SOURCE  }
+  { visually erase chars  }
+
+  const
+     ECHOE = $00000002;
+  { echo NL after line kill  }
+     ECHOK = $00000004;
+  { enable echoing  }
+     ECHO = $00000008;
+  { echo NL even if ECHO is off  }
+     ECHONL = $00000010;
+{$ifndef _POSIX_SOURCE}
+  { visual erase mode for hardcopy  }
+
+  const
+     ECHOPRT = $00000020;
+  { echo control chars as ^(Char)  }
+     ECHOCTL = $00000040;
+{$endif}
+  {_POSIX_SOURCE  }
+  { enable signals INTR, QUIT, [D]SUSP  }
+
+  const
+     ISIG = $00000080;
+  { canonicalize input lines  }
+     ICANON = $00000100;
+{$ifndef _POSIX_SOURCE}
+  { use alternate WERASE algorithm  }
+
+  const
+     ALTWERASE = $00000200;
+{$endif}
+  {_POSIX_SOURCE  }
+  { enable DISCARD and LNEXT  }
+
+  const
+     IEXTEN = $00000400;
+  { external processing  }
+     EXTPROC = $00000800;
+  { stop background jobs from output  }
+     TOSTOP = $00400000;
+{$ifndef _POSIX_SOURCE}
+  { output being flushed (state)  }
+
+  const
+     FLUSHO = $00800000;
+  { no kernel output from VSTATUS  }
+     NOKERNINFO = $02000000;
+  { XXX retype pending input (state)  }
+     PENDIN = $20000000;
+{$endif}
+  {_POSIX_SOURCE  }
+  { don't flush after interrupt  }
+
+  const
+     NOFLSH = $80000000;
+
+  type
+
+     tcflag_t = dword;
+
+     cc_t = byte;
+
+     speed_t = longint;
+  { XXX should be unsigned long  }
+  { input flags  }
+  { output flags  }
+  { control flags  }
+  { local flags  }
+  { control chars  }
+  { input speed  }
+  { output speed  }
+     termios = record
+          c_iflag : tcflag_t;
+          c_oflag : tcflag_t;
+          c_cflag : tcflag_t;
+          c_lflag : tcflag_t;
+          c_cc : array[0..(NCCS)-1] of cc_t;
+          c_ispeed : speed_t;
+          c_ospeed : speed_t;
+       end;
+
+  {
+     Commands passed to tcsetattr() for setting the termios structure.
+    }
+  { make change immediate  }
+
+  const
+     TCSANOW = 0;
+  { drain output, then change  }
+     TCSADRAIN = 1;
+  { drain output, flush input  }
+     TCSAFLUSH = 2;
+{$ifndef _POSIX_SOURCE}
+  { flag - don't alter h.w. state  }
+
+  const
+     TCSASOFT = $10;
+{$endif}
+  {
+     Standard speeds
+    }
+
+  const
+     B0 = 0;
+     B50 = 50;
+     B75 = 75;
+     B110 = 110;
+     B134 = 134;
+     B150 = 150;
+     B200 = 200;
+     B300 = 300;
+     B600 = 600;
+     B1200 = 1200;
+     B1800 = 1800;
+     B2400 = 2400;
+     B4800 = 4800;
+     B9600 = 9600;
+     B19200 = 19200;
+     B38400 = 38400;
+{$ifndef _POSIX_SOURCE}
+
+  const
+     B7200 = 7200;
+     B14400 = 14400;
+     B28800 = 28800;
+     B57600 = 57600;
+     B76800 = 76800;
+     B115200 = 115200;
+     B230400 = 230400;
+     EXTA = 19200;
+     EXTB = 38400;
+{$endif}
+  { !_POSIX_SOURCE  }
+
+  const
+     TCIFLUSH = 1;
+     TCOFLUSH = 2;
+     TCIOFLUSH = 3;
+     TCOOFF = 1;
+     TCOON = 2;
+     TCIOFF = 3;
+     TCION = 4;
+
+{
+ * Control Character Defaults
+ }
+        CtrlMask        = $1f;  {\037}
+        CEOF            =chr( ORD('d') and CtrlMask);
+        CEOL            =chr( $ff and CtrlMask);{ XXX avoid _POSIX_VDISABLE }
+        CERASE          =chr( $7F and CtrlMask);
+        CINTR           =chr(ORD('c') and CtrlMask);
+        CSTATUS         =chr(ORD('t') and CtrlMask);
+        CKILL           =chr(ORD('u') and CtrlMask);
+        CMIN            =chr(1);
+        CQUIT           =chr(034  and CtrlMask);        { FS, ^\ }
+        CSUSP           =chr(ORD('z') and CtrlMask);
+        CTIME           =chr(0);
+        CDSUSP          =chr(ORD('y') and CtrlMask);
+        CSTART          =chr(ORD('q') and CtrlMask);
+        CSTOP           =chr(ORD('s') and CtrlMask);
+        CLNEXT          =chr(ORD('v') and CtrlMask);
+        CDISCARD        =chr(ORD('o') and CtrlMask);
+        CWERASE         =chr(ORD('w') and CtrlMask);
+        CREPRINT        =chr(ORD('r') and CtrlMask);
+        CEOT            =CEOF;
+{ compat }
+        CBRK            =CEOL;
+        CRPRNT          =CREPRINT;
+        CFLUSH          =CDISCARD;
+
+
+{
+ *        TTYDEFCHARS to include an array of default control characters.
+}
+    ttydefchars : array[0..NCCS-1] OF char =(
+        CEOF,   CEOL,   CEOL,   CERASE, CWERASE, CKILL, CREPRINT,
+        chr(_POSIX_VDISABLE), CINTR,  CQUIT,  CSUSP,  CDSUSP, CSTART, CSTOP,  CLNEXT,
+        CDISCARD, CMIN, CTIME,  CSTATUS, chr(_POSIX_VDISABLE));
+
+{
+  $Log$
+  Revision 1.1  2004-01-04 20:05:38  jonas
+    * first working version of the Darwin/Mac OS X (for PowerPC) RTL
+      Several non-essential units are still missing, but make cycle works
+
+}

+ 97 - 0
rtl/darwin/termiosproc.inc

@@ -0,0 +1,97 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 1999-2000 by Peter Vreman
+    member of the Free Pascal development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This file contains the implementation of several termio(s) functions
+
+    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.
+
+ **********************************************************************}
+
+{******************************************************************************
+                         IOCtl and Termios calls
+******************************************************************************}
+
+Function TCGetAttr(fd:cint;var tios:TermIOS):cint; cdecl; external 'c' name 'tcgetattr';
+Function TCSetAttr(fd:cint;OptAct:cint;const tios:TermIOS):cint; cdecl; external 'c' name 'tcsetattr';
+Procedure CFSetISpeed(var tios:TermIOS;speed:Cardinal); cdecl; external 'c' name 'cfsetispeed';
+Procedure CFSetOSpeed(var tios:TermIOS;speed:Cardinal); cdecl; external 'c' name 'cfsetospeed';
+Procedure CFMakeRaw(var tios:TermIOS); cdecl; external 'c' name 'cfmakeraw';
+
+Function TCSendBreak(fd,duration:cint):cint;
+begin
+  TCSendBreak:=fpIOCtl(fd,TIOCSBRK,nil);
+end;
+
+
+Function TCSetPGrp(fd,id:cint):cint;
+begin
+  TCSetPGrp:=fpIOCtl(fd,TIOCSPGRP,pointer(id));
+end;
+
+
+Function TCGetPGrp(fd:cint;var id:cint):cint;
+begin
+  TCGetPGrp:=fpIOCtl(fd,TIOCGPGRP,@id);
+end;
+
+Function TCDrain(fd:cint):cint;
+begin
+  TCDrain:=fpIOCtl(fd,TIOCDRAIN,nil); {Should set timeout to 1 first?}
+end;
+
+
+Function TCFlow(fd,act:cint):cint;
+begin
+    case act OF
+     TCOOFF :  TCFlow:=fpIoctl(fd,TIOCSTOP,nil);
+     TCOOn  :  TCFlow:=fpIOctl(Fd,TIOCStart,nil);
+     TCIOFF :  {N/I}
+    end;
+end;
+
+Function TCFlush(fd,qsel:cint):cint;
+begin
+  TCFlush:=fpIOCtl(fd,TIOCFLUSH,pointer(qsel));
+end;
+
+Function IsATTY (Handle:cint):cint;
+{
+  Check if the filehandle described by 'handle' is a TTY (Terminal)
+}
+var
+  t : Termios;
+begin
+ IsAtty:=TCGetAttr(Handle,t);
+end;
+
+
+Function IsATTY(var f: text):cint;
+{
+  Idem as previous, only now for text variables.
+}
+begin
+  IsATTY:=IsaTTY(textrec(f).handle);
+end;
+
+{
+   $Log$
+   Revision 1.1  2004-01-04 20:05:38  jonas
+     * first working version of the Darwin/Mac OS X (for PowerPC) RTL
+       Several non-essential units are still missing, but make cycle works
+
+   Revision 1.2  2003/12/16 19:43:53  marco
+    * nil <-> 0 changes
+
+   Revision 1.1  2003/11/19 17:15:31  marco
+    * termio new includefile
+
+
+}

+ 646 - 0
rtl/darwin/tthread.inc

@@ -0,0 +1,646 @@
+{
+    $Id$
+    This file is part of the Free Component Library (FCL)
+    Copyright (c) 1999-2000 by Peter Vreman
+
+    Darwin TThread implementation
+
+    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.
+
+ **********************************************************************}
+
+
+{$IFDEF VER1_0} // leaving the old implementation in for now...
+type
+  PThreadRec=^TThreadRec;
+  TThreadRec=record
+    thread : TThread;
+    next   : PThreadRec;
+  end;
+
+var
+  ThreadRoot : PThreadRec;
+  ThreadsInited : boolean;
+//  MainThreadID: longint;
+
+Const
+  ThreadCount: longint = 0;
+
+function ThreadSelf:TThread;
+var
+  hp : PThreadRec;
+  sp : Pointer;
+begin
+  sp:=SPtr;
+  hp:=ThreadRoot;
+  while assigned(hp) do
+   begin
+     if (sp<=hp^.Thread.FStackPointer) and
+        (sp>(hp^.Thread.FStackPointer-hp^.Thread.FStackSize)) then
+      begin
+        Result:=hp^.Thread;
+        exit;
+      end;
+     hp:=hp^.next;
+   end;
+  Result:=nil;
+end;
+
+
+//function SIGCHLDHandler(Sig: longint): longint; cdecl;//this is std linux C declaration as function
+procedure SIGCHLDHandler(Sig: longint); cdecl;
+
+begin
+  fpwaitpid(-1, nil, WNOHANG);
+end;
+
+procedure InitThreads;
+var
+  Act, OldAct: Baseunix.PSigActionRec;
+begin
+  ThreadRoot:=nil;
+  ThreadsInited:=true;
+
+
+// This will install SIGCHLD signal handler
+// signal() installs "one-shot" handler,
+// so it is better to install and set up handler with sigaction()
+
+  GetMem(Act, SizeOf(SigActionRec));
+  GetMem(OldAct, SizeOf(SigActionRec));
+
+  Act^.sa_handler := TSigAction(@SIGCHLDHandler);
+  Act^.sa_flags := SA_NOCLDSTOP {or SA_NOMASK or SA_RESTART};
+  Fillchar(Act^.sa_mask,sizeof(Act^.sa_mask),0); //Do not block all signals ??. Don't need if SA_NOMASK in flags
+  FpSigAction(SIGCHLD, Act, OldAct);
+
+  FreeMem(Act, SizeOf(SigActionRec));
+  FreeMem(OldAct, SizeOf(SigActionRec));
+end;
+
+
+procedure DoneThreads;
+var
+  hp : PThreadRec;
+begin
+  while assigned(ThreadRoot) do
+   begin
+     ThreadRoot^.Thread.Destroy;
+     hp:=ThreadRoot;
+     ThreadRoot:=ThreadRoot^.Next;
+     dispose(hp);
+   end;
+  ThreadsInited:=false;
+end;
+
+
+procedure AddThread(t:TThread);
+var
+  hp : PThreadRec;
+begin
+  { Need to initialize threads ? }
+  if not ThreadsInited then
+   InitThreads;
+
+  { Put thread in the linked list }
+  new(hp);
+  hp^.Thread:=t;
+  hp^.next:=ThreadRoot;
+  ThreadRoot:=hp;
+
+  inc(ThreadCount, 1);
+end;
+
+
+procedure RemoveThread(t:TThread);
+var
+  lasthp,hp : PThreadRec;
+begin
+  hp:=ThreadRoot;
+  lasthp:=nil;
+  while assigned(hp) do
+   begin
+     if hp^.Thread=t then
+      begin
+        if assigned(lasthp) then
+         lasthp^.next:=hp^.next
+        else
+         ThreadRoot:=hp^.next;
+        dispose(hp);
+        exit;
+      end;
+     lasthp:=hp;
+     hp:=hp^.next;
+   end;
+
+  Dec(ThreadCount, 1);
+  if ThreadCount = 0 then DoneThreads;
+end;
+
+
+{ TThread }
+function ThreadProc(args:pointer): Integer;cdecl;
+var
+  FreeThread: Boolean;
+  Thread : TThread absolute args;
+begin
+  while Thread.FHandle = 0 do fpsleep(1);
+  if Thread.FSuspended then Thread.suspend();
+  try
+    Thread.Execute;
+  except
+    Thread.FFatalException := TObject(AcquireExceptionObject);
+  end;
+  FreeThread := Thread.FFreeOnTerminate;
+  Result := Thread.FReturnValue;
+  Thread.FFinished := True;
+  Thread.DoTerminate;
+  if FreeThread then
+    Thread.Free;
+  fpexit(Result);
+end;
+
+
+constructor TThread.Create(CreateSuspended: Boolean);
+var
+  Flags: Integer;
+begin
+  inherited Create;
+  AddThread(self);
+  FSuspended := CreateSuspended;
+  Flags := CLONE_VM + CLONE_FS + CLONE_FILES + CLONE_SIGHAND + SIGCHLD;
+  { Setup 16k of stack }
+  FStackSize:=16384;
+  Getmem(FStackPointer,FStackSize);
+  inc(FStackPointer,FStackSize);
+  FCallExitProcess:=false;
+  { Clone }
+  FHandle:= Clone(@ThreadProc,FStackPointer,Flags,self);
+//  if FSuspended then Suspend;
+  FThreadID := FHandle;
+  IsMultiThread := TRUE;
+  FFatalException := nil;
+end;
+
+
+destructor TThread.Destroy;
+begin
+  if not FFinished and not Suspended then
+   begin
+     Terminate;
+     WaitFor;
+   end;
+  if FHandle <> -1 then
+    fpkill(FHandle, SIGKILL);
+  dec(FStackPointer,FStackSize);
+  Freemem(FStackPointer);
+  FFatalException.Free;
+  FFatalException := nil;
+  inherited Destroy;
+  RemoveThread(self);
+end;
+
+
+procedure TThread.CallOnTerminate;
+begin
+  FOnTerminate(Self);
+end;
+
+procedure TThread.DoTerminate;
+begin
+  if Assigned(FOnTerminate) then
+    Synchronize(@CallOnTerminate);
+end;
+
+
+const
+{ I Don't know idle or timecritical, value is also 20, so the largest other
+  possibility is 19 (PFV) }
+  Priorities: array [TThreadPriority] of Integer =
+   (-20,-19,-10,9,10,19,20);
+
+function TThread.GetPriority: TThreadPriority;
+var
+  P: Integer;
+  I: TThreadPriority;
+begin
+  P := fpGetPriority(Prio_Process,FHandle);
+  Result := tpNormal;
+  for I := Low(TThreadPriority) to High(TThreadPriority) do
+    if Priorities[I] = P then
+      Result := I;
+end;
+
+
+procedure TThread.SetPriority(Value: TThreadPriority);
+begin
+  fpSetPriority(Prio_Process,FHandle,Priorities[Value]);
+end;
+
+
+procedure TThread.Synchronize(Method: TThreadMethod);
+begin
+  FSynchronizeException := nil;
+  FMethod := Method;
+{  SendMessage(ThreadWindow, CM_EXECPROC, 0, Longint(Self)); }
+  if Assigned(FSynchronizeException) then
+    raise FSynchronizeException;
+end;
+
+
+procedure TThread.SetSuspended(Value: Boolean);
+begin
+  if Value <> FSuspended then
+    if Value then
+      Suspend
+    else
+      Resume;
+end;
+
+
+procedure TThread.Suspend;
+begin
+  FSuspended := true;
+  fpKill(FHandle, SIGSTOP);
+end;
+
+
+procedure TThread.Resume;
+begin
+  fpKill(FHandle, SIGCONT);
+  FSuspended := False;
+end;
+
+
+procedure TThread.Terminate;
+begin
+  FTerminated := True;
+end;
+
+function TThread.WaitFor: Integer;
+var
+  status : longint;
+begin
+  if FThreadID = MainThreadID then
+    fpwaitpid(0,@status,0)
+  else
+    fpwaitpid(FHandle,@status,0);
+  Result:=status;
+end;
+{$ELSE}
+
+{
+  What follows, is a short description on my implementation of TThread.
+  Most information can also be found by reading the source and accompanying
+  comments.
+  
+  A thread is created using BeginThread, which in turn calls
+  pthread_create. So the threads here are always posix threads.
+  Posix doesn't define anything for suspending threads as this is
+  inherintly unsafe. Just don't suspend threads at points they cannot
+  control. Therefore, I didn't implement .Suspend() if its called from
+  outside the threads execution flow (except on Linux _without_ NPTL).
+  
+  The implementation for .suspend uses a semaphore, which is initialized
+  at thread creation. If the thread tries to suspend itself, we simply
+  let it wait on the semaphore until it is unblocked by someone else
+  who calls .Resume.
+
+  If a thread is supposed to be suspended (from outside its own path of
+  execution) on a system where the symbol LINUX is defined, two things
+  are possible.
+  1) the system has the LinuxThreads pthread implementation
+  2) the system has NPTL as the pthread implementation.
+  
+  In the first case, each thread is a process on its own, which as far as
+  know actually violates posix with respect to signal handling.
+  But we can detect this case, because getpid(2) will
+  return a different PID for each thread. In that case, sending SIGSTOP
+  to the PID associated with a thread will actually stop that thread
+  only.
+  In the second case, this is not possible. But getpid(2) returns the same
+  PID across all threads, which is detected, and TThread.Suspend() does
+  nothing in that case. This should probably be changed, but I know of
+  no way to suspend a thread when using NPTL.
+  
+  If the symbol LINUX is not defined, then the unimplemented
+  function SuspendThread is called.
+  
+  Johannes Berg <[email protected]>, Sunday, November 16 2003
+}
+
+// ========== semaphore stuff ==========
+{
+  I don't like this. It eats up 2 filedescriptors for each thread,
+  and those are a limited resource. If you have a server programm
+  handling client connections (one per thread) it will not be able
+  to handle many if we use 2 fds already for internal structures.
+  However, right now I don't see a better option unless some sem_*
+  functions are added to systhrds.
+  I encapsulated all used functions here to make it easier to
+  change them completely.
+}
+
+function SemaphoreInit: Pointer;
+begin
+  SemaphoreInit := GetMem(SizeOf(TFilDes));
+  fppipe(PFilDes(SemaphoreInit)^);
+end;
+
+procedure SemaphoreWait(const FSem: Pointer);
+var
+  b: byte;
+begin
+  fpread(PFilDes(FSem)^[0], b, 1);
+end;
+
+procedure SemaphorePost(const FSem: Pointer);
+begin
+  fpwrite(PFilDes(FSem)^[1], #0, 1);
+end;
+
+procedure SemaphoreDestroy(const FSem: Pointer);
+begin
+  fpclose(PFilDes(FSem)^[0]);
+  fpclose(PFilDes(FSem)^[1]);
+  FreeMemory(FSem);
+end;
+
+// =========== semaphore end ===========
+
+var
+  ThreadsInited: boolean = false;
+{$IFDEF LINUX}
+  GMainPID: LongInt = 0;
+{$ENDIF}
+const
+  // stupid, considering its not even implemented...
+  Priorities: array [TThreadPriority] of Integer =
+   (-20,-19,-10,0,9,18,19);
+
+procedure InitThreads;
+begin
+  if not ThreadsInited then begin
+    ThreadsInited := true;
+    {$IFDEF LINUX}
+    GMainPid := fpgetpid();
+    {$ENDIF}
+  end;
+end;
+
+procedure DoneThreads;
+begin
+  ThreadsInited := false;
+end;
+
+{ ok, so this is a hack, but it works nicely. Just never use
+  a multiline argument with WRITE_DEBUG! }
+{$MACRO ON}
+{$IFDEF DEBUG_MT}
+{$define WRITE_DEBUG := writeln} // actually write something
+{$ELSE}
+{$define WRITE_DEBUG := //}      // just comment out those lines
+{$ENDIF}
+
+function ThreadFunc(parameter: Pointer): LongInt; cdecl;
+var
+  LThread: TThread;
+  c: char;
+begin
+  WRITE_DEBUG('ThreadFunc is here...');
+  LThread := TThread(parameter);
+  {$IFDEF LINUX}
+  // save the PID of the "thread"
+  // this is different from the PID of the main thread if
+  // the LinuxThreads implementation is used
+  LThread.FPid := fpgetpid();
+  {$ENDIF}
+  WRITE_DEBUG('thread initing, parameter = ', LongInt(LThread));
+  try
+    if LThread.FInitialSuspended then begin
+      SemaphoreWait(LThread.FSem);
+      if not LThread.FInitialSuspended then begin
+        WRITE_DEBUG('going into LThread.Execute');
+        LThread.Execute;
+      end;
+    end else begin
+      WRITE_DEBUG('going into LThread.Execute');
+      LThread.Execute;
+    end;
+  except
+    on e: exception do begin
+      WRITE_DEBUG('got exception: ',e.message);
+      LThread.FFatalException :=  TObject(AcquireExceptionObject);
+      // not sure if we should really do this...
+      // but .Destroy was called, so why not try FreeOnTerminate?
+      if e is EThreadDestroyCalled then LThread.FFreeOnTerminate := true;
+    end;
+  end;
+  WRITE_DEBUG('thread done running');
+  Result := LThread.FReturnValue;
+  WRITE_DEBUG('Result is ',Result);
+  LThread.FFinished := True;
+  LThread.DoTerminate;
+  if LThread.FreeOnTerminate then begin
+    WRITE_DEBUG('Thread should be freed');
+    LThread.Free;
+    WRITE_DEBUG('Thread freed');
+  end;
+  WRITE_DEBUG('thread func exiting');
+end;
+
+{ TThread }
+constructor TThread.Create(CreateSuspended: Boolean);
+begin
+  // lets just hope that the user doesn't create a thread
+  // via BeginThread and creates the first TThread Object in there!
+  InitThreads;
+  inherited Create;
+  FSem := SemaphoreInit;
+  FSuspended := CreateSuspended;
+  FSuspendedExternal := false;
+  FInitialSuspended := CreateSuspended;
+  FFatalException := nil;
+  WRITE_DEBUG('creating thread, self = ',longint(self));
+  FHandle:= BeginThread(@ThreadFunc, Pointer(Self), FThreadID);
+  WRITE_DEBUG('TThread.Create done');
+end;
+
+
+destructor TThread.Destroy;
+begin
+  if FThreadID = GetCurrentThreadID then begin
+    raise EThreadDestroyCalled.Create('A thread cannot destroy itself except by setting FreeOnTerminate and leaving!');
+  end;
+  // if someone calls .Free on a thread with
+  // FreeOnTerminate, then don't crash!
+  FFreeOnTerminate := false;
+  if not FFinished and not FSuspended then begin
+    Terminate;
+    WaitFor;
+  end;
+  if (FInitialSuspended) then begin
+    // thread was created suspended but never woken up.
+    SemaphorePost(FSem);
+    WaitFor;
+  end;
+  FFatalException.Free;
+  FFatalException := nil;
+  SemaphoreDestroy(FSem);
+  inherited Destroy;
+end;
+
+procedure TThread.SetSuspended(Value: Boolean);
+begin
+  if Value <> FSuspended then
+    if Value then
+      Suspend
+    else
+      Resume;
+end;
+
+procedure TThread.Suspend;
+begin
+  if not FSuspended then begin
+    if FThreadID = GetCurrentThreadID then begin
+      FSuspended := true;
+      SemaphoreWait(FSem);
+    end else begin
+      FSuspendedExternal := true;
+{$IFDEF LINUX}
+      // naughty hack if the user doesn't have Linux with NPTL...
+      // in that case, the PID of threads will not be identical
+      // to the other threads, which means that our thread is a normal
+      // process that we can suspend via SIGSTOP...
+      // this violates POSIX, but is the way it works on the
+      // LinuxThreads pthread implementation. Not with NPTL, but in that case
+      // getpid(2) also behaves properly and returns the same PID for
+      // all threads. Thats actually (FINALLY!) native thread support :-)
+      if FPid <> GMainPID then begin
+        FSuspended := true;
+        fpkill(FPid, SIGSTOP);
+      end;
+{$ELSE}
+      SuspendThread(FHandle);
+{$ENDIF}
+    end;
+  end;
+end;
+
+
+procedure TThread.Resume;
+begin
+  if (not FSuspendedExternal) then begin
+    if FSuspended then begin
+      SemaphorePost(FSem);
+      FInitialSuspended := false;
+      FSuspended := False;
+    end;
+  end else begin
+{$IFDEF LINUX}
+    // see .Suspend
+    if FPid <> GMainPID then begin
+      fpkill(FPid, SIGCONT);
+      FSuspended := False;
+    end;
+{$ELSE}
+    ResumeThread(FHandle);
+{$ENDIF}
+    FSuspendedExternal := false;
+  end;
+end;
+
+
+procedure TThread.Terminate;
+begin
+  FTerminated := True;
+end;
+
+function TThread.WaitFor: Integer;
+begin
+  WRITE_DEBUG('waiting for thread ',FHandle);
+  WaitFor := WaitForThreadTerminate(FHandle, 0);
+  WRITE_DEBUG('thread terminated');
+end;
+
+procedure TThread.CallOnTerminate;
+begin
+  // no need to check if FOnTerminate <> nil, because
+  // thats already done in DoTerminate
+  FOnTerminate(self);
+end;
+
+procedure TThread.DoTerminate;
+begin
+  if Assigned(FOnTerminate) then
+    Synchronize(@CallOnTerminate);
+end;
+
+function TThread.GetPriority: TThreadPriority;
+var
+  P: Integer;
+  I: TThreadPriority;
+begin
+  P := ThreadGetPriority(FHandle);
+  Result := tpNormal;
+  for I := Low(TThreadPriority) to High(TThreadPriority) do
+    if Priorities[I] = P then
+      Result := I;
+end;
+
+procedure TThread.Synchronize(Method: TThreadMethod);
+begin
+{$TODO someone with more clue of the GUI stuff will have to do this}
+end;
+
+procedure TThread.SetPriority(Value: TThreadPriority);
+begin
+  ThreadSetPriority(FHandle, Priorities[Value]);
+end;
+{$ENDIF}
+
+{
+  $Log$
+  Revision 1.1  2004-01-04 20:05:38  jonas
+    * first working version of the Darwin/Mac OS X (for PowerPC) RTL
+      Several non-essential units are still missing, but make cycle works
+
+  Revision 1.7  2003/11/22 11:04:08  marco
+   * Johill: suspend fix
+
+  Revision 1.6  2003/11/19 10:12:02  marco
+   * more cleanups
+
+  Revision 1.5  2003/11/17 10:05:51  marco
+   * threads for FreeBSD. Not working tho
+
+  Revision 1.4  2003/11/17 08:27:49  marco
+   * pthreads based ttread from Johannes Berg
+
+  Revision 1.3  2003/11/10 16:54:28  marco
+   * new oldlinux unit. 1_0 defines killed in some former FCL parts.
+
+  Revision 1.2  2003/11/03 09:42:28  marco
+   * Peter's Cardinal<->Longint fixes patch
+
+  Revision 1.1  2003/10/06 21:01:06  peter
+    * moved classes unit to rtl
+
+  Revision 1.9  2003/10/06 17:06:55  florian
+    * applied Johannes Berg's patch for exception handling in threads
+
+  Revision 1.8  2003/09/20 15:10:30  marco
+   * small fixes. fcl now compiles
+
+  Revision 1.7  2002/12/18 20:44:36  peter
+    * use fillchar to clear sigset
+
+  Revision 1.6  2002/09/07 15:15:27  peter
+    * old logs removed and tabs fixed
+
+}

+ 73 - 0
rtl/darwin/unixsysc.inc

@@ -0,0 +1,73 @@
+{
+    $Id$
+    This file is part of the Free Component Library (FCL)
+    Copyright (c) 1999-2000 by Peter Vreman
+
+    Darwin temporary pclose/assignpipe implementation
+
+    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.
+
+ **********************************************************************}
+
+
+
+Function PClose(Var F:file) : cint;
+var
+  pl : ^cint;
+  res : cint;
+
+begin
+  fpclose(filerec(F).Handle);
+{ closed our side, Now wait for the other - this appears to be needed ?? }
+  pl:=@(filerec(f).userdata[2]);
+  fpwaitpid(pl^,@res,0);
+  pclose:=res shr 8;
+end;
+
+Function PClose(Var F:text) :cint;
+var
+  pl  : ^longint;
+  res : longint;
+
+begin
+  fpclose(Textrec(F).Handle);
+{ closed our side, Now wait for the other - this appears to be needed ?? }
+  pl:=@(textrec(f).userdata[2]);
+  fpwaitpid(pl^,@res,0);
+  pclose:=res shr 8;
+end;
+
+
+// can't have oldfpccall here, linux doesn't need it.
+Function AssignPipe(var pipe_in,pipe_out:cint):cint; [public, alias : 'FPC_SYSC_ASSIGNPIPE'];
+{
+  Sets up a pair of file variables, which act as a pipe. The first one can
+  be read from, the second one can be written to.
+  If the operation was unsuccesful, linuxerror is set.
+}
+var
+  ret  : longint;
+  errn : cint;
+  fdis : array[0..1] of cint;
+begin
+ fdis[0]:=pipe_in;
+ fdis[1]:=pipe_out;
+ ret:=pipe(fdis);
+ pipe_in:=fdis[0];
+ pipe_out:=fdis[1];
+ AssignPipe:=ret;
+end;
+
+
+{
+  $Log$
+  Revision 1.1  2004-01-04 20:05:38  jonas
+    * first working version of the Darwin/Mac OS X (for PowerPC) RTL
+      Several non-essential units are still missing, but make cycle works
+
+}