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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
#include <stdlib.h>
#include <limits.h>
#include <unistd.h>
#include <core/os.h>
#include <core/object.h>
#include <core/class.h>
#ifndef ENABLE
#define ENABLE NV_DEVICE_DISABLE_MMIO
#endif
#ifndef DEBUG0
#define DEBUG0 0ULL
#endif
int
main(int argc, char **argv)
{
struct nouveau_object *client;
struct nouveau_object *device;
struct nv_device_class args;
char *rstr = NULL;
int quiet = 0;
int ret, c;
while ((c = getopt(argc, argv, "-q")) != -1) {
switch (c) {
case 'q':
quiet = 1;
break;
case 1:
if (rstr)
return 1;
rstr = optarg;
break;
}
}
ret = os_client_new(NULL, "fatal", argc, argv, &client);
if (ret)
return ret;
args.device = ~0ULL;
args.disable = ~ENABLE;
args.debug0 = ~DEBUG0;
ret = nouveau_object_new(client, ~0, 0, 0x0080, &args, sizeof(args),
&device);
if (ret)
return ret;
while (rstr && *rstr != '\0') {
unsigned long cnt = 1;
unsigned long reg;
if ((reg = strtoul(rstr, &rstr, 0)) == ULONG_MAX)
return 1;
if (*rstr == '/') {
if ((cnt = strtoul(rstr + 1, &rstr, 0)) == ULONG_MAX)
return 1;
} else
if (*rstr == '+') {
if ((cnt = strtoul(rstr + 1, &rstr, 0)) == ULONG_MAX)
return 1;
cnt /= sizeof(CAST);
}
switch (*rstr) {
case ',':
rstr++;
case '\0':
while (cnt--) {
CAST val = READ(reg);
if (quiet)
printk(FMTDATA"\n", val);
else
printk(NAME" "FMTADDR" "FMTDATA"\n", reg, val);
reg += sizeof(CAST);
}
break;
default:
return 1;
}
}
return 0;
}
|