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

build-setup: Switch to one-platform build set up.

We can extend in the future as necessary. thc wasn't written for
our platform directory layout, and it's not worth ripping it apart
right now.

Also, reverted old changes back (uncommented asserts, etc.).
parent 91e5ce3b
......@@ -14,62 +14,30 @@ AM_INIT_AUTOMAKE([subdir-objects foreign])
# libasync features, packages, and config
# --------------------------------------------------
# Platform = kernel
# (other platforms to be added later ... )
AC_ARG_VAR([PLATFORM],
[The platform to build for @{:@kernel@:}@ (default=kernel)])
AS_CASE([$PLATFORM],
[kernel],
[PLATFORM_DIR=platform/kernel],
[*],
[
AC_MSG_NOTICE([PLATFORM (val=$PLATFORM) unset or invalid.])
AC_MSG_NOTICE([Defaulting to PLATFORM=kernel.])
PLATFORM=kernel
PLATFORM_DIR=platform/kernel
])
AC_MSG_NOTICE([Building for PLATFORM=$PLATFORM.])
AC_SUBST(PLATFORM)
AC_SUBST(PLATFORM_DIR)
AS_IF([test "x$PLATFORM" = "xkernel"],
[
# Build kernel tests?
AC_ARG_ENABLE([kernel_tests_build],
[AS_HELP_STRING([--enable-kernel-tests-build],
[Enable building kernel test modules (default=no)])],
[],
[enable_kernel_tests_build="no"])
AM_CONDITIONAL(ENABLE_KERNEL_TESTS_BUILD,
[test "x$enable_kernel_tests_build" = "xyes"])
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)
AC_ARG_ENABLE([kernel_module],
[AS_HELP_STRING([--disable-kernel-module],
[Disable kernel module build (default=no)])],
[],
[enable_kernel_module="yes"])
AM_CONDITIONAL(ENABLE_KERNEL_MODULE,
[test "x$enable_kernel_module" = "xyes"])
AM_COND_IF([ENABLE_KERNEL_MODULE],
[AC_MSG_NOTICE([Building kernel module.])],
[AC_MSG_NOTICE([Not building kernel module.])])
],
[
AM_CONDITIONAL(ENABLE_KERNEL_TESTS_BUILD,
[false])
AM_CONDITIONAL(ENABLE_KERNEL_MODULE,
[false])
])
# Build kernel tests?
AC_ARG_ENABLE([kernel_tests_build],
[AS_HELP_STRING([--enable-kernel-tests-build],
[Enable building kernel test modules (default=no)])],
[],
[enable_kernel_tests_build="no"])
AM_CONDITIONAL(ENABLE_KERNEL_TESTS_BUILD,
[test "x$enable_kernel_tests_build" = "xyes"])
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)
AC_ARG_ENABLE([kernel_module],
[AS_HELP_STRING([--disable-kernel-module],
[Disable kernel module build (default=no)])],
[],
[enable_kernel_module="yes"])
AM_CONDITIONAL(ENABLE_KERNEL_MODULE,
[test "x$enable_kernel_module" = "xyes"])
AM_COND_IF([ENABLE_KERNEL_MODULE],
[AC_MSG_NOTICE([Building kernel module.])],
[AC_MSG_NOTICE([Not building kernel module.])])
# --------------------------------------------------
# Checks for programs.
......@@ -102,27 +70,20 @@ AC_CHECK_FILE($LIBFIPC_DIR/include/libfipc.h,
AC_SUBST(LIBFIPC_DIR)
# Check for kernel build system
AS_IF([test "x$PLATFORM" = "xkernel"],
KDIR=/lib/modules/`uname -r`/build # default location of build system
[
KDIR=/lib/modules/`uname -r`/build # default location of build system
AC_ARG_WITH([kernel-headers],
[AS_HELP_STRING([--with-kernel-headers=DIRECTORY],
[find Linux kernel build stuff in DIRECTORY])],
[KDIR="$with_kernel_headers"])
AC_ARG_WITH([kernel-headers],
[AS_HELP_STRING([--with-kernel-headers=DIRECTORY],
[find Linux kernel build stuff in DIRECTORY])],
[KDIR="$with_kernel_headers"])
# Sanity check it (in the future, we could maybe check the
# kernel version in the top of the kernel Makefile)
AC_CHECK_FILE($KDIR/Makefile,
[AC_MSG_NOTICE([Found kernel Makefile in $KDIR])],
[AC_MSG_ERROR([Could not find kernel Makefile in $KDIR!])])
# Sanity check it (in the future, we could maybe check the
# kernel version in the top of the kernel Makefile)
AC_CHECK_FILE($KDIR/Makefile,
[AC_MSG_NOTICE([Found kernel Makefile in $KDIR])],
[AC_MSG_ERROR([Could not find kernel Makefile in $KDIR!])])
AC_SUBST(KDIR)
])
AC_SUBST(KDIR)
# --------------------------------------------------
# Checks for types
......@@ -160,14 +121,6 @@ AC_CONFIG_FILES(
src/include/Makefile
src/platform/Makefile
src/platform/kernel/Makefile
src/platform/kernel/Kbuild
src/platform/kernel/include/Makefile
src/platform/kernel/tests/Makefile
src/platform/kernel/tests/Kbuild
src/platform/kernel/tests/rpc/Kbuild
src/platform/kernel/tests/empty_msg/Kbuild
)
AC_OUTPUT
......@@ -11,7 +11,7 @@
# This single line of magic makes it so we can do an out of src tree
# build. It has to do with how and where this Kbuild file is included
# in the kernel build system.
src = @abs_top_srcdir@/src/platform/kernel
src = @abs_top_srcdir@/src
# Sources that make up library
lib-y += \
......
# Part of what makes the kernel build more complex is we need to use
# phony targets to link the kernel build system in with this one.
SUBDIRS = common include $(PLATFORM_DIR)
DIST_SUBDIRS = common include platform
# Include all dirs for distribution/tarball
DIST_SUBDIRS = module tests include
SUBDIRS = include # we manually recur into module and tests
# Add includes to include search path. (The root of the builddir is necessary to
# add explicitly for the kernel build, because some of the headers are
# generated by configure.)
AM_CPPFLAGS = \
-I$(abs_top_builddir) \
-I$(abs_top_srcdir)/src/include \
-I$(abs_top_builddir)/src/include \
-I$(LIBFIPC_DIR)/include
AM_CFLAGS = -fno-ipa-cp -fno-ipa-sra
COMMON_SRCS= \
common/thc.c \
common/thc_ipc.c \
common/thcsync.c \
common/awe_mapper.c
# Necessary to export so that these variables are available in Kbuilds
export AM_CPPFLAGS AM_CFLAGS COMMON_SRCS
LIBASYNC_KBUILD=@abs_top_builddir@/src
LIBASYNC_TESTS_KBUILD=@abs_top_builddir@/src/tests
LIBASYNC_KERNEL_MODULE_KBUILD=@abs_top_builddir@/src/module
# These are used in Kbuilds, so they need to be relative paths (boo). They
# are relative to this directory (the build version).
LIBASYNC_PATH=libasync.a
LIBFIPC_LIB=$(shell @abs_top_srcdir@/scripts/relpath.py \
$(LIBFIPC_DIR)/lib/libfipc.a @abs_top_builddir@)
export LIBASYNC_TESTS_KBUILD LIBASYNC_KERNEL_MODULE_KBUILD LIBASYNC_PATH
export LIBFIPC_LIB
if ENABLE_KERNEL_TESTS_BUILD
MAYBE_ALL_TESTS = all-tests
MAYBE_INSTALL_TESTS = install-tests
MAYBE_DO_MODULES_INSTALL = do-modules-install
MAYBE_CLEAN_TESTS = clean-tests
endif
if ENABLE_KERNEL_MODULE
MAYBE_ALL_MODULE = all-module
MAYBE_INSTALL_MODULE = install-tests
MAYBE_DO_MODULES_INSTALL_MODULE = do-modules-install-module
MAYBE_CLEAN_MODULE = clean-module
endif
# BUILD ------------------------------------------------------------
# Sequence the build, so we build libfipc first
all: all-lib-cp $(MAYBE_ALL_TESTS) $(MAYBE_ALL_MODULE)
all-tests: all-lib-cp
$(MAKE) -C $(KDIR) M=$(LIBASYNC_TESTS_KBUILD) modules
all-module: all-lib-cp
$(MAKE) -C $(KDIR) M=$(LIBASYNC_KERNEL_MODULE_KBUILD) modules
all-lib-cp: all-lib
cp $(LIBASYNC_KBUILD)/lib.a $(LIBASYNC_KBUILD)/libasync.a
all-lib:
$(MAKE) -C $(KDIR) M=$(LIBASYNC_KBUILD)
# INSTALL ------------------------------------------------------------
# Move libasync.a into install dir, and conditionally move modules
install-exec-hook: install-libasync $(MAYBE_INSTALL_TESTS) \
$(MAYBE_INSTALL_MODULE)
install-tests: install-setup-dir
$(MAKE) -C tests install-tests D=$(DESTDIR)$(libdir) # manually recur
install-module: install-setup-dir
cp $(LIBASYNC_KERNEL_MODULE_KBUILD)/module/libasync.ko \
$(DESTDIR)$(libdir)
install-libasync: install-setup-dir
cp $(LIBASYNC_KBUILD)/libasync.a $(DESTDIR)$(libdir)
install-setup-dir:
$(MKDIR_P) $(DESTDIR)$(libdir)
# MODULES INSTALL --------------------------------------------------
do-modules-install-module:
$(MAKE) -C $(KDIR) M=$(LIBASYNC_KERNEL_MODULE_KBUILD) modules_install
do-modules-install:
$(MAKE) -C $(KDIR) M=$(LIBASYNC_TESTS_KBUILD) modules_install
modules_install: $(MAYBE_DO_MODULES_INSTALL) $(MAYBE_DO_MODULES_INSTALL_MODULE)
# CLEAN ------------------------------------------------------------
clean: clean-lib $(MAYBE_CLEAN_TESTS) $(MAYBE_CLEAN_MODULE)
clean-tests:
$(MAKE) -C $(KDIR) M=$(LIBASYNC_TESTS_KBUILD) clean
clean-tests:
$(MAKE) -C $(KDIR) M=$(LIBASYNC_KERNEL_MODULE_KBUILD) clean
clean-lib:
$(MAKE) -C $(KDIR) M=$(LIBASYNC_KBUILD) clean
rm -f $(LIBASYNC_KBUILD)/libasync.a
.PHONY: all-tests all-module all-lib all-lib-cp \
install-tests install-module install-libasync install-setup-dir \
do-modules-install do-modules-install-module modules_install \
clean-tests clean-lib clean-module
......@@ -10,9 +10,17 @@
* Date: January 2016
*/
#ifdef LCD_ISOLATE
#include <lcd_config/pre_hook.h>
#endif
#include <linux/bug.h>
#include <linux/string.h>
#include <awe-mapper.h>
#include <awe_mapper.h>
#ifdef LCD_ISOLATE
#include <lcd_config/post_hook.h>
#endif
/*
* NOTE: This implementation right now is just a ring buffer.
......
#ifdef LCD_ISOLATE
#include <lcd_config/pre_hook.h>
#endif
#include <thc_ipc.h>
#include <thc_ipc_types.h>
#include <libfipc_types.h>
#include <awe-mapper.h>
#include <awe_mapper.h>
#ifdef LCD_ISOLATE
#include <lcd_config/post_hook.h>
#endif
//assumes msg is a valid received message
static int thc_recv_predicate(struct fipc_message* msg, void* data)
......
nobase_include_HEADERS = \
awe-mapper.h \
awe_mapper.h \
thc.h \
thcinternal.h \
thc_ipc.h \
thc_ipc_types.h \
thcsync.h
......@@ -6,9 +6,16 @@
#ifdef LINUX_KERNEL
#include <linux/types.h>
#include <linux/printk.h>
#define assert(XX) do { \
if (!(XX)) { \
printk("assertion failure at %s:%d\n", \
__FILE__, __LINE__); \
} \
} while(0)
#else
#include <stdint.h>
#include <stdlib.h>
#define EXPORT_SYMBOL(x)
#endif
#ifndef BARRELFISH
......
#ifndef THC_IPC_TYPES_H
#define THC_IPC_TYPES_H
#ifdef LINUX_KERNEL
#include <libfipc.h>
#include <linux/list.h>
typedef enum {
msg_type_unspecified,
msg_type_request,
msg_type_response,
} msg_type_t;
struct predicate_payload
{
unsigned long expected_msg_id;
unsigned long actual_msg_id;
msg_type_t msg_type;
};
struct thc_channel_group_item
{
struct list_head list;
struct fipc_ring_channel * channel;
int (*dispatch_fn)(struct fipc_ring_channel*, struct fipc_message*);
};
struct thc_channel_group
{
struct list_head head;
int size;
};
#endif /* LINUX_KERNEL */
#endif
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