|
From: <sv...@va...> - 2012-02-04 17:21:16
|
Author: florian
Date: 2012-02-04 17:16:40 +0000 (Sat, 04 Feb 2012)
New Revision: 12368
Log:
Add testcases for TR, TRE, TRTT, TROT, TRTO insns.
Fixes #273114. Patch by Divya Vyas (div...@li...).
Added:
trunk/none/tests/s390x/table.h
trunk/none/tests/s390x/tr.c
trunk/none/tests/s390x/tr.stderr.exp
trunk/none/tests/s390x/tr.stdout.exp
trunk/none/tests/s390x/tr.vgtest
trunk/none/tests/s390x/tre.c
trunk/none/tests/s390x/tre.stderr.exp
trunk/none/tests/s390x/tre.stdout.exp
trunk/none/tests/s390x/tre.vgtest
trunk/none/tests/s390x/trot.c
trunk/none/tests/s390x/trot.stderr.exp
trunk/none/tests/s390x/trot.stdout.exp
trunk/none/tests/s390x/trot.vgtest
trunk/none/tests/s390x/trto.c
trunk/none/tests/s390x/trto.stderr.exp
trunk/none/tests/s390x/trto.stdout.exp
trunk/none/tests/s390x/trto.vgtest
trunk/none/tests/s390x/trtt.c
trunk/none/tests/s390x/trtt.stderr.exp
trunk/none/tests/s390x/trtt.stdout.exp
trunk/none/tests/s390x/trtt.vgtest
Modified:
trunk/NEWS
trunk/none/tests/s390x/
trunk/none/tests/s390x/Makefile.am
trunk/none/tests/s390x/troo.c
Modified: trunk/NEWS
===================================================================
--- trunk/NEWS 2012-02-04 14:40:44 UTC (rev 12367)
+++ trunk/NEWS 2012-02-04 17:16:40 UTC (rev 12368)
@@ -40,6 +40,7 @@
247386 make perf does not run all performance tests
270796 s390x: Removed broken support for the TS insn
271438 Fix configure for proper SSE4.2 detection
+273114 s390x: Support TR, TRE, TROO, TROT, TRTO, and TRTT instructions
276993 fix mremap 'no thrash checks'
281482 valgrind's memcheck incorrect byte allocation count in realloc() for silly argument
282230 group allocator for small fixed size, use it for MC_Chunk/SEc vbit
Property changes on: trunk/none/tests/s390x
___________________________________________________________________
Name: svn:ignore
- .deps
add
add_EI
add_GE
and
and_EI
clc
clcle
cvb
cvd
div
ex_clone
ex_sig
flogr
icm
insert
insert_EI
lam_stam
lpr
Makefile
Makefile.in
mul
mul_GE
mvst
or
or_EI
srst
sub
sub_EI
tcxb
xc
xor
xor_EI
stck
stcke
stckf
op_exception
fgx
condloadstore
fold_And16
stfle
op00
cksm
clcl
mvcl
troo
+ .deps
add
add_EI
add_GE
allexec
and
and_EI
clc
clcle
cvb
cvd
div
ex_clone
ex_sig
flogr
icm
insert
insert_EI
lam_stam
lpr
Makefile
Makefile.in
mul
mul_GE
mvst
or
or_EI
srst
sub
sub_EI
tcxb
xc
xor
xor_EI
stck
stcke
stckf
op_exception
fgx
condloadstore
fold_And16
stfle
op00
cksm
clcl
mvcl
troo
trot
trto
trtt
tr
tre
Modified: trunk/none/tests/s390x/Makefile.am
===================================================================
--- trunk/none/tests/s390x/Makefile.am 2012-02-04 14:40:44 UTC (rev 12367)
+++ trunk/none/tests/s390x/Makefile.am 2012-02-04 17:16:40 UTC (rev 12368)
@@ -5,7 +5,8 @@
INSN_TESTS = clc clcle cvb cvd icm lpr tcxb lam_stam xc mvst add sub mul \
and or xor insert div srst fold_And16 flogr sub_EI add_EI \
and_EI or_EI xor_EI insert_EI mul_GE add_GE condloadstore \
- op_exception fgx stck stckf stcke stfle cksm mvcl clcl troo
+ op_exception fgx stck stckf stcke stfle cksm mvcl clcl troo \
+ trto trot trtt tr tre
check_PROGRAMS = $(INSN_TESTS) \
allexec \
@@ -21,13 +22,13 @@
ex_clone.stdout.exp ex_clone.stderr.exp ex_clone.vgtest \
op00.stderr.exp1 op00.stderr.exp2 op00.vgtest \
test.h opcodes.h add.h and.h div.h insert.h \
- mul.h or.h sub.h test.h xor.h
+ mul.h or.h sub.h test.h xor.h table.h
AM_CFLAGS += @FLAG_M64@
AM_CXXFLAGS += @FLAG_M64@
AM_CCASFLAGS += @FLAG_M64@
-allexec_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_NONNULL@
+allexec_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_NONNULL@
ex_clone_LDFLAGS = -lpthread
tcxb_CFLAGS = $(AM_CFLAGS) -std=gnu99
Added: trunk/none/tests/s390x/table.h
===================================================================
--- trunk/none/tests/s390x/table.h (rev 0)
+++ trunk/none/tests/s390x/table.h 2012-02-04 17:16:40 UTC (rev 12368)
@@ -0,0 +1,75 @@
+char touppercase[256] =
+{
+
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
+ 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
+ 0x30, 0x31, 0x32/*50*/, 0x33, 0x34, 0x35, 0x36, 0x37,
+ 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
+ 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
+ 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
+ 0x50/*80*/, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
+ 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F,
+ 0x60, 0x41/*97*/, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
+ 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
+ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
+ 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F,
+ 0x80, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
+ 0xC8, 0xC9, 0x8A, 0x8B, 0xAC, 0xAD, 0xAE, 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DE, 0xDF,
+ 0xE0, 0xE1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7,
+ 0xA8, 0xA9, 0xEA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,
+ 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7,
+ 0xF8, 0xF9, 0xFA, 0xDB, 0xDC, 0xDD, 0xDE, 0xFF
+};
+
+
Added: trunk/none/tests/s390x/tr.c
===================================================================
--- trunk/none/tests/s390x/tr.c (rev 0)
+++ trunk/none/tests/s390x/tr.c 2012-02-04 17:16:40 UTC (rev 12368)
@@ -0,0 +1,56 @@
+#include<stdio.h>
+#include<stdlib.h>
+#include<asm/types.h>
+#include<stdint.h>
+#include<string.h>
+#include "table.h"
+
+uint8_t buff[40];
+
+void tr(uint8_t *codepage, uint8_t *addr, uint64_t len)
+{
+ asm volatile(
+ " larl 1,1f\n"
+ "1: tr 0(1,%0),0(%2)\n"
+ " ex %1,0(1)"
+ : "+&a" (addr), "+d" (len)
+ : "a" (codepage) : "cc", "memory", "1");
+}
+
+void run_test(void *tran_table, void *srcaddr, uint64_t len)
+{
+ int i;
+
+ tr(tran_table, buff, len);
+ printf("the translated string is ");
+ for (i = 0; i < len; i++) {
+ printf("%c", buff[i]);
+ }
+ printf("\n");
+}
+
+int main()
+{
+ /* Test 1: length = 0 */
+ run_test((char *)&touppercase, &buff, 0);
+ run_test((char *)&touppercase, &buff, 0);
+
+ /* Test 2 : length > 0 */
+ memset(buff, 'a', 1);
+ run_test((char *)&touppercase, &buff, 1);
+
+ memcpy(buff, "abcdefgh", 8);
+ run_test((char *)&touppercase, &buff, 3);
+ run_test((char *)&touppercase, &buff, 3);
+ run_test((char *)&touppercase, &buff, 8);
+
+ memcpy(buff, "ABCDEFGH", 8);
+ run_test((char *)&tolowercase, &buff, 3);
+ run_test((char *)&tolowercase, &buff, 3);
+ run_test((char *)&tolowercase, &buff, 8);
+
+ memcpy(buff, "0123456789", 9);
+ run_test((char *)&touppercase, &buff, 9);
+ run_test((char *)&tolowercase, &buff, 9);
+ return 0;
+}
Added: trunk/none/tests/s390x/tr.stderr.exp
===================================================================
--- trunk/none/tests/s390x/tr.stderr.exp (rev 0)
+++ trunk/none/tests/s390x/tr.stderr.exp 2012-02-04 17:16:40 UTC (rev 12368)
@@ -0,0 +1,2 @@
+
+
Added: trunk/none/tests/s390x/tr.stdout.exp
===================================================================
--- trunk/none/tests/s390x/tr.stdout.exp (rev 0)
+++ trunk/none/tests/s390x/tr.stdout.exp 2012-02-04 17:16:40 UTC (rev 12368)
@@ -0,0 +1,11 @@
+the translated string is
+the translated string is
+the translated string is A
+the translated string is ABC
+the translated string is ABC
+the translated string is ABCDEFGH
+the translated string is abc
+the translated string is abc
+the translated string is abcdefgh
+the translated string is 012345678
+the translated string is 012345678
Added: trunk/none/tests/s390x/tr.vgtest
===================================================================
--- trunk/none/tests/s390x/tr.vgtest (rev 0)
+++ trunk/none/tests/s390x/tr.vgtest 2012-02-04 17:16:40 UTC (rev 12368)
@@ -0,0 +1 @@
+prog: tr
Added: trunk/none/tests/s390x/tre.c
===================================================================
--- trunk/none/tests/s390x/tre.c (rev 0)
+++ trunk/none/tests/s390x/tre.c 2012-02-04 17:16:40 UTC (rev 12368)
@@ -0,0 +1,94 @@
+#include<stdio.h>
+#include<stdlib.h>
+#include<stdint.h>
+#include<inttypes.h>
+#include<string.h>
+#include "table.h"
+
+/* Register contents after executing an TRE insn */
+typedef struct {
+ uint64_t addr;
+ uint64_t len;
+ uint64_t tabaddr;
+ uint8_t testbyte;
+ uint64_t cc;
+} tre_regs;
+
+uint8_t buff[40];
+
+tre_regs tre(uint8_t *codepage, uint8_t *addr, uint64_t len, uint8_t test_byte)
+{
+ int cc;
+ tre_regs regs;
+
+ register uint64_t param asm("0") = test_byte;
+ register uint64_t a2 asm ("4") = (uint64_t)codepage;
+ register uint64_t a1 asm ("2") = (uint64_t)addr;
+ register uint64_t l1 asm ("3") = len;
+
+ asm volatile(
+ " tre %1,%2\n"
+ " ipm %0\n"
+ " srl %0,28\n"
+ :"=d"(cc),"+&d"(a1)
+ :"d"(a2),"d"(param),"d"(l1),"d"(test_byte): "memory" );
+
+ regs.addr = a1;
+ regs.len = l1;
+ regs.tabaddr = a2;
+ regs.testbyte = param;
+ regs.cc = cc;
+
+ return regs;
+}
+
+void run_test(void *tran_table, void *srcaddr, uint64_t len, uint8_t test)
+{
+ tre_regs regs;
+ int i;
+
+ regs = tre(tran_table, buff, len, test);
+
+ if ((uint64_t)tran_table != regs.tabaddr)
+ printf("translation table address changed\n");
+ if (test != regs.testbyte)
+ printf("test byte changed\n");
+ if ((uint64_t)srcaddr + (len - regs.len) != regs.addr)
+ printf("source address/length not updated properly\n");
+
+ printf("Resulting cc is %"PRIu64" and the string is ", regs.cc);
+ for ( i = 0; i < len; i++) {
+ printf("%c", buff[i]);
+ }
+
+ printf("\n");
+}
+
+int main()
+{
+
+ /* Test 1: length = 0 */
+ run_test(NULL, NULL, 0, 0x0);
+ run_test((char *)&touppercase, &buff, 0, 0x0);
+ run_test((char *)&touppercase, &buff, 0, 'b');
+
+ /* Test 2 : length > 0 */
+ memset(buff, 'a', 1);
+ run_test((char *)&touppercase, &buff, 1, 'a'); //cc = 1
+ run_test((char *)&touppercase, &buff, 1, 'b');
+
+ memcpy(buff, "abcdefgh", 8);
+ run_test((char *)&touppercase, &buff, 3, 'a'); //cc = 1
+ run_test((char *)&touppercase, &buff, 3, 'f'); //cc = 0
+ run_test((char *)&touppercase, &buff, 8, 'l'); //cc = 0
+
+ memcpy(buff, "ABCDEFGH", 8);
+ run_test((char *)&tolowercase, &buff, 3, 'A'); // cc = 1
+ run_test((char *)&tolowercase, &buff, 3, 'C'); // cc = 0
+ run_test((char *)&tolowercase, &buff, 8, 0x0); // cc = 0
+
+ memcpy(buff, "01234567", 8);
+ run_test((char *)&touppercase, &buff, 8, 'A');
+ run_test((char *)&tolowercase, &buff, 8, 'A');
+ return 0;
+}
Added: trunk/none/tests/s390x/tre.stderr.exp
===================================================================
--- trunk/none/tests/s390x/tre.stderr.exp (rev 0)
+++ trunk/none/tests/s390x/tre.stderr.exp 2012-02-04 17:16:40 UTC (rev 12368)
@@ -0,0 +1,2 @@
+
+
Added: trunk/none/tests/s390x/tre.stdout.exp
===================================================================
--- trunk/none/tests/s390x/tre.stdout.exp (rev 0)
+++ trunk/none/tests/s390x/tre.stdout.exp 2012-02-04 17:16:40 UTC (rev 12368)
@@ -0,0 +1,14 @@
+source address/length not updated properly
+Resulting cc is 0 and the string is
+Resulting cc is 0 and the string is
+Resulting cc is 0 and the string is
+Resulting cc is 1 and the string is a
+Resulting cc is 0 and the string is A
+Resulting cc is 1 and the string is abc
+Resulting cc is 0 and the string is ABC
+Resulting cc is 0 and the string is ABCDEFGH
+Resulting cc is 1 and the string is ABC
+Resulting cc is 1 and the string is abC
+Resulting cc is 0 and the string is abcdefgh
+Resulting cc is 0 and the string is 01234567
+Resulting cc is 0 and the string is 01234567
Added: trunk/none/tests/s390x/tre.vgtest
===================================================================
--- trunk/none/tests/s390x/tre.vgtest (rev 0)
+++ trunk/none/tests/s390x/tre.vgtest 2012-02-04 17:16:40 UTC (rev 12368)
@@ -0,0 +1 @@
+prog: tre
Modified: trunk/none/tests/s390x/troo.c
===================================================================
--- trunk/none/tests/s390x/troo.c 2012-02-04 14:40:44 UTC (rev 12367)
+++ trunk/none/tests/s390x/troo.c 2012-02-04 17:16:40 UTC (rev 12368)
@@ -5,12 +5,12 @@
/* Register contents after executing an TROO insn */
typedef struct {
- uint64_t srcaddr;
- uint64_t len;
- uint64_t desaddr;
- uint64_t tabaddr;
- uint8_t testbyte;
- uint64_t cc;
+ uint64_t srcaddr;
+ uint64_t len;
+ uint64_t desaddr;
+ uint64_t tabaddr;
+ uint8_t testbyte;
+ uint64_t cc;
} troo_regs;
uint8_t tran_table[20] = {
Added: trunk/none/tests/s390x/trot.c
===================================================================
--- trunk/none/tests/s390x/trot.c (rev 0)
+++ trunk/none/tests/s390x/trot.c 2012-02-04 17:16:40 UTC (rev 12368)
@@ -0,0 +1,132 @@
+#include<stdio.h>
+#include<stdint.h>
+#include<string.h>
+#include<assert.h>
+
+/* Register contents after executing an TROT insn */
+typedef struct {
+ uint64_t srcaddr;
+ uint64_t len;
+ uint64_t desaddr;
+ uint64_t tabaddr;
+ uint16_t testbyte;
+ uint64_t cc;
+} trot_regs;
+
+uint16_t tran_table[40] = {
+ 0xaaaa,0xbbbb,0xcccc,0xccdd,0xffff,0xdada,0xbcbc,0xabab,0xcaca,0xeaea,
+ 0xbbbb,0xeeee
+};
+
+uint8_t src[40] = {
+ 0x01,0x03,0x04,0x02,0x07,0x08,0x06,0x02,0x05,0x09
+};
+
+uint16_t des[40];
+
+trot_regs tr(uint8_t *addr, uint16_t *codepage, uint16_t *dest, uint64_t len,
+ uint16_t test)
+{
+ trot_regs regs;
+ register uint64_t test_byte asm("0") = test;
+ register uint64_t length asm("3") = len;
+ register uint64_t srcaddr asm("4") = (uint64_t)addr;
+ register uint64_t codepage2 asm("1") = (uint64_t)codepage;
+ register uint64_t desaddr asm("2") = (uint64_t)dest;
+ register uint64_t cc asm("5");
+
+ cc = 2; /* cc result will never be 2 */
+ asm volatile(
+ " trot %1,%2\n"
+ " ipm %0\n"
+ " srl %0,28\n"
+ : "=d"(cc),"+&d"(desaddr)
+ : "d" (srcaddr),"d"(test_byte),"d" (codepage2),"d"(length)
+ : "memory" );
+
+ regs.srcaddr = srcaddr;
+ regs.len = length;
+ regs.desaddr = desaddr;
+ regs.tabaddr = codepage2;
+ regs.testbyte = test_byte;
+ regs.cc = cc;
+ return regs;
+}
+
+int run_test(void *srcaddr, void *tableaddr, void *desaddr, uint64_t len,
+ uint16_t testbyte)
+{
+ trot_regs regs;
+ int i;
+
+ assert(len <= sizeof src);
+
+ if ((testbyte & 0xffff) != testbyte)
+ printf("testbyte should be 2 byte only\n");
+
+ regs = tr(srcaddr, tableaddr, desaddr, len, testbyte);
+
+ if ((uint64_t)tableaddr != regs.tabaddr)
+ printf("translation table address changed\n");
+ if ((uint64_t)srcaddr + (len - regs.len) != regs.srcaddr)
+ printf("source address/length not updated properly\n");
+ if ((uint64_t)desaddr + 2*(len - regs.len) != regs.desaddr)
+ printf("destination address/length not updated properly\n");
+ if (regs.cc == 0 && regs.len != 0)
+ printf("length is not zero but cc is zero\n");
+ printf("%u bytes translated\n", (unsigned)(len - regs.len));
+ printf("the translated values is");
+ for (i = 0; i < len; i++) {
+ printf(" %hx", des[i]);
+ }
+ printf("\n");
+
+ return regs.cc;
+}
+
+
+int main()
+{
+ int cc;
+
+ assert(sizeof des >= sizeof src);
+
+ /* Test 1 : len == 0 */
+ cc = run_test(NULL, NULL, NULL, 0, 0x0);
+ if (cc != 0)
+ printf("cc not updated properly:%d", cc);
+
+ cc = run_test(&src, &tran_table, &des, 0, 0x0);
+ if (cc != 0)
+ printf("cc not updated properly:%d",cc);
+
+ cc = run_test(&src, &tran_table, &des, 0, 0xcaca);
+ if (cc != 0)
+ printf("cc not updated properly:%d",cc);
+
+ /* Test 2 : len > 0, testbyte not matching */
+ cc = run_test(&src, &tran_table, &des, 3, 0xeeee);
+ if (cc != 0)
+ printf("cc not updated properly:%d",cc);
+
+ cc = run_test(&src, &tran_table, &des, 10, 0xeeee);
+ if (cc != 0)
+ printf("cc not updated properly:%d",cc);
+
+ memset((uint16_t *)&des, 0, 10);
+
+ /* Test 3 : len > 0 , testbyte matching */
+ cc = run_test(&src, &tran_table, &des, 5, 0xffff);
+ if (cc != 1)
+ printf("cc not updated properly:%d",cc);
+
+ cc = run_test(&src, &tran_table, &des, 5, 0xcccc);
+ if (cc != 1)
+ printf("cc not updated properly:%d",cc);
+
+ cc = run_test(&src, &tran_table, &des, 10, 0xeaea);
+ if (cc != 1)
+ printf("cc not updated properly:%d",cc);
+
+ return 0;
+}
Added: trunk/none/tests/s390x/trot.stderr.exp
===================================================================
--- trunk/none/tests/s390x/trot.stderr.exp (rev 0)
+++ trunk/none/tests/s390x/trot.stderr.exp 2012-02-04 17:16:40 UTC (rev 12368)
@@ -0,0 +1,2 @@
+
+
Added: trunk/none/tests/s390x/trot.stdout.exp
===================================================================
--- trunk/none/tests/s390x/trot.stdout.exp (rev 0)
+++ trunk/none/tests/s390x/trot.stdout.exp 2012-02-04 17:16:40 UTC (rev 12368)
@@ -0,0 +1,16 @@
+0 bytes translated
+the translated values is
+0 bytes translated
+the translated values is
+0 bytes translated
+the translated values is
+3 bytes translated
+the translated values is bbbb ccdd ffff
+10 bytes translated
+the translated values is bbbb ccdd ffff cccc abab caca bcbc cccc dada eaea
+2 bytes translated
+the translated values is bbbb ccdd 0 0 0
+3 bytes translated
+the translated values is bbbb ccdd ffff 0 0
+9 bytes translated
+the translated values is bbbb ccdd ffff cccc abab caca bcbc cccc dada eaea
Added: trunk/none/tests/s390x/trot.vgtest
===================================================================
--- trunk/none/tests/s390x/trot.vgtest (rev 0)
+++ trunk/none/tests/s390x/trot.vgtest 2012-02-04 17:16:40 UTC (rev 12368)
@@ -0,0 +1 @@
+prog: trot
Added: trunk/none/tests/s390x/trto.c
===================================================================
--- trunk/none/tests/s390x/trto.c (rev 0)
+++ trunk/none/tests/s390x/trto.c 2012-02-04 17:16:40 UTC (rev 12368)
@@ -0,0 +1,130 @@
+#include<stdio.h>
+#include<stdint.h>
+#include<assert.h>
+#include<string.h>
+
+/* Register contents after executing an TRTO insn */
+typedef struct {
+ uint64_t srcaddr;
+ uint64_t len;
+ uint64_t desaddr;
+ uint64_t tabaddr;
+ uint8_t testbyte;
+ uint64_t cc;
+} trto_regs;
+
+uint8_t tran_table[40] = {
+ 0xaa,0xbb,0xcc,0xdd,0xff,0xdd,0xbc,0xab,0xca,0xea,0xbb,0xee
+};
+
+int16_t src[40] = {
+ 0x2,0x03,0x04,0x02,0x07,0x08,0x06,0x02,0x05,0x09
+};
+
+uint8_t des[20];
+
+trto_regs tr(uint16_t *addr, uint16_t *codepage, uint8_t *dest, uint64_t len,
+ uint8_t test)
+{
+ trto_regs regs;
+ register uint64_t test_byte asm("0") = test;
+ register uint64_t length asm("3") = len;
+ register uint64_t srcaddr asm("4") = (uint64_t)addr;
+ register uint64_t codepage2 asm("1") = (uint64_t)codepage;
+ register uint64_t desaddr asm("2") = (uint64_t)dest;
+ register uint64_t cc asm("5");
+
+ cc = 2; /* cc result will never be 2 */
+ asm volatile(
+ " trto %1,%2\n"
+ " ipm %0\n"
+ " srl %0,28\n"
+ : "=d"(cc),"+&d"(desaddr)
+ : "d" (srcaddr),"d"(test_byte),"d" (codepage2),"d"(length)
+ : "memory" );
+
+ regs.srcaddr = srcaddr;
+ regs.len = length;
+ regs.desaddr = desaddr;
+ regs.tabaddr = codepage2;
+ regs.testbyte = test_byte;
+ regs.cc = cc;
+ return regs;
+}
+
+int run_test(void *srcaddr, void *tableaddr, void *desaddr, uint64_t len,
+ uint8_t testbyte)
+{
+ trto_regs regs;
+ int i;
+
+ assert(len <= sizeof src);
+
+ if ((testbyte & 0xffff) != testbyte)
+ printf("testbyte should be 1 byte only\n");
+
+ regs = tr(srcaddr, tableaddr, desaddr, len, testbyte);
+
+ if ((uint64_t)tableaddr != regs.tabaddr)
+ printf("translation table address changed\n");
+ if ((uint64_t)srcaddr + (len - regs.len) != regs.srcaddr)
+ printf("source address/length not updated properly\n");
+ if ((uint64_t)desaddr + ((len - regs.len)/2) != regs.desaddr)
+ printf("destination address/length not updated properly\n");
+ if (regs.cc == 0 && regs.len != 0)
+ printf("length is not zero but cc is zero\n");
+ printf("%u bytes translated\n", ((unsigned)(len - regs.len)/2));
+ printf("the translated values is");
+ for (i = 0; i < len/2; i++) {
+ printf(" %x", des[i]);
+ }
+ printf("\n");
+
+ return regs.cc;
+}
+
+int main()
+{
+ int cc;
+
+ assert(sizeof des <= sizeof src);
+
+ /* Test 1 : len == 0 */
+ cc = run_test(NULL, NULL, NULL, 0, 0x0);
+ if (cc != 0)
+ printf("cc not updated properly:%d", cc);
+
+ cc = run_test(&src, &tran_table, &des, 0, 0x0);
+ if (cc != 0)
+ printf("cc not updated properly:%d",cc);
+
+ cc = run_test(&src, &tran_table, &des, 0, 0xca);
+ if (cc != 0)
+ printf("cc not updated properly:%d",cc);
+
+ /* Test 2 : len > 0, testbyte not matching */
+ cc = run_test(&src, &tran_table, &des, 12, 0xee);
+ if (cc != 0)
+ printf("cc not updated properly:%d",cc);
+
+ cc = run_test(&src, &tran_table, &des, 20, 0x00);
+ if (cc != 0)
+ printf("cc not updated properly:%d",cc);
+
+ memset((uint16_t *)&des, 0, 10);
+
+ /* Test 3 : len > 0 , testbyte matching */
+ cc = run_test(&src, &tran_table, &des, 12, 0xff);
+ if (cc != 1)
+ printf("cc not updated properly:%d",cc);
+
+ cc = run_test(&src, &tran_table, &des, 12, 0xcc);
+ if (cc != 1)
+ printf("cc not updated properly:%d",cc);
+
+ cc = run_test(&src, &tran_table, &des, 20, 0xea);
+ if (cc != 1)
+ printf("cc not updated properly:%d",cc);
+
+ return 0;
+}
Added: trunk/none/tests/s390x/trto.stderr.exp
===================================================================
--- trunk/none/tests/s390x/trto.stderr.exp (rev 0)
+++ trunk/none/tests/s390x/trto.stderr.exp 2012-02-04 17:16:40 UTC (rev 12368)
@@ -0,0 +1,2 @@
+
+
Added: trunk/none/tests/s390x/trto.stdout.exp
===================================================================
--- trunk/none/tests/s390x/trto.stdout.exp (rev 0)
+++ trunk/none/tests/s390x/trto.stdout.exp 2012-02-04 17:16:40 UTC (rev 12368)
@@ -0,0 +1,16 @@
+0 bytes translated
+the translated values is
+0 bytes translated
+the translated values is
+0 bytes translated
+the translated values is
+6 bytes translated
+the translated values is cc dd ff cc ab ca
+10 bytes translated
+the translated values is cc dd ff cc ab ca bc cc dd ea
+2 bytes translated
+the translated values is cc dd 0 0 0 0
+0 bytes translated
+the translated values is cc dd 0 0 0 0
+9 bytes translated
+the translated values is cc dd ff cc ab ca bc cc dd 0
Added: trunk/none/tests/s390x/trto.vgtest
===================================================================
--- trunk/none/tests/s390x/trto.vgtest (rev 0)
+++ trunk/none/tests/s390x/trto.vgtest 2012-02-04 17:16:40 UTC (rev 12368)
@@ -0,0 +1 @@
+prog: trto
Added: trunk/none/tests/s390x/trtt.c
===================================================================
--- trunk/none/tests/s390x/trtt.c (rev 0)
+++ trunk/none/tests/s390x/trtt.c 2012-02-04 17:16:40 UTC (rev 12368)
@@ -0,0 +1,133 @@
+#include<stdio.h>
+#include<stdint.h>
+#include<string.h>
+#include<assert.h>
+
+/* Register contents after executing an TRTT insn */
+typedef struct {
+ uint64_t srcaddr;
+ uint64_t len;
+ uint64_t desaddr;
+ uint64_t tabaddr;
+ uint16_t testbyte;
+ uint64_t cc;
+} trtt_regs;
+
+uint16_t tran_table[40] = {
+ 0xaaaa,0xcccc,0xcccc,0xdddd,0xffff,0xdada,0xbcbc,0xabab,0xcaca,0xeaea,
+ 0xbbbb,0xeeee
+};
+
+uint16_t src[40] = {
+ 0x4,0x03,0x04,0x02,0x07,0x08,0x06,0x02,0x05,0x09,0xa
+};
+
+uint16_t des[20];
+
+trtt_regs tr(uint16_t *addr, uint16_t *codepage, uint16_t *dest, uint64_t len,
+ uint16_t test)
+{
+ trtt_regs regs;
+ register uint64_t test_byte asm("0") = test;
+ register uint64_t length asm("3") = len;
+ register uint64_t srcaddr asm("4") = (uint64_t)addr;
+ register uint64_t codepage2 asm("1") = (uint64_t)codepage;
+ register uint64_t desaddr asm("2") = (uint64_t)dest;
+ register uint64_t cc asm("5");
+
+ cc = 2; /* cc result will never be 2 */
+ asm volatile(
+ " trtt %1,%2\n"
+ " ipm %0\n"
+ " srl %0,28\n"
+ : "=d"(cc),"+d"(desaddr),"+d"(srcaddr)
+ : "d"(test_byte),"d" (codepage2),"d"(length)
+ : "memory" );
+
+ regs.srcaddr = srcaddr;
+ regs.len = length;
+ regs.desaddr = desaddr;
+ regs.tabaddr = codepage2;
+ regs.testbyte = test_byte;
+ regs.cc = cc;
+
+ return regs;
+}
+
+int run_test(void *srcaddr, void *tableaddr, void *desaddr, uint64_t len,
+ uint16_t testbyte)
+{
+ trtt_regs regs;
+ int i;
+
+ assert(len <= sizeof src);
+
+ if ((testbyte & 0xffff) != testbyte)
+ printf("testbyte should be 2 byte only\n");
+
+ regs = tr(srcaddr, tableaddr, desaddr, len, testbyte);
+
+ if ((uint64_t)tableaddr != regs.tabaddr)
+ printf("translation table address changed\n");
+ if ((uint64_t)srcaddr + (len - regs.len) != regs.srcaddr)
+ printf("source address/length not updated properly\n");
+ if ((uint64_t)desaddr + (len - regs.len) != regs.desaddr)
+ printf("destination address/length not updated properly\n");
+ if (regs.cc == 0 && regs.len != 0)
+ printf("length is not zero but cc is zero\n");
+ printf("%u bytes translated\n", ((unsigned)(len - regs.len))/2);
+ printf("the translated values is");
+ for (i = 0; i < len/2; i++) {
+ printf(" %hx", des[i]);
+ }
+ printf("\n");
+
+ return regs.cc;
+}
+
+
+int main()
+{
+ int cc;
+
+ assert(sizeof des <= sizeof src);
+
+ /* Test 1 : len == 0 */
+ cc = run_test(NULL, NULL, NULL, 0, 0x0);
+ if (cc != 0)
+ printf("cc not updated properly:%d", cc);
+
+ cc = run_test(&src, &tran_table, &des, 0, 0x0);
+ if (cc != 0)
+ printf("cc not updated properly:%d",cc);
+
+ cc = run_test(&src, &tran_table, &des, 0, 0xcaca);
+ if (cc != 0)
+ printf("cc not updated properly:%d",cc);
+
+ /* Test 2 : len > 0, testbyte not matching */
+ cc = run_test(&src, &tran_table, &des, 4, 0xdada);
+ if (cc != 0)
+ printf("cc not updated properly:%d",cc);
+
+ cc = run_test(&src, &tran_table, &des, 10, 0x00);
+ if (cc != 0)
+ printf("cc not updated properly:%d",cc);
+
+ memset((uint16_t *)&des, 0, 10);
+
+ /* Test 3 : len > 0 , testbyte matching */
+ cc = run_test(&src, &tran_table, &des, 10, 0xffff);
+ if (cc != 1)
+ printf("cc not updated properly:%d",cc);
+
+ cc = run_test(&src, &tran_table, &des, 10, 0xcccc);
+ if (cc != 1)
+ printf("cc not updated properly:%d",cc);
+
+ cc = run_test(&src, &tran_table, &des, 20, 0xeaea);
+ if (cc != 1)
+ printf("cc not updated properly:%d",cc);
+
+ return 0;
+}
Added: trunk/none/tests/s390x/trtt.stderr.exp
===================================================================
--- trunk/none/tests/s390x/trtt.stderr.exp (rev 0)
+++ trunk/none/tests/s390x/trtt.stderr.exp 2012-02-04 17:16:40 UTC (rev 12368)
@@ -0,0 +1,2 @@
+
+
Added: trunk/none/tests/s390x/trtt.stdout.exp
===================================================================
--- trunk/none/tests/s390x/trtt.stdout.exp (rev 0)
+++ trunk/none/tests/s390x/trtt.stdout.exp 2012-02-04 17:16:40 UTC (rev 12368)
@@ -0,0 +1,16 @@
+0 bytes translated
+the translated values is
+0 bytes translated
+the translated values is
+0 bytes translated
+the translated values is
+2 bytes translated
+the translated values is ffff dddd
+5 bytes translated
+the translated values is ffff dddd ffff cccc abab
+0 bytes translated
+the translated values is 0 0 0 0 0
+3 bytes translated
+the translated values is ffff dddd ffff 0 0
+9 bytes translated
+the translated values is ffff dddd ffff cccc abab caca bcbc cccc dada 0
Added: trunk/none/tests/s390x/trtt.vgtest
===================================================================
--- trunk/none/tests/s390x/trtt.vgtest (rev 0)
+++ trunk/none/tests/s390x/trtt.vgtest 2012-02-04 17:16:40 UTC (rev 12368)
@@ -0,0 +1 @@
+prog: trtt
|