Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
* PATCH: (on Alpha) emulating missing instructions
@ 1999-10-15  9:30 Luke Deller
  1999-10-15 12:42 ` Eric Bohm
  1999-10-15 14:28 ` Michal Jaegermann
  0 siblings, 2 replies; 12+ messages in thread
From: Luke Deller @ 1999-10-15  9:30 UTC (permalink / raw)
  To: linux-kernel; +Cc: axp-list, Daniel Paul Potts

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1715 bytes --]

Daniel & I tried to run Loki's new beta version of Civilization Call to
Power for alpha linux on a multia (ev4 alpha).  We got an illegal
instruction exception.  We discovered that it was compiled for ev6, and so
contained instructions not supported by our CPU.

So we have patched the linux kernel to emulate the instructions we needed.
These instructions are:
- byte/word load/store instructions (ldbu,stb,ldwu,stw)
- some multimedia instructions (minsw, maxsw, minuw, maxuw, minsb, maxsb,
  minub, maxub)

We have tried to make the emulation fairly fast - we have added it as some
assembly language code to the "illegal instruction exception" kernel entry
point in arch/alpha/kernel/entry.S:entIF.  (Of course it's still faster
to avoid emulation and use a binary compiled for your generation of alpha
cpu).

We put an option for enabling it in the "Kernel Hacking" section of the
configuration.

The patch is applied to kernel version 2.2.11
(Loki say not to use 2.2.12 for Civilization CTP) 

We only wrote enough emulation code to get CivilizationCTP to run ..  in the
future it would be cool to see emulation of a more complete set of
instructions in the kernel.

Hope this is useful to somebody,

Luke Deller & Daniel Potts.

--------------------------------------------------------------------------
           Luke Deller                               luked@cse.unsw.edu.au
 _--_|\    Computer Engineering student           
/      \   School of Computer Science and Engineering     ? ? ? ?        
\_.--._*   The University of New South Wales               ~~^^~  
      v    Sydney, NSW     2052    AUSTRALIA                o o
-------------------------------------------------------ooO--(_)--Ooo------

