URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Subversion Repositories openrisc
[/] [openrisc/] [trunk/] [orpsocv2/] [sw/] [tests/] [or1200/] [sim/] [or1200-tick.S] - Rev 393
Go to most recent revision | Compare with Previous | Blame | View Log
/*Tick timer interrupt testWe specify our own reset and initialisation routines as we don't linkin the usual initialisation code.Based on original or1200 tick timer testmodified byJulius Baxter, julius@opencores.orgTadej Markovic, tadej@opencores.org*/////////////////////////////////////////////////////////////////////////// //////// Copyright (C) 2010 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"#define RAM_START RAM_BASE/* Within the test we'll use following global variables:r16 interrupt counterr17 current tick timer comparison counterr18 sanity counterr19 loop counterr20 temp value of SR regr21 temp value of TTMR reg.r23 RAM_STARTr25-r31 used by int handlerThe test do the following:We set up the tick timer to trigger once and then we trigger interruptsincrementally on every cycle in the specified test program; oninterrupt handler we check if data computed so far exactly matchesprecalculated values. If interrupt has returned incorreclty, we candetect this using assertion routine at the end.*//* =================================================== [ 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/* Jump to program initialisation code */.global _startl.movhi r4, hi(_start)l.ori r4, r4, lo(_start)l.jr r4l.nop/* ================================================== [ tick interrupt ] === */.org 0x500.global _tick_handler_tick_handler:l.addi r31,r3,0# get interrupted program pcl.mfspr r25,r0,SPR_EPCR_BASE# calculate instruction addressl.movhi r26,hi(_ie_start)l.ori r26,r26,lo(_ie_start)l.addi r3,r25,0 #print insn indexl.nop 2l.sub r25,r25,r26l.addi r3,r25,0 #print insn indexl.nop 2l.addi r3,r31,0 # restore r3l.sfeqi r25, 0x00l.bf _i00l.sfeqi r25, 0x04l.bf _i04l.sfeqi r25, 0x08l.bf _i08l.sfeqi r25, 0x0cl.bf _i0cl.sfeqi r25, 0x10l.bf _i10l.sfeqi r25, 0x14l.bf _i14l.sfeqi r25, 0x18l.bf _i18l.sfeqi r25, 0x1cl.bf _i1cl.sfeqi r25, 0x20l.bf _i20l.sfeqi r25, 0x24l.bf _i24l.sfeqi r25, 0x28l.bf _i28l.sfeqi r25, 0x2cl.bf _i2cl.sfeqi r25, 0x30l.bf _i30l.sfeqi r25, 0x34l.bf _i34l.sfeqi r25, 0x38l.bf _i38l.nop# value not defined_die:l.nop 2 #print r3l.addi r3,r0,0xeeeel.nop 2l.addi r3,r0,1l.jal exitl.nop1:l.j 1bl.nop/* =================================================== [ text section ] === */.section .text/* =================================================== [ start ] === */.global _start_start:/* Instruction cache enable *//* Check if IC present and skip enabling otherwise */l.mfspr r24,r0,SPR_UPRl.andi r26,r24,SPR_UPR_ICPl.sfeq r26,r0l.bf .L8l.nop/* Disable IC */l.mfspr r6,r0,SPR_SRl.addi r5,r0,-1l.xori r5,r5,SPR_SR_ICEl.and r5,r6,r5l.mtspr r0,r5,SPR_SR/* Establish cache block sizeIf BS=0, 16;If BS=1, 32;r14 contain block size*/l.mfspr r24,r0,SPR_ICCFGRl.andi r26,r24,SPR_ICCFGR_CBSl.srli r28,r26,7l.ori r30,r0,16l.sll r14,r30,r28/* Establish number of cache setsr16 contains number of cache setsr28 contains log(# of cache sets)*/l.andi r26,r24,SPR_ICCFGR_NCSl.srli r28,r26,3l.ori r30,r0,1l.sll r16,r30,r28/* Invalidate IC */l.addi r6,r0,0l.sll r5,r14,r28.L7:l.mtspr r0,r6,SPR_ICBIRl.sfne r6,r5l.bf .L7l.add r6,r6,r14/* Enable IC */l.mfspr r6,r0,SPR_SRl.ori r6,r6,SPR_SR_ICEl.mtspr r0,r6,SPR_SRl.nopl.nopl.nopl.nopl.nopl.nopl.nopl.nop.L8:/* Data cache enable *//* Check if DC present and skip enabling otherwise */l.mfspr r24,r0,SPR_UPRl.andi r26,r24,SPR_UPR_DCPl.sfeq r26,r0l.bf .L10l.nop/* Disable DC */l.mfspr r6,r0,SPR_SRl.addi r5,r0,-1l.xori r5,r5,SPR_SR_DCEl.and r5,r6,r5l.mtspr r0,r5,SPR_SR/* Establish cache block sizeIf BS=0, 16;If BS=1, 32;r14 contain block size*/l.mfspr r24,r0,SPR_DCCFGRl.andi r26,r24,SPR_DCCFGR_CBSl.srli r28,r26,7l.ori r30,r0,16l.sll r14,r30,r28/* Establish number of cache setsr16 contains number of cache setsr28 contains log(# of cache sets)*/l.andi r26,r24,SPR_DCCFGR_NCSl.srli r28,r26,3l.ori r30,r0,1l.sll r16,r30,r28/* Invalidate DC */l.addi r6,r0,0l.sll r5,r14,r28.L9:l.mtspr r0,r6,SPR_DCBIRl.sfne r6,r5l.bf .L9l.add r6,r6,r14/* Enable DC */l.mfspr r6,r0,SPR_SRl.ori r6,r6,SPR_SR_DCEl.mtspr r0,r6,SPR_SR.L10:// Kick off testl.jal _mainl.nop/* ========================================================= [ main ] === */.global _main_main:## set tick counter to initial 3 cycles#l.addi r16,r0,0l.addi r17,r0,1l.addi r18,r0,0l.addi r19,r0,0l.addi r22,r0,0l.movhi r23,hi(RAM_START)l.ori r23,r23,lo(RAM_START)## unmask all ints#l.movhi r5,0xffffl.ori r5,r5,0xffffl.mtspr r0,r5,SPR_PICMR # set PICMR# Set r20 to hold enable exceptions and interruptsl.mfspr r20,r0,SPR_SRl.ori r20,r20,SPR_SR_SM|SPR_SR_TEE|SPR_SR_F# Set r21 to hold value of TTMRl.movhi r5,hi(SPR_TTMR_SR | SPR_TTMR_IE)l.add r21,r5,r17## MAIN LOOP#_main_loop:# reinitialize memory and registersl.addi r3,r0,0xaaaal.addi r9,r0,0xbbbbl.sw 0(r23),r3l.sw 4(r23),r9l.sw 8(r23),r3# Reinitializes tick timerl.addi r17,r17,1l.mtspr r0,r0,SPR_TTCR # set TTCRl.mtspr r0,r21,SPR_TTMR # set TTMRl.mtspr r0,r0,SPR_TTCR # set TTCRl.addi r21,r21,1# Enable exceptions and interruptsl.mtspr r0,r20,SPR_SR # set SR##### TEST CODE #####_ie_start:l.movhi r3,0x1234 #00l.sw 0(r23),r3 #04l.movhi r3,hi(RAM_START) #08l.lwz r3,0(r3) #0cl.movhi r3,hi(RAM_START) #10l.addi r3,r3,4 #14l.j 1f #18l.lwz r3,0(r3) #1cl.addi r3,r3,1 #201:l.sfeqi r3,0xdead #24l.jal 2f #28l.addi r3,r0,0x5678 #2c_return_addr:2:l.bf _die #30l.sw 8(r23),r3 #34_ie_end:l.nop #38##### END OF TEST CODE ###### do some testingl.j _main_loopl.nop_i00:l.sfeqi r3,0xaaaal.bnf _diel.nopl.j _resumel.nop_i04:l.movhi r26,0x1234l.sfeq r3,r26l.bnf _diel.nopl.lwz r26,0(r23)l.sfeqi r26,0xaaaal.bnf _diel.nopl.j _resumel.nop_i08:l.movhi r26,0x1234l.sfeq r3,r26l.bnf _diel.nopl.lwz r27,0(r23)l.sfeq r27,r26l.bnf _diel.nopl.j _resumel.nop_i0c:l.sfeq r3,r23l.bnf _diel.nopl.j _resumel.nop_i10:l.movhi r26,0x1234l.sfeq r26,r3l.bnf _diel.nopl.j _resumel.nop_i14:l.sfeq r3,r23l.bnf _diel.nopl.j _resumel.nop_i18:l.addi r26,r23,4l.sfeq r3,r26l.bnf _diel.nopl.j _resumel.nop_i1c:l.j _diel.nop_i20:l.j _diel.nop_i24:l.mfspr r26,r0,SPR_ESR_BASEl.addi r30,r3,0l.addi r3,r26,0l.nop 2l.addi r3,r30,0l.andi r26,r26,SPR_SR_Fl.sfeq r26,r0l.bf _diel.nopl.sfeqi r3,0xbbbbl.bnf _diel.nopl.j _resumel.nop_i28:l.mfspr r26,r0,SPR_ESR_BASEl.addi r30,r3,0l.addi r3,r26,0l.nop 2l.addi r3,r30,0l.andi r26,r26,SPR_SR_Fl.sfeq r26,r0l.bnf _diel.nopl.sfeqi r22,1l.bf _resumel.addi r22,r0,1l.sfeqi r9,0xbbbbl.bnf _diel.nopl.j _resumel.nop_i2c:l.movhi r26,hi(_return_addr)l.ori r26,r26,lo(_return_addr)l.sfeq r9,r26l.bnf _diel.nopl.sfeqi r3,0xbbbbl.bnf _diel.nopl.j _resumel.nop_i30:l.sfeqi r3,0x5678l.bnf _diel.nopl.j _resumel.nop_i34:l.sfeqi r3,0x5678l.bnf _diel.nopl.lwz r26,8(r23)l.sfeqi r26,0xaaaal.bnf _diel.nopl.j _resumel.nop_i38:l.lwz r26,8(r23)l.sfeqi r26,0x5678l.bnf _diel.nop## mark finished ok#l.movhi r3,hi(0xdeaddead)l.ori r3,r3,lo(0xdeaddead)l.nop 2l.movhi r3,hi(0x8000000d)l.ori r3,r3,lo(0x8000000d)l.nop 2l.addi r3,r0,0l.jal exitl.nop_ok:l.j _okl.nop_resume:l.mfspr r27,r0,SPR_ESR_BASEl.addi r26,r0,SPR_SR_TEEl.addi r28,r0,-1l.xor r26,r26,r28l.and r26,r26,r27l.mtspr r0,r26,SPR_ESR_BASEl.rfel.addi r3,r3,5 # should not be executed
Go to most recent revision | Compare with Previous | Blame | View Log
