summaryrefslogtreecommitdiffstats
path: root/private/ntos/nthals/halfire/ppc/fpdebug.h
blob: b39899b8650e1f56506daf8af815561d8e207a17 (plain) (blame)
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/*
 * Copyright (c) 1995 FirePower Systems, Inc.
 * DO NOT DISTRIBUTE without permission
 *
 * $RCSfile: fpdebug.h $
 * $Revision: 1.30 $
 * $Date: 1996/01/11 07:06:23 $
 * $Locker:  $
 */

#ifndef _FPDEBUG_H
#define _FPDEBUG_H

#include "fpdcc.h"	// to cover the led writing macro.....

//
// This file provides an interface that allows individual debug printfs
// to be turned on and off in the HAL based on an environment variable.
// It also provides a means for turning on/off debug functionality
// (like auto stopping at a break point).
//

//
// Externs for global variables stuffed at run-time
// Default values are provided in sources files
//
#if defined(HALDEBUG_ON)
extern int HalpDebugValue;
#endif

//
// Macros used in C code to access the debug funcationality
//

//
// Since DBG is always defined ( at least as of 2/6/95 ), must change the test
// to look at the value of DBG
//
// #if !defined(DBG)
// #if DBG != 1
#if !defined(HALDEBUG_ON)
#define HDBG(_value, _str)
#define RDBG(_value, _str)
#else
#define DBGSET(_value) ((_value)&(HalpDebugValue))

#define HDBG(_value, _str)		\
	{				\
		if (DBGSET(_value)) {	\
			_str;		\
		}			\
	}

#endif

//
// Defines used in the C code for each of the values,
// so someone can tell what bits to turn on.
//
// Note: behavioral changes are at the top portion of the word and
// simple informational ones are at the bottom portion of the word.
//
#define DBG_GENERAL			0x00000001
#define DBG_EXTERNAL			0x00000002
#define DBG_INTERNAL			0x00000004
#define DBG_INTERRUPTS			0x00000008
#define DBG_DUMPTREE			0x00000010
#define DBG_IPI				0x00000020
#define DBG_DBAT			0x00000040
#define DBG_REGISTRY			0x00000080
#define DBG_DMA				0x00000100
#define DBG_ISA				0x00000200
#define DBG_MPINTS			0x00000400
#define DBG_PCI				0x00000800
#define DBG_DISPLAY			0x00001000
#define DBG_I2C				0x00002000
#define DBG_TIME			0x00004000

#define DBG_BUS				0x04000000
#define DBG_DISPMEMCOHERE		0x08000000
#define DBG_DISPNOCACHE			0x10000000
#define DBG_COLORS			0x20000000
#define DBG_BREAK			0x40000000
#define DBG_PROC1DBG			0x80000000

#define PRNTGENRL(_str)	HDBG(DBG_GENERAL, _str)
#define PRNTINTR(_str)	HDBG(DBG_INTERRUPTS, _str)
#define PRNTPCI(_str)	HDBG(DBG_PCI, _str)
#define PRNTREE(_str)	HDBG(DBG_DUMPTREE, _str)
#define PRNTDISP(_str)	HDBG(DBG_DISPLAY, _str)
#define PRNTI2C(_str)	HDBG(DBG_I2C, _str)
#define PRNTTIME(_str)	HDBG(DBG_TIME, _str)


//
// Assert macro definitions for the HAL - Checked/Debug Builds only
//
#if defined(HALDEBUG_ON)
#define _assert_begin(_exp) \
	ULONG holdit,ee,CpuId;			\
	ee = MSR(EE);					\
	HalpDisableInterrupts();		\
	rScratchPad2 = 0xdeadbeef;		\
	FireSyncRegister();		        \
	CpuId = GetCpuId();				\
	holdit = RInterruptMask(CpuId);	\
	RInterruptMask(CpuId) = 0x0;	\
	WaitForRInterruptMask(CpuId);	\
	HalpDebugPrint("HAssertion Failure at line %d in file %s\n", \
			__LINE__, __FILE__);	\
	HalpDebugPrint("HAssertion: " #_exp "\n");


#define _assert_end \
	HalpDebugPrint("Calling Debugger\n");	\
	DbgBreakPoint();				\
	RInterruptMask(CpuId) = holdit;	\
	if (ee) {						\
	    HalpEnableInterrupts();		\
	}								\

#define HASSERT(_exp)					\
	if (!(_exp)) { 						\
		_assert_begin(_exp);			\
		_assert_end;					\
	}


#define HASSERTMSG(_exp, _msg)			\
	if (!(_exp)) {						\
	        _assert_begin(_exp); 		\
		HalpDebugPrint("HAssertion Message: %s\n", _msg); \
	        _assert_end;				\
	}

#define HASSERTEXEC(_exp, _exec)		\
	if (!(_exp)) {						\
	        _assert_begin(_exp);		\
		{								\
			_exec;						\
		}								\
	        _assert_end;				\
	}


#define SET_LEDS(DATA)		\
	rDccIndex = dccGpioA;	\
	FireSyncRegister();	\
	rDccData = DATA;	\
	FireSyncRegister();

#define GET_LEDS(DATA)		\
	rDccIndex = dccGpioA;	\
	FireSyncRegister();	\
	DATA = rDccData;

#define TURN_ON(x,y)		\
	GET_LEDS(x);		\
	SET_LEDS((x | 0xf0 ) & ~(x));

#else // Free/Non-Debug Builds

#define HASSERT(_exp)
#define HASSERTEXEC(_exp, _msg)
#define HASSERTMSG(_exp, _exec)
#define SET_LEDS(DATA)
#define GET_LEDS(DATA)
#define TURN_ON(x,y)
#endif	// HALDEBUG_ON

#endif // _FPDEBUG_H