+int handle_arm9tdmi_catch_vectors_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
+{
+ target_t *target = get_current_target(cmd_ctx);
+ armv4_5_common_t *armv4_5;
+ arm7_9_common_t *arm7_9;
+ arm9tdmi_common_t *arm9tdmi;
+ reg_t *vector_catch;
+ u32 vector_catch_value;
+ int i, j;
+
+ if (arm9tdmi_get_arch_pointers(target, &armv4_5, &arm7_9, &arm9tdmi) != ERROR_OK)
+ {
+ command_print(cmd_ctx, "current target isn't an ARM9TDMI based target");
+ return ERROR_OK;
+ }
+
+ vector_catch = &arm7_9->eice_cache->reg_list[EICE_VEC_CATCH];
+
+ /* read the vector catch register if necessary */
+ if (!vector_catch->valid)
+ embeddedice_read_reg(vector_catch);
+
+ /* get the current setting */
+ vector_catch_value = buf_get_u32(vector_catch->value, 0, 32);
+
+ if (argc > 0)
+ {
+ vector_catch_value = 0x0;
+ if (strcmp(args[0], "all") == 0)
+ {
+ vector_catch_value = 0xdf;
+ }
+ else if (strcmp(args[0], "none") == 0)
+ {
+ /* do nothing */
+ }
+ else
+ {
+ for (i = 0; i < argc; i++)
+ {
+ /* go through list of vectors */
+ for(j = 0; arm9tdmi_vectors[j].name; j++)
+ {
+ if (strcmp(args[i], arm9tdmi_vectors[j].name) == 0)
+ {
+ vector_catch_value |= arm9tdmi_vectors[j].value;
+ break;
+ }
+ }
+
+ /* complain if vector wasn't found */
+ if (!arm9tdmi_vectors[j].name)
+ {
+ command_print(cmd_ctx, "vector '%s' not found, leaving current setting unchanged", args[i]);
+
+ /* reread current setting */
+ vector_catch_value = buf_get_u32(vector_catch->value, 0, 32);
+
+ break;
+ }
+ }
+ }
+
+ /* store new settings */
+ buf_set_u32(vector_catch->value, 0, 32, vector_catch_value);
+ embeddedice_store_reg(vector_catch);
+ }
+
+ /* output current settings (skip RESERVED vector) */
+ for (i = 0; i < 8; i++)
+ {
+ if (i != 5)
+ {
+ command_print(cmd_ctx, "%s: %s", arm9tdmi_vectors[i].name,
+ (vector_catch_value & (1 << i)) ? "catch" : "don't catch");
+ }
+ }
+
+ return ERROR_OK;
+}