2007-06-14 14:48:22 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright (C) 2005 by Dominic Rath *
|
|
|
|
* Dominic.Rath@gmx.de *
|
2008-02-29 12:37:45 +00:00
|
|
|
* *
|
2007-06-14 14:48:22 +00:00
|
|
|
* Copyright (C) 2006 by Magnus Lundin *
|
|
|
|
* lundin@mlu.mine.nu *
|
|
|
|
* *
|
2008-09-20 10:50:53 +00:00
|
|
|
* Copyright (C) 2008 by Spencer Oliver *
|
|
|
|
* spen@spen-soft.co.uk *
|
|
|
|
* *
|
2007-06-14 14:48:22 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program; if not, write to the *
|
|
|
|
* Free Software Foundation, Inc., *
|
|
|
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
|
|
|
***************************************************************************/
|
|
|
|
#ifndef ARMV7M_COMMON_H
|
|
|
|
#define ARMV7M_COMMON_H
|
|
|
|
|
2009-12-13 20:52:23 +00:00
|
|
|
#include "arm_adi_v5.h"
|
|
|
|
#include "arm.h"
|
2007-06-14 14:48:22 +00:00
|
|
|
|
2008-04-26 16:40:54 +00:00
|
|
|
/* define for enabling armv7 gdb workarounds */
|
|
|
|
#if 1
|
|
|
|
#define ARMV7_GDB_HACKS
|
|
|
|
#endif
|
|
|
|
|
2009-12-08 21:06:41 +00:00
|
|
|
#ifdef ARMV7_GDB_HACKS
|
|
|
|
extern uint8_t armv7m_gdb_dummy_cpsr_value[];
|
|
|
|
extern struct reg armv7m_gdb_dummy_cpsr_reg;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2007-06-14 14:48:22 +00:00
|
|
|
enum armv7m_mode
|
|
|
|
{
|
2008-04-10 11:43:48 +00:00
|
|
|
ARMV7M_MODE_THREAD = 0,
|
|
|
|
ARMV7M_MODE_USER_THREAD = 1,
|
|
|
|
ARMV7M_MODE_HANDLER = 2,
|
2007-06-14 14:48:22 +00:00
|
|
|
ARMV7M_MODE_ANY = -1
|
|
|
|
};
|
|
|
|
|
2009-11-05 09:02:52 +00:00
|
|
|
extern char *armv7m_mode_strings[];
|
2007-06-14 14:48:22 +00:00
|
|
|
|
|
|
|
enum armv7m_regtype
|
|
|
|
{
|
|
|
|
ARMV7M_REGISTER_CORE_GP,
|
|
|
|
ARMV7M_REGISTER_CORE_SP,
|
|
|
|
ARMV7M_REGISTER_MEMMAP
|
|
|
|
};
|
|
|
|
|
2009-11-09 12:22:23 +00:00
|
|
|
char *armv7m_exception_string(int number);
|
2007-06-14 14:48:22 +00:00
|
|
|
|
|
|
|
/* offsets into armv7m core register cache */
|
2009-06-23 22:49:23 +00:00
|
|
|
enum
|
2007-06-14 14:48:22 +00:00
|
|
|
{
|
2009-07-21 20:15:11 +00:00
|
|
|
/* for convenience, the first set of indices match
|
|
|
|
* the Cortex-M3 DCRSR selectors
|
|
|
|
*/
|
|
|
|
ARMV7M_R0,
|
|
|
|
ARMV7M_R1,
|
|
|
|
ARMV7M_R2,
|
|
|
|
ARMV7M_R3,
|
|
|
|
|
|
|
|
ARMV7M_R4,
|
|
|
|
ARMV7M_R5,
|
|
|
|
ARMV7M_R6,
|
|
|
|
ARMV7M_R7,
|
|
|
|
|
|
|
|
ARMV7M_R8,
|
|
|
|
ARMV7M_R9,
|
|
|
|
ARMV7M_R10,
|
|
|
|
ARMV7M_R11,
|
|
|
|
|
|
|
|
ARMV7M_R12,
|
|
|
|
ARMV7M_R13,
|
|
|
|
ARMV7M_R14,
|
2007-06-14 14:48:22 +00:00
|
|
|
ARMV7M_PC = 15,
|
2009-07-21 20:15:11 +00:00
|
|
|
|
2007-06-14 14:48:22 +00:00
|
|
|
ARMV7M_xPSR = 16,
|
2007-06-24 15:04:07 +00:00
|
|
|
ARMV7M_MSP,
|
|
|
|
ARMV7M_PSP,
|
2009-07-21 20:15:11 +00:00
|
|
|
|
|
|
|
/* this next set of indices is arbitrary */
|
2009-07-21 20:03:17 +00:00
|
|
|
ARMV7M_PRIMASK,
|
|
|
|
ARMV7M_BASEPRI,
|
|
|
|
ARMV7M_FAULTMASK,
|
|
|
|
ARMV7M_CONTROL,
|
2007-06-14 14:48:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define ARMV7M_COMMON_MAGIC 0x2A452A45
|
|
|
|
|
2009-11-13 16:41:39 +00:00
|
|
|
struct armv7m_common
|
2007-06-14 14:48:22 +00:00
|
|
|
{
|
|
|
|
int common_magic;
|
2009-11-13 16:44:08 +00:00
|
|
|
struct reg_cache *core_cache;
|
2007-06-14 14:48:22 +00:00
|
|
|
enum armv7m_mode core_mode;
|
2008-04-10 11:43:48 +00:00
|
|
|
int exception_number;
|
2009-11-13 16:40:31 +00:00
|
|
|
struct swjdp_common swjdp_info;
|
2009-04-27 08:29:28 +00:00
|
|
|
|
2010-01-13 11:16:37 +00:00
|
|
|
uint32_t demcr;
|
|
|
|
|
2007-06-14 14:48:22 +00:00
|
|
|
/* Direct processor core register read and writes */
|
2010-01-13 11:16:37 +00:00
|
|
|
int (*load_core_reg_u32)(struct target *target,
|
|
|
|
enum armv7m_regtype type, uint32_t num, uint32_t *value);
|
|
|
|
int (*store_core_reg_u32)(struct target *target,
|
|
|
|
enum armv7m_regtype type, uint32_t num, uint32_t value);
|
|
|
|
|
2007-06-14 14:48:22 +00:00
|
|
|
/* register cache to processor synchronization */
|
2009-11-16 11:33:22 +00:00
|
|
|
int (*read_core_reg)(struct target *target, unsigned num);
|
|
|
|
int (*write_core_reg)(struct target *target, unsigned num);
|
2009-06-23 22:49:23 +00:00
|
|
|
|
2009-11-13 18:11:13 +00:00
|
|
|
int (*examine_debug_reason)(struct target *target);
|
|
|
|
void (*post_debug_entry)(struct target *target);
|
2009-06-23 22:49:23 +00:00
|
|
|
|
2009-11-13 18:11:13 +00:00
|
|
|
void (*pre_restore_context)(struct target *target);
|
|
|
|
void (*post_restore_context)(struct target *target);
|
2009-11-13 16:41:39 +00:00
|
|
|
};
|
2007-06-14 14:48:22 +00:00
|
|
|
|
2009-11-13 16:41:39 +00:00
|
|
|
static inline struct armv7m_common *
|
2009-11-13 18:11:13 +00:00
|
|
|
target_to_armv7m(struct target *target)
|
2009-11-06 05:59:39 +00:00
|
|
|
{
|
|
|
|
return target->arch_info;
|
|
|
|
}
|
|
|
|
|
2009-11-13 16:41:43 +00:00
|
|
|
struct armv7m_algorithm
|
2007-06-14 14:48:22 +00:00
|
|
|
{
|
|
|
|
int common_magic;
|
2009-06-23 22:49:23 +00:00
|
|
|
|
2007-06-14 14:48:22 +00:00
|
|
|
enum armv7m_mode core_mode;
|
2009-11-13 16:41:43 +00:00
|
|
|
};
|
2007-06-14 14:48:22 +00:00
|
|
|
|
2009-11-13 16:41:46 +00:00
|
|
|
struct armv7m_core_reg
|
2007-06-14 14:48:22 +00:00
|
|
|
{
|
2009-06-18 07:08:52 +00:00
|
|
|
uint32_t num;
|
2007-06-14 14:48:22 +00:00
|
|
|
enum armv7m_regtype type;
|
2009-11-13 18:11:13 +00:00
|
|
|
struct target *target;
|
2009-11-13 16:41:39 +00:00
|
|
|
struct armv7m_common *armv7m_common;
|
2009-11-13 16:41:46 +00:00
|
|
|
};
|
2007-06-14 14:48:22 +00:00
|
|
|
|
2009-11-13 18:11:13 +00:00
|
|
|
struct reg_cache *armv7m_build_reg_cache(struct target *target);
|
2009-11-09 12:22:23 +00:00
|
|
|
enum armv7m_mode armv7m_number_to_mode(int number);
|
|
|
|
int armv7m_mode_to_number(enum armv7m_mode mode);
|
2007-06-14 14:48:22 +00:00
|
|
|
|
2009-11-13 18:11:13 +00:00
|
|
|
int armv7m_arch_state(struct target *target);
|
|
|
|
int armv7m_get_gdb_reg_list(struct target *target,
|
2009-11-13 17:55:49 +00:00
|
|
|
struct reg **reg_list[], int *reg_list_size);
|
2007-06-14 14:48:22 +00:00
|
|
|
|
2009-11-13 18:11:13 +00:00
|
|
|
int armv7m_init_arch_info(struct target *target, struct armv7m_common *armv7m);
|
2007-06-14 14:48:22 +00:00
|
|
|
|
2009-11-13 18:11:13 +00:00
|
|
|
int armv7m_run_algorithm(struct target *target,
|
2009-11-13 16:39:30 +00:00
|
|
|
int num_mem_params, struct mem_param *mem_params,
|
2009-11-13 16:39:42 +00:00
|
|
|
int num_reg_params, struct reg_param *reg_params,
|
2009-11-09 12:22:23 +00:00
|
|
|
uint32_t entry_point, uint32_t exit_point,
|
|
|
|
int timeout_ms, void *arch_info);
|
2007-06-14 14:48:22 +00:00
|
|
|
|
2009-11-13 18:11:13 +00:00
|
|
|
int armv7m_invalidate_core_regs(struct target *target);
|
2007-06-14 14:48:22 +00:00
|
|
|
|
2009-11-13 18:11:13 +00:00
|
|
|
int armv7m_restore_context(struct target *target);
|
2007-06-14 14:48:22 +00:00
|
|
|
|
2009-11-13 18:11:13 +00:00
|
|
|
int armv7m_checksum_memory(struct target *target,
|
2009-11-09 12:22:23 +00:00
|
|
|
uint32_t address, uint32_t count, uint32_t* checksum);
|
2009-11-13 18:11:13 +00:00
|
|
|
int armv7m_blank_check_memory(struct target *target,
|
2009-11-09 12:22:23 +00:00
|
|
|
uint32_t address, uint32_t count, uint32_t* blank);
|
2007-10-22 08:44:34 +00:00
|
|
|
|
2009-11-23 16:17:01 +00:00
|
|
|
extern const struct command_registration armv7m_command_handlers[];
|
|
|
|
|
2007-06-14 14:48:22 +00:00
|
|
|
#endif /* ARMV7M_H */
|