1/*  *********************************************************************
2    *  Broadcom Common Firmware Environment (CFE)
3    *
4    *  Verification Test APIs			File: vapi.h
5    *
6    *  This module contains special low-level routines for use
7    *  by verification programs.
8    *
9    *  Author:  Mitch Lichtenberg
10    *
11    *********************************************************************
12    *
13    *  Copyright 2000,2001,2002,2003
14    *  Broadcom Corporation. All rights reserved.
15    *
16    *  This software is furnished under license and may be used and
17    *  copied only in accordance with the following terms and
18    *  conditions.  Subject to these conditions, you may download,
19    *  copy, install, use, modify and distribute modified or unmodified
20    *  copies of this software in source and/or binary form.  No title
21    *  or ownership is transferred hereby.
22    *
23    *  1) Any source code used, modified or distributed must reproduce
24    *     and retain this copyright notice and list of conditions
25    *     as they appear in the source file.
26    *
27    *  2) No right is granted to use any trade name, trademark, or
28    *     logo of Broadcom Corporation.  The "Broadcom Corporation"
29    *     name may not be used to endorse or promote products derived
30    *     from this software without the prior written permission of
31    *     Broadcom Corporation.
32    *
33    *  3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
34    *     IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
35    *     WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
36    *     PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
37    *     SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
38    *     PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
39    *     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
40    *     (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
41    *     GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
42    *     BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
43    *     OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
44    *     TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
45    *     THE POSSIBILITY OF SUCH DAMAGE.
46    ********************************************************************* */
47
48
49#define VAPI_EPTSEAL		0x56415049
50#define VAPI_CFESEAL		0xCFE10000
51#define VAPI_SEAL_MASK		0xFFFF0000
52#define VAPI_FMT_MASK		0x000000FF
53#define VAPI_PRID_MASK		0x0000FF00
54
55#define VAPI_DIAG_ENTRY		0x80020000
56#define VAPI_DIAG_ENTRY_UNC	0xA0020000
57#define VAPI_DIAG_ENTRY_MC	0xBFD00000
58#define VAPI_MAGIC_NUMBER	0x1CFE2CFE3CFE4CFE
59#define VAPI_MAGIC_NUMBER_UNC	0x0CFE1CFE2CFE3CFE
60#define VAPI_MAGIC_NUMBER_MC	0xACFEBCFECCFEDCFE
61
62#define VAPI_FMT_GPRS		0
63#define VAPI_FMT_SOC		1
64#define VAPI_FMT_DATA		2
65#define VAPI_FMT_BUFFER		3
66#define VAPI_FMT_TRACE		4
67#define VAPI_FMT_EXIT		5
68#define VAPI_FMT_FPRS		6
69
70#define VAPI_PRNUM_SHIFT	8
71
72#define VAPI_REC_SIGNATURE	0
73#define VAPI_REC_SIZE		8
74#define VAPI_REC_RA		16
75#define VAPI_REC_DATA		24
76
77#define VAPI_IDX_SIGNATURE	0
78#define VAPI_IDX_SIZE		1
79#define VAPI_IDX_RA		2
80#define VAPI_IDX_DATA		3
81
82
83#define VAPI_FUNC_EXIT		0x9fc00510
84#define VAPI_FUNC_DUMPGPRS	0x9fc00520
85#define VAPI_FUNC_SETLOG	0x9fc00530
86#define VAPI_FUNC_LOGVALUE	0x9fc00540
87#define VAPI_FUNC_LOGDATA	0x9fc00550
88#define VAPI_FUNC_LOGTRACE	0x9fc00560
89#define VAPI_FUNC_LOGSOC	0x9fc00570
90#define VAPI_FUNC_LOGGPRS	0x9fc00580
91#define VAPI_FUNC_DUMPSTRING	0x9fc00590
92#define VAPI_FUNC_SETLEDS	0x9fc005a0
93#define VAPI_FUNC_LOGFPRS	0x9fc005b0
94
95
96#define VAPI_LOG_SETBUF(start,end)					\
97	.set push ;							\
98	.set reorder ;							\
99	la	a0, start ;						\
100	la	a1, end ;						\
101	li	k0, VAPI_FUNC_SETLOG ;					\
102	jalr	k0 ;							\
103	.set pop
104
105#define VAPI_EXIT_CONST(val)						\
106	.set push ;							\
107	.set reorder ;							\
108	li	a0, val ;						\
109	li	k0, VAPI_FUNC_EXIT ;					\
110	jr	k0 ;							\
111	.set pop
112
113#define VAPI_EXIT_REG(val)						\
114	.set push ;							\
115	.set reorder ;							\
116	move	a0, val ;						\
117	li	k0, VAPI_FUNC_EXIT ;					\
118	jr	k0 ;							\
119	.set pop
120
121#define VAPI_LOG_CONST(id,value)					\
122	.set push ;							\
123	.set reorder ;							\
124	li	a0, id ;						\
125	li	a1, value ;						\
126	li	k0, VAPI_FUNC_LOGVALUE ;				\
127	jalr	k0 ;							\
128	.set pop
129
130#define VAPI_LOG_REG(id,value)						\
131	.set push ;							\
132	.set reorder ;							\
133	li	a0, id ;						\
134	move	a1, value ;						\
135	li	k0, VAPI_FUNC_LOGVALUE ;				\
136	jalr	k0 ;							\
137	.set pop
138
139#define VAPI_LOG_BUFFER(id,addr,nwords)					\
140	.set push ;							\
141	.set reorder ;							\
142	li	a0,id ;							\
143	la	a1,addr ;						\
144	li	a2,nwords ;						\
145	li	k0, VAPI_FUNC_LOGDATA ;					\
146	jalr	k0 ;							\
147	.set pop
148
149#define VAPI_PUTS(text)							\
150	.set push ;							\
151	.set reorder ;							\
152	b	1f ;							\
1532:	.asciz text ;							\
154	.align 4 ;							\
1551:	la	a0, 2b ;						\
156	li	k0, VAPI_FUNC_DUMPSTRING ;				\
157	jalr	k0 ;							\
158	.set pop
159
160#define VAPI_PRINTGPRS()						\
161	.set push ;							\
162	.set reorder ;							\
163	li	k0, VAPI_FUNC_DUMPGPRS ;				\
164	jalr	k0 ;							\
165	.set pop
166
167#define VAPI_LOG_GPRS(id)						\
168	.set push ;							\
169	.set reorder ;							\
170	li	a0, id ;						\
171	li	k0, VAPI_FUNC_LOGGPRS ;					\
172	jalr	k0 ;							\
173	.set pop
174
175#define VAPI_LOG_FPRS(id)						\
176	.set push ;							\
177	.set reorder ;							\
178	li	a0, id ;						\
179	li	k0, VAPI_FUNC_LOGFPRS ;					\
180	jalr	k0 ;							\
181	.set pop
182
183#define VAPI_LOG_TRACE(id)						\
184	.set push ;							\
185	.set reorder ;							\
186	li	a0, id ;						\
187	li	k0, VAPI_FUNC_LOGTRACE ;				\
188	jalr	k0 ;							\
189	.set pop
190
191#define VAPI_LOG_SOCSTATE(id,bits)					\
192	.set push ;							\
193	.set reorder ;							\
194	li	a0, id ;						\
195	li	a1, bits ;						\
196	li	k0, VAPI_FUNC_LOGSOC ;					\
197	jalr	k0 ;							\
198	.set pop
199
200#define VAPI_SETLEDS(a,b,c,d)						\
201	.set push ;							\
202	.set reorder ;							\
203	li	a0, ((a) << 24) | ((b) << 16) | ((c) << 8) | (d) ;	\
204	li	k0, VAPI_FUNC_SETLEDS ;					\
205	jalr	k0 ;							\
206	.set pop
207
208#ifndef SOC_AGENT_MC0
209#define SOC_AGENT_MC0 0x00000001
210#define SOC_AGENT_MC1 0x00000002
211#define SOC_AGENT_MC 0x00000003
212#define SOC_AGENT_L2 0x00000004
213#define SOC_AGENT_MACDMA0 0x00000008
214#define SOC_AGENT_MACDMA1 0x00000010
215#define SOC_AGENT_MACDMA2 0x00000020
216#define SOC_AGENT_MACDMA 0x00000038
217#define SOC_AGENT_MACRMON0 0x00000040
218#define SOC_AGENT_MACRMON1 0x00000080
219#define SOC_AGENT_MACRMON2 0x00000100
220#define SOC_AGENT_MACRMON 0x000001C0
221#define SOC_AGENT_MAC0 0x00000200
222#define SOC_AGENT_MAC1 0x00000400
223#define SOC_AGENT_MAC2 0x00000800
224#define SOC_AGENT_MAC 0x00000E00
225#define SOC_AGENT_DUART 0x00001000
226#define SOC_AGENT_GENCS 0x00002000
227#define SOC_AGENT_GEN 0x00004000
228#define SOC_AGENT_GPIO 0x00008000
229#define SOC_AGENT_SMBUS0 0x00010000
230#define SOC_AGENT_SMBUS1 0x00020000
231#define SOC_AGENT_SMBUS 0x00030000
232#define SOC_AGENT_TIMER 0x00040000
233#define SOC_AGENT_SCD 0x00080000
234#define SOC_AGENT_BUSERR 0x00100000
235#define SOC_AGENT_DM 0x00200000
236#define SOC_AGENT_IMR0 0x00400000
237#define SOC_AGENT_IMR1 0x00800000
238#define SOC_AGENT_IMR 0x00C00000
239#endif
240
241
242
243