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

Subversion Repositories ao486

[/] [ao486/] [trunk/] [syn/] [components/] [ps2/] [software/] [exe_bsp/] [HAL/] [inc/] [sys/] [alt_exceptions.h] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 alfik
#ifndef __ALT_EXCEPTIONS_H__
2
#define __ALT_EXCEPTIONS_H__
3
 
4
/******************************************************************************
5
*                                                                             *
6
* License Agreement                                                           *
7
*                                                                             *
8
* Copyright (c) 2008 Altera Corporation, San Jose, California, USA.           *
9
* All rights reserved.                                                        *
10
*                                                                             *
11
* Permission is hereby granted, free of charge, to any person obtaining a     *
12
* copy of this software and associated documentation files (the "Software"),  *
13
* to deal in the Software without restriction, including without limitation   *
14
* the rights to use, copy, modify, merge, publish, distribute, sublicense,    *
15
* and/or sell copies of the Software, and to permit persons to whom the       *
16
* Software is furnished to do so, subject to the following conditions:        *
17
*                                                                             *
18
* The above copyright notice and this permission notice shall be included in  *
19
* all copies or substantial portions of the Software.                         *
20
*                                                                             *
21
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  *
22
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,    *
23
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
24
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      *
25
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING     *
26
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER         *
27
* DEALINGS IN THE SOFTWARE.                                                   *
28
*                                                                             *
29
* This agreement shall be governed in all respects by the laws of the State   *
30
* of California and by the laws of the United States of America.              *
31
*                                                                             *
32
******************************************************************************/
33
#include "alt_types.h"
34
#include "system.h"
35
 
36
#ifdef __cplusplus
37
extern "C"
38
{
39
#endif /* __cplusplus */
40
 
41
/*
42
 * This file defines instruction-generated exception handling and registry
43
 * API, exception type enumeration, and handler return value enumeration for
44
 * Nios II.
45
 */
46
 
47
/*
48
 * The following enumeration describes the value in the CPU EXCEPTION
49
 * register CAUSE bit field. Not all exception types will cause the
50
 * processor to go to the exception vector; these are provided for
51
 * reference.
52
 */
53
enum alt_exception_cause_e {
54
  /* Exeption causes that will cause jump to exception vector */
55
  NIOS2_EXCEPTION_INTERRUPT                  = 2,
56
  NIOS2_EXCEPTION_TRAP_INST                  = 3,
57
  NIOS2_EXCEPTION_UNIMPLEMENTED_INST         = 4,
58
  NIOS2_EXCEPTION_ILLEGAL_INST               = 5,
59
  NIOS2_EXCEPTION_MISALIGNED_DATA_ADDR       = 6,
60
  NIOS2_EXCEPTION_MISALIGNED_TARGET_PC       = 7,
61
  NIOS2_EXCEPTION_DIVISION_ERROR             = 8,
62
  NIOS2_EXCEPTION_SUPERVISOR_ONLY_INST_ADDR  = 9,
63
  NIOS2_EXCEPTION_SUPERVISOR_ONLY_INST       = 10,
64
  NIOS2_EXCEPTION_SUPERVISOR_ONLY_DATA_ADDR  = 11,
65
  NIOS2_EXCEPTION_TLB_MISS                   = 12,
66
  NIOS2_EXCEPTION_TLB_EXECUTE_PERM_VIOLATION = 13,
67
  NIOS2_EXCEPTION_MPU_INST_REGION_VIOLATION  = 16,
68
 
69
  /* Exception causes that will NOT cause a jump to exception vector */
70
  NIOS2_EXCEPTION_RESET                      = 0,
71
  NIOS2_EXCEPTION_CPU_ONLY_RESET_REQUEST     = 1,
72
  NIOS2_EXCEPTION_TLB_READ_PERM_VIOLATION    = 14,
73
  NIOS2_EXCEPTION_TLB_WRITE_PERM_VIOLATION   = 15,
74
  NIOS2_EXCEPTION_MPU_DATA_REGION_VIOLATION  = 17,
75
  /*
76
   * This value is passed to an exception handler's cause argument if
77
   * "extra exceptions" information (EXECPTION) register is not
78
   * present in the processor hardware configuration.
79
   */
80
  NIOS2_EXCEPTION_CAUSE_NOT_PRESENT          = -1
81
};
82
typedef enum alt_exception_cause_e alt_exception_cause;
83
 
84
/*
85
 * These define valid return values for a user-defined instruction-generated
86
 * exception handler. The handler should return one of these to indicate
87
 * whether to re-issue the instruction that triggered the exception, or to
88
 * skip it.
89
 */
90
enum alt_exception_result_e {
91
  NIOS2_EXCEPTION_RETURN_REISSUE_INST = 0,
92
  NIOS2_EXCEPTION_RETURN_SKIP_INST    = 1
93
};
94
typedef enum alt_exception_result_e alt_exception_result;
95
 
96
/*
97
 * alt_instruction_exception_register() can be used to register an exception
98
 * handler for instruction-generated exceptions that are not handled by the
99
 * built-in exception handler (i.e. for interrupts).
100
 *
101
 * The registry API is optionally enabled through the "Enable
102
 * Instruction-related Exception API" HAL BSP setting, which will
103
 * define the macro below.
104
 */
105
#ifdef ALT_INCLUDE_INSTRUCTION_RELATED_EXCEPTION_API
106
void alt_instruction_exception_register (
107
  alt_exception_result (*exception_handler)(
108
    alt_exception_cause cause,
109
    alt_u32 exception_pc,
110
    alt_u32 bad_addr) );
111
#endif /*ALT_INCLUDE_INSTRUCTION_RELATED_EXCEPTION_API */
112
 
113
/*
114
 * alt_exception_cause_generated_bad_addr() indicates whether a particular
115
 * exception cause value was from an exception-type that generated a valid
116
 * address in the BADADDR register. The contents of BADADDR is passed to
117
 * a user-registered exception handler in all cases, whether valid or not.
118
 * This routine should be called to validate the bad_addr argument to
119
 * your exception handler.
120
 */
121
int alt_exception_cause_generated_bad_addr(alt_exception_cause cause);
122
 
123
#ifdef __cplusplus
124
}
125
#endif /* __cplusplus */
126
 
127
#endif /* __ALT_EXCEPTIONS_H__ */

powered by: WebSVN 2.1.0

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