Commit a1952df5 authored by Charlie Jacobsen's avatar Charlie Jacobsen
Browse files

build-setup: libasync builds.

parent b7ce010e
......@@ -2,7 +2,7 @@
AC_PREREQ([2.68])
AC_INIT([libasync], [0.1])
AC_CONFIG_SRCDIR([libasync/src/common/thc.c])
AC_CONFIG_SRCDIR([src/common/thc.c])
AC_CONFIG_AUX_DIR(autoconf)
AC_CONFIG_HEADERS([config.h])
......@@ -26,12 +26,12 @@ AM_COND_IF([ENABLE_KERNEL_TESTS_BUILD],
[AC_MSG_NOTICE([Building kernel tests.])],
[AC_MSG_NOTICE([Not building kernel tests.])])
# Build libcap as kernel module? (in addition to static lib.a)
# Build libasync as kernel module? (in addition to static lib.a)
AC_ARG_ENABLE([kernel_module],
[AS_HELP_STRING([--disable-kernel-module],
[Disable kernel module build (default=no)])],
[AS_HELP_STRING([--enable-kernel-module],
[Enable kernel module build (default=no)])],
[],
[enable_kernel_module="yes"])
[enable_kernel_module="no"])
AM_CONDITIONAL(ENABLE_KERNEL_MODULE,
[test "x$enable_kernel_module" = "xyes"])
......@@ -62,7 +62,7 @@ AC_ARG_WITH([libfipc],
[LIBFIPC_DIR="$with_libfipc"])
AS_IF([test "x$LIBFIPC_DIR" = "x"],
[AC_MSG_ERR([libfipc (--with-libfipc) is required])])
[AC_MSG_ERROR([libfipc (--with-libfipc) is required])])
AC_CHECK_FILE($LIBFIPC_DIR/include/libfipc.h,
[AC_MSG_NOTICE([Found libfipc.h in $LIBFIPC_DIR/include])],
......@@ -117,8 +117,9 @@ AC_CONFIG_FILES(
Makefile
src/Makefile
src/common/Makefile
src/Kbuild
src/common/Makefile
src/include/Makefile
)
......
......@@ -15,7 +15,7 @@ AM_CPPFLAGS = \
-I$(abs_top_builddir)/src/include \
-I$(LIBFIPC_DIR)/include
AM_CFLAGS = -fno-ipa-cp -fno-ipa-sra
AM_CFLAGS = -fno-ipa-cp -fno-ipa-sra -DLINUX_KERNEL -DCONFIG_LAZY_THC
COMMON_SRCS= \
common/thc.c \
......@@ -110,7 +110,7 @@ clean: clean-lib $(MAYBE_CLEAN_TESTS) $(MAYBE_CLEAN_MODULE)
clean-tests:
$(MAKE) -C $(KDIR) M=$(LIBASYNC_TESTS_KBUILD) clean
clean-tests:
clean-module:
$(MAKE) -C $(KDIR) M=$(LIBASYNC_KERNEL_MODULE_KBUILD) clean
clean-lib:
......
......@@ -16,6 +16,7 @@
#include <linux/bug.h>
#include <linux/string.h>
#include <linux/slab.h>
#include <awe_mapper.h>
#ifdef LCD_ISOLATE
......
......@@ -15,6 +15,10 @@
#define FB_KIND_FINISH 0
#define FB_KIND_TOP_FINISH 1
#ifdef LINUX_KERNEL
#undef linux
#endif
#ifndef LINUX_KERNEL
#include <stdlib.h>
#include <stdio.h>
......@@ -39,10 +43,12 @@
#include <linux/slab.h>
#include <linux/types.h>
#include <linux/bug.h>
#include <awe-mapper.h>
#include <linux/sched.h>
#include <awe_mapper.h>
#ifdef LCD_ISOLATE
#include <lcd_config/post_hook.h>
#endif
#undef DEBUG_STACK
#endif
#ifdef linux
......@@ -59,7 +65,7 @@
#ifdef BARRELFISH
#define DEBUGPRINTF debug_printf
#elif LINUX_KENREL
#elif defined(LINUX_KERNEL)
#define DEBUGPRINTF printk
#else
#define DEBUGPRINTF printf
......@@ -133,14 +139,14 @@ PTState_t *PTS(void) {
static void InitPTS(void) {
#ifdef LINUX_KERNEL
PTState *pts = kzalloc(sizeof(PTState_t), GFP_KERNEL);
PTState_t *pts = kzalloc(sizeof(PTState_t), GFP_KERNEL);
#else
PTState *pts = malloc(sizeof(PTState_t));
PTState_t *pts = malloc(sizeof(PTState_t));
memset(pts, 0, sizeof(PTState_t));
#endif
thc_latch_init(&(current->ptstate->latch));
thc_latch_init(&(pts->latch));
assert((PTS() == NULL) && "PTS already initialized");
thc_set_pts_0(current->ptstate);
thc_set_pts_0(pts);
}
static void thc_pts_lock(PTState_t *t) {
......@@ -254,8 +260,8 @@ void *_thc_allocstack(void) {
DEBUG_STACK(DEBUGPRINTF(DEBUG_STACK_PREFIX "> AllocStack\n"));
if (pts->free_stacks != NULL) {
// Re-use previously freed stack
DEBUG_STACK(DEBUGPRINTF(DEBUG_STACK_PREFIX " Re-using free stack\n"));
struct thcstack_t *r = pts->free_stacks;
DEBUG_STACK(DEBUGPRINTF(DEBUG_STACK_PREFIX " Re-using free stack\n"));
pts->free_stacks = pts->free_stacks->next;
result = ((void*)r) + sizeof(struct thcstack_t);
} else {
......@@ -416,7 +422,7 @@ static void thc_dispatch_loop(void) {
// Pick up work passed to us from other threads
if (pts->aweRemoteHead.next != &pts->aweRemoteTail) {
awe_t *tmp = pts->aweHead.next;
awe_t *tmp = pts->aweHead.next;
thc_pts_lock(pts);
// Move remote list into our local list
pts->aweHead.next = pts->aweRemoteHead.next;
......@@ -958,8 +964,8 @@ static void remove_awe_from_list(awe_t* awe)
{
PTState_t *pts = awe->pts;
//if awe is on front of queue
int isHead = (awe == &((pts->aweHead).next));
int isTail = (awe == &((pts->aweTail).prev));
int isHead = (awe == pts->aweHead.next);
int isTail = (awe == pts->aweTail.prev);
if(isHead)
{
pts->aweHead.next = awe->next;
......@@ -1011,6 +1017,10 @@ static void thc_yieldto_with_cont(void *a, void *arg) {
awe->pts->curr_lazy_stack = awe->lazy_stack;
awe->pts->current_fb = awe->current_fb;
// Bug in original Barrelfish version; awe wasn't removed from
// dispatch queue when we yielded to it here. (Note that in
// dispatch loop awe's are removed from the dispatch queue
// when we yield to them.)
remove_awe_from_list(awe);
thc_awe_execute_0(awe);
}
......@@ -1252,7 +1262,7 @@ int THCRun(THCFn_t fn,
// Start-of-day code for Barrelfish, where we initialize THC before
// entry to main.
#ifndef LINUX_KERNEL
#ifdef LINUX_KERNEL
static void IdleFn(void *arg) {
PTState_t *pts = PTS();
......
......@@ -20,9 +20,13 @@
#endif
#define NOT_REACHED assert(0 && "Not reached")
#ifdef LINUX_KERNEL
#define DEBUGPRINTF printk
#else
#define DEBUGPRINTF debug_printf
#endif
#define DEBUG_SYNC(XX)
//#define DEBUG_SYNC(XX)
#define DEBUG_SYNC(XX) do{ XX; } while (0)
#define DEBUG_SYNC_PREFIX " sync: "
......
......@@ -12,6 +12,8 @@
#ifndef AWE_MAPPER_H
#define AWE_MAPPER_H
#include <thc.h>
#ifdef LINUX_KERNEL
#define AWE_TABLE_COUNT 128
......
......@@ -8,7 +8,6 @@ typedef struct ptstate_t PTState_t;
typedef struct thcstack_t thcstack_t;
typedef struct finish_t finish_t;
struct thc_latch;
typedef void (*THCIdleFn_t)(void *);
// Definition of an AWE, asynchronous work element. This definition must
// match the assembly-language definitions at the bottom of thc.c which
// access fields in the AWE structure.
......
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