2010-06-14 14:27:40 +00:00
|
|
|
// (c) 2010 Thomas Schoebel-Theuer / 1&1 Internet AG
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/string.h>
|
|
|
|
|
|
|
|
#include <linux/major.h>
|
|
|
|
#include <linux/genhd.h>
|
|
|
|
#include <linux/blkdev.h>
|
|
|
|
|
|
|
|
#define _STRATEGY
|
|
|
|
#include "mars.h"
|
|
|
|
|
|
|
|
#include "mars_if_device.h"
|
2010-06-15 18:31:06 +00:00
|
|
|
#include "mars_device_sio.h"
|
2010-06-14 14:27:40 +00:00
|
|
|
|
2010-06-15 18:31:06 +00:00
|
|
|
GENERIC_MAKE_CONNECT(if_device, device_sio);
|
2010-06-14 14:27:40 +00:00
|
|
|
|
|
|
|
static struct if_device_brick *if_brick = NULL;
|
2010-06-15 18:31:06 +00:00
|
|
|
static struct device_sio_brick *device_brick = NULL;
|
2010-06-14 14:27:40 +00:00
|
|
|
|
|
|
|
void make_test_instance(void)
|
|
|
|
{
|
|
|
|
static char *names[] = { "brick" };
|
2010-06-18 11:44:14 +00:00
|
|
|
int size = 4096;
|
2010-06-14 14:27:40 +00:00
|
|
|
int status;
|
|
|
|
void *mem = kzalloc(size, GFP_KERNEL);
|
|
|
|
if (!mem) {
|
|
|
|
MARS_ERR("cannot grab test memory\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
MARS_DBG("starting....\n");
|
|
|
|
|
2010-06-15 18:31:06 +00:00
|
|
|
status = device_sio_brick_init_full(mem, size, &device_sio_brick_type, NULL, NULL, names);
|
2010-06-14 14:27:40 +00:00
|
|
|
MARS_DBG("done (status=%d)\n", status);
|
|
|
|
if (!status)
|
|
|
|
device_brick = mem;
|
|
|
|
|
|
|
|
mem = kzalloc(size, GFP_KERNEL);
|
|
|
|
if (!mem) {
|
|
|
|
MARS_ERR("cannot grab test memory\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
status = if_device_brick_init_full(mem, size, &if_device_brick_type, NULL, NULL, names);
|
|
|
|
MARS_DBG("done (status=%d)\n", status);
|
|
|
|
if (!status)
|
|
|
|
if_brick = mem;
|
|
|
|
|
2010-06-15 18:31:06 +00:00
|
|
|
status = if_device_device_sio_connect(if_brick->inputs[0], device_brick->outputs[0]);
|
2010-06-14 14:27:40 +00:00
|
|
|
MARS_DBG("connect (status=%d)\n", status);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void destroy_test_instance(void)
|
|
|
|
{
|
|
|
|
if (if_brick) {
|
2010-06-15 18:31:06 +00:00
|
|
|
if_device_device_sio_disconnect(if_brick->inputs[0]);
|
2010-06-14 14:27:40 +00:00
|
|
|
if_device_brick_exit_full(if_brick);
|
|
|
|
kfree(if_brick);
|
|
|
|
if_brick = NULL;
|
|
|
|
}
|
|
|
|
if (device_brick) {
|
2010-06-15 18:31:06 +00:00
|
|
|
device_sio_brick_exit_full(device_brick);
|
2010-06-14 14:27:40 +00:00
|
|
|
kfree(device_brick);
|
|
|
|
device_brick = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit exit_test(void)
|
|
|
|
{
|
|
|
|
MARS_DBG("destroy_test_instance()\n");
|
|
|
|
destroy_test_instance();
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __init init_test(void)
|
|
|
|
{
|
|
|
|
MARS_DBG("make_test_instance()\n");
|
|
|
|
make_test_instance();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
MODULE_DESCRIPTION("MARS TEST");
|
|
|
|
MODULE_AUTHOR("Thomas Schoebel-Theuer <tst@1und1.de>");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
|
|
|
module_init(init_test);
|
|
|
|
module_exit(exit_test);
|