Commit 27c24f84 authored by Michael Quigley's avatar Michael Quigley
Browse files

modified test to more closely mimic what the dispatch loop will be used for.

parent c9bd878e
......@@ -18,7 +18,7 @@
#include <linux/string.h>
#include <linux/types.h>
#include <linux/slab.h>
#include "../IPC/ipc.h"
#include "ipc.h"
struct ttd_buf {
/* PRODUCER */
......@@ -30,11 +30,15 @@ struct ttd_buf {
uint8_t padding[16]; /* pad the struct up to cache line size */
};
//from ipc.h
struct ipc_message;
struct ttd_ring_channel {
struct ttd_buf tx;
struct ttd_buf rx;
/* TODO NECESSARY? */
uint8_t padding[64]; /* pad the struct to cacheline size */
int (*dispatch_fn)(struct ttd_ring_channel*, struct ipc_message*);
uint8_t padding[56]; /* pad the struct to cacheline size */
};
struct ttd_ring_channel_group
......
......@@ -8,7 +8,7 @@
#include "thread_fn_util.h"
//max_recv_ct just for testing
int ipc_dispatch_loop(ipc_local_fn_t* fns, int fns_length,struct ttd_ring_channel_group* rx_group, int max_recv_ct)
int ipc_dispatch_loop(struct ttd_ring_channel_group* rx_group, int max_recv_ct)
{
volatile void ** frame = (volatile void**)__builtin_frame_address(0);
volatile void *ret_addr = *(frame + 1);
......@@ -16,7 +16,7 @@ int ipc_dispatch_loop(ipc_local_fn_t* fns, int fns_length,struct ttd_ring_channe
*(frame + 1) = NULL;
//NOTE:recv_ct is just for testing
DO_FINISH_(0,{
DO_FINISH_(ipc_dispatch,{
int curr_ind = 0;
int* curr_ind_pt = &curr_ind;
struct ipc_message* curr_msg;
......@@ -39,16 +39,16 @@ int ipc_dispatch_loop(ipc_local_fn_t* fns, int fns_length,struct ttd_ring_channe
//else find corresponding function and execute.
else
{
int i;
for(i = 0; i < fns_length; i++)
if( rx_group->chans[curr_ind]->dispatch_fn )
{
if( curr_msg->fn_type == fns[i].fn_type )
{
printk(KERN_ERR "calling fn: %d\n", fns[i].fn_type);
ASYNC_({
fns[i].local_fn(rx_group, *curr_ind_pt, curr_msg);
},0xdeadbeef);
}
ASYNC_({
rx_group->chans[curr_ind]->dispatch_fn(rx_group->chans[curr_ind],
curr_msg);
},ipc_dispatch);
}
else
{
printk(KERN_ERR "Channel %d function not allocated, message dropped\n", curr_ind_pt);
}
}
}
......
#ifndef IPC_DISPATCH_H
#define IPC_DISPATCH_H
typedef struct ipc_local_fn{
int fn_type;
int (*local_fn)(struct ttd_ring_channel_group*, int, struct ipc_message*);
} ipc_local_fn_t;
int ipc_dispatch_loop(ipc_local_fn_t* fns, int fns_length,struct ttd_ring_channel_group* rx_group, int max_recv_ct);
int ipc_dispatch_loop(struct ttd_ring_channel_group* rx_group, int max_recv_ct);
#endif
......@@ -4,13 +4,14 @@
#include "ipc_dispatch.h"
#include "thread_fn_util.h"
#include "awe-mapper.h"
#include "../../ring-chan/ring-channel.h"
#define THREAD2_FNS_LENGTH 2
static struct ttd_ring_channel_group* rx_group;
//Just returns a value back to thread 1
static int add_2_fn(struct ttd_ring_channel_group* group, int channel_index, struct ipc_message* msg)
static int add_2_fn(struct ttd_ring_channel* chan, struct ipc_message* msg)
{
struct ttd_ring_channel * chan = group->chans[channel_index];
unsigned long result = msg->reg1 + msg->reg2;
struct ipc_message* out_msg = get_send_slot(chan);
out_msg->reg1 = result;
......@@ -24,19 +25,14 @@ static int add_2_fn(struct ttd_ring_channel_group* group, int channel_index, str
//Receives a value from thread1, then passes it to thread 3 and returns that result to thread 1
static int add_10_fn(struct ttd_ring_channel_group* group, int channel_index, struct ipc_message* msg)
static int add_10_fn(struct ttd_ring_channel* thread1_chan, struct ipc_message* msg)
{
struct ttd_ring_channel * thread1_chan = group->chans[0];
struct ttd_ring_channel * thread3_chan = group->chans[1];
struct ttd_ring_channel * thread3_chan = rx_group->chans[1];
struct ipc_message* thread3_msg = get_send_slot(thread3_chan);
struct ipc_message* thread1_result;
unsigned long saved_msg_id = msg->msg_id;
unsigned long new_msg_id = awe_mapper_create_id();
if( channel_index != 0 )
{
printk(KERN_ERR "CHANNEL INDEX WRONG\n");
}
thread3_msg->fn_type = msg->fn_type;
thread3_msg->reg1 = msg->reg1;
thread3_msg->reg2 = msg->reg2;
......@@ -58,17 +54,26 @@ static int add_10_fn(struct ttd_ring_channel_group* group, int channel_index, st
}
static ipc_local_fn_t functions[THREAD2_FNS_LENGTH] = {
{ADD_2_FN, add_2_fn},
{ADD_10_FN, add_10_fn}
};
static int thread1_dispatch_fn(struct ttd_ring_channel* chan, struct ipc_message* msg)
{
switch( msg->fn_type )
{
case ADD_2_FN:
return add_2_fn(chan, msg);
case ADD_10_FN:
return add_10_fn(chan, msg);
default:
printk(KERN_ERR "FN: %lu is not a valid function type\n", msg->fn_type);
}
return 1;
}
int thread2_fn1(void* group)
{
struct ttd_ring_channel_group* rx_group = group;
thc_init();
ipc_dispatch_loop(functions, THREAD2_FNS_LENGTH, rx_group, 3);
rx_group = (struct ttd_ring_channel_group*)group;
rx_group->chans[0]->dispatch_fn = thread1_dispatch_fn;
ipc_dispatch_loop(rx_group, 3);
thc_done();
return 1;
......
......@@ -8,12 +8,13 @@
#define THREAD3_FNS_LENGTH 1
static struct ttd_ring_channel_group* rx_group;
static int add_10_fn(struct ttd_ring_channel_group* group, int channel_index, struct ipc_message* msg)
static int add_10_fn(struct ttd_ring_channel* chan, struct ipc_message* msg)
{
msleep(1000);
unsigned long result = msg->reg1 + msg->reg2 + 10;
struct ttd_ring_channel* chan = group->chans[channel_index];
struct ipc_message* out_msg = get_send_slot(chan);
printk(KERN_ERR "got to thread3\n");
out_msg->reg1 = result;
......@@ -26,16 +27,24 @@ static int add_10_fn(struct ttd_ring_channel_group* group, int channel_index, st
}
static ipc_local_fn_t functions[THREAD3_FNS_LENGTH] = {
{ADD_10_FN, add_10_fn}
};
static int thread2_dispatch_fn(struct ttd_ring_channel* chan, struct ipc_message* msg)
{
switch( msg->fn_type )
{
case ADD_10_FN:
return add_10_fn(chan, msg);
default:
printk(KERN_ERR "FN: %d is not a valid function type\n", msg->fn_type);
}
return 1;
}
int thread3_fn1(void* group)
{
struct ttd_ring_channel_group* rx_group = group;
thc_init();
ipc_dispatch_loop(functions, THREAD3_FNS_LENGTH, rx_group, 1);
rx_group = (struct ttd_ring_channel_group*)group;
rx_group->chans[0]->dispatch_fn = thread2_dispatch_fn;
ipc_dispatch_loop(rx_group, 1);
thc_done();
return 1;
......
Supports Markdown
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