cpu.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * QEMU LatticeMico32 CPU
  3. *
  4. * Copyright (c) 2012 SUSE LINUX Products GmbH
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library; if not, see
  18. * <http://www.gnu.org/licenses/lgpl-2.1.html>
  19. */
  20. #include "cpu.h"
  21. #include "qemu-common.h"
  22. /* CPUClass::reset() */
  23. static void lm32_cpu_reset(CPUState *s)
  24. {
  25. LM32CPU *cpu = LM32_CPU(s);
  26. LM32CPUClass *lcc = LM32_CPU_GET_CLASS(cpu);
  27. CPULM32State *env = &cpu->env;
  28. if (qemu_loglevel_mask(CPU_LOG_RESET)) {
  29. qemu_log("CPU Reset (CPU %d)\n", s->cpu_index);
  30. log_cpu_state(env, 0);
  31. }
  32. lcc->parent_reset(s);
  33. tlb_flush(env, 1);
  34. /* reset cpu state */
  35. memset(env, 0, offsetof(CPULM32State, breakpoints));
  36. }
  37. static void lm32_cpu_initfn(Object *obj)
  38. {
  39. LM32CPU *cpu = LM32_CPU(obj);
  40. CPULM32State *env = &cpu->env;
  41. cpu_exec_init(env);
  42. env->flags = 0;
  43. cpu_reset(CPU(cpu));
  44. }
  45. static void lm32_cpu_class_init(ObjectClass *oc, void *data)
  46. {
  47. LM32CPUClass *lcc = LM32_CPU_CLASS(oc);
  48. CPUClass *cc = CPU_CLASS(oc);
  49. lcc->parent_reset = cc->reset;
  50. cc->reset = lm32_cpu_reset;
  51. }
  52. static const TypeInfo lm32_cpu_type_info = {
  53. .name = TYPE_LM32_CPU,
  54. .parent = TYPE_CPU,
  55. .instance_size = sizeof(LM32CPU),
  56. .instance_init = lm32_cpu_initfn,
  57. .abstract = false,
  58. .class_size = sizeof(LM32CPUClass),
  59. .class_init = lm32_cpu_class_init,
  60. };
  61. static void lm32_cpu_register_types(void)
  62. {
  63. type_register_static(&lm32_cpu_type_info);
  64. }
  65. type_init(lm32_cpu_register_types)