All new accounts created on Gitlab now require administrator approval. If you invite any collaborators, please let Flux staff know so they can approve the accounts.

Commit 6cc7eabb authored by Charlie Jacobsen's avatar Charlie Jacobsen Committed by Vikram Narayanan

Moving client-server code to new home, before building new example.

parent 6505b646
......@@ -39,3 +39,9 @@ config LCD_CS_SERVER
default m
---help---
Server module for the LCD client-server test
config RUN_IN_LCD
bool "Run client-server in LCD"
default false
---help---
Set to true to run client and server in lcd.
\ No newline at end of file
/**
* client.c - client for the client-server IPC test
*
*
* Authors: Anton Burtsev <aburtsev@flux.utah.edu>
* Copyright: University of Utah
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include "common.h"
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("LCD client-server test client");
struct server_interface *server;
int client_register_server(struct server_interface *s)
{
server = s;
return 0;
}
EXPORT_SYMBOL(client_register_server);
int client_do_work(void)
{
struct engine *e;
struct automobile *a;
int ret;
/*
* Make an 8 cylinder engine
*/
e = server->mk_engine(8);
if (!e || e->cylinders != 8) {
CS_ERR("client: bad engine");
return -1;
}
/*
* Make a 4-door car with e as its engine.
*/
a = server->mk_automobile(e, 4);
if (!a || a->engine != e || a->doors != 4) {
CS_ERR("client: bad auto");
return -1;
}
/*
* Free the data
*/
server->free_engine(e);
server->free_automobile(a);
return 0;
}
EXPORT_SYMBOL(client_do_work);
#if CONFIG_RUN_IN_LCD
int client_init(void)
#else
static int __init client_init(void)
#endif
{
CS_MSG("client initialized");
return 0;
}
#if CONFIG_RUN_IN_LCD
void client_exit(void)
#else
static void __init client_exit(void)
#endif
{
CS_MSG("client exited");
}
#if !CONFIG_RUN_IN_LCD
module_init(client_init);
module_exit(client_exit);
#endif
/*
* Author: Charles Jacobsen <charlesj@cs.utah.edu>
* Copyright: University of Utah
*
*/
#define CS_ERR(msg...) __cs_err(__FILE__, __LINE__, msg)
static inline void __cs_err(char *file, int lineno, char *fmt, ...)
{
va_list args;
pr_err("cs: %s:%d: error: ", file, lineno);
va_start(args, fmt);
vprintk(fmt, args);
va_end(args);
}
#define CS_MSG(msg...) __cs_msg(__FILE__, __LINE__, msg)
static inline void __cs_msg(char *file, int lineno, char *fmt, ...)
{
va_list args;
pr_info("cs: %s:%d: note: ", file, lineno);
va_start(args, fmt);
vprintk(fmt, args);
va_end(args);
}
#define CS_WARN(msg...) __cs_warn(__FILE__, __LINE__, msg)
static inline void __cs_warn(char *file, int lineno, char *fmt, ...)
{
va_list args;
pr_warn("cs: %s:%d: warning: ", file, lineno);
va_start(args, fmt);
vprintk(fmt, args);
va_end(args);
}
/*
* Author: Charles Jacobsen <charlesj@cs.utah.edu>
* Copyright: University of Utah
*
*/
#ifndef LCD_IPC_AUTO_DEALER_H
#define LCD_IPC_AUTO_DEALER_H
struct engine {
int cylinders;
};
struct automobile {
struct engine *engine;
int doors;
};
struct manufacturer_interface {
struct engine * (*mk_engine) (int cylinders);
struct automobile * (*mk_automobile) (struct engine *e, int doors);
void (*free_engine)(struct engine *e);
void (*free_automobile)(struct automobile *a);
};
int dealer_register_manufacturer(struct server_interface *s);
struct automobile * dealer_buy_car(void);
#endif
......@@ -19,6 +19,7 @@
#include <lcd/lcd.h>
#include <lcd/cap.h>
#include "common.h"
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("LCD client-server test server");
......
/**
* client.c - client for the client-server IPC test
*
*
* Authors: Anton Burtsev <aburtsev@flux.utah.edu>
* Copyright: University of Utah
*/
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/miscdevice.h>
#include <linux/compat.h>
#include <linux/fs.h>
#include <asm/uaccess.h>
#include <linux/kthread.h>
#include <linux/slab.h>
#include <lcd/lcd.h>
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("LCD client-server test client");
struct server_interface *server;
int register_server(struct server_interface *s) {
server = s;
client_main();
};
EXPORT_SYMBOL(register_server);
int server_test_1(struct server_interface *server) {
ret = server->test_func1(1, 2, 3);
printk(KERN_INFO "Server test1 returns: %d\n");
return ret;
};
int server_test_2(struct server_interface *server) {
ret = server->test_func2(4);
printk(KERN_INFO "Server test1 returns: %d\n");
return ret;
};
int client_main(void) {
server_test_1(server);
server_test_2(server);
}
static int __init client_init(void)
{
lcd_thread_init();
return;
}
static void __exit client_exit(void)
{
}
module_init(client_init);
module_exit(client_exit);
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