Full switch to clang/ELF. Drop ack. Simplify.

There is important information about booting non-ack images in
docs/UPDATING. ack/aout-format images can't be built any more, and
booting clang/ELF-format ones is a little different. Updating to the
new boot monitor is recommended.

Changes in this commit:

	. drop boot monitor -> allowing dropping ack support
	. facility to copy ELF boot files to /boot so that old boot monitor
	  can still boot fairly easily, see UPDATING
	. no more ack-format libraries -> single-case libraries
	. some cleanup of OBJECT_FMT, COMPILER_TYPE, etc cases
	. drop several ack toolchain commands, but not all support
	  commands (e.g. aal is gone but acksize is not yet).
	. a few libc files moved to netbsd libc dir
	. new /bin/date as minix date used code in libc/
	. test compile fix
	. harmonize includes
	. /usr/lib is no longer special: without ack, /usr/lib plays no
	  kind of special bootstrapping role any more and bootstrapping
	  is done exclusively through packages, so releases depend even
	  less on the state of the machine making them now.
	. rename nbsd_lib* to lib*
	. reduce mtree
This commit is contained in:
Ben Gras
2012-02-11 19:31:25 +01:00
parent 2487445f5f
commit 2fe8fb192f
5056 changed files with 16216 additions and 133169 deletions

23
include/ddekit/assert.h Normal file
View File

@@ -0,0 +1,23 @@
#ifndef _ddekit_assert_h
#define _ddekit_assert_h
#include <ddekit/ddekit.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 ddekit_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);
#define Assert ddekit_assert
#endif

16
include/ddekit/attribs.h Normal file
View File

@@ -0,0 +1,16 @@
#ifndef _DDEKIT_ATTRIBS_H
#define _DDEKIT_ATTRIBS_H
#ifdef __ACK__
#else
#define DDEKIT_USED __attribute__((used))
#define DDEKIT_CONSTRUCTOR __attribute__((constructor))
#define DDEKIT_PUBLIC PUBLIC
#define DDEKIT_PRIVATE static
#endif
#endif

32
include/ddekit/condvar.h Normal file
View File

@@ -0,0 +1,32 @@
#ifndef _ddekit_condvar_h
#define _ddekit_condvar_h
/** \file ddekit/condvar.h */
#include <ddekit/ddekit.h>
#include <ddekit/lock.h>
struct ddekit_condvar;
typedef struct ddekit_condvar ddekit_condvar_t;
/* Initialize conditional variable. */
_PROTOTYPE( ddekit_condvar_t * ddekit_condvar_init, (void));
/* Uninitialize conditional variable. */
_PROTOTYPE( void ddekit_condvar_deinit, (ddekit_condvar_t *cvp));
/* Wait on a conditional variable. */
_PROTOTYPE( void ddekit_condvar_waiti, (ddekit_condvar_t *cvp,
ddekit_lock_t *mp));
/* Wait on a conditional variable at most until a timeout expires. (UNIMPL) */
_PROTOTYPE( int ddekit_condvar_wait_timed, (ddekit_condvar_t *cvp,
ddekit_lock_t *mp, int timo));
/* Send signal to the next one waiting for condvar. */
_PROTOTYPE( void ddekit_condvar_signal, (ddekit_condvar_t *cvp));
/* Send signal to all threads waiting for condvar. */
_PROTOTYPE( void ddekit_condvar_broadcast, (ddekit_condvar_t *cvp));
#endif

7
include/ddekit/ddekit.h Normal file
View File

@@ -0,0 +1,7 @@
#ifndef _DDEKIT_DDEKIT_H
#define _DDEKIT_DDEKIT_H
#include <minix/ansi.h>
_PROTOTYPE( void ddekit_init, (void) );
#endif

41
include/ddekit/debug.h Normal file
View File

