bzr branch
http://darksoft.org/webbzr/alps/bar_resolve
1
by Suren A. Chilingaryan
Test application for resolving user-space BAR addresses |
1 |
#include <linux/init.h> |
2 |
#include <linux/module.h> |
|
3 |
#include <linux/device.h> |
|
4 |
#include <linux/types.h> |
|
5 |
#include <linux/cdev.h> |
|
6 |
#include <linux/fs.h> |
|
7 |
#include <linux/slab.h> |
|
8 |
#include <linux/sysfs.h> |
|
9 |
||
10 |
#include "mod.h" |
|
11 |
#include "dev.h" |
|
12 |
#include "debug.h" |
|
13 |
||
14 |
#include "rdma.h" |
|
15 |
||
16 |
static ssize_t test_request_show(struct device *dev, struct device_attribute *attr, char *buf) { |
|
17 |
test_dev_t *test = dev_get_drvdata(dev); |
|
18 |
||
19 |
return sprintf(buf, "%lx\n", test->addr); |
|
20 |
}
|
|
21 |
||
22 |
static ssize_t test_request_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { |
|
23 |
unsigned long ua; |
|
24 |
||
25 |
test_dev_t *test = dev_get_drvdata(dev); |
|
26 |
||
27 |
if (sscanf(buf, "%lx", &ua) != 1) { |
|
28 |
mod_info("Error processing request\n"); |
|
29 |
return 0; |
|
30 |
}
|
|
31 |
||
32 |
test->addr = pcidriver_resolve_bar(ua); |
|
33 |
||
34 |
return count; |
|
35 |
}
|
|
36 |
||
37 |
static DEVICE_ATTR(test_request, 0664, test_request_show, test_request_store); |
|
38 |
||
39 |
||
40 |
||
41 |
int test_sysfs_init(test_dev_t *dev) { |
|
42 |
int err; |
|
43 |
||
44 |
err = device_create_file(dev->dev, &dev_attr_test_request); |
|
45 |
||
46 |
return err; |
|
47 |
}
|
|
48 |
||
49 |
void test_sysfs_free(test_dev_t *dev) { |
|
50 |
device_remove_file(dev->dev, &dev_attr_test_request); |
|
51 |
}
|