[-- Attachment #2: linux-alpha-emu-for2_2_11.patch --]
[-- Type: TEXT/PLAIN, Size: 16525 bytes --]

diff -u --recursive --new-file v2.2.11/linux/arch/alpha/config.in linux/arch/alpha/config.in
--- v2.2.11/linux/arch/alpha/config.in	Sun May 23 06:41:37 1999
+++ linux/arch/alpha/config.in	Fri Oct 15 18:18:16 1999
@@ -280,6 +280,7 @@
 #bool 'Debug kmalloc/kfree' CONFIG_DEBUG_MALLOC
 if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
   tristate 'Kernel FP software completion' CONFIG_MATHEMU
+  bool 'Emulation of some extended instruction sets' CONFIG_ALPHA_EXTINSNS
 else
   define_bool CONFIG_MATHEMU y
 fi
diff -u --recursive --new-file v2.2.11/linux/arch/alpha/defconfig linux/arch/alpha/defconfig
--- v2.2.11/linux/arch/alpha/defconfig	Sun Jun 13 04:52:51 1999
+++ linux/arch/alpha/defconfig	Fri Oct 15 18:17:50 1999
@@ -330,4 +330,5 @@
 # Kernel hacking
 #
 CONFIG_MATHEMU=y
+# CONFIG_ALPHA_EXTINSNS is not set
 # CONFIG_MAGIC_SYSRQ is not set
diff -u --recursive --new-file v2.2.11/linux/arch/alpha/kernel/entry.S linux/arch/alpha/kernel/entry.S
--- v2.2.11/linux/arch/alpha/kernel/entry.S	Tue Aug 10 05:04:57 1999
+++ linux/arch/alpha/kernel/entry.S	Fri Oct 15 18:18:30 1999
@@ -173,10 +173,819 @@
 	jsr	$31,do_entArith
 .end entArith
 
+#ifdef CONFIG_ALPHA_EXTINSNS
+/* emulation of some extended alpha instructions */
+
+.align 3
+.ent	get_user_sp
+get_user_sp:
+	subq		$30,6*8,$30
+	stq		$0,0($30)
+	stq		$1,8($30)
+	stq		$16,16($30)
+	mov		$25,$3
+	stq		$22,24($30)
+	stq		$23,32($30)
+	stq		$24,40($30)
+	call_pal	PAL_rdusp
+	ldq		$24,40($30)
+	mov		$3,$25
+	ldq		$23,32($30)
+	ldq		$22,24($30)
+	mov		$0,$3
+	ldq		$16,16($30)
+	ldq		$1,8($30)
+	ldq		$0,0($30)
+	addq		$30,6*8,$30
+	ret		$31,($5)
+.end	get_user_sp
+
+.align 3
+.ent	put_user_sp
+put_user_sp:
+	subq		$30,5*8,$30
+	stq		$16,0($30)
+	stq		$22,8($30)
+	stq		$23,16($30)
+	mov		$3,$16
+	stq		$24,24($30)
+	mov		$1,$3
+	stq		$25,32($30)
+	call_pal	PAL_wrusp
+	ldq		$25,32($30)
+	ldq		$24,24($30)
+	mov		$3,$1
+	ldq		$23,16($30)
+	ldq		$22,8($30)
+	ldq		$16,0($30)
+	addq		$30,5*8,$30
+	ret		$31,($5)
+.end	put_user_sp
+
+/* a code table .. make sure each entry is exactly 2 instructions */
+.align 3
+.ent	get_ureg_table
+get_ureg0:
+	ldq	$3,8*0($30)
+	ret	$31,($5)
+get_ureg1:
+	ldq	$3,8*1($30)
+	ret	$31,($5)
+get_ureg2:
+	ldq	$3,8*2($30)
+	ret	$31,($5)
+get_ureg3:
+	ldq	$3,8*3($30)
+	ret	$31,($5)
+get_ureg4:
+	ldq	$3,8*4($30)
+	ret	$31,($5)
+get_ureg5:
+	ldq	$3,8*5($30)
+	ret	$31,($5)
+get_ureg6:
+	mov	$6,$3
+	ret	$31,($5)
+get_ureg7:
+	mov	$7,$3
+	ret	$31,($5)
+get_ureg8:
+	mov	$8,$3
+	ret	$31,($5)
+get_ureg9:
+	mov	$9,$3
+	ret	$31,($5)
+get_ureg10:
+	mov	$10,$3
+	ret	$31,($5)
+get_ureg11:
+	mov	$11,$3
+	ret	$31,($5)
+get_ureg12:
+	mov	$12,$3
+	ret	$31,($5)
+get_ureg13:
+	mov	$13,$3
+	ret	$31,($5)
+get_ureg14:
+	mov	$14,$3
+	ret	$31,($5)
+get_ureg15:
+	mov	$15,$3
+	ret	$31,($5)
+get_ureg16:
+	ldq	$3,8*10($30)
+	ret	$31,($5)
+get_ureg17:
+	ldq	$3,8*11($30)
+	ret	$31,($5)
+get_ureg18:
+	ldq	$3,8*12($30)
+	ret	$31,($5)
+get_ureg19:
+	mov	$19,$3
+	ret	$31,($5)
+get_ureg20:
+	mov	$20,$3
+	ret	$31,($5)
+get_ureg21:
+	mov	$21,$3
+	ret	$31,($5)
+get_ureg22:
+	mov	$22,$3
+	ret	$31,($5)
+get_ureg23:
+	mov	$23,$3
+	ret	$31,($5)
+get_ureg24:
+	mov	$24,$3
+	ret	$31,($5)
+get_ureg25:
+	mov	$25,$3
+	ret	$31,($5)
+get_ureg26:
+	mov	$26,$3
+	ret	$31,($5)
+get_ureg27:
+	mov	$27,$3
+	ret	$31,($5)
+get_ureg28:
+	mov	$28,$3
+	ret	$31,($5)
+get_ureg29:
+	ldq	$3,9*8($30)
+	ret	$31,($5)
+get_ureg30:
+	br	$31,get_user_sp 
+	ret	$31,($5)
+get_ureg31:
+	mov	$31,$3
+	ret	$31,($5)
+.end	get_ureg_table
+
+/* another code table .. make sure each entry is exactly 2 instructions */
+.align 3
+.ent	put_ureg_table
+put_ureg0:
+	stq	$3,8*0($30)
+	ret	$31,($5)
+put_ureg1:
+	stq	$3,8*1($30)
+	ret	$31,($5)
+put_ureg2:
+	stq	$3,8*2($30)
+	ret	$31,($5)
+put_ureg3:
+	stq	$3,8*3($30)
+	ret	$31,($5)
+put_ureg4:
+	stq	$3,8*4($30)
+	ret	$31,($5)
+put_ureg5:
+	stq	$3,8*5($30)
+	ret	$31,($5)
+put_ureg6:
+	mov	$3,$6
+	ret	$31,($5)
+put_ureg7:
+	mov	$3,$7
+	ret	$31,($5)
+put_ureg8:
+	mov	$3,$8
+	ret	$31,($5)
+put_ureg9:
+	mov	$3,$9
+	ret	$31,($5)
+put_ureg10:
+	mov	$3,$10
+	ret	$31,($5)
+put_ureg11:
+	mov	$3,$11
+	ret	$31,($5)
+put_ureg12:
+	mov	$3,$12
+	ret	$31,($5)
+put_ureg13:
+	mov	$3,$13
+	ret	$31,($5)
+put_ureg14:
+	mov	$3,$14
+	ret	$31,($5)
+put_ureg15:
+	mov	$3,$15
+	ret	$31,($5)
+put_ureg16:
+	stq	$3,8*10($30)
+	ret	$31,($5)
+put_ureg17:
+	stq	$3,8*11($30)
+	ret	$31,($5)
+put_ureg18:
+	stq	$3,8*12($30)
+	ret	$31,($5)
+put_ureg19:
+	mov	$3,$19
+	ret	$31,($5)
+put_ureg20:
+	mov	$3,$20
+	ret	$31,($5)
+put_ureg21:
+	mov	$3,$21
+	ret	$31,($5)
+put_ureg22:
+	mov	$3,$22
+	ret	$31,($5)
+put_ureg23:
+	mov	$3,$23
+	ret	$31,($5)
+put_ureg24:
+	mov	$3,$24
+	ret	$31,($5)
+put_ureg25:
+	mov	$3,$25
+	ret	$31,($5)
+put_ureg26:
+	mov	$3,$26
+	ret	$31,($5)
+put_ureg27:
+	mov	$3,$27
+	ret	$31,($5)
+put_ureg28:
+	mov	$3,$28
+	ret	$31,($5)
+put_ureg29:
+	stq	$3,9*8($30)
+	ret	$31,($5)
+put_ureg30:
+	br	$31,put_user_sp 
+	ret	$31,($5)
+put_ureg31:
+	ret	$31,($5)
+.end	put_ureg_table
+
+/* this macro trashes $5 & index, and returns user reg val in $3 */
+#define get_user_reg(index)           \
+	br	$3,1f                 ;\
+1:	                              ;\
+	s8addq	index,$3,index        ;\
+	lda	$5,get_ureg0-1b($31)  ;\
+	addq	index,$5,index        ;\
+	jsr	$5,(index),get_ureg16
+
+/* this macro trashes $3, $5 & index, and takes new user reg val in $3 */
+#define put_user_reg(index)           \
+	br	$5,1f                 ;\
+1:	                              ;\
+	s8addq	index,$5,index        ;\
+	lda	$5,put_ureg0-1b($31)  ;\
+	addq	index,$5,index        ;\
+	jsr	$5,(index),put_ureg16
+
+.align 3
+.globl	emul_ldwu
+.ent	emul_ldwu
+emul_ldwu:
+	stq	$3,24($30)
+	stq	$4,32($30)
+	stq	$5,40($30)
+
+	srl	$0,21,$1
+	srl	$0,16,$2
+	and	$1,0x1f,$1
+	sll	$0,48,$0
+	and	$2,0x1f,$2
+	sra	$0,48,$0   /* $0 = disp */
+	get_user_reg($2)   /* $3 = Rb  */
+	addq	$0,$3,$0
+	ldq_u	$3,0($0)
+	ldq_u	$5,1($0)
+	extwl	$3,$0,$3
+	extwh	$5,$0,$5
+	or	$3,$5,$3
+	put_user_reg($1)
+
+	ldq	$5,40($30)
+	ldq	$4,32($30)
+	ldq	$3,24($30)
+	ldq	$2,16($30)
+	ldq	$1,8($30)
+	ldq	$0,0($30)
+	addq	$30,7*8,$30
+	call_pal PAL_rti
+.end	emul_ldwu
+
+.align 3
+.globl	emul_stw
+.ent	emul_stw
+emul_stw:
+	stq	$3,24($30)
+	stq	$4,32($30)
+	stq	$5,40($30)
+
+	srl	$0,21,$1
+	srl	$0,16,$2
+	and	$1,0x1f,$1
+	sll	$0,48,$0
+	and	$2,0x1f,$2
+	sra	$0,48,$0   /* $0 = disp */
+	get_user_reg($1)
+	mov	$3,$1
+	get_user_reg($2)   /* $3 = Rb  */
+	/* needs writing here */
+	addq	$0,$3,$0
+	ldq_u	$3,1($0)
+	ldq_u	$2,0($0)
+	inswh	$1,$0,$5
+	inswl	$1,$0,$4
+	mskwh	$3,$0,$3
+	mskwl	$2,$0,$2
+	or	$3,$5,$3
+	or	$2,$4,$2
+	stq_u	$3,1($0)
+	stq_u	$2,0($0)
+
+	ldq	$5,40($30)
+	ldq	$4,32($30)
+	ldq	$3,24($30)
+	ldq	$2,16($30)
+	ldq	$1,8($30)
+	ldq	$0,0($30)
+	addq	$30,7*8,$30
+	call_pal PAL_rti
+.end	emul_stw
+
+.align 3
+.globl	emul_ldbu
+.ent	emul_ldbu
+emul_ldbu:
+	stq	$3,24($30)
+	stq	$4,32($30)
+	stq	$5,40($30)
+
+	srl	$0,21,$1
+	srl	$0,16,$2
+	and	$1,0x1f,$1
+	sll	$0,48,$4
+	and	$2,0x1f,$2
+	sra	$4,48,$4   /* $0 = disp */
+	get_user_reg($2)   /* $3 = Rb  */
+	addq	$4,$3,$4
+	ldq_u	$3,0($4)
+	extbl	$3,$4,$3
+	put_user_reg($1)
+
+	ldq	$5,40($30)
+	ldq	$4,32($30)
+	ldq	$3,24($30)
+	ldq	$2,16($30)
+	ldq	$1,8($30)
+	ldq	$0,0($30)
+	addq	$30,7*8,$30
+	call_pal PAL_rti
+.end	emul_ldbu
+
+.align 3
+.globl	emul_stb
+.ent	emul_stb
+emul_stb:
+	stq	$3,24($30)
+	stq	$4,32($30)
+	stq	$5,40($30)
+
+	srl	$0,21,$1
+	srl	$0,16,$2
+	and	$1,0x1f,$1
+	sll	$0,48,$0
+	and	$2,0x1f,$2
+	sra	$0,48,$0   /* $0 = disp */
+	get_user_reg($1)
+	mov	$3,$1
+	get_user_reg($2)   /* $3 = Rb  */
+	addq	$0,$3,$0
+	ldq_u	$2,0($0)
+	insbl	$1,$0,$3
+	mskbl	$2,$0,$2
+
+	ldq	$5,40($30)
+	or	$2,$3,$2
+
+	ldq	$3,24($30)
+	stq_u	$2,0($0)
+
+	ldq	$2,16($30)
+	ldq	$1,8($30)
+	ldq	$0,0($30)
+	addq	$30,7*8,$30
+	call_pal PAL_rti
+.end	emul_stb
+
+.align 3
+.globl	emul_minsw_4
+.ent	emul_minsw_4
+emul_minsw_4:
+	stq	$6,48($30)
+
+	extwl	$3,0x6,$4 /* get word 3 of ra (most significant) -> $4 */
+	extwl	$2,0x6,$1 /* get word 3 of rb                    -> $2 */
+	cmple	$2,$3,$6
+	cmovne	$6,$1,$4
+
+	extwl	$3,0x4,$5 /* get word 2 of ra                    -> $5 */
+	extwl	$2,0x4,$1 /* get word 2 of rb                    -> $1 */
+	cmple	$2,$3,$6
+	sll	$4,16,$4
+	cmovne	$6,$1,$5
+	or	$4,$5,$4
+
+	extwl	$3,0x2,$5 /* get word 1 of ra                    -> $5 */
+	extwl	$2,0x2,$1 /* get word 1 of rb                    -> $1 */
+	cmple	$2,$3,$6
+	sll	$4,16,$4
+	cmovne	$6,$1,$5
+	or	$4,$5,$4
+
+	extwl	$3,0x0,$5 /* get word 1 of ra                    -> $5 */
+	extwl	$2,0x0,$1 /* get word 1 of rb                    -> $1 */
+	cmple	$2,$3,$6
+	sll	$4,16,$4
+	cmovne	$6,$1,$5
+	or	$4,$5,$3
+	
+	ldq	$6,48($30)
+
+	put_user_reg($0)
+
+	ldq	$5,40($30)
+	ldq	$4,32($30)
+	ldq	$3,24($30)
+	ldq	$2,16($30)
+	ldq	$1,8($30)
+	ldq	$0,0($30)
+	addq	$30,7*8,$30
+	call_pal PAL_rti
+.end	emul_minsw_4
+
+.align 3
+.globl	emul_minuw_4
+.ent	emul_minuw_4
+emul_minuw_4:
+	stq	$6,48($30)
+
+	extwl	$3,0x6,$4 /* get word 3 of ra (most significant) -> $4 */
+	extwl	$2,0x6,$1 /* get word 3 of rb                    -> $2 */
+	cmpule	$2,$3,$6
+	cmovne	$6,$1,$4
+
+	extwl	$3,0x4,$5 /* get word 2 of ra                    -> $5 */
+	extwl	$2,0x4,$1 /* get word 2 of rb                    -> $1 */
+	cmpule	$2,$3,$6
+	sll	$4,16,$4
+	cmovne	$6,$1,$5
+	or	$4,$5,$4
+
+	extwl	$3,0x2,$5 /* get word 1 of ra                    -> $5 */
+	extwl	$2,0x2,$1 /* get word 1 of rb                    -> $1 */
+	cmpule	$2,$3,$6
+	sll	$4,16,$4
+	cmovne	$6,$1,$5
+	or	$4,$5,$4
+
+	extwl	$3,0x0,$5 /* get word 1 of ra                    -> $5 */
+	extwl	$2,0x0,$1 /* get word 1 of rb                    -> $1 */
+	cmpule	$2,$3,$6
+	sll	$4,16,$4
+	cmovne	$6,$1,$5
+	or	$4,$5,$3
+	
+	ldq	$6,48($30)
+
+	put_user_reg($0)
+
+	ldq	$5,40($30)
+	ldq	$4,32($30)
+	ldq	$3,24($30)
+	ldq	$2,16($30)
+	ldq	$1,8($30)
+	ldq	$0,0($30)
+	addq	$30,7*8,$30
+	call_pal PAL_rti
+.end	emul_minuw_4
+
+.align 3
+.globl	emul_maxsw_4
+.ent	emul_maxsw_4
+emul_maxsw_4:
+	stq	$6,48($30)
+
+	extwl	$3,0x6,$4 /* get word 3 of ra (most significant) -> $4 */
+	extwl	$2,0x6,$1 /* get word 3 of rb                    -> $2 */
+	cmple	$4,$1,$6
+	cmovne	$6,$1,$4
+
+	extwl	$3,0x4,$5 /* get word 2 of ra                    -> $5 */
+	extwl	$2,0x4,$1 /* get word 2 of rb                    -> $1 */
+	cmple	$5,$1,$6
+	sll	$4,16,$4
+	cmovne	$6,$1,$5
+	or	$4,$5,$4
+
+	extwl	$3,0x2,$5 /* get word 1 of ra                    -> $5 */
+	extwl	$2,0x2,$1 /* get word 1 of rb                    -> $1 */
+	cmple	$5,$1,$6
+	sll	$4,16,$4
+	cmovne	$6,$1,$5
+	or	$4,$5,$4
+
+	extwl	$3,0x0,$5 /* get word 1 of ra                    -> $5 */
+	extwl	$2,0x0,$1 /* get word 1 of rb                    -> $1 */
+	cmple	$5,$1,$6
+	sll	$4,16,$4
+	cmovne	$6,$1,$5
+	or	$4,$5,$3
+	
+	ldq	$6,48($30)
+
+	put_user_reg($0)
+
+	ldq	$5,40($30)
+	ldq	$4,32($30)
+	ldq	$3,24($30)
+	ldq	$2,16($30)
+	ldq	$1,8($30)
+	ldq	$0,0($30)
+	addq	$30,7*8,$30
+	call_pal PAL_rti
+.end	emul_maxsw_4
+
+.align 3
+.globl	emul_maxuw_4
+.ent	emul_maxuw_4
+emul_maxuw_4:
+	stq	$6,48($30)
+
+	extwl	$3,0x6,$4 /* get word 3 of ra (most significant) -> $4 */
+	extwl	$2,0x6,$1 /* get word 3 of rb                    -> $2 */
+	cmpule	$4,$1,$6
+	cmovne	$6,$1,$4
+
+	extwl	$3,0x4,$5 /* get word 2 of ra                    -> $5 */
+	extwl	$2,0x4,$1 /* get word 2 of rb                    -> $1 */
+	cmpule	$5,$1,$6
+	sll	$4,16,$4
+	cmovne	$6,$1,$5
+	or	$4,$5,$4
+
+	extwl	$3,0x2,$5 /* get word 1 of ra                    -> $5 */
+	extwl	$2,0x2,$1 /* get word 1 of rb                    -> $1 */
+	cmpule	$5,$1,$6
+	sll	$4,16,$4
+	cmovne	$6,$1,$5
+	or	$4,$5,$4
+
+	extwl	$3,0x0,$5 /* get word 1 of ra                    -> $5 */
+	extwl	$2,0x0,$1 /* get word 1 of rb                    -> $1 */
+	cmpule	$5,$1,$6
+	sll	$4,16,$4
+	cmovne	$6,$1,$5
+	or	$4,$5,$3
+	
+	ldq	$6,48($30)
+
+	put_user_reg($0)
+
+	ldq	$5,40($30)
+	ldq	$4,32($30)
+	ldq	$3,24($30)
+	ldq	$2,16($30)
+	ldq	$1,8($30)
+	ldq	$0,0($30)
+	addq	$30,7*8,$30
+	call_pal PAL_rti
+.end	emul_maxuw_4
+
+.align 3
+.globl	emul_maxub_8
+.ent	emul_maxub_8
+emul_maxub_8:
+	cmpbge	$2,$3,$1
+	zap	$3,$1,$3
+	zapnot	$2,$1,$2
+	or	$3,$2,$3
+	put_user_reg($0)
+
+	ldq	$5,40($30)
+	ldq	$4,32($30)
+	ldq	$3,24($30)
+	ldq	$2,16($30)
+	ldq	$1,8($30)
+	ldq	$0,0($30)
+	addq	$30,7*8,$30
+	call_pal PAL_rti
+.end	emul_maxub_8
+
+.align 3
+.globl	emul_maxub_8
+.ent	emul_maxub_8
+emul_maxsb_8:
+	lda	$1,0x7f7f($31)
+	ldah	$1,0x7f7f($1)
+	sll	$1,32,$5
+	or	$1,$5,$1
+	not	$1,$1
+	xor	$3,$1,$5
+	xor	$2,$1,$1
+
+	cmpbge	$1,$5,$1
+	zap	$3,$1,$3
+	zapnot	$2,$1,$2
+	or	$3,$2,$3
+	put_user_reg($0)
+
+	ldq	$5,40($30)
+	ldq	$4,32($30)
+	ldq	$3,24($30)
+	ldq	$2,16($30)
+	ldq	$1,8($30)
+	ldq	$0,0($30)
+	addq	$30,7*8,$30
+	call_pal PAL_rti
+.end	emul_maxub_8
+
+.align 3
+.globl	emul_minub_8
+.ent	emul_minub_8
+emul_minub_8:
+	cmpbge	$3,$2,$1
+	zap	$3,$1,$3
+	zapnot	$2,$1,$2
+	or	$3,$2,$3
+	put_user_reg($0)
+
+	ldq	$5,40($30)
+	ldq	$4,32($30)
+	ldq	$3,24($30)
+	ldq	$2,16($30)
+	ldq	$1,8($30)
+	ldq	$0,0($30)
+	addq	$30,7*8,$30
+	call_pal PAL_rti
+.end	emul_minub_8
+
+.align 3
+.globl	emul_minsb_8
+.ent	emul_minsb_8
+emul_minsb_8:
+	lda	$1,0x7f7f($31)
+	ldah	$1,0x7f7f($1)
+	sll	$1,32,$5
+	or	$1,$5,$1
+	not	$1,$1
+	xor	$3,$1,$5
+	xor	$2,$1,$1
+
+	cmpbge	$5,$1,$1
+	zap	$3,$1,$3
+	zapnot	$2,$1,$2
+	or	$3,$2,$3
+	put_user_reg($0)
+
+	ldq	$5,40($30)
+	ldq	$4,32($30)
+	ldq	$3,24($30)
+	ldq	$2,16($30)
+	ldq	$1,8($30)
+	ldq	$0,0($30)
+	addq	$30,7*8,$30
+	call_pal PAL_rti
+.end	emul_minsb_8
+
+.align 3
+.globl	emul_sexw
+.ent	emul_sexw
+emul_sexw:
+	sll	$3,48,$3
+	and	$0,0x1f,$1
+	sra	$3,48,$3
+	put_user_reg($1)
+	ldq	$5,40($30)
+	ldq	$4,32($30)
+	ldq	$3,24($30)
+	ldq	$2,16($30)
+	ldq	$1,8($30)
+	ldq	$0,0($30)
+	addq	$30,7*8,$30
+	call_pal PAL_rti
+.end	emul_sexw
+
+.align 3
+.globl	emul_sexb
+.ent	emul_sexb
+emul_sexb:
+	sll	$3,56,$3
+	and	$0,0x1f,$1
+	sra	$3,56,$3
+	put_user_reg($1)
+	ldq	$5,40($30)
+	ldq	$4,32($30)
+	ldq	$3,24($30)
+	ldq	$2,16($30)
+	ldq	$1,8($30)
+	ldq	$0,0($30)
+	addq	$30,7*8,$30
+	call_pal PAL_rti
+.end	emul_sexb
+
+.align 3
+.globl	emul_mmx
+.ent	emul_mmx
+emul_mmx:
+	stq	$3,24($30)
+	stq	$4,32($30)
+	stq	$5,40($30)
+
+	srl	$0,5,$4
+	srl	$0,12,$2
+	and	$4,0x3f,$4
+	blbs	$2,21f
+	srl	$0,16,$1
+	and	$1,0x1f,$1
+	get_user_reg($1)
+21:
+	srl	$0,13,$1
+	and	$1,0xff,$1
+	cmovlbs	$2,$1,$3
+	/* now:	$0 = insn
+		$3 = regb val
+		$4 = operation function code */
+	cmpeq	$4,0x1,$2
+	beq	$4,emul_sexb
+	bne	$2,emul_sexw
+	srl	$0,21,$1
+	mov	$3,$2
+	and	$1,0x1f,$1
+	get_user_reg($1)
+	cmpeq	$4,0x3a,$1
+	cmpeq	$4,0x38,$5
+	and	$0,0x1f,$0
+	/* now:	$0 = rc index
+		$2 = rb val
+		$3 = ra val
+		$4 = operation function code */
+	bne	$1,emul_minub_8
+	bne	$5,emul_minsb_8
+	cmpeq	$4,0x3e,$1
+	cmpeq	$4,0x3c,$5
+	bne	$1,emul_maxsb_8
+	bne	$5,emul_maxub_8
+	cmpeq	$4,0x39,$1
+	cmpeq	$4,0x3f,$5
+	bne	$1,emul_minsw_4
+	bne	$5,emul_maxsw_4
+	cmpeq	$4,0x3b,$1
+	cmpeq	$4,0x3d,$5
+	bne	$1,emul_minuw_4
+	bne	$5,emul_maxuw_4
+	ldq	$5,40($30)
+	ldq	$4,32($30)
+	ldq	$3,24($30)
+	ldq	$2,16($30)
+	ldq	$1,8($30)
+	ldq	$0,0($30)
+	addq	$30,7*8,$30
+	br	old_entIF
+.end	emul_mmx
+
+#endif /* CONFIG_ALPHA_EXTINSNS */
+
 .align 3
 .globl	entIF
 .ent	entIF
 entIF:
+#ifdef CONFIG_ALPHA_EXTINSNS
+	subq	$30,7*8,$30 /* 3 regs saved here, 3 or 4 more saved in fns */
+	stq	$0,0($30)
+	ldq	$0,8+7*8($30)
+	stq	$1,8($30)
+	ldl	$0,-4($0)
+	stq	$2,16($30)
+	srl	$0,26,$1
+	and	$1,0x3f,$1
+	cmpeq	$1,0x1c,$2
+	bne	$2,emul_mmx
+	cmpeq	$1,0x0a,$2
+	bne	$2,emul_ldbu
+	cmpeq	$1,0x0e,$2
+	bne	$2,emul_stb
+	cmpeq	$1,0x0c,$2
+	cmpeq	$1,0x0d,$1
+	bne	$2,emul_ldwu
+	bne	$1,emul_stw
+	ldq	$0,0($30)
+	ldq	$1,8($30)
+	ldq	$2,16($30)
+	addq	$30,7*8,$30
+old_entIF:
+#endif /* CONFIG_ALPHA_EXTINSNS */
 	SAVE_ALL
 	lda	$8,0x3fff
 	lda	$26,ret_from_sys_call

^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: PATCH: (on Alpha) emulating missing instructions
@ 1999-10-15 10:03 Lennart Börjeson
  1999-10-15 10:55 ` Daniel Potts
  1999-10-15 14:19 ` Kirk R. Erichsen
  0 siblings, 2 replies; 12+ messages in thread
From: Lennart Börjeson @ 1999-10-15 10:03 UTC (permalink / raw)
  To: 'axp-list@redhat.com'

Eminently done, but I was really under the impression that these exceptions
should be handled by the PALcode (since it is really a general Alpha
problem, not Linux-specific)? Is this not so (i.e. are we missing some
PALcode update) or is it solved differently in different OSes?

-----Original Message-----
From: Luke Deller [mailto:luked@cse.unsw.edu.au]
Sent: Friday, October 15, 1999 11:39 AM
To: axp-list@redhat.com
Cc: axp-list@redhat.com; Daniel Paul Potts
Subject: PATCH: (on Alpha) emulating missing instructions


Daniel & I tried to run Loki's new beta version of Civilization Call to
Power for alpha linux on a multia (ev4 alpha).  We got an illegal
instruction exception.  We discovered that it was compiled for ev6, and so
contained instructions not supported by our CPU.

So we have patched the linux kernel to emulate the instructions we needed.
These instructions are:
- byte/word load/store instructions (ldbu,stb,ldwu,stw)
- some multimedia instructions (minsw, maxsw, minuw, maxuw, minsb, maxsb,
  minub, maxub)

We have tried to make the emulation fairly fast - we have added it as some
assembly language code to the "illegal instruction exception" kernel entry
point in arch/alpha/kernel/entry.S:entIF.  (Of course it's still faster
to avoid emulation and use a binary compiled for your generation of alpha
cpu).

We put an option for enabling it in the "Kernel Hacking" section of the
configuration.

The patch is applied to kernel version 2.2.11
(Loki say not to use 2.2.12 for Civilization CTP) 

We only wrote enough emulation code to get CivilizationCTP to run ..  in the
future it would be cool to see emulation of a more complete set of
instructions in the kernel.

Hope this is useful to somebody,

Luke Deller & Daniel Potts.

--------------------------------------------------------------------------
           Luke Deller                               luked@cse.unsw.edu.au
 _--_|\    Computer Engineering student           
/      \   School of Computer Science and Engineering     ? ? ? ?        
\_.--._*   The University of New South Wales               ~~^^~  
      v    Sydney, NSW     2052    AUSTRALIA                o o
-------------------------------------------------------ooO--(_)--Ooo------


^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: PATCH: (on Alpha) emulating missing instructions
  1999-10-15 10:03 PATCH: (on Alpha) emulating missing instructions Lennart Börjeson
@ 1999-10-15 10:55 ` Daniel Potts
  1999-10-15 14:19 ` Kirk R. Erichsen
  1 sibling, 0 replies; 12+ messages in thread
From: Daniel Potts @ 1999-10-15 10:55 UTC (permalink / raw)
  To: 'axp-list@redhat.com'

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: TEXT/PLAIN; charset=US-ASCII, Size: 3265 bytes --]


