summaryrefslogtreecommitdiff
path: root/ramht.cpp
blob: 77897fefe0b148fa2c18f60cb6634aa5bafd8128 (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
#include "nvlib.h"
#include <boost/io/ios_state.hpp>
using namespace std;
using namespace boost;

void print_ramht(shared_ptr<nv_ramht> ramht)
{
	for(unsigned i = 0; i < ramht->entries; ++i) {
		nv_ramht_entry entry = ramht->get_at(i);
		if(!entry.valid)
			continue;
		cout << "[" << i << "] " << make_pair(ramht->dev, entry) << endl;
	}
}

int main(int argc, char** argv)
{
	unique_ptr<nv_device> dev(nv_device::open_default());

	if(dev->dev_ramht)
		print_ramht(dev->dev_ramht);
	else {
		unsigned chans = 0;
		for(unsigned i = 0; i < dev->channels; ++i) {
			shared_ptr<nv_hwchannel> hwchan = dev->hwchannel(i);
			if(!hwchan)
				continue;

			if(chans)
				cout << endl;
			cout << "Channel " << dec << i << endl;
			print_ramht(hwchan->ramht);
			++chans;
		}
	}
	return 0;
}