summaryrefslogtreecommitdiffstats
path: root/freebsd/sys/sys
diff options
context:
space:
mode:
authorSichen Zhao <1473996754@qq.com>2017-07-13 10:24:04 +0800
committerSebastian Huber <sebastian.huber@embedded-brains.de>2017-07-13 07:30:02 +0200
commitbd3c01a1260ced850ee348809712be1f2db24772 (patch)
treea0e615dbc5eb71b3f8d43f77db523498af105e77 /freebsd/sys/sys
parenttermios: Interrupt server API changes (diff)
downloadrtems-libbsd-bd3c01a1260ced850ee348809712be1f2db24772.tar.bz2
Import am335x usb driver file from FreeBSD.
Diffstat (limited to 'freebsd/sys/sys')
-rw-r--r--freebsd/sys/sys/timeet.h106
-rw-r--r--freebsd/sys/sys/watchdog.h115
2 files changed, 221 insertions, 0 deletions
diff --git a/freebsd/sys/sys/timeet.h b/freebsd/sys/sys/timeet.h
new file mode 100644
index 00000000..3d50e51d
--- /dev/null
+++ b/freebsd/sys/sys/timeet.h
@@ -0,0 +1,106 @@
+/*-
+ * Copyright (c) 2010-2013 Alexander Motin <mav@FreeBSD.org>
+ * 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,
+ * without modification, immediately at the beginning of the file.
+ * 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 ``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 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.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _SYS_TIMEEC_H_
+#define _SYS_TIMEEC_H_
+
+#ifndef _KERNEL
+#error "no user-serviceable parts inside"
+#endif
+
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/queue.h>
+#include <sys/time.h>
+
+/*
+ * `struct eventtimer' is the interface between the hardware which implements
+ * a event timer and the MI code which uses this to receive time events.
+ */
+
+struct eventtimer;
+typedef int et_start_t(struct eventtimer *et,
+ sbintime_t first, sbintime_t period);
+typedef int et_stop_t(struct eventtimer *et);
+typedef void et_event_cb_t(struct eventtimer *et, void *arg);
+typedef int et_deregister_cb_t(struct eventtimer *et, void *arg);
+
+struct eventtimer {
+ SLIST_ENTRY(eventtimer) et_all;
+ /* Pointer to the next event timer. */
+ const char *et_name;
+ /* Name of the event timer. */
+ int et_flags;
+ /* Set of capabilities flags: */
+#define ET_FLAGS_PERIODIC 1
+#define ET_FLAGS_ONESHOT 2
+#define ET_FLAGS_PERCPU 4
+#define ET_FLAGS_C3STOP 8
+#define ET_FLAGS_POW2DIV 16
+ int et_quality;
+ /*
+ * Used to determine if this timecounter is better than
+ * another timecounter. Higher means better.
+ */
+ int et_active;
+ u_int64_t et_frequency;
+ /* Base frequency in Hz. */
+ sbintime_t et_min_period;
+ sbintime_t et_max_period;
+ et_start_t *et_start;
+ et_stop_t *et_stop;
+ et_event_cb_t *et_event_cb;
+ et_deregister_cb_t *et_deregister_cb;
+ void *et_arg;
+ void *et_priv;
+ struct sysctl_oid *et_sysctl;
+ /* Pointer to the event timer's private parts. */
+};
+
+extern struct mtx et_eventtimers_mtx;
+#define ET_LOCK() mtx_lock(&et_eventtimers_mtx)
+#define ET_UNLOCK() mtx_unlock(&et_eventtimers_mtx)
+
+/* Driver API */
+int et_register(struct eventtimer *et);
+int et_deregister(struct eventtimer *et);
+void et_change_frequency(struct eventtimer *et, uint64_t newfreq);
+/* Consumer API */
+struct eventtimer *et_find(const char *name, int check, int want);
+int et_init(struct eventtimer *et, et_event_cb_t *event,
+ et_deregister_cb_t *deregister, void *arg);
+int et_start(struct eventtimer *et, sbintime_t first, sbintime_t period);
+int et_stop(struct eventtimer *et);
+int et_ban(struct eventtimer *et);
+int et_free(struct eventtimer *et);
+
+#ifdef SYSCTL_DECL
+SYSCTL_DECL(_kern_eventtimer);
+#endif
+#endif /* !_SYS_TIMETC_H_ */
+
diff --git a/freebsd/sys/sys/watchdog.h b/freebsd/sys/sys/watchdog.h
new file mode 100644
index 00000000..92c47dee
--- /dev/null
+++ b/freebsd/sys/sys/watchdog.h
@@ -0,0 +1,115 @@
+/*-
+ * Copyright (c) 2003 Poul-Henning Kamp
+ * Copyright (c) 2013 iXsystems.com,
+ * author: Alfred Perlstein <alfred@freebsd.org>
+ *
+ * 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.
+ *
+ * $FreeBSD$
+ */
+#ifndef _SYS_WATCHDOG_H
+#define _SYS_WATCHDOG_H
+
+#include <sys/ioccom.h>
+
+#define _PATH_WATCHDOG "fido"
+
+#define WDIOCPATPAT _IOW('W', 42, u_int) /* pat the watchdog */
+#define WDIOC_SETTIMEOUT _IOW('W', 43, int) /* set/reset the timer */
+#define WDIOC_GETTIMEOUT _IOR('W', 44, int) /* get total timeout */
+#define WDIOC_GETTIMELEFT _IOR('W', 45, int) /* get time left */
+#define WDIOC_GETPRETIMEOUT _IOR('W', 46, int) /* get the pre-timeout */
+#define WDIOC_SETPRETIMEOUT _IOW('W', 47, int) /* set the pre-timeout */
+/* set the action when a pre-timeout occurs see: WD_SOFT_* */
+#define WDIOC_SETPRETIMEOUTACT _IOW('W', 48, int)
+
+/* use software watchdog instead of hardware */
+#define WDIOC_SETSOFT _IOW('W', 49, int)
+#define WDIOC_SETSOFTTIMEOUTACT _IOW('W', 50, int)
+
+#define WD_ACTIVE 0x8000000
+ /*
+ * Watchdog reset, timeout set to value in WD_INTERVAL field.
+ * The kernel will arm the watchdog and unless the userland
+ * program calls WDIOCPATPAT again before the timer expires
+ * the system will reinitialize.
+ */
+
+#define WD_PASSIVE 0x0400000
+ /*
+ * Set the watchdog in passive mode.
+ * The kernel will chose an appropriate timeout duration and
+ * periodically reset the timer provided everything looks all
+ * right to the kernel.
+ */
+
+#define WD_LASTVAL 0x0200000
+ /*
+ * Use the already last used timeout value.
+ * The kernel will use as timeout the last valid timeout provided.
+ */
+
+#define WD_INTERVAL 0x00000ff
+ /*
+ * Mask for duration bits.
+ * The watchdog will have a nominal patience of 2^N * nanoseconds.
+ * Example: N == 30 gives a patience of 2^30 nanoseconds ~= 1 second.
+ * NB: Expect variance in the +/- 10-20% range.
+ */
+
+/* Handy macros for humans not used to power of two nanoseconds */
+#define WD_TO_NEVER 0
+#define WD_TO_1MS 20
+#define WD_TO_125MS 27
+#define WD_TO_250MS 28
+#define WD_TO_500MS 29
+#define WD_TO_1SEC 30
+#define WD_TO_2SEC 31
+#define WD_TO_4SEC 32
+#define WD_TO_8SEC 33
+#define WD_TO_16SEC 34
+#define WD_TO_32SEC 35
+#define WD_TO_64SEC 36
+#define WD_TO_128SEC 37
+
+/* action on pre-timeout trigger */
+#define WD_SOFT_PANIC 0x01 /* panic */
+#define WD_SOFT_DDB 0x02 /* enter debugger */
+#define WD_SOFT_LOG 0x04 /* log(9) */
+#define WD_SOFT_PRINTF 0x08 /* printf(9) */
+#define WD_SOFT_MASK 0x0f /* all of the above */
+
+#ifdef _KERNEL
+
+#include <sys/eventhandler.h>
+
+typedef void (*watchdog_fn)(void *, u_int, int *);
+
+EVENTHANDLER_DECLARE(watchdog_list, watchdog_fn);
+
+u_int wdog_kern_last_timeout(void);
+int wdog_kern_pat(u_int utim);
+#endif
+
+#endif /* _SYS_WATCHDOG_H */