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
|
#include <stdlib.h>
#include <limits.h>
#include <unistd.h>
#include <nvif/client.h>
#include <nvif/device.h>
#include <nvif/class.h>
int
main(int argc, char **argv)
{
const char *drv = "lib";
const char *cfg = NULL;
const char *dbg = "error";
u64 dev = ~0ULL;
struct nvif_client *client;
struct nvif_device *device;
u32 fucbase = ~0;
int segment = -1;
int ret, c, i;
while ((c = getopt(argc, argv, "-a:b:cd")) != -1) {
switch (c) {
case 'a': dev = strtoull(optarg, NULL, 0); break;
case 'b': drv = optarg; break;
case 'c':
segment = 0;
break;
case 'd':
segment = 1;
break;
case 1:
fucbase = strtol(optarg, NULL, 0);
break;
}
}
if (fucbase == ~0 || segment < 0 || segment > 1)
return 1;
ret = nvif_client_new(drv, argv[0], dev, cfg, dbg, &client);
if (ret)
return ret;
ret = nvif_device_new(nvif_object(client), 0x00000000, NV_DEVICE,
&(struct nv_device_v0) {
.device = ~0ULL,
.disable = ~NV_DEVICE_V0_DISABLE_MMIO,
.debug0 = 0,
}, sizeof(struct nv_device_v0), &device);
nvif_client_ref(NULL, &client);
if (ret)
return ret;
if (segment == 0) {
u32 size = (nvif_rd32(device, fucbase + 0x0108) & 0x1ff) << 8;
nvif_wr32(device, fucbase + 0x0180, 0x02000000);
for (i = 0; i < size; i += 4) {
if (!(i & 0xff))
nvif_wr32(device, fucbase + 0x0188, i >> 8);
printf("0x%08x\n", nvif_rd32(device, fucbase + 0x0184));
}
} else {
u32 size = (nvif_rd32(device, fucbase + 0x0108) & 0x3fe00) >> 1;
nvif_wr32(device, fucbase + 0x01c0, 0x02000000);
for (i = 0; i < size; i += 4)
printf("0x%08x\n", nvif_rd32(device, fucbase + 0x01c4));
}
nvif_device_ref(NULL, &device);
return 0;
}
|