target.c 127 KB
Newer Older
5001
5002
		struct target *target = get_current_target(CMD_CTX);
		command_print(CMD_CTX, "Write to 0x%08x, length 0x%08x",
5003
					  (unsigned int)(fastload[i].address),
duane's avatar
duane committed
5004
					  (unsigned int)(fastload[i].length));
zwelch's avatar
zwelch committed
5005
		if (retval == ERROR_OK)
5006
		{
oharboe's avatar
oharboe committed
5007
			retval = target_write_buffer(target, fastload[i].address, fastload[i].length, fastload[i].data);
5008
		}
zwelch's avatar
zwelch committed
5009
		size += fastload[i].length;
5010
	}
zwelch's avatar
zwelch committed
5011
	int after = timeval_ms();
5012
	command_print(CMD_CTX, "Loaded image %f kBytes/s", (float)(size/1024.0)/((float)(after-ms)/1000.0));
oharboe's avatar
oharboe committed
5013
	return retval;
5014
}
duane's avatar
duane committed
5015

5016
5017
5018
static const struct command_registration target_command_handlers[] = {
	{
		.name = "targets",
5019
		.handler = handle_targets_command,
5020
		.mode = COMMAND_ANY,
5021
5022
5023
		.help = "change current default target (one parameter) "
			"or prints table of all targets (no parameters)",
		.usage = "[target]",
5024
	},
5025
5026
5027
5028
	{
		.name = "target",
		.mode = COMMAND_CONFIG,
		.help = "configure target",
5029
5030

		.chain = target_subcommand_handlers,
5031
	},
5032
5033
5034
	COMMAND_REGISTRATION_DONE
};

5035
int target_register_commands(struct command_context *cmd_ctx)
5036
{
5037
	return register_commands(cmd_ctx, NULL, target_command_handlers);
5038
5039
}

Øyvind Harboe's avatar
Øyvind Harboe committed
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
static bool target_reset_nag = true;

bool get_target_reset_nag(void)
{
	return target_reset_nag;
}

COMMAND_HANDLER(handle_target_reset_nag)
{
	return CALL_COMMAND_HANDLER(handle_command_parse_bool,
			&target_reset_nag, "Nag after each reset about options to improve "
			"performance");
}

