scall.S revision 12771
12SN/A# See LICENSE for license details. 21762SN/A 32SN/A#***************************************************************************** 42SN/A# scall.S 52SN/A#----------------------------------------------------------------------------- 62SN/A# 72SN/A# Test syscall trap. 82SN/A# 92SN/A 102SN/A#include "riscv_test.h" 112SN/A#include "test_macros.h" 122SN/A 132SN/ARVTEST_RV64S 142SN/ARVTEST_CODE_BEGIN 152SN/A 162SN/A#ifdef __MACHINE_MODE 172SN/A #define sscratch mscratch 182SN/A #define sstatus mstatus 192SN/A #define scause mcause 202SN/A #define sepc mepc 212SN/A #define sret mret 222SN/A #define stvec_handler mtvec_handler 232SN/A #undef SSTATUS_SPP 242SN/A #define SSTATUS_SPP MSTATUS_MPP 252SN/A#endif 262SN/A 272665Ssaidi@eecs.umich.edu li TESTNUM, 2 282665Ssaidi@eecs.umich.edu 292665Ssaidi@eecs.umich.edu # This is the expected trap code. 302SN/A li t1, CAUSE_USER_ECALL 312SN/A 325569Snate@binkert.org#ifdef __MACHINE_MODE 335569Snate@binkert.org # If running in M mode, use mstatus.MPP to check existence of U mode. 342SN/A # Otherwise, if in S mode, then U mode must exist and we don't need to check. 352SN/A li t0, MSTATUS_MPP 362SN/A csrc mstatus, t0 372432SN/A csrr t1, mstatus 381147SN/A and t0, t0, t1 393453Sgblack@eecs.umich.edu beqz t0, 1f 402984Sgblack@eecs.umich.edu 412984Sgblack@eecs.umich.edu # If U mode doesn't exist, mcause should indicate ECALL from M mode. 421147SN/A li t1, CAUSE_MACHINE_ECALL 432517SN/A#endif 445034Smilesck@eecs.umich.edu 455034Smilesck@eecs.umich.edu1: 462984Sgblack@eecs.umich.edu li t0, SSTATUS_SPP 475358Sgblack@eecs.umich.edu csrc sstatus, t0 482SN/A la t0, 1f 492680Sktlim@umich.edu csrw sepc, t0 502SN/A sret 515569Snate@binkert.org1: 525569Snate@binkert.org 535569Snate@binkert.org li TESTNUM, 1 545569Snate@binkert.orgdo_scall: 555569Snate@binkert.org scall 562SN/A j fail 575569Snate@binkert.org 585569Snate@binkert.org TEST_PASSFAIL 595569Snate@binkert.org 602SN/A .align 2 615569Snate@binkert.org .global stvec_handler 625569Snate@binkert.orgstvec_handler: 635569Snate@binkert.org csrr t0, scause 645569Snate@binkert.org bne t0, t1, fail 655569Snate@binkert.org la t2, do_scall 665569Snate@binkert.org csrr t0, sepc 675569Snate@binkert.org bne t0, t2, fail 685569Snate@binkert.org j pass 695569Snate@binkert.org 705569Snate@binkert.orgRVTEST_CODE_END 715569Snate@binkert.org 725569Snate@binkert.org .data 735569Snate@binkert.orgRVTEST_DATA_BEGIN 745569Snate@binkert.org 755569Snate@binkert.org TEST_DATA 765569Snate@binkert.org 775569Snate@binkert.orgRVTEST_DATA_END 785569Snate@binkert.org