From 5fe2ce69dcd1d0ddb42c4edffac7ab11d939ca45 Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Fri, 23 Aug 2013 20:02:02 -0700 Subject: Reflect changes to ISA Conflicts: isa/Makefile --- mt/.gitignore | 6 + mt/Makefile | 11 +- mt/common/crt-mt.S | 116 --------- mt/common/crt.S | 108 -------- mt/common/pcr.h | 90 ------- mt/common/syscalls.S | 678 --------------------------------------------------- mt/common/syscalls.c | 265 -------------------- mt/common/test-mt.ld | 45 ---- mt/common/test.ld | 45 ---- mt/common/util.h | 32 --- 10 files changed, 12 insertions(+), 1384 deletions(-) create mode 100644 mt/.gitignore delete mode 100644 mt/common/crt-mt.S delete mode 100755 mt/common/crt.S delete mode 100755 mt/common/pcr.h delete mode 100755 mt/common/syscalls.S delete mode 100755 mt/common/syscalls.c delete mode 100644 mt/common/test-mt.ld delete mode 100755 mt/common/test.ld delete mode 100755 mt/common/util.h (limited to 'mt') diff --git a/mt/.gitignore b/mt/.gitignore new file mode 100644 index 0000000..131616e --- /dev/null +++ b/mt/.gitignore @@ -0,0 +1,6 @@ +*.riscv +*.host +*.o +*.dump +*.out +*.hex diff --git a/mt/Makefile b/mt/Makefile index 2be1455..21f75f9 100755 --- a/mt/Makefile +++ b/mt/Makefile @@ -7,6 +7,7 @@ default: all bmarkdir = . +common = ../benchmarks/common instname = riscv-bmarks-mt instbasedir = $(UCB_VLSI_HOME)/install @@ -89,17 +90,17 @@ bt_vvadd\ RISCV_GCC = riscv-gcc RISCV_GCC_OPTS = -std=gnu99 -T common/test.ld -O3 -nostdlib -nostartfiles -funroll-all-loops -RISCV_LINK = riscv-gcc -T $(bmarkdir)/common/test.ld -RISCV_LINK_MT = riscv-gcc -T $(bmarkdir)/common/test-mt.ld +RISCV_LINK = riscv-gcc -T $(common)/test.ld +RISCV_LINK_MT = riscv-gcc -T $(common)/test-mt.ld RISCV_LINK_OPTS = -lc -RISCV_LINK_SYSCALL = $(bmarkdir)/common/syscalls.c -lc +RISCV_LINK_SYSCALL = $(common)/syscalls.c -lc RISCV_OBJDUMP = riscv-objdump --disassemble-all --disassemble-zeroes --section=.text --section=.text.startup --section=.data RISCV_SIM = spike -p2 VPATH += $(addprefix $(bmarkdir)/, $(bmarks)) -VPATH += $(bmarkdir)/common +VPATH += $(common) -incs += -I. -I./common $(addprefix -I$(bmarkdir)/, $(bmarks)) +incs += -I. -I$(common) $(addprefix -I$(bmarkdir)/, $(bmarks)) objs := #include $(patsubst %, $(bmarkdir)/%/bmark.mk, $(bmarks)) diff --git a/mt/common/crt-mt.S b/mt/common/crt-mt.S deleted file mode 100644 index 283b3bf..0000000 --- a/mt/common/crt-mt.S +++ /dev/null @@ -1,116 +0,0 @@ - .data - .globl _heapend - .globl environ -_heapend: - .word 0 -environ: - .word 0 - - .text - .globl _start - -_start: - li x1, 0 - li x2, 0 - li x3, 0 - li x4, 0 - li x5, 0 - li x6, 0 - li x7, 0 - li x8, 0 - li x9, 0 - li x10,0 - li x11,0 - li x12,0 - li x13,0 - li x14,0 - li x15,0 - li x16,0 - li x17,0 - li x18,0 - li x19,0 - li x20,0 - li x21,0 - li x22,0 - li x23,0 - li x24,0 - li x25,0 - li x26,0 - li x27,0 - li x28,0 - li x29,0 - li x30,0 - li x31,0 - - # enable fp - mfpcr x1,cr0 - ori x1,x1,0x2 - mtpcr x1,cr0 - - # enable vec - mfpcr x1,cr0 - ori x1,x1,0x4 - mtpcr x1,cr0 - - ## if that didn't stick, we don't have an FPU, so don't initialize it - mfpcr x1,cr0 - andi x1,x1,0x2 - beqz x1,1f - - mtfsr x0 - mxtf.s f0, x0 - mxtf.s f1, x0 - mxtf.s f2, x0 - mxtf.s f3, x0 - mxtf.s f4, x0 - mxtf.s f5, x0 - mxtf.s f6, x0 - mxtf.s f7, x0 - mxtf.s f8, x0 - mxtf.s f9, x0 - mxtf.s f10,x0 - mxtf.s f11,x0 - mxtf.s f12,x0 - mxtf.s f13,x0 - mxtf.s f14,x0 - mxtf.s f15,x0 - mxtf.s f16,x0 - mxtf.s f17,x0 - mxtf.s f18,x0 - mxtf.s f19,x0 - mxtf.s f20,x0 - mxtf.s f21,x0 - mxtf.s f22,x0 - mxtf.s f23,x0 - mxtf.s f24,x0 - mxtf.s f25,x0 - mxtf.s f26,x0 - mxtf.s f27,x0 - mxtf.s f28,x0 - mxtf.s f29,x0 - mxtf.s f30,x0 - mxtf.s f31,x0 -1: - - # get core id and number of cores - mfpcr a0,cr10 - lw a1, 4(zero) - - slli a2, a0, 13 - la sp, stacktop - sub sp, sp, a2 - - la tp, tlstop - sub tp, tp, a2 - - jal thread_entry - - .bss - .globl stacktop - .globl tlstop - - .align 4 - .skip 32768 -stacktop: - .skip 65536 -tlstop: diff --git a/mt/common/crt.S b/mt/common/crt.S deleted file mode 100755 index d153210..0000000 --- a/mt/common/crt.S +++ /dev/null @@ -1,108 +0,0 @@ - .data - .globl _heapend - .globl environ -_heapend: - .word 0 -environ: - .word 0 - - .text - .globl _start - -_start: - li x1, 0 - li x2, 0 - li x3, 0 - li x4, 0 - li x5, 0 - li x6, 0 - li x7, 0 - li x8, 0 - li x9, 0 - li x10,0 - li x11,0 - li x12,0 - li x13,0 - li x14,0 - li x15,0 - li x16,0 - li x17,0 - li x18,0 - li x19,0 - li x20,0 - li x21,0 - li x22,0 - li x23,0 - li x24,0 - li x25,0 - li x26,0 - li x27,0 - li x28,0 - li x29,0 - li x30,0 - li x31,0 - - # enable fp - mfpcr x1,cr0 - ori x1,x1,0x2 - mtpcr x1,cr0 - - # enable vec - mfpcr x1,cr0 - ori x1,x1,0x4 - mtpcr x1,cr0 - - ## if that didn't stick, we don't have an FPU, so don't initialize it - mfpcr x1,cr0 - andi x1,x1,0x2 - beqz x1,1f - - mtfsr x0 - mxtf.s f0, x0 - mxtf.s f1, x0 - mxtf.s f2, x0 - mxtf.s f3, x0 - mxtf.s f4, x0 - mxtf.s f5, x0 - mxtf.s f6, x0 - mxtf.s f7, x0 - mxtf.s f8, x0 - mxtf.s f9, x0 - mxtf.s f10,x0 - mxtf.s f11,x0 - mxtf.s f12,x0 - mxtf.s f13,x0 - mxtf.s f14,x0 - mxtf.s f15,x0 - mxtf.s f16,x0 - mxtf.s f17,x0 - mxtf.s f18,x0 - mxtf.s f19,x0 - mxtf.s f20,x0 - mxtf.s f21,x0 - mxtf.s f22,x0 - mxtf.s f23,x0 - mxtf.s f24,x0 - mxtf.s f25,x0 - mxtf.s f26,x0 - mxtf.s f27,x0 - mxtf.s f28,x0 - mxtf.s f29,x0 - mxtf.s f30,x0 - mxtf.s f31,x0 -1: - - # only allow core 0 to proceed -1:mfpcr a0, cr10 - bnez a0, 1b - - la sp,stacktop - jal main -1:b 1b - - .bss - .globl stacktop - - .align 4 - .skip 131072 -stacktop: diff --git a/mt/common/pcr.h b/mt/common/pcr.h deleted file mode 100755 index 7659a97..0000000 --- a/mt/common/pcr.h +++ /dev/null @@ -1,90 +0,0 @@ -#ifndef _RISCV_PCR_H -#define _RISCV_PCR_H - -#define SR_ET 0x00000001 -#define SR_EF 0x00000002 -#define SR_EV 0x00000004 -#define SR_EC 0x00000008 -#define SR_PS 0x00000010 -#define SR_S 0x00000020 -#define SR_U64 0x00000040 -#define SR_S64 0x00000080 -#define SR_VM 0x00000100 -#define SR_IM 0x00FF0000 -#define SR_ZERO ~(SR_ET|SR_EF|SR_EV|SR_EC|SR_PS|SR_S|SR_U64|SR_S64|SR_VM|SR_IM) -#define SR_IM_SHIFT 16 - -#define PCR_SR 0 -#define PCR_EPC 1 -#define PCR_BADVADDR 2 -#define PCR_EVEC 3 -#define PCR_COUNT 4 -#define PCR_COMPARE 5 -#define PCR_CAUSE 6 -#define PCR_PTBR 7 -#define PCR_SEND_IPI 8 -#define PCR_CLR_IPI 9 -#define PCR_COREID 10 -#define PCR_IMPL 11 -#define PCR_K0 12 -#define PCR_K1 13 -#define PCR_VECBANK 18 -#define PCR_VECCFG 19 -#define PCR_RESET 29 -#define PCR_TOHOST 30 -#define PCR_FROMHOST 31 - -#define IRQ_IPI 5 -#define IRQ_TIMER 7 - -#define CAUSE_MISALIGNED_FETCH 0 -#define CAUSE_FAULT_FETCH 1 -#define CAUSE_ILLEGAL_INSTRUCTION 2 -#define CAUSE_PRIVILEGED_INSTRUCTION 3 -#define CAUSE_FP_DISABLED 4 -#define CAUSE_SYSCALL 6 -#define CAUSE_BREAKPOINT 7 -#define CAUSE_MISALIGNED_LOAD 8 -#define CAUSE_MISALIGNED_STORE 9 -#define CAUSE_FAULT_LOAD 10 -#define CAUSE_FAULT_STORE 11 -#define CAUSE_VECTOR_DISABLED 12 -#define CAUSE_VECTOR_BANK 13 - -#define CAUSE_VECTOR_MISALIGNED_FETCH 24 -#define CAUSE_VECTOR_FAULT_FETCH 25 -#define CAUSE_VECTOR_ILLEGAL_INSTRUCTION 26 -#define CAUSE_VECTOR_ILLEGAL_COMMAND 27 -#define CAUSE_VECTOR_MISALIGNED_LOAD 28 -#define CAUSE_VECTOR_MISALIGNED_STORE 29 -#define CAUSE_VECTOR_FAULT_LOAD 30 -#define CAUSE_VECTOR_FAULT_STORE 31 - -#ifdef __riscv - -#define ASM_CR(r) _ASM_CR(r) -#define _ASM_CR(r) cr##r - -#ifndef __ASSEMBLER__ - -#define mtpcr(reg,val) ({ long __tmp = (long)(val), __tmp2; \ - asm volatile ("mtpcr %0,%1,cr%2" : "=r"(__tmp2) : "r"(__tmp),"i"(reg)); \ - __tmp2; }) - -#define mfpcr(reg) ({ long __tmp; \ - asm volatile ("mfpcr %0,cr%1" : "=r"(__tmp) : "i"(reg)); \ - __tmp; }) - -#define setpcr(reg,val) ({ long __tmp; \ - asm volatile ("setpcr %0,cr%2,%1" : "=r"(__tmp) : "i"(val), "i"(reg)); \ - __tmp; }) - -#define clearpcr(reg,val) ({ long __tmp; \ - asm volatile ("clearpcr %0,cr%2,%1" : "=r"(__tmp) : "i"(val), "i"(reg)); \ - __tmp; }) - -#endif - -#endif - -#endif diff --git a/mt/common/syscalls.S b/mt/common/syscalls.S deleted file mode 100755 index a0cdf6e..0000000 --- a/mt/common/syscalls.S +++ /dev/null @@ -1,678 +0,0 @@ - .file 1 "syscalls.c" - .section .mdebug.abi64 - .previous - .section .rodata.str1.8,"aMS",@progbits,1 - .align 3 -$LC0: - .ascii "0123456789abcdef\000" - .text - .align 2 - .ent printnum - .type printnum, @function -printnum: - .frame x30,64,x1 # vars= 0, regs= 7/0, args= 0 - .mask 0x03f00002,-8 - .fmask 0x00000000,0 - add x30,x30,-64 - sd x22,32(x30) - sll x22,x7,32 - srl x22,x22,32 - sd x24,48(x30) - sd x23,40(x30) - sd x21,24(x30) - sd x20,16(x30) - sd x25,56(x30) - sd x1,8(x30) - move x23,x6 - move x20,x4 - move x21,x5 - move x24,x9 - bleu x22,x6,$L2 - addw x8,x8,-1 - move x25,x8 - ble x8,x0,$L4 -$L6: - addw x25,x25,-1 - move x4,x24 - move x5,x21 - jalr x20 - bne x25,x0,$L6 -$L4: - lui x2,%hi($LC0) - add x2,x2,%lo($LC0) - remu x22,x23,x22 - add x22,x22,x2 - lb x4,0(x22) - move x5,x21 - move x19,x20 - ld x25,56(x30) - ld x24,48(x30) - ld x23,40(x30) - ld x22,32(x30) - ld x21,24(x30) - ld x20,16(x30) - ld x1,8(x30) - add x30,x30,64 - jr x19 -$L2: - addw x8,x8,-1 - divu x6,x6,x22 - jal printnum - j $L4 - .end printnum - .size printnum, .-printnum - .align 2 - .ent getuint - .type getuint, @function -getuint: - .frame x30,0,x1 # vars= 0, regs= 0/0, args= 0 - .mask 0x00000000,0 - .fmask 0x00000000,0 - slt x2,x5,2 - bne x2,x0,$L10 -$L13: - ld x2,0(x4) - add x3,x2,8 - sd x3,0(x4) - ld x2,0(x2) - ret -$L10: - bne x5,x0,$L13 - ld x3,0(x4) - lwu x2,0(x3) - add x3,x3,8 - sd x3,0(x4) - ret - .end getuint - .size getuint, .-getuint - .align 2 - .globl putchar - .ent putchar - .type putchar, @function -putchar: - .frame x30,64,x1 # vars= 64, regs= 0/0, args= 0 - .mask 0x00000000,0 - .fmask 0x00000000,0 - li x2,-1 # 0xffffffffffffffff - add x30,x30,-64 - lui x3,%hi(buflen.1596) - beq x4,x2,$L21 - lw x5,%lo(buflen.1596)(x3) - lui x2,%hi(buf.1595) - add x2,x2,%lo(buf.1595) - add x6,x2,x5 - sb x4,0(x6) - addw x5,x5,1 - li x4,64 # 0x40 - sw x5,%lo(buflen.1596)(x3) - beq x5,x4,$L15 - move x2,x0 - add x30,x30,64 - j x1 -$L21: - lui x2,%hi(buf.1595) - add x2,x2,%lo(buf.1595) -$L15: - lw x4,%lo(buflen.1596)(x3) - li x5,4 # 0x4 - sd x0,0(x30) - sd x0,8(x30) - sd x0,16(x30) - sd x0,24(x30) - sd x0,32(x30) - sd x0,40(x30) - sd x0,48(x30) - sd x0,56(x30) - sd x5,0(x30) - li x5,1 # 0x1 - sd x5,8(x30) - sd x2,16(x30) - sd x4,24(x30) - fence - #APP - # 45 "syscalls.c" 1 - mtpcr x2,x30,cr30 - # 0 "" 2 - #NO_APP -$L17: - #APP - # 46 "syscalls.c" 1 - mfpcr x2,cr31 - # 0 "" 2 - #NO_APP - beq x2,x0,$L17 - move x2,x0 - sw x0,%lo(buflen.1596)(x3) - add x30,x30,64 - j x1 - .end putchar - .size putchar, .-putchar - .align 2 - .globl exit - .ent exit - .type exit, @function -exit: - .frame x30,64,x1 # vars= 64, regs= 0/0, args= 0 - .mask 0x00000000,0 - .fmask 0x00000000,0 - add x30,x30,-64 - li x2,1 # 0x1 - sd x0,0(x30) - sd x0,8(x30) - sd x0,16(x30) - sd x0,24(x30) - sd x0,32(x30) - sd x0,40(x30) - sd x0,48(x30) - sd x0,56(x30) - sd x2,0(x30) - sd x4,8(x30) - fence - #APP - # 12 "syscalls.c" 1 - mtpcr x2,x30,cr30 - # 0 "" 2 - #NO_APP -$L23: - j $L23 - .end exit - .size exit, .-exit - .align 2 - .globl printstr - .ent printstr - .type printstr, @function -printstr: - .frame x30,80,x1 # vars= 64, regs= 1/0, args= 0 - .mask 0x00000002,-8 - .fmask 0x00000000,0 - add x30,x30,-80 - li x3,4 # 0x4 - sd x0,0(x30) - sd x0,8(x30) - sd x0,16(x30) - sd x0,24(x30) - sd x0,32(x30) - sd x0,40(x30) - sd x0,48(x30) - sd x0,56(x30) - sd x3,0(x30) - li x3,1 # 0x1 - sd x3,8(x30) - sd x1,72(x30) - sd x4,16(x30) - jal strlen - sd x2,24(x30) - fence - #APP - # 24 "syscalls.c" 1 - mtpcr x2,x30,cr30 - # 0 "" 2 - #NO_APP -$L25: - #APP - # 25 "syscalls.c" 1 - mfpcr x2,cr31 - # 0 "" 2 - #NO_APP - beq x2,x0,$L25 - ld x1,72(x30) - add x30,x30,80 - j x1 - .end printstr - .size printstr, .-printstr - .align 2 - .globl printhex - .ent printhex - .type printhex, @function -printhex: - .frame x30,48,x1 # vars= 32, regs= 1/0, args= 0 - .mask 0x00000002,-8 - .fmask 0x00000000,0 - add x30,x30,-48 - sd x1,40(x30) - add x2,x30,15 - add x7,x30,-1 -$L29: - and x3,x4,15 - sltu x6,x3,10 - li x5,87 # 0x57 - beq x6,x0,$L28 - li x5,48 # 0x30 -$L28: - add x3,x5,x3 - sb x3,0(x2) - add x2,x2,-1 - srl x4,x4,4 - bne x2,x7,$L29 - move x4,x30 - sb x0,16(x30) - jal printstr - ld x1,40(x30) - add x30,x30,48 - j x1 - .end printhex - .size printhex, .-printhex - .section .rodata.str1.8 - .align 3 -$LC1: - .ascii "(null)\000" - .text - .align 2 - .globl vprintfmt - .ent vprintfmt - .type vprintfmt, @function -vprintfmt: - .frame x30,112,x1 # vars= 32, regs= 10/0, args= 0 - .mask 0x2ff00002,-8 - .fmask 0x00000000,0 - add x30,x30,-112 - sd x25,80(x30) - lui x25,%hi($L53) - sd x26,88(x30) - sd x24,72(x30) - sd x23,64(x30) - sd x22,56(x30) - sd x21,48(x30) - sd x20,40(x30) - sd x29,104(x30) - sd x27,96(x30) - sd x1,32(x30) - move x21,x4 - move x20,x5 - move x23,x6 - sd x7,0(x30) - li x22,37 # 0x25 - add x25,x25,%lo($L53) - li x24,-1 # 0xffffffffffffffff - lui x26,%hi($LC1) - j $L84 -$L35: - beq x2,x0,$L32 - move x5,x20 - add x23,x23,1 - jalr x21 -$L84: - lbu x4,0(x23) - move x2,x4 - bne x4,x22,$L35 - ld x2,0(x30) - add x6,x23,1 - move x7,x6 - li x27,32 # 0x20 - sd x0,8(x30) - li x3,-1 # 0xffffffffffffffff - li x29,-1 # 0xffffffffffffffff - move x5,x0 -$L85: - lbu x4,0(x7) - add x23,x7,1 - addw x8,x4,-35 - and x9,x8,0xff - sltu x9,x9,86 - bne x9,x0,$L90 -$L38: - li x4,37 # 0x25 - move x5,x20 - sd x2,0(x30) - move x23,x6 - jalr x21 - j $L84 -$L32: - ld x1,32(x30) - ld x29,104(x30) - ld x27,96(x30) - ld x26,88(x30) - ld x25,80(x30) - ld x24,72(x30) - ld x23,64(x30) - ld x22,56(x30) - ld x21,48(x30) - ld x20,40(x30) - add x30,x30,112 - j x1 -$L90: - and x8,x8,0xff - sll x8,x8,3 - add x8,x25,x8 - ld x8,0(x8) - j x8 - .section .rodata - .align 3 - .align 2 -$L53: - .dword $L39 - .dword $L38 - .dword $L40 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L41 - .dword $L38 - .dword $L38 - .dword $L42 - .dword $L43 - .dword $L38 - .dword $L74 - .dword $L44 - .dword $L44 - .dword $L44 - .dword $L44 - .dword $L44 - .dword $L44 - .dword $L44 - .dword $L44 - .dword $L44 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L45 - .dword $L46 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L38 - .dword $L47 - .dword $L38 - .dword $L38 - .dword $L48 - .dword $L49 - .dword $L38 - .dword $L38 - .dword $L50 - .dword $L38 - .dword $L51 - .dword $L38 - .dword $L38 - .dword $L52 - .text -$L52: - move x4,x30 - sd x2,0(x30) - jal getuint - move x6,x2 - li x7,16 # 0x10 -$L73: - move x4,x21 - move x5,x20 - move x8,x29 - move x9,x27 - jal printnum - j $L84 -$L39: - li x4,1 # 0x1 - move x7,x23 - sd x4,8(x30) - j $L85 -$L40: - move x5,x20 - sd x2,0(x30) - jalr x21 - j $L84 -$L41: - lw x3,0(x2) - move x7,x23 - add x2,x2,8 -$L54: - bge x29,x0,$L85 - move x29,x3 - li x3,-1 # 0xffffffffffffffff - j $L85 -$L42: - move x7,x23 - li x27,45 # 0x2d - j $L85 -$L43: - blt x29,x0,$L91 - move x7,x23 - j $L85 -$L74: - move x7,x23 - li x27,48 # 0x30 - j $L85 -$L44: - lb x8,1(x7) - addw x3,x4,-48 - move x7,x23 - addw x4,x8,-48 - sltu x4,x4,10 - beq x4,x0,$L54 -$L55: - add x7,x7,1 - lb x4,0(x7) - sllw x9,x3,1 - sllw x3,x3,3 - addw x3,x9,x3 - addw x9,x4,-48 - addw x3,x3,x8 - sltu x9,x9,10 - addw x3,x3,-48 - move x8,x4 - bne x9,x0,$L55 - j $L54 -$L45: - lw x4,0(x2) - add x2,x2,8 - move x5,x20 - sd x2,0(x30) - jalr x21 - j $L84 -$L46: - slt x3,x5,2 - bne x3,x0,$L69 -$L88: - add x3,x2,8 - sd x3,0(x30) - ld x6,0(x2) - blt x6,x0,$L72 -$L89: - li x7,10 # 0xa - j $L73 -$L47: - addw x5,x5,1 - move x7,x23 - j $L85 -$L48: - move x4,x30 - sd x2,0(x30) - jal getuint - move x6,x2 - li x7,8 # 0x8 - j $L73 -$L49: - sd x2,0(x30) - li x4,48 # 0x30 - move x5,x20 - jalr x21 - li x4,120 # 0x78 - move x5,x20 - jalr x21 - ld x2,0(x30) - li x7,16 # 0x10 - add x3,x2,8 - sd x3,0(x30) - ld x6,0(x2) - j $L73 -$L50: - add x4,x2,8 - sd x4,0(x30) - ld x2,0(x2) - sd x2,16(x30) - beq x2,x0,$L92 -$L58: - ble x29,x0,$L59 - li x2,45 # 0x2d - beq x27,x2,$L59 - ld x4,16(x30) - move x5,x3 - sd x3,24(x30) - jal strnlen - sllw x2,x2,0 - subw x2,x29,x2 - move x29,x2 - ld x3,24(x30) - ble x2,x0,$L59 - move x29,x2 -$L60: - sd x3,24(x30) - move x4,x27 - move x5,x20 - addw x29,x29,-1 - jalr x21 - ld x3,24(x30) - bne x29,x0,$L60 -$L59: - ld x2,16(x30) - lb x4,0(x2) - add x27,x2,1 - beq x4,x0,$L62 -$L80: - blt x3,x0,$L67 - addw x2,x3,-1 - move x3,x2 - beq x2,x24,$L62 -$L67: - ld x2,8(x30) - beq x2,x0,$L63 - addw x2,x4,-32 - sltu x2,x2,95 - beq x2,x0,$L93 -$L63: - sd x3,24(x30) - move x5,x20 - jalr x21 - ld x3,24(x30) -$L64: - lb x4,0(x27) - addw x29,x29,-1 - add x27,x27,1 - bne x4,x0,$L80 -$L62: - ble x29,x0,$L84 -$L79: - addw x29,x29,-1 - li x4,32 # 0x20 - move x5,x20 - jalr x21 - bne x29,x0,$L79 - j $L84 -$L51: - move x4,x30 - sd x2,0(x30) - jal getuint - move x6,x2 - li x7,10 # 0xa - j $L73 -$L93: - sd x3,24(x30) - li x4,63 # 0x3f - move x5,x20 - jalr x21 - ld x3,24(x30) - j $L64 -$L91: - move x7,x23 - move x29,x0 - j $L85 -$L92: - add x2,x26,%lo($LC1) - sd x2,16(x30) - j $L58 -$L72: - sd x6,24(x30) - li x4,45 # 0x2d - move x5,x20 - jalr x21 - ld x6,24(x30) - li x7,10 # 0xa - sub x6,zero,x6 - j $L73 -$L69: - bne x5,x0,$L88 - lw x6,0(x2) - add x2,x2,8 - sd x2,0(x30) - bge x6,x0,$L89 - j $L72 - .end vprintfmt - .size vprintfmt, .-vprintfmt - .align 2 - .globl printf - .ent printf - .type printf, @function -printf: - .frame x30,96,x1 # vars= 16, regs= 1/0, args= 0 - .mask 0x00000002,-72 - .fmask 0x00000000,0 - add x30,x30,-96 - add x2,x30,40 - move x3,x4 - lui x4,%hi(putchar) - sd x5,40(x30) - sd x6,48(x30) - sd x7,56(x30) - add x4,x4,%lo(putchar) - move x5,x0 - move x6,x3 - move x7,x2 - sd x1,24(x30) - sd x8,64(x30) - sd x9,72(x30) - sd x10,80(x30) - sd x11,88(x30) - sd x2,0(x30) - jal vprintfmt - li x4,-1 # 0xffffffffffffffff - jal putchar - ld x1,24(x30) - move x2,x0 - add x30,x30,96 - j x1 - .end printf - .size printf, .-printf - .local buflen.1596 - .comm buflen.1596,4,4 - .local buf.1595 - .comm buf.1595,64,8 - .ident "GCC: (GNU) 4.6.1" diff --git a/mt/common/syscalls.c b/mt/common/syscalls.c deleted file mode 100755 index f95dde4..0000000 --- a/mt/common/syscalls.c +++ /dev/null @@ -1,265 +0,0 @@ -#include -#include -#include -#include "pcr.h" - -void exit(int code) -{ - volatile uint64_t magic_mem[8] = {0}; - magic_mem[0] = 1; - magic_mem[1] = code; - __sync_synchronize(); - mtpcr(PCR_TOHOST, (long)magic_mem); - while(1); -} - -void printstr(const char* s) -{ - volatile uint64_t magic_mem[8] = {0}; - magic_mem[0] = 4; - magic_mem[1] = 1; - magic_mem[2] = (unsigned long)s; - magic_mem[3] = strlen(s); - __sync_synchronize(); - mtpcr(PCR_TOHOST, (long)magic_mem); - while(mtpcr(PCR_FROMHOST, 0) == 0); -} - -int putchar(int ch) -{ - #define buffered_putch_bufsize 64 - static char buf[buffered_putch_bufsize]; - static int buflen = 0; - - if(ch != -1) - buf[buflen++] = ch; - - if(ch == -1 || buflen == buffered_putch_bufsize) - { - volatile uint64_t magic_mem[8] = {0}; - magic_mem[0] = 4; - magic_mem[1] = 1; - magic_mem[2] = (long)buf; - magic_mem[3] = buflen; - __sync_synchronize(); - mtpcr(PCR_TOHOST, (long)magic_mem); - while(mtpcr(PCR_FROMHOST, 0) == 0); - - buflen = 0; - } - - return 0; -} - -void printhex(uint64_t x) -{ - char str[17]; - int i; - for (i = 0; i < 16; i++) - { - str[15-i] = (x & 0xF) + ((x & 0xF) < 10 ? '0' : 'a'-10); - x >>= 4; - } - str[16] = 0; - - printstr(str); -} - -static void printnum(void (*putch)(int, void**), void **putdat, - unsigned long long num, unsigned base, int width, int padc) -{ - if (num >= base) - printnum(putch, putdat, num / base, base, width - 1, padc); - else while (--width > 0) - putch(padc, putdat); - - putch("0123456789abcdef"[num % base], putdat); -} - -static unsigned long long getuint(va_list *ap, int lflag) -{ - if (lflag >= 2) - return va_arg(*ap, unsigned long long); - else if (lflag) - return va_arg(*ap, unsigned long); - else - return va_arg(*ap, unsigned int); -} - -static long long getint(va_list *ap, int lflag) -{ - if (lflag >= 2) - return va_arg(*ap, long long); - else if (lflag) - return va_arg(*ap, long); - else - return va_arg(*ap, int); -} - -void vprintfmt(void (*putch)(int, void**), void **putdat, const char *fmt, va_list ap) -{ - register const char* p; - const char* last_fmt; - register int ch, err; - unsigned long long num; - int base, lflag, width, precision, altflag; - char padc; - - while (1) { - while ((ch = *(unsigned char *) fmt) != '%') { - if (ch == '\0') - return; - fmt++; - putch(ch, putdat); - } - fmt++; - - // Process a %-escape sequence - last_fmt = fmt; - padc = ' '; - width = -1; - precision = -1; - lflag = 0; - altflag = 0; - reswitch: - switch (ch = *(unsigned char *) fmt++) { - - // flag to pad on the right - case '-': - padc = '-'; - goto reswitch; - - // flag to pad with 0's instead of spaces - case '0': - padc = '0'; - goto reswitch; - - // width field - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - for (precision = 0; ; ++fmt) { - precision = precision * 10 + ch - '0'; - ch = *fmt; - if (ch < '0' || ch > '9') - break; - } - goto process_precision; - - case '*': - precision = va_arg(ap, int); - goto process_precision; - - case '.': - if (width < 0) - width = 0; - goto reswitch; - - case '#': - altflag = 1; - goto reswitch; - - process_precision: - if (width < 0) - width = precision, precision = -1; - goto reswitch; - - // long flag (doubled for long long) - case 'l': - lflag++; - goto reswitch; - - // character - case 'c': - putch(va_arg(ap, int), putdat); - break; - - // string - case 's': - if ((p = va_arg(ap, char *)) == NULL) - p = "(null)"; - if (width > 0 && padc != '-') - for (width -= strnlen(p, precision); width > 0; width--) - putch(padc, putdat); - for (; (ch = *p) != '\0' && (precision < 0 || --precision >= 0); width--) { - if (altflag && (ch < ' ' || ch > '~')) - putch('?', putdat); - else - putch(ch, putdat); - p++; - } - for (; width > 0; width--) - putch(' ', putdat); - break; - - // (signed) decimal - case 'd': - num = getint(&ap, lflag); - if ((long long) num < 0) { - putch('-', putdat); - num = -(long long) num; - } - base = 10; - goto number; - - // unsigned decimal - case 'u': - num = getuint(&ap, lflag); - base = 10; - goto number; - - // (unsigned) octal - case 'o': - // should do something with padding so it's always 3 octits - num = getuint(&ap, lflag); - base = 8; - goto number; - - // pointer - case 'p': - putch('0', putdat); - putch('x', putdat); - num = (unsigned long long) - (uintptr_t) va_arg(ap, void *); - base = 16; - goto number; - - // (unsigned) hexadecimal - case 'x': - num = getuint(&ap, lflag); - base = 16; - number: - printnum(putch, putdat, num, base, width, padc); - break; - - // escaped '%' character - case '%': - putch(ch, putdat); - break; - - // unrecognized escape sequence - just print it literally - default: - putch('%', putdat); - fmt = last_fmt; - break; - } - } -} - -int printf(const char* fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - - vprintfmt((void*)putchar, 0, fmt, ap); - putchar(-1); - - va_end(ap); - return 0; // incorrect return value, but who cares, anyway? -} diff --git a/mt/common/test-mt.ld b/mt/common/test-mt.ld deleted file mode 100644 index 5523032..0000000 --- a/mt/common/test-mt.ld +++ /dev/null @@ -1,45 +0,0 @@ -/*======================================================================*/ -/* Proxy kernel linker script */ -/*======================================================================*/ -/* This is the linker script used when building the proxy kernel. */ - -/*----------------------------------------------------------------------*/ -/* Setup */ -/*----------------------------------------------------------------------*/ - -/* The OUTPUT_ARCH command specifies the machine architecture where the - argument is one of the names used in the BFD library. More - specifically one of the entires in bfd/cpu-mips.c */ - -OUTPUT_ARCH( "riscv" ) - -/* The ENTRY command specifies the entry point (ie. first instruction - to execute). The symbol _start should be defined in each test. */ - -ENTRY( _start ) - -/*----------------------------------------------------------------------*/ -/* Sections */ -/*----------------------------------------------------------------------*/ - -SECTIONS -{ - - /* text: test code section */ - . = 0x00002000; - .text : - { - crt-mt.o(.text) - *(.text) - } - - /* data: Initialized data segment */ - .data : - { - *(.data) - } - - /* End of uninitalized data segement */ - _end = .; -} - diff --git a/mt/common/test.ld b/mt/common/test.ld deleted file mode 100755 index 952bf53..0000000 --- a/mt/common/test.ld +++ /dev/null @@ -1,45 +0,0 @@ -/*======================================================================*/ -/* Proxy kernel linker script */ -/*======================================================================*/ -/* This is the linker script used when building the proxy kernel. */ - -/*----------------------------------------------------------------------*/ -/* Setup */ -/*----------------------------------------------------------------------*/ - -/* The OUTPUT_ARCH command specifies the machine architecture where the - argument is one of the names used in the BFD library. More - specifically one of the entires in bfd/cpu-mips.c */ - -OUTPUT_ARCH( "riscv" ) - -/* The ENTRY command specifies the entry point (ie. first instruction - to execute). The symbol _start should be defined in each test. */ - -ENTRY( _start ) - -/*----------------------------------------------------------------------*/ -/* Sections */ -/*----------------------------------------------------------------------*/ - -SECTIONS -{ - - /* text: test code section */ - . = 0x00002000; - .text : - { - crt.o(.text) - *(.text) - } - - /* data: Initialized data segment */ - .data : - { - *(.data) - } - - /* End of uninitalized data segement */ - _end = .; -} - diff --git a/mt/common/util.h b/mt/common/util.h deleted file mode 100755 index 83b2b6c..0000000 --- a/mt/common/util.h +++ /dev/null @@ -1,32 +0,0 @@ -// helpful utility and synch functions - -// relies on defining "ncores" before including this file... - -#ifndef __UTIL_H -#define __UTIL_H - -#define rdcycle() ({ unsigned long _c; asm volatile ("rdcycle %0" : "=r"(_c) :: "memory"); _c; }) -#define rdinstret() ({ unsigned long _c; asm volatile ("rdinstret %0" : "=r"(_c) :: "memory"); _c; }) - -void __attribute__((noinline)) barrier() -{ - static volatile int sense; - static volatile int count; - static __thread int threadsense; - - __sync_synchronize(); - - threadsense = !threadsense; - if (__sync_fetch_and_add(&count, 1) == ncores-1) - { - count = 0; - sense = threadsense; - } - else while(sense != threadsense) - ; - - __sync_synchronize(); -} - -#endif //__UTIL_H - -- cgit v1.1