@@ -0,0 +1,41 @@
#ifndef DDEKIT_DEBUG_H
#define DDEKIT_DEBUG_H
#include <ddekit/ddekit.h>
#include <ddekit/printf.h>
#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
#define DDEBUG_MSG_ERR(fmt, ...)
#define DDEBUG_MSG_WARN(fmt, ...)
#define DDEBUG_MSG_INFO(fmt, ...)
#define DDEBUG_MSG_VERBOSE(fmt, ...)
#if DDEBUG >= DDEBUG_ERR
#undef DDEBUG_MSG_ERR
#define DDEBUG_MSG_ERR(fmt, ...) ddekit_printf("%s : "fmt"\n", __func__, ##__VA_ARGS__ )
#endif
#if DDEBUG >= DDEBUG_WARN
#undef DDEBUG_MSG_WARN
#define DDEBUG_MSG_WARN(fmt, ...) ddekit_printf("%s: "fmt"\n", __func__, ##__VA_ARGS__ )
#endif
#if DDEBUG >= DDEBUG_INFO
#undef DDEBUG_MSG_INFO
#define DDEBUG_MSG_INFO(fmt, ...) ddekit_printf("%s: "fmt"\n", __func__, ##__VA_ARGS__ )
#endif
#if DDEBUG >= DDEBUG_VERBOSE
#undef DDEBUG_MSG_VERBOSE
#define DDEBUG_MSG_VERBOSE(fmt, ...) ddekit_printf("%s: "fmt"\n", __func__, ##__VA_ARGS__ )
#endif
#endif

30
include/ddekit/initcall.h Normal file
View File

@@ -0,0 +1,30 @@
#ifndef _DDEKIT_INITCALL_H
#define _DDEKIT_INITCALL_H
#include <ddekit/ddekit.h>
#include <ddekit/attribs.h>
typedef void (*ddekit_initcall_t)(void);
struct __ddekit_initcall_s {
ddekit_initcall_t func;
int prio;
struct __ddekit_initcall_s *next;
};
void __ddekit_add_initcall(struct __ddekit_initcall_s *dis);
/* Define a function to be a DDEKit initcall.
* This is the right place to place Linux' module_init functions & Co.
*/
#define DDEKIT_INITCALL(fn) DDEKIT_CTOR(fn, 1)
#define DDEKIT_CTOR(fn, prio) \
static void __attribute__((used)) __attribute__((constructor))\
__ddekit_initcall_##fn() { \
static struct __ddekit_initcall_s dis = {(ddekit_initcall_t)fn, prio, 0}; \
__ddekit_add_initcall(&dis); }
/* Runs all registered initcalls. */
_PROTOTYPE (void ddekit_do_initcalls, (void));
#endif

2
include/ddekit/inline.h Normal file
View File

@@ -0,0 +1,2 @@
#define DDEKIT_INLINE __inline__ __attribute__((always_inline))

View File

