From 5389b476b0c88d1555186fb8f4e68a5bc198d348 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 19 Feb 2012 13:01:53 +0000 Subject: Simplify link flags computation --- dde_ne2k_pci/Makeconf.local | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) (limited to 'dde_ne2k_pci') diff --git a/dde_ne2k_pci/Makeconf.local b/dde_ne2k_pci/Makeconf.local index 44f70ab8..fb8e6ae6 100644 --- a/dde_ne2k_pci/Makeconf.local +++ b/dde_ne2k_pci/Makeconf.local @@ -2,31 +2,12 @@ SYSTEMS = x86-l4v2 ARCH = x86 SYSTEM = x86-l4v2 -BUILDDIR ?= +BUILDDIR ?= .. -libmachdev_path := ../libmachdev/libmachdev.a -has_libmachdev := $(wildcard $(libmachdev_path)) -ifeq ($(strip $(has_libmachdev)),) - libmachdev_path := $(BUILDDIR)/libmachdev/libmachdev.a -endif - -libddekit_path := ../libddekit/libddekit.a -has_libddekit := $(wildcard $(libddekit_path)) -ifeq ($(strip $(has_libddekit)),) - libddekit_path := $(BUILDDIR)/libddekit/libddekit.a -endif - -libslab_path := ../libhurd-slab/libhurd-slab.a -has_libslab := $(wildcard $(libslab_path)) -ifeq ($(strip $(has_libslab)),) - libslab_path := $(BUILDDIR)/libhurd-slab/libhurd-slab.a -endif - -libbpf_path := ../libbpf/libbpf.a -has_libbpf := $(wildcard $(libbpf_path)) -ifeq ($(strip $(has_libbpf)),) - libbpf_path := $(BUILDDIR)/libbpf/libbpf.a -endif +libmachdev_path := $(BUILDDIR)/libmachdev/libmachdev.a +libddekit_path := $(BUILDDIR)/libddekit/libddekit.a +libslab_path := $(BUILDDIR)/libhurd-slab/libhurd-slab.a +libbpf_path := $(BUILDDIR)/libbpf/libbpf.a DDEKITLIBDIR = $(PKGDIR)/../libddekit/ DDEKITINCDIR = $(PKGDIR)/../libddekit/include -- cgit v1.2.3 From 0d6bc97a073fc3aacd0cc4ff417edf6d5f79a25c Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Tue, 21 Feb 2012 23:37:19 +0000 Subject: Clean up includes To use the standard hurd Makeconf rules and permit external dde_* build Conflicts: dde_e100/Makefile dde_e1000/Makefile dde_ne2k_pci/Makefile dde_pcnet32/Makefile dde_rtl8139/Makefile --- dde_e100/Makefile | 2 +- dde_e100/main.c | 2 +- dde_e1000/Makefile | 2 +- dde_e1000/main.c | 2 +- dde_ne2k_pci/Makefile | 2 +- dde_ne2k_pci/main.c | 2 +- dde_pcnet32/Makefile | 2 +- dde_pcnet32/main.c | 2 +- dde_rtl8139/Makefile | 2 +- dde_rtl8139/main.c | 2 +- libbpf/Makefile | 2 +- libdde_linux26/Makeconf | 2 +- libdde_linux26/mk/prog.mk | 1 - libddekit/Makefile | 26 ++--- libddekit/dde.h | 14 +++ libddekit/ddekit/assert.h | 23 ++++ libddekit/ddekit/condvar.h | 53 ++++++++++ libddekit/ddekit/debug.h | 8 ++ libddekit/ddekit/initcall.h | 42 ++++++++ libddekit/ddekit/inline.h | 2 + libddekit/ddekit/interrupt.h | 57 ++++++++++ libddekit/ddekit/lock.h | 83 +++++++++++++++ libddekit/ddekit/memory.h | 144 +++++++++++++++++++++++++ libddekit/ddekit/panic.h | 16 +++ libddekit/ddekit/pci.h | 199 +++++++++++++++++++++++++++++++++++ libddekit/ddekit/pgtab.h | 86 +++++++++++++++ libddekit/ddekit/printf.h | 35 ++++++ libddekit/ddekit/resources.h | 14 +++ libddekit/ddekit/semaphore.h | 50 +++++++++ libddekit/ddekit/thread.h | 145 +++++++++++++++++++++++++ libddekit/ddekit/timer.h | 59 +++++++++++ libddekit/ddekit/types.h | 22 ++++ libddekit/include/dde.h | 14 --- libddekit/include/ddekit/assert.h | 23 ---- libddekit/include/ddekit/condvar.h | 53 ---------- libddekit/include/ddekit/debug.h | 8 -- libddekit/include/ddekit/initcall.h | 42 -------- libddekit/include/ddekit/inline.h | 2 - libddekit/include/ddekit/interrupt.h | 57 ---------- libddekit/include/ddekit/lock.h | 83 --------------- libddekit/include/ddekit/memory.h | 144 ------------------------- libddekit/include/ddekit/panic.h | 16 --- libddekit/include/ddekit/pci.h | 199 ----------------------------------- libddekit/include/ddekit/pgtab.h | 86 --------------- libddekit/include/ddekit/printf.h | 35 ------ libddekit/include/ddekit/resources.h | 14 --- libddekit/include/ddekit/semaphore.h | 50 --------- libddekit/include/ddekit/thread.h | 145 ------------------------- libddekit/include/ddekit/timer.h | 59 ----------- libddekit/include/ddekit/types.h | 22 ---- libddekit/memory.c | 2 +- libhurd-slab/Makefile | 2 +- libmachdev/Makefile | 4 +- libmachdev/if_hdr.h | 2 +- 54 files changed, 1082 insertions(+), 1083 deletions(-) create mode 100644 libddekit/dde.h create mode 100644 libddekit/ddekit/assert.h create mode 100644 libddekit/ddekit/condvar.h create mode 100644 libddekit/ddekit/debug.h create mode 100644 libddekit/ddekit/initcall.h create mode 100644 libddekit/ddekit/inline.h create mode 100644 libddekit/ddekit/interrupt.h create mode 100644 libddekit/ddekit/lock.h create mode 100644 libddekit/ddekit/memory.h create mode 100644 libddekit/ddekit/panic.h create mode 100644 libddekit/ddekit/pci.h create mode 100644 libddekit/ddekit/pgtab.h create mode 100644 libddekit/ddekit/printf.h create mode 100644 libddekit/ddekit/resources.h create mode 100644 libddekit/ddekit/semaphore.h create mode 100644 libddekit/ddekit/thread.h create mode 100644 libddekit/ddekit/timer.h create mode 100644 libddekit/ddekit/types.h delete mode 100644 libddekit/include/dde.h delete mode 100644 libddekit/include/ddekit/assert.h delete mode 100644 libddekit/include/ddekit/condvar.h delete mode 100644 libddekit/include/ddekit/debug.h delete mode 100644 libddekit/include/ddekit/initcall.h delete mode 100644 libddekit/include/ddekit/inline.h delete mode 100644 libddekit/include/ddekit/interrupt.h delete mode 100644 libddekit/include/ddekit/lock.h delete mode 100644 libddekit/include/ddekit/memory.h delete mode 100644 libddekit/include/ddekit/panic.h delete mode 100644 libddekit/include/ddekit/pci.h delete mode 100644 libddekit/include/ddekit/pgtab.h delete mode 100644 libddekit/include/ddekit/printf.h delete mode 100644 libddekit/include/ddekit/resources.h delete mode 100644 libddekit/include/ddekit/semaphore.h delete mode 100644 libddekit/include/ddekit/thread.h delete mode 100644 libddekit/include/ddekit/timer.h delete mode 100644 libddekit/include/ddekit/types.h (limited to 'dde_ne2k_pci') diff --git a/dde_e100/Makefile b/dde_e100/Makefile index f5b2294a..db23a0ce 100644 --- a/dde_e100/Makefile +++ b/dde_e100/Makefile @@ -8,7 +8,7 @@ TARGET = dde_e100 SRC_C = main.c e100.c LIBS += $(libmachdev_path) -ldde_linux26.o -ldde_linux26_net $(libddekit_path) -lfshelp -ltrivfs -lpciaccess -lthreads -lshouldbeinlibc -lports $(libslab_path) $(libbpf_path) -CFLAGS += -g -I$(PKGDIR)/include -I../libmachdev +CFLAGS += -g -I$(PKGDIR)/include -I$(BUILDDIR)/include # DDE configuration include $(L4DIR)/Makeconf diff --git a/dde_e100/main.c b/dde_e100/main.c index 63ab182f..98f4452a 100644 --- a/dde_e100/main.c +++ b/dde_e100/main.c @@ -6,7 +6,7 @@ #include // initcall() #include // msleep() -#include +#include int using_std = 1; diff --git a/dde_e1000/Makefile b/dde_e1000/Makefile index 137a69ef..376efe94 100644 --- a/dde_e1000/Makefile +++ b/dde_e1000/Makefile @@ -8,7 +8,7 @@ TARGET = dde_e1000 SRC_C = main.c e1000_ethtool.c e1000_hw.c e1000_main.c e1000_param.c LIBS += $(libmachdev_path) -ldde_linux26.o -ldde_linux26_net $(libddekit_path) -lfshelp -ltrivfs -lpciaccess -lthreads -lshouldbeinlibc -lports $(libslab_path) $(libbpf_path) -CFLAGS += -g -I$(PKGDIR)/include -I../libmachdev +CFLAGS += -g -I$(PKGDIR)/include -I$(BUILDDIR)/include # DDE configuration include $(L4DIR)/Makeconf diff --git a/dde_e1000/main.c b/dde_e1000/main.c index 63ab182f..98f4452a 100644 --- a/dde_e1000/main.c +++ b/dde_e1000/main.c @@ -6,7 +6,7 @@ #include // initcall() #include // msleep() -#include +#include int using_std = 1; diff --git a/dde_ne2k_pci/Makefile b/dde_ne2k_pci/Makefile index 44e805e0..f414a3f3 100644 --- a/dde_ne2k_pci/Makefile +++ b/dde_ne2k_pci/Makefile @@ -10,7 +10,7 @@ TARGET = dde_ne2k_pci SRC_C = main.c ne2k-pci.c 8390.c LIBS += $(libmachdev_path) -ldde_linux26.o -ldde_linux26_net $(libddekit_path) -lfshelp -ltrivfs -lpciaccess -lthreads -lshouldbeinlibc -lports $(libslab_path) $(libbpf_path) -CFLAGS += -g -I$(PKGDIR)/include -I../libmachdev +CFLAGS += -g -I$(PKGDIR)/include -I$(BUILDDIR)/include # DDE configuration include $(L4DIR)/Makeconf diff --git a/dde_ne2k_pci/main.c b/dde_ne2k_pci/main.c index 63ab182f..98f4452a 100644 --- a/dde_ne2k_pci/main.c +++ b/dde_ne2k_pci/main.c @@ -6,7 +6,7 @@ #include // initcall() #include // msleep() -#include +#include int using_std = 1; diff --git a/dde_pcnet32/Makefile b/dde_pcnet32/Makefile index 5b45cc14..18cd336c 100644 --- a/dde_pcnet32/Makefile +++ b/dde_pcnet32/Makefile @@ -8,7 +8,7 @@ TARGET = dde_pcnet32 SRC_C = main.c pcnet32.c LIBS += $(libmachdev_path) -ldde_linux26.o -ldde_linux26_net $(libddekit_path) -lfshelp -ltrivfs -lpciaccess -lthreads -lshouldbeinlibc -lports $(libslab_path) $(libbpf_path) -CFLAGS += -g -I$(PKGDIR)/include -I../libmachdev +CFLAGS += -g -I$(PKGDIR)/include -I$(BUILDDIR)/include # DDE configuration include $(L4DIR)/Makeconf diff --git a/dde_pcnet32/main.c b/dde_pcnet32/main.c index 63ab182f..98f4452a 100644 --- a/dde_pcnet32/main.c +++ b/dde_pcnet32/main.c @@ -6,7 +6,7 @@ #include // initcall() #include // msleep() -#include +#include int using_std = 1; diff --git a/dde_rtl8139/Makefile b/dde_rtl8139/Makefile index 16d3b764..f2c49547 100644 --- a/dde_rtl8139/Makefile +++ b/dde_rtl8139/Makefile @@ -10,7 +10,7 @@ TARGET = dde_rtl8139 SRC_C = main.c 8139cp.c LIBS += $(libmachdev_path) -ldde_linux26.o -ldde_linux26_net $(libddekit_path) -lfshelp -ltrivfs -lpciaccess -lthreads -lshouldbeinlibc -lports $(libslab_path) $(libbpf_path) -CFLAGS += -g -I$(PKGDIR)/include -I../libmachdev +CFLAGS += -g -I$(PKGDIR)/include -I$(BUILDDIR)/include # DDE configuration include $(L4DIR)/Makeconf diff --git a/dde_rtl8139/main.c b/dde_rtl8139/main.c index 63ab182f..98f4452a 100644 --- a/dde_rtl8139/main.c +++ b/dde_rtl8139/main.c @@ -6,7 +6,7 @@ #include // initcall() #include // msleep() -#include +#include int using_std = 1; diff --git a/libbpf/Makefile b/libbpf/Makefile index 5ce87573..1000429d 100644 --- a/libbpf/Makefile +++ b/libbpf/Makefile @@ -21,7 +21,7 @@ makemode := library libname = libbpf SRCS= bpf_impl.c queue.c LCLHDRS = bpf_impl.h queue.h -installhdrs = +installhdrs = bpf_impl.h MIGSTUBS = OBJS = $(sort $(SRCS:.c=.o) $(MIGSTUBS)) diff --git a/libdde_linux26/Makeconf b/libdde_linux26/Makeconf index 4ee54c66..00c59092 100644 --- a/libdde_linux26/Makeconf +++ b/libdde_linux26/Makeconf @@ -39,7 +39,7 @@ ifeq ($(ARCH), x86) MY_DDE_INCDIR += $(OBJ_BASE)/include/linux-headers/asm/mach-default endif -PRIVATE_INCDIR += $(MY_DDE_INCDIR) $(MY_LINUX26_INCDIR) $(PKGDIR)/../libddekit/include +PRIVATE_INCDIR += $(MY_DDE_INCDIR) $(MY_LINUX26_INCDIR) $(PKGDIR)/../libddekit DEFINES += -D__KERNEL__ -DDDE_LINUX $(KBUILD_DEFINES) CPPFLAGS += $(KBUILD_CPPFLAGS) diff --git a/libdde_linux26/mk/prog.mk b/libdde_linux26/mk/prog.mk index d54c38e9..c1d5d9a8 100644 --- a/libdde_linux26/mk/prog.mk +++ b/libdde_linux26/mk/prog.mk @@ -56,7 +56,6 @@ TARGET_STANDARD := $(TARGET) $(TARGET_$(OSYSTEM)) TARGET_PROFILE := $(addsuffix .pr,$(filter $(BUILD_PROFILE),$(TARGET))) TARGET += $(TARGET_$(OSYSTEM)) $(TARGET_PROFILE) -CFLAGS += $(DDEKITINCDIR) # define some variables different for lib.mk and prog.mk ifeq ($(MODE),loader) LDFLAGS += --dynamic-linker libld-l4.s.so diff --git a/libddekit/Makefile b/libddekit/Makefile index 8ba581ec..29000cd9 100644 --- a/libddekit/Makefile +++ b/libddekit/Makefile @@ -22,17 +22,20 @@ libname = libddekit SRCS= condvar.c init.c interrupt.c lock.c malloc.c memory.c \ pci.c pgtab.c printf.c resources.c list.c panic.c \ thread.c timer.c initcall.c -LCLHDRS = include/ddekit/condvar.h include/ddekit/lock.h \ - include/ddekit/semaphore.h include/ddekit/debug.h \ - include/ddekit/inline.h include/ddekit/panic.h \ - include/ddekit/thread.h include/ddekit/types.h \ - include/ddekit/pgtab.h include/ddekit/printf.h \ - include/ddekit/pci.h include/ddekit/assert.h \ - include/ddekit/interrupt.h include/ddekit/resources.h \ - include/ddekit/memory.h include/ddekit/timer.h \ - include/dde.h \ +installhdrs = ddekit/condvar.h ddekit/lock.h \ + ddekit/semaphore.h ddekit/debug.h \ + ddekit/inline.h ddekit/panic.h \ + ddekit/thread.h ddekit/types.h \ + ddekit/pgtab.h ddekit/printf.h \ + ddekit/pci.h ddekit/assert.h \ + ddekit/interrupt.h ddekit/resources.h \ + ddekit/memory.h ddekit/timer.h \ + ddekit/initcall.h + +installhdrsubdir = . +LCLHDRS = $(installhdrs) \ + dde.h \ config.h list.h util.h -installhdrs = MIGSTUBS = deviceUser.o machUser.o OBJS = $(sort $(SRCS:.c=.o) $(MIGSTUBS)) @@ -43,8 +46,7 @@ MIGCOMSFLAGS = -prefix dde_ include ../Makeconf -LDFLAGS += -lpciaccess -CFLAGS += -I$(srcdir)/include +LIBS += -lpciaccess $(libname).so.$(hurd-version): echo "INPUT ( $(libname).a )" > $@ diff --git a/libddekit/dde.h b/libddekit/dde.h new file mode 100644 index 00000000..12f8a81a --- /dev/null +++ b/libddekit/dde.h @@ -0,0 +1,14 @@ +#ifndef l4_ddekit_h +#define l4_ddekit_h + +/* FIXME if this is ddekit.h, it should be moved into dde/ddekit/include/ddekit.h (also + * all headers under include/ddekit) */ + +/** + * Initialize the DDE. Must be called before any other DDE function. + * + * FIXME revisit this one + */ +void ddekit_init(void); + +#endif diff --git a/libddekit/ddekit/assert.h b/libddekit/ddekit/assert.h new file mode 100644 index 00000000..5d593662 --- /dev/null +++ b/libddekit/ddekit/assert.h @@ -0,0 +1,23 @@ +#ifndef _ddekit_assert_h +#define _ddekit_assert_h + +#include "ddekit/printf.h" +#include "ddekit/panic.h" + +/** \file ddekit/assert.h */ + +/** Assert that an expression is true and panic if not. + * \ingroup DDEKit_util + */ +#define Assert(expr) do \ + { \ + if (!(expr)) { \ + ddekit_print("\033[31;1mDDE: Assertion failed: "#expr"\033[0m\n"); \ + ddekit_printf(" File: %s:%d\n",__FILE__,__LINE__); \ + ddekit_printf(" Function: %s()\n", __FUNCTION__); \ + ddekit_panic("Assertion failed."); \ + }} while (0); + +#endif + +#define assert Assert diff --git a/libddekit/ddekit/condvar.h b/libddekit/ddekit/condvar.h new file mode 100644 index 00000000..129a718d --- /dev/null +++ b/libddekit/ddekit/condvar.h @@ -0,0 +1,53 @@ +#ifndef _ddekit_condvar_h +#define _ddekit_condvar_h + +/** \file ddekit/condvar.h */ +#include "ddekit/lock.h" + +struct ddekit_condvar; +typedef struct ddekit_condvar ddekit_condvar_t; + +/** Initialize conditional variable. + * + * \ingroup DDEKit_synchronization + */ +ddekit_condvar_t * ddekit_condvar_init(void); + +/** Uninitialize conditional variable. + * + * \ingroup DDEKit_synchronization + */ +void ddekit_condvar_deinit(ddekit_condvar_t *cvp); + +/** Wait on a conditional variable. + * + * \ingroup DDEKit_synchronization + */ +void ddekit_condvar_wait(ddekit_condvar_t *cvp, ddekit_lock_t *mp); + +/** Wait on a conditional variable at most until a timeout expires. + * + * \ingroup DDEKit_synchronization + * + * \param cvp pointer to condvar + * \param mp lock + * \param timo timeout in ms + * + * \return 0 success + * \return !=0 timeout + */ +int ddekit_condvar_wait_timed(ddekit_condvar_t *cvp, ddekit_lock_t *mp, int timo); + +/** Send signal to the next one waiting for condvar. + * + * \ingroup DDEKit_synchronization + */ +void ddekit_condvar_signal(ddekit_condvar_t *cvp); + +/** Send signal to all threads waiting for condvar. + * + * \ingroup DDEKit_synchronization + */ +void ddekit_condvar_broadcast(ddekit_condvar_t *cvp); + +#endif diff --git a/libddekit/ddekit/debug.h b/libddekit/ddekit/debug.h new file mode 100644 index 00000000..79a8e7b5 --- /dev/null +++ b/libddekit/ddekit/debug.h @@ -0,0 +1,8 @@ +#define DDEBUG_QUIET 0 +#define DDEBUG_ERR 1 +#define DDEBUG_WARN 2 +#define DDEBUG_INFO 3 +#define DDEBUG_VERBOSE 4 + +#define DDEBUG_MEM DDEBUG_INFO + diff --git a/libddekit/ddekit/initcall.h b/libddekit/ddekit/initcall.h new file mode 100644 index 00000000..6befa31c --- /dev/null +++ b/libddekit/ddekit/initcall.h @@ -0,0 +1,42 @@ +#ifndef _ddekit_initcall_h +#define _ddekit_initcall_h + +// from l4/sys/compiler.h +#if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ >= 4 +#define L4_STICKY(x) __attribute__((used)) x +#else +#define L4_STICKY(x) __attribute__((unused)) x +#endif + +#define l4str(s) #s + +// from dde_linux/ARCH-x86/ctor.h +typedef void (*l4ddekit_initcall_t)(void); + +#define __l4ddekit_initcall(p) \ + __attribute__ ((__section__ (".l4dde_ctors." #p))) + +/** Define a function to be a DDEKit initcall. + * + * Define a function to be a DDEKit initcall. This function will then be placed + * in a separate linker section of the binary (called .l4dde_ctors). The L4Env + * construction mechanism will execute all constructors in this section during + * application startup. + * + * This is the right place to place Linux' module_init functions & Co. + * + * \param fn function + */ +#define DDEKIT_INITCALL(fn) DDEKIT_CTOR(fn, 1) + +#define DDEKIT_CTOR(fn, prio) \ + l4ddekit_initcall_t \ + L4_STICKY(__l4ddekit_initcall_##fn) \ + __l4ddekit_initcall(prio) = (void *)fn + +/** + * Runs all registered initcalls. + */ +void ddekit_do_initcalls(void); + +#endif diff --git a/libddekit/ddekit/inline.h b/libddekit/ddekit/inline.h new file mode 100644 index 00000000..e59a5c68 --- /dev/null +++ b/libddekit/ddekit/inline.h @@ -0,0 +1,2 @@ +#define INLINE __inline__ __attribute__((always_inline)) + diff --git a/libddekit/ddekit/interrupt.h b/libddekit/ddekit/interrupt.h new file mode 100644 index 00000000..3f789210 --- /dev/null +++ b/libddekit/ddekit/interrupt.h @@ -0,0 +1,57 @@ +/* + * \brief Hardware-interrupt subsystem + * \author Thomas Friebel + * \author Christian Helmuth + * \date 2007-01-26 + * + * DDEKit supports registration of one handler function per interrupt. If any + * specific DDE implementation needs to register more than one handler, + * multiplexing has to be implemented there! + */ + +#ifndef _ddekit_interrupt_h +#define _ddekit_interrupt_h + +#include "ddekit/thread.h" + +#define DDEKIT_IRQ_PRIO 2 + +/** + * Attach to hardware interrupt + * + * \param irq IRQ number to attach to + * \param shared set to 1 if interrupt sharing is supported; set to 0 + * otherwise + * \param thread_init called just after DDEKit internal init and before any + * other function + * \param handler IRQ handler for interrupt irq + * \param priv private token (argument for thread_init and handler) + * + * \return pointer to interrupt thread created + */ +ddekit_thread_t *ddekit_interrupt_attach(int irq, int shared, + void(*thread_init)(void *), + void(*handler)(void *), void *priv); + +/** + * Detach from a previously attached interrupt. + * + * \param irq IRQ number + */ +void ddekit_interrupt_detach(int irq); + +/** + * Block interrupt. + * + * \param irq IRQ number to block + */ +void ddekit_interrupt_disable(int irq); + +/** + * Enable interrupt. + * + * \param irq IRQ number to block + */ +void ddekit_interrupt_enable(int irq); + +#endif diff --git a/libddekit/ddekit/lock.h b/libddekit/ddekit/lock.h new file mode 100644 index 00000000..dd398b38 --- /dev/null +++ b/libddekit/ddekit/lock.h @@ -0,0 +1,83 @@ +#ifndef _ddekit_lock_h +#define _ddekit_lock_h + +struct ddekit_lock; + +/** Initialize a DDEKit lock. + * + * \ingroup DDEKit_synchronization + */ +void _ddekit_lock_init (struct ddekit_lock **mtx); + +/** Uninitialize a DDEKit lock. + * + * \ingroup DDEKit_synchronization + */ +void _ddekit_lock_deinit (struct ddekit_lock **mtx); + +/** Acquire a lock. + * + * \ingroup DDEKit_synchronization + */ +void _ddekit_lock_lock (struct ddekit_lock **mtx); + +/** Acquire a lock, non-blocking. + * + * \ingroup DDEKit_synchronization + */ +int _ddekit_lock_try_lock(struct ddekit_lock **mtx); + +/** Unlock function. + * + * \ingroup DDEKit_synchronization + */ +void _ddekit_lock_unlock (struct ddekit_lock **mtx); + +/** Get lock owner. + * + * \ingroup DDEKit_synchronization + */ +int _ddekit_lock_owner(struct ddekit_lock **mtx); + +// definition of ddekit_lock_t +typedef struct ddekit_lock *ddekit_lock_t; + +// common prototypes +static void ddekit_lock_init_locked(ddekit_lock_t *mtx); +static void ddekit_lock_init_unlocked(ddekit_lock_t *mtx); +#define ddekit_lock_init ddekit_lock_init_unlocked +static void ddekit_lock_deinit (ddekit_lock_t *mtx); +static void ddekit_lock_lock (ddekit_lock_t *mtx); +static int ddekit_lock_try_lock(ddekit_lock_t *mtx); // returns 0 on success, != 0 if it would block +static void ddekit_lock_unlock (ddekit_lock_t *mtx); + +// inline implementation or inline call to non-inline implementation +#include "ddekit/inline.h" + +static INLINE void ddekit_lock_init_unlocked(ddekit_lock_t *mtx) { + _ddekit_lock_init(mtx); +} + +static INLINE void ddekit_lock_init_locked(ddekit_lock_t *mtx) { + _ddekit_lock_init(mtx); + _ddekit_lock_lock(mtx); +} + +static INLINE void ddekit_lock_deinit(ddekit_lock_t *mtx) { + _ddekit_lock_deinit(mtx); +} +static INLINE void ddekit_lock_lock(ddekit_lock_t *mtx) { + _ddekit_lock_lock(mtx); +} +static INLINE int ddekit_lock_try_lock(ddekit_lock_t *mtx) { + return _ddekit_lock_try_lock(mtx); +} +static INLINE void ddekit_lock_unlock(ddekit_lock_t *mtx) { + _ddekit_lock_unlock(mtx); +} + +static INLINE int ddekit_lock_owner(ddekit_lock_t *mtx) { + return _ddekit_lock_owner(mtx); +} + +#endif diff --git a/libddekit/ddekit/memory.h b/libddekit/ddekit/memory.h new file mode 100644 index 00000000..051a4d9e --- /dev/null +++ b/libddekit/ddekit/memory.h @@ -0,0 +1,144 @@ +/* + * \brief Memory subsystem + * \author Thomas Friebel + * \author Christian Helmuth + * \date 2006-11-03 + */ + +#ifndef _ddekit_memory_h +#define _ddekit_memory_h + + +/******************* + ** Slab facility ** + *******************/ + +struct ddekit_slab; + +/** + * Store user pointer in slab cache + * + * \param slab pointer to slab cache + * \param data user pointer + */ +void ddekit_slab_set_data(struct ddekit_slab * slab, void *data); + +/** + * Read user pointer from slab cache + * + * \param slab pointer to slab cache + * + * \return stored user pointer or 0 + */ +void *ddekit_slab_get_data(struct ddekit_slab * slab); + +/** + * Allocate slab in slab cache + * + * \param slab pointer to slab cache + * + * \return pointer to allocated slab + */ +void *ddekit_slab_alloc(struct ddekit_slab * slab); + +/** + * Deallocate slab in slab cache + * + * \param slab pointer to slab cache + * \param objp pointer to allocated slab + */ +void ddekit_slab_free(struct ddekit_slab * slab, void *objp); + +/** + * Setup page cache for all slabs + * + * \param pages maximal number of memory pages + * + * If 'pages' is too low, memory pages may be given back to the memory server + * (dm_phys) and just to be allocated again later. This hits performance (but + * saves memory). Increase 'pages' to avoid this thrashing-like effect. + * + * If the maximal number of unused pages is exceeded, subsequent deallocation + * will be freed at the memory server. This page cache caches pages from all + * slabs. + */ +void ddekit_slab_setup_page_cache(unsigned pages); + +/** + * Destroy slab cache + * + * \param slab pointer to slab cache structure + */ +void ddekit_slab_destroy(struct ddekit_slab * slab); + +/** + * Initialize slab cache + * + * \param size size of cache objects + * \param contiguous make this slab use physically contiguous memory + * + * \return pointer to new slab cache or 0 on error + */ +struct ddekit_slab * ddekit_slab_init(unsigned size, int contiguous); + + +/********************** + ** Memory allocator ** + **********************/ + +/** + * Allocate large memory block + * + * \param size block size + * \return pointer to new memory block + * + * Allocations via this allocator may be slow (because memory servers are + * involved) and should be used only for large (i.e., > page size) blocks. If + * allocations/deallocations are relatively dynamic this may not be what you + * want. + * + * Allocated blocks have valid virt->phys mappings and are physically + * contiguous. + */ +void *ddekit_large_malloc(int size); + +/** + * Free large memory block + * + * \param p pointer to memory block + */ +void ddekit_large_free(void *p); + +/** FIXME + * contig_malloc() is the lowest-level allocator interface one could implement. + * we should consider to provide vmalloc() too. */ +void *ddekit_contig_malloc( + unsigned long size, + unsigned long low, unsigned long high, + unsigned long alignment, unsigned long boundary +); + + +/***************************** + ** Simple memory allocator ** + *****************************/ + +/** + * Allocate memory block via simple allocator + * + * \param size block size + * \return pointer to new memory block + * + * The blocks allocated via this allocator CANNOT be used for DMA or other + * device operations, i.e., there exists no virt->phys mapping. + */ +void *ddekit_simple_malloc(unsigned size); + +/** + * Free memory block via simple allocator + * + * \param p pointer to memory block + */ +void ddekit_simple_free(void *p); + +#endif diff --git a/libddekit/ddekit/panic.h b/libddekit/ddekit/panic.h new file mode 100644 index 00000000..1468675f --- /dev/null +++ b/libddekit/ddekit/panic.h @@ -0,0 +1,16 @@ +#ifndef _ddekit_panic_h +#define _ddekit_panic_h + +/** \defgroup DDEKit_util */ + +/** Panic - print error message and enter the kernel debugger. + * \ingroup DDEKit_util + */ +void ddekit_panic(char *fmt, ...) __attribute__((noreturn)); + +/** Print a debug message. + * \ingroup DDEKit_util + */ +void ddekit_debug(char *fmt, ...); + +#endif diff --git a/libddekit/ddekit/pci.h b/libddekit/ddekit/pci.h new file mode 100644 index 00000000..5a5fd29b --- /dev/null +++ b/libddekit/ddekit/pci.h @@ -0,0 +1,199 @@ +#ifndef _ddekit_pci_h +#define _ddekit_pci_h + +#include "ddekit/types.h" + +/** \defgroup DDEKit_pci */ + +/** Our version of PCI_ANY_ID */ +#define DDEKIT_PCI_ANY_ID (~0) + +/** Copy of L4IO_PCIDEV_RES */ +#define DDEKIT_PCIDEV_RES 12 + +struct ddekit_pci_dev; + +/** PCI resource descriptor. Copied from generic_io. + * + * XXX! + */ +typedef struct ddekit_pci_resource { + unsigned long start; + unsigned long end; + unsigned long flags; +} ddekit_pci_res_t; + +void ddekit_pci_init(void); + +int ddekit_pci_get_device(int nr, int *bus, int *slot, int *func); + +int ddekit_pci_read(int bus, int slot, int func, int pos, int len, ddekit_uint32_t *val); +int ddekit_pci_write(int bus, int slot, int func, int pos, int len, ddekit_uint32_t val); + +/** Read byte from PCI config space. + * + * \ingroup DDEKit_pci + * + * \param bus bus ID + * \param slot slot # + * \param func function # + * \param pos offset in config space + * \retval val read value + * + * \return 0 success + */ +int ddekit_pci_readb (int bus, int slot, int func, int pos, ddekit_uint8_t *val); + +/** Read word from PCI config space. + * + * \ingroup DDEKit_pci + * + * \param bus bus ID + * \param slot slot # + * \param func function # + * \param pos offset in config space + * \retval val read value + * + * \return 0 success + */ +int ddekit_pci_readw (int bus, int slot, int func, int pos, ddekit_uint16_t *val); + +/** Read dword from PCI config space. + * + * \ingroup DDEKit_pci + * + * \param bus bus ID + * \param slot slot # + * \param func function # + * \param pos offset in config space + * \retval val read value + * + * \return 0 success + */ +int ddekit_pci_readl (int bus, int slot, int func, int pos, ddekit_uint32_t *val); + +/** Write byte to PCI config space. + * + * \ingroup DDEKit_pci + * + * \param bus bus ID + * \param slot slot # + * \param func function # + * \param pos offset in config space + * \retval val value to write + * + * \return 0 success + */ +int ddekit_pci_writeb(int bus, int slot, int func, int pos, ddekit_uint8_t val); + +/** Write word to PCI config space. + * + * \ingroup DDEKit_pci + * + * \param bus bus ID + * \param slot slot # + * \param func function # + * \param pos offset in config space + * \retval val value to write + * + * \return 0 success + */ +int ddekit_pci_writew(int bus, int slot, int func, int pos, ddekit_uint16_t val); + +/** Write word to PCI config space. + * + * \ingroup DDEKit_pci + * + * \param bus bus ID + * \param slot slot # + * \param func function # + * \param pos offset in config space + * \retval val value to write + * + * \return 0 success + */ +int ddekit_pci_writel(int bus, int slot, int func, int pos, ddekit_uint32_t val); + +/** Find a PCI device. + * + * \ingroup DDEKit_pci + * + * \param bus pointer to bus number or \ref DDEKIT_PCI_ANY_ID + * \param slot pointer to slot number (devfn >> DEVFN_SLOTSHIFT) or \ref DDEKIT_PCI_ANY_ID + * \param func pointer to func number (devfc & DEVFN_FUNCMASK) or \ref DDEKIT_PCI_ANY_ID + * \param start search device list only behind this device (excluding it!), NULL + * searches whole device list + * + * \retval bus bus number + * \retval slot slot number + * \retval func function number + * + * \return device a valid PCI device + * \return NULL if no device found + */ +struct ddekit_pci_dev * +ddekit_pci_find_device(int *bus, int *slot, int *func, struct ddekit_pci_dev *start); + +/** Enable PCI device + * \ingroup DDEKit_pci + */ +int ddekit_pci_enable_device(struct ddekit_pci_dev *dev); + +/** Disable PCI device + * \ingroup DDEKit_pci + */ +int ddekit_pci_disable_device(struct ddekit_pci_dev *dev); + +/** Enable bus-mastering for device. + * \ingroup DDEKit_pci + */ +void ddekit_pci_set_master(struct ddekit_pci_dev *dev); + +/** Get device vendor ID. + * \ingroup DDEKit_pci + */ +unsigned short ddekit_pci_get_vendor(struct ddekit_pci_dev *dev); + +/** Get device ID. + * \ingroup DDEKit_pci + */ +unsigned short ddekit_pci_get_device_id(struct ddekit_pci_dev *dev); + +/** Get device subvendor ID. + * \ingroup DDEKit_pci + */ +unsigned short ddekit_pci_get_sub_vendor(struct ddekit_pci_dev *dev); + +/** Get subdevice ID. + * \ingroup DDEKit_pci + */ +unsigned short ddekit_pci_get_sub_device(struct ddekit_pci_dev *dev); + +/** Get device class ID. + * \ingroup DDEKit_pci + */ +unsigned ddekit_pci_get_dev_class(struct ddekit_pci_dev *dev); + +/** Get device's IRQ number. + * \ingroup DDEKit_pci + */ +unsigned long ddekit_pci_get_irq(struct ddekit_pci_dev *dev); + +/** Get device name. + * \ingroup DDEKit_pci + */ +char *ddekit_pci_get_name(struct ddekit_pci_dev *dev); + +/** Get device's slot name. + * \ingroup DDEKit_pci + */ +char *ddekit_pci_get_slot_name(struct ddekit_pci_dev *dev); + +/** Get one of the device's resources. + * \ingroup DDEKit_pci + */ +ddekit_pci_res_t *ddekit_pci_get_resource(struct ddekit_pci_dev *dev, unsigned int idx); + +int ddekit_pci_irq_enable(int bus, int slot, int func, int pin, int *irq); + +#endif // _ddekit_pci_h diff --git a/libddekit/ddekit/pgtab.h b/libddekit/ddekit/pgtab.h new file mode 100644 index 00000000..8964b713 --- /dev/null +++ b/libddekit/ddekit/pgtab.h @@ -0,0 +1,86 @@ +/* + * \brief Virtual page-table facility + * \author Thomas Friebel + * \author Christian Helmuth + * \date 2006-11-03 + */ + +#ifndef _ddekit_pgtab_h +#define _ddekit_pgtab_h + +#include "ddekit/types.h" + +/* FIXME Region types may be defined by pgtab users. Do we really need them + * here? */ +enum ddekit_pgtab_type +{ + PTE_TYPE_OTHER, PTE_TYPE_LARGE, PTE_TYPE_UMA, PTE_TYPE_CONTIG +}; + + +/** + * Set virtual->physical mapping for VM region + * + * \param virt virtual start address for region + * \param phys physical start address for region + * \param pages number of pages in region + * \param type pgtab type for region + */ +void ddekit_pgtab_set_region(void *virt, ddekit_addr_t phys, int pages, int type); + + +/** + * Set virtual->physical mapping for VM region given a specific size in bytes. + * + * Internally, DDEKit manages regions with pages. However, DDEs do not need to tangle + * with the underlying mechanism and therefore can use this function that takes care + * of translating a size to an amount of pages. + */ +void ddekit_pgtab_set_region_with_size(void *virt, ddekit_addr_t phys, int size, int type); + + +/** + * Clear virtual->physical mapping for VM region + * + * \param virt virtual start address for region + * \param type pgtab type for region + */ +void ddekit_pgtab_clear_region(void *virt, int type); + +/** + * Get physical address for virtual address + * + * \param virt virtual address + * + * \return physical address + */ +ddekit_addr_t ddekit_pgtab_get_physaddr(const void *virt); + +/** + * Get virtual address for physical address + * + * \param physical physical address + * + * \return virtual address + */ +ddekit_addr_t ddekit_pgtab_get_virtaddr(const ddekit_addr_t physical); + +/** + * Get type of VM region. + * + * \param virt virtual address + + * \return VM region type + */ +int ddekit_pgtab_get_type(const void *virt); + +/** + * Get size of VM region. + * + * \param virt virtual address + * + * \return VM region size (in bytes) + */ +int ddekit_pgtab_get_size(const void *virt); + +#endif diff --git a/libddekit/ddekit/printf.h b/libddekit/ddekit/printf.h new file mode 100644 index 00000000..6dafa18d --- /dev/null +++ b/libddekit/ddekit/printf.h @@ -0,0 +1,35 @@ +#ifndef _ddekit_print_h +#define _ddekit_print_h + +#include + +/** Print message. + * \ingroup DDEKit_util + */ +int ddekit_print(const char *); + +/** Print message with format. + * \ingroup DDEKit_util + */ +int ddekit_printf(const char *fmt, ...); + +/** Print message with format list. + * \ingroup DDEKit_util + */ +int ddekit_vprintf(const char *fmt, va_list va); + +void dump_stack(void); + +/** Log function and message. + * \ingroup DDEKit_util + */ +#define ddekit_log(doit, msg...) \ + do { \ + if (doit) { \ + ddekit_printf("%s(): ", __func__); \ + ddekit_printf(msg); \ + ddekit_printf("\n"); \ + } \ + } while(0); + +#endif diff --git a/libddekit/ddekit/resources.h b/libddekit/ddekit/resources.h new file mode 100644 index 00000000..657295a0 --- /dev/null +++ b/libddekit/ddekit/resources.h @@ -0,0 +1,14 @@ +#ifndef _ddekit_resources_h +#define _ddekit_resources_h + +#include "ddekit/types.h" + +int ddekit_request_dma(int nr); +int ddekit_release_dma(int nr); +int ddekit_request_io (ddekit_addr_t start, ddekit_addr_t count); +int ddekit_release_io (ddekit_addr_t start, ddekit_addr_t count); +int ddekit_request_mem(ddekit_addr_t start, ddekit_addr_t count, ddekit_addr_t *vaddr); +int ddekit_release_mem(ddekit_addr_t start, ddekit_addr_t count); +long ddekit_random (void); + +#endif diff --git a/libddekit/ddekit/semaphore.h b/libddekit/ddekit/semaphore.h new file mode 100644 index 00000000..c959919d --- /dev/null +++ b/libddekit/ddekit/semaphore.h @@ -0,0 +1,50 @@ +#ifndef _ddekit_semaphore_h +#define _ddekit_semaphore_h + +/** \defgroup DDEKit_synchronization */ + +struct ddekit_sem; +typedef struct ddekit_sem ddekit_sem_t; + +/** Initialize DDEKit semaphore. + * + * \ingroup DDEKit_synchronization + * + * \param value initial semaphore counter + */ +ddekit_sem_t *ddekit_sem_init(int value); + +/** Uninitialize semaphore. + * + * \ingroup DDEKit_synchronization + */ +void ddekit_sem_deinit(ddekit_sem_t *sem); + +/** Semaphore down method. */ +void ddekit_sem_down(ddekit_sem_t *sem); + +/** Semaphore down method, non-blocking. + * + * \ingroup DDEKit_synchronization + * + * \return 0 success + * \return !=0 would block + */ +int ddekit_sem_down_try(ddekit_sem_t *sem); + +/** Semaphore down with timeout. + * + * \ingroup DDEKit_synchronization + * + * \return 0 success + * \return !=0 would block + */ +int ddekit_sem_down_timed(ddekit_sem_t *sem, int timo); + +/** Semaphore up method. + * + * \ingroup DDEKit_synchronization + */ +void ddekit_sem_up(ddekit_sem_t *sem); + +#endif diff --git a/libddekit/ddekit/thread.h b/libddekit/ddekit/thread.h new file mode 100644 index 00000000..8ed52013 --- /dev/null +++ b/libddekit/ddekit/thread.h @@ -0,0 +1,145 @@ +#ifndef _ddekit_thread_h +#define _ddekit_thread_h + +/** \defgroup DDEKit_threads */ + +#include "ddekit/lock.h" + +struct ddekit_thread; +typedef struct ddekit_thread ddekit_thread_t; + +/** Create thread + * + * \ingroup DDEKit_threads + * + * Create a new thread running the specified thread function with the specified + * arguments. The thread is assigned the given internal name. + * + * Additionally, DDEKit threads possess a thread-local storage area where they + * may store arbitrary data. + * + * \param fun thread function + * \param arg optional argument to thread function, set to NULL if not needed + * \param name internal thread name + */ +ddekit_thread_t *ddekit_thread_create(void (*fun)(void *), void *arg, const char *name); + +/** Reference to own DDEKit thread id. + * + * \ingroup DDEKit_threads + */ +ddekit_thread_t *ddekit_thread_myself(void); + +/** Initialize thread with given name. + * + * \ingroup DDEKit_threads + * + * This function may be used by threads that were not created using + * \ref ddekit_thread_create. This enables such threads to be handled as if they + * were DDEKit threads. + */ +ddekit_thread_t *ddekit_thread_setup_myself(const char *name); + +/** Get TLS data for a specific thread. + * + * \ingroup DDEKit_threads + * + * \return Pointer to TLS data of this thread. + */ +void *ddekit_thread_get_data(ddekit_thread_t *thread); + +/** Get TLS data for current thread. + * + * \ingroup DDEKit_threads + * + * Same as calling \ref ddekit_thread_get_data with \ref ddekit_thread_myself + * as parameter. + * + * \return Pointer to TLS data of current thread. + */ +void *ddekit_thread_get_my_data(void); + +/** Set TLS data for specific thread. + * + * \ingroup DDEKit_threads + * + * \param thread DDEKit thread + * \param data pointer to thread data + */ +void ddekit_thread_set_data(ddekit_thread_t *thread, void *data); + +/** Set TLS data for current thread. + * + * \ingroup DDEKit_threads + * + * \param data pointer to thread data + */ +void ddekit_thread_set_my_data(void *data); + +/** Sleep for some miliseconds. + * + * \ingroup DDEKit_threads + * + * \param msecs time to sleep in ms. + */ +void ddekit_thread_msleep(unsigned long msecs); + +/** Sleep for some microseconds. + * + * \ingroup DDEKit_threads + * + * \param usecs time to sleep in µs. + */ +void ddekit_thread_usleep(unsigned long usecs); + +/** Sleep for some nanoseconds. + * + * \ingroup DDEKit_threads + * + * \param usecs time to sleep in ns. + */ +void ddekit_thread_nsleep(unsigned long nsecs); + +/** Sleep until a lock becomes unlocked. + * + * \ingroup DDEKit_threads + */ +void ddekit_thread_sleep(ddekit_lock_t *lock); + +/** Wakeup a waiting thread. + * + * \ingroup DDEKit_threads + */ +void ddekit_thread_wakeup(ddekit_thread_t *thread); + +/** Terminate a thread + * + * \ingroup DDEKit_threads + */ +void ddekit_thread_exit(void) __attribute__((noreturn)); + +/** Get the name, a thread registered with DDEKit. + * + * \ingroup DDEKit_threads + */ +const char *ddekit_thread_get_name(ddekit_thread_t *thread); + +/** Hint that this thread is done and may be scheduled somehow. + * + * \ingroup DDEKit_threads + */ +void ddekit_thread_schedule(void); + +/** Hint that this thread is done and may be scheduled somehow. + * + * \ingroup DDEKit_threads + */ +void ddekit_yield(void); + +/** Initialize DDEKit thread subsystem. + * + * \ingroup DDEKit_threads + */ +void ddekit_init_threads(void); + +#endif diff --git a/libddekit/ddekit/timer.h b/libddekit/ddekit/timer.h new file mode 100644 index 00000000..387f2078 --- /dev/null +++ b/libddekit/ddekit/timer.h @@ -0,0 +1,59 @@ +#ifndef _ddekit_timer_h +#define _ddekit_timer_h + +#include "ddekit/thread.h" + +#define jiffies (fetch_jiffies()) +#define HZ 100 + +enum +{ + DDEKIT_INVALID_TIMER_ID = -1, +}; + +/** \defgroup DDEKit_timer + * + * Timer subsystem + * + * DDEKit provides a generic timer implementation that enables users + * to execute a function with some arguments after a certain period + * of time. DDEKit therefore starts a timer thread that executes these + * functions and keeps track of the currently running timers. + */ + +/** Add a timer event. After the absolute timeout has expired, function fn + * is called with args as arguments. + * + * \ingroup DDEKit_timer + * + * \return >=0 valid timer ID + * \return < 0 error + */ +int ddekit_add_timer(void (*fn)(void *), void *args, unsigned long timeout); + +/** Delete timer with the corresponding timer id. + * + * \ingroup DDEKit_timer + */ +int ddekit_del_timer(int timer); + +/** Check whether a timer is pending + * + * \ingroup DDEKit_timer + * + * Linux needs this. + */ +int ddekit_timer_pending(int timer); + +/** Initialization function, startup timer thread + * + * \ingroup DDEKit_timer + */ +void ddekit_init_timers(void); + +/** Get the timer thread. + */ +ddekit_thread_t *ddekit_get_timer_thread(void); +extern unsigned long fetch_jiffies (void); + +#endif diff --git a/libddekit/ddekit/types.h b/libddekit/ddekit/types.h new file mode 100644 index 00000000..83d92c65 --- /dev/null +++ b/libddekit/ddekit/types.h @@ -0,0 +1,22 @@ +/* + * \brief Types for ddekit (x86 version) + * \author Thomas Friebel + * \author Christian Helmuth + * \date 2006-11-09 + * + * FIXME This is definitely arch-dependent! Move to ARCH-something + */ + +#ifndef _DDEKIT_TYPES_H +#define _DDEKIT_TYPES_H + +typedef signed char ddekit_int8_t; +typedef unsigned char ddekit_uint8_t; +typedef signed short int ddekit_int16_t; +typedef unsigned short int ddekit_uint16_t; +typedef signed int ddekit_int32_t; +typedef unsigned int ddekit_uint32_t; + +typedef unsigned long ddekit_addr_t; + +#endif diff --git a/libddekit/include/dde.h b/libddekit/include/dde.h deleted file mode 100644 index 12f8a81a..00000000 --- a/libddekit/include/dde.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef l4_ddekit_h -#define l4_ddekit_h - -/* FIXME if this is ddekit.h, it should be moved into dde/ddekit/include/ddekit.h (also - * all headers under include/ddekit) */ - -/** - * Initialize the DDE. Must be called before any other DDE function. - * - * FIXME revisit this one - */ -void ddekit_init(void); - -#endif diff --git a/libddekit/include/ddekit/assert.h b/libddekit/include/ddekit/assert.h deleted file mode 100644 index 5d593662..00000000 --- a/libddekit/include/ddekit/assert.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef _ddekit_assert_h -#define _ddekit_assert_h - -#include "ddekit/printf.h" -#include "ddekit/panic.h" - -/** \file ddekit/assert.h */ - -/** Assert that an expression is true and panic if not. - * \ingroup DDEKit_util - */ -#define Assert(expr) do \ - { \ - if (!(expr)) { \ - ddekit_print("\033[31;1mDDE: Assertion failed: "#expr"\033[0m\n"); \ - ddekit_printf(" File: %s:%d\n",__FILE__,__LINE__); \ - ddekit_printf(" Function: %s()\n", __FUNCTION__); \ - ddekit_panic("Assertion failed."); \ - }} while (0); - -#endif - -#define assert Assert diff --git a/libddekit/include/ddekit/condvar.h b/libddekit/include/ddekit/condvar.h deleted file mode 100644 index 129a718d..00000000 --- a/libddekit/include/ddekit/condvar.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef _ddekit_condvar_h -#define _ddekit_condvar_h - -/** \file ddekit/condvar.h */ -#include "ddekit/lock.h" - -struct ddekit_condvar; -typedef struct ddekit_condvar ddekit_condvar_t; - -/** Initialize conditional variable. - * - * \ingroup DDEKit_synchronization - */ -ddekit_condvar_t * ddekit_condvar_init(void); - -/** Uninitialize conditional variable. - * - * \ingroup DDEKit_synchronization - */ -void ddekit_condvar_deinit(ddekit_condvar_t *cvp); - -/** Wait on a conditional variable. - * - * \ingroup DDEKit_synchronization - */ -void ddekit_condvar_wait(ddekit_condvar_t *cvp, ddekit_lock_t *mp); - -/** Wait on a conditional variable at most until a timeout expires. - * - * \ingroup DDEKit_synchronization - * - * \param cvp pointer to condvar - * \param mp lock - * \param timo timeout in ms - * - * \return 0 success - * \return !=0 timeout - */ -int ddekit_condvar_wait_timed(ddekit_condvar_t *cvp, ddekit_lock_t *mp, int timo); - -/** Send signal to the next one waiting for condvar. - * - * \ingroup DDEKit_synchronization - */ -void ddekit_condvar_signal(ddekit_condvar_t *cvp); - -/** Send signal to all threads waiting for condvar. - * - * \ingroup DDEKit_synchronization - */ -void ddekit_condvar_broadcast(ddekit_condvar_t *cvp); - -#endif diff --git a/libddekit/include/ddekit/debug.h b/libddekit/include/ddekit/debug.h deleted file mode 100644 index 79a8e7b5..00000000 --- a/libddekit/include/ddekit/debug.h +++ /dev/null @@ -1,8 +0,0 @@ -#define DDEBUG_QUIET 0 -#define DDEBUG_ERR 1 -#define DDEBUG_WARN 2 -#define DDEBUG_INFO 3 -#define DDEBUG_VERBOSE 4 - -#define DDEBUG_MEM DDEBUG_INFO - diff --git a/libddekit/include/ddekit/initcall.h b/libddekit/include/ddekit/initcall.h deleted file mode 100644 index 6befa31c..00000000 --- a/libddekit/include/ddekit/initcall.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef _ddekit_initcall_h -#define _ddekit_initcall_h - -// from l4/sys/compiler.h -#if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ >= 4 -#define L4_STICKY(x) __attribute__((used)) x -#else -#define L4_STICKY(x) __attribute__((unused)) x -#endif - -#define l4str(s) #s - -// from dde_linux/ARCH-x86/ctor.h -typedef void (*l4ddekit_initcall_t)(void); - -#define __l4ddekit_initcall(p) \ - __attribute__ ((__section__ (".l4dde_ctors." #p))) - -/** Define a function to be a DDEKit initcall. - * - * Define a function to be a DDEKit initcall. This function will then be placed - * in a separate linker section of the binary (called .l4dde_ctors). The L4Env - * construction mechanism will execute all constructors in this section during - * application startup. - * - * This is the right place to place Linux' module_init functions & Co. - * - * \param fn function - */ -#define DDEKIT_INITCALL(fn) DDEKIT_CTOR(fn, 1) - -#define DDEKIT_CTOR(fn, prio) \ - l4ddekit_initcall_t \ - L4_STICKY(__l4ddekit_initcall_##fn) \ - __l4ddekit_initcall(prio) = (void *)fn - -/** - * Runs all registered initcalls. - */ -void ddekit_do_initcalls(void); - -#endif diff --git a/libddekit/include/ddekit/inline.h b/libddekit/include/ddekit/inline.h deleted file mode 100644 index e59a5c68..00000000 --- a/libddekit/include/ddekit/inline.h +++ /dev/null @@ -1,2 +0,0 @@ -#define INLINE __inline__ __attribute__((always_inline)) - diff --git a/libddekit/include/ddekit/interrupt.h b/libddekit/include/ddekit/interrupt.h deleted file mode 100644 index 3f789210..00000000 --- a/libddekit/include/ddekit/interrupt.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * \brief Hardware-interrupt subsystem - * \author Thomas Friebel - * \author Christian Helmuth - * \date 2007-01-26 - * - * DDEKit supports registration of one handler function per interrupt. If any - * specific DDE implementation needs to register more than one handler, - * multiplexing has to be implemented there! - */ - -#ifndef _ddekit_interrupt_h -#define _ddekit_interrupt_h - -#include "ddekit/thread.h" - -#define DDEKIT_IRQ_PRIO 2 - -/** - * Attach to hardware interrupt - * - * \param irq IRQ number to attach to - * \param shared set to 1 if interrupt sharing is supported; set to 0 - * otherwise - * \param thread_init called just after DDEKit internal init and before any - * other function - * \param handler IRQ handler for interrupt irq - * \param priv private token (argument for thread_init and handler) - * - * \return pointer to interrupt thread created - */ -ddekit_thread_t *ddekit_interrupt_attach(int irq, int shared, - void(*thread_init)(void *), - void(*handler)(void *), void *priv); - -/** - * Detach from a previously attached interrupt. - * - * \param irq IRQ number - */ -void ddekit_interrupt_detach(int irq); - -/** - * Block interrupt. - * - * \param irq IRQ number to block - */ -void ddekit_interrupt_disable(int irq); - -/** - * Enable interrupt. - * - * \param irq IRQ number to block - */ -void ddekit_interrupt_enable(int irq); - -#endif diff --git a/libddekit/include/ddekit/lock.h b/libddekit/include/ddekit/lock.h deleted file mode 100644 index dd398b38..00000000 --- a/libddekit/include/ddekit/lock.h +++ /dev/null @@ -1,83 +0,0 @@ -#ifndef _ddekit_lock_h -#define _ddekit_lock_h - -struct ddekit_lock; - -/** Initialize a DDEKit lock. - * - * \ingroup DDEKit_synchronization - */ -void _ddekit_lock_init (struct ddekit_lock **mtx); - -/** Uninitialize a DDEKit lock. - * - * \ingroup DDEKit_synchronization - */ -void _ddekit_lock_deinit (struct ddekit_lock **mtx); - -/** Acquire a lock. - * - * \ingroup DDEKit_synchronization - */ -void _ddekit_lock_lock (struct ddekit_lock **mtx); - -/** Acquire a lock, non-blocking. - * - * \ingroup DDEKit_synchronization - */ -int _ddekit_lock_try_lock(struct ddekit_lock **mtx); - -/** Unlock function. - * - * \ingroup DDEKit_synchronization - */ -void _ddekit_lock_unlock (struct ddekit_lock **mtx); - -/** Get lock owner. - * - * \ingroup DDEKit_synchronization - */ -int _ddekit_lock_owner(struct ddekit_lock **mtx); - -// definition of ddekit_lock_t -typedef struct ddekit_lock *ddekit_lock_t; - -// common prototypes -static void ddekit_lock_init_locked(ddekit_lock_t *mtx); -static void ddekit_lock_init_unlocked(ddekit_lock_t *mtx); -#define ddekit_lock_init ddekit_lock_init_unlocked -static void ddekit_lock_deinit (ddekit_lock_t *mtx); -static void ddekit_lock_lock (ddekit_lock_t *mtx); -static int ddekit_lock_try_lock(ddekit_lock_t *mtx); // returns 0 on success, != 0 if it would block -static void ddekit_lock_unlock (ddekit_lock_t *mtx); - -// inline implementation or inline call to non-inline implementation -#include "ddekit/inline.h" - -static INLINE void ddekit_lock_init_unlocked(ddekit_lock_t *mtx) { - _ddekit_lock_init(mtx); -} - -static INLINE void ddekit_lock_init_locked(ddekit_lock_t *mtx) { - _ddekit_lock_init(mtx); - _ddekit_lock_lock(mtx); -} - -static INLINE void ddekit_lock_deinit(ddekit_lock_t *mtx) { - _ddekit_lock_deinit(mtx); -} -static INLINE void ddekit_lock_lock(ddekit_lock_t *mtx) { - _ddekit_lock_lock(mtx); -} -static INLINE int ddekit_lock_try_lock(ddekit_lock_t *mtx) { - return _ddekit_lock_try_lock(mtx); -} -static INLINE void ddekit_lock_unlock(ddekit_lock_t *mtx) { - _ddekit_lock_unlock(mtx); -} - -static INLINE int ddekit_lock_owner(ddekit_lock_t *mtx) { - return _ddekit_lock_owner(mtx); -} - -#endif diff --git a/libddekit/include/ddekit/memory.h b/libddekit/include/ddekit/memory.h deleted file mode 100644 index 051a4d9e..00000000 --- a/libddekit/include/ddekit/memory.h +++ /dev/null @@ -1,144 +0,0 @@ -/* - * \brief Memory subsystem - * \author Thomas Friebel - * \author Christian Helmuth - * \date 2006-11-03 - */ - -#ifndef _ddekit_memory_h -#define _ddekit_memory_h - - -/******************* - ** Slab facility ** - *******************/ - -struct ddekit_slab; - -/** - * Store user pointer in slab cache - * - * \param slab pointer to slab cache - * \param data user pointer - */ -void ddekit_slab_set_data(struct ddekit_slab * slab, void *data); - -/** - * Read user pointer from slab cache - * - * \param slab pointer to slab cache - * - * \return stored user pointer or 0 - */ -void *ddekit_slab_get_data(struct ddekit_slab * slab); - -/** - * Allocate slab in slab cache - * - * \param slab pointer to slab cache - * - * \return pointer to allocated slab - */ -void *ddekit_slab_alloc(struct ddekit_slab * slab); - -/** - * Deallocate slab in slab cache - * - * \param slab pointer to slab cache - * \param objp pointer to allocated slab - */ -void ddekit_slab_free(struct ddekit_slab * slab, void *objp); - -/** - * Setup page cache for all slabs - * - * \param pages maximal number of memory pages - * - * If 'pages' is too low, memory pages may be given back to the memory server - * (dm_phys) and just to be allocated again later. This hits performance (but - * saves memory). Increase 'pages' to avoid this thrashing-like effect. - * - * If the maximal number of unused pages is exceeded, subsequent deallocation - * will be freed at the memory server. This page cache caches pages from all - * slabs. - */ -void ddekit_slab_setup_page_cache(unsigned pages); - -/** - * Destroy slab cache - * - * \param slab pointer to slab cache structure - */ -void ddekit_slab_destroy(struct ddekit_slab * slab); - -/** - * Initialize slab cache - * - * \param size size of cache objects - * \param contiguous make this slab use physically contiguous memory - * - * \return pointer to new slab cache or 0 on error - */ -struct ddekit_slab * ddekit_slab_init(unsigned size, int contiguous); - - -/********************** - ** Memory allocator ** - **********************/ - -/** - * Allocate large memory block - * - * \param size block size - * \return pointer to new memory block - * - * Allocations via this allocator may be slow (because memory servers are - * involved) and should be used only for large (i.e., > page size) blocks. If - * allocations/deallocations are relatively dynamic this may not be what you - * want. - * - * Allocated blocks have valid virt->phys mappings and are physically - * contiguous. - */ -void *ddekit_large_malloc(int size); - -/** - * Free large memory block - * - * \param p pointer to memory block - */ -void ddekit_large_free(void *p); - -/** FIXME - * contig_malloc() is the lowest-level allocator interface one could implement. - * we should consider to provide vmalloc() too. */ -void *ddekit_contig_malloc( - unsigned long size, - unsigned long low, unsigned long high, - unsigned long alignment, unsigned long boundary -); - - -/***************************** - ** Simple memory allocator ** - *****************************/ - -/** - * Allocate memory block via simple allocator - * - * \param size block size - * \return pointer to new memory block - * - * The blocks allocated via this allocator CANNOT be used for DMA or other - * device operations, i.e., there exists no virt->phys mapping. - */ -void *ddekit_simple_malloc(unsigned size); - -/** - * Free memory block via simple allocator - * - * \param p pointer to memory block - */ -void ddekit_simple_free(void *p); - -#endif diff --git a/libddekit/include/ddekit/panic.h b/libddekit/include/ddekit/panic.h deleted file mode 100644 index 1468675f..00000000 --- a/libddekit/include/ddekit/panic.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef _ddekit_panic_h -#define _ddekit_panic_h - -/** \defgroup DDEKit_util */ - -/** Panic - print error message and enter the kernel debugger. - * \ingroup DDEKit_util - */ -void ddekit_panic(char *fmt, ...) __attribute__((noreturn)); - -/** Print a debug message. - * \ingroup DDEKit_util - */ -void ddekit_debug(char *fmt, ...); - -#endif diff --git a/libddekit/include/ddekit/pci.h b/libddekit/include/ddekit/pci.h deleted file mode 100644 index 5a5fd29b..00000000 --- a/libddekit/include/ddekit/pci.h +++ /dev/null @@ -1,199 +0,0 @@ -#ifndef _ddekit_pci_h -#define _ddekit_pci_h - -#include "ddekit/types.h" - -/** \defgroup DDEKit_pci */ - -/** Our version of PCI_ANY_ID */ -#define DDEKIT_PCI_ANY_ID (~0) - -/** Copy of L4IO_PCIDEV_RES */ -#define DDEKIT_PCIDEV_RES 12 - -struct ddekit_pci_dev; - -/** PCI resource descriptor. Copied from generic_io. - * - * XXX! - */ -typedef struct ddekit_pci_resource { - unsigned long start; - unsigned long end; - unsigned long flags; -} ddekit_pci_res_t; - -void ddekit_pci_init(void); - -int ddekit_pci_get_device(int nr, int *bus, int *slot, int *func); - -int ddekit_pci_read(int bus, int slot, int func, int pos, int len, ddekit_uint32_t *val); -int ddekit_pci_write(int bus, int slot, int func, int pos, int len, ddekit_uint32_t val); - -/** Read byte from PCI config space. - * - * \ingroup DDEKit_pci - * - * \param bus bus ID - * \param slot slot # - * \param func function # - * \param pos offset in config space - * \retval val read value - * - * \return 0 success - */ -int ddekit_pci_readb (int bus, int slot, int func, int pos, ddekit_uint8_t *val); - -/** Read word from PCI config space. - * - * \ingroup DDEKit_pci - * - * \param bus bus ID - * \param slot slot # - * \param func function # - * \param pos offset in config space - * \retval val read value - * - * \return 0 success - */ -int ddekit_pci_readw (int bus, int slot, int func, int pos, ddekit_uint16_t *val); - -/** Read dword from PCI config space. - * - * \ingroup DDEKit_pci - * - * \param bus bus ID - * \param slot slot # - * \param func function # - * \param pos offset in config space - * \retval val read value - * - * \return 0 success - */ -int ddekit_pci_readl (int bus, int slot, int func, int pos, ddekit_uint32_t *val); - -/** Write byte to PCI config space. - * - * \ingroup DDEKit_pci - * - * \param bus bus ID - * \param slot slot # - * \param func function # - * \param pos offset in config space - * \retval val value to write - * - * \return 0 success - */ -int ddekit_pci_writeb(int bus, int slot, int func, int pos, ddekit_uint8_t val); - -/** Write word to PCI config space. - * - * \ingroup DDEKit_pci - * - * \param bus bus ID - * \param slot slot # - * \param func function # - * \param pos offset in config space - * \retval val value to write - * - * \return 0 success - */ -int ddekit_pci_writew(int bus, int slot, int func, int pos, ddekit_uint16_t val); - -/** Write word to PCI config space. - * - * \ingroup DDEKit_pci - * - * \param bus bus ID - * \param slot slot # - * \param func function # - * \param pos offset in config space - * \retval val value to write - * - * \return 0 success - */ -int ddekit_pci_writel(int bus, int slot, int func, int pos, ddekit_uint32_t val); - -/** Find a PCI device. - * - * \ingroup DDEKit_pci - * - * \param bus pointer to bus number or \ref DDEKIT_PCI_ANY_ID - * \param slot pointer to slot number (devfn >> DEVFN_SLOTSHIFT) or \ref DDEKIT_PCI_ANY_ID - * \param func pointer to func number (devfc & DEVFN_FUNCMASK) or \ref DDEKIT_PCI_ANY_ID - * \param start search device list only behind this device (excluding it!), NULL - * searches whole device list - * - * \retval bus bus number - * \retval slot slot number - * \retval func function number - * - * \return device a valid PCI device - * \return NULL if no device found - */ -struct ddekit_pci_dev * -ddekit_pci_find_device(int *bus, int *slot, int *func, struct ddekit_pci_dev *start); - -/** Enable PCI device - * \ingroup DDEKit_pci - */ -int ddekit_pci_enable_device(struct ddekit_pci_dev *dev); - -/** Disable PCI device - * \ingroup DDEKit_pci - */ -int ddekit_pci_disable_device(struct ddekit_pci_dev *dev); - -/** Enable bus-mastering for device. - * \ingroup DDEKit_pci - */ -void ddekit_pci_set_master(struct ddekit_pci_dev *dev); - -/** Get device vendor ID. - * \ingroup DDEKit_pci - */ -unsigned short ddekit_pci_get_vendor(struct ddekit_pci_dev *dev); - -/** Get device ID. - * \ingroup DDEKit_pci - */ -unsigned short ddekit_pci_get_device_id(struct ddekit_pci_dev *dev); - -/** Get device subvendor ID. - * \ingroup DDEKit_pci - */ -unsigned short ddekit_pci_get_sub_vendor(struct ddekit_pci_dev *dev); - -/** Get subdevice ID. - * \ingroup DDEKit_pci - */ -unsigned short ddekit_pci_get_sub_device(struct ddekit_pci_dev *dev); - -/** Get device class ID. - * \ingroup DDEKit_pci - */ -unsigned ddekit_pci_get_dev_class(struct ddekit_pci_dev *dev); - -/** Get device's IRQ number. - * \ingroup DDEKit_pci - */ -unsigned long ddekit_pci_get_irq(struct ddekit_pci_dev *dev); - -/** Get device name. - * \ingroup DDEKit_pci - */ -char *ddekit_pci_get_name(struct ddekit_pci_dev *dev); - -/** Get device's slot name. - * \ingroup DDEKit_pci - */ -char *ddekit_pci_get_slot_name(struct ddekit_pci_dev *dev); - -/** Get one of the device's resources. - * \ingroup DDEKit_pci - */ -ddekit_pci_res_t *ddekit_pci_get_resource(struct ddekit_pci_dev *dev, unsigned int idx); - -int ddekit_pci_irq_enable(int bus, int slot, int func, int pin, int *irq); - -#endif // _ddekit_pci_h diff --git a/libddekit/include/ddekit/pgtab.h b/libddekit/include/ddekit/pgtab.h deleted file mode 100644 index 8964b713..00000000 --- a/libddekit/include/ddekit/pgtab.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * \brief Virtual page-table facility - * \author Thomas Friebel - * \author Christian Helmuth - * \date 2006-11-03 - */ - -#ifndef _ddekit_pgtab_h -#define _ddekit_pgtab_h - -#include "ddekit/types.h" - -/* FIXME Region types may be defined by pgtab users. Do we really need them - * here? */ -enum ddekit_pgtab_type -{ - PTE_TYPE_OTHER, PTE_TYPE_LARGE, PTE_TYPE_UMA, PTE_TYPE_CONTIG -}; - - -/** - * Set virtual->physical mapping for VM region - * - * \param virt virtual start address for region - * \param phys physical start address for region - * \param pages number of pages in region - * \param type pgtab type for region - */ -void ddekit_pgtab_set_region(void *virt, ddekit_addr_t phys, int pages, int type); - - -/** - * Set virtual->physical mapping for VM region given a specific size in bytes. - * - * Internally, DDEKit manages regions with pages. However, DDEs do not need to tangle - * with the underlying mechanism and therefore can use this function that takes care - * of translating a size to an amount of pages. - */ -void ddekit_pgtab_set_region_with_size(void *virt, ddekit_addr_t phys, int size, int type); - - -/** - * Clear virtual->physical mapping for VM region - * - * \param virt virtual start address for region - * \param type pgtab type for region - */ -void ddekit_pgtab_clear_region(void *virt, int type); - -/** - * Get physical address for virtual address - * - * \param virt virtual address - * - * \return physical address - */ -ddekit_addr_t ddekit_pgtab_get_physaddr(const void *virt); - -/** - * Get virtual address for physical address - * - * \param physical physical address - * - * \return virtual address - */ -ddekit_addr_t ddekit_pgtab_get_virtaddr(const ddekit_addr_t physical); - -/** - * Get type of VM region. - * - * \param virt virtual address - - * \return VM region type - */ -int ddekit_pgtab_get_type(const void *virt); - -/** - * Get size of VM region. - * - * \param virt virtual address - * - * \return VM region size (in bytes) - */ -int ddekit_pgtab_get_size(const void *virt); - -#endif diff --git a/libddekit/include/ddekit/printf.h b/libddekit/include/ddekit/printf.h deleted file mode 100644 index 6dafa18d..00000000 --- a/libddekit/include/ddekit/printf.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef _ddekit_print_h -#define _ddekit_print_h - -#include - -/** Print message. - * \ingroup DDEKit_util - */ -int ddekit_print(const char *); - -/** Print message with format. - * \ingroup DDEKit_util - */ -int ddekit_printf(const char *fmt, ...); - -/** Print message with format list. - * \ingroup DDEKit_util - */ -int ddekit_vprintf(const char *fmt, va_list va); - -void dump_stack(void); - -/** Log function and message. - * \ingroup DDEKit_util - */ -#define ddekit_log(doit, msg...) \ - do { \ - if (doit) { \ - ddekit_printf("%s(): ", __func__); \ - ddekit_printf(msg); \ - ddekit_printf("\n"); \ - } \ - } while(0); - -#endif diff --git a/libddekit/include/ddekit/resources.h b/libddekit/include/ddekit/resources.h deleted file mode 100644 index 657295a0..00000000 --- a/libddekit/include/ddekit/resources.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef _ddekit_resources_h -#define _ddekit_resources_h - -#include "ddekit/types.h" - -int ddekit_request_dma(int nr); -int ddekit_release_dma(int nr); -int ddekit_request_io (ddekit_addr_t start, ddekit_addr_t count); -int ddekit_release_io (ddekit_addr_t start, ddekit_addr_t count); -int ddekit_request_mem(ddekit_addr_t start, ddekit_addr_t count, ddekit_addr_t *vaddr); -int ddekit_release_mem(ddekit_addr_t start, ddekit_addr_t count); -long ddekit_random (void); - -#endif diff --git a/libddekit/include/ddekit/semaphore.h b/libddekit/include/ddekit/semaphore.h deleted file mode 100644 index c959919d..00000000 --- a/libddekit/include/ddekit/semaphore.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef _ddekit_semaphore_h -#define _ddekit_semaphore_h - -/** \defgroup DDEKit_synchronization */ - -struct ddekit_sem; -typedef struct ddekit_sem ddekit_sem_t; - -/** Initialize DDEKit semaphore. - * - * \ingroup DDEKit_synchronization - * - * \param value initial semaphore counter - */ -ddekit_sem_t *ddekit_sem_init(int value); - -/** Uninitialize semaphore. - * - * \ingroup DDEKit_synchronization - */ -void ddekit_sem_deinit(ddekit_sem_t *sem); - -/** Semaphore down method. */ -void ddekit_sem_down(ddekit_sem_t *sem); - -/** Semaphore down method, non-blocking. - * - * \ingroup DDEKit_synchronization - * - * \return 0 success - * \return !=0 would block - */ -int ddekit_sem_down_try(ddekit_sem_t *sem); - -/** Semaphore down with timeout. - * - * \ingroup DDEKit_synchronization - * - * \return 0 success - * \return !=0 would block - */ -int ddekit_sem_down_timed(ddekit_sem_t *sem, int timo); - -/** Semaphore up method. - * - * \ingroup DDEKit_synchronization - */ -void ddekit_sem_up(ddekit_sem_t *sem); - -#endif diff --git a/libddekit/include/ddekit/thread.h b/libddekit/include/ddekit/thread.h deleted file mode 100644 index 8ed52013..00000000 --- a/libddekit/include/ddekit/thread.h +++ /dev/null @@ -1,145 +0,0 @@ -#ifndef _ddekit_thread_h -#define _ddekit_thread_h - -/** \defgroup DDEKit_threads */ - -#include "ddekit/lock.h" - -struct ddekit_thread; -typedef struct ddekit_thread ddekit_thread_t; - -/** Create thread - * - * \ingroup DDEKit_threads - * - * Create a new thread running the specified thread function with the specified - * arguments. The thread is assigned the given internal name. - * - * Additionally, DDEKit threads possess a thread-local storage area where they - * may store arbitrary data. - * - * \param fun thread function - * \param arg optional argument to thread function, set to NULL if not needed - * \param name internal thread name - */ -ddekit_thread_t *ddekit_thread_create(void (*fun)(void *), void *arg, const char *name); - -/** Reference to own DDEKit thread id. - * - * \ingroup DDEKit_threads - */ -ddekit_thread_t *ddekit_thread_myself(void); - -/** Initialize thread with given name. - * - * \ingroup DDEKit_threads - * - * This function may be used by threads that were not created using - * \ref ddekit_thread_create. This enables such threads to be handled as if they - * were DDEKit threads. - */ -ddekit_thread_t *ddekit_thread_setup_myself(const char *name); - -/** Get TLS data for a specific thread. - * - * \ingroup DDEKit_threads - * - * \return Pointer to TLS data of this thread. - */ -void *ddekit_thread_get_data(ddekit_thread_t *thread); - -/** Get TLS data for current thread. - * - * \ingroup DDEKit_threads - * - * Same as calling \ref ddekit_thread_get_data with \ref ddekit_thread_myself - * as parameter. - * - * \return Pointer to TLS data of current thread. - */ -void *ddekit_thread_get_my_data(void); - -/** Set TLS data for specific thread. - * - * \ingroup DDEKit_threads - * - * \param thread DDEKit thread - * \param data pointer to thread data - */ -void ddekit_thread_set_data(ddekit_thread_t *thread, void *data); - -/** Set TLS data for current thread. - * - * \ingroup DDEKit_threads - * - * \param data pointer to thread data - */ -void ddekit_thread_set_my_data(void *data); - -/** Sleep for some miliseconds. - * - * \ingroup DDEKit_threads - * - * \param msecs time to sleep in ms. - */ -void ddekit_thread_msleep(unsigned long msecs); - -/** Sleep for some microseconds. - * - * \ingroup DDEKit_threads - * - * \param usecs time to sleep in µs. - */ -void ddekit_thread_usleep(unsigned long usecs); - -/** Sleep for some nanoseconds. - * - * \ingroup DDEKit_threads - * - * \param usecs time to sleep in ns. - */ -void ddekit_thread_nsleep(unsigned long nsecs); - -/** Sleep until a lock becomes unlocked. - * - * \ingroup DDEKit_threads - */ -void ddekit_thread_sleep(ddekit_lock_t *lock); - -/** Wakeup a waiting thread. - * - * \ingroup DDEKit_threads - */ -void ddekit_thread_wakeup(ddekit_thread_t *thread); - -/** Terminate a thread - * - * \ingroup DDEKit_threads - */ -void ddekit_thread_exit(void) __attribute__((noreturn)); - -/** Get the name, a thread registered with DDEKit. - * - * \ingroup DDEKit_threads - */ -const char *ddekit_thread_get_name(ddekit_thread_t *thread); - -/** Hint that this thread is done and may be scheduled somehow. - * - * \ingroup DDEKit_threads - */ -void ddekit_thread_schedule(void); - -/** Hint that this thread is done and may be scheduled somehow. - * - * \ingroup DDEKit_threads - */ -void ddekit_yield(void); - -/** Initialize DDEKit thread subsystem. - * - * \ingroup DDEKit_threads - */ -void ddekit_init_threads(void); - -#endif diff --git a/libddekit/include/ddekit/timer.h b/libddekit/include/ddekit/timer.h deleted file mode 100644 index 387f2078..00000000 --- a/libddekit/include/ddekit/timer.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef _ddekit_timer_h -#define _ddekit_timer_h - -#include "ddekit/thread.h" - -#define jiffies (fetch_jiffies()) -#define HZ 100 - -enum -{ - DDEKIT_INVALID_TIMER_ID = -1, -}; - -/** \defgroup DDEKit_timer - * - * Timer subsystem - * - * DDEKit provides a generic timer implementation that enables users - * to execute a function with some arguments after a certain period - * of time. DDEKit therefore starts a timer thread that executes these - * functions and keeps track of the currently running timers. - */ - -/** Add a timer event. After the absolute timeout has expired, function fn - * is called with args as arguments. - * - * \ingroup DDEKit_timer - * - * \return >=0 valid timer ID - * \return < 0 error - */ -int ddekit_add_timer(void (*fn)(void *), void *args, unsigned long timeout); - -/** Delete timer with the corresponding timer id. - * - * \ingroup DDEKit_timer - */ -int ddekit_del_timer(int timer); - -/** Check whether a timer is pending - * - * \ingroup DDEKit_timer - * - * Linux needs this. - */ -int ddekit_timer_pending(int timer); - -/** Initialization function, startup timer thread - * - * \ingroup DDEKit_timer - */ -void ddekit_init_timers(void); - -/** Get the timer thread. - */ -ddekit_thread_t *ddekit_get_timer_thread(void); -extern unsigned long fetch_jiffies (void); - -#endif diff --git a/libddekit/include/ddekit/types.h b/libddekit/include/ddekit/types.h deleted file mode 100644 index 83d92c65..00000000 --- a/libddekit/include/ddekit/types.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * \brief Types for ddekit (x86 version) - * \author Thomas Friebel - * \author Christian Helmuth - * \date 2006-11-09 - * - * FIXME This is definitely arch-dependent! Move to ARCH-something - */ - -#ifndef _DDEKIT_TYPES_H -#define _DDEKIT_TYPES_H - -typedef signed char ddekit_int8_t; -typedef unsigned char ddekit_uint8_t; -typedef signed short int ddekit_int16_t; -typedef unsigned short int ddekit_uint16_t; -typedef signed int ddekit_int32_t; -typedef unsigned int ddekit_uint32_t; - -typedef unsigned long ddekit_addr_t; - -#endif diff --git a/libddekit/memory.c b/libddekit/memory.c index b4723b96..34b283b3 100644 --- a/libddekit/memory.c +++ b/libddekit/memory.c @@ -18,7 +18,7 @@ #include #include "mach_U.h" -#include "libhurd-slab/slab.h" +#include #include "util.h" #include "ddekit/memory.h" diff --git a/libhurd-slab/Makefile b/libhurd-slab/Makefile index 4682a934..f109f59b 100644 --- a/libhurd-slab/Makefile +++ b/libhurd-slab/Makefile @@ -21,7 +21,7 @@ makemode := library libname = libhurd-slab SRCS= slab.c LCLHDRS = slab.h -installhdrs = +installhdrs = slab.h MIGSTUBS = OBJS = $(sort $(SRCS:.c=.o) $(MIGSTUBS)) diff --git a/libmachdev/Makefile b/libmachdev/Makefile index 15bc9730..ad090cae 100644 --- a/libmachdev/Makefile +++ b/libmachdev/Makefile @@ -25,13 +25,11 @@ LCLHDRS = dev_hdr.h device_emul.h ds_routines.h vm_param.h \ util.h queue.h io_req.h if_ether.h machdev.h linux-errno.h \ errno-base.h installhdrs = machdev.h -HURDLIBS = ports threads trivfs +HURDLIBS = ports threads trivfs ddekit bpf OBJS = $(SRCS:.c=.o) $(MIGSTUBS) include ../Makeconf -CFLAGS += -I$(top_srcdir)/libddekit/include -I$(top_srcdir)/libbpf - ourdevice.defs: device.defs $(CPP) $(CPPFLAGS) -x c $< | sed -e '/out[ ]*device[ ]*:[ ]*device_t/s/device_t/mach_port_send_t/' > $@ diff --git a/libmachdev/if_hdr.h b/libmachdev/if_hdr.h index 74d0fa8a..32497206 100644 --- a/libmachdev/if_hdr.h +++ b/libmachdev/if_hdr.h @@ -62,7 +62,7 @@ #include #include -#include +#include #if 0 /* -- cgit v1.2.3