diff --git a/!BDDebug,fd7 b/!BDDebug,fd7
new file mode 100644
index 0000000000000000000000000000000000000000..fec0ee9bfae8ecd12f7c898caae190e7f1723e74
--- /dev/null
+++ b/!BDDebug,fd7
@@ -0,0 +1,17 @@
+| Copyright 1998 Acorn Computers Ltd
+|
+| Licensed under the Apache License, Version 2.0 (the "License");
+| you may not use this file except in compliance with the License.
+| You may obtain a copy of the License at
+|
+|     http://www.apache.org/licenses/LICENSE-2.0
+|
+| Unless required by applicable law or agreed to in writing, software
+| distributed under the License is distributed on an "AS IS" BASIS,
+| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+| See the License for the specific language governing permissions and
+| limitations under the License.
+|
+Dir <Obey$Dir>
+wimpslot 2048k
+amu_machine debug THROWBACK=-throwback CBLOCKDRIVERS=-DBLOCKDRIVERS ASMBLOCKDRIVERS={TRUE}
diff --git a/!BDRam,fd7 b/!BDRam,fd7
new file mode 100644
index 0000000000000000000000000000000000000000..15c3e08f4fdd69a99c6ab10ef7ee2a63b0a4b5b8
--- /dev/null
+++ b/!BDRam,fd7
@@ -0,0 +1,17 @@
+| Copyright 1998 Acorn Computers Ltd
+|
+| Licensed under the Apache License, Version 2.0 (the "License");
+| you may not use this file except in compliance with the License.
+| You may obtain a copy of the License at
+|
+|     http://www.apache.org/licenses/LICENSE-2.0
+|
+| Unless required by applicable law or agreed to in writing, software
+| distributed under the License is distributed on an "AS IS" BASIS,
+| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+| See the License for the specific language governing permissions and
+| limitations under the License.
+|
+Dir <Obey$Dir>
+wimpslot 2048k
+amu_machine ram THROWBACK=-throwback CBLOCKDRIVERS=-DBLOCKDRIVERS ASMBLOCKDRIVERS={TRUE}
diff --git a/!BDRom,fd7 b/!BDRom,fd7
new file mode 100644
index 0000000000000000000000000000000000000000..7477899865f46709d70c07e896c76866e2e1cb06
--- /dev/null
+++ b/!BDRom,fd7
@@ -0,0 +1,18 @@
+| Copyright 1998 Acorn Computers Ltd
+|
+| Licensed under the Apache License, Version 2.0 (the "License");
+| you may not use this file except in compliance with the License.
+| You may obtain a copy of the License at
+|
+|     http://www.apache.org/licenses/LICENSE-2.0
+|
+| Unless required by applicable law or agreed to in writing, software
+| distributed under the License is distributed on an "AS IS" BASIS,
+| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+| See the License for the specific language governing permissions and
+| limitations under the License.
+|
+Dir <Obey$Dir>
+wimpslot 2048k
+amu_machine rom THROWBACK=-throwback CBLOCKDRIVERS=-DBLOCKDRIVERS ASMBLOCKDRIVERS={TRUE}
+
diff --git a/!DSDebug,fd7 b/!DSDebug,fd7
new file mode 100644
index 0000000000000000000000000000000000000000..8f4ab9d18e3ab507ac67a5975d3e8da6385553fd
--- /dev/null
+++ b/!DSDebug,fd7
@@ -0,0 +1,17 @@
+| Copyright 1998 Acorn Computers Ltd
+|
+| Licensed under the Apache License, Version 2.0 (the "License");
+| you may not use this file except in compliance with the License.
+| You may obtain a copy of the License at
+|
+|     http://www.apache.org/licenses/LICENSE-2.0
+|
+| Unless required by applicable law or agreed to in writing, software
+| distributed under the License is distributed on an "AS IS" BASIS,
+| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+| See the License for the specific language governing permissions and
+| limitations under the License.
+|
+Dir <Obey$Dir>
+wimpslot 2048k
+amu_machine debug THROWBACK=-throwback ASMBLOCKDRIVERS={FALSE}
diff --git a/!DSMcCabe,fd7 b/!DSMcCabe,fd7
new file mode 100644
index 0000000000000000000000000000000000000000..45400fc54ffc4465897132b87baecf1f106869dd
--- /dev/null
+++ b/!DSMcCabe,fd7
@@ -0,0 +1,17 @@
+| Copyright 1998 Acorn Computers Ltd
+|
+| Licensed under the Apache License, Version 2.0 (the "License");
+| you may not use this file except in compliance with the License.
+| You may obtain a copy of the License at
+|
+|     http://www.apache.org/licenses/LICENSE-2.0
+|
+| Unless required by applicable law or agreed to in writing, software
+| distributed under the License is distributed on an "AS IS" BASIS,
+| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+| See the License for the specific language governing permissions and
+| limitations under the License.
+|
+Dir <Obey$Dir>
+wimpslot 8192k
+amu_machine analyse THROWBACK=-throwback ASMBLOCKDRIVERS={FALSE}
diff --git a/!MkRam,fd7 b/!DSRam,fd7
similarity index 83%
rename from !MkRam,fd7
rename to !DSRam,fd7
index df9e9ae481853d1e24870fb8482dfe5fc205833b..965899db8f4b75d5f09fc024e1efaece1f858a6c 100644
--- a/!MkRam,fd7
+++ b/!DSRam,fd7
@@ -1,4 +1,4 @@
-| Copyright 1996 Acorn Computers Ltd
+| Copyright 1998 Acorn Computers Ltd
 |
 | Licensed under the Apache License, Version 2.0 (the "License");
 | you may not use this file except in compliance with the License.
@@ -13,5 +13,5 @@
 | limitations under the License.
 |
 Dir <Obey$Dir>
-wimpslot 4000k
-amu_machine all
+wimpslot 2048k
+amu_machine ram THROWBACK=-throwback ASMBLOCKDRIVERS={FALSE}
diff --git a/!MkRom,fd7 b/!DSRom,fd7
similarity index 83%
rename from !MkRom,fd7
rename to !DSRom,fd7
index 1844fa80f101f9e9015076d90d0bcda0dbbdccca..de5b37a693ad0acf16953235c6bcbfca093485b5 100644
--- a/!MkRom,fd7
+++ b/!DSRom,fd7
@@ -1,4 +1,4 @@
-| Copyright 1996 Acorn Computers Ltd
+| Copyright 1998 Acorn Computers Ltd
 |
 | Licensed under the Apache License, Version 2.0 (the "License");
 | you may not use this file except in compliance with the License.
@@ -13,5 +13,6 @@
 | limitations under the License.
 |
 Dir <Obey$Dir>
-wimpslot 5000k
-amu_machine rom
+wimpslot 2048k
+amu_machine rom THROWBACK=-throwback ASMBLOCKDRIVERS={FALSE}
+
diff --git a/Makefile b/Makefile
index d22dca126a86e5ee0d73abd234ec146b2de3b2f9..5bd928f4c66b92973d94acc1c0f8850da409ba39 100644
--- a/Makefile
+++ b/Makefile
@@ -17,102 +17,149 @@
 # ***********************************
 # ***    C h a n g e   L i s t    ***
 # ***********************************
-# Date       Name         Description
-# ----       ----         -----------
-# 16-Jul-96  SMC          Created
+# Date		Name	Description
+# ----		----	-----------
+# 1998-01-19	BAL	Created
+#
+
 #
 # Paths
 #
-EXP_HDR = <export$dir>
+EXP_HDR	=	<export$dir>
 
 #
 # Generic options:
 #
-MKDIR   = cdir
-AS      = objasm -tb
-CC      = cc
-CMHG    = cmhg
-CP      = copy
-LD      = link
-RM      = remove
-MODSQZ  = modsqz
-WIPE    = -wipe
-CD	= dir
+MKDIR =		cdir
+AS =		objasm
+CC =		cc
+CMHG =		cmhg
+CP =		copy
+LD =		<boot$dir>.library.link
+RM =		remove
+MODSQZ =	modsqz
+WIPE =		-wipe
+
+ASMFLAGS =	-depend !Depend ${THROWBACK} -predefine "BlockDrivers SETL ${ASMBLOCKDRIVERS}"
+CFLAGS =	-depend !Depend ${THROWBACK} ${INCLUDES} ${CBLOCKDRIVERS} -strict -wP -ffah 
+CMHGFLAGS =	-depend !Depend ${THROWBACK} ${INCLUDES} ${CBLOCKDRIVERS} -p
+CPFLAGS =	~cfr~v
+WFLAGS =	~c~v
 
