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
89
90
91
92
93
94
95
96
|
#include <stdlib.h>
#include <limits.h>
#include <unistd.h>
#include <nvif/client.h>
#include <nvif/device.h>
#include <nvif/class.h>
#ifndef DETECT
#define DETECT false
#endif
#include "util.h"
int
MAIN(int argc, char **argv)
{
struct nvif_client client;
struct nvif_device _device, *device = &_device;
char *rstr = NULL;
char *vstr = NULL;
int quiet = 0;
int ret, c;
while ((c = getopt(argc, argv, "-q"U_GETOPT)) != -1) {
switch (c) {
case 'q':
quiet = 1;
break;
case 1:
if (rstr) {
if (vstr)
return 1;
vstr = optarg;
} else {
rstr = optarg;
}
break;
default:
if (!u_option(c))
return 1;
break;
}
}
ret = u_device("lib", argv[0], "fatal", DETECT, true, 0ULL,
0x00000000, &client, device);
if (ret)
return ret;
while (rstr && *rstr != '\0') {
u32 cnt = 1, val;
u64 reg;
if ((reg = strtoull(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);
}
if (*rstr == '=') {
if ((val = strtoul(rstr + 1, &rstr, 0)) == ULONG_MAX)
return 1;
} else {
if (!vstr ||
(val = strtoul(vstr, NULL, 0)) == ULONG_MAX)
return 1;
}
switch (*rstr) {
case ',':
rstr++;
case '\0':
while (cnt--) {
if (!quiet)
printk(NAME" "FMTADDR" "FMTDATA"\n", reg, (CAST)val);
WRITE(reg, val);
reg += sizeof(CAST);
}
break;
default:
return 1;
}
}
nvif_device_fini(device);
nvif_client_fini(&client);
return 0;
}
|