New DDE-Linux-based USB driver

The new 'dde_linux' repository will host device drivers ported from the
Linux kernel. In contrast to the original 'linux_drivers' repository,
'dde_linux' does not contain any 3rd-party source code. To download the
Linux kernel source code and extract the drivers, execute the 'make
prepare' rule of the top-level Makefile. The initial version of the
'dde_linux' repository comes with an USB driver. The porting methodology
follows the path of the Intel GEM port. Instead of attempting to provide
a generic Linux environment that works across drivers, each driver comes
with a specially tailored DDE.

The DDE consists of Genode-specific implementations of Linux API
functions as declared in 'lx_emul.h'. Most of these functions are
dummies that must merely be provided to resolve dependencies at the
linking stage. They are called by unused code-paths.

As of now, the USB driver support UHCI, EHCI on the x86_32 platform. I
exposes USB HID devices and USB storage devices via Genode's input-session
and block-session respectively.

The USB driver is accompanied with two run scripts 'run/usb_hid.run' and
'run/usb_storage.run'.
devel
Sebastian Sumpf 11 years ago committed by Christian Helmuth
parent 9471490d01
commit 9f73476b37

2
.gitignore vendored

@ -13,6 +13,8 @@
/base-okl4/download
/base-pistachio/contrib
/dde_ipxe/contrib
/dde_linux/contrib
/dde_linux/download
/libports/contrib
/libports/download
/libports/include/EGL/egl.h

@ -127,10 +127,17 @@ The Genode source tree is composed of the following subdirectories:
For instructions about how to use this mechanism, please consult the README
file at the top level of the repository.
:'linux_drivers':
:'dde_linux':
This source-code repository contains the device driver environment for
executing Linux device drivers natively on Genode.
executing Linux device drivers natively on Genode. Currently, this
repository hosts the USB stack.
:'linux_drivers':
Deprecated version of the Linux device driver environment featuring audio
drivers and the Intel GEM driver. This repository is in a transitionary
phase. Its functionality will be incorporated into 'dde_linux'.
:'dde_ipxe':

@ -0,0 +1,98 @@
#
# \brief Download integrate Linux kernel sources with Genode
# \author Norman Feske
# \date 2012-01-28
CONTRIB_DIR = contrib
DOWNLOAD_DIR = download
VERBOSE ?= @
ECHO = @echo
PATCHES = $(shell find patches -name *.patch)
LINUX = linux-3.2.2
LINUX_TBZ2 = $(LINUX).tar.bz2
LINUX_URL = http://www.kernel.org/pub/linux/kernel/v3.x/$(LINUX_TBZ2)
# Linux utilities
CONTENT += include/linux/list.h
CONTENT += $(addprefix include/linux/,pci_ids.h pci_regs.h usb.h hid.h hiddev.h input.h mod_devicetable.h)
CONTENT += $(addprefix include/linux/byteorder/,generic.h little_endian.h)
CONTENT += include/linux/swab.h
CONTENT += $(addprefix include/asm-generic/bitops/,__ffs.h non-atomic.h)
# USB core
CONTENT += drivers/usb/core
CONTENT += drivers/usb/usb-common.c
CONTENT_INCLUDE_USB := ch11.h ch9.h ehci_def.h hcd.h input.h otg.h quirks.h storage.h
CONTENT += $(addprefix include/linux/usb/,$(CONTENT_INCLUDE_USB))
# needed by usb/core/devio.c
CONTENT += include/linux/usbdevice_fs.h include/asm-generic/ioctl.h
# USB host-controller driver
CONTENT_USB_HOST := ehci.h ehci-hcd.c ehci-hub.c ehci-dbg.c ehci-mem.c \
ehci-q.c ehci-pci.c ehci-sched.c ehci-sysfs.c
CONTENT_USB_HOST += ohci.h ohci-hcd.c ohci-hub.c ohci-dbg.c ohci-mem.c \
ohci-q.c ohci-pci.c ehci-lpm.c
CONTENT_USB_HOST += uhci-hcd.h uhci-hcd.c uhci-debug.c uhci-q.c uhci-hub.c \
uhci-pci.c
CONTENT_USB_HOST += pci-quirks.h pci-quirks.c xhci-ext-caps.h
CONTENT += $(addprefix drivers/usb/host/,$(CONTENT_USB_HOST))
# USB storage driver
CONTENT += drivers/usb/storage/
CONTENT += include/linux/usb_usual.h
# SCSI support for storage
CONTENT += $(addprefix drivers/scsi/,scsi.h scsi.c constants.c scsi_priv.h scsi_logging.h)
CONTENT += $(addprefix include/scsi/,scsi.h scsi_host.h)
# USB hid driver
CONTENT += drivers/hid/hid-input.c drivers/hid/hid-core.c drivers/hid/hid-ids.h
CONTENT += drivers/hid/usbhid
# needed by USB hid
CONTENT_INPUT := input.c evdev.c input-compat.h
CONTENT += $(addprefix drivers/input/,$(CONTENT_INPUT))
CONTENT += include/linux/input/mt.h
CONTRIB_CONTENT := $(addprefix $(CONTRIB_DIR)/,$(CONTENT))
#
# Print help information by default
#
help:
$(ECHO)
$(ECHO) "Download integrate Linux kernel sources with Genode"
$(ECHO)
$(ECHO) "--- available commands ---"
$(ECHO) "prepare - download and integrate Linux source code"
$(ECHO) "clean - remove contib sources except downloaded archives"
$(ECHO) "cleanall - remove contib sources and downloaded archives"
$(ECHO)
prepare: $(CONTRIB_DIR)/.prepared
$(CONTRIB_DIR)/.prepared: Makefile
$(CONTRIB_DIR)/.prepared: $(DOWNLOAD_DIR)/$(LINUX_TBZ2)
$(ECHO) "extracting source code to '$(CONTRIB_DIR)'"
$(VERBOSE)tar xfj $< --transform "s/$(LINUX)/$(CONTRIB_DIR)/" $(addprefix $(LINUX)/,$(CONTENT))
$(VERBOSE)touch $@
$(ECHO) "applying patches to '$(CONTRIB_DIR)/'"
$(VERBOSE)for i in $(PATCHES); do patch -d $(CONTRIB_DIR) -p1 < $$i; done
$(DOWNLOAD_DIR):
$(VERBOSE)mkdir -p $@
$(DOWNLOAD_DIR)/$(LINUX_TBZ2): $(DOWNLOAD_DIR)
$(ECHO) "downloading source code to '$@'"
$(VERBOSE)cd $(DOWNLOAD_DIR); wget -c $(LINUX_URL)
$(VERBOSE)touch $@
clean:
$(VERBOSE)rm -f $(CONTRIB_DIR)
cleanall: clean
$(VERBOSE)rm -rf $(DOWNLOAD_DIR)

