]> git.lizzy.rs Git - plan9front.git/blob - sys/src/9/alphapc/faultalpha.c
merge
[plan9front.git] / sys / src / 9 / alphapc / faultalpha.c
1 #include        "u.h"
2 #include        "../port/lib.h"
3 #include        "mem.h"
4 #include        "dat.h"
5 #include        "fns.h"
6 #include        "ureg.h"
7 #include        "../port/error.h"
8
9 /*
10  *  find out fault address and type of access.
11  *  Call common fault handler.
12  */
13 void
14 faultalpha(Ureg *ur)
15 {
16         ulong addr, cause;
17         int read, user;
18         char buf[ERRMAX];
19         uvlong x;
20
21         x = ur->a0&0xffffffff80000000LL;
22         if (x != 0LL && x != 0xffffffff80000000LL)
23                 iprint("faultalpha bad addr %llux pc %llux\n", ur->a0, ur->pc);
24
25         addr = (ulong)ur->a0;
26         cause = (ulong)ur->a2;
27         addr &= ~(BY2PG-1);
28         read = (cause !=1);
29         user = (ulong)ur->status&UMODE;
30
31 /*      print("fault %s pc=0x%lux addr=0x%lux 0x%lux\n",
32                 read? (cause != 0) ? "ifetch" : "read" : "write", (ulong)ur->pc, addr, (ulong)ur->a1); /**/
33
34         if(fault(addr, read) == 0)
35                 return;
36
37         if(user){
38                 sprint(buf, "sys: trap: fault %s addr=0x%lux",
39                         read? (cause != 0) ? "ifetch" : "read" : "write", (ulong)ur->a0);
40                 postnote(up, 1, buf, NDebug);
41                 return;
42         }
43
44         iprint("kernel %s vaddr=0x%lux\n", read? (cause != 0) ? "ifetch" : "read" : "write", (ulong)ur->a0);
45         if(0)
46                 mmudump();
47         dumpregs(ur);
48         _dumpstack(ur);
49         exit(1);
50 }
51
52 /*
53  * called in sysfile.c
54  */
55 void
56 evenaddr(ulong addr)
57 {
58         if(addr & 3){
59                 postnote(up, 1, "sys: odd address", NDebug);
60                 error(Ebadarg);
61         }
62 }