-CPFLAGS = ~cfr~v
-WFLAGS = ~c~v
+DFLAGS_COMMON = -DINET -DCOMPAT_INET4 -DVJC
+DFLAGS =	${DFLAGS_COMMON} -DNDEBUG
+DDFLAGS =       ${DFLAGS_COMMON} -DDEBUG -DDEBUG_TML -DTrace_TRACE
 
 #
-# Include files
+# Libraries
 #
-INCLUDES=	TCPIPLibs:,C:
+CLIB =		CLIB:o.stubs
+RLIB =		RISCOSLIB:o.risc_oslib
+RSTUBS =	RISCOSLIB:o.rstubs
+ROMSTUBS =	RISCOSLIB:o.romstubs
+ROMCSTUBS =	RISCOSLIB:o.romcstubs
+ABSSYM  =	RISC_OSLib:o.c_AbsSym
 
 INETLIB   = TCPIPLibs:o.inetlibzm
 SOCKLIB   = TCPIPLibs:o.socklibzm
 UNIXLIB   = TCPIPLibs:o.unixlibzm
 
-#
-# Program specific options:
-#
-COMPONENT = PPP
-TARGET = rm.PPP
-ROMTARGET = aof.PPP
+LIBS =\
+ ${INETLIB}\
+ ${SOCKLIB}\
+ ${UNIXLIB}
+		
 
-# To compile a version of PPP which uses the blockdrivers uncomment the next
-# line, ensure that o.blockdrive is in the list of object files and change
-# ASMFLAGS so that the symbol BlockDrivers is predefined to {TRUE}
-# 
-# The Makefile in pppd must also be changed
+LIBSD =\
+ ${INETLIB}\
+ ${SOCKLIB}\
+ ${UNIXLIB}\
+ <Lib$Dir>.svcprint.o.svcprint\
+ <Lib$Dir>.Trace.o.T_M_PL
 
-BLOCKDRIVERS=	#-DBLOCKDRIVERS
 
+#
+# Include files
+#
+INCLUDES =	-ITCPIPLibs:,C:
+
+#
+# Program specific options:
+#
+COMPONENT =	PPP
+RAMTARGET =	rm.PPP
+ROMTARGET =	aof.PPP
+DEBUGTARGET =	rm.PPPD
+EXPORTS =	${EXP_DIR}.PPP
 
-# You may want to link with TinyStubs. if you do, set LD to tlink and
-# uncomment this TINYSTUBS, and comment out the STUBS
 
-TINYSTUBS=	#-DTINYSTUBS
-STUBS=		C:o.Stubs
+#
+# Export Paths for Messages module
+#
+#RESDIR = 	<resource$dir>.Resources2.PPP
 
-ROMCSTUBS=      RISC_OSLib:o.romcstubs
-ABSSYM=         RISC_OSLib:o.AbsSym
 
-DEBUG=		#-DDEBUG
+OBJS =\
+ o.blockdrive\
+ o.if_ppp\
+ o.mbuf\
+ o.ppp_io\
+ o.ppphdr\
+ o.pppmodule\
+ o.serial\
+ o.slcompress\
 
-COMPAT=		-DCOMPAT_INET4
 
-CFLAGS=		-ffah -zM -I${INCLUDES} -DINET -DCOMPAT_INET4 ${DEBUG}\
-		-zps1 -Wp -depend !Depend -c -throwback -DVJC ${TINYSTUBS}\
-		${BLOCKDRIVERS}
+OBJSD =\
+ od.blockdrive\
+ od.if_ppp\
+ od.mbuf\
+ od.ppp_io\
+ od.ppphdr\
+ od.pppmodule\
+ od.serial\
+ od.slcompress\
 
-CMHGFLAGS=	-p -I${INCLUDES} ${BLOCKDRIVERS} -depend !Depend
 
-ASMFLAGS=       -PreDefine "BlockDrivers SETL {FALSE}"
+OBJSCP =\
+ cp.if_ppp\
+ cp.mbuf\
+ o.ppphdr\
+ cp.pppmodule\
+ cp.serial\
+ cp.slcompress\
 
-OBJS=		o.if_ppp o.slcompress o.pppmodule \
-		o.serial o.mbuf o.ppphdr o.ppp_io o.blockdrive \
-		${SOCKLIB} ${INETLIB} ${UNIXLIB} \
-		#o.svcprint
 
-HDRS = 		h.PPPHdr
+HDRS =	h.ppphdr
 
 #
 # Rule patterns
 #
-.SUFFIXES:	.o .h .s .c .cmhg
-.c.o:;		$(CC) $(CFLAGS) -o $@ $<
-.s.o:;		$(AS) ${ASMFLAGS} -o $@ $<
-.cmhg.o:;	${CMHG} ${CMHGFLAGS} $< -o $@
-.cmhg.h:;	${CMHG} ${CMHGFLAGS} $< -d $@
-
-all: ${TARGET}
-	@echo ${COMPONENT}: all complete
+.SUFFIXES:	.o .od .cp .h .s .c .cmhg
+.c.o:;		${CC} ${CFLAGS} ${DFLAGS}       -c -zM -zps1 -o $@ $<
+.c.od:;		${CC} ${CFLAGS} ${DDFLAGS}      -c -zM -zps1 -fn -o $@ $<
+.c.cp:;		${CC} ${CFLAGS} ${DFLAGS}       -c -C -E $< >> $@
+.s.o:;		${AS} ${ASMFLAGS}               -o $@ $<
+.s.od:;		${AS} ${ASMFLAGS}               -o $@ $<
+.cmhg.o:;	${CMHG} ${CMHGFLAGS} ${DFLAGS}  -o $@ $<
+.cmhg.od:;	${CMHG} ${CMHGFLAGS} ${DDFLAGS} -o $@ $<
+.cmhg.h:;	${CMHG} ${CMHGFLAGS} ${DFLAGS}  -d $@ $<
 
 #
-# RISC OS ROM build rules:
+# Main rules:
 #
+ram: ${RAMTARGET}
+	@echo ${COMPONENT}: all complete
+
 rom: ${ROMTARGET}
 	@echo ${COMPONENT}: rom module built
 
+debug: ${DEBUGTARGET}
+	@echo ${COMPONENT}: debug build complete
+
+analyse: pppd ${OBJSCP} ${HDRS}
+	@echo ${COMPONENT}: analysis build complete
+
 export:
 	@echo ${COMPONENT}: export complete
 
@@ -120,25 +167,45 @@ install_rom: ${ROMTARGET}
 	${CP} ${ROMTARGET} ${INSTDIR}.${COMPONENT} ${CPFLAGS}
 	@echo ${COMPONENT}: rom module installed
 
-clean:
-		$(RM)	$(HDRS)
-		$(WIPE) o.*      $(WFLAGS)
-		$(WIPE) pppd.o.* $(WFLAGS)
-	        $(WIPE) rm.*     $(WFLAGS)
-		$(RM) link/sym
+resources:
+	@echo ${COMPONENT}: resource files copied
+
+clean:	pppd
+	${RM} ${HDRS}
+	${WIPE} o.* ${WFLAGS}
+	${WIPE} od.* ${WFLAGS}
+	${WIPE} cp.* ${WFLAGS}
+	${WIPE} rm.* ${WFLAGS}
+	${WIPE} linked ${WFLAGS}
+	${WIPE} map ${WFLAGS}
+	${RM} ${RAMTARGET}
+	${RM} ${ROMTARGET}
+	${RM} ${DEBUGTARGET}
+	@echo ${COMPONENT}: cleaned
+
+pppd:
+	Dir pppd
+	amu ${MFLAGS}
+	Up
 
 #
 # Target 
 #
-${TARGET}:	pppd $(OBJS) $(HDRS)
-		$(LD) -rmf -s link/sym -o rm.PPPu $(OBJS) $(STUBS) pppd.o.pppd
-		ModSqz rm.PPPu $@
+${RAMTARGET}: pppd ${OBJS} ${HDRS} ${CLIB}
+	${LD} -rmf -o $@ pppd.o.pppd ${OBJS} ${LIBS} ${CLIB}
+	${MODSQZ} $@
 
 #
-# ROM Target 
+# ROM Target (re-linked at ROM Image build time)
 #
-${ROMTARGET}: pppd ${OBJS} $(HDRS)
-	${LD} -s link/sym -o $@ -aof ${OBJS} ${ROMCSTUBS} pppd.o.pppd
+${ROMTARGET}: pppd ${OBJS} ${HDRS} ${ROMCSTUBS}
+	${LD} -o $@ -aof pppd.o.pppd ${OBJS} ${LIBS} ${ROMCSTUBS}
+
+#
+# Debug target
+#
+${DEBUGTARGET}: pppd ${OBJSD} ${HDRS} ${CLIB}
+	${LD} -rmf -o $@ pppd.od.pppd ${OBJSD} ${LIBSD} ${CLIB}
 
 #
 # Final link for the ROM Image (using given base address)
