proc-v7m.S 3.8 KB

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