@ -0,0 +1,37 @@
Device drivers ported from the Linux kernel
USB
###
HID
~~~
Supports keyboard and mouse. A run script can be found under 'run/usb_hid.run'.
Configuration snippet:
!<start name="usb_drv">
! <resource name="RAM" quantum="3M"/>
! <provides><service name="Input"/></provides>
! <config>
! <hid/>
! </config>
!</start>
Note: It has been observed that certain 1.0 versions of Qemu do not generate
mouse interrupts. The mouse driver should work correctly on Qemu 1.0.93 and
above.
STORAGE
~~~~~~~
Currently supports one USB storage device. Hot plugging has not been tested. A
run script can be found under 'run/usb_storage.run'.
Configuration snippet:
!<start name="usb_drv">
! <resource name="RAM" quantum="2M"/>
! <provides> <service name="Block"/> </provides>
! <config><storage /></config>
!</start>

@ -0,0 +1,22 @@
diff -r 1d04c9c5fa8a drivers/input/evdev.c
--- a/drivers/input/evdev.c Tue Apr 17 16:14:54 2012 +0200
+++ b/drivers/input/evdev.c Wed Apr 18 11:25:37 2012 +0200
@@ -957,6 +957,9 @@
if (error)
goto err_cleanup_evdev;
+ evdev_open_device(evdev);
+ dev_info(evdev, "%s\n", dev->name);
+
return 0;
err_cleanup_evdev:
@@ -986,7 +989,7 @@
MODULE_DEVICE_TABLE(input, evdev_ids);
static struct input_handler evdev_handler = {
- .event = evdev_event,
+ .event = genode_evdev_event,
.connect = evdev_connect,
.disconnect = evdev_disconnect,
.fops = &evdev_fops,

@ -0,0 +1,75 @@
#
# Build
#
set build_components {
core init
drivers/timer
drivers/pci
drivers/usb
test/input
}
build $build_components
create_boot_directory
#
# Generate config
#
append config {
<config>
<parent-provides>
<service name="ROM"/>
<service name="RAM"/>
<service name="IRQ"/>
<service name="IO_MEM"/>
<service name="IO_PORT"/>
<service name="CAP"/>
<service name="PD"/>
<service name="RM"/>
<service name="CPU"/>
<service name="LOG"/>
<service name="SIGNAL" />
</parent-provides>
<default-route>
<any-service> <parent/> <any-child/> </any-service>
</default-route>
<start name="pci_drv">
<resource name="RAM" quantum="1M"/>
<provides><service name="PCI"/></provides>
</start>
<start name="timer">
<resource name="RAM" quantum="1M"/>
<provides><service name="Timer"/></provides>
</start>
<start name="usb_drv">
<resource name="RAM" quantum="3M"/>
<provides><service name="Input"/></provides>
<config>
<hid/>
</config>
</start>
<start name="test-input">
<resource name="RAM" quantum="1M"/>
</start>
</config>}
install_config $config
#
# Boot modules
#
# generic modules
set boot_modules {
core init timer pci_drv usb_drv test-input
}
build_boot_image $boot_modules
append qemu_args " -m 256 -usb -usbdevice mouse -usbdevice keyboard"
run_genode_until forever

@ -0,0 +1,107 @@
#
# \brief Test for using the Block (Storage) service of usb_drv
# \author Christian Prochaska
# \date 2011-06-24
#
#
# Build
#
build {
core init
drivers/pci
drivers/timer
drivers/usb
test/ahci
}
create_boot_directory
#
# Generate config
#
set config {
<config verbose="yes">
<parent-provides>
<service name="ROM"/>
<service name="RAM"/>
<service name="IRQ"/>
<service name="IO_MEM"/>
<service name="IO_PORT"/>
<service name="CAP"/>
<service name="PD"/>
<service name="RM"/>
<service name="CPU"/>
<service name="LOG"/>
<service name="SIGNAL"/>
</parent-provides>
<default-route>
<any-service> <parent/> <any-child/> </any-service>
</default-route>
<start name="timer">
<resource name="RAM" quantum="512K"/>
<provides> <service name="Timer"/> </provides>
</start>
<start name="usb_drv">
<resource name="RAM" quantum="3M"/>
<provides> <service name="Block"/> </provides>
<config><storage /></config>
</start>
<start name="pci_drv">
<resource name="RAM" quantum="512K"/>
<provides> <service name="PCI"/> </provides>
</start>
<start name="test-usb">
<resource name="RAM" quantum="1M" />
<binary name="test-ahci" />
</start>
</config>
}
install_config $config
#
# Boot modules
#
# generic modules
set boot_modules {
core init timer usb_drv pci_drv test-ahci
}
build_boot_image $boot_modules
#
# Execute test case
#
set disk_image "bin/test.img"
set cmd "dd if=/dev/zero of=$disk_image bs=1024 count=65536"
puts "creating disk image:\n$cmd"
catch { exec sh -c $cmd }
set cmd "mkfs.vfat -F32 $disk_image"
puts "formating disk image with vfat file system:\$cmd"
catch { exec sh -c $cmd }
#
# Qemu opts for UHCI
#
#append qemu_args " -m 64 -nographic -usbdevice disk::$disk_image -boot order=d"
#
# Qemu opts for EHCI
#
append qemu_args "-drive if=none,id=disk,file=$disk_image"
append qemu_args { \
-m 64 -nographic -M pc \
-device usb-ehci,id=ehci \
-device usb-storage,bus=ehci.0,drive=disk \
-boot order=d }
run_genode_until {.*child exited with exit value 0.*} 40
puts "\ntest succeeded\n"
# vi: set ft=tcl :

@ -0,0 +1,782 @@
/*
* \brief Dummy functions
* \author Norman Feske
* \author Sebastian sumpf
* \date 2011-01-29
*/
/*
* Copyright (C) 2011-2012 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2.
*/
/* Linux kernel API */
#include <lx_emul.h>
/* DDE-Kit includes */
#include <dde_kit/printf.h>
/* Linux includes */
#include <linux/input.h>
#define SKIP_VERBOSE 0
#if VERBOSE_LX_EMUL
#define TRACE dde_kit_printf("\033[32m%s\033[0m called, not implemented\n", __PRETTY_FUNCTION__)
#else
#define TRACE
#endif
#if SKIP_VERBOSE
#define SKIP dde_kit_printf("\033[34m%s\033[0m: skipped\n", __PRETTY_FUNCTION__)
#else
#define SKIP
#endif
/******************
** asm/atomic.h **
******************/
int atomic_inc_return(atomic_t *v) { TRACE; return 0; }
/*******************************
** linux/byteorder/generic.h **
*******************************/
u16 get_unaligned_le16(const void *p) { TRACE; return 0; }
u32 get_unaligned_le32(const void *p) { TRACE; return 0; }
/*******************************
** linux/errno.h and friends **
*******************************/
long PTR_ERR(const void *ptr) { TRACE; return 0; }
/********************
** linux/kernel.h **
********************/
void might_sleep() { SKIP; }
char *kasprintf(gfp_t gfp, const char *fmt, ...) { TRACE; return NULL; }
int kstrtouint(const char *s, unsigned int base, unsigned int *res) { TRACE; return 0; }
int sprintf(char *buf, const char *fmt, ...) { TRACE; return 0; }
int sscanf(const char *b, const char *s, ...) { TRACE; return 0; }
int scnprintf(char *buf, size_t size, const char *fmt, ...) { TRACE; return 0; }
int strict_strtoul(const char *s, unsigned int base, unsigned long *res) { TRACE; return 0; }
long simple_strtoul(const char *cp, char **endp, unsigned int base) { TRACE; return 0; }
/******************
** linux/log2.h **
******************/
int roundup_pow_of_two(u32 n) { TRACE; return 0; }
/********************
** linux/printk.h **
********************/
void print_hex_dump(const char *level, const char *prefix_str,
int prefix_type, int rowsize, int groupsize,
const void *buf, size_t len, bool ascii) { TRACE; }
/**********************************
** linux/bitops.h, asm/bitops.h **
**********************************/
int ffs(int x) { TRACE; return 0; }
/********************
** linux/string.h **
********************/
int memcmp(const void *dst, const void *src, size_t s) { TRACE; return 0; }
char *strcat(char *dest, const char *src) { TRACE; return 0; }
int strcmp(const char *s1, const char *s2) { TRACE; return 0; }
int strncmp(const char *cs, const char *ct, size_t count) { TRACE; return 0; }
char *strncpy(char *dst, const char *src, size_t s) { TRACE; return NULL; }
char *strchr(const char *s, int n) { TRACE; return NULL; }
char *strrchr(const char *s, int n) { TRACE; return NULL; }
size_t strlcpy(char *dest, const char *src, size_t size) { TRACE; return 0; }
char *strsep(char **s,const char *d) { TRACE; return NULL; }
char *kstrdup(const char *s, gfp_t gfp) { TRACE; return 0; }
char *strstr(const char *h, const char *n) { TRACE; return 0; }
/*****************
** linux/nls.h **
*****************/
int utf16s_to_utf8s(const wchar_t *pwcs, int len,
enum utf16_endian endian, u8 *s, int maxlen) { TRACE; return 0; }
/*******************
** linux/ctype.h **
*******************/
int isprint(int v) { TRACE; return 0; }
/**********************
** linux/spinlock.h **
**********************/
void spin_lock(spinlock_t *lock) { SKIP; }
void spin_lock_nested(spinlock_t *lock, int subclass) { TRACE; }
void spin_unlock(spinlock_t *lock) { SKIP; }
void spin_lock_init(spinlock_t *lock) { SKIP; }
void spin_lock_irqsave(spinlock_t *lock, unsigned long flags) { SKIP; }
void spin_lock_irqrestore(spinlock_t *lock, unsigned long flags) { SKIP; }
void spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags) { SKIP; }
void spin_lock_irq(spinlock_t *lock) { SKIP; }
void spin_unlock_irq(spinlock_t *lock) { SKIP; }
void assert_spin_locked(spinlock_t *lock) { TRACE;}
/*******************
** linux/mutex.h **
*******************/
void mutex_lock_nested(struct mutex *lock, unsigned int subclass) { TRACE; }
int mutex_lock_interruptible(struct mutex *m) { TRACE; return 0; }
/*******************
** linux/rwsem.h **
*******************/
void down_read(struct rw_semaphore *sem) { TRACE; }
void up_read(struct rw_semaphore *sem) { TRACE; }
void down_write(struct rw_semaphore *sem) { TRACE; }
void up_write(struct rw_semaphore *sem) { TRACE; }
/*******************
** linux/ktime.h **
*******************/
ktime_t ktime_add_ns(const ktime_t kt, u64 nsec) { TRACE; ktime_t ret = { 0 }; return ret; }
s64 ktime_us_delta(const ktime_t later, const ktime_t earlier) { TRACE; return 0; };
/*******************
** linux/timer.h **
*******************/
int del_timer_sync(struct timer_list *timer) { TRACE; return 0; }
unsigned long round_jiffies(unsigned long j) { TRACE; return 1; }
/*********************
** linux/hrtimer.h **
*********************/
ktime_t ktime_get_real(void) { TRACE; ktime_t ret; return ret; }
/*******************
** linux/delay.h **
*******************/
void mdelay(unsigned long msecs) { TRACE; }
/***********************
** linux/workquque.h **
***********************/
bool cancel_work_sync(struct work_struct *work) { TRACE; return 0; }
int cancel_delayed_work_sync(struct delayed_work *work) { TRACE; return 0; }
int schedule_work(struct work_struct *work) { TRACE; return 0; }
bool flush_work_sync(struct work_struct *work) { TRACE; return 0; }
/******************
** linux/wait.h **
******************/
void init_waitqueue_head(wait_queue_head_t *q) { TRACE; }
void add_wait_queue(wait_queue_head_t *q, wait_queue_t *wait) { TRACE; }
void remove_wait_queue(wait_queue_head_t *q, wait_queue_t *wait) { TRACE; }
/******************
** linux/time.h **
******************/
struct timespec current_kernel_time(void)
{
struct timespec t = { 0, 0 };
return t;
}
void do_gettimeofday(struct timeval *tv) { TRACE; }
/*******************
** linux/sched.h **
*******************/
int kill_pid_info_as_cred(int i, struct siginfo *s, struct pid *p,
const struct cred *c, u32 v) { TRACE; return 0; }
pid_t task_pid_nr(struct task_struct *tsk) { TRACE; return 0; }
struct pid *task_pid(struct task_struct *task) { TRACE; return NULL; }
void __set_current_state(int state) { TRACE; }
int signal_pending(struct task_struct *p) { TRACE; return 0; }
void schedule(void) { TRACE; }
void yield(void) { TRACE; }
void cpu_relax(void) { TRACE; }
struct task_struct *current;
/*********************
** linux/kthread.h **
*********************/
int kthread_should_stop(void) { SKIP; return 0; }
int kthread_stop(struct task_struct *k) { TRACE; return 0; }
/**********************
** linux/notifier.h **
**********************/
int blocking_notifier_chain_register(struct blocking_notifier_head *nh,
struct notifier_block *nb) { TRACE; return 0; }
int blocking_notifier_chain_unregister(struct blocking_notifier_head *nh,
struct notifier_block *nb) { TRACE; return 0; }
int blocking_notifier_call_chain(struct blocking_notifier_head *nh,
unsigned long val, void *v) { TRACE; return 0; }
int atomic_notifier_chain_register(struct atomic_notifier_head *nh,
struct notifier_block *nb) { TRACE; return 0; }
int atomic_notifier_chain_unregister(struct atomic_notifier_head *nh,
struct notifier_block *nb) { TRACE; return 0; }
/*********************
** linux/kobject.h **
*********************/
int add_uevent_var(struct kobj_uevent_env *env, const char *format, ...) { TRACE; return 0; }
char *kobject_name(const struct kobject *kobj) { TRACE; return 0; }
char *kobject_get_path(struct kobject *kobj, gfp_t gfp_mask) { TRACE; return 0; }
/*******************
** linux/sysfs.h **
*******************/
int sysfs_create_group(struct kobject *kobj,
const struct attribute_group *grp) { TRACE; return 0; }
void sysfs_remove_group(struct kobject *kobj,
const struct attribute_group *grp) { TRACE; }
int fasync_helper(int fd, struct file * filp, int on, struct fasync_struct **fapp) { TRACE; return 0; }
ssize_t simple_read_from_buffer(void __user *to, size_t count,
loff_t *ppos, const void *from, size_t available) { TRACE; return 0; }
/************************
** linux/pm_runtime.h **
************************/
int pm_runtime_set_active(struct device *dev) { TRACE; return 0; }
void pm_suspend_ignore_children(struct device *dev, bool enable) { TRACE; }
void pm_runtime_enable(struct device *dev) { TRACE; }
void pm_runtime_disable(struct device *dev) { TRACE; }
void pm_runtime_set_suspended(struct device *dev) { TRACE; }
void pm_runtime_get_noresume(struct device *dev) { TRACE; }
void pm_runtime_put_noidle(struct device *dev) { TRACE; }
void pm_runtime_use_autosuspend(struct device *dev) { TRACE; }
int pm_runtime_put_sync_autosuspend(struct device *dev) { TRACE; return 0; }
void pm_runtime_no_callbacks(struct device *dev) { TRACE; }
/***********************
** linux/pm_wakeup.h **
***********************/
int device_init_wakeup(struct device *dev, bool val) { TRACE; return 0; }
int device_wakeup_enable(struct device *dev) { TRACE; return 0; }
bool device_may_wakeup(struct device *dev) { TRACE; return 0; }
int device_set_wakeup_enable(struct device *dev, bool enable) { TRACE; return 0; }
bool device_can_wakeup(struct device *dev) { TRACE; return 0; }
/********************
** linux/device.h **
********************/
int dev_set_name(struct device *dev, const char *name, ...) { TRACE; return 0; }
const char *dev_name(const struct device *dev) { TRACE; return NULL; }
int dev_to_node(struct device *dev) { TRACE; return 0; }
void set_dev_node(struct device *dev, int node) { TRACE; }
struct device *device_create(struct class *cls, struct device *parent,
dev_t devt, void *drvdata,
const char *fmt, ...) { TRACE; return NULL; }
void device_destroy(struct class *cls, dev_t devt) { TRACE; }
void device_unregister(struct device *dev) { TRACE; }
void device_lock(struct device *dev) { TRACE; }
int device_trylock(struct device *dev) { TRACE; return 0; }
void device_unlock(struct device *dev) { TRACE; }
void device_del(struct device *dev) { TRACE; }
void device_initialize(struct device *dev) { TRACE; }
int device_attach(struct device *dev) { TRACE; return 0; }
int device_is_registered(struct device *dev) { TRACE; return 0; }
int device_bind_driver(struct device *dev) { TRACE; return 0; }
void device_release_driver(struct device *dev) { TRACE; }
void device_enable_async_suspend(struct device *dev) { TRACE; }
void device_set_wakeup_capable(struct device *dev, bool capable) { TRACE; }
int device_create_bin_file(struct device *dev,
const struct bin_attribute *attr) { TRACE; return 0; }
void device_remove_bin_file(struct device *dev,
const struct bin_attribute *attr) { TRACE; }
int device_create_file(struct device *device,
const struct device_attribute *entry) { TRACE; return 0; }
void device_remove_file(struct device *dev,
const struct device_attribute *attr) { TRACE; }
void put_device(struct device *dev) { TRACE; }
void driver_unregister(struct device_driver *drv) { TRACE; }
int driver_attach(struct device_driver *drv) { TRACE; return 0; }
int driver_create_file(struct device_driver *driver,
const struct driver_attribute *attr) { TRACE; return 0; }
void driver_remove_file(struct device_driver *driver,
const struct driver_attribute *attr) { TRACE; }
struct device_driver *get_driver(struct device_driver *drv) { TRACE; return NULL; }
void put_driver(struct device_driver *drv) { TRACE; }
struct device *bus_find_device(struct bus_type *bus, struct device *start,
void *data,
int (*match)(struct device *dev, void *data)) { TRACE; return NULL; }
int bus_register(struct bus_type *bus) { TRACE; return 0; }
void bus_unregister(struct bus_type *bus) { TRACE; }
int bus_register_notifier(struct bus_type *bus,
struct notifier_block *nb) { TRACE; return 0; }
int bus_unregister_notifier(struct bus_type *bus,
struct notifier_block *nb) { TRACE; return 0; }
struct class *__class_create(struct module *owner,
const char *name,
struct lock_class_key *key) { TRACE; return NULL; }
int class_register(struct class *cls) { TRACE; return 0; }
void class_unregister(struct class *cls) { TRACE; }
void class_destroy(struct class *cls) { TRACE; }
/*****************************
** linux/platform_device.h **
*****************************/
void *platform_get_drvdata(const struct platform_device *pdev) { TRACE; return NULL; }
/********************
** linux/dcache.h **
********************/
void d_instantiate(struct dentry *dentry, struct inode *i) { TRACE; }
int d_unhashed(struct dentry *dentry) { TRACE; return 0; }
void d_delete(struct dentry *d) { TRACE; }
struct dentry *d_alloc_root(struct inode *i) { TRACE; return NULL; }
struct dentry *dget(struct dentry *dentry) { TRACE; return NULL; }
void dput(struct dentry *dentry) { TRACE; }
void dont_mount(struct dentry *dentry) { TRACE; }
/******************
** linux/poll.h **
******************/
void poll_wait(struct file *f, wait_queue_head_t *w, poll_table *p) { TRACE; }
/********************
** linux/statfs.h **
********************/
loff_t default_llseek(struct file *file, loff_t offset, int origin) { TRACE; return 0; }
/****************
** linux/fs.h **
****************/
unsigned iminor(const struct inode *inode) { TRACE; return 0; }
unsigned imajor(const struct inode *inode) { TRACE; return 0; }
int register_chrdev_region(dev_t d, unsigned v, const char *s) { TRACE; return 0; }
void unregister_chrdev_region(dev_t d, unsigned v) { TRACE; }
void fops_put(struct file_operations const *fops) { TRACE; }
loff_t noop_llseek(struct file *file, loff_t offset, int origin) { TRACE; return 0; }
int register_chrdev(unsigned int major, const char *name,
const struct file_operations *fops) { TRACE; return 0; }
void unregister_chrdev(unsigned int major, const char *name) { TRACE; }
struct inode *new_inode(struct super_block *sb) { TRACE; return NULL; }
unsigned int get_next_ino(void) { TRACE; return 0; }
void init_special_inode(struct inode *i, umode_t m, dev_t d) { TRACE; }
int generic_delete_inode(struct inode *inode) { TRACE; return 0; }
void drop_nlink(struct inode *inode) { TRACE; }
void inc_nlink(struct inode *inode) { TRACE; }
void dentry_unhash(struct dentry *dentry) { TRACE; }
void iput(struct inode *i) { TRACE; }
struct dentry *mount_single(struct file_system_type *fs_type,
int flags, void *data,
int (*fill_super)(struct super_block *,
void *, int)) { TRACE; return NULL; }
int nonseekable_open(struct inode *inode, struct file *filp) { TRACE; return 0; }
int simple_statfs(struct dentry *d, struct kstatfs *k) { TRACE; return 0; }
int simple_pin_fs(struct file_system_type *t, struct vfsmount **mount, int *count) { TRACE; return 0; }
void simple_release_fs(struct vfsmount **mount, int *count) { TRACE; }
void kill_litter_super(struct super_block *sb) { TRACE; }
int register_filesystem(struct file_system_type *t) { TRACE; return 0; }
int unregister_filesystem(struct file_system_type *t) { TRACE; return 0; }
void kill_fasync(struct fasync_struct **fp, int sig, int band) { TRACE; }
int fasync_add_entry(int fd, struct file *filp, struct fasync_struct **fapp) { TRACE; return 0; }
const struct file_operations simple_dir_operations;
const struct inode_operations simple_dir_inode_operations;
/*******************
** linux/namei.h **
*******************/
struct dentry *lookup_one_len(const char *c, struct dentry *e, int v) { TRACE; return NULL; }
/**********************
** linux/seq_file.h **
**********************/
int seq_printf(struct seq_file *f, const char *fmt, ...) { TRACE; return 0; }
/*****************
** linux/gfp.h **
*****************/
unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order) { TRACE; return 0; }
void __free_pages(struct page *p, unsigned int order) { TRACE; }
void free_pages(unsigned long addr, unsigned int order) { TRACE; }
/*********************
** linux/proc_fs.h **
*********************/
struct proc_dir_entry *proc_mkdir(const char *s,struct proc_dir_entry *e) { TRACE; return NULL; }
void remove_proc_entry(const char *name, struct proc_dir_entry *parent) { TRACE; }
/********************
* linux/debugfs.h **
********************/
struct dentry *debugfs_create_dir(const char *name, struct dentry *parent) { TRACE; return (struct dentry *)1; }
struct dentry *debugfs_create_file(const char *name, mode_t mode,
struct dentry *parent, void *data,
const struct file_operations *fops) { TRACE; return (struct dentry *)1; }
void debugfs_remove(struct dentry *dentry) { TRACE; }
/************************
** linux/page-flags.h **
************************/
bool is_highmem(void *ptr) { TRACE; return 0; }
/****************
** linux/mm.h **
****************/
struct zone *page_zone(const struct page *page) { TRACE; return NULL; }
/**********************
** linux/highmem.h **
**********************/
void *kmap(struct page *page) { TRACE; return 0; }
void kunmap(struct page *page) { TRACE; }
/**********************
** asm-generic/io.h **
**********************/
void *ioremap(resource_size_t offset, unsigned long size) { TRACE; return NULL; }
void iounmap(volatile void *addr) { TRACE; }
void native_io_delay(void) { TRACE; }
/********************
** linux/ioport.h **
********************/
void release_region(resource_size_t start, resource_size_t n) { TRACE; }
void release_mem_region(resource_size_t start, resource_size_t n) { TRACE; }
/**
* SKIP
*/
/* implemented in Pci_driver */
struct resource *request_region(resource_size_t start, resource_size_t n,
const char *name) { SKIP; return (struct resource *)1; }
/* implemented in Pci_driver */
struct resource *request_mem_region(resource_size_t start, resource_size_t n,
const char *name) { SKIP; return (struct resource *)1; }
/***********************
** linux/interrupt.h **
***********************/
void local_irq_enable(void) { TRACE; }
void local_irq_disable(void) { TRACE; }
void free_irq(unsigned int i, void *p) { TRACE; }
/*********************
** linux/hardirq.h **
*********************/
void synchronize_irq(unsigned int irq) { TRACE; }
/*****************
** linux/pci.h **
*****************/
int pci_bus_read_config_dword(struct pci_bus *bus, unsigned int devfn, int where, u32 *val) { TRACE; return 0; }
int pci_bus_write_config_dword(struct pci_bus *bus, unsigned int devfn, int where, u32 val) { TRACE; return 0; }
void *pci_get_drvdata(struct pci_dev *pdev) { TRACE; return NULL; }
void pci_dev_put(struct pci_dev *dev) { TRACE; }
struct pci_dev *pci_get_device(unsigned int vendor, unsigned int device,
struct pci_dev *from) { TRACE; return NULL; }
void pci_disable_device(struct pci_dev *dev) { TRACE; }
int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask) { TRACE; return 0; }
void pci_unregister_driver(struct pci_driver *drv) { TRACE; }
bool pci_dev_run_wake(struct pci_dev *dev) { TRACE; return 0; }
int pci_set_mwi(struct pci_dev *dev) { TRACE; return 0; }
int pci_find_capability(struct pci_dev *dev, int cap) { TRACE; return 0; }
struct pci_dev *pci_get_slot(struct pci_bus *bus, unsigned int devfn) { TRACE; return NULL; }
const struct pci_device_id *pci_match_id(const struct pci_device_id *ids,
struct pci_dev *dev) { TRACE; return 0; }
void *pci_ioremap_bar(struct pci_dev *pdev, int bar);
/**
* Omitted PCI functions
*/
/* scans resources, this is already implemented in 'pci_driver.cc' */
int pci_enable_device(struct pci_dev *dev) { SKIP; return 0; }
/* implemented in Pci_driver::_setup_pci_device */
void pci_set_master(struct pci_dev *dev) { SKIP; }
/**********************
** linux/irqflags.h **
**********************/
unsigned long local_irq_save(unsigned long flags) { SKIP; return 0; }
unsigned long local_irq_restore(unsigned long flags) { SKIP; return 0; }
/*************************
** linux/dma-mapping.h **
*************************/
void dma_unmap_single_attrs(struct device *dev, dma_addr_t addr,
size_t size,
enum dma_data_direction dir,
struct dma_attrs *attrs) { SKIP; }
void dma_unmap_sg_attrs(struct device *dev, struct scatterlist *sg,
int nents, enum dma_data_direction dir,
struct dma_attrs *attrs) { SKIP; }
void dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size,
enum dma_data_direction direction) { SKIP;; }
int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) { SKIP; return 0; }
/*****************
** linux/pid.h **
*****************/
void put_pid(struct pid *pid) { TRACE; }
struct pid *get_pid(struct pid *pid) { TRACE; return NULL; }
/******************
** linux/cred.h **
******************/
void put_cred(struct cred const *c) { TRACE; }
const struct cred *get_cred(const struct cred *cred) { TRACE; return NULL; }
/**********************
** linux/security.h **
**********************/
void security_task_getsecid(struct task_struct *p, u32 *secid) { TRACE; }
/******************
** linux/cdev.h **
******************/
void cdev_init(struct cdev *c, const struct file_operations *fops) { TRACE; }
int cdev_add(struct cdev *c, dev_t d, unsigned v) { TRACE; return 0; }
void cdev_del(struct cdev *c) { TRACE; }
/*********************
** linux/utsname.h **
*********************/
struct new_utsname *init_utsname(void)
{
static struct new_utsname uts = { .sysname = "Genode.UTS", .release = "1.0" };
return &uts;
}
struct new_utsname *utsname(void) { TRACE; return NULL; }
/*********************
** linux/freezer.h **
*********************/
void set_freezable(void) { TRACE; }
/********************
** linux/parser.h **
********************/
int match_token(char *s, const match_table_t table, substring_t args[]) { TRACE; return 0; }
int match_int(substring_t *s, int *result) { TRACE; return 0; }
int match_octal(substring_t *s, int *result) { TRACE; return 0; }
/*********************
** linux/semaphore **
*********************/
void sema_init(struct semaphore *sem, int val) { TRACE; }
int down_trylock(struct semaphore *sem) { TRACE; return 0; }
int down_interruptible(struct semaphore *sem) { TRACE; return 0; }
void up(struct semaphore *sem) { TRACE; }
/*******************
** linux/input.h **
*******************/
void input_ff_destroy(struct input_dev *dev) { TRACE; }
int input_ff_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) { TRACE; return 0; }
int input_ff_upload(struct input_dev *dev, struct ff_effect *effect, struct file *file) { TRACE; return 0; }
int input_ff_erase(struct input_dev *dev, int effect_id, struct file *file) { TRACE; return 0; }
/*********************
** input-compat.h" **
*********************/
int input_event_from_user(const char __user *buffer, struct input_event *event) { TRACE; return 0; }
int input_event_to_user(char __user *buffer, const struct input_event *event) { TRACE; return 0; }
int input_ff_effect_from_user(const char __user *buffer, size_t size, struct ff_effect *effect) { TRACE; return 0;}
/****************
** linux/mt.h **
****************/
void input_mt_destroy_slots(struct input_dev *dev) { TRACE; }
/*********************
** linux/vmalloc.h **
*********************/
void *vmalloc(unsigned long size) { TRACE; return 0; }
/********************
** linux/blkdev.h **
********************/
void blk_queue_bounce_limit(struct request_queue *q, u64 dma_mask) { TRACE; }
void blk_queue_update_dma_alignment(struct request_queue *q, int mask) { TRACE; }
void blk_queue_max_hw_sectors(struct request_queue *q, unsigned int max_hw_sectors) { TRACE; }
unsigned int queue_max_hw_sectors(struct request_queue *q) { TRACE; return 0; }
/**********************
** scsi/scsi_cmnd.h **
**********************/
void scsi_set_resid(struct scsi_cmnd *cmd, int resid) { TRACE; }
int scsi_get_resid(struct scsi_cmnd *cmd) { TRACE; return 0; }
/********************
** scsi/scsi_eh.h **
*******************/
void scsi_report_bus_reset(struct Scsi_Host *shost, int channel) { TRACE; }
void scsi_report_device_reset(struct Scsi_Host *shost, int channel, int target) { TRACE; }
void scsi_eh_prep_cmnd(struct scsi_cmnd *scmd,
struct scsi_eh_save *ses, unsigned char *cmnd,
int cmnd_size, unsigned sense_bytes) { TRACE; }
void scsi_eh_restore_cmnd(struct scsi_cmnd* scmd,
struct scsi_eh_save *ses) { TRACE; }
int scsi_normalize_sense(const u8 *sense_buffer, int sb_len,
struct scsi_sense_hdr *sshdr) { TRACE; return 0; }
const u8 * scsi_sense_desc_find(const u8 * sense_buffer, int sb_len,
int desc_type) { TRACE; return 0; }
/***********************
** drivers/scsi/sd.h **
**********************/
struct scsi_disk *scsi_disk(struct gendisk *disk) { TRACE; return 0; }
/**********************
** scsi/scsi_host.h **
**********************/
int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev,
struct device *dma_dev) { TRACE; return 0; }
void scsi_remove_host(struct Scsi_Host *shost) { TRACE; }
void scsi_host_put(struct Scsi_Host *shost) { TRACE; }
struct scsi_device *scsi_get_host_dev(struct Scsi_Host *shost) { TRACE; return 0; }