@@ -151,14 +218,5 @@ rom_link:
 	${CP} linked.${COMPONENT} ${LINKDIR}.${COMPONENT} ${CPFLAGS}
 	@echo ${COMPONENT}: rom_link complete
 
-#
-# Some rules that need explicitly declaring
-#
-pppd:
-	Dir pppd
-	Amu
-	Up
 
-s.blockdrive::	Internal.Driver
-	
 # Dynamic dependencies:
diff --git a/c/if_ppp b/c/if_ppp
index 8e621dd06ea4b6dbd60796ce556746734191606f..63a911e807f9c1c07d61a01eb98a360fb2845699 100644
--- a/c/if_ppp
+++ b/c/if_ppp
@@ -69,11 +69,16 @@
  * Paul Mackerras (paulus@cs.anu.edu.au).
  */
 
+/* 1998-03-09: BAL
+ * Removed support for using the Dialler for idle-timeout.  This was completely
+ * pointless as PPP's built-in idle timer works fine.
+ */
+
 /* from if_sl.c,v 1.11 84/10/04 12:54:47 rick Exp */
 
 
-char *ack_if_ppp="Copyright (c) 1989 Carnegie Mellon University. "
-                 "All rights reserved.";
+static char *ack_if_ppp="Copyright (c) 1989 Carnegie Mellon University. "
+                        "All rights reserved.";
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -537,12 +542,26 @@ int pppoutput(struct dib *ifp, struct mbuf *m0, const struct sockaddr *dst)
         {
             unsigned int status;
 
-            _swix (Dialler_Status, _OUT (0), &status);
+            if (dialler_flags & DiallerFlags_DiallerB)
+            {
+                _swix (DiallerB_Status, _OUT (0), &status);
+            }
+            else
+            {
+                _swix (Dialler_Status, _OUT (0), &status);
+            }
 
             if ((status & (Dialler_ExecutingScript_Dial | Dialler_Connected)) == 0)
             {
                 /* Dial up using previous settings */
-                _swix (Dialler_Dial, _INR (0, 4), 0, 0, 0, 0, 0);
+                if (dialler_flags & DiallerFlags_DiallerB)
+                {
+                    _swix (DiallerB_Dial, _INR (0, 4), 0, 0, 0, 0, 0);
+                }
+                else
+                {
+                    _swix (Dialler_Dial, _INR (0, 4), 0, 0, 0, 0, 0);
+                }
             }
             error = ENETUNREACH;
         }
@@ -585,13 +604,6 @@ int pppoutput(struct dib *ifp, struct mbuf *m0, const struct sockaddr *dst)
                 ifq = &sc->sc_fastq;
 	}
 
-        /* If the packet is TCP or UDP then prod the dialler to keep the line alive */
-        if ((dialler_flags & DiallerFlags_UsingDialler) &&
-            (ip->ip_p == IPPROTO_TCP || ip->ip_p == IPPROTO_UDP))
-        {
-            _swix (Dialler_ResetCounter, 0);
-        }
-
 	break;
 #endif
       case AF_UNSPEC:
diff --git a/c/pppmodule b/c/pppmodule
index 2d62c781aa74b686db0fec3ec9337fe6845844fa..dcabee9594d0673961354366dab39707b64f0f85 100644
--- a/c/pppmodule
+++ b/c/pppmodule
@@ -16,6 +16,12 @@
  *
  * Copyright (c) 1995 Acorn Computers Ltd., Cambridge, England
  *
+ * 1998-03-09: BAL
+ * Added support for using DiallerB as well as Dialler for serial stream
+ * handle arbitration.
+ *
+ * Removed support for using Dialler to check for line drops as PPP's
+ * built in routines are perfectly good enough.
  */
 #include <ctype.h>
 #include <stdio.h>