We decided not to change the PALcode for several reasons. The main one
being that we would have to change it for various different PALcodes and
it is something that shouldn't be there anyway. Further more this might
result in having to change PALcode stored in BIOS if you dont use MILO
for example.... list does on. Another important point, someone might want
to manage this in userland so putting it in PALcode is a no no.

The code is in an alpha specific portion of Linux, before the fp
completion stuff.

On Fri, 15 Oct 1999, [windows-1252] Lennart Börjeson wrote:

> Eminently done, but I was really under the impression that these exceptions
> should be handled by the PALcode (since it is really a general Alpha
> problem, not Linux-specific)? Is this not so (i.e. are we missing some
> PALcode update) or is it solved differently in different OSes?
> 
> -----Original Message-----
> From: Luke Deller [mailto:luked@cse.unsw.edu.au]
> Sent: Friday, October 15, 1999 11:39 AM
> To: axp-list@redhat.com
> Cc: axp-list@redhat.com; Daniel Paul Potts
> Subject: PATCH: (on Alpha) emulating missing instructions
> 
> 
> Daniel & I tried to run Loki's new beta version of Civilization Call to
> Power for alpha linux on a multia (ev4 alpha).  We got an illegal
> instruction exception.  We discovered that it was compiled for ev6, and so
> contained instructions not supported by our CPU.
> 
> So we have patched the linux kernel to emulate the instructions we needed.
> These instructions are:
> - byte/word load/store instructions (ldbu,stb,ldwu,stw)
> - some multimedia instructions (minsw, maxsw, minuw, maxuw, minsb, maxsb,
>   minub, maxub)
> 
> We have tried to make the emulation fairly fast - we have added it as some
> assembly language code to the "illegal instruction exception" kernel entry
> point in arch/alpha/kernel/entry.S:entIF.  (Of course it's still faster
> to avoid emulation and use a binary compiled for your generation of alpha
> cpu).
> 
> We put an option for enabling it in the "Kernel Hacking" section of the
> configuration.
> 
> The patch is applied to kernel version 2.2.11
> (Loki say not to use 2.2.12 for Civilization CTP) 
> 
> We only wrote enough emulation code to get CivilizationCTP to run ..  in the
> future it would be cool to see emulation of a more complete set of
> instructions in the kernel.
> 
> Hope this is useful to somebody,
> 
> Luke Deller & Daniel Potts.
> 
> --------------------------------------------------------------------------
>            Luke Deller                               luked@cse.unsw.edu.au
>  _--_|\    Computer Engineering student           
> /      \   School of Computer Science and Engineering     ? ? ? ?        
> \_.--._*   The University of New South Wales               ~~^^~  
>       v    Sydney, NSW     2052    AUSTRALIA                o o
> -------------------------------------------------------ooO--(_)--Ooo------
> 
> -- 
> To unsubscribe: send e-mail to axp-list-request@redhat.com with
> 'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com
> 

