head.S 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622
  1. /*
  2. * linux/arch/arm/kernel/head.S
  3. *
  4. * Copyright (C) 1994-2002 Russell King
  5. * Copyright (c) 2003 ARM Limited
  6. * All Rights Reserved
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. *
  12. * Kernel startup code for all 32-bit CPUs
  13. */
  14. #include <linux/linkage.h>
  15. #include <linux/init.h>
  16. #include <asm/assembler.h>
  17. #include <asm/cp15.h>
  18. #include <asm/domain.h>
  19. #include <asm/ptrace.h>
  20. #include <asm/asm-offsets.h>
  21. #include <asm/memory.h>
  22. #include <asm/thread_info.h>
  23. #include <asm/pgtable.h>
  24. #ifdef CONFIG_DEBUG_LL
  25. #include <mach/debug-macro.S>
  26. #endif
  27. /*
  28. * swapper_pg_dir is the virtual address of the initial page table.
  29. * We place the page tables 16K below KERNEL_RAM_VADDR. Therefore, we must
  30. * make sure that KERNEL_RAM_VADDR is correctly set. Currently, we expect
  31. * the least significant 16 bits to be 0x8000, but we could probably
  32. * relax this restriction to KERNEL_RAM_VADDR >= PAGE_OFFSET + 0x4000.
  33. */
  34. #define KERNEL_RAM_VADDR (PAGE_OFFSET + TEXT_OFFSET)
  35. #if (KERNEL_RAM_VADDR & 0xffff) != 0x8000
  36. #error KERNEL_RAM_VADDR must start at 0xXXXX8000
  37. #endif
  38. #ifdef CONFIG_ARM_LPAE
  39. /* LPAE requires an additional page for the PGD */
  40. #define PG_DIR_SIZE 0x5000
  41. #define PMD_ORDER 3
  42. #else
  43. #define PG_DIR_SIZE 0x4000
  44. #define PMD_ORDER 2
  45. #endif
  46. .globl swapper_pg_dir
  47. .equ swapper_pg_dir, KERNEL_RAM_VADDR - PG_DIR_SIZE
  48. .macro pgtbl, rd, phys
  49. add \rd, \phys, #TEXT_OFFSET - PG_DIR_SIZE
  50. .endm
  51. #ifdef CONFIG_XIP_KERNEL
  52. #define KERNEL_START XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR)
  53. #define KERNEL_END _edata_loc
  54. #else
  55. #define KERNEL_START KERNEL_RAM_VADDR
  56. #define KERNEL_END _end
  57. #endif
  58. /*
  59. * Kernel startup entry point.
  60. * ---------------------------
  61. *
  62. * This is normally called from the decompressor code. The requirements
  63. * are: MMU = off, D-cache = off, I-cache = dont care, r0 = 0,
  64. * r1 = machine nr, r2 = atags or dtb pointer.
  65. *
  66. * This code is mostly position independent, so if you link the kernel at
  67. * 0xc0008000, you call this at __pa(0xc0008000).
  68. *
  69. * See linux/arch/arm/tools/mach-types for the complete list of machine
  70. * numbers for r1.
  71. *
  72. * We're trying to keep crap to a minimum; DO NOT add any machine specific
  73. * crap here - that's what the boot loader (or in extreme, well justified
  74. * circumstances, zImage) is for.
  75. */
  76. .arm
  77. __HEAD
  78. ENTRY(stext)
  79. THUMB( adr r9, BSYM(1f) ) @ Kernel is always entered in ARM.
  80. THUMB( bx r9 ) @ If this is a Thumb-2 kernel,
  81. THUMB( .thumb ) @ switch to Thumb now.
  82. THUMB(1: )
  83. setmode PSR_F_BIT | PSR_I_BIT | SVC_MODE, r9 @ ensure svc mode
  84. @ and irqs disabled
  85. mrc p15, 0, r9, c0, c0 @ get processor id
  86. bl __lookup_processor_type @ r5=procinfo r9=cpuid
  87. movs r10, r5 @ invalid processor (r5=0)?
  88. THUMB( it eq ) @ force fixup-able long branch encoding
  89. beq __error_p @ yes, error 'p'
  90. #ifdef CONFIG_ARM_LPAE
  91. mrc p15, 0, r3, c0, c1, 4 @ read ID_MMFR0
  92. and r3, r3, #0xf @ extract VMSA support
  93. cmp r3, #5 @ long-descriptor translation table format?
  94. THUMB( it lo ) @ force fixup-able long branch encoding
  95. blo __error_p @ only classic page table format
  96. #endif
  97. #ifndef CONFIG_XIP_KERNEL
  98. adr r3, 2f
  99. ldmia r3, {r4, r8}
  100. sub r4, r3, r4 @ (PHYS_OFFSET - PAGE_OFFSET)
  101. add r8, r8, r4 @ PHYS_OFFSET
  102. #else
  103. ldr r8, =PHYS_OFFSET @ always constant in this case
  104. #endif
  105. /*
  106. * r1 = machine no, r2 = atags or dtb,
  107. * r8 = phys_offset, r9 = cpuid, r10 = procinfo
  108. */
  109. bl __vet_atags
  110. #ifdef CONFIG_SMP_ON_UP
  111. bl __fixup_smp
  112. #endif
  113. #ifdef CONFIG_ARM_PATCH_PHYS_VIRT
  114. bl __fixup_pv_table
  115. #endif
  116. bl __create_page_tables
  117. /*
  118. * The following calls CPU specific code in a position independent
  119. * manner. See arch/arm/mm/proc-*.S for details. r10 = base of
  120. * xxx_proc_info structure selected by __lookup_processor_type
  121. * above. On return, the CPU will be ready for the MMU to be
  122. * turned on, and r0 will hold the CPU control register value.
  123. */
  124. ldr r13, =__mmap_switched @ address to jump to after
  125. @ mmu has been enabled
  126. adr lr, BSYM(1f) @ return (PIC) address
  127. mov r8, r4 @ set TTBR1 to swapper_pg_dir
  128. ARM( add pc, r10, #PROCINFO_INITFUNC )
  129. THUMB( add r12, r10, #PROCINFO_INITFUNC )
  130. THUMB( mov pc, r12 )
  131. 1: b __enable_mmu
  132. ENDPROC(stext)
  133. .ltorg
  134. #ifndef CONFIG_XIP_KERNEL
  135. 2: .long .
  136. .long PAGE_OFFSET
  137. #endif
  138. /*
  139. * Setup the initial page tables. We only setup the barest
  140. * amount which are required to get the kernel running, which
  141. * generally means mapping in the kernel code.
  142. *
  143. * r8 = phys_offset, r9 = cpuid, r10 = procinfo
  144. *
  145. * Returns:
  146. * r0, r3, r5-r7 corrupted
  147. * r4 = physical page table address
  148. */
  149. __create_page_tables:
  150. pgtbl r4, r8 @ page table address
  151. /*
  152. * Clear the swapper page table
  153. */
  154. mov r0, r4
  155. mov r3, #0
  156. add r6, r0, #PG_DIR_SIZE
  157. 1: str r3, [r0], #4
  158. str r3, [r0], #4
  159. str r3, [r0], #4
  160. str r3, [r0], #4
  161. teq r0, r6
  162. bne 1b
  163. #ifdef CONFIG_ARM_LPAE
  164. /*
  165. * Build the PGD table (first level) to point to the PMD table. A PGD
  166. * entry is 64-bit wide.
  167. */
  168. mov r0, r4
  169. add r3, r4, #0x1000 @ first PMD table address
  170. orr r3, r3, #3 @ PGD block type
  171. mov r6, #4 @ PTRS_PER_PGD
  172. mov r7, #1 << (55 - 32) @ L_PGD_SWAPPER
  173. 1: str r3, [r0], #4 @ set bottom PGD entry bits
  174. str r7, [r0], #4 @ set top PGD entry bits
  175. add r3, r3, #0x1000 @ next PMD table
  176. subs r6, r6, #1
  177. bne 1b
  178. add r4, r4, #0x1000 @ point to the PMD tables
  179. #endif
  180. ldr r7, [r10, #PROCINFO_MM_MMUFLAGS] @ mm_mmuflags
  181. /*
  182. * Create identity mapping to cater for __enable_mmu.
  183. * This identity mapping will be removed by paging_init().
  184. */
  185. adr r0, __turn_mmu_on_loc
  186. ldmia r0, {r3, r5, r6}
  187. sub r0, r0, r3 @ virt->phys offset
  188. add r5, r5, r0 @ phys __turn_mmu_on
  189. add r6, r6, r0 @ phys __turn_mmu_on_end
  190. mov r5, r5, lsr #SECTION_SHIFT
  191. mov r6, r6, lsr #SECTION_SHIFT
  192. 1: orr r3, r7, r5, lsl #SECTION_SHIFT @ flags + kernel base
  193. str r3, [r4, r5, lsl #PMD_ORDER] @ identity mapping
  194. cmp r5, r6
  195. addlo r5, r5, #1 @ next section
  196. blo 1b
  197. /*
  198. * Now setup the pagetables for our kernel direct
  199. * mapped region.
  200. */
  201. mov r3, pc
  202. mov r3, r3, lsr #SECTION_SHIFT
  203. orr r3, r7, r3, lsl #SECTION_SHIFT
  204. add r0, r4, #(KERNEL_START & 0xff000000) >> (SECTION_SHIFT - PMD_ORDER)
  205. str r3, [r0, #((KERNEL_START & 0x00f00000) >> SECTION_SHIFT) << PMD_ORDER]!
  206. ldr r6, =(KERNEL_END - 1)
  207. add r0, r0, #1 << PMD_ORDER
  208. add r6, r4, r6, lsr #(SECTION_SHIFT - PMD_ORDER)
  209. 1: cmp r0, r6
  210. add r3, r3, #1 << SECTION_SHIFT
  211. strls r3, [r0], #1 << PMD_ORDER
  212. bls 1b
  213. #ifdef CONFIG_XIP_KERNEL
  214. /*
  215. * Map some ram to cover our .data and .bss areas.
  216. */
  217. add r3, r8, #TEXT_OFFSET
  218. orr r3, r3, r7
  219. add r0, r4, #(KERNEL_RAM_VADDR & 0xff000000) >> (SECTION_SHIFT - PMD_ORDER)
  220. str r3, [r0, #(KERNEL_RAM_VADDR & 0x00f00000) >> (SECTION_SHIFT - PMD_ORDER)]!
  221. ldr r6, =(_end - 1)
  222. add r0, r0, #4
  223. add r6, r4, r6, lsr #(SECTION_SHIFT - PMD_ORDER)
  224. 1: cmp r0, r6
  225. add r3, r3, #1 << 20
  226. strls r3, [r0], #4
  227. bls 1b
  228. #endif
  229. /*
  230. * Then map boot params address in r2 or the first 1MB (2MB with LPAE)
  231. * of ram if boot params address is not specified.
  232. */
  233. mov r0, r2, lsr #SECTION_SHIFT
  234. movs r0, r0, lsl #SECTION_SHIFT
  235. moveq r0, r8
  236. sub r3, r0, r8
  237. add r3, r3, #PAGE_OFFSET
  238. add r3, r4, r3, lsr #(SECTION_SHIFT - PMD_ORDER)
  239. orr r6, r7, r0
  240. str r6, [r3]
  241. #ifdef CONFIG_DEBUG_LL
  242. #if !defined(CONFIG_DEBUG_ICEDCC) && !defined(CONFIG_DEBUG_SEMIHOSTING)
  243. /*
  244. * Map in IO space for serial debugging.
  245. * This allows debug messages to be output
  246. * via a serial console before paging_init.
  247. */
  248. addruart r7, r3, r0
  249. mov r3, r3, lsr #SECTION_SHIFT
  250. mov r3, r3, lsl #PMD_ORDER
  251. add r0, r4, r3
  252. rsb r3, r3, #0x4000 @ PTRS_PER_PGD*sizeof(long)
  253. cmp r3, #0x0800 @ limit to 512MB
  254. movhi r3, #0x0800
  255. add r6, r0, r3
  256. mov r3, r7, lsr #SECTION_SHIFT
  257. ldr r7, [r10, #PROCINFO_IO_MMUFLAGS] @ io_mmuflags
  258. orr r3, r7, r3, lsl #SECTION_SHIFT
  259. #ifdef CONFIG_ARM_LPAE
  260. mov r7, #1 << (54 - 32) @ XN
  261. #else
  262. orr r3, r3, #PMD_SECT_XN
  263. #endif
  264. 1: str r3, [r0], #4
  265. #ifdef CONFIG_ARM_LPAE
  266. str r7, [r0], #4
  267. #endif
  268. add r3, r3, #1 << SECTION_SHIFT
  269. cmp r0, r6
  270. blo 1b
  271. #else /* CONFIG_DEBUG_ICEDCC || CONFIG_DEBUG_SEMIHOSTING */
  272. /* we don't need any serial debugging mappings */
  273. ldr r7, [r10, #PROCINFO_IO_MMUFLAGS] @ io_mmuflags
  274. #endif
  275. #if defined(CONFIG_ARCH_NETWINDER) || defined(CONFIG_ARCH_CATS)
  276. /*
  277. * If we're using the NetWinder or CATS, we also need to map
  278. * in the 16550-type serial port for the debug messages
  279. */
  280. add r0, r4, #0xff000000 >> (SECTION_SHIFT - PMD_ORDER)
  281. orr r3, r7, #0x7c000000
  282. str r3, [r0]
  283. #endif
  284. #ifdef CONFIG_ARCH_RPC
  285. /*
  286. * Map in screen at 0x02000000 & SCREEN2_BASE
  287. * Similar reasons here - for debug. This is
  288. * only for Acorn RiscPC architectures.
  289. */
  290. add r0, r4, #0x02000000 >> (SECTION_SHIFT - PMD_ORDER)
  291. orr r3, r7, #0x02000000
  292. str r3, [r0]
  293. add r0, r4, #0xd8000000 >> (SECTION_SHIFT - PMD_ORDER)
  294. str r3, [r0]
  295. #endif
  296. #endif
  297. #ifdef CONFIG_ARM_LPAE
  298. sub r4, r4, #0x1000 @ point to the PGD table
  299. #endif
  300. mov pc, lr
  301. ENDPROC(__create_page_tables)
  302. .ltorg
  303. .align
  304. __turn_mmu_on_loc:
  305. .long .
  306. .long __turn_mmu_on
  307. .long __turn_mmu_on_end
  308. #if defined(CONFIG_SMP)
  309. __CPUINIT
  310. ENTRY(secondary_startup)
  311. /*
  312. * Common entry point for secondary CPUs.
  313. *
  314. * Ensure that we're in SVC mode, and IRQs are disabled. Lookup
  315. * the processor type - there is no need to check the machine type
  316. * as it has already been validated by the primary processor.
  317. */
  318. setmode PSR_F_BIT | PSR_I_BIT | SVC_MODE, r9
  319. mrc p15, 0, r9, c0, c0 @ get processor id
  320. bl __lookup_processor_type
  321. movs r10, r5 @ invalid processor?
  322. moveq r0, #'p' @ yes, error 'p'
  323. THUMB( it eq ) @ force fixup-able long branch encoding
  324. beq __error_p
  325. /*
  326. * Use the page tables supplied from __cpu_up.
  327. */
  328. adr r4, __secondary_data
  329. ldmia r4, {r5, r7, r12} @ address to jump to after
  330. sub lr, r4, r5 @ mmu has been enabled
  331. ldr r4, [r7, lr] @ get secondary_data.pgdir
  332. add r7, r7, #4
  333. ldr r8, [r7, lr] @ get secondary_data.swapper_pg_dir
  334. adr lr, BSYM(__enable_mmu) @ return address
  335. mov r13, r12 @ __secondary_switched address
  336. ARM( add pc, r10, #PROCINFO_INITFUNC ) @ initialise processor
  337. @ (return control reg)
  338. THUMB( add r12, r10, #PROCINFO_INITFUNC )
  339. THUMB( mov pc, r12 )
  340. ENDPROC(secondary_startup)
  341. /*
  342. * r6 = &secondary_data
  343. */
  344. ENTRY(__secondary_switched)
  345. ldr sp, [r7, #4] @ get secondary_data.stack
  346. mov fp, #0
  347. b secondary_start_kernel
  348. ENDPROC(__secondary_switched)
  349. .align
  350. .type __secondary_data, %object
  351. __secondary_data:
  352. .long .
  353. .long secondary_data
  354. .long __secondary_switched
  355. #endif /* defined(CONFIG_SMP) */
  356. /*
  357. * Setup common bits before finally enabling the MMU. Essentially
  358. * this is just loading the page table pointer and domain access
  359. * registers.
  360. *
  361. * r0 = cp#15 control register
  362. * r1 = machine ID
  363. * r2 = atags or dtb pointer
  364. * r4 = page table pointer
  365. * r9 = processor ID
  366. * r13 = *virtual* address to jump to upon completion
  367. */
  368. __enable_mmu:
  369. #if defined(CONFIG_ALIGNMENT_TRAP) && __LINUX_ARM_ARCH__ < 6
  370. orr r0, r0, #CR_A
  371. #else
  372. bic r0, r0, #CR_A
  373. #endif
  374. #ifdef CONFIG_CPU_DCACHE_DISABLE
  375. bic r0, r0, #CR_C
  376. #endif
  377. #ifdef CONFIG_CPU_BPREDICT_DISABLE
  378. bic r0, r0, #CR_Z
  379. #endif
  380. #ifdef CONFIG_CPU_ICACHE_DISABLE
  381. bic r0, r0, #CR_I
  382. #endif
  383. #ifdef CONFIG_ARM_LPAE
  384. mov r5, #0
  385. mcrr p15, 0, r4, r5, c2 @ load TTBR0
  386. #else
  387. mov r5, #(domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
  388. domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
  389. domain_val(DOMAIN_TABLE, DOMAIN_MANAGER) | \
  390. domain_val(DOMAIN_IO, DOMAIN_CLIENT))
  391. mcr p15, 0, r5, c3, c0, 0 @ load domain access register
  392. mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
  393. #endif
  394. b __turn_mmu_on
  395. ENDPROC(__enable_mmu)
  396. /*
  397. * Enable the MMU. This completely changes the structure of the visible
  398. * memory space. You will not be able to trace execution through this.
  399. * If you have an enquiry about this, *please* check the linux-arm-kernel
  400. * mailing list archives BEFORE sending another post to the list.
  401. *
  402. * r0 = cp#15 control register
  403. * r1 = machine ID
  404. * r2 = atags or dtb pointer
  405. * r9 = processor ID
  406. * r13 = *virtual* address to jump to upon completion
  407. *
  408. * other registers depend on the function called upon completion
  409. */
  410. .align 5
  411. .pushsection .idmap.text, "ax"
  412. ENTRY(__turn_mmu_on)
  413. mov r0, r0
  414. instr_sync
  415. mcr p15, 0, r0, c1, c0, 0 @ write control reg
  416. mrc p15, 0, r3, c0, c0, 0 @ read id reg
  417. instr_sync
  418. mov r3, r3
  419. mov r3, r13
  420. mov pc, r3
  421. __turn_mmu_on_end:
  422. ENDPROC(__turn_mmu_on)
  423. .popsection
  424. #ifdef CONFIG_SMP_ON_UP
  425. __INIT
  426. __fixup_smp:
  427. and r3, r9, #0x000f0000 @ architecture version
  428. teq r3, #0x000f0000 @ CPU ID supported?
  429. bne __fixup_smp_on_up @ no, assume UP
  430. bic r3, r9, #0x00ff0000
  431. bic r3, r3, #0x0000000f @ mask 0xff00fff0
  432. mov r4, #0x41000000
  433. orr r4, r4, #0x0000b000
  434. orr r4, r4, #0x00000020 @ val 0x4100b020
  435. teq r3, r4 @ ARM 11MPCore?
  436. moveq pc, lr @ yes, assume SMP
  437. mrc p15, 0, r0, c0, c0, 5 @ read MPIDR
  438. and r0, r0, #0xc0000000 @ multiprocessing extensions and
  439. teq r0, #0x80000000 @ not part of a uniprocessor system?
  440. moveq pc, lr @ yes, assume SMP
  441. __fixup_smp_on_up:
  442. adr r0, 1f
  443. ldmia r0, {r3 - r5}
  444. sub r3, r0, r3
  445. add r4, r4, r3
  446. add r5, r5, r3
  447. b __do_fixup_smp_on_up
  448. ENDPROC(__fixup_smp)
  449. .align
  450. 1: .word .
  451. .word __smpalt_begin
  452. .word __smpalt_end
  453. .pushsection .data
  454. .globl smp_on_up
  455. smp_on_up:
  456. ALT_SMP(.long 1)
  457. ALT_UP(.long 0)
  458. .popsection
  459. #endif
  460. .text
  461. __do_fixup_smp_on_up:
  462. cmp r4, r5
  463. movhs pc, lr
  464. ldmia r4!, {r0, r6}
  465. ARM( str r6, [r0, r3] )
  466. THUMB( add r0, r0, r3 )
  467. #ifdef __ARMEB__
  468. THUMB( mov r6, r6, ror #16 ) @ Convert word order for big-endian.
  469. #endif
  470. THUMB( strh r6, [r0], #2 ) @ For Thumb-2, store as two halfwords
  471. THUMB( mov r6, r6, lsr #16 ) @ to be robust against misaligned r3.
  472. THUMB( strh r6, [r0] )
  473. b __do_fixup_smp_on_up
  474. ENDPROC(__do_fixup_smp_on_up)
  475. ENTRY(fixup_smp)
  476. stmfd sp!, {r4 - r6, lr}
  477. mov r4, r0
  478. add r5, r0, r1
  479. mov r3, #0
  480. bl __do_fixup_smp_on_up
  481. ldmfd sp!, {r4 - r6, pc}
  482. ENDPROC(fixup_smp)
  483. #ifdef CONFIG_ARM_PATCH_PHYS_VIRT
  484. /* __fixup_pv_table - patch the stub instructions with the delta between
  485. * PHYS_OFFSET and PAGE_OFFSET, which is assumed to be 16MiB aligned and
  486. * can be expressed by an immediate shifter operand. The stub instruction
  487. * has a form of '(add|sub) rd, rn, #imm'.
  488. */
  489. __HEAD
  490. __fixup_pv_table:
  491. adr r0, 1f
  492. ldmia r0, {r3-r5, r7}
  493. sub r3, r0, r3 @ PHYS_OFFSET - PAGE_OFFSET
  494. add r4, r4, r3 @ adjust table start address
  495. add r5, r5, r3 @ adjust table end address
  496. add r7, r7, r3 @ adjust __pv_phys_offset address
  497. str r8, [r7] @ save computed PHYS_OFFSET to __pv_phys_offset
  498. mov r6, r3, lsr #24 @ constant for add/sub instructions
  499. teq r3, r6, lsl #24 @ must be 16MiB aligned
  500. THUMB( it ne @ cross section branch )
  501. bne __error
  502. str r6, [r7, #4] @ save to __pv_offset
  503. b __fixup_a_pv_table
  504. ENDPROC(__fixup_pv_table)
  505. .align
  506. 1: .long .
  507. .long __pv_table_begin
  508. .long __pv_table_end
  509. 2: .long __pv_phys_offset
  510. .text
  511. __fixup_a_pv_table:
  512. #ifdef CONFIG_THUMB2_KERNEL
  513. lsls r6, #24
  514. beq 2f
  515. clz r7, r6
  516. lsr r6, #24
  517. lsl r6, r7
  518. bic r6, #0x0080
  519. lsrs r7, #1
  520. orrcs r6, #0x0080
  521. orr r6, r6, r7, lsl #12
  522. orr r6, #0x4000
  523. b 2f
  524. 1: add r7, r3
  525. ldrh ip, [r7, #2]
  526. and ip, 0x8f00
  527. orr ip, r6 @ mask in offset bits 31-24
  528. strh ip, [r7, #2]
  529. 2: cmp r4, r5
  530. ldrcc r7, [r4], #4 @ use branch for delay slot
  531. bcc 1b
  532. bx lr
  533. #else
  534. b 2f
  535. 1: ldr ip, [r7, r3]
  536. bic ip, ip, #0x000000ff
  537. orr ip, ip, r6 @ mask in offset bits 31-24
  538. str ip, [r7, r3]
  539. 2: cmp r4, r5
  540. ldrcc r7, [r4], #4 @ use branch for delay slot
  541. bcc 1b
  542. mov pc, lr
  543. #endif
  544. ENDPROC(__fixup_a_pv_table)
  545. ENTRY(fixup_pv_table)
  546. stmfd sp!, {r4 - r7, lr}
  547. ldr r2, 2f @ get address of __pv_phys_offset
  548. mov r3, #0 @ no offset
  549. mov r4, r0 @ r0 = table start
  550. add r5, r0, r1 @ r1 = table size
  551. ldr r6, [r2, #4] @ get __pv_offset
  552. bl __fixup_a_pv_table
  553. ldmfd sp!, {r4 - r7, pc}
  554. ENDPROC(fixup_pv_table)
  555. .align
  556. 2: .long __pv_phys_offset
  557. .data
  558. .globl __pv_phys_offset
  559. .type __pv_phys_offset, %object
  560. __pv_phys_offset:
  561. .long 0
  562. .size __pv_phys_offset, . - __pv_phys_offset
  563. __pv_offset:
  564. .long 0
  565. #endif
  566. #include "head-common.S"