head.S 16 KB

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