target: less implicit inclusion of "command.h"
[openocd.git] / src / target / armv7a.c
index 1e0e02f189f024fa0e639514de6dc3c32a38f80b..7b33053da491bc55258d9b4cadfdca8cb8899a90 100644 (file)
@@ -27,7 +27,6 @@
 
 #include "target.h"
 #include "register.h"
-#include "log.h"
 #include "binarybuffer.h"
 #include "command.h"
 
 #include <string.h>
 #include <unistd.h>
 
-bitfield_desc_t armv7a_psr_bitfield_desc[] =
-{
-       {"M[4:0]", 5},
-       {"T", 1},
-       {"F", 1},
-       {"I", 1},
-       {"A", 1},
-       {"E", 1},
-       {"IT[7:2]", 6},
-       {"GE[3:0]", 4},
-       {"reserved(DNM)", 4},
-       {"J", 1},
-       {"IT[0:1]", 2},
-       {"Q", 1},
-       {"V", 1},
-       {"C", 1},
-       {"Z", 1},
-       {"N", 1},
-};
 
 char* armv7a_core_reg_list[] =
 {
@@ -82,7 +62,7 @@ char* armv7a_state_strings[] =
        "ARM", "Thumb", "Jazelle", "ThumbEE"
 };
 
-armv7a_core_reg_t armv7a_core_reg_list_arch_info[] =
+struct armv7a_core_reg armv7a_core_reg_list_arch_info[] =
 {
        {0, ARMV4_5_MODE_ANY, NULL, NULL},
        {1, ARMV4_5_MODE_ANY, NULL, NULL},
@@ -165,21 +145,26 @@ int armv7a_core_reg_map[8][17] =
        }
 };
 
