From 071ee9bfd885310e9ef04e3785569a0546c3dde4 Mon Sep 17 00:00:00 2001 From: armin Date: Tue, 19 Mar 2002 19:16:01 +0000 Subject: [PATCH] + Implemented nwpre and prelude in assembler, now working like the original nwpre --- rtl/netware/Makefile | 20 +++++--- rtl/netware/compile.cmd | 29 +++++++---- rtl/netware/nwpre.as | 109 ++++++++++++++++++++++++++++++++++++++++ rtl/netware/prelude.as | 99 ++++++++++++++++++++++++++++++++++++ 4 files changed, 238 insertions(+), 19 deletions(-) create mode 100644 rtl/netware/nwpre.as create mode 100644 rtl/netware/prelude.as diff --git a/rtl/netware/Makefile b/rtl/netware/Makefile index 61e4e6e8a4..291124eb1c 100644 --- a/rtl/netware/Makefile +++ b/rtl/netware/Makefile @@ -4,16 +4,17 @@ UNITDIR = $(INSTALL_PREFIX)/usr/lib/fpc/1.1/units/netware/rtl #PPC386OPT = -n -dMT -dDEBUG_MT -di386 -dSYSTEMDEBUG -O3 -Sg -Tnetware -Aelf -a -al -gg -FE. #PPC386OPT = -n -di386 -dSYSTEMDEBUG -O3 -Sg -Tnetware -Aelf -a -al -gg -FE. -PPC386OPT = -n -di386 -O3 -Sg -Tnetware -Aelf -a -al -FE. +PPC386OPT = -n -di386 -O3 -Og -Sg -Tnetware -Aelf -a -al -FE. PPC386OPTDBG = -n -di386 -O3 -Sg -Tnetware -Aelf -a -al -gg -FE. INCLUDES = -I../inc -I../i386 -I../objpas SYSUNIT=system NWPRE=nwpre +PRELUDE=prelude OBJEXT=on PPUEXT=ppn ASMEXT=s -OBJS = $(SYSUNIT).$(OBJEXT) $(NWPRE).$(OBJEXT) ../inc/os_types.$(OBJEXT) ../inc/strings.$(OBJEXT) dos.$(OBJEXT) ../objpas/objpas.$(OBJEXT) sysutils.$(OBJEXT) crt.$(OBJEXT) sockets.$(OBJEXT) mouse.$(OBJEXT) netware.$(OBJEXT) video.$(OBJEXT) keyboard.$(OBJEXT) ../objpas/math.$(OBJEXT) ../objpas/typinfo.$(OBJEXT) ../inc/objects.$(OBJEXT) ../inc/getopts.$(OBJEXT) ../inc/heaptrc.$(OBJEXT) varutils.$(OBJEXT) ../i386/cpu.$(OBJEXT) ../i386/mmx.$(OBJEXT) winsock2.$(OBJEXT) +OBJS = $(SYSUNIT).$(OBJEXT) $(NWPRE).$(OBJEXT) $(PRELUDE).$(OBJEXT) ../inc/os_types.$(OBJEXT) ../inc/strings.$(OBJEXT) dos.$(OBJEXT) ../objpas/objpas.$(OBJEXT) sysutils.$(OBJEXT) crt.$(OBJEXT) sockets.$(OBJEXT) mouse.$(OBJEXT) netware.$(OBJEXT) video.$(OBJEXT) keyboard.$(OBJEXT) ../objpas/math.$(OBJEXT) ../objpas/typinfo.$(OBJEXT) ../inc/objects.$(OBJEXT) ../inc/getopts.$(OBJEXT) ../inc/heaptrc.$(OBJEXT) varutils.$(OBJEXT) ../i386/cpu.$(OBJEXT) ../i386/mmx.$(OBJEXT) winsock2.$(OBJEXT) all: $(OBJS) @@ -21,22 +22,25 @@ all: $(OBJS) $(SYSUNIT).$(OBJEXT): $(SYSUNIT).pp nwsys.inc ppc386 -Us $(PPC386OPT) $(INCLUDES) $(SYSUNIT).pp -$(NWPRE).$(OBJEXT): $(NWPRE).pp - ppc386 $(PPC386OPTDBG) $(INCLUDES) $(NWPRE).pp +$(NWPRE).$(OBJEXT): $(NWPRE).as + as $(NWPRE).as -o $(NWPRE).$(OBJEXT) + +$(PRELUDE).$(OBJEXT): $(NWPRE).as + as $(PRELUDE).as -o $(PRELUDE).$(OBJEXT) %.$(OBJEXT): %.pp nwsys.inc ppc386 $(PPC386OPT) $(INCLUDES) $*.pp install: $(OBJS) - + rm -f $(UNITDIR)/* cp -f $(SYSUNIT).$(OBJEXT) $(UNITDIR) cp -f $(SYSUNIT).$(PPUEXT) $(UNITDIR) cp -f dos.$(OBJEXT) $(UNITDIR) cp -f dos.$(PPUEXT) $(UNITDIR) cp -f strings.$(OBJEXT) $(UNITDIR) cp -f strings.$(PPUEXT) $(UNITDIR) - cp -f nwpre.$(OBJEXT) $(UNITDIR) - cp -f nwpre.$(PPUEXT) $(UNITDIR) + cp -f $(NWPRE).$(OBJEXT) $(UNITDIR) + cp -f $(PRELUDE).$(OBJEXT) $(UNITDIR) cp -f sysutils.$(OBJEXT) $(UNITDIR) cp -f sysutils.$(PPUEXT) $(UNITDIR) cp -f objpas.$(OBJEXT) $(UNITDIR) @@ -75,7 +79,7 @@ install: $(OBJS) cp -f nwimp/*.imp $(UNITDIR) clean: - rm -f *.$(OBJEXT) *.$(PPUEXT) *.$(ASMEXT) *.bak + rm -f *.$(OBJEXT) *.$(PPUEXT) *.$(ASMEXT) *.bak *.rst *.a dist: clean diff --git a/rtl/netware/compile.cmd b/rtl/netware/compile.cmd index a36c755a7b..45c29d9ef7 100644 --- a/rtl/netware/compile.cmd +++ b/rtl/netware/compile.cmd @@ -5,9 +5,12 @@ REM SET DEST=\compiler\fpc\units\netware REM Compile and install system unit first +SET INC=-I../inc -I../i386 -I../objpas ../inc/strings.pp +SET OPT=-di386 -XX -O3 -Sg -Tnetware + del /Q *.ppn del /Q *.on -ppc386 -di386 -XX -dSYSTEMDEBUG -O3 -Sg -Tnetware -FE. -I../inc -I../i386 -I../objpas ../inc/strings.pp +ppc386 %OPT% -dSYSTEMDEBUG -FE. %INC% copy *.ppn %DEST% copy *.on %DEST% @@ -15,16 +18,20 @@ REM copy the import files copy nwimp\*.imp %DEST% REM and build other stuff -ppc386 -di386 -XX -O3 -Sg -Tnetware -FE. nwpre.pp -ppc386 -di386 -XX -O3 -Sg -Tnetware -FE. -I../inc -I../i386 dos.pp -ppc386 -di386 -XX -O3 -Sg -Tnetware -FE. -I../inc -I../i386 crt.pp -ppc386 -di386 -XX -O3 -Sg -Tnetware -FE. -I../inc -I../i386 -I../objpas ../objpas/objpas.pp -ppc386 -di386 -XX -O3 -Sg -Tnetware -FE. -I../inc -I../i386 -I../objpas sysutils.pp -ppc386 -di386 -XX -O3 -Sg -Tnetware -FE. -I../inc -I../i386 keyboard.pp -ppc386 -di386 -XX -O3 -Sg -Tnetware -FE. -I../inc -I../i386 mouse.pp -ppc386 -di386 -XX -O3 -Sg -Tnetware -FE. -I../inc -I../i386 video.pp -ppc386 -di386 -XX -O3 -Sg -Tnetware -FE. -I../inc -I../i386 sockets.pp -ppc386 -di386 -XX -O3 -Sg -Tnetware -FE. -I../inc -I../i386 netware.pp +#ppc386 -di386 -XX -O3 -Sg -Tnetware -FE. nwpre.pp +asw nwpre.as -o nwpre.on +asw prelude.as -o prelude.on + +ppc386 %OPT% %INC% dos.pp +ppc386 %OPT% %INC% crt.pp +ppc386 %OPT% %INC% ../objpas/objpas.pp +ppc386 %OPT% %INC% sysutils.pp +ppc386 %OPT% %INC% keyboard.pp +ppc386 %OPT% %INC% mouse.pp +ppc386 %OPT% %INC% video.pp +ppc386 %OPT% %INC% sockets.pp +ppc386 %OPT% %INC% netware.pp +ppc386 %OPT% %INC% winsock2.pp copy *.on %DEST% copy *.ppn %DEST% \ No newline at end of file diff --git a/rtl/netware/nwpre.as b/rtl/netware/nwpre.as new file mode 100644 index 0000000000..5cde93e123 --- /dev/null +++ b/rtl/netware/nwpre.as @@ -0,0 +1,109 @@ +# +# $Id$ +# This file is part of the Free Pascal run time library. +# Copyright (c) 1999-2002 by the Free Pascal development team +# Copyright (c) 2002 Armin Diehl +# +# This is the (nwpre-like) startup code for netware +# +# 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. +# +#********************************************************************** + + .file "nwpre.as" + .text + +# +# This is the main program (not loader) Entry-Point that will be called by netware +# it sets up the argc and argv and calls _nlm_main (in system.pp) +# +_pasStart_: + pushl $_nlm_main + call _SetupArgV_411 + addl $4,%esp + ret + + +# +# this will be called by the loader, we pass the address of _pasStart_ and +# _kNLMInfo (needed by clib) and netware is doing the work +# + .globl _Prelude +_Prelude: + pushl %ebp + movl %esp,%ebp + pushl %edi + pushl %esi + pushl %ebx + movl 0x14(%ebp),%edi + movl 0x18(%ebp),%esi + movl 0x1c(%ebp),%ebx + movl 0x20(%ebp),%ecx + movl 0x28(%ebp),%eax + pushl $_pasStart_ + pushl $_kNLMInfo + pushl %eax + movl 0x24(%ebp),%edx + pushl %edx + pushl %ecx + pushl %ebx + pushl %esi + pushl %edi + movl 0x10(%ebp),%edx + pushl %edx + movl 0xc(%ebp),%edx + pushl %edx + movl 0x8(%ebp),%edx + pushl %edx + call _StartNLM + test %eax,%eax + jne x1 + xorl %eax,%eax # dont know why this is needed ? +x1: + lea 0xfffffff4(%ebp),%esp + popl %ebx + popl %esi + popl %edi + movl %ebp,%esp + popl %ebp + ret + + +# +# the global stop-function +# + .globl _Stop +_Stop: + pushl $0x5 # TERMINATE_BY_UNLOAD=0, TERMINATE_BY_EXTERNAL_THREAD=0 + pushl $0x0 + movl _kNLMInfo,%edx + pushl %edx + call _TerminateNLM + addl $0x0c,%esp + ret + + +.data +# argc is defined in the novell nwpre, i assume it is not needed +#_argc: +# .long 0 + +# structure needed by clib +# kNLMInfoT = +# PACKED RECORD +# Signature : ARRAY [0..3] OF CHAR; // LONG 'NLMI' +# Flavor : LONGINT; // TRADINIONAL_FLAVOR = 0 +# Version : LONGINT; // TRADINIONAL_VERSION = 0, LIBERTY_VERSION = 1 +# LongDoubleSize : LONGINT; // gcc nwpre defines 12, watcom 8 +# wchar_tSize : LONGINT; +# END; + +_kNLMInfo: + .ascii "NLMI" + .long 0,1,8,2 + diff --git a/rtl/netware/prelude.as b/rtl/netware/prelude.as new file mode 100644 index 0000000000..0223edbb1a --- /dev/null +++ b/rtl/netware/prelude.as @@ -0,0 +1,99 @@ +# +# $Id$ +# This file is part of the Free Pascal run time library. +# Copyright (c) 1999-2002 by the Free Pascal development team +# Copyright (c) 2002 Armin Diehl +# +# This is the (prelude-like) startup code for netware before 4.11 +# +# 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. +# +#********************************************************************** + + .file "nwpre.as" + .text + +# +# This is the main program (not loader) Entry-Point that will be called by netware +# it sets up the argc and argv and calls _nlm_main (in system.pp) +# This version uses the old _SetupArgv and not the newer _SetupArvV_411 +# +_pasStart_: + pushl $_nlm_main + call _SetupArgv + addl $4,%esp + ret + + +# +# this will be called by the loader, we pass the address of _pasStart_ and +# _NLMID (needed by clib) and netware is doing the work +# + .globl _Prelude +_Prelude: + pushl %ebp + movl %esp,%ebp + pushl %edi + pushl %esi + pushl %ebx + movl 0x14(%ebp),%edi + movl 0x18(%ebp),%esi + movl 0x1c(%ebp),%ebx + movl 0x20(%ebp),%ecx + movl 0x28(%ebp),%eax + pushl $_pasStart_ + pushl $_NLMID + pushl %eax + movl 0x24(%ebp),%edx + pushl %edx + pushl %ecx + pushl %ebx + pushl %esi + pushl %edi + movl 0x10(%ebp),%edx + pushl %edx + movl 0xc(%ebp),%edx + pushl %edx + movl 0x8(%ebp),%edx + pushl %edx + call _StartNLM + test %eax,%eax + jne x1 + xorl %eax,%eax # dont know why this is needed ? +x1: + lea 0xfffffff4(%ebp),%esp + popl %ebx + popl %esi + popl %edi + movl %ebp,%esp + popl %ebp + ret + + +# +# the global stop-function +# + .globl _Stop +_Stop: + pushl $0x5 # TERMINATE_BY_UNLOAD=0, TERMINATE_BY_EXTERNAL_THREAD=0 + pushl $0x0 + movl _NLMID,%edx + pushl %edx + call _TerminateNLM + addl $0x0c,%esp + ret + + +.data +# argc is defined in the novell prelude, i assume it is not needed +#_argc: +# .long 0 + +_NLMID: + .long 0 +