@@ -0,0 +1,48 @@
/*-
* Copyright (c) 2006 TU Dresden, All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _DDEKIT_INTERUPT_H
#define _DDEKIT_INTERUPT_H
#include <ddekit/ddekit.h>
#include <ddekit/thread.h>
/** Attach to an interrupt */
_PROTOTYPE( 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. */
_PROTOTYPE( void ddekit_interrupt_detach, (int irq));
/* Block interrupt. */
_PROTOTYPE( void ddekit_interrupt_disable, (int irq));
/* Enable interrupt */
_PROTOTYPE( void ddekit_interrupt_enable, (int irq));
#endif

33
include/ddekit/lock.h Normal file
View File

@@ -0,0 +1,33 @@
#ifndef _DDEKIT_LOCK_H
#define _DDEKIT_LOCK_H
#include <ddekit/ddekit.h>
struct ddekit_lock;
typedef struct ddekit_lock *ddekit_lock_t;
/* Initialize a DDEKit unlocked lock. */
#define ddekit_lock_init ddekit_lock_init_unlocked
/* Initialize a DDEKit unlocked lock. */
_PROTOTYPE( void ddekit_lock_init_unlocked, (ddekit_lock_t *mtx));
/* Initialize a DDEKit locked lock. */
_PROTOTYPE( void ddekit_lock_init_locked, (ddekit_lock_t *mtx));
/* Uninitialize a DDEKit lock. */
_PROTOTYPE( void ddekit_lock_deinit, (ddekit_lock_t *mtx));
/* Acquire a lock. */
_PROTOTYPE( void ddekit_lock_lock, (ddekit_lock_t *mtx));
/* Acquire a lock, non-blocking. */
_PROTOTYPE( int ddekit_lock_try_lock, (ddekit_lock_t *mtx));
/* Unlock function. */
_PROTOTYPE( void ddekit_lock_unlock, (ddekit_lock_t *mtx));
/* Get lock owner. */
_PROTOTYPE( int ddekit_lock_owner, (ddekit_lock_t *mtx));
#endif

146
include/ddekit/memory.h Normal file
View File

@@ -0,0 +1,146 @@
/*-
* Copyright (c) 2006 Thomas Friebel <tf13@os.inf.tu-dresden.de>
* Copyright (c) 2006 Christian Helmuth <ch12@os.inf.tu-dresden.de>
* Copyright (c) 2010 Dirk Vogt <dvogt@few.vu.nl>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _DDEKIT_MEMORY_H
#define _DDEKIT_MEMORY_H
#include <ddekit/ddekit.h>
/*******************
** Slab facility **
*******************/
struct ddekit_slab;
/* Store user pointer in slab cache */
_PROTOTYPE( void ddekit_slab_set_data, (struct ddekit_slab * slab,
void *data));
/* Read user pointer from slab cache */
_PROTOTYPE( void *ddekit_slab_get_data,(struct ddekit_slab * slab));
/* Allocate slab in slab cache */
_PROTOTYPE( void *ddekit_slab_alloc, (struct ddekit_slab * slab));
/* Allocate slab in slab cache */
_PROTOTYPE( void ddekit_slab_free, (struct ddekit_slab * slab, void *objp));
/*
* Setup page cache for all slabs
*
* 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.
*/
_PROTOTYPE( void ddekit_slab_setup_page_cache, (unsigned pages));
/*
* Destroy slab cache
*
* slab: pointer to slab cache structure
*/
_PROTOTYPE( 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
*/
_PROTOTYPE( 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.
*/
_PROTOTYPE( void *ddekit_large_malloc, (int size));
/**
* Free large memory block
*
* \param p pointer to memory block
*/
_PROTOTYPE( 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. */
_PROTOTYPE( 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.
*/
_PROTOTYPE( void *ddekit_simple_malloc, (unsigned size));
/**
* Free memory block via simple allocator
*
* \param p pointer to memory block
*/
_PROTOTYPE( void ddekit_simple_free, (void *p));
#endif

View File

@@ -0,0 +1,22 @@
#ifndef DDEKIT_SRC_MSG_QUEUE_H
#define DDEKIT_SRC_MSG_QUEUE_H
#include <ddekit/ddekit.h>
#include <ddekit/thread.h>
#include <minix/ipc.h>
struct ddekit_minix_msg_q;
_PROTOTYPE( void ddekit_minix_queue_msg, (message *m));
_PROTOTYPE( void ddekit_minix_rcv,
(struct ddekit_minix_msg_q * mq, message *m));
_PROTOTYPE( struct ddekit_minix_msg_q *ddekit_minix_create_msg_q,
(unsigned from, unsigned to));
_PROTOTYPE( void ddekit_minix_destroy_msg_q,
(struct ddekit_minix_msg_q *mq));
#endif /* DDEKIT_SRC_MSG_QUEUE_H */

View File

@@ -0,0 +1,4 @@
#ifndef DDEKIT_MINIX_PCI
#define DDEKIT_MINIX_PCI
void ddekit_pci_init_only_one(int skip);
#endif

18
include/ddekit/panic.h Normal file
View File

@@ -0,0 +1,18 @@
#ifndef _DDEKIT_PANIC_H
#define _DDEKIT_PANIC_H
#include <ddekit/ddekit.h>
#include <stdarg.h>
/** \defgroup DDEKit_util */
/** Panic - print error message and enter the kernel debugger.
* \ingroup DDEKit_util
*/
_PROTOTYPE (void ddekit_panic, (char *fmt, ...));
/** Print a debug message.
* \ingroup DDEKit_util
*/
_PROTOTYPE (void ddekit_debug, (char *fmt, ...));
#endif

217
include/ddekit/pci.h Normal file
View File

@@ -0,0 +1,217 @@
#ifndef _DDEKIT_PCI_H
#define _DDEKIT_PCI_H
#include <ddekit/ddekit.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;
_PROTOTYPE( void ddekit_pci_init, (void));
_PROTOTYPE( int ddekit_pci_get_device,(int nr, int *bus,
int *slot, int *func));
_PROTOTYPE( int ddekit_pci_read, (int bus, int slot, int func,
int pos, int len, ddekit_uint32_t *val));
_PROTOTYPE( 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
*/
_PROTOTYPE( 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
*/
_PROTOTYPE( 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
*/
_PROTOTYPE( 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
*/
_PROTOTYPE( 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
*/
_PROTOTYPE( 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
*/
_PROTOTYPE( 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
*/
_PROTOTYPE( 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
*/
_PROTOTYPE( int ddekit_pci_enable_device, (struct ddekit_pci_dev *dev));
/** Disable PCI device
* \ingroup DDEKit_pci
*/
_PROTOTYPE( int ddekit_pci_disable_device, (struct ddekit_pci_dev *dev));
/** Enable bus-mastering for device.
* \ingroup DDEKit_pci
*/
_PROTOTYPE( void ddekit_pci_set_master, (struct ddekit_pci_dev *dev));
/** Get device vendor ID.
* \ingroup DDEKit_pci
*/
_PROTOTYPE( unsigned short ddekit_pci_get_vendor,
(struct ddekit_pci_dev *dev));
/** Get device ID.
* \ingroup DDEKit_pci
*/
_PROTOTYPE( unsigned short ddekit_pci_get_device_id,
(struct ddekit_pci_dev *dev));
/** Get device subvendor ID.
* \ingroup DDEKit_pci
*/
_PROTOTYPE( unsigned short ddekit_pci_get_sub_vendor,
(struct ddekit_pci_dev *dev));
/** Get subdevice ID.
* \ingroup DDEKit_pci
*/
_PROTOTYPE( unsigned short ddekit_pci_get_sub_device,
(struct ddekit_pci_dev *dev));
/** Get device class ID.
* \ingroup DDEKit_pci
*/
_PROTOTYPE( unsigned ddekit_pci_get_dev_class,
(struct ddekit_pci_dev *dev));
/** Get device's IRQ number.
* \ingroup DDEKit_pci
*/
_PROTOTYPE( unsigned long ddekit_pci_get_irq,
(struct ddekit_pci_dev *dev));
/** Get device name.
* \ingroup DDEKit_pci
*/
_PROTOTYPE( char *ddekit_pci_get_name, (struct ddekit_pci_dev *dev));
/** Get device's slot name.
* \ingroup DDEKit_pci
*/
_PROTOTYPE( char *ddekit_pci_get_slot_name, (struct ddekit_pci_dev *dev));
/** Get one of the device's resources.
* \ingroup DDEKit_pci
*/
_PROTOTYPE( ddekit_pci_res_t *ddekit_pci_get_resource,
(struct ddekit_pci_dev *dev, unsigned int idx));
_PROTOTYPE( int ddekit_pci_irq_enable, (int bus, int slot,
int func, int pin, int *irq));
#endif

92
include/ddekit/pgtab.h Normal file
View File

@@ -0,0 +1,92 @@
/*
* \brief Virtual page-table facility
* \author Thomas Friebel <tf13@os.inf.tu-dresden.de>
* \author Christian Helmuth <ch12@os.inf.tu-dresden.de>
* \date 2006-11-03
*/
#ifndef _DDEKIT_PGTAB_H
#define _DDEKIT_PGTAB_H
#include <ddekit/ddekit.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
*/
_PROTOTYPE( 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.
*/
_PROTOTYPE( 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
*/
_PROTOTYPE( void ddekit_pgtab_clear_region,
(void *virt, int type));
/**
* Get physical address for virtual address
*
* \param virt virtual address
*
* \return physical address
*/
_PROTOTYPE( ddekit_addr_t ddekit_pgtab_get_physaddr, (const void *virt));
/**
* Get virtual address for physical address
*
* \param physical physical address
*
* \return virtual address
*/
_PROTOTYPE( 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
*/
_PROTOTYPE( int ddekit_pgtab_get_type, (const void *virt));
/**
* Get size of VM region.
*
* \param virt virtual address
*
* \return VM region size (in bytes)
*/
_PROTOTYPE( int ddekit_pgtab_get_size, (const void *virt));
#endif

34
include/ddekit/printf.h Normal file
View File

@@ -0,0 +1,34 @@
#ifndef _DDEKIT_PRINTF_H
#define _DDEKIT_PRINTF_H
#include <ddekit/ddekit.h>
#include <stdarg.h>
/** Print message.
* \ingroup DDEKit_util
*/
_PROTOTYPE( int ddekit_print,(const char *));
/** Print message with format.
* \ingroup DDEKit_util
*/
_PROTOTYPE( int ddekit_printf,(const char *fmt, ...));
/** Print message with format list.
* \ingroup DDEKit_util
*/
_PROTOTYPE( int ddekit_vprintf, (const char *fmt, va_list va));
/** 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

View File

@@ -0,0 +1,80 @@
#ifndef _DDEKIT_RESOURCES_H
#define _DDEKIT_RESOURCES_H
#include <ddekit/ddekit.h>
#include <ddekit/types.h>
/*
* request/release an isa DMA-channel
*/
_PROTOTYPE( int ddekit_request_dma, (int nr));
_PROTOTYPE( int ddekit_release_dma, (int nr));
/*
* request/release an io-port range starting at addr start, lenght of count
*/
_PROTOTYPE( int ddekit_request_io, (ddekit_addr_t start, ddekit_addr_t count));
_PROTOTYPE( int ddekit_release_io, (ddekit_addr_t start, ddekit_addr_t count));
/*
* request an IO-Memory mapping from address start to vaddr of the length count
*/
_PROTOTYPE( int ddekit_request_mem,
(ddekit_addr_t start, ddekit_addr_t count, ddekit_addr_t *vaddr));
_PROTOTYPE( int ddekit_release_mem, (ddekit_addr_t start, ddekit_addr_t count));
/**
* Read I/O port (byte)
*
* \param port port to read
*
* \return value read from port
*/
_PROTOTYPE( unsigned char dde_kit_inb, (ddekit_addr_t port));
/**
* Read I/O port (2-byte)
*
* \param port port to read
*
* \return value read from port
*/
_PROTOTYPE( unsigned short dde_kit_inw, (ddekit_addr_t port));
/**
* Read I/O port (4-byte)
*
* \param port port to read
*
* \return value read from port
*/
_PROTOTYPE( unsigned long dde_kit_inl, (ddekit_addr_t port));
/**
* Write I/O port (byte)
*
* \param port port to write
* \param val value to write
*/
_PROTOTYPE( void dde_kit_outb, (ddekit_addr_t port, unsigned char val));
/**
* Write I/O port (2-byte)
*
* \param port port to write
* \param val value to write
*/
_PROTOTYPE( void dde_kit_outw, (ddekit_addr_t port, unsigned short val));
/**
* Write I/O port (4-byte)
*
* \param port port to write
* \param val value to write
*/
_PROTOTYPE( void dde_kit_outl, (ddekit_addr_t port, unsigned long val));
#endif

View File

@@ -0,0 +1,53 @@
#ifndef _DDEKIT_SEMAPHORE_H
#define _DDEKIT_SEMAPHORE_H
#include <ddekit/ddekit.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
*/
_PROTOTYPE( ddekit_sem_t *ddekit_sem_init, (int value));
/** Uninitialize semaphore.
*
* \ingroup DDEKit_synchronization
*/
_PROTOTYPE( void ddekit_sem_deinit, (ddekit_sem_t *sem));
/** Semaphore down method. */
_PROTOTYPE( void ddekit_sem_down, (ddekit_sem_t *sem));
/** Semaphore down method, non-blocking.
*
* \ingroup DDEKit_synchronization
*
* \return 0 success
* \return !=0 would block
*/
_PROTOTYPE( int ddekit_sem_down_try, (ddekit_sem_t *sem));
/** Semaphore down with timeout.
*
* \ingroup DDEKit_synchronization
*
* \return 0 success
* \return !=0 would block
*/
_PROTOTYPE( int ddekit_sem_down_timed, (ddekit_sem_t *sem, int timo));
/** Semaphore up method.
*
* \ingroup DDEKit_synchronization
*/
_PROTOTYPE( void ddekit_sem_up, (ddekit_sem_t *sem));
#endif

164
include/ddekit/thread.h Normal file
View File

@@ -0,0 +1,164 @@
#ifndef _DDEKIT_THREAD_H
#define _DDEKIT_THREAD_H
/** \defgroup DDEKit_threads */
#include <ddekit/ddekit.h>
#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
*/
_PROTOTYPE( ddekit_thread_t *ddekit_thread_create,
(void (*fun)(void *), void *arg, const char *name));
/** Reference to own DDEKit thread id.
*
* \ingroup DDEKit_threads
*/
_PROTOTYPE( 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.
*/
_PROTOTYPE( 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.
*/
_PROTOTYPE( 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.
*/
_PROTOTYPE( 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
*/
_PROTOTYPE( 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
*/
_PROTOTYPE( void ddekit_thread_set_my_data, (void *data));
/** Sleep for some miliseconds.
*
* \ingroup DDEKit_threads
*
* \param msecs time to sleep in ms.
*/
_PROTOTYPE( void ddekit_thread_msleep, (unsigned long msecs));
/** Sleep for some microseconds.
*
* \ingroup DDEKit_threads
*
* \param usecs time to sleep in µs.
*/
_PROTOTYPE( void ddekit_thread_usleep, (unsigned long usecs));
/** Sleep for some nanoseconds.
*
* \ingroup DDEKit_threads
*
* \param usecs time to sleep in ns.
*/
_PROTOTYPE( void ddekit_thread_nsleep, (unsigned long nsecs));
/** Sleep until a lock becomes unlocked.
*
* \ingroup DDEKit_threads
*/
_PROTOTYPE( void ddekit_thread_sleep, (ddekit_lock_t *lock));
/** Wakeup a waiting thread.
*
* \ingroup DDEKit_threads
*/
_PROTOTYPE( void ddekit_thread_wakeup, (ddekit_thread_t *thread));
/** Terminate a thread
*
* \ingroup DDEKit_threads
*/
_PROTOTYPE( void ddekit_thread_exit, (void) __attribute__((noreturn)));
/** Terminate a thread
*
* \ingroup DDEKit_threads
*/
_PROTOTYPE( void ddekit_thread_terminate, (ddekit_thread_t *thread));
/** Get the name, a thread registered with DDEKit.
*
* \ingroup DDEKit_threads
*/
_PROTOTYPE( const char *ddekit_thread_get_name, (ddekit_thread_t *thread));
/** Get unique ID of a DDEKit thread.
*
* \ingroup DDEKit_threads
*
* DDEKit does not allow direct access to the thread data
* structure, since this struct contains L4-specific data types.
* However, applications might want to get some kind of ID related
* to a ddekit_thread, for instance to use it as a Linux-like PID.
*/
_PROTOTYPE( int ddekit_thread_get_id, (ddekit_thread_t *thread));
/** Hint that this thread is done and may be scheduled somehow.
*
* \ingroup DDEKit_threads
*/
_PROTOTYPE( void ddekit_thread_schedule, (void));
/** Hint that this thread is done and may be scheduled somehow.
*
* \ingroup DDEKit_threads
*/
_PROTOTYPE( void ddekit_yield, (void));
/** Initialize DDEKit thread subsystem.
*
* \ingroup DDEKit_threads
*/
_PROTOTYPE( void ddekit_init_threads, (void));
#endif

52
include/ddekit/timer.h Normal file
View File

@@ -0,0 +1,52 @@
#ifndef _DDEKIT_TIMER_H
#define _DDEKIT_TIMER_H
#include <ddekit/ddekit.h>
#include <ddekit/thread.h>
/** \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
*/
_PROTOTYPE( int ddekit_add_timer,
(void (*fn)(void *), void *args, unsigned long timeout));
/** Delete timer with the corresponding timer id.
*
* \ingroup DDEKit_timer
*/
_PROTOTYPE( int ddekit_del_timer, (int timer));
/** Check whether a timer is pending
*
* \ingroup DDEKit_timer
*
* Linux needs this.
*/
_PROTOTYPE( int ddekit_timer_pending, (int timer));
/** Initialization function, startup timer thread
*
* \ingroup DDEKit_timer
*/
_PROTOTYPE( void ddekit_init_timers, (void));
/** Get the timer thread.
*/
_PROTOTYPE( ddekit_thread_t *ddekit_get_timer_thread, (void));
#endif

22
include/ddekit/types.h Normal file
View File

@@ -0,0 +1,22 @@
/*
* \brief Types for ddekit (x86 version)
* \author Thomas Friebel <tf13@os.inf.tu-dresden.de>
* \author Christian Helmuth <ch12@os.inf.tu-dresden.de>
* \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

97
include/ddekit/usb.h Normal file
View File

@@ -0,0 +1,97 @@
#ifndef _DDEKIT_USB_H
#define _DDEKIT_USB_H
#include <ddekit/ddekit.h>
#include <ddekit/types.h>
/** isochronous transfer */
#define DDEKIT_USB_TRANSFER_ISO 0
/** interrupt transfer */
#define DDEKIT_USB_TRANSFER_INT 1
/** control transfer */
#define DDEKIT_USB_TRANSFER_CTL 2
/** bulk transfer */
#define DDEKIT_USB_TRANSFER_BLK 3
#define DDEKIT_USB_IN 1
#define DDEKIT_USB_OUT 0
struct ddekit_usb_dev;
struct ddekit_usb_urb;
struct ddekit_usb_device_id {
ddekit_uint16_t idVendor;
ddekit_uint16_t idProduct;
ddekit_uint32_t bcdDevice;
ddekit_uint8_t bDeviceClass;
ddekit_uint8_t bDeviceSubClass;
ddekit_uint8_t bDeviceProtocol;
ddekit_uint8_t bInterfaceClass;
ddekit_uint8_t bInterfaceSubClass;
ddekit_uint8_t bInterfaceProtocol;
};
struct ddekit_usb_iso_packet_desc {
ddekit_int32_t offset;
ddekit_int32_t length; /* expected length */
ddekit_int32_t actual_length;
ddekit_int32_t status;
};
typedef void (*ddekit_usb_completion_cb)(void* priv);
typedef void (*ddekit_usb_connect_cb)(struct ddekit_usb_dev *dev,
unsigned int interfaces);
typedef void (*ddekit_usb_disconnect_cb)(struct ddekit_usb_dev *dev);
typedef void *(*ddekit_usb_malloc_fn)(unsigned size);
typedef void (*ddekit_usb_free_fn)(void *ptr);
struct ddekit_usb_driver {
ddekit_usb_completion_cb completion;
ddekit_usb_connect_cb connect;
ddekit_usb_disconnect_cb disconnect;
};
struct ddekit_usb_urb {
struct ddekit_usb_dev *dev;
ddekit_int32_t type;
ddekit_int32_t endpoint;
ddekit_int32_t direction;
ddekit_int32_t status;
ddekit_int32_t interval;
ddekit_uint32_t transfer_flags;
ddekit_uint32_t size;
ddekit_uint32_t actual_length;
ddekit_int32_t number_of_packets;
ddekit_int32_t error_count;
ddekit_int32_t start_frame;
char *setup_packet;
char *data;
struct ddekit_usb_iso_packet_desc *iso_desc;
void *priv;
void *ddekit_priv;
};
_PROTOTYPE( int ddekit_usb_dev_set_data,
(struct ddekit_usb_dev *dev, void *data));
_PROTOTYPE( void *ddekit_usb_dev_get_data, (struct ddekit_usb_dev *dev));
_PROTOTYPE( void ddekit_usb_get_device_id, (struct ddekit_usb_dev *dev,
struct ddekit_usb_device_id *id));
_PROTOTYPE( int ddekit_usb_submit_urb, (struct ddekit_usb_urb *d_urb));
_PROTOTYPE( int ddekit_usb_cancle_urb, (struct ddekit_usb_urb *d_urb));
/*
* This one is only implemented for the client side. For the server side is
* has to be implemented in the DDELinux/FBSD part.
*/
_PROTOTYPE( int ddekit_usb_init, (struct ddekit_usb_driver *drv,
ddekit_usb_malloc_fn *_m,
ddekit_usb_free_fn *_f));
#endif