@ -0,0 +1,136 @@
/*
* \brief Input service and event handler
* \author Christian Helmuth
* \author Dirk Vogt <dvogt@os.inf.tu-dresden.de>
* \author Sebastian Sumpf <sebastian.sumpf@genode-labs.com>
* \date 2009-04-20
*
* The original implementation was in the L4Env from the TUD:OS group
* (l4/pkg/input/lib/src/l4evdev.c). This file was released under the terms of
* the GNU General Public License version 2.
*/
/* Linux */
#include <linux/input.h>
/* Local */
#include <lx_emul.h>
/* Callback function to Genode subsystem */
static genode_input_event_cb handler;;
void genode_evdev_event(struct input_handle *handle, unsigned int type,
unsigned int code, int value)
{
#if DEBUG_EVDEV
static unsigned long count = 0;
#endif
/* filter sound events */
if (test_bit(EV_SND, handle->dev->evbit)) return;
/* filter input_repeat_key() */
if ((type == EV_KEY) && (value == 2)) return;
/* filter EV_SYN */
if (type == EV_SYN) return;
/* generate arguments and call back */
enum input_event_type arg_type;
unsigned arg_keycode = KEY_UNKNOWN;
int arg_ax = 0, arg_ay = 0, arg_rx = 0, arg_ry = 0;
switch (type) {
case EV_KEY:
arg_keycode = code;
switch (value) {
case 0:
arg_type = EVENT_TYPE_RELEASE;
break;
case 1:
arg_type = EVENT_TYPE_PRESS;
break;
default:
printk("Unknown key event value %d - not handled\n", value);
return;
}
break;
case EV_ABS:
switch (code) {
case ABS_X:
arg_type = EVENT_TYPE_MOTION;
arg_ax = value;
break;
case ABS_Y:
arg_type = EVENT_TYPE_MOTION;
arg_ay = value;
break;
case ABS_WHEEL:
/*
* XXX I do not know, how to handle this correctly. At least, this
* scheme works on Qemu.
*/
arg_type = EVENT_TYPE_WHEEL;
arg_ry = value;
break;
default:
printk("Unknown absolute event code %d - not handled\n", code);
return;
}
break;
case EV_REL:
switch (code) {
case REL_X:
arg_type = EVENT_TYPE_MOTION;
arg_rx = value;
break;
case REL_Y:
arg_type = EVENT_TYPE_MOTION;
arg_ry = value;
break;
case REL_HWHEEL:
arg_type = EVENT_TYPE_WHEEL;
arg_rx = value;
break;
case REL_WHEEL:
arg_type = EVENT_TYPE_WHEEL;
arg_ry = value;
break;
default:
printk("Unknown relative event code %d - not handled\n", code);
return;
}
break;
default:
printk("Unknown event type %d - not handled\n", type);
return;
}
if (handler)
handler(arg_type, arg_keycode, arg_ax, arg_ay, arg_rx, arg_ry);
printk("EVENT: t: %x c: %x ax: %d ay %d rx: %d ry %d\n",
arg_type, arg_keycode, arg_ax, arg_ay, arg_rx, arg_ry);
#if DEBUG_EVDEV
printk("event[%ld]. dev: %s, type: %d, code: %d, value: %d\n",
count++, handle->dev->name, type, code, value);
#endif
}
void genode_input_register(genode_input_event_cb h) { handler = h; }

