mirror of
https://github.com/hermitcore/libhermit.git
synced 2025-03-09 00:00:03 +01:00
includes ok. working on memory mapping stuff.
This commit is contained in:
parent
eb76db19a2
commit
ba8fea704f
11 changed files with 369 additions and 415 deletions
|
@ -16,3 +16,4 @@ install(FILES
|
|||
|
||||
# More of a workaround?
|
||||
file(COPY ibv.h DESTINATION "${LOCAL_PREFIX_ARCH_INCLUDE_DIR}/hermit")
|
||||
file(COPY verbs.h DESTINATION "${LOCAL_PREFIX_ARCH_INCLUDE_DIR}/hermit")
|
||||
|
|
|
@ -36,19 +36,21 @@
|
|||
#ifndef INFINIBAND_VERBS_H
|
||||
#define INFINIBAND_VERBS_H
|
||||
|
||||
#ifdef __KERNEL__
|
||||
#include <hermit/stddef.h>
|
||||
#include <hermit/errno.h>
|
||||
#include <hermit/string.h>
|
||||
#else
|
||||
#include <stddef.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
//#include <stdint.h>
|
||||
#include <hermit/pthread.h>
|
||||
|
||||
//#include <stddef.h>
|
||||
//#include <errno.h>
|
||||
//#include <string.h>
|
||||
//#include <stdint.h> // not needed for data structures
|
||||
|
||||
//#include <linux/types.h>
|
||||
//#include <stdint.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
# define BEGIN_C_DECLS extern "C" {
|
||||
|
@ -66,43 +68,55 @@
|
|||
|
||||
BEGIN_C_DECLS
|
||||
|
||||
// Replacing linux/types.h (left out __bitwise):
|
||||
// Replacing in-l64.h:
|
||||
typedef unsigned short __u16;
|
||||
typedef unsigned int __u32;
|
||||
typedef unsigned long __u64;
|
||||
|
||||
// Replacing linux/types.h (left out __bitwise):
|
||||
//typedef __u16 __bitwise __be16;
|
||||
typedef __u16 __be16;
|
||||
typedef __u32 __be32;
|
||||
typedef __u64 __be64;
|
||||
|
||||
#ifdef __KERNEL__
|
||||
// Replacing pthread.h:
|
||||
typedef struct _pthread_descr_struct *_pthread_descr; // TODO
|
||||
typedef long long int __pthread_cond_align_t;
|
||||
|
||||
struct _pthread_fastlock {
|
||||
long int __status;
|
||||
int __spinlock;
|
||||
long int __status;
|
||||
int __spinlock;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
int __m_reserved;
|
||||
int __m_count;
|
||||
_pthread_descr __m_owner;
|
||||
int __m_kind;
|
||||
struct _pthread_fastlock __m_lock;
|
||||
int __m_reserved;
|
||||
int __m_count;
|
||||
_pthread_descr __m_owner;
|
||||
int __m_kind;
|
||||
struct _pthread_fastlock __m_lock;
|
||||
} pthread_mutex_t;
|
||||
|
||||
typedef struct {
|
||||
struct _pthread_fastlock __c_lock;
|
||||
_pthread_descr __c_waiting;
|
||||
char __padding[48 - sizeof(struct _pthread_fastlock) -
|
||||
sizeof(_pthread_descr) -
|
||||
sizeof(__pthread_cond_align_t)];
|
||||
__pthread_cond_align_t __align;
|
||||
struct _pthread_fastlock __c_lock;
|
||||
_pthread_descr __c_waiting;
|
||||
char __padding[48 - sizeof(struct _pthread_fastlock) -
|
||||
sizeof(_pthread_descr) -
|
||||
sizeof(__pthread_cond_align_t)];
|
||||
__pthread_cond_align_t __align;
|
||||
} pthread_cond_t;
|
||||
|
||||
// Replacing time.h:
|
||||
// TODO: Put this in an appropriate (arch specific) header.
|
||||
typedef long __kernel_long_t;
|
||||
typedef __kernel_long_t __kernel_time_t;
|
||||
|
||||
struct timespec {
|
||||
__kernel_time_t tv_sec; /* seconds */
|
||||
long tv_nsec; /* nanoseconds */
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
union ibv_gid {
|
||||
uint8_t raw[16];
|
||||
struct {
|
||||
|
@ -125,7 +139,7 @@ union ibv_gid {
|
|||
|
||||
#define vext_field_avail(type, fld, sz) (offsetof(type, fld) < (sz))
|
||||
|
||||
static void *__VERBS_ABI_IS_EXTENDED = (void *)UINTPTR_MAX;
|
||||
//static void *__VERBS_ABI_IS_EXTENDED = (void *)UINTPTR_MAX;
|
||||
|
||||
enum ibv_node_type {
|
||||
IBV_NODE_UNKNOWN = -1,
|
||||
|
|
146
include/limits.h
Normal file
146
include/limits.h
Normal file
|
@ -0,0 +1,146 @@
|
|||
#ifndef _LIBC_LIMITS_H_
|
||||
# define _LIBC_LIMITS_H_ 1
|
||||
|
||||
#include <newlib.h>
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
# ifdef _MB_LEN_MAX
|
||||
# define MB_LEN_MAX _MB_LEN_MAX
|
||||
# else
|
||||
# define MB_LEN_MAX 1
|
||||
# endif
|
||||
|
||||
/* Maximum number of positional arguments, if _WANT_IO_POS_ARGS. */
|
||||
# ifndef NL_ARGMAX
|
||||
# define NL_ARGMAX 32
|
||||
# endif
|
||||
|
||||
/* if do not have #include_next support, then we
|
||||
have to define the limits here. */
|
||||
# if !defined __GNUC__ || __GNUC__ < 2
|
||||
|
||||
# ifndef _LIMITS_H
|
||||
# define _LIMITS_H 1
|
||||
|
||||
# include <sys/config.h>
|
||||
|
||||
/* Number of bits in a `char'. */
|
||||
# undef CHAR_BIT
|
||||
# define CHAR_BIT 8
|
||||
|
||||
/* Minimum and maximum values a `signed char' can hold. */
|
||||
# undef SCHAR_MIN
|
||||
# define SCHAR_MIN (-128)
|
||||
# undef SCHAR_MAX
|
||||
# define SCHAR_MAX 127
|
||||
|
||||
/* Maximum value an `unsigned char' can hold. (Minimum is 0). */
|
||||
# undef UCHAR_MAX
|
||||
# define UCHAR_MAX 255
|
||||
|
||||
/* Minimum and maximum values a `char' can hold. */
|
||||
# ifdef __CHAR_UNSIGNED__
|
||||
# undef CHAR_MIN
|
||||
# define CHAR_MIN 0
|
||||
# undef CHAR_MAX
|
||||
# define CHAR_MAX 255
|
||||
# else
|
||||
# undef CHAR_MIN
|
||||
# define CHAR_MIN (-128)
|
||||
# undef CHAR_MAX
|
||||
# define CHAR_MAX 127
|
||||
# endif
|
||||
|
||||
/* Minimum and maximum values a `signed short int' can hold. */
|
||||
# undef SHRT_MIN
|
||||
/* For the sake of 16 bit hosts, we may not use -32768 */
|
||||
# define SHRT_MIN (-32767-1)
|
||||
# undef SHRT_MAX
|
||||
# define SHRT_MAX 32767
|
||||
|
||||
/* Maximum value an `unsigned short int' can hold. (Minimum is 0). */
|
||||
# undef USHRT_MAX
|
||||
# define USHRT_MAX 65535
|
||||
|
||||
/* Minimum and maximum values a `signed int' can hold. */
|
||||
# ifndef __INT_MAX__
|
||||
# define __INT_MAX__ 2147483647
|
||||
# endif
|
||||
# undef INT_MIN
|
||||
# define INT_MIN (-INT_MAX-1)
|
||||
# undef INT_MAX
|
||||
# define INT_MAX __INT_MAX__
|
||||
|
||||
/* Maximum value an `unsigned int' can hold. (Minimum is 0). */
|
||||
# undef UINT_MAX
|
||||
# define UINT_MAX (INT_MAX * 2U + 1)
|
||||
|
||||
/* Minimum and maximum values a `signed long int' can hold.
|
||||
(Same as `int'). */
|
||||
# ifndef __LONG_MAX__
|
||||
# if defined (__alpha__) || (defined (__sparc__) && defined(__arch64__)) || defined (__sparcv9)
|
||||
# define __LONG_MAX__ 9223372036854775807L
|
||||
# else
|
||||
# define __LONG_MAX__ 2147483647L
|
||||
# endif /* __alpha__ || sparc64 */
|
||||
# endif
|
||||
# undef LONG_MIN
|
||||
# define LONG_MIN (-LONG_MAX-1)
|
||||
# undef LONG_MAX
|
||||
# define LONG_MAX __LONG_MAX__
|
||||
|
||||
/* Maximum value an `unsigned long int' can hold. (Minimum is 0). */
|
||||
# undef ULONG_MAX
|
||||
# define ULONG_MAX (LONG_MAX * 2UL + 1)
|
||||
|
||||
# ifndef __LONG_LONG_MAX__
|
||||
# define __LONG_LONG_MAX__ 9223372036854775807LL
|
||||
# endif
|
||||
|
||||
# if __ISO_C_VISIBLE >= 1999
|
||||
/* Minimum and maximum values a `signed long long int' can hold. */
|
||||
# undef LLONG_MIN
|
||||
# define LLONG_MIN (-LLONG_MAX-1)
|
||||
# undef LLONG_MAX
|
||||
# define LLONG_MAX __LONG_LONG_MAX__
|
||||
|
||||
/* Maximum value an `unsigned long long int' can hold. (Minimum is 0). */
|
||||
# undef ULLONG_MAX
|
||||
# define ULLONG_MAX (LLONG_MAX * 2ULL + 1)
|
||||
# endif
|
||||
|
||||
# if __GNU_VISIBLE
|
||||
/* Minimum and maximum values a `signed long long int' can hold. */
|
||||
# undef LONG_LONG_MIN
|
||||
# define LONG_LONG_MIN (-LONG_LONG_MAX-1)
|
||||
# undef LONG_LONG_MAX
|
||||
# define LONG_LONG_MAX __LONG_LONG_MAX__
|
||||
|
||||
/* Maximum value an `unsigned long long int' can hold. (Minimum is 0). */
|
||||
# undef ULONG_LONG_MAX
|
||||
# define ULONG_LONG_MAX (LONG_LONG_MAX * 2ULL + 1)
|
||||
# endif
|
||||
|
||||
# endif /* _LIMITS_H */
|
||||
# endif /* GCC 2. */
|
||||
|
||||
#endif /* !_LIBC_LIMITS_H_ */
|
||||
|
||||
#if defined __GNUC__ && !defined _GCC_LIMITS_H_
|
||||
/* `_GCC_LIMITS_H_' is what GCC's file defines. */
|
||||
# include_next <limits.h>
|
||||
#endif /* __GNUC__ && !_GCC_LIMITS_H_ */
|
||||
|
||||
#ifndef _POSIX2_RE_DUP_MAX
|
||||
/* The maximum number of repeated occurrences of a regular expression
|
||||
* permitted when using the interval notation `\{M,N\}'. */
|
||||
#define _POSIX2_RE_DUP_MAX 255
|
||||
#endif /* _POSIX2_RE_DUP_MAX */
|
||||
|
||||
#ifndef ARG_MAX
|
||||
#define ARG_MAX 4096
|
||||
#endif
|
||||
|
||||
#ifndef PATH_MAX
|
||||
#define PATH_MAX 4096
|
||||
#endif
|
17
include/pte_types.h
Normal file
17
include/pte_types.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
/* pte_types.h */
|
||||
|
||||
#ifndef PTE_TYPES_H
|
||||
#define PTE_TYPES_H
|
||||
|
||||
#ifdef __KERNEL__
|
||||
#include <hermit/errno.h>
|
||||
#else
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/timeb.h>
|
||||
|
||||
typedef unsigned int tid_t;
|
||||
|
||||
#endif /* PTE_TYPES_H */
|
|
@ -8,382 +8,6 @@
|
|||
* Contact Email: jschmidlapp@users.sourceforge.net
|
||||
*
|
||||
*
|
||||
* Pthreads-embedded (PTE) - POSIX Threads Library for embedded systems
|
||||
* Copyright(C) 2008 Jason Schmidlapp
|
||||
*
|
||||
* Contact Email: jschmidlapp@users.sourceforge.net
|
||||
*
|
||||
*
|
||||
* Based upon Pthreads-win32 - POSIX Threads Library for Win32
|
||||
* Copyright(C) 1998 John E. Bossom
|
||||
* Copyright(C) 1999,2005 Pthreads-win32 contributors
|
||||
*
|
||||
* Contact Email: rpj@callisto.canberra.edu.au
|
||||
*
|
||||
* The original list of contributors to the Pthreads-win32 project
|
||||
* is contained in the file CONTRIBUTORS.ptw32 included with the
|
||||
* source code distribution. The list can also be seen at the
|
||||
* following World Wide Web location:
|
||||
* http://sources.redhat.com/pthreads-win32/contributors.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library in the file COPYING.LIB;
|
||||
* if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined( PTHREAD_H )
|
||||
#define PTHREAD_H
|
||||
|
||||
//#include <hermit/pte_types.h>
|
||||
|
||||
#define PTE_VERSION 2,8,0,0
|
||||
#define PTE_VERSION_STRING "2, 8, 0, 0\0"
|
||||
|
||||
/* There are two implementations of cancel cleanup.
|
||||
* Note that pthread.h is included in both application
|
||||
* compilation units and also internally for the library.
|
||||
* The code here and within the library aims to work
|
||||
* for all reasonable combinations of environments.
|
||||
*
|
||||
* The two implementations are:
|
||||
*
|
||||
* C
|
||||
* C++
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Define defaults for cleanup code.
|
||||
* Note: Unless the build explicitly defines one of the following, then
|
||||
* we default to standard C style cleanup. This style uses setjmp/longjmp
|
||||
* in the cancelation and thread exit implementations and therefore won't
|
||||
* do stack unwinding if linked to applications that have it (e.g.
|
||||
* C++ apps). This is currently consistent with most/all commercial Unix
|
||||
* POSIX threads implementations.
|
||||
*/
|
||||
#if !defined( PTE_CLEANUP_CXX ) && !defined( PTE_CLEANUP_C )
|
||||
# define PTE_CLEANUP_C
|
||||
#endif
|
||||
|
||||
#undef PTE_LEVEL
|
||||
|
||||
#if defined(_POSIX_SOURCE)
|
||||
#define PTE_LEVEL 0
|
||||
/* Early POSIX */
|
||||
#endif
|
||||
|
||||
#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309
|
||||
#undef PTE_LEVEL
|
||||
#define PTE_LEVEL 1
|
||||
/* Include 1b, 1c and 1d */
|
||||
#endif
|
||||
|
||||
#if defined(INCLUDE_NP)
|
||||
#undef PTE_LEVEL
|
||||
#define PTE_LEVEL 2
|
||||
/* Include Non-Portable extensions */
|
||||
#endif
|
||||
|
||||
#define PTE_LEVEL_MAX 3
|
||||
|
||||
#if !defined(PTE_LEVEL)
|
||||
#define PTE_LEVEL PTE_LEVEL_MAX
|
||||
/* Include everything */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* -------------------------------------------------------------
|
||||
*
|
||||
*
|
||||
* Module: pthread.h
|
||||
*
|
||||
* Purpose:
|
||||
* Provides an implementation of PThreads based upon the
|
||||
* standard:
|
||||
*
|
||||
* POSIX 1003.1-2001
|
||||
* and
|
||||
* The Single Unix Specification version 3
|
||||
*
|
||||
* (these two are equivalent)
|
||||
*
|
||||
* in order to enhance code portability between Windows,
|
||||
* various commercial Unix implementations, and Linux.
|
||||
*
|
||||
* See the ANNOUNCE file for a full list of conforming
|
||||
* routines and defined constants, and a list of missing
|
||||
* routines and constants not defined in this implementation.
|
||||
*
|
||||
* Authors:
|
||||
* There have been many contributors to this library.
|
||||
* The initial implementation was contributed by
|
||||
* John Bossom, and several others have provided major
|
||||
* sections or revisions of parts of the implementation.
|
||||
* Often significant effort has been contributed to
|
||||
* find and fix important bugs and other problems to
|
||||
* improve the reliability of the library, which sometimes
|
||||
* is not reflected in the amount of code which changed as
|
||||
* result.
|
||||
* As much as possible, the contributors are acknowledged
|
||||
* in the ChangeLog file in the source code distribution
|
||||
* where their changes are noted in detail.
|
||||
*
|
||||
* Contributors are listed in the CONTRIBUTORS file.
|
||||
*
|
||||
* As usual, all bouquets go to the contributors, and all
|
||||
* brickbats go to the project maintainer.
|
||||
*
|
||||
* Maintainer:
|
||||
* The code base for this project is coordinated and
|
||||
* eventually pre-tested, packaged, and made available by
|
||||
*
|
||||
* Ross Johnson <rpj@callisto.canberra.edu.au>
|
||||
*
|
||||
* QA Testers:
|
||||
* Ultimately, the library is tested in the real world by
|
||||
* a host of competent and demanding scientists and
|
||||
* engineers who report bugs and/or provide solutions
|
||||
* which are then fixed or incorporated into subsequent
|
||||
* versions of the library. Each time a bug is fixed, a
|
||||
* test case is written to prove the fix and ensure
|
||||
* that later changes to the code don't reintroduce the
|
||||
* same error. The number of test cases is slowly growing
|
||||
* and therefore so is the code reliability.
|
||||
*
|
||||
* Compliance:
|
||||
* See the file ANNOUNCE for the list of implemented
|
||||
* and not-implemented routines and defined options.
|
||||
* Of course, these are all defined is this file as well.
|
||||
*
|
||||
* Web site:
|
||||
* The source code and other information about this library
|
||||
* are available from
|
||||
*
|
||||
* http://sources.redhat.com/pthreads-win32/
|
||||
*
|
||||
* -------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include <hermit/time.h>
|
||||
|
||||
#include <hermit/setjmp.h>
|
||||
#include <hermit/limits.h>
|
||||
|
||||
/*
|
||||
* Boolean values to make us independent of system includes.
|
||||
*/
|
||||
enum
|
||||
{
|
||||
PTE_FALSE = 0,
|
||||
PTE_TRUE = (! PTE_FALSE)
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* -------------------------------------------------------------
|
||||
*
|
||||
* POSIX 1003.1-2001 Options
|
||||
* =========================
|
||||
*
|
||||
* Options are normally set in <unistd.h>, which is not provided
|
||||
* with pthreads-embedded.
|
||||
*
|
||||
* For conformance with the Single Unix Specification (version 3), all of the
|
||||
* options below are defined, and have a value of either -1 (not supported)
|
||||
* or 200112L (supported).
|
||||
*
|
||||
* These options can neither be left undefined nor have a value of 0, because
|
||||
* either indicates that sysconf(), which is not implemented, may be used at
|
||||
* runtime to check the status of the option.
|
||||
*
|
||||
* _POSIX_THREADS (== 200112L)
|
||||
* If == 200112L, you can use threads
|
||||
*
|
||||
* _POSIX_THREAD_ATTR_STACKSIZE (== 200112L)
|
||||
* If == 200112L, you can control the size of a thread's
|
||||
* stack
|
||||
* pthread_attr_getstacksize
|
||||
* pthread_attr_setstacksize
|
||||
*
|
||||
* _POSIX_THREAD_ATTR_STACKADDR (== -1)
|
||||
* If == 200112L, you can allocate and control a thread's
|
||||
* stack. If not supported, the following functions
|
||||
* will return ENOSYS, indicating they are not
|
||||
* supported:
|
||||
* pthread_attr_getstackaddr
|
||||
* pthread_attr_setstackaddr
|
||||
*
|
||||
* _POSIX_THREAD_PRIORITY_SCHEDULING (== -1)
|
||||
* If == 200112L, you can use realtime scheduling.
|
||||
* This option indicates that the behaviour of some
|
||||
* implemented functions conforms to the additional TPS
|
||||
* requirements in the standard. E.g. rwlocks favour
|
||||
* writers over readers when threads have equal priority.
|
||||
*
|
||||
* _POSIX_THREAD_PRIO_INHERIT (== -1)
|
||||
* If == 200112L, you can create priority inheritance
|
||||
* mutexes.
|
||||
* pthread_mutexattr_getprotocol +
|
||||
* pthread_mutexattr_setprotocol +
|
||||
*
|
||||
* _POSIX_THREAD_PRIO_PROTECT (== -1)
|
||||
* If == 200112L, you can create priority ceiling mutexes
|
||||
* Indicates the availability of:
|
||||
* pthread_mutex_getprioceiling
|
||||
* pthread_mutex_setprioceiling
|
||||
* pthread_mutexattr_getprioceiling
|
||||
* pthread_mutexattr_getprotocol +
|
||||
* pthread_mutexattr_setprioceiling
|
||||
* pthread_mutexattr_setprotocol +
|
||||
*
|
||||
* _POSIX_THREAD_PROCESS_SHARED (== -1)
|
||||
* If set, you can create mutexes and condition
|
||||
* variables that can be shared with another
|
||||
* process.If set, indicates the availability
|
||||
* of:
|
||||
* pthread_mutexattr_getpshared
|
||||
* pthread_mutexattr_setpshared
|
||||
* pthread_condattr_getpshared
|
||||
* pthread_condattr_setpshared
|
||||
*
|
||||
* _POSIX_THREAD_SAFE_FUNCTIONS (== 200112L)
|
||||
* If == 200112L you can use the special *_r library
|
||||
* functions that provide thread-safe behaviour
|
||||
*
|
||||
* _POSIX_READER_WRITER_LOCKS (== 200112L)
|
||||
* If == 200112L, you can use read/write locks
|
||||
*
|
||||
* _POSIX_SPIN_LOCKS (== 200112L)
|
||||
* If == 200112L, you can use spin locks
|
||||
*
|
||||
* _POSIX_BARRIERS (== 200112L)
|
||||
* If == 200112L, you can use barriers
|
||||
*
|
||||
* + These functions provide both 'inherit' and/or
|
||||
* 'protect' protocol, based upon these macro
|
||||
* settings.
|
||||
*
|
||||
* -------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
* POSIX Options
|
||||
*/
|
||||
#undef _POSIX_THREADS
|
||||
#define _POSIX_THREADS 200112L
|
||||
|
||||
#undef _POSIX_READER_WRITER_LOCKS
|
||||
#define _POSIX_READER_WRITER_LOCKS 200112L
|
||||
|
||||
#undef _POSIX_SPIN_LOCKS
|
||||
#define _POSIX_SPIN_LOCKS 200112L
|
||||
|
||||
#undef _POSIX_BARRIERS
|
||||
#define _POSIX_BARRIERS 200112L
|
||||
|
||||
#undef _POSIX_THREAD_SAFE_FUNCTIONS
|
||||
#define _POSIX_THREAD_SAFE_FUNCTIONS 200112L
|
||||
|
||||
#undef _POSIX_THREAD_ATTR_STACKSIZE
|
||||
#define _POSIX_THREAD_ATTR_STACKSIZE 200112L
|
||||
|
||||
/*
|
||||
* The following options are not supported
|
||||
*/
|
||||
#undef _POSIX_THREAD_ATTR_STACKADDR
|
||||
#define _POSIX_THREAD_ATTR_STACKADDR -1
|
||||
|
||||
#undef _POSIX_THREAD_PRIO_INHERIT
|
||||
#define _POSIX_THREAD_PRIO_INHERIT -1
|
||||
|
||||
#undef _POSIX_THREAD_PRIO_PROTECT
|
||||
#define _POSIX_THREAD_PRIO_PROTECT -1
|
||||
|
||||
/* TPS is not fully supported. */
|
||||
#undef _POSIX_THREAD_PRIORITY_SCHEDULING
|
||||
#define _POSIX_THREAD_PRIORITY_SCHEDULING -1
|
||||
|
||||
#undef _POSIX_THREAD_PROCESS_SHARED
|
||||
#define _POSIX_THREAD_PROCESS_SHARED -1
|
||||
|
||||
|
||||
/*
|
||||
* POSIX 1003.1-2001 Limits
|
||||
* ===========================
|
||||
*
|
||||
* These limits are normally set in <limits.h>, which is not provided with
|
||||
* pthreads-embedded.
|
||||
*
|
||||
* PTHREAD_DESTRUCTOR_ITERATIONS
|
||||
* Maximum number of attempts to destroy
|
||||
* a thread's thread-specific data on
|
||||
* termination (must be at least 4)
|
||||
*
|
||||
* PTHREAD_KEYS_MAX
|
||||
* Maximum number of thread-specific data keys
|
||||
* available per process (must be at least 128)
|
||||
*
|
||||
* PTHREAD_STACK_MIN
|
||||
* Minimum supported stack size for a thread
|
||||
*
|
||||
* PTHREAD_THREADS_MAX
|
||||
* Maximum number of threads supported per
|
||||
* process (must be at least 64).
|
||||
*
|
||||
* SEM_NSEMS_MAX
|
||||
* The maximum number of semaphores a process can have.
|
||||
* (must be at least 256)
|
||||
*
|
||||
* SEM_VALUE_MAX
|
||||
* The maximum value a semaphore can have.
|
||||
* (must be at least 32767)
|
||||
*
|
||||
*/
|
||||
#undef _POSIX_THREAD_DESTRUCTOR_ITERATIONS
|
||||
#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
|
||||
|
||||
#undef PTHREAD_DESTRUCTOR_ITERATIONS
|
||||
#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
|
||||
|
||||
#undef _POSIX_THREAD_KEYS_MAX
|
||||
#define _POSIX_THREAD_KEYS_MAX 128
|
||||
|
||||
#undef PTHREAD_KEYS_MAX
|
||||
#define PTHREAD_KEYS_MAX _POSIX_THREAD_KEYS_MAX
|
||||
|
||||
#undef PTHREAD_STACK_MIN
|
||||
#define PTHREAD_STACK_MIN 0
|
||||
|
||||
#undef _POSIX_THREAD_THREADS_MAX
|
||||
#define _POSIX_THREAD_THREADS_MAX 64
|
||||
|
||||
/* Arbitrary value */
|
||||
#undef PTHREAD_THREADS_MAX
|
||||
#define PTHREAD_THREADS_MAX 2019
|
||||
|
||||
#undef _POSIX_SEM_NSEMS_MAX
|
||||
#define _POSIX_SEM_NSEMS_MAX 256
|
||||
|
||||
/* Arbitrary value */
|
||||
#undef SEM_NSEMS_MAX
|
||||
#define SEM_NSEMS_MAX 1024
|
||||
|
||||
#undef _POSIX_SEM_VALUE_MAX
|
||||
#define _POSIX_SEM_VALUE_MAX 32767
|
||||
|
||||
#undef SEM_VALUE_MAX
|
||||
#define SEM_VALUE_MAX INT_MAX
|
||||
|
||||
#include <sched.h>
|
||||
|
||||
/*
|
97
include/sched.h
Normal file
97
include/sched.h
Normal file
|
@ -0,0 +1,97 @@
|
|||
/*
|
||||
* Written by Joel Sherrill <joel@OARcorp.com>.
|
||||
*
|
||||
* COPYRIGHT (c) 1989-2010.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose without fee is hereby granted, provided that this entire notice
|
||||
* is included in all copies of any software which is or includes a copy
|
||||
* or modification of this software.
|
||||
*
|
||||
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
|
||||
* WARRANTY. IN PARTICULAR, THE AUTHOR MAKES NO REPRESENTATION
|
||||
* OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS
|
||||
* SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef _SCHED_H_
|
||||
#define _SCHED_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/sched.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(_POSIX_PRIORITY_SCHEDULING)
|
||||
/*
|
||||
* XBD 13 - Set Scheduling Parameters, P1003.1b-2008, p. 1803
|
||||
*/
|
||||
int sched_setparam(
|
||||
pid_t __pid,
|
||||
const struct sched_param *__param
|
||||
);
|
||||
|
||||
/*
|
||||
* XBD 13 - Set Scheduling Parameters, P1003.1b-2008, p. 1800
|
||||
*/
|
||||
int sched_getparam(
|
||||
pid_t __pid,
|
||||
struct sched_param *__param
|
||||
);
|
||||
|
||||
/*
|
||||
* XBD 13 - Set Scheduling Policy and Scheduling Parameters,
|
||||
* P1003.1b-2008, p. 1805
|
||||
*/
|
||||
int sched_setscheduler(
|
||||
pid_t __pid,
|
||||
int __policy,
|
||||
const struct sched_param *__param
|
||||
);
|
||||
|
||||
/*
|
||||
* XBD 13 - Get Scheduling Policy, P1003.1b-2008, p. 1801
|
||||
*/
|
||||
int sched_getscheduler(
|
||||
pid_t __pid
|
||||
);
|
||||
|
||||
/*
|
||||
* XBD 13 - Get Scheduling Parameter Limits, P1003.1b-2008, p. 1799
|
||||
*/
|
||||
int sched_get_priority_max(
|
||||
int __policy
|
||||
);
|
||||
|
||||
int sched_get_priority_min(
|
||||
int __policy
|
||||
);
|
||||
|
||||
/*
|
||||
* XBD 13 - Get Scheduling Parameter Limits, P1003.1b-2008, p. 1802
|
||||
*/
|
||||
int sched_rr_get_interval(
|
||||
pid_t __pid,
|
||||
struct timespec *__interval
|
||||
);
|
||||
#endif /* _POSIX_PRIORITY_SCHEDULING */
|
||||
|
||||
#if defined(_POSIX_THREADS) || defined(_POSIX_PRIORITY_SCHEDULING)
|
||||
|
||||
/*
|
||||
* XBD 13 - Yield Processor, P1003.1b-2008, p. 1807
|
||||
*/
|
||||
int sched_yield( void );
|
||||
|
||||
#endif /* _POSIX_THREADS or _POSIX_PRIORITY_SCHEDULING */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SCHED_H_ */
|
25
include/setjmp.h
Normal file
25
include/setjmp.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
setjmp.h
|
||||
stubs for future use.
|
||||
*/
|
||||
|
||||
#ifndef _SETJMP_H_
|
||||
#define _SETJMP_H_
|
||||
|
||||
#include "_ansi.h"
|
||||
#include <machine/setjmp.h>
|
||||
|
||||
_BEGIN_STD_C
|
||||
|
||||
#ifdef __GNUC__
|
||||
void _EXFUN(longjmp,(jmp_buf __jmpb, int __retval))
|
||||
__attribute__ ((__noreturn__));
|
||||
#else
|
||||
void _EXFUN(longjmp,(jmp_buf __jmpb, int __retval));
|
||||
#endif
|
||||
int _EXFUN(setjmp,(jmp_buf __jmpb));
|
||||
|
||||
_END_STD_C
|
||||
|
||||
#endif /* _SETJMP_H_ */
|
||||
|
11
kernel/ibv.c
11
kernel/ibv.c
|
@ -30,20 +30,27 @@
|
|||
#include <asm/uhyve.h>
|
||||
#include <hermit/stddef.h>
|
||||
#include <hermit/stdio.h>
|
||||
#include <hermit/stdlib.h>
|
||||
|
||||
#include <hermit/ibv.h> // GEHT
|
||||
|
||||
#define MAX_NUM_OF_IBV_DEVICES 16
|
||||
|
||||
typedef struct {
|
||||
// In:
|
||||
int *num_devices;
|
||||
struct ibv_device **ret;
|
||||
// Out:
|
||||
/*struct ibv_device **ret;*/
|
||||
struct ibv_device devices[MAX_NUM_OF_IBV_DEVICES];
|
||||
} __attribute__((packed)) uhyve_ibv_get_device_list_t;
|
||||
|
||||
struct ibv_device** h_ibv_get_device_list(int *num_devices)
|
||||
{
|
||||
uhyve_ibv_get_device_list_t uhyve_args = {(int*) virt_to_phys((size_t) num_devices)};
|
||||
/*(struct ibv_device*) virt_to_phys((size_t) devices)};*/
|
||||
&uhyve_args.devices = (struct ibv_device*) virt_to_phys((size_t) uhyve_args.devices);
|
||||
uhyve_send(UHYVE_PORT_IBV_GET_DEVICE_LIST, (unsigned)virt_to_phys((size_t)&uhyve_args));
|
||||
return uhyve_args.ret;
|
||||
return &uhyve_args.devices;
|
||||
|
||||
// TODO: proxy implementation
|
||||
}
|
||||
|
|
|
@ -21,15 +21,18 @@
|
|||
|
||||
#include <infiniband/verbs.h> // Linux include
|
||||
|
||||
#define MAX_NUM_OF_IBV_DEVICES 16
|
||||
|
||||
typedef enum {
|
||||
UHYVE_PORT_IBV_GET_DEVICE_LIST = 0x510,
|
||||
UHYVE_PORT_IBV_GET_DEVICE_NAME = 0x511,
|
||||
} uhyve_ibv_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
// In:
|
||||
int *num_devices;
|
||||
struct ibv_device **ret;
|
||||
// Out:
|
||||
struct ibv_device devices[MAX_NUM_OF_IBV_DEVICES];
|
||||
} __attribute__((packed)) uhyve_ibv_get_device_list_t;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -972,10 +972,30 @@ static int vcpu_loop(void)
|
|||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_get_device_list_t* args = (uhyve_ibv_get_device_list_t*) (guest_mem+data);
|
||||
|
||||
args->ret = ibv_get_device_list((int*)(guest_mem+(size_t)args->num_devices));
|
||||
printf("UHYVE_PORT_IBV_GET_DEVICE_LIST\n");
|
||||
int num_devices;
|
||||
struct ibv_device **temp_dev_list = ibv_get_device_list(&num_devices);
|
||||
|
||||
printf("uhyve.c: before memcpy num_devices.\nGuest mem value: %p\n", guest_mem);
|
||||
/*uhyve_read->ret = read(uhyve_read->fd, guest_mem+(size_t)uhyve_read->buf, uhyve_read->len);*/
|
||||
memcpy(guest_mem+(size_t)args->num_devices, &num_devices, sizeof(num_devices));
|
||||
/*memcpy(args->num_devices, &num_devices, sizeof(num_devices));*/
|
||||
|
||||
/*printf("uhyve.c: before for loop.\n");*/
|
||||
/*for (int d = 0; d < 1; d++) {*/
|
||||
/*printf("uhyve.c: for loop: before dev ptr definition.\n");*/
|
||||
/*[>struct ibv_device* dest_device_guest = guest_mem + (size_t)args->devices + d*sizeof(struct ibv_device);<]*/
|
||||
/*printf("uhyve.c: device name: %s\n", temp_dev_list[d]->name);*/
|
||||
/*printf("uhyve.c: for loop: before memcpy device struct.\n args->devices val: %s\n", args->devices);*/
|
||||
/*memcpy(args->devices, temp_dev_list[d], sizeof(struct ibv_device));*/
|
||||
/*}*/
|
||||
|
||||
/*memcpy(uhyve_netinfo->mac_str, uhyve_get_mac(), 18);*/
|
||||
/*memcpy(args->ret, ibv_get_device_list((int*)(guest_mem+(size_t)args->num_devices)), 18);*/
|
||||
/*args->ret = ibv_get_device_list((int*)(guest_mem+(size_t)args->num_devices));*/
|
||||
|
||||
printf("uhyve.c: before break.\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_GET_DEVICE_NAME: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
|
@ -984,7 +1004,7 @@ static int vcpu_loop(void)
|
|||
args->ret = ibv_get_device_name((struct ibv_device*)(guest_mem+(size_t)args->device));
|
||||
printf("UHYVE_PORT_IBV_GET_DEVICE_NAME\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
default:
|
||||
err(1, "KVM: unhandled KVM_EXIT_IO at port 0x%x, direction %d\n", run->io.port, run->io.direction);
|
||||
|
@ -994,7 +1014,7 @@ static int vcpu_loop(void)
|
|||
|
||||
case KVM_EXIT_FAIL_ENTRY:
|
||||
err(1, "KVM: entry failure: hw_entry_failure_reason=0x%llx\n",
|
||||
run->fail_entry.hardware_entry_failure_reason);
|
||||
run->fail_entry.hardware_entry_failure_reason);
|
||||
break;
|
||||
|
||||
case KVM_EXIT_INTERNAL_ERROR:
|
||||
|
|
|
@ -32,8 +32,6 @@
|
|||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
|
||||
/*#include <verbs.h> // GEHT, brauche ich aber nicht?*/
|
||||
|
||||
#include <hermit/ibv.h> // Geht per cmake copy workaround
|
||||
|
||||
#define N 255
|
||||
|
@ -50,21 +48,23 @@ int main(int argc, char** argv)
|
|||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/*struct ibv_device **dev_list;*/
|
||||
/*int num_devices;*/
|
||||
struct ibv_device **dev_list;
|
||||
int num_devices;
|
||||
|
||||
printf("before get dev list.\n");
|
||||
|
||||
/*dev_list = h_ibv_get_device_list(&num_devices);*/
|
||||
/*printf("after get dev list.\n");*/
|
||||
h_ibv_get_device_list(&num_devices);
|
||||
printf("after get dev list.\n");
|
||||
|
||||
/*printf("char name: %s", dev_list[0]->name);*/
|
||||
printf("num devices: %s\n", num_devices);
|
||||
/*printf("first device name: %s\n", (*dev_list)->name);*/
|
||||
|
||||
/*if (!dev_list) {*/
|
||||
/*perror("Failed to get IB devices list");*/
|
||||
/*return 1;*/
|
||||
/*}*/
|
||||
/*printf("after dev list check.\n");*/
|
||||
printf("after dev list check.\n");
|
||||
|
||||
/*const char* dev_name = h_ibv_get_device_name(dev_list[0]);*/
|
||||
/*printf("after get device name.\n");*/
|
||||
|
|
Loading…
Add table
Reference in a new issue