1/*
2 * Copyright (c) 1998-2009 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24
25#ifndef _IOKIT_IO_FIREWIRE_SERIAL_BUS_PROTOCOL_TRANSPORT_DEBUGGING_H_
26#define _IOKIT_IO_FIREWIRE_SERIAL_BUS_PROTOCOL_TRANSPORT_DEBUGGING_H_
27
28#include <stdint.h>
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34
35#define FWSBP_SYSCTL	"debug.FirewireSBPTransport"
36
37typedef struct FWSysctlArgs
38{
39	uint32_t		type;
40	uint32_t		operation;
41	uint32_t		debugFlags;
42} FWSysctlArgs;
43
44
45#define kFWTypeDebug	'FRWR'
46
47enum
48{
49	kFWOperationGetFlags 	= 0,
50	kFWOperationSetFlags	= 1
51};
52
53
54extern UInt32	gSBP2DiskDebugFlags;
55
56enum
57{
58	kSBP2DiskEnableDebugLoggingBit		= 0,
59	kSBP2DiskEnableTracePointsBit		= 1,
60
61	kSBP2DiskEnableDebugLoggingMask		= (1 << kSBP2DiskEnableDebugLoggingBit),
62	kSBP2DiskEnableTracePointsMask		= (1 << kSBP2DiskEnableTracePointsBit),
63};
64
65
66#if KERNEL
67
68void IOFireWireSerialBusProtocolTransportDebugAssert ( const char * componentNameString,
69                                                       const char * assertionString,
70                                                       const char * exceptionLabelString,
71                                                       const char * errorString,
72                                                       const char * fileName,
73                                                       long lineNumber,
74                                                       int errorCode );
75
76#define DEBUG_ASSERT_MESSAGE( componentNameString, \
77	assertionString, \
78	exceptionLabelString, \
79	errorString, \
80	fileName, \
81	lineNumber, \
82	error ) \
83	IOFireWireSerialBusProtocolTransportDebugAssert( componentNameString, \
84	assertionString, \
85	exceptionLabelString, \
86	errorString, \
87	fileName, \
88	lineNumber, \
89	error )
90
91
92#endif	/* KERNEL */
93
94
95#include <AssertMacros.h>
96
97
98// Other helpful macros (maybe some day these will make
99// their way into /usr/include/AssertMacros.h)
100
101#define require_success( errorCode, exceptionLabel ) \
102	require( kIOReturnSuccess == (errorCode), exceptionLabel )
103
104#define require_success_action( errorCode, exceptionLabel, action ) \
105	require_action( kIOReturnSuccess == (errorCode), exceptionLabel, action )
106
107#define require_success_quiet( errorCode, exceptionLabel ) \
108	require_quiet( kIOReturnSuccess == (errorCode), exceptionLabel )
109
110#define require_success_action_quiet( errorCode, exceptionLabel, action ) \
111	require_action_quiet( kIOReturnSuccess == (errorCode), exceptionLabel, action )
112
113#define require_success_string( errorCode, exceptionLabel, message ) \
114	require_string( kIOReturnSuccess == (errorCode), exceptionLabel, message )
115
116#define require_success_action_string( errorCode, exceptionLabel, action, message ) \
117	require_action_string( kIOReturnSuccess == (errorCode), exceptionLabel, action, message )
118
119
120#define require_nonzero( obj, exceptionLabel ) \
121	require( ( 0 != obj ), exceptionLabel )
122
123#define require_nonzero_action( obj, exceptionLabel, action ) \
124	require_action( ( 0 != obj ), exceptionLabel, action )
125
126#define require_nonzero_quiet( obj, exceptionLabel ) \
127	require_quiet( ( 0 != obj ), exceptionLabel )
128
129#define require_nonzero_action_quiet( obj, exceptionLabel, action ) \
130	require_action_quiet( ( 0 != obj ), exceptionLabel, action )
131
132#define require_nonzero_string( obj, exceptionLabel, message ) \
133	require_string( ( 0 != obj ), exceptionLabel, message )
134
135#define require_nonzero_action_string( obj, exceptionLabel, action, message ) \
136	require_action_string( ( 0 != obj ), exceptionLabel, action, message )
137
138
139#define DEBUG_UNUSED( X )		( void )( X )
140
141#ifdef __cplusplus
142}
143#endif
144
145
146#endif	/* _IOKIT_IO_FIREWIRE_SERIAL_BUS_PROTOCOL_TRANSPORT_DEBUGGING_H_ */