summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-10-27 08:24:50 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-11-08 10:15:28 +0100
commit6de41c5fe9cbfdcc451b7760a0ffa006dcfd8a8e (patch)
tree306defe8ae75aac22fc1c6f785fc8742fd4ca20d
parentbsp/qoriq: Remove duplicate qoriq_gpio definition (diff)
downloadrtems-6de41c5fe9cbfdcc451b7760a0ffa006dcfd8a8e.tar.bz2
Provide kernel space header files
These kernel space header files must be provided for Newlib 172e2050d95b41861db858dd9bc43a3fb4a28987.
-rw-r--r--cpukit/libcsupport/Makefile.am5
-rw-r--r--cpukit/libcsupport/include/machine/_kernel_time.h169
-rw-r--r--cpukit/libcsupport/include/machine/_kernel_types.h34
-rw-r--r--cpukit/libcsupport/preinstall.am13
-rw-r--r--cpukit/libnetworking/Makefile.am1
-rw-r--r--cpukit/libnetworking/machine/_kernel_lock.h1
-rw-r--r--cpukit/libnetworking/preinstall.am4
-rw-r--r--cpukit/score/src/kern_tc.c1
-rw-r--r--testsuites/sptests/sptimecounter02/init.c2
9 files changed, 230 insertions, 0 deletions
diff --git a/cpukit/libcsupport/Makefile.am b/cpukit/libcsupport/Makefile.am
index 4fea4aa338..bf78fa0c65 100644
--- a/cpukit/libcsupport/Makefile.am
+++ b/cpukit/libcsupport/Makefile.am
@@ -23,6 +23,11 @@ include_rtems_HEADERS += include/rtems/malloc.h
include_rtems_HEADERS += include/rtems/termiostypes.h
include_rtems_HEADERS += include/rtems/gxx_wrappers.h
+include_machinedir = $(includedir)/machine
+include_machine_HEADERS =
+include_machine_HEADERS += include/machine/_kernel_time.h
+include_machine_HEADERS += include/machine/_kernel_types.h
+
## General stuff
ERROR_C_FILES = src/error.c src/__assert.c
diff --git a/cpukit/libcsupport/include/machine/_kernel_time.h b/cpukit/libcsupport/include/machine/_kernel_time.h
new file mode 100644
index 0000000000..4eeebbadea
--- /dev/null
+++ b/cpukit/libcsupport/include/machine/_kernel_time.h
@@ -0,0 +1,169 @@
+/*-
+ * Copyright (c) 2016 embedded brains GmbH
+ * 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 AUTHOR 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 AUTHOR 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.
+ */
+
+#if !defined(_SYS_TIME_H_) || !defined(_KERNEL)
+#error "must be included via <sys/time.h> in kernel space"
+#endif
+
+/* Operations on timespecs */
+#define timespecclear(tvp) ((tvp)->tv_sec = (tvp)->tv_nsec = 0)
+#define timespecisset(tvp) ((tvp)->tv_sec || (tvp)->tv_nsec)
+#define timespeccmp(tvp, uvp, cmp) \
+ (((tvp)->tv_sec == (uvp)->tv_sec) ? \
+ ((tvp)->tv_nsec cmp (uvp)->tv_nsec) : \
+ ((tvp)->tv_sec cmp (uvp)->tv_sec))
+#define timespecadd(vvp, uvp) \
+ do { \
+ (vvp)->tv_sec += (uvp)->tv_sec; \
+ (vvp)->tv_nsec += (uvp)->tv_nsec; \
+ if ((vvp)->tv_nsec >= 1000000000) { \
+ (vvp)->tv_sec++; \
+ (vvp)->tv_nsec -= 1000000000; \
+ } \
+ } while (0)
+#define timespecsub(vvp, uvp) \
+ do { \
+ (vvp)->tv_sec -= (uvp)->tv_sec; \
+ (vvp)->tv_nsec -= (uvp)->tv_nsec; \
+ if ((vvp)->tv_nsec < 0) { \
+ (vvp)->tv_sec--; \
+ (vvp)->tv_nsec += 1000000000; \
+ } \
+ } while (0)
+
+/* Operations on timevals. */
+
+#define timevalclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0)
+#define timevalisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
+#define timevalcmp(tvp, uvp, cmp) \
+ (((tvp)->tv_sec == (uvp)->tv_sec) ? \
+ ((tvp)->tv_usec cmp (uvp)->tv_usec) : \
+ ((tvp)->tv_sec cmp (uvp)->tv_sec))
+
+/* timevaladd and timevalsub are not inlined */
+
+/*
+ * Kernel to clock driver interface.
+ */
+void inittodr(time_t base);
+void resettodr(void);
+
+#define time_second _Timecounter_Time_second
+#define time_uptime _Timecounter_Time_uptime
+#define boottimebin _Timecounter_Boottimebin
+extern struct timeval boottime;
+extern struct bintime tc_tick_bt;
+extern sbintime_t tc_tick_sbt;
+extern struct bintime tick_bt;
+extern sbintime_t tick_sbt;
+extern int tc_precexp;
+extern int tc_timepercentage;
+extern struct bintime bt_timethreshold;
+extern struct bintime bt_tickthreshold;
+extern sbintime_t sbt_timethreshold;
+extern sbintime_t sbt_tickthreshold;
+
+/*
+ * Functions for looking at our clock: [get]{bin,nano,micro}[up]time()
+ *
+ * Functions without the "get" prefix returns the best timestamp
+ * we can produce in the given format.
+ *
+ * "bin" == struct bintime == seconds + 64 bit fraction of seconds.
+ * "nano" == struct timespec == seconds + nanoseconds.
+ * "micro" == struct timeval == seconds + microseconds.
+ *
+ * Functions containing "up" returns time relative to boot and
+ * should be used for calculating time intervals.
+ *
+ * Functions without "up" returns UTC time.
+ *
+ * Functions with the "get" prefix returns a less precise result
+ * much faster than the functions without "get" prefix and should
+ * be used where a precision of 1/hz seconds is acceptable or where
+ * performance is priority. (NB: "precision", _not_ "resolution" !)
+ */
+
+#define binuptime(_bt) _Timecounter_Binuptime(_bt)
+#define nanouptime(_tsp) _Timecounter_Nanouptime(_tsp)
+#define microuptime(_tvp) _Timecounter_Microuptime(_tvp)
+
+static __inline sbintime_t
+sbinuptime(void)
+{
+ struct bintime _bt;
+
+ binuptime(&_bt);
+ return (bttosbt(_bt));
+}
+
+#define bintime(_bt) _Timecounter_Bintime(_bt)
+#define nanotime(_tsp) _Timecounter_Nanotime(_tsp)
+#define microtime(_tvp) _Timecounter_Microtime(_tvp)
+
+#define getbinuptime(_bt) _Timecounter_Getbinuptime(_bt)
+#define getnanouptime(_tsp) _Timecounter_Getnanouptime(_tsp)
+#define getmicrouptime(_tvp) _Timecounter_Getmicrouptime(_tvp)
+
+static __inline sbintime_t
+getsbinuptime(void)
+{
+ struct bintime _bt;
+
+ getbinuptime(&_bt);
+ return (bttosbt(_bt));
+}
+
+#define getbintime(_bt) _Timecounter_Getbintime(_bt)
+#define getnanotime(_tsp) _Timecounter_Getnanotime(_tsp)
+#define getmicrotime(_tvp) _Timecounter_Getmicrotime(_tvp)
+
+/* Other functions */
+int itimerdecr(struct itimerval *itp, int usec);
+int itimerfix(struct timeval *tv);
+int ppsratecheck(struct timeval *, int *, int);
+int ratecheck(struct timeval *, const struct timeval *);
+void timevaladd(struct timeval *t1, const struct timeval *t2);
+void timevalsub(struct timeval *t1, const struct timeval *t2);
+int tvtohz(struct timeval *tv);
+
+#define TC_DEFAULTPERC 5
+
+#define BT2FREQ(bt) \
+ (((uint64_t)0x8000000000000000 + ((bt)->frac >> 2)) / \
+ ((bt)->frac >> 1))
+
+#define SBT2FREQ(sbt) ((SBT_1S + ((sbt) >> 1)) / (sbt))
+
+#define FREQ2BT(freq, bt) \
+{ \
+ (bt)->sec = 0; \
+ (bt)->frac = ((uint64_t)0x8000000000000000 / (freq)) << 1; \
+}
+
+#define TIMESEL(sbt, sbt2) \
+ (((sbt2) >= sbt_timethreshold) ? \
+ ((*(sbt) = getsbinuptime()), 1) : ((*(sbt) = sbinuptime()), 0))
diff --git a/cpukit/libcsupport/include/machine/_kernel_types.h b/cpukit/libcsupport/include/machine/_kernel_types.h
new file mode 100644
index 0000000000..892ec413d5
--- /dev/null
+++ b/cpukit/libcsupport/include/machine/_kernel_types.h
@@ -0,0 +1,34 @@
+/*-
+ * Copyright (c) 2016 embedded brains GmbH
+ * 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 AUTHOR 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 AUTHOR 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.
+ */
+
+#if !defined(_SYS_TYPES_H) || !defined(_KERNEL)
+#error "must be included via <sys/types.h> in kernel space"
+#endif
+
+typedef int boolean_t;
+typedef struct device *device_t;
+typedef char vm_memattr_t; /* memory attribute codes */
+typedef struct vm_page *vm_page_t;
diff --git a/cpukit/libcsupport/preinstall.am b/cpukit/libcsupport/preinstall.am
index 4b25d3c6f1..82d7abafcc 100644
--- a/cpukit/libcsupport/preinstall.am
+++ b/cpukit/libcsupport/preinstall.am
@@ -74,3 +74,16 @@ $(PROJECT_INCLUDE)/rtems/gxx_wrappers.h: include/rtems/gxx_wrappers.h $(PROJECT_
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/gxx_wrappers.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/gxx_wrappers.h
+$(PROJECT_INCLUDE)/machine/$(dirstamp):
+ @$(MKDIR_P) $(PROJECT_INCLUDE)/machine
+ @: > $(PROJECT_INCLUDE)/machine/$(dirstamp)
+PREINSTALL_DIRS += $(PROJECT_INCLUDE)/machine/$(dirstamp)
+
+$(PROJECT_INCLUDE)/machine/_kernel_time.h: include/machine/_kernel_time.h $(PROJECT_INCLUDE)/machine/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/machine/_kernel_time.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/machine/_kernel_time.h
+
+$(PROJECT_INCLUDE)/machine/_kernel_types.h: include/machine/_kernel_types.h $(PROJECT_INCLUDE)/machine/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/machine/_kernel_types.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/machine/_kernel_types.h
+
diff --git a/cpukit/libnetworking/Makefile.am b/cpukit/libnetworking/Makefile.am
index 5def014bb1..df7cd282ec 100644
--- a/cpukit/libnetworking/Makefile.am
+++ b/cpukit/libnetworking/Makefile.am
@@ -55,6 +55,7 @@ include_machine_HEADERS = machine/_align.h
include_machine_HEADERS += machine/cpu.h
include_machine_HEADERS += machine/cpufunc.h
include_machine_HEADERS += machine/in_cksum.h
+include_machine_HEADERS += machine/_kernel_lock.h
include_machine_HEADERS += machine/vmparam.h
libnetworking_a_SOURCES += machine/limits.h
diff --git a/cpukit/libnetworking/machine/_kernel_lock.h b/cpukit/libnetworking/machine/_kernel_lock.h
new file mode 100644
index 0000000000..710cecca97
--- /dev/null
+++ b/cpukit/libnetworking/machine/_kernel_lock.h
@@ -0,0 +1 @@
+/* Empty */
diff --git a/cpukit/libnetworking/preinstall.am b/cpukit/libnetworking/preinstall.am
index 53f702684d..0d7c270b2a 100644
--- a/cpukit/libnetworking/preinstall.am
+++ b/cpukit/libnetworking/preinstall.am
@@ -73,6 +73,10 @@ $(PROJECT_INCLUDE)/machine/in_cksum.h: machine/in_cksum.h $(PROJECT_INCLUDE)/mac
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/machine/in_cksum.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/machine/in_cksum.h
+$(PROJECT_INCLUDE)/machine/_kernel_lock.h: machine/_kernel_lock.h $(PROJECT_INCLUDE)/machine/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/machine/_kernel_lock.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/machine/_kernel_lock.h
+
$(PROJECT_INCLUDE)/machine/vmparam.h: machine/vmparam.h $(PROJECT_INCLUDE)/machine/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/machine/vmparam.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/machine/vmparam.h
diff --git a/cpukit/score/src/kern_tc.c b/cpukit/score/src/kern_tc.c
index 03d09971f2..65e6fea2d2 100644
--- a/cpukit/score/src/kern_tc.c
+++ b/cpukit/score/src/kern_tc.c
@@ -14,6 +14,7 @@
*/
#ifdef __rtems__
+#include <sys/lock.h>
#define _KERNEL
#define binuptime(_bt) _Timecounter_Binuptime(_bt)
#define nanouptime(_tsp) _Timecounter_Nanouptime(_tsp)
diff --git a/testsuites/sptests/sptimecounter02/init.c b/testsuites/sptests/sptimecounter02/init.c
index c7d72a8eb7..e01b1e97e1 100644
--- a/testsuites/sptests/sptimecounter02/init.c
+++ b/testsuites/sptests/sptimecounter02/init.c
@@ -16,6 +16,8 @@
#include "config.h"
#endif
+#include <sys/lock.h>
+
#define _KERNEL
#include <sys/time.h>