summaryrefslogtreecommitdiff
path: root/bin/nv_init.c
blob: 548e55150b4023e96250775491f4c77fcaf6a08f (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
#include <stdlib.h>
#include <limits.h>
#include <unistd.h>

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

#include <core/device.h>

struct nouveau_object *client;
struct nouveau_object *device;

int
main(int argc, char **argv)
{
	bool suspend = false, wait = false;
	int ret, c;

	while ((c = getopt(argc, argv, "-sw")) != -1) {
		switch (c) {
		case 's':
			suspend = true;
			break;
		case 'w':
			wait = true;
			break;
		case 1:
			return -EINVAL;
		}
	}

	ret = os_client_new(NULL, "trace", argc, argv, &client);
	if (ret)
		return ret;

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

	if (suspend) {
		os_suspend();
		os_resume();
	}

	while (wait && (c = getchar()) == EOF) {
		sched_yield();
	}

	os_client_del(&client);
	nouveau_object_debug();
	return ret;
}