1 /* Misc TRAX API function definitions.
2 
3    Copyright (c) 2007-2012 Tensilica Inc.
4 
5    Permission is hereby granted, free of charge, to any person obtaining
6    a copy of this software and associated documentation files (the
7    "Software"), to deal in the Software without restriction, including
8    without limitation the rights to use, copy, modify, merge, publish,
9    distribute, sublicense, and/or sell copies of the Software, and to
10    permit persons to whom the Software is furnished to do so, subject to
11    the following conditions:
12 
13    The above copyright notice and this permission notice shall be included
14    in all copies or substantial portions of the Software.
15 
16    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19    IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20    CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21    TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22    SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  */
23 
24 #ifndef _TRAX_API_H_
25 #define _TRAX_API_H_
26 
27 #include <xtensa-isa.h>
28 #include <xtensa-params.h>
29 #include "tpack.h"
30 #include "traxreg.h"
31 
32 #include "xdm-regs.h"
33 
34 /*  Flags for trax_stop():  */
35 #define TRAX_STOP_HALT	0x0001	/* halt immediately, don't wait for post-stop-trigger capture */
36 #define TRAX_STOP_QUIET	0x0002	/* don't display informative messages */
37 
38 
39 /*
40  *  Describes a TRAX channel (based on tpack).
41  */
42 typedef struct {
43     tpack_channel	chan;		/* channel structure header */
44     /*  Per TRAX unit information:  */
45     int			trax_version;	/* TRAX_ID_VER(id), one of TRAX_VER_xxx macros */
46     unsigned long	trax_tram_size;	/* size of trace RAM in bytes */
47     int			trax_erratum10;	/* set if TRAX 1.0 erratum workarounds needed */
48     int			trax_erratum20;	/* set if TRAX 2.0 erratum workaround needed (PR 22161)*/
49     int			trax_erratum20_size;
50     int			trax_has_busy;	/* has trace-busy feature */
51     int			trax_has_atb;	/* has ATB feature */
52     /*FIXME: add various features:  coresight regs (don't call it that), APB, ATB, TRAM, ... */
53 } trax_channel;
54 
55 
56 /*  Prototypes:  */
57 
58 /*  TRAX Protocol API:  */
59 extern int  trax_read_register(tpack_channel *tchan, int regno, unsigned *value);
60 extern int  trax_write_register(tpack_channel *tchan, int regno, unsigned value);
61 extern int  trax_read_memory(tpack_channel *tchan, int address, int size, unsigned char *pdata);
62 extern int  trax_fill_memory(tpack_channel *tchan, int address, int size, tpack_u32 pattern);
63 extern int  trax_enumerate_devices(tpack_channel *tchan, int * buf, int * size);
64 
65 /*  TRAX Network API:  */
66 extern unsigned long  trax_ram_size(tpack_channel *traxchan);
67 extern unsigned long  trax_ram_size_addr(tpack_channel *traxchan);
68 extern int  trax_create_tracefile(tpack_channel *traxchan, int size, unsigned char * data,
69 				char *filename, int hflags, const char *toolver);
70 extern int  trax_memaccess_safe(tpack_channel *traxchan, const char *what);
71 extern int  trax_start(tpack_channel *traxchan, int flags);
72 extern int  trax_stop(tpack_channel *traxchan, int flags);
73 extern int  trax_halt(tpack_channel *traxchan, int flags);
74 extern int  trax_save(tpack_channel *traxchan, char *filename, int flags, const char *toolver, int erratum);
75 
76 /*  TRAX Misc API (no network dependencies):  */
77 int trax_fixed_hw(unsigned * regs);
78 extern int  trax_display_id(unsigned id, const char *prefix);
79 extern int  trax_display_summary(unsigned id,
80 				 unsigned status,
81 				 unsigned control,
82 				 unsigned address,
83 				 unsigned delay,
84 				 unsigned trigger,
85 				 unsigned match,
86 				 unsigned startaddr,
87 				 unsigned endaddr,
88 				 const char *prefix);
89 
90 /*  Other:  */
91 
92 #endif /* _TRAX_API_H_ */
93 
94