NEW(arm11_reg_state_t,     arm11_reg_states,       ARM11_REGCACHE_COUNT);
 
     if (arm11_regs_arch_type == -1)
-       arm11_regs_arch_type = register_reg_arch_type(arm11_get_reg, arm11_set_reg);
+       arm11_regs_arch_type = register_reg_arch_type(arm11_get_reg, arm11_set_reg);
+   
+       register_init_dummy(&arm11_gdb_dummy_fp_reg);
+       register_init_dummy(&arm11_gdb_dummy_fps_reg);
 
     arm11->reg_list    = reg_list;
 
 
        if (armv4_5_core_reg_arch_type == -1)
                armv4_5_core_reg_arch_type = register_reg_arch_type(armv4_5_get_core_reg, armv4_5_set_core_reg);
 
+       register_init_dummy(&armv4_5_gdb_dummy_fp_reg);
+       register_init_dummy(&armv4_5_gdb_dummy_fps_reg);
+
        for (i = 0; i < 37; i++)
        {
                arch_info[i] = armv4_5_core_reg_list_arch_info[i];
 
        return ERROR_OK;
 }
 
-int armv7m_get_dummy_core_reg(reg_t *reg)
-{
-       return ERROR_OK;
-}
-
-int armv7m_set_dummy_core_reg(reg_t *reg, u8 *buf)
-{
-       u32 value = buf_get_u32(buf, 0, 32);
-       buf_set_u32(reg->value, 0, 32, value);
-       reg->dirty = 1;
-       reg->valid = 1;
-
-       return ERROR_OK;
-}
-
 int armv7m_read_core_reg(struct target_s *target, int num)
 {
        u32 reg_value;
        if (armv7m_core_reg_arch_type == -1)
        {
                armv7m_core_reg_arch_type = register_reg_arch_type(armv7m_get_core_reg, armv7m_set_core_reg);
-               armv7m_dummy_core_reg_arch_type = register_reg_arch_type(armv7m_get_dummy_core_reg, armv7m_set_dummy_core_reg);
-
-               armv7m_gdb_dummy_fp_reg.arch_type=armv7m_dummy_core_reg_arch_type;
-               armv7m_gdb_dummy_fps_reg.arch_type=armv7m_dummy_core_reg_arch_type;
-               armv7m_gdb_dummy_cpsr_reg.arch_type=armv7m_dummy_core_reg_arch_type;
        }
+       
+       register_init_dummy(&armv7m_gdb_dummy_fps_reg);
+       register_init_dummy(&armv7m_gdb_dummy_cpsr_reg);
+       register_init_dummy(&armv7m_gdb_dummy_fp_reg);
                
        /* Build the process context cache */ 
        cache->name = "arm v7m registers";
 
  *                                                                         *
  *   Copyright (C) 2008 by David T.L. Wong                                 *
  *                                                                         *
+ *   Copyright (C) 2007,2008 Øyvind Harboe                                 *
+ *   oyvind.harboe@zylin.com                                               *
+ *                                                                         *
  *   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     *
        
        if (mips32_core_reg_arch_type == -1)
                mips32_core_reg_arch_type = register_reg_arch_type(mips32_get_core_reg, mips32_set_core_reg);
-               
+
+       register_init_dummy(&mips32_gdb_dummy_fsr_reg);
+       register_init_dummy(&mips32_gdb_dummy_fir_reg);
+
        /* Build the process context cache */ 
        cache->name = "mips32 registers";
        cache->next = NULL;
 
  *   Copyright (C) 2005 by Dominic Rath                                    *
  *   Dominic.Rath@gmx.de                                                   *
  *                                                                         *
+ *   Copyright (C) 2007,2008 Øyvind Harboe                                 *
+ *   oyvind.harboe@zylin.com                                               *
+ *                                                                         *
  *   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     *
        exit(-1);
        return NULL;
 }
+
+
+
+static int register_get_dummy_core_reg(reg_t *reg)
+{
+       return ERROR_OK;
+}
+
+static int register_set_dummy_core_reg(reg_t *reg, u8 *buf)
+{
+       reg->dirty = 1;
+       reg->valid = 1;
+
+       return ERROR_OK;
+}
+
+void register_init_dummy(reg_t *reg)
+{
+       static int dummy_arch_type = -1;
+       if (dummy_arch_type == -1 )
+               register_reg_arch_type(register_get_dummy_core_reg, register_set_dummy_core_reg);
+       
+       reg->arch_type = dummy_arch_type;
+}
 
  *   Copyright (C) 2005 by Dominic Rath                                    *
  *   Dominic.Rath@gmx.de                                                   *
  *                                                                         *
+ *   Copyright (C) 2007,2008 Øyvind Harboe                                 *
+ *   oyvind.harboe@zylin.com                                               *
+ *                                                                         *
  *   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     *
 extern reg_cache_t** register_get_last_cache_p(reg_cache_t **first);
 extern int register_reg_arch_type(int (*get)(reg_t *reg), int (*set)(reg_t *reg, u8 *buf));
 extern reg_arch_type_t* register_get_arch_type(int id);
+extern void register_init_dummy(reg_t *reg);
 
 #endif /* REGISTER_H */