summaryrefslogtreecommitdiff
path: root/bin/nv_rdfuc.c
blob: 540ac4253dde23f905732807e9a47f5f6984bd2c (plain)
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
#include <stdlib.h>
#include <limits.h>
#include <unistd.h>

#include <core/os.h>
#include <core/object.h>
#include <core/class.h>

int
main(int argc, char **argv)
{
	struct nouveau_object *client;
	struct nouveau_object *device;
	u32 fucbase = ~0;
	int segment = -1;
	int ret, c, i;

	while ((c = getopt(argc, argv, "-cd")) != -1) {
		switch (c) {
		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 = os_client_new(NULL, "info", argc, argv, &client);
	if (ret)
		return ret;

	ret = nouveau_object_new(client, ~0, 0, 0x0080,
				&(struct nv_device_class) {
					.device = ~0ULL,
					.disable = ~NV_DEVICE_DISABLE_MMIO,
					.debug0 = 0,
				}, sizeof(struct nv_device_class), &device);
	if (ret)
		return ret;

	if (segment == 0) {
		u32 size = (nv_ro32(device, fucbase + 0x0108) & 0x1ff) << 8;
		nv_wo32(device, fucbase + 0x0180, 0x02000000);
		for (i = 0; i < size; i += 4) {
			if (!(i & 0xff))
				nv_wo32(device, fucbase + 0x0188, i >> 8);
			printf("0x%08x\n", nv_ro32(device, fucbase + 0x0184));
		}
	} else {
		u32 size = (nv_ro32(device, fucbase + 0x0108) & 0x3fe00) >> 1;
		nv_wo32(device, fucbase + 0x01c0, 0x02000000);
		for (i = 0; i < size; i += 4)
			printf("0x%08x\n", nv_ro32(device, fucbase + 0x01c4));
	}


	os_client_del(&client);
	return 0;
}