0106045bad
The modular lx_kit seperates the required back end functionality of the Linux emulation environment from the front end. Thereby each driver can reuse specific parts or supply more suitable implementations by itself. It is used to reduce the amount of redundant code in each driver. The lx_kit is split into several layers whose structure is as follows: The first layer in _repos/dde_linux/src/include/lx_emul_ contains those header files that provide the structural definitions and function declarations of the Linux API, e.g. _errno.h_ provides all error code values. The second layer in _repos/dde_linux/src/include/lx_emul/impl_ contains the implementation of selected functions, e.g. _slab.h_ provides the implementation of 'kmalloc()'. The lx_kit back end API is the third layer and provides the _Lx::Malloc_ interface (_repos/dde_linux/src/include/lx_kit/malloc.h_) which is used to implement 'kmalloc()'. There are several generic implementations of the lx_kit interfaces that can be used by a driver. A driver typically includes a 'lx_emul/impl/xyz.h' header once directly in its lx_emul compilation unit. The lx_kit interface files are only included in those compilation units that use or implement the interface. If a driver wants to use a generic implementation it must add the source file to its source file list. The generic implementations are located in _repos/dde_linux/src/lx_kit/_. The modular lx_kit still depends on the private _lx_emul.h_ header file that is tailored to each driver. Since the lx_kit already contains much of the declarations and definitions that were originally placed in these private header files, those files can now ommit a large amount of code. Fixes #1974.
129 lines
2.8 KiB
C
129 lines
2.8 KiB
C
/*
|
|
* \brief Linux kernel API
|
|
* \author Norman Feske
|
|
* \author Sebastian Sumpf
|
|
* \author Josef Soentgen
|
|
* \date 2014-08-21
|
|
*
|
|
* Based on the prototypes found in the Linux kernel's 'include/'.
|
|
*/
|
|
|
|
/*
|
|
* Copyright (C) 2014 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/errno.h and friends **
|
|
*******************************/
|
|
|
|
/**
|
|
* Error codes
|
|
*
|
|
* Note that the codes do not correspond to those of the Linux kernel.
|
|
*/
|
|
enum {
|
|
/*
|
|
* The following numbers correspond to FreeBSD
|
|
*/
|
|
EPERM = 1,
|
|
ENOENT = 2,
|
|
ESRCH = 3,
|
|
EINTR = 4,
|
|
EIO = 5,
|
|
ENXIO = 6,
|
|
E2BIG = 7,
|
|
EDEADLK = 11,
|
|
ENOMEM = 12,
|
|
EACCES = 13,
|
|
EFAULT = 14,
|
|
EBUSY = 16,
|
|
EEXIST = 17,
|
|
EXDEV = 18,
|
|
ENODEV = 19,
|
|
EINVAL = 22,
|
|
ENFILE = 23,
|
|
ENOTTY = 25,
|
|
EFBIG = 27,
|
|
ENOSPC = 28,
|
|
ESPIPE = 29,
|
|
EPIPE = 32,
|
|
EDOM = 33,
|
|
ERANGE = 34,
|
|
EAGAIN = 35,
|
|
EINPROGRESS = 36,
|
|
EALREADY = 37,
|
|
ENOTSOCK = 38,
|
|
EDESTADDRREQ = 39,
|
|
EMSGSIZE = 40,
|
|
ENOPROTOOPT = 42,
|
|
EPROTONOSUPPORT = 43,
|
|
ESOCKTNOSUPPORT = 44,
|
|
EOPNOTSUPP = 45,
|
|
EPFNOSUPPORT = 46,
|
|
EAFNOSUPPORT = 47,
|
|
EADDRINUSE = 48,
|
|
EADDRNOTAVAIL = 49,
|
|
ENETDOWN = 50,
|
|
ENETUNREACH = 51,
|
|
ECONNABORTED = 53,
|
|
ECONNRESET = 54,
|
|
ENOBUFS = 55,
|
|
EISCONN = 56,
|
|
ENOTCONN = 57,
|
|
ETIMEDOUT = 60,
|
|
ECONNREFUSED = 61,
|
|
ENAMETOOLONG = 63,
|
|
EHOSTDOWN = 64,
|
|
EHOSTUNREACH = 65,
|
|
ENOSYS = 78,
|
|
ENOMSG = 83,
|
|
EOVERFLOW = 84,
|
|
ECANCELED = 85,
|
|
EILSEQ = 86,
|
|
EBADMSG = 89,
|
|
ENOLINK = 91,
|
|
EPROTO = 92,
|
|
|
|
/*
|
|
* The following numbers correspond to nothing
|
|
*/
|
|
EREMOTEIO = 200,
|
|
ERESTARTSYS = 201,
|
|
ENODATA = 202,
|
|
ETOOSMALL = 203,
|
|
ENOIOCTLCMD = 204,
|
|
ENONET = 205,
|
|
ENOTSUPP = 206,
|
|
ENOTUNIQ = 207,
|
|
ERFKILL = 208,
|
|
ETIME = 209,
|
|
EPROBE_DEFER = 210,
|
|
|
|
MAX_ERRNO = 4095,
|
|
};
|
|
|
|
|
|
/*****************
|
|
** linux/err.h **
|
|
*****************/
|
|
|
|
#define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
|
|
|
|
static inline bool IS_ERR(void const *ptr) {
|
|
return (unsigned long)(ptr) > (unsigned long)(-1000); }
|
|
|
|
static inline void * ERR_PTR(long error) {
|
|
return (void *) error; }
|
|
|
|
static inline void * ERR_CAST(const void *ptr) {
|
|
return (void *) ptr; }
|
|
|
|
static inline long IS_ERR_OR_NULL(const void *ptr) {
|
|
return !ptr || IS_ERR_VALUE((unsigned long)ptr); }
|
|
|
|
static inline long PTR_ERR(const void *ptr) { return (long) ptr; }
|
|
|