OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_34/] [or1ksim/] [cpu/] [or1k/] [except.c] - Blame information for rev 43

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 33 lampret
/* except.c -- Simulation of OR1K exceptions
2
   Copyright (C) 1999 Damjan Lampret, lampret@opencores.org
3
 
4
This file is part of OpenRISC 1000 Architectural Simulator.
5
 
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2 of the License, or
9
(at your option) any later version.
10
 
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
GNU General Public License for more details.
15
 
16
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software
18
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
19
 
20
#include <stdlib.h>
21
#include <stdio.h>
22
#include <string.h>
23
 
24
#include "abstract.h"
25
#include "except.h"
26
#include "sprs.h"
27
 
28
extern int cont_run;
29
extern struct iqueue_entry iqueue[20];
30
extern unsigned long pc;
31
extern unsigned long pctemp;
32
 
33
/* Handle OR1K exceptions. */
34
void except_handle(int except, unsigned long ea)
35
{
36 43 lampret
        unsigned long pc_saved;
37 33 lampret
#if ONLY_VIRTUAL_MACHINE
38
        printf("WARNING: Exception 0x%x (%s): ", except, EXCEPT_NAME(except));
39
        printf("Insn ADDR: 0x%x  Eff ADDR: 0x%x\n",  iqueue[0].insn_addr, ea);
40
        printf("No exception processing while ONLY_VIRTUAL_MACHINE is defined.\n");
41
#else
42
        if (!(mfspr(SPR_SR) & SPR_SR_EXR)) {
43
                printf("ABORT: Exception 0x%x (%s)", except, EXCEPT_NAME(except));
44
                printf(" occured while exception detection was disabled.\n");
45
                cont_run = 0;
46
                return;
47
        }
48
 
49
        printf("Exception 0x%x (%s): ", except, EXCEPT_NAME(except));
50
        printf("Insn ADDR: 0x%x  Eff ADDR: 0x%x\n",  iqueue[0].insn_addr, ea);
51 43 lampret
 
52
        pc_saved = (iqueue[0].insn_addr & ~0x1) | (mfspr(SPR_SR) & SPR_SR_SUPV);
53 33 lampret
        mtspr(SPR_EPCR_BASE, iqueue[0].insn_addr);
54
        mtspr(SPR_EEAR_BASE, ea);
55
        mtspr(SPR_SR, mfspr(SPR_SR) | SPR_SR_SUPV);     /* SUPV mode */
56
        mtspr(SPR_SR, mfspr(SPR_SR) & ~SPR_SR_EIR);     /* Disable ints. */
57
        pc = (unsigned long)except;
58
        pctemp = (unsigned long)except;
59
#endif
60
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.