+/* FIXME this dummy is IDENTICAL to the armv4_5, arm11, and armv7m
+ * ones... except for naming/scoping
+ */
 uint8_t armv7a_gdb_dummy_fp_value[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
 
-reg_t armv7a_gdb_dummy_fp_reg =
+struct reg armv7a_gdb_dummy_fp_reg =
 {
-       "GDB dummy floating-point register", armv7a_gdb_dummy_fp_value,
-                       0, 1, 96, NULL, 0, NULL, 0
+       .name = "GDB dummy floating-point register",
+       .value = armv7a_gdb_dummy_fp_value,
+       .dirty = 0,
+       .valid = 1,
+       .size = 96,
+       .arch_info = NULL,
+       .arch_type = 0,
 };
 
-void armv7a_show_fault_registers(target_t *target)
+void armv7a_show_fault_registers(struct target *target)
 {
        uint32_t dfsr, ifsr, dfar, ifar;
-
-       /* get pointers to arch-specific information */
-       armv4_5_common_t *armv4_5 = target->arch_info;
-       armv7a_common_t *armv7a = armv4_5->arch_info;
+       struct armv7a_common *armv7a = target_to_armv7a(target);
 
        armv7a->read_cp15(target, 0, 0, 5, 0, &dfsr);
        armv7a->read_cp15(target, 0, 1, 5, 0, &ifsr);
@@ -193,15 +178,15 @@ void armv7a_show_fault_registers(target_t *target)
 
 }
 
-int armv7a_arch_state(struct target_s *target)
+int armv7a_arch_state(struct target *target)
 {
        static const char *state[] =
        {
                "disabled", "enabled"
        };
 
-       armv4_5_common_t *armv4_5 = target->arch_info;
-       armv7a_common_t *armv7a = armv4_5->arch_info;
+       struct armv7a_common *armv7a = target_to_armv7a(target);
+       struct armv4_5_common_s *armv4_5 = &armv7a->armv4_5_common;
 
        if (armv4_5->common_magic != ARMV4_5_COMMON_MAGIC)
        {
@@ -233,72 +218,67 @@ int armv7a_arch_state(struct target_s *target)
 }
 
 
-static int handle_dap_baseaddr_command(struct command_context_s *cmd_ctx,
-               char *cmd, char **args, int argc)
+COMMAND_HANDLER(handle_dap_baseaddr_command)
 {
-       target_t *target = get_current_target(cmd_ctx);
-       armv4_5_common_t *armv4_5 = target->arch_info;
-       armv7a_common_t *armv7a = armv4_5->arch_info;
-       swjdp_common_t *swjdp = &armv7a->swjdp_info;
+       struct target *target = get_current_target(cmd_ctx);
+       struct armv7a_common *armv7a = target_to_armv7a(target);
+       struct swjdp_common *swjdp = &armv7a->swjdp_info;
 
-       return dap_baseaddr_command(cmd_ctx, swjdp, args, argc);
+       return CALL_COMMAND_HANDLER(dap_baseaddr_command, swjdp);
 }
 
-static int handle_dap_memaccess_command(struct command_context_s *cmd_ctx,
-               char *cmd, char **args, int argc)
+COMMAND_HANDLER(handle_dap_memaccess_command)
 {
-       target_t *target = get_current_target(cmd_ctx);
-       armv4_5_common_t *armv4_5 = target->arch_info;
-       armv7a_common_t *armv7a = armv4_5->arch_info;
-       swjdp_common_t *swjdp = &armv7a->swjdp_info;
+       struct target *target = get_current_target(cmd_ctx);
+       struct armv7a_common *armv7a = target_to_armv7a(target);
+       struct swjdp_common *swjdp = &armv7a->swjdp_info;
 
-       return dap_memaccess_command(cmd_ctx, swjdp, args, argc);
+       return CALL_COMMAND_HANDLER(dap_memaccess_command, swjdp);
 }
 
-static int handle_dap_apsel_command(struct command_context_s *cmd_ctx,
-               char *cmd, char **args, int argc)
+COMMAND_HANDLER(handle_dap_apsel_command)
 {
-       target_t *target = get_current_target(cmd_ctx);
-       armv4_5_common_t *armv4_5 = target->arch_info;
-       armv7a_common_t *armv7a = armv4_5->arch_info;
-       swjdp_common_t *swjdp = &armv7a->swjdp_info;
+       struct target *target = get_current_target(cmd_ctx);
+       struct armv7a_common *armv7a = target_to_armv7a(target);
+       struct swjdp_common *swjdp = &armv7a->swjdp_info;
 
-       return dap_apsel_command(cmd_ctx, swjdp, args, argc);
+       return CALL_COMMAND_HANDLER(dap_apsel_command, swjdp);
 }
 
-static int handle_dap_apid_command(struct command_context_s *cmd_ctx,
-               char *cmd, char **args, int argc)
+COMMAND_HANDLER(handle_dap_apid_command)
 {
-       target_t *target = get_current_target(cmd_ctx);
-       armv4_5_common_t *armv4_5 = target->arch_info;
-       armv7a_common_t *armv7a = armv4_5->arch_info;
-       swjdp_common_t *swjdp = &armv7a->swjdp_info;
+       struct target *target = get_current_target(cmd_ctx);
+       struct armv7a_common *armv7a = target_to_armv7a(target);
+       struct swjdp_common *swjdp = &armv7a->swjdp_info;
 
-       return dap_apid_command(cmd_ctx, swjdp, args, argc);
+       return CALL_COMMAND_HANDLER(dap_apid_command, swjdp);
 }
 
-static int handle_dap_info_command(struct command_context_s *cmd_ctx,
-               char *cmd, char **args, int argc)
+COMMAND_HANDLER(handle_dap_info_command)
 {
-       target_t *target = get_current_target(cmd_ctx);
-       armv4_5_common_t *armv4_5 = target->arch_info;
-       armv7a_common_t *armv7a = armv4_5->arch_info;
-       swjdp_common_t *swjdp = &armv7a->swjdp_info;
+       struct target *target = get_current_target(cmd_ctx);
+       struct armv7a_common *armv7a = target_to_armv7a(target);
+       struct swjdp_common *swjdp = &armv7a->swjdp_info;
        uint32_t apsel;
 
-       apsel =  swjdp->apsel;
-       if (argc > 0)
-               apsel = strtoul(args[0], NULL, 0);
+       switch (argc) {
+       case 0:
+               apsel = swjdp->apsel;
+               break;
+       case 1:
+               COMMAND_PARSE_NUMBER(u32, args[0], apsel);
+               break;
+       default:
+               return ERROR_COMMAND_SYNTAX_ERROR;
+       }
 
        return dap_info_command(cmd_ctx, swjdp, apsel);
 }
 
-static int
-handle_armv7a_disassemble_command(struct command_context_s *cmd_ctx,
-               char *cmd, char **args, int argc)
+COMMAND_HANDLER(handle_armv7a_disassemble_command)
 {
-       target_t *target = get_current_target(cmd_ctx);
-       armv4_5_common_t *armv4_5 = target->arch_info;
+       struct target *target = get_current_target(cmd_ctx);
+       struct armv4_5_common_s *armv4_5 = target_to_armv4_5(target);
        int thumb = 0;
        int count = 1;
        uint32_t address;
@@ -320,10 +300,10 @@ handle_armv7a_disassemble_command(struct command_context_s *cmd_ctx,
                thumb = 1;
                /* FALL THROUGH */
        case 2:
-               count = strtoul(args[1], NULL, 0);
+               COMMAND_PARSE_NUMBER(int, args[1], count);
                /* FALL THROUGH */
        case 1:
-               address = strtoul(args[0], NULL, 0);
+               COMMAND_PARSE_NUMBER(u32, args[0], address);
                if (address & 0x01) {
                        if (!thumb) {
                                command_print(cmd_ctx, "Disassemble as Thumb");
@@ -335,12 +315,12 @@ handle_armv7a_disassemble_command(struct command_context_s *cmd_ctx,
        default:
 usage:
                command_print(cmd_ctx,
-                       "usage: armv4_5 disassemble <address> [<count> ['thumb']]");
+                       "usage: armv7a disassemble <address> [<count> ['thumb']]");
                return ERROR_OK;
        }
 
        for (i = 0; i < count; i++) {
-               arm_instruction_t cur_instruction;
+               struct arm_instruction cur_instruction;
                int retval;
 
                if (thumb) {
@@ -369,10 +349,10 @@ usage:
        return ERROR_OK;
 }
 
-int armv7a_register_commands(struct command_context_s *cmd_ctx)
+int armv7a_register_commands(struct command_context *cmd_ctx)
 {
-       command_t *arm_adi_v5_dap_cmd;
-       command_t *armv7a_cmd;
+       struct command *arm_adi_v5_dap_cmd;
+       struct command *armv7a_cmd;
 
        arm_adi_v5_dap_cmd = register_command(cmd_ctx, NULL, "dap",
                        NULL, COMMAND_ANY,

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)