--
Email: danielp@cse.unsw.edu.au
Pager: danielp.sms@cse.unsw.edu.au
http://www.cse.unsw.edu.au/~danielp
----->
 ^Switch




^ permalink raw reply	[flat|nested] 12+ messages in thread

* PATCH: (on Alpha) emulating missing instructions
  1999-10-15  9:30 Luke Deller
@ 1999-10-15 12:42 ` Eric Bohm
  1999-10-15 15:02   ` Luke Deller
  1999-10-15 14:28 ` Michal Jaegermann
  1 sibling, 1 reply; 12+ messages in thread
From: Eric Bohm @ 1999-10-15 12:42 UTC (permalink / raw)
  To: axp-list; +Cc: linux-kernel, Daniel Paul Potts

>>>>> "Luke" == Luke Deller <luked@cse.unsw.edu.au> writes:

    Luke> Daniel & I tried to run Loki's new beta version of
    Luke> Civilization Call to Power for alpha linux on a multia (ev4
    Luke> alpha).  We got an illegal instruction exception.  We
    Luke> discovered that it was compiled for ev6, and so contained
    Luke> instructions not supported by our CPU.

    Luke> So we have patched the linux kernel to emulate the
    Luke> instructions we needed.  These instructions are: - byte/word
    Luke> load/store instructions (ldbu,stb,ldwu,stw) - some
    Luke> multimedia instructions (minsw, maxsw, minuw, maxuw, minsb,
    Luke> maxsb, minub, maxub)

Good work.

The same problem happens on my EV56.  Would you expect your patch to
work there also?  Or are there EV5 elements that I should expect
to be issues?


^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: PATCH: (on Alpha) emulating missing instructions
  1999-10-15 10:03 PATCH: (on Alpha) emulating missing instructions Lennart Börjeson
  1999-10-15 10:55 ` Daniel Potts
