Commits (7)
......@@ -7,21 +7,29 @@
* Copyright: University of Utah
*/
#ifdef LCD_DOMAINS
#include <lcd_config/pre_hook.h>
#endif
#include <libfipc.h>
#include <libfipc_internal.h>
#define FIPC_MSG_STATUS_AVAILABLE 0xdeaddeadUL
#define FIPC_MSG_STATUS_SENT 0xfeedfeedUL
#ifdef LCD_DOMAINS
#include <lcd_config/post_hook.h>
#endif
#ifndef LINUX_KERNEL_MODULE
#undef EXPORT_SYMBOL
#define EXPORT_SYMBOL(x)
#endif
static inline unsigned long get_tx_slot(struct fipc_ring_channel *rc)
{
return rc->tx.slot;
}
static inline unsigned long get_rx_slot(struct fipc_ring_channel *rc)
{
return rc->rx.slot;
}
#define FIPC_MSG_STATUS_AVAILABLE 0xdeaddeadUL
#define FIPC_MSG_STATUS_SENT 0xfeedfeedUL
static inline unsigned long get_tx_idx(struct fipc_ring_channel *rc)
{
......@@ -33,16 +41,6 @@ static inline unsigned long get_rx_idx(struct fipc_ring_channel *rc)
return rc->rx.slot & rc->rx.order_two_mask;
}
static inline void set_tx_slot(struct fipc_ring_channel *rc, unsigned long num)
{
rc->tx.slot = num;
}
static inline void set_rx_slot(struct fipc_ring_channel *rc, unsigned long num)
{
rc->rx.slot = num;
}
static inline unsigned long inc_tx_slot(struct fipc_ring_channel *rc)
{
return (rc->tx.slot++);
......@@ -65,6 +63,8 @@ get_current_rx_slot(struct fipc_ring_channel *rc)
return &rc->rx.buffer[get_rx_idx(rc)];
}
#if FIPC_DEBUG_LVL >= FIPC_DEBUG_VERB
static inline unsigned long
rx_msg_to_idx(struct fipc_ring_channel *rc, struct fipc_message *msg)
{
......@@ -77,6 +77,8 @@ tx_msg_to_idx(struct fipc_ring_channel *rc, struct fipc_message *msg)
return msg - rc->tx.buffer;
}
#endif
static inline int check_rx_slot_msg_waiting(struct fipc_message *slot)
{
return slot->msg_status == FIPC_MSG_STATUS_SENT;
......@@ -97,7 +99,9 @@ static inline unsigned long order_two_mask(unsigned int buf_order)
return nr_slots(buf_order) - 1;
}
int fipc_prep_buffers(unsigned int buf_order, void *buffer_1, void *buffer_2)
int
LIBFIPC_FUNC_ATTR
fipc_prep_buffers(unsigned int buf_order, void *buffer_1, void *buffer_2)
{
unsigned long i;
struct fipc_message *msg_buffer_1 = buffer_1;
......@@ -121,6 +125,7 @@ int fipc_prep_buffers(unsigned int buf_order, void *buffer_1, void *buffer_2)
}
return 0;
}
EXPORT_SYMBOL(fipc_prep_buffers);
static void ring_buf_init(struct fipc_ring_buf *ring_buf,
unsigned int buf_order,
......@@ -130,9 +135,11 @@ static void ring_buf_init(struct fipc_ring_buf *ring_buf,
ring_buf->order_two_mask = order_two_mask(buf_order);
}
int fipc_ring_channel_init(struct fipc_ring_channel *chnl,
unsigned int buf_order,
void *buffer_tx, void *buffer_rx)
int
LIBFIPC_FUNC_ATTR
fipc_ring_channel_init(struct fipc_ring_channel *chnl,
unsigned int buf_order,
void *buffer_tx, void *buffer_rx)
{
/*
* Checks at compile time
......@@ -159,9 +166,12 @@ int fipc_ring_channel_init(struct fipc_ring_channel *chnl,
return 0;
}
EXPORT_SYMBOL(fipc_ring_channel_init);
int fipc_send_msg_start(struct fipc_ring_channel *chnl,
struct fipc_message **msg)
int
LIBFIPC_FUNC_ATTR
fipc_send_msg_start(struct fipc_ring_channel *chnl,
struct fipc_message **msg)
{
int ret = -EWOULDBLOCK;
......@@ -185,8 +195,11 @@ int fipc_send_msg_start(struct fipc_ring_channel *chnl,
return ret;
}
EXPORT_SYMBOL(fipc_send_msg_start);
int fipc_send_msg_end(struct fipc_ring_channel *chnl,
int
LIBFIPC_FUNC_ATTR
fipc_send_msg_end(struct fipc_ring_channel *chnl,
struct fipc_message *msg)
{
msg->msg_status = FIPC_MSG_STATUS_SENT;
......@@ -200,8 +213,8 @@ int fipc_send_msg_end(struct fipc_ring_channel *chnl,
return 0;
}
EXPORT_SYMBOL(fipc_send_msg_end);
/* Expects rx to be locked! */
static int recv_msg_peek(struct fipc_ring_channel *chnl,
struct fipc_message **msg)
{
......@@ -217,8 +230,10 @@ static int recv_msg_peek(struct fipc_ring_channel *chnl,
return ret;
}
int fipc_recv_msg_start(struct fipc_ring_channel *chnl,
struct fipc_message **msg)
int
LIBFIPC_FUNC_ATTR
fipc_recv_msg_start(struct fipc_ring_channel *chnl,
struct fipc_message **msg)
{
int ret;
struct fipc_message *m;
......@@ -242,8 +257,11 @@ int fipc_recv_msg_start(struct fipc_ring_channel *chnl,
return ret;
}
EXPORT_SYMBOL(fipc_recv_msg_start);
int fipc_recv_msg_if(struct fipc_ring_channel *chnl,
int
LIBFIPC_FUNC_ATTR
fipc_recv_msg_if(struct fipc_ring_channel *chnl,
int (*pred)(struct fipc_message *, void *),
void *data,
struct fipc_message **msg)
......@@ -276,8 +294,11 @@ int fipc_recv_msg_if(struct fipc_ring_channel *chnl,
return ret;
}
EXPORT_SYMBOL(fipc_recv_msg_if);
int fipc_recv_msg_end(struct fipc_ring_channel *chnl,
int
LIBFIPC_FUNC_ATTR
fipc_recv_msg_end(struct fipc_ring_channel *chnl,
struct fipc_message *msg)
{
msg->msg_status = FIPC_MSG_STATUS_AVAILABLE;
......@@ -291,19 +312,26 @@ int fipc_recv_msg_end(struct fipc_ring_channel *chnl,
return 0;
}
EXPORT_SYMBOL(fipc_recv_msg_end);
int fipc_init(void)
int
LIBFIPC_FUNC_ATTR
fipc_init(void)
{
FIPC_DEBUG(FIPC_DEBUG_VERB,
"libfipc initialized\n");
return 0;
}
EXPORT_SYMBOL(fipc_init);
void fipc_fini(void)
void
LIBFIPC_FUNC_ATTR
fipc_fini(void)
{
FIPC_DEBUG(FIPC_DEBUG_VERB,
"libfipc torn down\n");
return;
}
EXPORT_SYMBOL(fipc_fini);
......@@ -160,6 +160,10 @@
#include <libfipc_types.h>
#include <libfipc_platform.h>
#ifndef LIBFIPC_FUNC_ATTR
#define LIBFIPC_FUNC_ATTR
#endif
/* MAIN INTERFACE -------------------------------------------------- */
/**
......
......@@ -13,9 +13,17 @@
# in the kernel build system.
src = @abs_top_srcdir@/src/platform/kernel
# This needs to be pasted in here, because the kernel build system will force
# gcc at the top-level.
export CC=@CC@
# Sources that make up library
lib-y += \
$(COMMON_SRCS:.c=.o)
# Pass along include directories from the Automake file
ccflags-y += $(CFLAGS) $(AM_CPPFLAGS)
# Provide option to filter out some kbuild cflags (this is needed for
# clang builds).
KBUILD_CFLAGS := $(filter-out $(LIBFIPC_BAD_CFLAGS), $(KBUILD_CFLAGS))
\ No newline at end of file
......@@ -85,7 +85,7 @@ clean-tests:
clean-lib:
$(MAKE) -C $(KDIR) M=$(LIBFIPC_KBUILD) clean
rm -f $(LIBFIPC_KBUILD)/libcap.a
rm -f $(LIBFIPC_KBUILD)/libfipc.a
.PHONY: all-tests all-lib all-lib-cp \
install-tests install-libfipc install-setup-dir \
......
......@@ -70,6 +70,8 @@ static inline int send_response(struct fipc_ring_channel *chnl,
struct fipc_message *response;
/*
* Mark recvd msg slot as available
*
* NOTE: recvd_msg is not valid after this call.
*/
ret = fipc_recv_msg_end(chnl, recvd_msg);
if (ret) {
......