aboutsummaryrefslogtreecommitdiff
path: root/src/target/stm8.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/target/stm8.c')
-rw-r--r--src/target/stm8.c52
1 files changed, 48 insertions, 4 deletions
diff --git a/src/target/stm8.c b/src/target/stm8.c
index 76482e8..81c41f2 100644
--- a/src/target/stm8.c
+++ b/src/target/stm8.c
@@ -13,14 +13,12 @@
#include <helper/log.h>
#include "target.h"
#include "target_type.h"
-#include "hello.h"
#include "jtag/interface.h"
#include "jtag/jtag.h"
#include "jtag/swim.h"
#include "register.h"
#include "breakpoints.h"
#include "algorithm.h"
-#include "stm8.h"
static struct reg_cache *stm8_build_reg_cache(struct target *target);
static int stm8_read_core_reg(struct target *target, unsigned int num);
@@ -54,6 +52,8 @@ static const struct {
{ 5, "cc", 8, REG_TYPE_UINT8, "general", "org.gnu.gdb.stm8.core", 0 },
};
+#define STM8_COMMON_MAGIC 0x53544D38U
+
#define STM8_NUM_REGS ARRAY_SIZE(stm8_regs)
#define STM8_PC 0
#define STM8_A 1
@@ -168,6 +168,51 @@ struct stm8_comparator {
enum hw_break_type type;
};
+struct stm8_common {
+ unsigned int common_magic;
+
+ void *arch_info;
+ struct reg_cache *core_cache;
+ uint32_t core_regs[STM8_NUM_REGS];
+
+ /* working area for fastdata access */
+ struct working_area *fast_data_area;
+
+ bool swim_configured;
+ bool bp_scanned;
+ uint8_t num_hw_bpoints;
+ uint8_t num_hw_bpoints_avail;
+ struct stm8_comparator *hw_break_list;
+ uint32_t blocksize;
+ uint32_t flashstart;
+ uint32_t flashend;
+ uint32_t eepromstart;
+ uint32_t eepromend;
+ uint32_t optionstart;
+ uint32_t optionend;
+ bool enable_step_irq;
+
+ bool enable_stm8l;
+ uint32_t flash_cr2;
+ uint32_t flash_ncr2;
+ uint32_t flash_iapsr;
+ uint32_t flash_dukr;
+ uint32_t flash_pukr;
+
+ /* cc value used for interrupt flags restore */
+ uint32_t cc;
+ bool cc_valid;
+
+ /* register cache to processor synchronization */
+ int (*read_core_reg)(struct target *target, unsigned int num);
+ int (*write_core_reg)(struct target *target, unsigned int num);
+};
+
+static struct stm8_common *target_to_stm8(struct target *target)
+{
+ return target->arch_info;
+}
+
static int stm8_adapter_read_memory(struct target *target,
uint32_t addr, int size, int count, void *buf)
{
@@ -1106,8 +1151,7 @@ static int stm8_init_arch_info(struct target *target,
return ERROR_OK;
}
-static int stm8_target_create(struct target *target,
- Jim_Interp *interp)
+static int stm8_target_create(struct target *target)
{
struct stm8_common *stm8 = calloc(1, sizeof(struct stm8_common));