@ 1999-10-15 14:19 ` Kirk R. Erichsen
  1999-10-15 14:36   ` Peter Rival
  1 sibling, 1 reply; 12+ messages in thread
From: Kirk R. Erichsen @ 1999-10-15 14:19 UTC (permalink / raw)
  To: axp-list

You better believe we are missing PALcode updates.  The PALcode in MILO
dates back to the EB series machines and was part of the EBSDK.  The
PALcode was built from examples from the SDK and are fairly close to the
Digital UNIX 3.2 versions.  There are a lot of unimplemented functions and
it is quite old.  If Compaq is serious about Alpha, we need PALcode
updates, not more kernel hacks.
The fact that Linux works over Alpha at all is in spite of, not because of
support from Compaq.

--Kirk

At 12:03 PM 10/15/99 +0200, you wrote:
>Eminently done, but I was really under the impression that these exceptions
>should be handled by the PALcode (since it is really a general Alpha
>problem, not Linux-specific)? Is this not so (i.e. are we missing some
>PALcode update) or is it solved differently in different OSes?
>
>-----Original Message-----
>From: Luke Deller [mailto:luked@cse.unsw.edu.au]
>Sent: Friday, October 15, 1999 11:39 AM
>To: axp-list@redhat.com
>Cc: axp-list@redhat.com; Daniel Paul Potts
>Subject: PATCH: (on Alpha) emulating missing instructions
>
>
>Daniel & I tried to run Loki's new beta version of Civilization Call to
>Power for alpha linux on a multia (ev4 alpha).  We got an illegal
>instruction exception.  We discovered that it was compiled for ev6, and so
>contained instructions not supported by our CPU.
>
>So we have patched the linux kernel to emulate the instructions we needed.
>These instructions are:
>- byte/word load/store instructions (ldbu,stb,ldwu,stw)
>- some multimedia instructions (minsw, maxsw, minuw, maxuw, minsb, maxsb,
>  minub, maxub)
>
>We have tried to make the emulation fairly fast - we have added it as some
>assembly language code to the "illegal instruction exception" kernel entry
>point in arch/alpha/kernel/entry.S:entIF.  (Of course it's still faster
>to avoid emulation and use a binary compiled for your generation of alpha
>cpu).
>
>We put an option for enabling it in the "Kernel Hacking" section of the
>configuration.
>
>The patch is applied to kernel version 2.2.11
>(Loki say not to use 2.2.12 for Civilization CTP) 
>
>We only wrote enough emulation code to get CivilizationCTP to run ..  in the
>future it would be cool to see emulation of a more complete set of
>instructions in the kernel.
>
>Hope this is useful to somebody,
>
>Luke Deller & Daniel Potts.
>
>--------------------------------------------------------------------------
>           Luke Deller                               luked@cse.unsw.edu.au
> _--_|\    Computer Engineering student           
>/      \   School of Computer Science and Engineering     ? ? ? ?        
>\_.--._*   The University of New South Wales               ~~^^~  
>      v    Sydney, NSW     2052    AUSTRALIA                o o
>-------------------------------------------------------ooO--(_)--Ooo------
>
>-- 
>To unsubscribe: send e-mail to axp-list-request@redhat.com with
>'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com
>
>


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: PATCH: (on Alpha) emulating missing instructions
  1999-10-15  9:30 Luke Deller
  1999-10-15 12:42 ` Eric Bohm
@ 1999-10-15 14:28 ` Michal Jaegermann
  1 sibling, 0 replies; 12+ messages in thread
