1 /*
2  * Copyright(c) 2013-2016 Intel Corporation.
3  *
4  * Adrian Burns (adrian.burns@intel.com)
5  * Thomas Faust (thomas.faust@intel.com)
6  * Ivan De Cesaris (ivan.de.cesaris@intel.com)
7  * Julien Carreno (julien.carreno@intel.com)
8  * Jeffrey Maxwell (jeffrey.r.maxwell@intel.com)
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful, but
16  * WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22  *
23  * Contact Information:
24  * Intel Corporation
25  */
26 
27 /*
28  * @file
29  * This is the interface to the probemode operations for Lakemont 1 (LMT1).
30  */
31 
32 #ifndef OPENOCD_TARGET_LAKEMONT_H
33 #define OPENOCD_TARGET_LAKEMONT_H
34 
35 #include <jtag/jtag.h>
36 #include <helper/types.h>
37 
38 /* The Intel Quark SoC X1000 Core is codenamed lakemont */
39 
40 #define LMT_IRLEN		8
41 
42 /* lakemont tap instruction opcodes */
43 #define IDCODE			2
44 #define SUBMITPIR		3
45 #define PROBEMODE		4
46 #define WRPIR			6
47 #define RDWRPDR			8
48 #define TAPSTATUS		11
49 #define BYPASS			255
50 #define NOT_NULL		2
51 
52 /* DR sizes */
53 #define ID_SIZE			32
54 #define PM_SIZE			1
55 #define PIR_SIZE		64
56 #define PDR_SIZE		32
57 #define TS_SIZE			32
58 #define BP_SIZE			1
59 #define MAX_SCAN_SIZE	PIR_SIZE
60 
61 /* needed during lakemont probemode */
62 #define NOT_PMREG		0xfe
63 #define NOT_AVAIL_REG		0xff
64 #define PM_DSB			((uint32_t)0x00000000)
65 #define PM_DSL			((uint32_t)0xFFFFFFFF)
66 #define PM_DSAR			((uint32_t)0x004F9300)
67 #define PM_DR7			((uint32_t)0x00000400)
68 #define DELAY_SUBMITPIR		0 /* for now 0 is working */
69 
70 /* lakemont tapstatus bits */
71 #define TS_PRDY_BIT		((uint32_t)0x00000001)
72 #define TS_EN_PM_BIT		((uint32_t)0x00000002)
73 #define TS_PM_BIT		((uint32_t)0x00000004)
74 #define TS_PMCR_BIT		((uint32_t)0x00000008)
75 #define TS_SBP_BIT		((uint32_t)0x00000010)
76 
77 struct lakemont_core_reg {
78 	uint32_t num;
79 	struct target *target;
80 	struct x86_32_common *x86_32_common;
81 	uint64_t op;
82 	uint8_t pm_idx;
83 };
84 
85 struct scan_blk {
86 	uint8_t out[MAX_SCAN_SIZE]; /* scanned out to the tap */
87 	uint8_t in[MAX_SCAN_SIZE]; /* in to our capture buf */
88 	struct scan_field field;
89 };
90 
91 #define I(name) (((struct lakemont_core_reg *)x86_32->cache->reg_list[name].arch_info)->pm_idx)
92 
93 int lakemont_init_target(struct command_context *cmd_ctx, struct target *t);
94 int lakemont_init_arch_info(struct target *t, struct x86_32_common *x86_32);
95 int lakemont_poll(struct target *t);
96 int lakemont_arch_state(struct target *t);
97 int lakemont_halt(struct target *t);
98 int lakemont_resume(struct target *t, int current, target_addr_t address,
99 			int handle_breakpoints, int debug_execution);
100 int lakemont_step(struct target *t, int current,
101 			target_addr_t address, int handle_breakpoints);
102 int lakemont_reset_assert(struct target *t);
103 int lakemont_reset_deassert(struct target *t);
104 int lakemont_update_after_probemode_entry(struct target *t);
105 
106 #endif /* OPENOCD_TARGET_LAKEMONT_H */
107