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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [arch/] [ia64/] [mm/] [extable.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/*
2
 * Kernel exception handling table support.  Derived from arch/alpha/mm/extable.c.
3
 *
4
 * Copyright (C) 1998, 1999, 2001-2002 Hewlett-Packard Co
5
 *      David Mosberger-Tang <davidm@hpl.hp.com>
6
 */
7
 
8
#include <linux/config.h>
9
 
10
#include <asm/uaccess.h>
11
#include <asm/module.h>
12
 
13
extern const struct exception_table_entry __start___ex_table[];
14
extern const struct exception_table_entry __stop___ex_table[];
15
 
16
static inline const struct exception_table_entry *
17
search_one_table (const struct exception_table_entry *first,
18
                  const struct exception_table_entry *last,
19
                  unsigned long ip, unsigned long gp)
20
{
21
        while (first <= last) {
22
                const struct exception_table_entry *mid;
23
                long diff;
24
 
25
                mid = &first[(last - first)/2];
26
                diff = (mid->addr + gp) - ip;
27
                if (diff == 0)
28
                        return mid;
29
                else if (diff < 0)
30
                        first = mid + 1;
31
                else
32
                        last = mid - 1;
33
        }
34
        return 0;
35
}
36
 
37
#ifndef CONFIG_MODULES
38
register unsigned long main_gp __asm__("gp");
39
#endif
40
 
41
extern spinlock_t modlist_lock;
42
 
43
struct exception_fixup
44
search_exception_table (unsigned long addr)
45
{
46
        const struct exception_table_entry *entry;
47
        struct exception_fixup fix = { 0 };
48
 
49
#ifndef CONFIG_MODULES
50
        /* There is only the kernel to search.  */
51
        entry = search_one_table(__start___ex_table, __stop___ex_table - 1, addr, main_gp);
52
        if (entry)
53
                fix.cont = entry->cont + main_gp;
54
        return fix;
55
#else
56
        struct archdata *archdata;
57
        unsigned long flags;
58
        struct module *mp;
59
 
60
        /* The kernel is the last "module" -- no need to treat it special. */
61
        spin_lock_irqsave(&modlist_lock, flags);
62
        for (mp = module_list; mp; mp = mp->next) {
63
                if (!mp->ex_table_start)
64
                        continue;
65
                archdata = (struct archdata *) mp->archdata_start;
66
                if (!archdata)
67
                        continue;
68
                entry = search_one_table(mp->ex_table_start, mp->ex_table_end - 1,
69
                                         addr, (unsigned long) archdata->gp);
70
                if (entry) {
71
                        fix.cont = entry->cont + (unsigned long) archdata->gp;
72
                        break;
73
                }
74
        }
75
        spin_unlock_irqrestore(&modlist_lock, flags);
76
#endif
77
        return fix;
78
}
79
 
80
void
81
handle_exception (struct pt_regs *regs, struct exception_fixup fix)
82
{
83
        regs->r8 = -EFAULT;
84
        if (fix.cont & 4)
85
                regs->r9 = 0;
86
        regs->cr_iip = (long) fix.cont & ~0xf;
87
        ia64_psr(regs)->ri = fix.cont & 0x3;            /* set continuation slot number */
88
}

powered by: WebSVN 2.1.0

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