From: Michal Jaegermann @ 1999-10-15 14:28 UTC (permalink / raw)
  To: axp-list

On Fri, Oct 15, 1999 at 07:30:21PM +1000, Luke Deller wrote:
> (Loki say not to use 2.2.12 for Civilization CTP) 

Any ideas if this is because of the same floating point issues
which trip em86?  Or they run into something else?

Warning!  Unpatched 2.2.11 has very nasty memory leaks.

  Michal


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: PATCH: (on Alpha) emulating missing instructions
  1999-10-15 14:19 ` Kirk R. Erichsen
@ 1999-10-15 14:36   ` Peter Rival
  0 siblings, 0 replies; 12+ messages in thread
From: Peter Rival @ 1999-10-15 14:36 UTC (permalink / raw)
  To: axp-list

Well, to answer his question, it's not a PALcode thing - Tru64 emulates the
instructions in the same way this patch intends to.  Otherwise the simple answer
would be "use SRM" as it is always up to the latest firmware/PALcode rev (if you
keep up with it).

That brings us to something better - with the rumored (I'm not in a position at
Compaq to know) demise of AlphaBIOS/ARC, what kind of base does that give MILO
to work from?  If you're particularly worried, work on getting MILO happy with
SRM, and know then that you are working from the latest PALcode.  I know it's
not that simple, but I'm hoping that you see where I'm going.

