Subversion Repositories HelenOS

Rev

Rev 2298 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2128 jermar 1
/*
2304 kebrt 2
 * Copyright (c) 2007 Michal Kebrt, Petr Stepan
2180 stepan 3
 *
2128 jermar 4
 * All rights reserved.
5
 *
6
 * Redistribution and use in source and binary forms, with or without
7
 * modification, are permitted provided that the following conditions
8
 * are met:
9
 *
10
 * - Redistributions of source code must retain the above copyright
11
 *   notice, this list of conditions and the following disclaimer.
12
 * - Redistributions in binary form must reproduce the above copyright
13
 *   notice, this list of conditions and the following disclaimer in the
14
 *   documentation and/or other materials provided with the distribution.
15
 * - The name of the author may not be used to endorse or promote products
16
 *   derived from this software without specific prior written permission.
17
 *
18
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
 */
29
 
30
/** @addtogroup arm32  
31
 * @{
32
 */
33
/** @file
34
 */
35
 
36
#ifndef KERN_arm32_EXCEPTION_H_
37
#define KERN_arm32_EXCEPTION_H_
38
 
39
#include <arch/types.h>
2298 stepan 40
#include <arch/regutils.h>
2128 jermar 41
 
2262 stepan 42
#define HIGH_EXCEPTION_VECTORS
43
 
44
#ifdef HIGH_EXCEPTION_VECTORS
45
    #define EXC_BASE_ADDRESS    0xffff0000
46
#else
47
    #define EXC_BASE_ADDRESS    0x0
48
#endif
49
 
2180 stepan 50
/* Exception Vectors */
2304 kebrt 51
#define EXC_RESET_VEC          (EXC_BASE_ADDRESS + 0x0)
52
#define EXC_UNDEF_INSTR_VEC    (EXC_BASE_ADDRESS + 0x4)
53
#define EXC_SWI_VEC            (EXC_BASE_ADDRESS + 0x8)
54
#define EXC_PREFETCH_ABORT_VEC (EXC_BASE_ADDRESS + 0xc)
55
#define EXC_DATA_ABORT_VEC     (EXC_BASE_ADDRESS + 0x10)
56
#define EXC_IRQ_VEC            (EXC_BASE_ADDRESS + 0x18)
57
#define EXC_FIQ_VEC            (EXC_BASE_ADDRESS + 0x1c)
2180 stepan 58
 
2235 stepan 59
/* Exception numbers */
2304 kebrt 60
#define EXC_RESET           0
61
#define EXC_UNDEF_INSTR     1
62
#define EXC_SWI             2
63
#define EXC_PREFETCH_ABORT  3
64
#define EXC_DATA_ABORT      4
65
#define EXC_IRQ             5
66
#define EXC_FIQ             6
2235 stepan 67
 
2128 jermar 68
typedef struct {
2304 kebrt 69
    uint32_t spsr;
2286 stepan 70
    uint32_t sp;
71
    uint32_t lr;
2178 kebrt 72
 
2304 kebrt 73
    uint32_t r0;
74
    uint32_t r1;
75
    uint32_t r2;
76
    uint32_t r3;
77
    uint32_t r4;
78
    uint32_t r5;
79
    uint32_t r6;
80
    uint32_t r7;
81
    uint32_t r8;
82
    uint32_t r9;
83
    uint32_t r10;
84
    uint32_t r11;
85
    uint32_t r12;
2286 stepan 86
 
2304 kebrt 87
    uint32_t pc;
2128 jermar 88
} istate_t;
89
 
2286 stepan 90
 
91
 
2128 jermar 92
static inline void istate_set_retaddr(istate_t *istate, uintptr_t retaddr)
93
{
2298 stepan 94
    istate->pc = retaddr;
2128 jermar 95
}
96
 
97
/** Return true if exception happened while in userspace */
98
static inline int istate_from_uspace(istate_t *istate)
99
{
2298 stepan 100
    return (istate->spsr & STATUS_REG_MODE_MASK) == USER_MODE;
2128 jermar 101
}
102
static inline unative_t istate_get_pc(istate_t *istate)
103
{
2298 stepan 104
    return istate->pc;
2128 jermar 105
}
106
 
2235 stepan 107
extern void setup_exception_stacks(void);
2180 stepan 108
extern void install_exception_handlers(void);
109
extern void exception_init(void);
2304 kebrt 110
extern void print_istate(istate_t *istate);
2180 stepan 111
 
2128 jermar 112
#endif
113
 
114
/** @}
115
 */