@ -0,0 +1,77 @@
/*
* \brief Linux 2.6 Input driver for USB HID
* \author Christian Helmuth
* \author Christian Prochaska
* \author Sebastian Sumpf
* \date 2011-07-15
*/
/*
* Copyright (C) 2011-2012 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2.
*/
#include <base/printf.h>
#include <base/rpc_server.h>
#include <input/component.h>
#include <os/ring_buffer.h>
#include <lx_emul.h>
#undef RELEASE
using namespace Genode;
/*********************
** Input component **
*********************/
typedef Ring_buffer<Input::Event, 512> Input_ring_buffer;
static Input_ring_buffer ev_queue;
namespace Input {
void event_handling(bool enable) { }
bool event_pending() { return !ev_queue.empty(); }
Event get_event() { return ev_queue.get(); }
}
/**
* Input event call-back function
*/
static void input_callback(enum input_event_type type,
unsigned keycode,
int absolute_x, int absolute_y,
int relative_x, int relative_y)
{
Input::Event::Type t = Input::Event::INVALID;
switch (type) {
case EVENT_TYPE_PRESS: t = Input::Event::PRESS; break;
case EVENT_TYPE_RELEASE: t = Input::Event::RELEASE; break;
case EVENT_TYPE_MOTION: t = Input::Event::MOTION; break;
case EVENT_TYPE_WHEEL: t = Input::Event::WHEEL; break;
}
try {
ev_queue.add(Input::Event(t, keycode,
absolute_x, absolute_y,
relative_x, relative_y));
} catch (Input_ring_buffer::Overflow) {
PWRN("input ring buffer overflow");
}
}
void start_input_service(void *ep)
{
Rpc_entrypoint *e = static_cast<Rpc_entrypoint *>(ep);
static Input::Root input_root(e, env()->heap());
env()->parent()->announce(e->manage(&input_root));
genode_input_register(input_callback);
}

