cpu64.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * QEMU AArch64 CPU
  3. *
  4. * Copyright (c) 2013 Linaro Ltd
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or (at your option) any later version.
  10. *
  11. * This program 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
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, see
  18. * <http://www.gnu.org/licenses/gpl-2.0.html>
  19. */
  20. #include "cpu.h"
  21. #include "qemu-common.h"
  22. #if !defined(CONFIG_USER_ONLY)
  23. #include "hw/loader.h"
  24. #endif
  25. #include "hw/arm/arm.h"
  26. #include "sysemu/sysemu.h"
  27. #include "sysemu/kvm.h"
  28. static inline void set_feature(CPUARMState *env, int feature)
  29. {
  30. env->features |= 1ULL << feature;
  31. }
  32. #ifdef CONFIG_USER_ONLY
  33. static void aarch64_any_initfn(Object *obj)
  34. {
  35. ARMCPU *cpu = ARM_CPU(obj);
  36. set_feature(&cpu->env, ARM_FEATURE_V8);
  37. set_feature(&cpu->env, ARM_FEATURE_VFP4);
  38. set_feature(&cpu->env, ARM_FEATURE_VFP_FP16);
  39. set_feature(&cpu->env, ARM_FEATURE_NEON);
  40. set_feature(&cpu->env, ARM_FEATURE_THUMB2EE);
  41. set_feature(&cpu->env, ARM_FEATURE_ARM_DIV);
  42. set_feature(&cpu->env, ARM_FEATURE_V7MP);
  43. set_feature(&cpu->env, ARM_FEATURE_AARCH64);
  44. }
  45. #endif
  46. typedef struct ARMCPUInfo {
  47. const char *name;
  48. void (*initfn)(Object *obj);
  49. void (*class_init)(ObjectClass *oc, void *data);
  50. } ARMCPUInfo;
  51. static const ARMCPUInfo aarch64_cpus[] = {
  52. #ifdef CONFIG_USER_ONLY
  53. { .name = "any", .initfn = aarch64_any_initfn },
  54. #endif
  55. };
  56. static void aarch64_cpu_initfn(Object *obj)
  57. {
  58. }
  59. static void aarch64_cpu_finalizefn(Object *obj)
  60. {
  61. }
  62. static void aarch64_cpu_class_init(ObjectClass *oc, void *data)
  63. {
  64. CPUClass *cc = CPU_CLASS(oc);
  65. cc->dump_state = aarch64_cpu_dump_state;
  66. cc->gdb_read_register = aarch64_cpu_gdb_read_register;
  67. cc->gdb_write_register = aarch64_cpu_gdb_write_register;
  68. cc->gdb_num_core_regs = 34;
  69. cc->gdb_core_xml_file = "aarch64-core.xml";
  70. }
  71. static void aarch64_cpu_register(const ARMCPUInfo *info)
  72. {
  73. TypeInfo type_info = {
  74. .parent = TYPE_AARCH64_CPU,
  75. .instance_size = sizeof(ARMCPU),
  76. .instance_init = info->initfn,
  77. .class_size = sizeof(ARMCPUClass),
  78. .class_init = info->class_init,
  79. };
  80. type_info.name = g_strdup_printf("%s-" TYPE_ARM_CPU, info->name);
  81. type_register(&type_info);
  82. g_free((void *)type_info.name);
  83. }
  84. static const TypeInfo aarch64_cpu_type_info = {
  85. .name = TYPE_AARCH64_CPU,
  86. .parent = TYPE_ARM_CPU,
  87. .instance_size = sizeof(ARMCPU),
  88. .instance_init = aarch64_cpu_initfn,
  89. .instance_finalize = aarch64_cpu_finalizefn,
  90. .abstract = true,
  91. .class_size = sizeof(AArch64CPUClass),
  92. .class_init = aarch64_cpu_class_init,
  93. };
  94. static void aarch64_cpu_register_types(void)
  95. {
  96. int i;
  97. type_register_static(&aarch64_cpu_type_info);
  98. for (i = 0; i < ARRAY_SIZE(aarch64_cpus); i++) {
  99. aarch64_cpu_register(&aarch64_cpus[i]);
  100. }
  101. }
  102. type_init(aarch64_cpu_register_types)