While I will say that Compaq has done a lot to help make Linux on Alpha work, I
will also admit that there is a _lot_ more that we could do.  Working
through/with issues like this should probably rank high on that list.  If you
think you know of good things that Compaq can do to make AlphaLinux work better
(or in some cases just "work"...but we won't go into that rant...) try to get
someone "up the ladder" to send mail to Michael Capellas or Enrico Pesatori or
Bill Heill (or all three).  Mail directly from customers with an expressed
interest in buying Alpha systems if only Compaq did XYZ has a lot more pull than
sending it to axp-list and hoping that a developer can manage to get it up the
chain without the message getting distorted.  Something like "there's this
customer that said they might think about buying Alpha systems for Linux if we
just do blah" really sounds wimpy.

Just like Linux, if we all work together everything gets better.  I guess that
would be my equivalent of Linus saying "code it up and we'll see".  I want
things to be where you the customer think they need to be...and it _will_
happen.  End of story.  (and rant ;)

 - Pete

"Kirk R. Erichsen" wrote:

> You better believe we are missing PALcode updates.  The PALcode in MILO
> dates back to the EB series machines and was part of the EBSDK.  The
> PALcode was built from examples from the SDK and are fairly close to the
> Digital UNIX 3.2 versions.  There are a lot of unimplemented functions and
> it is quite old.  If Compaq is serious about Alpha, we need PALcode
> updates, not more kernel hacks.
> The fact that Linux works over Alpha at all is in spite of, not because of
> support from Compaq.
>
> --Kirk
>
> At 12:03 PM 10/15/99 +0200, you wrote:
> >Eminently done, but I was really under the impression that these exceptions
> >should be handled by the PALcode (since it is really a general Alpha
> >problem, not Linux-specific)? Is this not so (i.e. are we missing some
> >PALcode update) or is it solved differently in different OSes?
> >
> >-----Original Message-----
> >From: Luke Deller [mailto:luked@cse.unsw.edu.au]
> >Sent: Friday, October 15, 1999 11:39 AM
> >To: axp-list@redhat.com
> >Cc: axp-list@redhat.com; Daniel Paul Potts
> >Subject: PATCH: (on Alpha) emulating missing instructions
> >
> >
> >Daniel & I tried to run Loki's new beta version of Civilization Call to
> >Power for alpha linux on a multia (ev4 alpha).  We got an illegal
> >instruction exception.  We discovered that it was compiled for ev6, and so
> >contained instructions not supported by our CPU.
> >
> >So we have patched the linux kernel to emulate the instructions we needed.
> >These instructions are:
> >- byte/word load/store instructions (ldbu,stb,ldwu,stw)
> >- some multimedia instructions (minsw, maxsw, minuw, maxuw, minsb, maxsb,
> >  minub, maxub)
> >
> >We have tried to make the emulation fairly fast - we have added it as some
> >assembly language code to the "illegal instruction exception" kernel entry
> >point in arch/alpha/kernel/entry.S:entIF.  (Of course it's still faster
> >to avoid emulation and use a binary compiled for your generation of alpha
> >cpu).
> >
> >We put an option for enabling it in the "Kernel Hacking" section of the
> >configuration.
> >
> >The patch is applied to kernel version 2.2.11
> >(Loki say not to use 2.2.12 for Civilization CTP)
> >
> >We only wrote enough emulation code to get CivilizationCTP to run ..  in the
> >future it would be cool to see emulation of a more complete set of
> >instructions in the kernel.
> >
> >Hope this is useful to somebody,
> >
> >Luke Deller & Daniel Potts.
> >
> >--------------------------------------------------------------------------
> >           Luke Deller                               luked@cse.unsw.edu.au
> > _--_|\    Computer Engineering student
> >/      \   School of Computer Science and Engineering     ? ? ? ?
> >\_.--._*   The University of New South Wales               ~~^^~
> >      v    Sydney, NSW     2052    AUSTRALIA                o o
> >-------------------------------------------------------ooO--(_)--Ooo------
> >
> >--
> >To unsubscribe: send e-mail to axp-list-request@redhat.com with
> >'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com
> >
> >
>
> --
> To unsubscribe: send e-mail to axp-list-request@redhat.com with
> 'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com


^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: PATCH: (on Alpha) emulating missing instructions
@ 1999-10-15 14:39 Jemiolo, John
  1999-10-15 20:05 ` Paul Jakma
  0 siblings, 1 reply; 12+ messages in thread
From: Jemiolo, John @ 1999-10-15 14:39 UTC (permalink / raw)
  To: 'axp-list@redhat.com'

Which is why you should use SRM Unix, if its available on your platform,
Instead of (ARC or AlphaBios)  milo.  With SRM the palcode is updated with
the firmware update releases (If needed).

I know this is a problem for the old NT-only systems which only have ARC or
AlphaBios, but this is not true for current stuff, even the NT only
white-box (33XX, 53XX, 73XX) systems have SRM, they just can't run unix or
VMS, but run linux just fine (from SRM).

JJ


-----Original Message-----
From: Kirk R. Erichsen [mailto:kirke@inteli-home.com]
Sent: Friday, October 15, 1999 10:20 AM
To: axp-list@redhat.com
Subject: RE: PATCH: (on Alpha) emulating missing instructions


You better believe we are missing PALcode updates.  The PALcode in MILO
dates back to the EB series machines and was part of the EBSDK.  The
PALcode was built from examples from the SDK and are fairly close to the
Digital UNIX 3.2 versions.  There are a lot of unimplemented functions and
it is quite old.  If Compaq is serious about Alpha, we need PALcode
updates, not more kernel hacks.
The fact that Linux works over Alpha at all is in spite of, not because of
support from Compaq.

--Kirk

At 12:03 PM 10/15/99 +0200, you wrote:
>Eminently done, but I was really under the impression that these exceptions
>should be handled by the PALcode (since it is really a general Alpha
>problem, not Linux-specific)? Is this not so (i.e. are we missing some
>PALcode update) or is it solved differently in different OSes?
>
>-----Original Message-----
>From: Luke Deller [mailto:luked@cse.unsw.edu.au]
>Sent: Friday, October 15, 1999 11:39 AM
>To: axp-list@redhat.com
>Cc: axp-list@redhat.com; Daniel Paul Potts
>Subject: PATCH: (on Alpha) emulating missing instructions
>
>
>Daniel & I tried to run Loki's new beta version of Civilization Call to
>Power for alpha linux on a multia (ev4 alpha).  We got an illegal
>instruction exception.  We discovered that it was compiled for ev6, and so
>contained instructions not supported by our CPU.
>
>So we have patched the linux kernel to emulate the instructions we needed.
>These instructions are:
>- byte/word load/store instructions (ldbu,stb,ldwu,stw)
>- some multimedia instructions (minsw, maxsw, minuw, maxuw, minsb, maxsb,
>  minub, maxub)
>
>We have tried to make the emulation fairly fast - we have added it as some
>assembly language code to the "illegal instruction exception" kernel entry
>point in arch/alpha/kernel/entry.S:entIF.  (Of course it's still faster
>to avoid emulation and use a binary compiled for your generation of alpha
>cpu).
>
>We put an option for enabling it in the "Kernel Hacking" section of the
>configuration.
>
>The patch is applied to kernel version 2.2.11
>(Loki say not to use 2.2.12 for Civilization CTP) 
>
>We only wrote enough emulation code to get CivilizationCTP to run ..  in
the
>future it would be cool to see emulation of a more complete set of
>instructions in the kernel.
>
>Hope this is useful to somebody,
>
>Luke Deller & Daniel Potts.
>
>--------------------------------------------------------------------------
>           Luke Deller                               luked@cse.unsw.edu.au
> _--_|\    Computer Engineering student           
>/      \   School of Computer Science and Engineering     ? ? ? ?        
>\_.--._*   The University of New South Wales               ~~^^~  
>      v    Sydney, NSW     2052    AUSTRALIA                o o
>-------------------------------------------------------ooO--(_)--Ooo------
>
>-- 
>To unsubscribe: send e-mail to axp-list-request@redhat.com with
>'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com
>
>

-- 
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: PATCH: (on Alpha) emulating missing instructions
  1999-10-15 12:42 ` Eric Bohm
@ 1999-10-15 15:02   ` Luke Deller
  1999-10-16  4:10     ` Eric Bohm
  0 siblings, 1 reply; 12+ messages in thread
From: Luke Deller @ 1999-10-15 15:02 UTC (permalink / raw)
  To: Eric Bohm; +Cc: axp-list, linux-kernel, Daniel Paul Potts

On Fri, 15 Oct 1999, Eric Bohm wrote:

> >>>>> "Luke" == Luke Deller <luked@cse.unsw.edu.au> writes:
> 
>     Luke> Daniel & I tried to run Loki's new beta version of
>     Luke> Civilization Call to Power for alpha linux on a multia (ev4
>     Luke> alpha).  We got an illegal instruction exception.  We
>     Luke> discovered that it was compiled for ev6, and so contained
>     Luke> instructions not supported by our CPU.
> 
>     Luke> So we have patched the linux kernel to emulate the
>     Luke> instructions we needed.  These instructions are: - byte/word
>     Luke> load/store instructions (ldbu,stb,ldwu,stw) - some
>     Luke> multimedia instructions (minsw, maxsw, minuw, maxuw, minsb,
>     Luke> maxsb, minub, maxub)
> 
> Good work.
> 
> The same problem happens on my EV56.  Would you expect your patch to
> work there also?  Or are there EV5 elements that I should expect
> to be issues?

I think that ev56 supports the byte/word load/store instructions, but it is
still missing the multimedia instructions (minsw etc).  I would expect that
ev56 users could also use this patch.  Let me know if it works ok :-)

