2009-06-10 09:58:50 +02:00
|
|
|
#ifndef _SPECIFIC_COMM_H_
|
|
|
|
#define _SPECIFIC_COMM_H_ 1
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
/* Non standard include */
|
|
|
|
#include <common_comm.h>
|
|
|
|
|
|
|
|
/* This is not an error, we need this two-macro system */
|
|
|
|
#define toString(x) doStringification(x)
|
|
|
|
#define doStringification(x) #x
|
|
|
|
|
2009-06-17 18:15:16 +02:00
|
|
|
struct comm_channel
|
2009-06-10 09:58:50 +02:00
|
|
|
{
|
2009-06-17 18:15:16 +02:00
|
|
|
volatile void *buf[2 * BUF_SIZE / sizeof(void *)] __attribute__ ((aligned (CACHE_LINE_SIZE)));
|
|
|
|
volatile int state __attribute__ ((aligned (CACHE_LINE_SIZE)));
|
2009-06-10 09:58:50 +02:00
|
|
|
int idx __attribute__ ((aligned (CACHE_LINE_SIZE)));
|
|
|
|
};
|
|
|
|
|
2009-06-17 18:15:16 +02:00
|
|
|
struct thread_comm
|
2009-06-10 09:58:50 +02:00
|
|
|
{
|
2009-06-17 18:15:16 +02:00
|
|
|
struct comm_channel *channel;
|
2009-06-10 09:58:50 +02:00
|
|
|
int receiver_idx;
|
|
|
|
};
|
|
|
|
|
2009-06-17 18:15:16 +02:00
|
|
|
extern struct thread_comm *tcomms;
|
2009-06-10 09:58:50 +02:00
|
|
|
|
|
|
|
__BEGIN_DECLS
|
|
|
|
|
2009-06-17 18:15:16 +02:00
|
|
|
void init_thread_comm(void);
|
2009-06-17 18:22:03 +02:00
|
|
|
static inline void send(void **addr)
|
|
|
|
{
|
2009-06-10 09:58:50 +02:00
|
|
|
asm volatile("mov %%gs:channel@NTPOFF + 2 *" toString(BUF_SIZE) " + " toString(CACHE_LINE_SIZE) ", %%eax\n\t"
|
|
|
|
"mov %0, %%gs:channel@NTPOFF(%%eax)\n\t"
|
|
|
|
"addl $4, %%eax\n\t"
|
|
|
|
"andl $(2*" toString(BUF_SIZE) "-1), %%eax\n\t"
|
|
|
|
"mov %%eax, %%gs:channel@NTPOFF + 2 * " toString(BUF_SIZE)" + " toString(CACHE_LINE_SIZE) "\n\t"
|
|
|
|
"test $(" toString(BUF_SIZE) " - 1), %%eax\n\t"
|
|
|
|
"mov $2f, %%eax\n\t"
|
|
|
|
"jz swap_buffer\n\t"
|
|
|
|
"2:"
|
|
|
|
:
|
2009-06-16 12:58:30 +02:00
|
|
|
: "r"(addr)
|
2009-06-10 09:58:50 +02:00
|
|
|
: "%eax");
|
|
|
|
}
|
|
|
|
|
|
|
|
__END_DECLS
|
|
|
|
|
|
|
|
#endif
|