@ -0,0 +1,770 @@
/*
* \brief Emulation of Linux kernel interfaces
* \author Norman Feske
* \author Sebastian Sumpf
* \date 2012-01-29
*/
/*
* Copyright (C) 2012 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2.
*/
/* Genode includes */
#include <base/allocator_avl.h>
#include <dataspace/client.h>
#include <rm_session/connection.h>
#include <timer_session/connection.h>
#include <util/string.h>
/* Local includes */
#include "routine.h"
#include "signal.h"
#include "lx_emul.h"
/* DDE kit includes */
extern "C" {
#include <dde_kit/semaphore.h>
#include <dde_kit/memory.h>
#include <dde_kit/pgtab.h>
#include <dde_kit/resources.h>
#include <dde_kit/interrupt.h>
#include <dde_kit/thread.h>
}
#if VERBOSE_LX_EMUL
#define TRACE dde_kit_printf("\033[35m%s\033[0m called\n", __PRETTY_FUNCTION__)
#define UNSUPPORTED dde_kit_printf("\033[31m%s\033[0m unsupported arguments\n", __PRETTY_FUNCTION__)
#else
#define TRACE
#define UNSUPPORTED
#endif
/***********************
** Atomic operations **
***********************/
/*
* Actually not atomic, for now
*/
unsigned int atomic_read(atomic_t *p) { return *(volatile int *)p; }
void atomic_inc(atomic_t *v) { (*(volatile int *)v)++; }
void atomic_dec(atomic_t *v) { (*(volatile int *)v)--; }
void atomic_add(int i, atomic_t *v) { (*(volatile int *)v) += i; }
void atomic_sub(int i, atomic_t *v) { (*(volatile int *)v) -= i; }
void atomic_set(atomic_t *p, unsigned int v) { (*(volatile int *)p) = v; }
/*******************
** linux/mutex.h **
*******************/
void mutex_init (struct mutex *m) { if (m->lock) dde_kit_lock_init (&m->lock); }
void mutex_lock (struct mutex *m) { if (m->lock) dde_kit_lock_lock ( m->lock); }
void mutex_unlock(struct mutex *m) { if (m->lock) dde_kit_lock_unlock( m->lock); }
/*************************************
** Memory allocation, linux/slab.h **
*************************************/
void *kmalloc(size_t size, gfp_t flags)
{
return dde_kit_large_malloc(size);
}
void *kzalloc(size_t size, gfp_t flags)
{
void *addr = dde_kit_large_malloc(size);
if (addr)