Page MenuHomeFreeBSD

D6247.id16041.diff
No OneTemporary

D6247.id16041.diff

Index: sys/dev/bhnd/bhnd.h
===================================================================
--- sys/dev/bhnd/bhnd.h
+++ sys/dev/bhnd/bhnd.h
@@ -39,6 +39,7 @@
#include "bhnd_ids.h"
#include "bhnd_types.h"
+#include "bhnd_debug.h"
#include "bhnd_bus_if.h"
extern devclass_t bhnd_devclass;
Index: sys/dev/bhnd/bhnd_debug.h
===================================================================
--- /dev/null
+++ sys/dev/bhnd/bhnd_debug.h
@@ -0,0 +1,116 @@
+/*-
+ * Copyright (c) 2016 Michael Zhilin <mizhka@gmail.com>
+ * 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.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
+ * redistribution must be conditioned upon including a substantially
+ * similar Disclaimer requirement for further binary redistribution.
+ *
+ * NO WARRANTY
+ * 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 NONINFRINGEMENT, MERCHANTIBILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
+ */
+
+/* $FreeBSD$ */
+
+#ifndef _BHND_BHND_DEBUG_H_
+#define _BHND_BHND_DEBUG_H_
+
+#include <sys/systm.h>
+
+#define BHND_WARN_LEVEL 0x00
+#define BHND_INFO_LEVEL 0x10
+#define BHND_DEBUG_LEVEL 0x20
+#define BHND_TRACE_LEVEL 0x30
+
+#if !(defined(BHND_LOGGING))
+#define BHND_LOGGING BHND_DEBUG_LEVEL
+#endif
+
+#if BHND_LOGGING >= BHND_DEBUG_LEVEL
+#define BHND_LOGPRINT(level, fmt, ...) {printf("[BHND " level "] => %s:%d: " fmt, __func__, __LINE__, ## __VA_ARGS__); printf("\n");}
+#define BHND_DEVPRINT(dev, level, fmt, ...) {device_printf(dev, "[BHND " level "] => %s:%d: " fmt, __func__, __LINE__, ## __VA_ARGS__); printf("\n");}
+#else /* BHND_LOGGING < BHND_DEBUG_LEVEL */
+#define BHND_LOGPRINT(level, fmt, ...) {printf("bhnd: " fmt, ## __VA_ARGS__); printf("\n");}
+#define BHND_DEVPRINT(dev, level, fmt, ...) {device_printf(dev, "bhnd: " fmt, ## __VA_ARGS__); printf("\n");}
+#endif /* BHND_LOGGING >= BHND_DEBUG_LEVEL */
+
+#define BHND_ERROR(fmt, ...) BHND_LOGPRINT("ERROR", fmt, ## __VA_ARGS__)
+#define BHND_ERROR_DEV(dev, fmt, ...) BHND_DEVPRINT(dev, "ERROR", fmt, ## __VA_ARGS__)
+
+#if BHND_LOGGING >= BHND_WARN_LEVEL
+#define BHND_WARN(fmt, ...) BHND_LOGPRINT("!!!!!", fmt, ## __VA_ARGS__)
+#define BHND_WARN_DEV(dev, fmt, ...) BHND_DEVPRINT(dev, "!!!!!", fmt, ## __VA_ARGS__)
+
+#if BHND_LOGGING >= BHND_INFO_LEVEL
+#define BHND_INFO(fmt, ...) BHND_LOGPRINT(" info", fmt, ## __VA_ARGS__)
+#define BHND_INFO_DEV(dev, fmt, ...) BHND_DEVPRINT(dev, " info", fmt, ## __VA_ARGS__)
+
+#if BHND_LOGGING >= BHND_DEBUG_LEVEL
+#define BHND_DEBUG(fmt, ...) if(bootverbose) BHND_LOGPRINT("debug", fmt, ## __VA_ARGS__)
+#define BHND_DEBUG_DEV(dev, fmt, ...) if(bootverbose) BHND_DEVPRINT(dev, "debug", fmt, ## __VA_ARGS__)
+
+#if BHND_LOGGING >= BHND_TRACE_LEVEL
+#define BHND_TRACE(fmt, ...) if(bootverbose) BHND_LOGPRINT("trace", fmt, ## __VA_ARGS__)
+#define BHND_TRACE_DEV(dev, fmt, ...) if(bootverbose) BHND_DEVPRINT(dev, "trace", fmt, ## __VA_ARGS__)
+
+#endif /* BHND_LOGGING >= BHND_TRACE_LEVEL */
+#endif /* BHND_LOGGING >= BHND_DEBUG_LEVEL */
+#endif /* BHND_LOGGING >= BHND_INFO_LEVEL */
+#endif /* BHND_LOGGING >= BHND_WARN_LEVEL */
+
+/*
+ * Empty defines without device context
+ */
+#if !(defined(BHND_WARN))
+#define BHND_WARN(fmt, ...);
+#endif
+
+#if !(defined(BHND_INFO))
+#define BHND_INFO(fmt, ...);
+#endif
+
+#if !(defined(BHND_DEBUG))
+#define BHND_DEBUG(fmt, ...);
+#endif
+
+#if !(defined(BHND_TRACE))
+#define BHND_TRACE(fmt, ...);
+#endif
+
+/*
+ * Empty defines with device context
+ */
+#if !(defined(BHND_WARN_DEV))
+#define BHND_WARN_DEV(dev, fmt, ...);
+#endif
+
+#if !(defined(BHND_INFO_DEV))
+#define BHND_INFO_DEV(dev, fmt, ...);
+#endif
+
+#if !(defined(BHND_DEBUG_DEV))
+#define BHND_DEBUG_DEV(dev, fmt, ...);
+#endif
+
+#if !(defined(BHND_TRACE_DEV))
+#define BHND_TRACE_DEV(dev, fmt, ...);
+#endif
+
+#endif /* _BHND_BHND_DEBUG_H_ */

File Metadata

Mime Type
text/plain
Expires
Mon, Oct 5, 12:32 AM (1 h, 8 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
40217129
Default Alt Text
D6247.id16041.diff (4 KB)

Event Timeline