@@ -708,7 +714,6 @@ static int ppp_stats(_kernel_swi_regs *r)
 static _kernel_oserror *ppp_alter_settings (_kernel_swi_regs *r)
 {
     unsigned int reason_code = (unsigned int) r->r[0];
-    int unit = r->r[1];
 
 
     switch (reason_code)
@@ -754,7 +759,6 @@ static _kernel_oserror *ppp_status (_kernel_swi_regs *r)
 {
     unsigned int reason_code = (unsigned int) r->r[0];
     int interrupt_status;
-    int unit = r->r[1];
 
 
     switch (reason_code)
@@ -771,20 +775,7 @@ static _kernel_oserror *ppp_status (_kernel_swi_regs *r)
         case PPP_Status_Connection:
             if (modem)
             {
-              #ifdef BLOCKDRIVERS
-                r->r[2] = (driver_modemcontrol() & 8) ? 1 : 0;
-              #else
-                ioctl_t ioctl;
-
-                ioctl.group = 0;
-                ioctl.reason = IOCtl_control_lines;
-                ioctl.reserved = 0;
-                ioctl.read = 1;
-                ioctl.write = 0;
-
-                _swix (OS_Args, _INR (0, 2), OS_Args_IOCtl, serial_in, &ioctl);
-                r->r[2] = (ioctl.data & IOCtl_control_line_DCD) ? 1 : 0;
-              #endif
+                r->r[2] = serial_dcd ();
             }
 
             /* atomic read of ppp phase */
@@ -850,6 +841,7 @@ static void trace_enter (const char *fn)
 {
     int i;
 
+    Debug_Routine ("PPP");
     for (i = 0; i < trace_depth; i++)
         Debug_Routine (" |");
 
@@ -946,20 +938,16 @@ _kernel_oserror *ppp_initialise(const char *cmd_tail, int pbase, void *pw)
     }
 
   #ifdef Trace_TRACE
-    pdebug ((LOG_DEBUG, "Initialising trace library"));
     Trace_SetVerboseLevel (5);
-/*
     Trace_IgnoreFunctions (
         "Printf syslog pppd* PDebug* trace* hup* upcall_handler pppinput pppioctl "
-        "putblock ppp_dequeue");
-*/
+        "putblock ppp_dequeue message_* pr_log");
+#if 0
     Trace_IgnoreFunctions (
         "Printf syslog PDebug* trace* pppinput putblock");
-    pdebug ((LOG_DEBUG, "Set functions to ignore"));
+#endif
     Trace_SetHandlers (trace_enter, trace_exit);
-    pdebug ((LOG_DEBUG, "Set trace handlers"));
     Trace_InterceptAllFunctions ();
-    pdebug ((LOG_DEBUG, "Intercepted functions"));
   #endif
 
   #if 0
@@ -1076,18 +1064,19 @@ static void handle_managerstatus(_kernel_swi_regs *r)
 /* Module Service Call handler */
 void ppp_sc_handler(int sn, _kernel_swi_regs *r, void *pw)
 {
-    if (sn == Service_DiallerStatus)
-    {
-        /* syslog (LOG_INFO, "Service_DiallerStatus: %x", r->r[0]); */
+    NOT_USED (pw);
 
-        if ((r->r[0] & (Dialler_LineDropped | Dialler_RelinquishAccess)))
+    if ((dialler_flags & DiallerFlags_UsingDialler) &&
+        (sn == Service_DiallerStatus || sn == Service_DiallerBStatus))
+    {
+        if ( ( (dialler_flags & DiallerFlags_DiallerB) &&
+                   sn == Service_DiallerBStatus) ||
+             ( (dialler_flags & DiallerFlags_DiallerB) == 0 &&
+                   sn == Service_DiallerStatus))
         {
-            if ((r->r[0] & Dialler_DiallerDroppedLine) == Dialler_DiallerDroppedLine)
-            {
-                pppd_signal_handler (SIGTERM);
-            }
+/*         syslog (LOG_INFO, "Service_DiallerStatus: %x", r->r[0]); */
 
-            else
+            if (r->r[0] & Dialler_RelinquishAccess)
             {
                 pppd_signal_handler (SIGHUP);
             }
diff --git a/c/serial b/c/serial
index a8a99198449443d27b2d8017be6fd1095c47f73c..63203a98086719b99707aa89eae8d32b5dc049ec 100644
--- a/c/serial
+++ b/c/serial
@@ -16,6 +16,10 @@
  *
  * Copyright (c) 1995 Acorn Computers Ltd., Cambridge, England
  *
+ * 1998-03-09: BAL
+ * Idle timer was mistakenly being incremented twice in hangup check handler.
+ * Removed reliance on Dialler for hangup check if dialler option is used on
+ * command line.
  */
 #include <stdlib.h>
 #include <stdio.h>
@@ -102,10 +106,7 @@ extern void *module_wsp;
  */
 static void release_ticker(void)
 {
-    if ((dialler_flags & DiallerFlags_UsingDialler) == 0)
-    {
-        _swix(OS_RemoveTickerEvent, _INR(0,1), hupcheck_entry, module_wsp);
-    }
+    _swix(OS_RemoveTickerEvent, _INR(0,1), hupcheck_entry, module_wsp);
     _swix(OS_Release, _INR(0,2), TickerV, ticker_handler, module_wsp);
 }
 
@@ -113,10 +114,7 @@ static void release_ticker(void)
 
 static void release_upcall (void)
 {
-    if ((dialler_flags & DiallerFlags_UsingDialler) == 0)
-    {
-        _swix(OS_RemoveTickerEvent, _INR(0,1), hupcheck_entry, module_wsp);
-    }
+    _swix(OS_RemoveTickerEvent, _INR(0,1), hupcheck_entry, module_wsp);
     _swix(OS_Release, _INR (0, 2), UpCallV, upcall_entry, module_wsp);
 }
 
@@ -134,11 +132,10 @@ static _kernel_oserror *claim_ticker(void)
 {
     _kernel_oserror *e = NULL;
 
-    if ((dialler_flags & DiallerFlags_UsingDialler) == 0)
+    e=_swix(OS_CallEvery, _INR(0,2), 99, hupcheck_entry, module_wsp);
+    if (e)
     {
-        e=_swix(OS_CallEvery, _INR(0,2), 99, hupcheck_entry, module_wsp);
-        if (e)
-            return e;
+        return e;
     }
 
     return _swix(OS_Claim, _INR(0,2), TickerV, ticker_handler, module_wsp);
@@ -152,13 +149,10 @@ static _kernel_oserror *claim_upcall (void)
     _kernel_oserror *e = NULL;
 
 
-    if ((dialler_flags & DiallerFlags_UsingDialler) == 0)
+    e = _swix(OS_CallEvery, _INR(0,2), 99, hupcheck_entry, module_wsp);
+    if (e)
     {
-        e = _swix(OS_CallEvery, _INR(0,2), 99, hupcheck_entry, module_wsp);
-        if (e)
-        {
-            return e;
-        }
+        return e;
     }
 
     e = _swix (OS_Claim, _INR (0, 2), UpCallV, upcall_entry, module_wsp);
@@ -181,35 +175,42 @@ static _kernel_oserror *claim_upcall (void)
 
 /**********************************************************************/
 
-#ifdef BLOCKDRIVERS
-
 _kernel_oserror *hupcheck_handler(_kernel_swi_regs *r, void *pw)
 {
     NOT_USED (r);
     NOT_USED (pw);
 
-    if (modem && (driver_modemcontrol() & 8) == 0)
+    /* Check DCD line */
+    if (modem && serial_dcd == 0)
+    {
+        /* DCD has been dropped */
         _swix(OS_AddCallBack, _INR(0,1), hup_entry, module_wsp);
-
+    }
     else
     {
         int interrupt_status;
 
 
-        /* atomic update of counter */
+        /* atomic update and test of counter */
         interrupt_status = splhi ();
         idle_time++;
 
-        if (idle_time_limit && ++idle_time >= idle_time_limit)
+        if (idle_time_limit > 0 && idle_time >= idle_time_limit)
         {
             int not_claimed;
 
             restore_irqs (interrupt_status);
+
+            /* Issue Servive Call to indicate PPP is about to timeout.  If this
+             * Service Call is claimed then do not timeout.
+             */
             _swix (OS_ServiceCall, _IN (1) | _OUT (1),
                    Service_PPPTimingOut, &not_claimed);
+
             if (not_claimed)
+            {
                 _swix (OS_AddCallBack, _INR (0,1), term_entry, module_wsp);
-
+            }
             else
             {
                 /* another atomic counter update */
@@ -218,73 +219,15 @@ _kernel_oserror *hupcheck_handler(_kernel_swi_regs *r, void *pw)
                 restore_irqs (interrupt_status);
             }
         }
-
         else
-            restore_irqs (interrupt_status);
-    }
-
-    return NULL;
-}
-
-#else
-
-_kernel_oserror *hupcheck_handler(_kernel_swi_regs *r, void *pw)
-{
-    ioctl_t ioctl;
-
-
-    NOT_USED (r);
-    NOT_USED (pw);
-
-
-    ioctl.reason = IOCtl_control_lines;
-    ioctl.group = 0;
-    ioctl.reserved = 0;
-    ioctl.read = 1;
-    ioctl.write = 0;
-
-    _swix (OS_Args, _INR (0, 2), OS_Args_IOCtl, serial_in, &ioctl);
-
-    if (modem && (ioctl.data & IOCtl_control_line_DCD) == 0)
-        _swix(OS_AddCallBack, _INR (0, 1), hup_entry, module_wsp);
-
-    else
-    {
-        int interrupt_status;
-
-
-        /* atomic update of counter */
-        interrupt_status = splhi ();
-        idle_time++;
-
-        if (idle_time_limit && ++idle_time >= idle_time_limit)
         {
-            int not_claimed;
-
             restore_irqs (interrupt_status);
-            _swix (OS_ServiceCall, _IN (1) | _OUT (1),
-                   Service_PPPTimingOut, &not_claimed);
-            if (not_claimed)
-                _swix (OS_AddCallBack, _INR (0,1), term_entry, module_wsp);
-
-            else
-            {
-                /* another atomic counter update */
-                interrupt_status = splhi ();
-                idle_time = 0;
-                restore_irqs (interrupt_status);
-            }
         }
-
-        else
-            restore_irqs (interrupt_status);
     }
 
     return NULL;
 }
 
-#endif
-
 /**********************************************************************/
 
 _kernel_oserror *hup_handler(_kernel_swi_regs *r, void *pw)
@@ -625,9 +568,22 @@ _kernel_oserror *serial_finalise(void)
     }
 #endif
 
-    if ((dialler_flags & DiallerFlags_UsingDialler))
+    if (dialler_flags & DiallerFlags_UsingDialler)
     {
-        _swix (Dialler_Arbitrate, _IN (0), Dialler_Arbitrate_RelinquishAccess);
+        if (dialler_flags & DiallerFlags_DiallerB)
+        {
+            _swix (DiallerB_Arbitrate,
+                   _IN (0),
+
+                   Dialler_Arbitrate_RelinquishAccess);
+        }
+        else
+        {
+            _swix (Dialler_Arbitrate,
+                   _IN (0),
+
+                   Dialler_Arbitrate_RelinquishAccess);
+        }
     }
 
     return(NULL);
@@ -656,8 +612,24 @@ _kernel_oserror *serial_initialise(struct ppp_softc *sc)
         int io_access_granted;
 
 
-        e = _swix (Dialler_Arbitrate, _IN (0) | _OUT (0),
-                   Dialler_Arbitrate_RequestIOAccess, &io_access_granted);
+        if (dialler_flags & DiallerFlags_DiallerB)
+        {
+            e = _swix (DiallerB_Arbitrate,
+                       _IN (0) | _OUT (0),
+
+                       Dialler_Arbitrate_RequestIOAccess,
+
+                       &io_access_granted);
+        }
+        else
+        {
+            e = _swix (Dialler_Arbitrate,
+                       _IN (0) | _OUT (0),
+
+                       Dialler_Arbitrate_RequestIOAccess,
+
+                       &io_access_granted);
+        }
 
         if (e)
             return (e);
@@ -706,9 +678,28 @@ _kernel_oserror *serial_initialise(struct ppp_softc *sc)
 
 
         /* Get the serial file handles from the dialler */
-        e = _swix (Dialler_Arbitrate, _IN (0) | _OUTR (0, 2),
-                   Dialler_Arbitrate_RequestIOAccess,
-                   &io_access_granted, &serial_in, &serial_out);
+        if (dialler_flags & DiallerFlags_DiallerB)
+        {
+            e = _swix (DiallerB_Arbitrate,
+                       _IN (0) | _OUTR (0, 2),
+
+                       Dialler_Arbitrate_RequestIOAccess,
+
+                       &io_access_granted,
+                       &serial_in,
+                       &serial_out);
+        }
+        else
+        {
+            e = _swix (Dialler_Arbitrate,
+                       _IN (0) | _OUTR (0, 2),
+
+                       Dialler_Arbitrate_RequestIOAccess,
+
+                       &io_access_granted,
+                       &serial_in,
+                       &serial_out);
+        }
 
         if (e)
             return (e);
@@ -833,6 +824,54 @@ int upcall_handler (_kernel_swi_regs *r, void *pw)
 
 #endif
 
+/* -----------------------------------------------------------------------------
++
+   serial_dcd
+
+   Get the status of the DCD line.
+
+   Returns
+   0: DCD not asserted (ie. no carrier)
+   1: DCD asserted
+-
+ */
+
+#ifdef BLOCKDRIVERS
+
+extern serial_dcd (void)
+{
+    if ((driver_modemcontrol() & 8) == 0)
+    {
+        return 0;
+    }
+
+    return 1;
+}
+
+#else
+
+extern serial_dcd (void)
+{
+    ioctl_t ioctl;
+
+    ioctl.reason = IOCtl_control_lines;
+    ioctl.group = 0;
+    ioctl.reserved = 0;
+    ioctl.read = 1;
+    ioctl.write = 0;
+
+    _swix (OS_Args, _INR (0, 2), OS_Args_IOCtl, serial_in, &ioctl);
+
+    if ((ioctl.data & IOCtl_control_line_DCD) == 0)
+    {
+        return 0;
+    }
+
+    return 1;
+}
+
+#endif
+
 /**********************************************************************/
 
 /* EOF serial.c */
diff --git a/c/slcompress b/c/slcompress
index 242bb783f3a8eee2cf95190bc4ddf7e794fc46bc..c61de0c37cb26f4816c7ba2545fa1aa87e28b7e5 100644
--- a/c/slcompress
+++ b/c/slcompress
@@ -46,8 +46,9 @@
  *
  */
 
-char *ack_sl="Copyright (c) 1989 The Regents of the University of California. "
-             "All rights reserved.";
+static char *ack_sl =
+    "Copyright (c) 1989 The Regents of the University of California. "
+    "All rights reserved.";
 
 #include <assert.h>
 #include <string.h>
@@ -307,19 +308,22 @@ u_char sl_compress_tcp(struct mbuf *m, register struct ip *ip,
 		 * with it. */
 		 goto uncompressed;
 
-	if (deltaS = (u_short)(ntohs(th->th_win) - ntohs(oth->th_win))) {
+	deltaS = (u_short)(ntohs(th->th_win) - ntohs(oth->th_win));
+	if (deltaS) {
 		ENCODE(deltaS);
 		changes |= NEW_W;
 	}
 
-	if (deltaA = ntohl(th->th_ack) - ntohl(oth->th_ack)) {
+	deltaA = ntohl(th->th_ack) - ntohl(oth->th_ack);
+	if (deltaA) {
 		if (deltaA > 0xffff)
 			goto uncompressed;
 		ENCODE(deltaA);
 		changes |= NEW_A;
 	}
 
-	if (deltaS = ntohl(th->th_seq) - ntohl(oth->th_seq)) {
+	deltaS = ntohl(th->th_seq) - ntohl(oth->th_seq);
+	if (deltaS) {
 		if (deltaS > 0xffff)
 			goto uncompressed;
 		ENCODE(deltaS);
diff --git a/cmhg/PPPHdr b/cmhg/PPPHdr
index ecfe3b2083a73e00e9d5483da05250650f2aa29c..505d803e760acc3b3f3b31b1e3dae75fdc39bd77 100644
--- a/cmhg/PPPHdr
+++ b/cmhg/PPPHdr
@@ -12,33 +12,32 @@
 ; See the License for the specific language governing permissions and
 ; limitations under the License.
 ;
-;// -*-Text-*-
-;//
-;// PPPHdr - cmhg header file for PPP module
-;//
-;// Copyright (c) 1995 Acorn Computers Ltd., Cambridge, England
-;//
+// PPPHdr - cmhg header file for PPP module
+//
+// Copyright (c) 1995 Acorn Computers Ltd., Cambridge, England
+//
 
-;// This must be built with CMHG 5.14 or later
+// This must be built with CMHG 5.14 or later
 
 
 
 title-string:           PPP
 
 #ifdef BLOCKDRIVERS
-  help-string:		PPP 1.18 block driver serial interface
+  help-string:		PPP 1.19 block driver serial interface
 #else
-  help-string:		PPP 1.18 DeviceFS serial interface
+  help-string:		PPP 1.19 DeviceFS serial interface
 #endif
 
 initialisation-code:    ppp_initialise
 
 finalisation-code:      ppp_quit
 
-service-call-handler:   ppp_sc_handler &9B, ; Service_EnumerateNetworkDrivers
-                                       &9F, ; Service_DCIProtocolStatus
-                                       &A2, ; Service_MbufManagerStatus
-                                       &B4  ; Service_DiallerService
+service-call-handler:   ppp_sc_handler &9B, // Service_EnumerateNetworkDrivers
+                                       &9F, // Service_DCIProtocolStatus
+                                       &A2, // Service_MbufManagerStatus
+                                       &B4, // Service_DiallerStatus
+                                       &C4  // Service_DiallerBStatus
 
 generic-veneers:	poll_entry/poll_handler,
 			callb_entry/callb_handler,
@@ -47,7 +46,7 @@ generic-veneers:	poll_entry/poll_handler,
 			hup_entry/hup_handler,
 			term_entry/term_handler,
 			hupcheck_entry/hupcheck_handler
-			
+
 #ifndef BLOCKDRIVERS
 vector-handlers:	upcall_entry/upcall_handler
 #endif
@@ -62,13 +61,13 @@ swi-decoding-table:	PPP,
 			7 8 9 10 11 12 13 14 15,
 			16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31,
 			AlterSettings Status
-			
-;//
-;// YUCK - need to mess around with internationalised help, but cannot
-;// use the automatic features added as part of RISC OS 3.5; cmhg's
-;// handling of this used to be broken - this *must* be build with cmhg
-;// version 4.55 or later.
-;//
+
+//
+// YUCK - need to mess around with internationalised help, but cannot
+// use the automatic features added as part of RISC OS 3.5; cmhg's
+// handling of this used to be broken - this *must* be build with cmhg
+// version 4.55 or later.
+//
 command-keyword-table:  ppp_cli_handler
                         PPPInfo(min-args:0, max-args:0, help:,
                             invalid-syntax: "Syntax: *PPPInfo"),
diff --git a/doc/build b/doc/build
new file mode 100644
index 0000000000000000000000000000000000000000..82bf817877bee3e0d3c35eed73cf39bbabb8e16d
--- /dev/null
+++ b/doc/build
@@ -0,0 +1,10 @@
+Two different variants of PPP can be built: one to work with
+blockdrivers and one to work with the new-style DeviceFS interface.  For
+ROM builds (under the new !Builder system) the build can be selected by
+passing down options to PPP from the components file.
+
+For the blockdriver version the entry in the components file should be:
+PPP		-options ASMBLOCKDRIVERS=TRUE CBLOCKDRIVERS=-DBLOCKDRIVERS
+
+For the DeviceFS version the entry in the components file should be:
+PPP		-options ASMBLOCKDRIVERS=FALSE
diff --git a/h/dialler b/h/dialler
deleted file mode 100644
index 7334a3392ccea1bd7939dfa039fd35c1531e0cd2..0000000000000000000000000000000000000000
--- a/h/dialler
+++ /dev/null
@@ -1,101 +0,0 @@
-/* Copyright 1997 Acorn Computers Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/* File:    dialler.h
- * Purpose: Interface to Dialler SWIs, status codes etc.
- * Author:  B Laughton
- * History: 07-Feb-97: BAL: created
- *          25-Feb-97: BAL: added reason code masks courtesy of AH
- *                          added R0 bit mask for entry to SWI Dialler_Status
- */
-
-#ifndef dialler_h
-#define dialler_h
-
-/* =============================================================================
- * Include header files
- */
-
-/* CLib */
-#include "kernel.h"
-
-
-
-
-/* =============================================================================
- * Define contants
- */
-
-#ifndef Dialler_Dial
-#define Dialler_Dial                     0x04c6c0
-#define Dialler_HangUp                   0x04c6c1
-#define Dialler_Status                   0x04c6c2
-#define Dialler_Answering                0x04c6c3
-#define Dialler_Configure                0x04c6c4
-#define Dialler_Register                 0x04c6c5
-#define Dialler_Arbitrate                0x04c6c6
-#define Dialler_Timeout                  0x04c6c7
-#define Dialler_ResetCounter             0x04c6c8
-#endif
-
-
-/* Bit masks for r0 flags word on entry to SWI Dialler_Status */
-#define Dialler_Status_ConnectTime            0x1
-
-/* SWI Dialler_Arbitrate entry and exit values */
-#define Dialler_Arbitrate_RequestIOAccess       0
-#define Dialler_Arbitrate_RelinquishAccess      1
-#define Dialler_IOAccessGranted_BlockDrivers    0
-#define Dialler_IOAccessGranted_DualSerial      1
-#define Dialler_IOAccessDenied_ActiveClient    64
-#define Dialler_IOAccessDenied_NotConnected    65
-
-
-#define Service_DiallerStatus                0xb4
-
-/* Reason code masks */
-#define Dialler_MajorReasonCodeMask    0xffff0000
-#define Dialler_MinorReasonCodeMask    0x0000ff00
-#define Dialler_GeneralInfoMask        0x000000ff
-
-/* Major reason code (top two bytes of status word) */
-#define Dialler_StateChanged           0x00010000
-#define Dialler_LineDropped            0x00020000
-
-/* Minor reason code (2nd byte of status word) */
-#define Dialler_ConnectedFlagsMask     0x00000300
-#define Dialler_Disconnected           0x00000000
-#define Dialler_Connected              0x00000200
-#define Dialler_ConnectedOutgoing      0x00000200
-#define Dialler_ConnectedIncoming      0x00000300
-#define Dialler_RelinquishAccess       0x00000400
-#define Dialler_DiallerDroppedLine     0x00000000
-#define Dialler_RemoteDroppedLine      0x00000800
-
-/* General info (1st byte of status word) */
-enum
-{
-    Dialler_ExecutingScript_Dial = 1,
-    Dialler_ExecutingScript_Hangup,
-    Dialler_ExecutingScript_Answer,
-    Dialler_AbortedScript_Syntax,
-    Dialler_AbortedScript_Timeout,
-    Dialler_AbortedScript_NoCarrier,
-    Dialler_AbortedScript_Error,
-    Dialler_AbortedScript_NoDialtone,
-    Dialler_AbortedScript_Busy,
-    Dialler_AbortedScript_NoAnswer
-};
-
-#endif
diff --git a/h/pppd b/h/pppd
index af5c962fa8e5221f459b43f737e15d4f34fe9f4a..9aca8c081a5aa4935dd9a3e11117672da92f089f 100644
--- a/h/pppd
+++ b/h/pppd
@@ -25,9 +25,11 @@
  */
 #define check_errlevel(x)		((x) == ERRLVL_NO_ERRORS)
 
+#if 0
 #ifndef MAX
 #define MAX(a,b) 			(((a)>(b))?(a):(b))
 #endif
+#endif
 
 extern _kernel_oserror *pppd_main(int argc, char *argv[]);
 
diff --git a/h/ppphdr b/h/ppphdr
index f95465928ecb66dc12c4c7a511a1409b7915db91..8d6aa0e6a673eb2c107d050d4a377cfb402a4f2d 100644
--- a/h/ppphdr
+++ b/h/ppphdr
@@ -27,9 +27,9 @@
 
 #define Module_Title                     "PPP"
 #define Module_Help                      "PPP"
-#define Module_VersionString             "1.17"
-#define Module_VersionNumber             117
-#define Module_Date                      "30 Jul 1997"
+#define Module_VersionString             "1.19"
+#define Module_VersionNumber             119
+#define Module_Date                      "09 Mar 1998"
 
 
 /*
@@ -218,4 +218,41 @@ _kernel_oserror *timeout_handler(_kernel_swi_regs *r, void *pw);
 _kernel_oserror *callb_handler(_kernel_swi_regs *r, void *pw);
 _kernel_oserror *poll_handler(_kernel_swi_regs *r, void *pw);
 
+
+/*
+ * Vector handlers
+ * ===============
+ *
+ * This is the name of the vector handler entry veneer
+ * compiled by CMHG. Use this name as an argument to SWI
+ * OS_Claim. (EventV claimants should use a CMHG event handler).
+ *
+ * Note that vector handlers were previously called IRQ handlers
+ * and were documented as being for attaching to IrqV. IrqV has
+ * long being deprecated; you should use OS_ClaimDeviceVector and
+ * a CMHG generic veneer instead.
+ */
+extern void upcall_entry(void);
+
+/*
+ * This is the handler function you must write to handle the
+ * vector for which upcall_entry is the veneer function.
+ *
+ * If a handler function is installed onto a vector, then:
+ *   Return 0 to intercept the call.
+ *   Return 1 to pass on the call.
+ * If you use a vector handler veneer for any other purpose, always
+ * return non-0, and consider the use of a generic veneer instead.
+ * It is not currently possible to return an error from a vector
+ * handler.
+ *
+ * 'r' points to a vector of words containing the values of R0-R9 on
+ * entry to the veneer. If r is updated, the updated values will be
+ * loaded into R0-R9 on return from the handler.
+ *
+ * pw is the private word pointer ('R12') value with which the
+ * vector entry veneer is called.
+ */
+int upcall_handler(_kernel_swi_regs *r, void *pw);
+
 #endif
diff --git a/h/serial b/h/serial
index da49ce4d8240ef6b3ae0bfca372ee34eccf06367..4beccf089dc8bf9a1104ee460668dbecf559750e 100644
--- a/h/serial
+++ b/h/serial
@@ -23,6 +23,8 @@ extern _kernel_oserror *event_handler(_kernel_swi_regs *ignore, void *pw);
 extern _kernel_oserror *hup_handler(_kernel_swi_regs *ignore, void *pw);
 extern _kernel_oserror *hupcheck_handler(_kernel_swi_regs *ignore, void *pw);
 
+extern int serial_dcd (void);
+
 extern int poll_pending;
 
 extern volatile u_char *ring_start, *ring_limit;
diff --git a/pppd/Makefile b/pppd/Makefile
index 51fac13938cff71dfd05d87733eccad43a817010..98a7d48e76e1563ab4a9d3fa2c383d01a45448d3 100644
--- a/pppd/Makefile
+++ b/pppd/Makefile
@@ -12,31 +12,137 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
-CC=		CC
-LD=		Link
-LIB=		libfile
-AS=		objasm
+# Makefile for pppd
+#
+# ***********************************
+# ***    C h a n g e   L i s t    ***
+# ***********************************
+# Date		Name	Description
+# ----		----	-----------
+# 1998-01-19	BAL	Created
+#
+
+#
+# Generic options:
+#
+MKDIR =		cdir
+AS =		objasm
+CC =		cc
+CMHG =		cmhg
+CP =		copy
+LD =		<boot$dir>.library.link
+RM =		remove
+MODSQZ =	modsqz
+WIPE =		-wipe
+
+ASMFLAGS =	-depend !Depend ${THROWBACK}
+CFLAGS =	-depend !Depend ${THROWBACK} ${INCLUDES} ${CBLOCKDRIVERS} -strict -Wp -ffah 
+CPFLAGS =	~cfr~v
+LDFLAGS =	-aof
+WFLAGS =	~c~v
+
+DFLAGS_COMMON = -DCOMPAT_INET4 -DDEBUGMAIN -DDEBUGCHAP -DNO_DRAND48 -DVJC
+DFLAGS =	${DFLAGS_COMMON} -DNDEBUG
+DDFLAGS =       ${DFLAGS_COMMON} -DDEBUG -DEBUGALL -DDEBUG_TML -DTrace_TRACE
+
+#
+# Include files
+#
+INCLUDES =	-ITCPIPLibs:,C:
+
+#
+# Program specific options:
+#
+TARGET =	o.pppd
+DEBUGTARGET =	od.pppd
+
+
+OBJS =\
+ o.auth\
+ o.chap\
+ o.dea_crypt\
+ o.dea_data\
+ o.fsm\
+ o.ipcp\
+ o.lcp\
+ o.magic\
+ o.main\
+ o.md5\
+ o.minixlib\
+ o.options\
+ o.sys-riscos\
+ o.upap\
+
 
-# To compile a version of PPP which uses the blockdrivers uncomment the next
-# line
+OBJSD =\
+ od.auth\
+ od.chap\
+ od.dea_crypt\
+ od.dea_data\
+ od.fsm\
+ od.ipcp\
+ od.lcp\
+ od.magic\
+ od.main\
+ od.md5\
+ od.minixlib\
+ od.options\
+ od.sys-riscos\
+ od.upap\
 
-BLOCKDRIVERS=	-DBLOCKDRIVERS
 
-CCFLAGS=	-Wp -depend !Depend -c -ITCPIPLibs:,C: -throwback -ffah\
-                -DDEBUGMAIN -DDEBUGCHAP -DNO_DRAND48 -DCOMPAT_INET4\
-                -DVJC -zM -zps1 ${BLOCKDRIVERS} # -DDEBUG -DDEBUGALL
-LDFLAGS=	-aof -o $@
-OBJS=		o.main o.magic o.fsm o.lcp o.ipcp o.upap o.chap \
-		o.auth o.options o.md5 o.sys-riscos o.minixlib \
-		o.dea_crypt o.dea_data
+OBJSCP =\
+ cp.auth\
+ cp.chap\
+ cp.dea_crypt\
+ cp.fsm\
+ cp.ipcp\
+ cp.lcp\
+ cp.magic\
+ cp.main\
+ cp.md5\
+ cp.minixlib\
+ cp.options\
+ cp.sys-riscos\
+ cp.upap\
 
-.SUFFIXES:	.o .c
-.c.o:;		$(cc) $(ccflags) -o $@ $<
 
-o.pppd:		$(OBJS)
-		$(LD) $(LDFLAGS) $(OBJS)
+#
+# Rule patterns
+#
+.SUFFIXES:	.o .od .cp .c .s
+.c.o:;		${CC} ${CFLAGS} ${DFLAGS}       -c -zM -zps1 -o $@ $<
+.c.od:;		${CC} ${CFLAGS} ${DDFLAGS}      -c -zM -zps1 -fn -o $@ $<
+.c.cp:;		${CC} ${CFLAGS} ${DFLAGS}       -c -C -E $< >> $@
+.s.o:;		$(AS) ${ASMFLAGS} -o $@ $<
+.s.od:;		$(AS) ${ASMFLAGS} -o $@ $<
+
+#
+# Main rules:
+#
+ram: ${TARGET}
+
+rom: ${TARGET}
+
+debug: ${DEBUGTARGET}
+
+analyse: ${OBJSCP}
+
+clean:
+	${WIPE} o.* ${WFLAGS}
+	${WIPE} od.* ${WFLAGS}
+	${WIPE} cp.* ${WFLAGS}
+
+#
+# Target 
+#
+${TARGET}: ${OBJS}
+	${LD} ${LDFLAGS} -o $@ ${OBJS}
+
+#
+# Debug target
+#
+${DEBUGTARGET}: ${OBJSD}
+	${LD} ${LDFLAGS} -o $@ ${OBJSD}
 
-o.dea_data:	s.dea_data
-		$(AS) s.dea_data o.dea_data
-		
 # Dynamic dependencies:
diff --git a/pppd/c/auth b/pppd/c/auth
index 9350c42ae66c45e7d0ba85180be2d09d8d59ff90..11d5f90bb8ea7c105ec053407be7a30e116875a3 100644
--- a/pppd/c/auth
+++ b/pppd/c/auth
@@ -32,8 +32,9 @@
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-char *ack_auth="Copyright (c) 1993 The Australian National University. "
-               "All rights reserved.";
+static char *ack_auth =
+    "Copyright (c) 1993 The Australian National University. "
+    "All rights reserved.";
 
 #include <stdio.h>
 #include <stddef.h>
diff --git a/pppd/c/chap b/pppd/c/chap
index 4ebcabb027e857280a3b9173532b26f55aeb77c5..6133dedf4a320cf07594fcde29e553563547dec3 100644
--- a/pppd/c/chap
+++ b/pppd/c/chap
@@ -22,8 +22,8 @@
  * TODO:
  */
 
-char *ack_chap="Copyright (c) 1991 Gregory M. Christy. "
-               "All rights reserved.";
+static char *ack_chap="Copyright (c) 1991 Gregory M. Christy. "
+                      "All rights reserved.";
 
 #include <stdio.h>
 #include <string.h>
diff --git a/pppd/c/main b/pppd/c/main
index fd612da50f04d2db2b9b6c49a161b61c0014f71c..437945302d41462f820f8569281361758e61bfc2 100644
--- a/pppd/c/main
+++ b/pppd/c/main
@@ -88,7 +88,7 @@
 
 #include "main.h"
 
-#include "^.dialler.h"
+#include "dialler.h"
 
 #define OutputFreeSpaceThres 63
 
diff --git a/pppd/c/md5 b/pppd/c/md5
index 20e3d2e471fe50daa2a0e829205be98e3c36f4db..442cc011ef4210388e9cde6de0e941b8527bdb99 100644
--- a/pppd/c/md5
+++ b/pppd/c/md5
@@ -33,7 +33,8 @@
  ***********************************************************************
  */
 
-char *ack_md5="Copyright (C) 1990, RSA Data Security, Inc. All rights reserved.";
+static char *ack_md5 = "Copyright (C) 1990, RSA Data Security, Inc. "
+                       "All rights reserved.";
 
 #include "md5.h"
 
diff --git a/pppd/c/options b/pppd/c/options
index 68437c5693ee7e00a056fa1266817713443da1ae..e864185f79db68e65c36579ca09029a77e8b4763 100644
--- a/pppd/c/options
+++ b/pppd/c/options
@@ -19,6 +19,11 @@
 
 /* Carnegie Mellon acknowledged in c.if_ppp */
 
+/* 1998-03-09: BAL
+ * Added support for using DiallerB for serial stream handle arbitration as
+ * well as Dialler.
+ */
+
 #include <stdio.h>
 #include <string.h>
 #include <ctype.h>
@@ -101,6 +106,7 @@ static int setxonxoff(void);
 static int setmodem(void);
 static int setlocal(void);
 static int setdialler (void);
+static int setdiallerb (void);
 static int setnodialler (void);
 static int setautodial (void);
 static int setnoautodial (void);
@@ -210,6 +216,7 @@ static struct cmd {
     {"ipcp-accept-remote", 0, setipcpaccr}, /* Accept peer's address for it */
     {"idle-disconnect", 1, setidle}, /* seconds for disconnect of idle link */
     {"dialler", 0, setdialler}, /* use the dialler */
+    {"diallerb", 0, setdiallerb}, /* use the diallerb */
     {"nodialler", 0, setnodialler}, /* don't use the dialler: autodialling not possible */
     {"autodial", 0, setautodial}, /* enable autodialling (only if also using dialler) */
     {"noautodial", 0, setnoautodial}, /* disable autodialling */
@@ -1179,6 +1186,13 @@ static int setdialler (void)
     return 1;
 }
 
+static int setdiallerb (void)
+{
+    dialler_flags |= DiallerFlags_UsingDialler;
+    dialler_flags |= DiallerFlags_DiallerB;
+    return 1;
+}
+
 static int setnodialler (void)
 {
     dialler_flags &= ~DiallerFlags_UsingDialler;
@@ -1188,11 +1202,13 @@ static int setnodialler (void)
 static int setautodial (void)
 {
     dialler_flags |= DiallerFlags_AutoDial;
+    return 1;
 }
 
 static int setnoautodial (void)
 {
     dialler_flags &= ~DiallerFlags_AutoDial;
+    return 1;
 }
 
 static int setusehostname(void)
diff --git a/pppd/c/sys-riscos b/pppd/c/sys-riscos
index 46c6e5e9fcd0c4228464438f65d5367e0aa9add2..557302a2be834f0f67f8bf819c82f36703384696 100644
--- a/pppd/c/sys-riscos
+++ b/pppd/c/sys-riscos
@@ -320,7 +320,7 @@ int sifdown(int u)
 {
     struct ifreq ifr;
     u_int x;
-    int rv;
+    int rv = 1;
 
     IGNORE(u);
 
@@ -331,10 +331,11 @@ int sifdown(int u)
 
     if ((dialler_flags & DiallerFlags_UsingDialler) &&
         (dialler_flags & DiallerFlags_AutoDial) && !finalising)
+    {
         ppp_softc[u].moreflags &= ~IFF_UP;
+    }
     else
     {
-        rv = 1;
         if (pppioctl(fd, PPPIOCGFLAGS, (caddr_t) &x) < 0)
         {
             syslog(LOG_ERR, "ioctl (PPPIOCGFLAGS): %m");
@@ -479,7 +480,9 @@ int sifaddr(int u, u_long o, u_long h, u_long m)
  */
 int cifaddr(int u, u_long o, u_long h)
 {
+#if 0
     struct rtentry rt;
+#endif
 
     IGNORE(u);
     IGNORE(o);
@@ -632,10 +635,8 @@ static int rtm_seq;
 /*
  * dodefaultroute - talk to a routing socket to add/delete/change a default route.
  */
-static int
-dodefaultroute(g, cmd)
-    u_long g;
-    int cmd;
+static int dodefaultroute (u_long  g,
+                           int     cmd)
 {
     int routes;
     struct {
@@ -727,13 +728,13 @@ static struct {
 
 static int arpmsg_valid;
 
-int
-sifproxyarp(unit, hisaddr)
-    int unit;
-    u_long hisaddr;
+int sifproxyarp (int     unit,
+                 u_long  hisaddr)
 {
     int routes;
-    int l;
+
+    NOT_USED (unit);
+    NOT_USED (hisaddr);
 
     if (internet_version < 414) {
         syslog(LOG_ERR, "Proxy ARP requires Internet 4.14 or later");
@@ -782,13 +783,14 @@ sifproxyarp(unit, hisaddr)
 /*
  * cifproxyarp - Delete the proxy ARP entry for the peer.
  */
-int
-cifproxyarp(unit, hisaddr)
-    int unit;
-    u_long hisaddr;
+int cifproxyarp (int     unit,
+                 u_long  hisaddr)
 {
     int routes;
 
+    NOT_USED (unit);
+    NOT_USED (hisaddr);
+
     if (!arpmsg_valid)
 	return 0;
     arpmsg_valid = 0;
@@ -819,10 +821,8 @@ cifproxyarp(unit, hisaddr)
  */
 #define MAX_IFS		32
 
-int
-get_ether_addr(ipaddr, hwaddr)
-    u_long ipaddr;
-    struct sockaddr_dl *hwaddr;
+int get_ether_addr (u_long                ipaddr,
+                    struct sockaddr_dl *  hwaddr)
 {
     struct ifreq *ifr, *ifend, *ifp;
     u_long ina, mask;
@@ -868,7 +868,7 @@ get_ether_addr(ipaddr, hwaddr)
 
 	    break;
 	}
-	//ifr = (struct ifreq *) ((char *)&ifr->ifr_addr + ifr->ifr_addr.sa_len);
+/* 	ifr = (struct ifreq *) ((char *)&ifr->ifr_addr + ifr->ifr_addr.sa_len); */
 	ifr = (struct ifreq *) ((char *)&ifr->ifr_addr + 16);
     }
 
@@ -891,7 +891,7 @@ get_ether_addr(ipaddr, hwaddr)
 	    BCOPY(dla, hwaddr, dla->sdl_len);
 	    return 1;
 	}
-	//ifr = (struct ifreq *) ((char *)&ifr->ifr_addr + ifr->ifr_addr.sa_len);
+/* 	ifr = (struct ifreq *) ((char *)&ifr->ifr_addr + ifr->ifr_addr.sa_len); */
 	ifr = (struct ifreq *) ((char *)&ifr->ifr_addr + 16);
     }
 
diff --git a/pppd/h/main b/pppd/h/main
index af9464cfa97e3a25455e5090b4a15dbf77ec4209..5189f55069ca79f7759312ffbbc8c28339015276 100644
--- a/pppd/h/main
+++ b/pppd/h/main
@@ -51,6 +51,7 @@ extern int dialler_flags;
 
 #define DiallerFlags_UsingDialler 0x00000001
 #define DiallerFlags_AutoDial     0x00000002
+#define DiallerFlags_DiallerB     0x00000004
 
 #ifndef __setjmp_h
 #include <setjmp.h>
diff --git a/s/ppp_ioO b/s/ppp_ioO
deleted file mode 100644
index 39584d453e08ac9f91cd9cdfd83a14b1e6fb52be..0000000000000000000000000000000000000000
--- a/s/ppp_ioO
+++ /dev/null
@@ -1,212 +0,0 @@
-; Copyright 1996 Acorn Computers Ltd
-;
-; Licensed under the Apache License, Version 2.0 (the "License");
-; you may not use this file except in compliance with the License.
-; You may obtain a copy of the License at
-;
-;     http://www.apache.org/licenses/LICENSE-2.0
-;
-; Unless required by applicable law or agreed to in writing, software
-; distributed under the License is distributed on an "AS IS" BASIS,
-; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-; See the License for the specific language governing permissions and
-; limitations under the License.
-;
-; -*-As-*-
-;
-;	 ppp_io.s
-;
-;	 data transfer routines for PPP driver
-;
-;	 Copyright (c) 1995 Acorn Computers Ltd., Cambridge, England
-;
-;
-	GET	Hdr.CVars
-
-SP	RN	13
-I_bit	*	(1:SHL:27)
-C_bit	*	(1:SHL:29)
-SVC_mode *	3
-XOS_AddCallBack	*	&20054
-
-	AREA	ppp_io, CODE, READONLY
-
-;
-; callproto - set r12 and branch to protocol module's handler
-;
-; void callproto(DibRef dib, struct mbuf *m0,
-;                  void (*handler)(DibRef, struct mbuf *),
-;                   unsigned int pw);
-
-	EXPORT  callproto
-callproto
-	MOV	r12,a4
-	MOV	pc,a3
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;
-; ticker_handler:
-;
-; this routine is installed directly on TickerV.  If the byte to be inserted
-; is destined for the serial input buffer, then it is diverted and placed
-; in our own private buffer.
-;
-
-	ImportVar ring_insert
-	ImportVar ring_limit
-	ImportVar ring_start
-	ImportVar poll_pending
-
-poll_entry_ptr
-	IMPORT	poll_entry
-	DCD	poll_entry
-
-		EXPORT	ticker_handler
-ticker_handler	ROUT
-
-;
-; before we switch mode (below) need to store r14_irq (i.e. lr) on
-; the irq stack.  copy pc into r9 so we can restore the correct
-; mode upon exit
-;
-	STMFD	SP!, {R0-R1, R6, R9, LR}
-	MOV	R9, PC
-
-;
-; we are normally called in IRQ mode, get into SVC mode.
-;
-	ORR	R0, R9, #SVC_mode
-	TEQP	R0, #0
-	NOP
-	STMFD	R13!,{LR}
-
-;
-; mess around with relocation offsets
-;
-
-	LDR	R0,[R12]
-	StaticBaseFromWP R6,R0		; data reloc now in r6
-
-	MOV	R0,#5           ; Check RX buffer
-	MOV	R1,#0	     	; Port number (***HACK***)
-	BL	driver_asm
-	TEQS	R0,#0
-
-	BNE	%FA10
-5	LDMFD	R13!,{LR}
-	TEQP	R9, #0
-	NOP
-	LDMFD	SP!, {R0-R1, R6, R9, PC}^
-
-
-; copy a block into  the ring buffer
-; R2->data, R3=len
-
-10	STMFD	SP!, {R2-R4}
-	B	%FA13
-
-20	LDRVar	R2,R6,ring_insert           ; R2=ring_insert
-	LDRVar	R4,R6,ring_limit            ; R4=ring_limit
-	SUBS	R3,R4,R2                    ; R3=space till end of buffer
-	LDRVar	R2,R6,ring_start,EQ         ; if no space, R2=ring_start
-	SUBEQ	R3,R4,R2
-	MOV	R0,#3      ; Get block
-	MOV	R1,#0
-	BL	driver_asm   		    ; get as many as possible (R3)
-	ADD	R2,R2,R0
-	STRVar	R2,R6,ring_insert,LR        ; update ring_insert
-	TEQS	R2,R4                       ; if ring_insert=ring_limit
-	BEQ	%BA20                       ;    then go round again
-
-13	ADRVar	R3,R6,poll_pending
-	LDR	R0,[R3]
-	TEQS	R0,#0
-	BNE	%F25
-
-	LDR	R0,poll_entry_ptr
-	MOV	R1,R12
-	SWI	XOS_AddCallBack
-	STR	R0,[R3]
-;
-25	LDMFD	SP!, {R2-R4}
-	B	%B5
-
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;
-; splhi etc:
-;
-; Disable IRQs. Once IRQs are disabled, we cannot/must not be reentered.
-;
-; Returns a value indicating the state of interrupts prior to calling here.
-;
-		EXPORT	splhi[LEAF]
-splhi		ROUT
-
-	AND	r0, lr, # I_bit
-	ORRS	pc, lr, # I_bit
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;
-; ensure_irqs_on:
-;
-; Ensure that interrupts are enabled. Returns a value that, when passed
-; to restore_irqs, will restore the state prior to enabling interrupts.
-;
-		EXPORT	ensure_irqs_on[LEAF]
-ensure_irqs_on	ROUT
-
-	AND	r0, lr, # I_bit
-	BICS	pc, lr, # I_bit
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;
-; restore_irqs etc:
-;
-; Restore interrupts to the state they were in prior to a call to
-; splhi, using the value returned by splhi.
-;
-		EXPORT	restore_irqs[LEAF]
-		EXPORT	splx[LEAF]
-
-restore_irqs	ROUT
-splx
-	BIC	lr, lr, # I_bit
-	ORRS	pc, lr, r0
-
-; Grobbly bit - the block driver is in the data area, but we need
-; to call it as code. This assembler veneer handles relocations.
-
-	ImportVar driver_block
-
-; Version to be called from C
-	EXPORT driver
-driver
-	STMFD	sp!,{r4-r5,lr}
-	StaticBaseFromSL r5
-	ADRVar	r4,r5,driver_block
-	MOV	lr,pc
-	MOV	pc,r4
-	LDMFD	sp!,{r4-r5,pc}^
-
-
-; Version to be called from Assembler above
-; Takes R6 as its relocation base
-driver_asm
-	STMFD	sp!,{r1-r4,lr}
-	ADRVar	r4,r6,driver_block
-	;LDR	lr,a8000
-	;STR	r4,[lr]
-	;MOV	r0,#0
-	;LDMFD	sp!,{r4,pc}^
-	MOV	lr,pc
-	MOV	pc,r4
-77	LDMFD	sp!,{r1-r4,pc}^
-
-a8000
-	DCD	&8000
-
-	END
-
-;	/* EOF ppp_io.s */