--------------------------------------------------------------------------
           Luke Deller                               luked@cse.unsw.edu.au
 _--_|\    Computer Engineering student           
/      \   School of Computer Science and Engineering     ? ? ? ?        
\_.--._*   The University of New South Wales               ~~^^~  
      v    Sydney, NSW     2052    AUSTRALIA                o o
-------------------------------------------------------ooO--(_)--Ooo------


^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: PATCH: (on Alpha) emulating missing instructions
  1999-10-15 14:39 Jemiolo, John
@ 1999-10-15 20:05 ` Paul Jakma
  1999-10-15 20:08   ` Greg Lindahl
  0 siblings, 1 reply; 12+ messages in thread
From: Paul Jakma @ 1999-10-15 20:05 UTC (permalink / raw)
  To: 'axp-list@redhat.com'

On Fri, 15 Oct 1999, Jemiolo, John wrote:

  Which is why you should use SRM Unix, if its available on your platform,

And if it's not? eg UX. What then?

It'd be nice to standardise on SRM. Compaq just need to make it
available. As someone else pointed out today, Compaq Alpha Linux
customers need to make their views re: importance of Open SRM to
future of Alpha known to Compaq. Similarly for API customers - tell
API that SRM is what you want to see on API boards.

They'll get the message eventually. 

regards,
-- 
Paul Jakma	paul@clubi.ie
PGP5 key: http://www.clubi.ie/jakma/publickey.txt
-------------------------------------------
Fortune:
news: gotcha

(a compaq employee by day, but with no connections to Alpha or Tru64
engineering. 'Tis now night so these opinions are my own).


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: PATCH: (on Alpha) emulating missing instructions
  1999-10-15 20:05 ` Paul Jakma
@ 1999-10-15 20:08   ` Greg Lindahl
  0 siblings, 0 replies; 12+ messages in thread
From: Greg Lindahl @ 1999-10-15 20:08 UTC (permalink / raw)
  To: axp-list

> Similarly for API customers - tell
> API that SRM is what you want to see on API boards.

I suspect that they already got the message.

-- g


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: PATCH: (on Alpha) emulating missing instructions
  1999-10-15 15:02   ` Luke Deller
@ 1999-10-16  4:10     ` Eric Bohm
  0 siblings, 0 replies; 12+ messages in thread
From: Eric Bohm @ 1999-10-16  4:10 UTC (permalink / raw)
  To: axp-list

>>>>> "Luke" == Luke Deller <luked@cse.unsw.edu.au> writes:

    Luke> On Fri, 15 Oct 1999, Eric Bohm wrote:
    >> >>>>> "Luke" == Luke Deller <luked@cse.unsw.edu.au> writes:
    >> 
    Luke> Daniel & I tried to run Loki's new beta version of
    Luke> Civilization Call to Power for alpha linux on a multia (ev4
    Luke> alpha).  We got an illegal instruction exception.  We
    Luke> discovered that it was compiled for ev6, and so contained
    Luke> instructions not supported by our CPU.
    >>
    Luke> So we have patched the linux kernel to emulate the
    Luke> instructions we needed.  These instructions are: - byte/word
    Luke> load/store instructions (ldbu,stb,ldwu,stw) - some
    Luke> multimedia instructions (minsw, maxsw, minuw, maxuw, minsb,
    Luke> maxsb, minub, maxub)
    Eric> Good work.

    Eric> The same problem happens on my EV56.  Would you expect your
    Eric> patch to work there also?  Or are there EV5 elements that I
    Eric> should expect to be issues?

    Luke> I think that ev56 supports the byte/word load/store
    Luke> instructions, but it is still missing the multimedia
    Luke> instructions (minsw etc).  I would expect that ev56 users
    Luke> could also use this patch.  Let me know if it works ok :-)

It is working quite well here in my LX164.

Thank you very much.





^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~1999-10-16  4:10 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-10-15 10:03 PATCH: (on Alpha) emulating missing instructions Lennart Börjeson
1999-10-15 10:55 ` Daniel Potts
1999-10-15 14:19 ` Kirk R. Erichsen
1999-10-15 14:36   ` Peter Rival
  -- strict thread matches above, loose matches on Subject: below --
1999-10-15 14:39 Jemiolo, John
1999-10-15 20:05 ` Paul Jakma
1999-10-15 20:08   ` Greg Lindahl
1999-10-15  9:30 Luke Deller
1999-10-15 12:42 ` Eric Bohm
1999-10-15 15:02   ` Luke Deller
1999-10-16  4:10     ` Eric Bohm
1999-10-15 14:28 ` Michal Jaegermann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox