~kris/9p

9hist

ref: 73aa6a9430656ae5fc0c3edc2f264479fd9db2b5 9hist/pc/fault386.c -rw-r--r-- 720 bytes
73aa6a94 — David du Colombier Plan 9 from Bell Labs 1995-01-01 31 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include	"u.h"
#include	"../port/lib.h"
#include	"mem.h"
#include	"dat.h"
#include	"fns.h"
#include	"ureg.h"
#include	"io.h"

static void
fault386(Ureg *ur, void *arg)
{
	ulong addr;
	int read;
	int user;
	int n;
	int insyscall;
	char buf[ERRLEN];

	USED(arg);

	insyscall = up->insyscall;
	up->insyscall = 1;
	addr = getcr2();
	read = !(ur->ecode & 2);
	user = (ur->cs&0xffff) == UESEL;
	spllo();
	n = fault(addr, read);
	if(n < 0){
		if(user){
			sprint(buf, "sys: trap: fault %s addr=0x%lux",
				read? "read" : "write", addr);
			postnote(up, 1, buf, NDebug);
			return;
		}
		dumpregs(ur);
		panic("fault: 0x%lux\n", addr);
	}
	up->insyscall = insyscall;
}

void
faultinit(void)
{
	setvec(Faultvec, fault386, 0);
}