Commit 9120bff6 authored by Charlie Jacobsen's avatar Charlie Jacobsen Committed by Vikram Narayanan

Finished toy modules, now build and run test.

parent 6cc7eabb
/**
* client.c - client for the client-server IPC test
* dealer.c - car dealer subsystem for test
*
*
* Authors: Anton Burtsev <aburtsev@flux.utah.edu>
* Authors: Anton Burtsev <aburtsev@flux.utah.edu>
* Charles Jacobsen <charlesj@cs.utah.edu>
*
* Copyright: University of Utah
*/
......@@ -10,20 +12,21 @@
#include <linux/module.h>
#include "common.h"
#include "dealer.h"
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("LCD client-server test client");
MODULE_DESCRIPTION("Auto dealer (LCD test)");
struct server_interface *server;
struct manufacturer_interface *manufacturer;
int client_register_server(struct server_interface *s)
int dealer_register_manufacturer(struct manufacturer_interface *m)
{
server = s;
manufacturer = m;
return 0;
}
EXPORT_SYMBOL(client_register_server);
EXPORT_SYMBOL(dealer_register_manufacturer);
int client_do_work(void)
struct automobile * dealer_buy_car(void)
{
struct engine *e;
struct automobile *a;
......@@ -31,48 +34,53 @@ int client_do_work(void)
/*
* Make an 8 cylinder engine
*/
e = server->mk_engine(8);
e = manufacturer->mk_engine(8);
if (!e || e->cylinders != 8) {
CS_ERR("client: bad engine");
AU_ERR("client: bad engine");
return -1;
}
/*
* Make a 4-door car with e as its engine.
*/
a = server->mk_automobile(e, 4);
a = manufacturer->mk_automobile(e, 4);
if (!a || a->engine != e || a->doors != 4) {
CS_ERR("client: bad auto");
AU_ERR("client: bad auto");
return -1;
}
return a;
}
EXPORT_SYMBOL(dealer_buy_car);
void dealer_return_car(struct automobile *a)
{
/*
* Free the data
*/
server->free_engine(e);
server->free_automobile(a);
return 0;
manufacturer->free_engine(a->engine);
manufacturer->free_automobile(a);
}
EXPORT_SYMBOL(client_do_work);
EXPORT_SYMBOL(dealer_return_car);
#if CONFIG_RUN_IN_LCD
int client_init(void)
int dealer_init(void)
#else
static int __init client_init(void)
static int __init dealer_init(void)
#endif
{
CS_MSG("client initialized");
AU_MSG("dealer initialized");
return 0;
}
#if CONFIG_RUN_IN_LCD
void client_exit(void)
void dealer_exit(void)
#else
static void __init client_exit(void)
static void __init dealer_exit(void)
#endif
{
CS_MSG("client exited");
AU_MSG("dealer exited");
}
#if !CONFIG_RUN_IN_LCD
module_init(client_init);
module_exit(client_exit);
module_init(dealer_init);
module_exit(dealer_exit);
#endif
......@@ -23,7 +23,8 @@ struct manufacturer_interface {
void (*free_automobile)(struct automobile *a);
};
int dealer_register_manufacturer(struct server_interface *s);
int dealer_register_manufacturer(struct manufacturer_interface *s);
struct automobile * dealer_buy_car(void);
void dealer_return_car(struct automobile *a);
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment