arminit.cpp 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /* arminit.c -- ARMulator initialization: ARM6 Instruction Emulator.
  2. Copyright (C) 1994 Advanced RISC Machines Ltd.
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  14. #include <cstring>
  15. #include "core/arm/skyeye_common/armdefs.h"
  16. #include "core/arm/skyeye_common/armemu.h"
  17. #include "core/arm/skyeye_common/vfp/vfp.h"
  18. /***************************************************************************\
  19. * Returns a new instantiation of the ARMulator's state *
  20. \***************************************************************************/
  21. ARMul_State* ARMul_NewState(ARMul_State* state)
  22. {
  23. state->Emulate = RUN;
  24. state->Mode = USER32MODE;
  25. state->lateabtSig = HIGH;
  26. state->bigendSig = LOW;
  27. return state;
  28. }
  29. /***************************************************************************\
  30. * Call this routine to set ARMulator to model a certain processor *
  31. \***************************************************************************/
  32. void ARMul_SelectProcessor(ARMul_State* state, unsigned properties)
  33. {
  34. state->is_v4 = (properties & (ARM_v4_Prop | ARM_v5_Prop)) != 0;
  35. state->is_v5 = (properties & ARM_v5_Prop) != 0;
  36. state->is_v5e = (properties & ARM_v5e_Prop) != 0;
  37. state->is_v6 = (properties & ARM_v6_Prop) != 0;
  38. state->is_v7 = (properties & ARM_v7_Prop) != 0;
  39. }
  40. // Resets certain MPCore CP15 values to their ARM-defined reset values.
  41. static void ResetMPCoreCP15Registers(ARMul_State* cpu)
  42. {
  43. // c0
  44. cpu->CP15[CP15_MAIN_ID] = 0x410FB024;
  45. cpu->CP15[CP15_TLB_TYPE] = 0x00000800;
  46. cpu->CP15[CP15_PROCESSOR_FEATURE_0] = 0x00000111;
  47. cpu->CP15[CP15_PROCESSOR_FEATURE_1] = 0x00000001;
  48. cpu->CP15[CP15_DEBUG_FEATURE_0] = 0x00000002;
  49. cpu->CP15[CP15_MEMORY_MODEL_FEATURE_0] = 0x01100103;
  50. cpu->CP15[CP15_MEMORY_MODEL_FEATURE_1] = 0x10020302;
  51. cpu->CP15[CP15_MEMORY_MODEL_FEATURE_2] = 0x01222000;
  52. cpu->CP15[CP15_MEMORY_MODEL_FEATURE_3] = 0x00000000;
  53. cpu->CP15[CP15_ISA_FEATURE_0] = 0x00100011;
  54. cpu->CP15[CP15_ISA_FEATURE_1] = 0x12002111;
  55. cpu->CP15[CP15_ISA_FEATURE_2] = 0x11221011;
  56. cpu->CP15[CP15_ISA_FEATURE_3] = 0x01102131;
  57. cpu->CP15[CP15_ISA_FEATURE_4] = 0x00000141;
  58. // c1
  59. cpu->CP15[CP15_CONTROL] = 0x00054078;
  60. cpu->CP15[CP15_AUXILIARY_CONTROL] = 0x0000000F;
  61. cpu->CP15[CP15_COPROCESSOR_ACCESS_CONTROL] = 0x00000000;
  62. // c2
  63. cpu->CP15[CP15_TRANSLATION_BASE_TABLE_0] = 0x00000000;
  64. cpu->CP15[CP15_TRANSLATION_BASE_TABLE_1] = 0x00000000;
  65. cpu->CP15[CP15_TRANSLATION_BASE_CONTROL] = 0x00000000;
  66. // c3
  67. cpu->CP15[CP15_DOMAIN_ACCESS_CONTROL] = 0x00000000;
  68. // c7
  69. cpu->CP15[CP15_PHYS_ADDRESS] = 0x00000000;
  70. // c9
  71. cpu->CP15[CP15_DATA_CACHE_LOCKDOWN] = 0xFFFFFFF0;
  72. // c10
  73. cpu->CP15[CP15_TLB_LOCKDOWN] = 0x00000000;
  74. cpu->CP15[CP15_PRIMARY_REGION_REMAP] = 0x00098AA4;
  75. cpu->CP15[CP15_NORMAL_REGION_REMAP] = 0x44E048E0;
  76. // c13
  77. cpu->CP15[CP15_PID] = 0x00000000;
  78. cpu->CP15[CP15_CONTEXT_ID] = 0x00000000;
  79. cpu->CP15[CP15_THREAD_UPRW] = 0x00000000;
  80. cpu->CP15[CP15_THREAD_URO] = 0x00000000;
  81. cpu->CP15[CP15_THREAD_PRW] = 0x00000000;
  82. // c15
  83. cpu->CP15[CP15_PERFORMANCE_MONITOR_CONTROL] = 0x00000000;
  84. cpu->CP15[CP15_MAIN_TLB_LOCKDOWN_VIRT_ADDRESS] = 0x00000000;
  85. cpu->CP15[CP15_MAIN_TLB_LOCKDOWN_PHYS_ADDRESS] = 0x00000000;
  86. cpu->CP15[CP15_MAIN_TLB_LOCKDOWN_ATTRIBUTE] = 0x00000000;
  87. cpu->CP15[CP15_TLB_DEBUG_CONTROL] = 0x00000000;
  88. }
  89. /***************************************************************************\
  90. * Call this routine to set up the initial machine state (or perform a RESET *
  91. \***************************************************************************/
  92. void ARMul_Reset(ARMul_State* state)
  93. {
  94. VFPInit(state);
  95. state->Reg[15] = 0;
  96. state->Cpsr = INTBITS | SVC32MODE;
  97. state->Mode = SVC32MODE;
  98. state->Bank = SVCBANK;
  99. ResetMPCoreCP15Registers(state);
  100. state->NresetSig = HIGH;
  101. state->NfiqSig = HIGH;
  102. state->NirqSig = HIGH;
  103. state->NtransSig = (state->Mode & 3) ? HIGH : LOW;
  104. state->abortSig = LOW;
  105. state->NumInstrs = 0;
  106. }