From 0da9ad689658e701caeb11016a117e67183c0273 Mon Sep 17 00:00:00 2001
From: pmai <pmai>
Date: Thu, 6 Mar 2003 14:13:47 +0000
Subject: [PATCH] Fixes by Brian Uhrain for the alpha port:   Attached is the
 full patch containing the addition of the   ISTREAM-MEMORY-BARRIER VOP, the
 change to GENTRAP to use the bugchk   opcode, and also a boot file to allow
 the patched sources to be   compiled with an unpatched binary.

---
 bootfiles/18d/boot11-alpha-linux.lisp | 11 +++++++++++
 code/alpha-vm.lisp                    |  6 +++---
 compiler/alpha/insts.lisp             | 18 +++++++++++++++---
 compiler/alpha/system.lisp            |  8 +++++++-
 lisp/alpha-assem.S                    |  9 +++++----
 5 files changed, 41 insertions(+), 11 deletions(-)
 create mode 100644 bootfiles/18d/boot11-alpha-linux.lisp

diff --git a/bootfiles/18d/boot11-alpha-linux.lisp b/bootfiles/18d/boot11-alpha-linux.lisp
new file mode 100644
index 000000000..1e0f038fa
--- /dev/null
+++ b/bootfiles/18d/boot11-alpha-linux.lisp
@@ -0,0 +1,11 @@
+; This file is only needed when compiling for the Alpha under Linux, to add the
+; new Alpha-only ISTREAM-MEMORY-BARRIER VOP.
+(in-package "ALPHA")
+
+(define-instruction imb (segment)
+  (:emitter (emit-pal segment 0 #x000086)))
+
+(define-vop (c::istream-memory-barrier)
+  (:generator 1
+    (inst imb)))
+
diff --git a/code/alpha-vm.lisp b/code/alpha-vm.lisp
index be2ea189c..d35ed455e 100644
--- a/code/alpha-vm.lisp
+++ b/code/alpha-vm.lisp
@@ -5,11 +5,11 @@
 ;;; Carnegie Mellon University, and has been placed in the public domain.
 ;;;
 (ext:file-comment
-  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/alpha-vm.lisp,v 1.3 2002/11/19 13:17:13 toy Exp $")
+  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/alpha-vm.lisp,v 1.4 2003/03/06 14:13:07 pmai Exp $")
 ;;;
 ;;; **********************************************************************
 ;;;
-;;; $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/alpha-vm.lisp,v 1.3 2002/11/19 13:17:13 toy Exp $
+;;; $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/alpha-vm.lisp,v 1.4 2003/03/06 14:13:07 pmai Exp $
 ;;;
 ;;; This file contains the Alpha specific runtime stuff.
 ;;;
@@ -236,4 +236,4 @@
 ;;; 
 (defun sanctify-for-execution (component)
   (declare (ignore component))
-  nil)
+  (%primitive istream-memory-barrier))
diff --git a/compiler/alpha/insts.lisp b/compiler/alpha/insts.lisp
index a5f9a6fd7..3641be1f4 100644
--- a/compiler/alpha/insts.lisp
+++ b/compiler/alpha/insts.lisp
@@ -5,7 +5,7 @@
 ;;; Carnegie Mellon University, and has been placed in the public domain.
 ;;;
 (ext:file-comment
-  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/alpha/insts.lisp,v 1.4 1997/06/07 19:04:39 pw Exp $")
+  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/alpha/insts.lisp,v 1.5 2003/03/06 14:13:08 pmai Rel $")
 ;;;
 ;;; **********************************************************************
 ;;;
@@ -440,14 +440,26 @@
 
 (define-instruction  excb (segment)
   (:emitter (emit-lword segment #x63ff0400)))
-  
+
 (define-instruction trapb (segment)
   (:emitter (emit-lword segment #x63ff0000)))
 
+(define-instruction imb (segment)
+  (:emitter (emit-pal segment 0 #x000086)))
+
 (define-instruction gentrap (segment code)
   (:printer call-pal ((palcode #xaa0000)))
   (:emitter
-   (emit-pal segment 0 #x0000aa)
+	 ; BAU: This *might* cause troubles on Alphas that only have ARC firmware,
+	 ; as the Alpha Architecture Handbook lists the bugchk PALcode instruction
+	 ; only for the OpenVMS/Digital UNIX PALcode (SRM firmware), but not for
+	 ; the Windows NT PALcode (ARC firmware) (see p. C-19 in the AAH,
+	 ; opcode 00.0081)
+	 ; Oddly enough, even though the gentrap instruction is defined for all
+	 ; three PALcode instruction sets, Eric Marsden noticed that it was not
+	 ; working as expected under some PALcode setups.
+   (emit-pal segment 0 #x000081)      ; actually bugchk PALcode instruction
+   ;; (emit-pal segment 0 #x0000aa)   ; gentrap PALcode instruction
    (emit-lword segment code)))
 
 (define-instruction-macro move (src dst)
diff --git a/compiler/alpha/system.lisp b/compiler/alpha/system.lisp
index 64ed96210..aea72ddf4 100644
--- a/compiler/alpha/system.lisp
+++ b/compiler/alpha/system.lisp
@@ -5,7 +5,7 @@
 ;;; Carnegie Mellon University, and has been placed in the public domain.
 ;;;
 (ext:file-comment
-  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/alpha/system.lisp,v 1.2 1994/10/31 04:39:51 ram Exp $")
+  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/alpha/system.lisp,v 1.3 2003/03/06 14:13:08 pmai Rel $")
 ;;;
 ;;; **********************************************************************
 ;;;
@@ -237,6 +237,12 @@
   (:generator 1
     (inst gentrap halt-trap)))
 
+(defknown istream-memory-barrier () (values))
+(define-vop (c::istream-memory-barrier)
+  (:translate istream-memory-barrier)
+  (:generator 1
+    (inst imb)))
+
 
 ;;;; Dynamic vop count collection support
 
diff --git a/lisp/alpha-assem.S b/lisp/alpha-assem.S
index 8427bf96a..780c5d516 100644
--- a/lisp/alpha-assem.S
+++ b/lisp/alpha-assem.S
@@ -1,4 +1,4 @@
-/* $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/alpha-assem.S,v 1.9 2002/08/23 17:01:00 pmai Exp $ */
+/* $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/alpha-assem.S,v 1.10 2003/03/06 14:13:09 pmai Rel $ */
 #ifndef	__linux__
 #include <machine/regdef.h>
 #include <machine/pal.h>
@@ -60,10 +60,9 @@ call_into_lisp:
 	ldl	reg_OCFP,current_control_frame_pointer
 	mov	a1,reg_CFP
 
-#ifndef __linux__	
 	.set	noat
-#endif	
 	ldil	reg_L2,0
+        .set at
 	/* End of pseudo-atomic. */
 
 	/* Establish lisp arguments. */
@@ -188,8 +187,10 @@ call_into_c:
 	mov	reg_ZERO, reg_A4
 	mov	reg_ZERO, reg_A5
 	mov	reg_ZERO, reg_L0
+	.set noat
 	mov	reg_ZERO, reg_L2
-
+        .set at
+        
 	/* Turn on pseudo-atomic. */
 	lda	reg_ALLOC,1(reg_ZERO)
 
-- 
GitLab