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

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_47/] [or1ksim/] [cpu/] [or1k/] [except.c] - Blame information for rev 82

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 82 lampret
extern unsigned long pcnext;
32 51 lampret
extern struct iqueue_entry iqueue[];
33 33 lampret
 
34 82 lampret
extern int delay_insn;
35
 
36 33 lampret
/* Handle OR1K exceptions. */
37
void except_handle(int except, unsigned long ea)
38
{
39 43 lampret
        unsigned long pc_saved;
40 51 lampret
 
41
        printf("Exception 0x%x (%s): ", except, EXCEPT_NAME(except));
42
        printf("Iqueue[0].insn_addr: 0x%x  Eff ADDR: 0x%x\n",  iqueue[0].insn_addr, ea);
43 82 lampret
        printf("  pc: 0x%x  pcnext: 0x%x\n",  pc, pcnext);
44 64 lampret
 
45 33 lampret
#if ONLY_VIRTUAL_MACHINE
46 51 lampret
        printf("WARNING: No exception processing while ONLY_VIRTUAL_MACHINE is defined.\n");
47
        cont_run = 0;
48 33 lampret
#else
49 51 lampret
 
50 82 lampret
        if (delay_insn) {
51
                printf(" INFO: Exception during execution of delay slot insn.\n");
52
                pc -= 4;
53
        }
54
#if 0
55
        if ((pcnext != (pc + 4)) && (except != EXCEPT_ITLBMISS)) {      /* Always execute delay slot insn */
56
                printf("XXXXXXXXXXXXXX\n");
57 77 lampret
                fetch();                                                /* before starting with exception */
58
                decode(&iqueue[0]);                                      /* (itlbmiss is special case) */
59 51 lampret
                execute();
60
        }
61 82 lampret
#endif
62 64 lampret
 
63 33 lampret
        if (!(mfspr(SPR_SR) & SPR_SR_EXR)) {
64 51 lampret
                printf("ABORT: Exception occured while exception detection was disabled.\n");
65 33 lampret
                cont_run = 0;
66
                return;
67
        }
68 51 lampret
 
69 64 lampret
        pc_saved = pc & ~0x3;
70 51 lampret
        mtspr(SPR_EPCR_BASE, pc_saved);
71 33 lampret
        mtspr(SPR_EEAR_BASE, ea);
72 64 lampret
        mtspr(SPR_ESR_BASE, mfspr(SPR_SR));
73
 
74
        /* Address translation is always disabled when starting exception. */
75
        mtspr(SPR_SR, mfspr(SPR_SR) & ~(SPR_SR_DME));
76
        mtspr(SPR_SR, mfspr(SPR_SR) & ~(SPR_SR_IME));
77
 
78 33 lampret
        mtspr(SPR_SR, mfspr(SPR_SR) | SPR_SR_SUPV);     /* SUPV mode */
79 51 lampret
        mtspr(SPR_SR, mfspr(SPR_SR) & ~SPR_SR_EXR);     /* Disable except. */
80 33 lampret
        pc = (unsigned long)except;
81 82 lampret
        pcnext = (unsigned long)except;
82 33 lampret
#endif
83
}

powered by: WebSVN 2.1.0

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