proc-v7m.S 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /*
  2. * linux/arch/arm/mm/proc-v7m.S
  3. *
  4. * Copyright (C) 2008 ARM Ltd.
  5. * Copyright (C) 2001 Deep Blue Solutions Ltd.
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. *
  11. * This is the "shell" of the ARMv7-M processor support.
  12. */
  13. #include <linux/linkage.h>
  14. #include <asm/assembler.h>
  15. #include <asm/memory.h>
  16. #include <asm/v7m.h>
  17. #include "proc-macros.S"
  18. ENTRY(cpu_v7m_proc_init)
  19. ret lr
  20. ENDPROC(cpu_v7m_proc_init)
  21. ENTRY(cpu_v7m_proc_fin)
  22. ret lr
  23. ENDPROC(cpu_v7m_proc_fin)
  24. /*
  25. * cpu_v7m_reset(loc)
  26. *
  27. * Perform a soft reset of the system. Put the CPU into the
  28. * same state as it would be if it had been reset, and branch
  29. * to what would be the reset vector.
  30. *
  31. * - loc - location to jump to for soft reset
  32. */
  33. .align 5
  34. ENTRY(cpu_v7m_reset)
  35. ret r0
  36. ENDPROC(cpu_v7m_reset)
  37. /*
  38. * cpu_v7m_do_idle()
  39. *
  40. * Idle the processor (eg, wait for interrupt).
  41. *
  42. * IRQs are already disabled.
  43. */
  44. ENTRY(cpu_v7m_do_idle)
  45. wfi
  46. ret lr
  47. ENDPROC(cpu_v7m_do_idle)
  48. ENTRY(cpu_v7m_dcache_clean_area)
  49. ret lr
  50. ENDPROC(cpu_v7m_dcache_clean_area)
  51. /*
  52. * There is no MMU, so here is nothing to do.
  53. */
  54. ENTRY(cpu_v7m_switch_mm)
  55. ret lr
  56. ENDPROC(cpu_v7m_switch_mm)
  57. .globl cpu_v7m_suspend_size
  58. .equ cpu_v7m_suspend_size, 0
  59. #ifdef CONFIG_ARM_CPU_SUSPEND
  60. ENTRY(cpu_v7m_do_suspend)
  61. ret lr
  62. ENDPROC(cpu_v7m_do_suspend)
  63. ENTRY(cpu_v7m_do_resume)
  64. ret lr
  65. ENDPROC(cpu_v7m_do_resume)
  66. #endif
  67. .section ".text.init", #alloc, #execinstr
  68. /*
  69. * __v7m_setup
  70. *
  71. * This should be able to cover all ARMv7-M cores.
  72. */
  73. __v7m_setup:
  74. @ Configure the vector table base address
  75. ldr r0, =BASEADDR_V7M_SCB
  76. ldr r12, =vector_table
  77. str r12, [r0, V7M_SCB_VTOR]
  78. @ enable UsageFault, BusFault and MemManage fault.
  79. ldr r5, [r0, #V7M_SCB_SHCSR]
  80. orr r5, #(V7M_SCB_SHCSR_USGFAULTENA | V7M_SCB_SHCSR_BUSFAULTENA | V7M_SCB_SHCSR_MEMFAULTENA)
  81. str r5, [r0, #V7M_SCB_SHCSR]
  82. @ Lower the priority of the SVC and PendSV exceptions
  83. mov r5, #0x80000000
  84. str r5, [r0, V7M_SCB_SHPR2] @ set SVC priority
  85. mov r5, #0x00800000
  86. str r5, [r0, V7M_SCB_SHPR3] @ set PendSV priority
  87. @ SVC to switch to handler mode. Notice that this requires sp to
  88. @ point to writeable memory because the processor saves
  89. @ some registers to the stack.
  90. badr r1, 1f
  91. ldr r5, [r12, #11 * 4] @ read the SVC vector entry
  92. str r1, [r12, #11 * 4] @ write the temporary SVC vector entry
  93. mov r6, lr @ save LR
  94. ldr sp, =init_thread_union + THREAD_START_SP
  95. cpsie i
  96. svc #0
  97. 1: cpsid i
  98. str r5, [r12, #11 * 4] @ restore the original SVC vector entry
  99. mov lr, r6 @ restore LR
  100. @ Special-purpose control register
  101. mov r1, #1
  102. msr control, r1 @ Thread mode has unpriviledged access
  103. @ Configure the System Control Register to ensure 8-byte stack alignment
  104. @ Note the STKALIGN bit is either RW or RAO.
  105. ldr r12, [r0, V7M_SCB_CCR] @ system control register
  106. orr r12, #V7M_SCB_CCR_STKALIGN
  107. str r12, [r0, V7M_SCB_CCR]
  108. ret lr
  109. ENDPROC(__v7m_setup)
  110. define_processor_functions v7m, dabort=nommu_early_abort, pabort=legacy_pabort, nommu=1
  111. .section ".rodata"
  112. string cpu_arch_name, "armv7m"
  113. string cpu_elf_name "v7m"
  114. string cpu_v7m_name "ARMv7-M"
  115. .section ".proc.info.init", #alloc
  116. /*
  117. * Match any ARMv7-M processor core.
  118. */
  119. .type __v7m_proc_info, #object
  120. __v7m_proc_info:
  121. .long 0x000f0000 @ Required ID value
  122. .long 0x000f0000 @ Mask for ID
  123. .long 0 @ proc_info_list.__cpu_mm_mmu_flags
  124. .long 0 @ proc_info_list.__cpu_io_mmu_flags
  125. initfn __v7m_setup, __v7m_proc_info @ proc_info_list.__cpu_flush
  126. .long cpu_arch_name
  127. .long cpu_elf_name
  128. .long HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT
  129. .long cpu_v7m_name
  130. .long v7m_processor_functions @ proc_info_list.proc
  131. .long 0 @ proc_info_list.tlb
  132. .long 0 @ proc_info_list.user
  133. .long nop_cache_fns @ proc_info_list.cache
  134. .size __v7m_proc_info, . - __v7m_proc_info