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

Subversion Repositories c0or1k

[/] [c0or1k/] [trunk/] [include/] [l4/] [arch/] [arm/] [exception.h] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 drasko
/*
2
 * Common definitions for exceptions
3
 * across ARM sub-architectures.
4
 *
5
 * Copyright (C) 2010 B Labs Ltd.
6
 */
7
 
8
#ifndef __EXCEPTION_H__
9
#define __EXCEPTION_H__
10
 
11
#include INC_SUBARCH(exception.h)
12
#include INC_ARCH(asm.h)
13
 
14
/* Abort debugging conditions */
15
// #define DEBUG_ABORTS
16
#if defined (DEBUG_ABORTS)
17
#define dbg_abort(...)  printk(__VA_ARGS__)
18
#else
19
#define dbg_abort(...)
20
#endif
21
 
22
/* Codezero-specific abort type */
23
#define ABORT_TYPE_PREFETCH             1
24
#define ABORT_TYPE_DATA                 0
25
 
26
/* If abort is handled and resolved in check_aborts */
27
#define ABORT_HANDLED                   1
28
 
29
/* Codezero makes use of bit 8 (Always Zero) of FSR to define which type of abort */
30
#define set_abort_type(fsr, x)  { fsr &= ~(1 << 8); fsr |= ((x & 1) << 8); }
31
#define is_prefetch_abort(fsr)  ((fsr >> 8) & 0x1)
32
#define is_data_abort(fsr)      (!is_prefetch_abort(fsr))
33
 
34
/* Kernel's data about the fault */
35
typedef struct fault_kdata {
36
        u32 faulty_pc;  /* In DABT: Aborting PC, In PABT: Same as FAR */
37
        u32 fsr;        /* In DABT: DFSR, In PABT: IFSR */
38
        u32 far;        /* In DABT: DFAR, in PABT: IFAR */
39
        pte_t pte;      /* Faulty page table entry */
40
} __attribute__ ((__packed__)) fault_kdata_t;
41
 
42
 
43
/* This is filled on entry to irq handler, only if a process was interrupted.*/
44
extern unsigned int preempted_psr;
45
 
46
/* Implementing these as functions cause circular include dependency for tcb.h */
47
#define TASK_IN_KERNEL(tcb)     (((tcb)->context.spsr & ARM_MODE_MASK) == ARM_MODE_SVC)
48
#define TASK_IN_USER(tcb)       (!TASK_IN_KERNEL(tcb))
49
 
50
static inline int is_user_mode(u32 spsr)
51
{
52
        return ((spsr & ARM_MODE_MASK) == ARM_MODE_USR);
53
}
54
 
55
static inline int in_kernel()
56
{
57
        return (((preempted_psr & ARM_MODE_MASK) == ARM_MODE_SVC)) ? 1 : 0;
58
}
59
 
60
static inline int in_user()
61
{
62
        return !in_kernel();
63
}
64
 
65
int pager_pagein_request(unsigned long vaddr, unsigned long size,
66
                         unsigned int flags);
67
 
68
int fault_ipc_to_pager(u32 faulty_pc, u32 fsr, u32 far, u32 ipc_tag);
69
 
70
int is_kernel_abort(u32 faulted_pc, u32 fsr, u32 far, u32 spsr);
71
int check_abort_type(u32 faulted_pc, u32 fsr, u32 far, u32 spsr);
72
 
73
#endif /* __EXCEPTION_H__ */

powered by: WebSVN 2.1.0

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