URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Subversion Repositories openrisc
[/] [openrisc/] [trunk/] [orpsocv2/] [sw/] [tests/] [or1200/] [sim/] [or1200-range.S] - Rev 805
Compare with Previous | Blame | View Log
/*OR1200 Range exception testVery basic, testing, checking that the EPC value is correctfor generated range exceptions.Julius Baxter <juliusbaxter at gmail.com>*/////////////////////////////////////////////////////////////////////////// //////// Copyright (C) 2012 Authors and OPENCORES.ORG //////// //////// This source file may be used and distributed without //////// restriction provided that this copyright statement is not //////// removed from the file and that any derivative work contains //////// the original copyright notice and the associated disclaimer. //////// //////// This source file is free software; you can redistribute it //////// and/or modify it under the terms of the GNU Lesser General //////// Public License as published by the Free Software Foundation; //////// either version 2.1 of the License, or (at your option) any //////// later version. //////// //////// This source is distributed in the hope that it will be //////// useful, but WITHOUT ANY WARRANTY; without even the implied //////// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //////// PURPOSE. See the GNU Lesser General Public License for more //////// details. //////// //////// You should have received a copy of the GNU Lesser General //////// Public License along with this source; if not, download it //////// from http://www.opencores.org/lgpl.shtml //////// //////////////////////////////////////////////////////////////////////////#include "spr-defs.h"#include "board.h"#include "or1200-defines.h"/* =================================================== [ exceptions ] === */.section .vectors, "ax"/* ---[ 0x100: RESET exception ]----------------------------------------- */.org 0x100l.movhi r0, 0/* Clear status register */l.ori r1, r0, SPR_SR_SMl.mtspr r0, r1, SPR_SR/* Clear timer */l.mtspr r0, r0, SPR_TTMR/* Init the stack */.global stackl.movhi r1, hi(stack)l.ori r1, r1, lo(stack)l.addi r2, r0, -3l.and r1, r1, r2// Clear r10 -used to remember if we've run the// test with cache eanbeld yet.l.movhi r10, 0/* Jump to program initialisation code */.global _startl.movhi r4, hi(_start)l.ori r4, r4, lo(_start)l.jr r4l.nop/* ---[ 0x700: ILLEGAL INSN exception ]------------------------------------- */.org 0x700l.nop 0x1/* ---[ 0xB00: RANGE exception ]-------------------------------------------- */.org 0xb00l.mfspr r3,r0,SPR_EPCR_BASEl.nop 2// Check the PCl.ori r6,r0,0x7fff // Use this as a mask for the PCl.and r7,r6,r3 // just take the bottom 15 bits, should be enough// Test 1 should be atl.sfeqi r5,1l.bf test1l.nopl.sfeqi r5,2l.bf test2l.noptest1:l.sfnei r7,0xf08 // test 1 trigger insn PCl.bf faill.nop// set the PC to step over the range exceptionl.addi r3,r3,4l.mtspr r0,r3,SPR_EPCR_BASEl.nop 2l.j returnl.noptest2:l.sfnei r7,0xf10 // test 2 - in delay slot, so PC should be of// preceeding l.j insnl.bf faill.nop// set the PC to step over the branch and range exceptionl.addi r3,r3,8l.mtspr r0,r3,SPR_EPCR_BASEl.j returnl.nopreturn:// Clear the OV flagl.mfspr r3,r0,SPR_ESR_BASEl.xori r3,r3,SPR_SR_OVl.mtspr r0,r3,SPR_ESR_BASEl.rfe.org 0xf00ov_tests:// Cause some range exceptions at known PC// Trigger a range execptionl.movhi r2,0x4000// Test 1l.ori r5,r0,1// Should have 0x40000000 + 0x40000000, at PC 0xf08l.add r4,r2,r2// Test 2 - delay slotl.ori r5,r0,2l.j a_place// Should have 0x40000000 + 0x40000000, at PC 0xf10 (insn before as// we're in delay slot)l.add r4,r2,r2a_place:l.nop// Check if we've run with cache yet - if so then// r10 will contain nonzerol.sfeq r10,r0l.bnf passl.nop// Init caches and restartl.jal _cache_initl.nopl.j _startl.ori r10,r0,1pass:l.movhi r3,0l.nop 1/* =================================================== [ text section ] === */.section .text/* =================================================== [ start ] === */.global _start_start:// Set up SR to have range exception enabledl.mfspr r3, r0, SPR_SRl.nop 0x2l.ori r3,r3,SPR_SR_OVEl.nop 0x2l.mtspr r0,r3,SPR_SR// Now jump to the testsl.movhi r1,hi(ov_tests)l.ori r1,r1,lo(ov_tests)l.jr r1l.nopfail:l.nop 2l.ori r3,r0,1l.nop 1
