aboutsummaryrefslogtreecommitdiff
path: root/drivers/gud/MobiCoreKernelApi/common.h
blob: b6c404b8b235f107560bcb3e67a8325c015bd949 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
 * Copyright (c) 2013 TRUSTONIC LIMITED
 * All Rights Reserved.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * version 2 as published by the Free Software Foundation.
 *
 * This program 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 General Public License for more details.
 */
/*
 * Common data types for use by the MobiCore Kernel API Driver
 */
#ifndef _MC_KAPI_COMMON_H
#define _MC_KAPI_COMMON_H

#include "connection.h"
#include "mcinq.h"

void mcapi_insert_connection(struct connection *connection);
void mcapi_remove_connection(uint32_t seq);
unsigned int mcapi_unique_id(void);

#define MC_DAEMON_PID			0xFFFFFFFF
#define MC_DRV_MOD_DEVNODE_FULLPATH	"/dev/mobicore"

/* dummy function helper macro */
#define DUMMY_FUNCTION()		do {} while (0)

/* Found in main.c */
extern struct device *mc_kapi;

#define MCDRV_ERROR(dev, txt, ...) \
	dev_err(dev, "%s() ### ERROR: " txt, __func__, ##__VA_ARGS__)

#if defined(DEBUG)

/* #define DEBUG_VERBOSE */
#if defined(DEBUG_VERBOSE)
#define MCDRV_DBG_VERBOSE		MCDRV_DBG
#else
#define MCDRV_DBG_VERBOSE(...)		DUMMY_FUNCTION()
#endif

#define MCDRV_DBG(dev, txt, ...) \
	dev_info(dev, "%s(): " txt, __func__, ##__VA_ARGS__)

#define MCDRV_DBG_WARN(dev, txt, ...) \
	dev_warn(dev, "%s() WARNING: " txt, __func__, ##__VA_ARGS__)

#define MCDRV_DBG_ERROR(dev, txt, ...) \
	dev_err(dev, "%s() ### ERROR: " txt, __func__, ##__VA_ARGS__)

#define MCDRV_ASSERT(cond) \
	do { \
		if (unlikely(!(cond))) { \
			panic("mc_kernelapi Assertion failed: %s:%d\n", \
			      __FILE__, __LINE__); \
		} \
	} while (0)

#elif defined(NDEBUG)

#define MCDRV_DBG_VERBOSE(...)		DUMMY_FUNCTION()
#define MCDRV_DBG(...)			DUMMY_FUNCTION()
#define MCDRV_DBG_WARN(...)		DUMMY_FUNCTION()
#define MCDRV_DBG_ERROR(...)		DUMMY_FUNCTION()

#define MCDRV_ASSERT(...)		DUMMY_FUNCTION()

#else
#error "Define DEBUG or NDEBUG"
#endif /* [not] defined(DEBUG_MCMODULE) */

#define assert(expr)			MCDRV_ASSERT(expr)

#endif /* _MC_KAPI_COMMON_H */