mars/mars_dummy.c

147 lines
3.7 KiB
C
Raw Normal View History

2010-06-14 14:27:40 +00:00
// (c) 2010 Thomas Schoebel-Theuer / 1&1 Internet AG
// Dummy brick (just for demonstration)
2010-07-30 05:46:22 +00:00
//#define BRICK_DEBUGGING
//#define MARS_DEBUGGING
2010-06-14 14:27:40 +00:00
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/string.h>
#include "mars.h"
///////////////////////// own type definitions ////////////////////////
2010-06-20 18:55:34 +00:00
#include "mars_dummy.h"
2010-06-14 14:27:40 +00:00
2010-07-07 14:09:16 +00:00
///////////////////////// own helper functions ////////////////////////
2010-06-14 14:27:40 +00:00
////////////////// own brick / input / output operations //////////////////
2010-07-07 14:09:16 +00:00
static int dummy_get_info(struct dummy_output *output, struct mars_info *info)
2010-06-28 05:53:46 +00:00
{
struct dummy_input *input = output->brick->inputs[0];
2010-07-07 14:09:16 +00:00
return GENERIC_INPUT_CALL(input, mars_get_info, info);
2010-07-05 15:56:58 +00:00
}
2010-08-05 15:54:48 +00:00
static int dummy_ref_get(struct dummy_output *output, struct mars_ref_object *mref)
2010-07-05 15:56:58 +00:00
{
struct dummy_input *input = output->brick->inputs[0];
2010-08-05 15:54:48 +00:00
return GENERIC_INPUT_CALL(input, mars_ref_get, mref);
2010-07-05 15:56:58 +00:00
}
2010-08-05 15:54:48 +00:00
static void dummy_ref_put(struct dummy_output *output, struct mars_ref_object *mref)
2010-07-05 15:56:58 +00:00
{
struct dummy_input *input = output->brick->inputs[0];
2010-08-05 15:54:48 +00:00
GENERIC_INPUT_CALL(input, mars_ref_put, mref);
2010-07-05 15:56:58 +00:00
}
2010-12-10 17:40:20 +00:00
static void dummy_ref_io(struct dummy_output *output, struct mars_ref_object *mref)
2010-07-05 15:56:58 +00:00
{
struct dummy_input *input = output->brick->inputs[0];
2010-12-10 17:40:20 +00:00
GENERIC_INPUT_CALL(input, mars_ref_io, mref);
2010-06-28 05:53:46 +00:00
}
2010-06-22 13:21:42 +00:00
//////////////// object / aspect constructors / destructors ///////////////
2010-08-05 15:54:48 +00:00
static int dummy_mars_ref_aspect_init_fn(struct generic_aspect *_ini, void *_init_data)
2010-07-05 15:56:58 +00:00
{
2010-08-05 15:54:48 +00:00
struct dummy_mars_ref_aspect *ini = (void*)_ini;
2010-08-08 09:03:42 +00:00
(void)ini;
2010-07-05 15:56:58 +00:00
ini->my_own = 0;
return 0;
}
2010-08-08 09:03:42 +00:00
static void dummy_mars_ref_aspect_exit_fn(struct generic_aspect *_ini, void *_init_data)
{
struct dummy_mars_ref_aspect *ini = (void*)_ini;
(void)ini;
}
2010-07-23 11:55:18 +00:00
MARS_MAKE_STATICS(dummy);
2010-06-22 13:21:42 +00:00
////////////////////// brick constructors / destructors ////////////////////
2010-06-14 14:27:40 +00:00
static int dummy_brick_construct(struct dummy_brick *brick)
{
brick->my_own = 0;
return 0;
}
static int dummy_output_construct(struct dummy_output *output)
{
output->my_own = 0;
return 0;
}
///////////////////////// static structs ////////////////////////
static struct dummy_brick_ops dummy_brick_ops = {
};
static struct dummy_output_ops dummy_output_ops = {
2010-06-22 13:21:42 +00:00
.make_object_layout = dummy_make_object_layout,
2010-07-07 14:09:16 +00:00
.mars_get_info = dummy_get_info,
2010-08-05 15:54:48 +00:00
.mars_ref_get = dummy_ref_get,
.mars_ref_put = dummy_ref_put,
.mars_ref_io = dummy_ref_io,
2010-06-14 14:27:40 +00:00
};
2010-08-10 17:39:30 +00:00
const struct dummy_input_type dummy_input_type = {
2010-06-14 14:27:40 +00:00
.type_name = "dummy_input",
.input_size = sizeof(struct dummy_input),
};
2010-07-23 11:55:18 +00:00
static const struct dummy_input_type *dummy_input_types[] = {
2010-06-14 14:27:40 +00:00
&dummy_input_type,
};
2010-08-10 17:39:30 +00:00
const struct dummy_output_type dummy_output_type = {
2010-06-14 14:27:40 +00:00
.type_name = "dummy_output",
.output_size = sizeof(struct dummy_output),
.master_ops = &dummy_output_ops,
.output_construct = &dummy_output_construct,
2010-07-30 05:46:22 +00:00
.aspect_types = dummy_aspect_types,
.layout_code = {
2010-08-05 15:54:48 +00:00
[BRICK_OBJ_MARS_REF] = LAYOUT_ALL,
2010-07-23 11:55:18 +00:00
}
2010-06-14 14:27:40 +00:00
};
2010-07-23 11:55:18 +00:00
static const struct dummy_output_type *dummy_output_types[] = {
2010-06-14 14:27:40 +00:00
&dummy_output_type,
};
2010-07-23 11:55:18 +00:00
const struct dummy_brick_type dummy_brick_type = {
2010-06-14 14:27:40 +00:00
.type_name = "dummy_brick",
.brick_size = sizeof(struct dummy_brick),
.max_inputs = 1,
.max_outputs = 1,
.master_ops = &dummy_brick_ops,
.default_input_types = dummy_input_types,
.default_output_types = dummy_output_types,
.brick_construct = &dummy_brick_construct,
};
EXPORT_SYMBOL_GPL(dummy_brick_type);
////////////////// module init stuff /////////////////////////
static int __init init_dummy(void)
{
printk(MARS_INFO "init_dummy()\n");
return dummy_register_brick_type();
}
static void __exit exit_dummy(void)
{
printk(MARS_INFO "exit_dummy()\n");
dummy_unregister_brick_type();
}
MODULE_DESCRIPTION("MARS dummy brick");
MODULE_AUTHOR("Thomas Schoebel-Theuer <tst@1und1.de>");
MODULE_LICENSE("GPL");
module_init(init_dummy);
module_exit(exit_dummy);