5054
5055
5056
static const struct command_registration target_exec_command_handlers[] = {
	{
		.name = "fast_load_image",
5057
		.handler = handle_fast_load_image_command,
5058
		.mode = COMMAND_ANY,
5059
5060
5061
5062
		.help = "Load image into server memory for later use by "
			"fast_load; primarily for profiling",
		.usage = "filename address ['bin'|'ihex'|'elf'|'s19'] "
			"[min_address [max_length]]",
5063
5064
5065
	},
	{
		.name = "fast_load",
5066
		.handler = handle_fast_load_command,
5067
		.mode = COMMAND_EXEC,
5068
5069
5070
5071
5072
		.help = "loads active fast load image to current target "
			"- mainly for profiling purposes",
	},
	{
		.name = "profile",
5073
		.handler = handle_profile_command,
5074
5075
5076
5077
5078
5079
		.mode = COMMAND_EXEC,
		.help = "profiling samples the CPU PC",
	},
	/** @todo don't register virt2phys() unless target supports it */
	{
		.name = "virt2phys",
5080
		.handler = handle_virt2phys_command,
5081
5082
		.mode = COMMAND_ANY,
		.help = "translate a virtual address into a physical address",
David Brownell's avatar
David Brownell committed
5083
		.usage = "virtual_address",
5084
5085
5086
	},
	{
		.name = "reg",
5087
		.handler = handle_reg_command,
5088
		.mode = COMMAND_EXEC,
5089
5090
5091
		.help = "display or set a register; with no arguments, "
			"displays all registers and their values",
		.usage = "[(register_name|register_number) [value]]",
5092
5093
5094
	},
	{
		.name = "poll",
5095
		.handler = handle_poll_command,
5096
		.mode = COMMAND_EXEC,
5097
5098
		.help = "poll target state; or reconfigure background polling",
		.usage = "['on'|'off']",
5099
5100
5101
	},
	{
		.name = "wait_halt",
5102
		.handler = handle_wait_halt_command,
5103
		.mode = COMMAND_EXEC,
5104
5105
5106
		.help = "wait up to the specified number of milliseconds "
			"(default 5) for a previously requested halt",
		.usage = "[milliseconds]",
5107
5108
5109
	},
	{
		.name = "halt",
5110
		.handler = handle_halt_command,
5111
		.mode = COMMAND_EXEC,
5112
5113
5114
		.help = "request target to halt, then wait up to the specified"
			"number of milliseconds (default 5) for it to complete",
		.usage = "[milliseconds]",
5115
5116
5117
	},
	{
		.name = "resume",
5118
		.handler = handle_resume_command,
5119
		.mode = COMMAND_EXEC,
5120
5121
		.help =	"resume target execution from current PC or address",
		.usage = "[address]",
5122
5123
5124
	},
	{
		.name = "reset",
5125
		.handler = handle_reset_command,
5126
5127
5128
5129
5130
5131
5132
		.mode = COMMAND_EXEC,
		.usage = "[run|halt|init]",
		.help = "Reset all targets into the specified mode."
			"Default reset mode is run, if not given.",
	},
	{
		.name = "soft_reset_halt",
5133
		.handler = handle_soft_reset_halt_command,
5134
5135
5136
5137
5138
		.mode = COMMAND_EXEC,
		.help = "halt the target and do a soft reset",
	},
	{
		.name = "step",
5139
		.handler = handle_step_command,
5140
		.mode = COMMAND_EXEC,
5141
5142
		.help =	"step one instruction from current PC or address",
		.usage = "[address]",
5143
5144
5145
	},
	{
		.name = "mdw",
5146
		.handler = handle_md_command,
5147
5148
		.mode = COMMAND_EXEC,
		.help = "display memory words",
5149
		.usage = "['phys'] address [count]",
5150
5151
5152
	},
	{
		.name = "mdh",
5153
		.handler = handle_md_command,
5154
5155
		.mode = COMMAND_EXEC,
		.help = "display memory half-words",
5156
		.usage = "['phys'] address [count]",
5157
5158
5159
	},
	{
		.name = "mdb",
5160
		.handler = handle_md_command,
5161
5162
		.mode = COMMAND_EXEC,
		.help = "display memory bytes",
5163
		.usage = "['phys'] address [count]",
5164
5165
5166
	},
	{
		.name = "mww",
5167
		.handler = handle_mw_command,
5168
5169
		.mode = COMMAND_EXEC,
		.help = "write memory word",
5170
		.usage = "['phys'] address value [count]",
5171
5172
5173
	},
	{
		.name = "mwh",
5174
		.handler = handle_mw_command,
5175
5176
		.mode = COMMAND_EXEC,
		.help = "write memory half-word",
5177
		.usage = "['phys'] address value [count]",
5178
5179
5180
	},
	{
		.name = "mwb",
5181
		.handler = handle_mw_command,
5182
5183
		.mode = COMMAND_EXEC,
		.help = "write memory byte",
5184
		.usage = "['phys'] address value [count]",
5185
5186
5187
	},
	{
		.name = "bp",
5188
		.handler = handle_bp_command,
5189
		.mode = COMMAND_EXEC,
5190
5191
		.help = "list or set hardware or software breakpoint",
		.usage = "[address length ['hw']]",
5192
5193
5194
	},
	{
		.name = "rbp",
5195
		.handler = handle_rbp_command,
5196
5197
		.mode = COMMAND_EXEC,
		.help = "remove breakpoint",
5198
		.usage = "address",
5199
5200
5201
	},
	{
		.name = "wp",
5202
		.handler = handle_wp_command,
5203
		.mode = COMMAND_EXEC,
5204
5205
		.help = "list (no params) or create watchpoints",
		.usage = "[address length [('r'|'w'|'a') value [mask]]]",
5206
5207
5208
	},
	{
		.name = "rwp",
5209
		.handler = handle_rwp_command,
5210
5211
		.mode = COMMAND_EXEC,
		.help = "remove watchpoint",
5212
		.usage = "address",
5213
5214
5215
	},
	{
		.name = "load_image",
5216
		.handler = handle_load_image_command,
5217
		.mode = COMMAND_EXEC,
5218
		.usage = "filename address ['bin'|'ihex'|'elf'|'s19'] "
5219
5220
5221
5222
			"[min_address] [max_length]",
	},
	{
		.name = "dump_image",
5223
		.handler = handle_dump_image_command,
5224
		.mode = COMMAND_EXEC,
5225
		.usage = "filename address size",
5226
5227
5228
	},
	{
		.name = "verify_image",
5229
		.handler = handle_verify_image_command,
5230
		.mode = COMMAND_EXEC,
5231
		.usage = "filename [offset [type]]",
5232
5233
5234
	},
	{
		.name = "test_image",
5235
		.handler = handle_test_image_command,
5236
		.mode = COMMAND_EXEC,
5237
		.usage = "filename [offset [type]]",
5238
	},
5239
5240
5241
	{
		.name = "ocd_mem2array",
		.mode = COMMAND_EXEC,
5242
5243
		.jim_handler = jim_mem2array,
		.help = "read 8/16/32 bit memory and return as a TCL array "
5244
			"for script processing",
5245
		.usage = "arrayname bitwidth address count",
5246
5247
5248
5249
	},
	{
		.name = "ocd_array2mem",
		.mode = COMMAND_EXEC,
5250
		.jim_handler = jim_array2mem,
5251
		.help = "convert a TCL array to memory locations "
5252
5253
			"and write the 8/16/32 bit values",
		.usage = "arrayname bitwidth address count",
5254
	},
Øyvind Harboe's avatar
Øyvind Harboe committed
5255
5256
5257
5258
5259
5260
5261
5262
	{
		.name = "reset_nag",
		.handler = handle_target_reset_nag,
		.mode = COMMAND_ANY,
		.help = "Nag after each reset about options that could have been "
				"enabled to improve performance. ",
		.usage = "['enable'|'disable']",
	},
5263
5264
	COMMAND_REGISTRATION_DONE
};
5265
int target_register_user_commands(struct command_context *cmd_ctx)
5266
5267
5268
5269
5270
5271
5272
5273
5274
{
	int retval = ERROR_OK;
	if ((retval = target_request_register_commands(cmd_ctx)) != ERROR_OK)
		return retval;

	if ((retval = trace_register_commands(cmd_ctx)) != ERROR_OK)
		return retval;


5275
	return register_commands(cmd_ctx, NULL, target_exec_command_handlers);
5276
}
For faster browsing, not all history is shown. View entire blame