2019-06-04 11:11:33 +03:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* linux/arch/arm/kernel/head.S
|
|
|
|
*
|
|
|
|
* Copyright (C) 1994-2002 Russell King
|
2005-06-18 12:33:31 +04:00
|
|
|
* Copyright (c) 2003 ARM Limited
|
|
|
|
* All Rights Reserved
|
2005-04-17 02:20:36 +04:00
|
|
|
*
|
|
|
|
* Kernel startup code for all 32-bit CPUs
|
|
|
|
*/
|
|
|
|
#include <linux/linkage.h>
|
|
|
|
#include <linux/init.h>
|
2020-06-09 07:32:42 +03:00
|
|
|
#include <linux/pgtable.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
#include <asm/assembler.h>
|
2012-01-19 14:05:41 +04:00
|
|
|
#include <asm/cp15.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
#include <asm/domain.h>
|
|
|
|
#include <asm/ptrace.h>
|
2005-09-09 23:08:59 +04:00
|
|
|
#include <asm/asm-offsets.h>
|
2005-10-30 00:44:55 +04:00
|
|
|
#include <asm/memory.h>
|
2005-05-05 16:11:00 +04:00
|
|
|
#include <asm/thread_info.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-08-31 09:03:46 +04:00
|
|
|
#if defined(CONFIG_DEBUG_LL) && !defined(CONFIG_DEBUG_SEMIHOSTING)
|
|
|
|
#include CONFIG_DEBUG_LL_INCLUDE
|
2010-07-07 07:19:48 +04:00
|
|
|
#endif
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/*
|
2005-10-30 00:44:56 +04:00
|
|
|
* swapper_pg_dir is the virtual address of the initial page table.
|
2006-12-12 01:29:16 +03:00
|
|
|
* We place the page tables 16K below KERNEL_RAM_VADDR. Therefore, we must
|
|
|
|
* make sure that KERNEL_RAM_VADDR is correctly set. Currently, we expect
|
2005-10-30 00:44:56 +04:00
|
|
|
* the least significant 16 bits to be 0x8000, but we could probably
|
2006-12-12 01:29:16 +03:00
|
|
|
* relax this restriction to KERNEL_RAM_VADDR >= PAGE_OFFSET + 0x4000.
|
2005-04-17 02:20:36 +04:00
|
|
|
*/
|
ARM: P2V: eliminate head.S use of PHYS_OFFSET for !XIP_KERNEL
head.S makes use of PHYS_OFFSET. When it becomes a variable, the
assembler won't understand this. Compute PHYS_OFFSET by the following
method. This code is linked at its virtual address, but run at before
the MMU is enabled, so at his physical address.
1: .long .
.long PAGE_OFFSET
adr r0, 1b @ r0 = physical ','
ldmia r0, {r1, r2} @ r1 = virtual '.', r2 = PAGE_OFFSET
sub r1, r0, r1 @ r1 = physical-virtual
add r2, r2, r1 @ r2 = PAGE_OFFSET + physical-virtual
@ := PHYS_OFFSET.
Switch XIP users of PHYS_OFFSET to use PLAT_PHYS_OFFSET - we can't
use this method for XIP kernels as the code doesn't execute in RAM.
Tested-by: Tony Lindgren <tony@atomide.com>
Reviewed-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2011-01-04 22:04:00 +03:00
|
|
|
#define KERNEL_RAM_VADDR (PAGE_OFFSET + TEXT_OFFSET)
|
2006-12-12 01:29:16 +03:00
|
|
|
#if (KERNEL_RAM_VADDR & 0xffff) != 0x8000
|
|
|
|
#error KERNEL_RAM_VADDR must start at 0xXXXX8000
|
2005-04-17 02:20:36 +04:00
|
|
|
#endif
|
|
|
|
|
2011-11-22 21:30:29 +04:00
|
|
|
#ifdef CONFIG_ARM_LPAE
|
|
|
|
/* LPAE requires an additional page for the PGD */
|
|
|
|
#define PG_DIR_SIZE 0x5000
|
|
|
|
#define PMD_ORDER 3
|
|
|
|
#else
|
2011-08-23 17:07:23 +04:00
|
|
|
#define PG_DIR_SIZE 0x4000
|
|
|
|
#define PMD_ORDER 2
|
2011-11-22 21:30:29 +04:00
|
|
|
#endif
|
2011-08-23 17:07:23 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
.globl swapper_pg_dir
|
2011-08-23 17:07:23 +04:00
|
|
|
.equ swapper_pg_dir, KERNEL_RAM_VADDR - PG_DIR_SIZE
|
2005-04-17 02:20:36 +04:00
|
|
|
|
ARM: P2V: eliminate head.S use of PHYS_OFFSET for !XIP_KERNEL
head.S makes use of PHYS_OFFSET. When it becomes a variable, the
assembler won't understand this. Compute PHYS_OFFSET by the following
method. This code is linked at its virtual address, but run at before
the MMU is enabled, so at his physical address.
1: .long .
.long PAGE_OFFSET
adr r0, 1b @ r0 = physical ','
ldmia r0, {r1, r2} @ r1 = virtual '.', r2 = PAGE_OFFSET
sub r1, r0, r1 @ r1 = physical-virtual
add r2, r2, r1 @ r2 = PAGE_OFFSET + physical-virtual
@ := PHYS_OFFSET.
Switch XIP users of PHYS_OFFSET to use PLAT_PHYS_OFFSET - we can't
use this method for XIP kernels as the code doesn't execute in RAM.
Tested-by: Tony Lindgren <tony@atomide.com>
Reviewed-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2011-01-04 22:04:00 +03:00
|
|
|
.macro pgtbl, rd, phys
|
2014-01-21 19:25:34 +04:00
|
|
|
add \rd, \phys, #TEXT_OFFSET
|
|
|
|
sub \rd, \rd, #PG_DIR_SIZE
|
2005-04-17 02:20:36 +04:00
|
|
|
.endm
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Kernel startup entry point.
|
|
|
|
* ---------------------------
|
|
|
|
*
|
|
|
|
* This is normally called from the decompressor code. The requirements
|
|
|
|
* are: MMU = off, D-cache = off, I-cache = dont care, r0 = 0,
|
2011-04-29 00:27:20 +04:00
|
|
|
* r1 = machine nr, r2 = atags or dtb pointer.
|
2005-04-17 02:20:36 +04:00
|
|
|
*
|
|
|
|
* This code is mostly position independent, so if you link the kernel at
|
|
|
|
* 0xc0008000, you call this at __pa(0xc0008000).
|
|
|
|
*
|
|
|
|
* See linux/arch/arm/tools/mach-types for the complete list of machine
|
|
|
|
* numbers for r1.
|
|
|
|
*
|
|
|
|
* We're trying to keep crap to a minimum; DO NOT add any machine specific
|
|
|
|
* crap here - that's what the boot loader (or in extreme, well justified
|
|
|
|
* circumstances, zImage) is for.
|
|
|
|
*/
|
2011-07-13 18:53:30 +04:00
|
|
|
.arm
|
|
|
|
|
2009-10-03 00:32:46 +04:00
|
|
|
__HEAD
|
2005-04-17 02:20:36 +04:00
|
|
|
ENTRY(stext)
|
2013-02-01 13:40:42 +04:00
|
|
|
ARM_BE8(setend be ) @ ensure we are in BE8 mode
|
2011-07-13 18:53:30 +04:00
|
|
|
|
2015-04-21 16:17:25 +03:00
|
|
|
THUMB( badr r9, 1f ) @ Kernel is always entered in ARM.
|
2011-07-13 18:53:30 +04:00
|
|
|
THUMB( bx r9 ) @ If this is a Thumb-2 kernel,
|
|
|
|
THUMB( .thumb ) @ switch to Thumb now.
|
|
|
|
THUMB(1: )
|
|
|
|
|
2012-02-09 20:47:17 +04:00
|
|
|
#ifdef CONFIG_ARM_VIRT_EXT
|
|
|
|
bl __hyp_stub_install
|
|
|
|
#endif
|
|
|
|
@ ensure svc mode and all interrupts masked
|
|
|
|
safe_svcmode_maskall r9
|
|
|
|
|
2006-02-25 00:04:56 +03:00
|
|
|
mrc p15, 0, r9, c0, c0 @ get processor id
|
2005-04-17 02:20:36 +04:00
|
|
|
bl __lookup_processor_type @ r5=procinfo r9=cpuid
|
|
|
|
movs r10, r5 @ invalid processor (r5=0)?
|
2010-11-29 21:43:28 +03:00
|
|
|
THUMB( it eq ) @ force fixup-able long branch encoding
|
2005-11-25 18:43:22 +03:00
|
|
|
beq __error_p @ yes, error 'p'
|
2010-11-22 15:06:28 +03:00
|
|
|
|
2012-01-09 15:24:47 +04:00
|
|
|
#ifdef CONFIG_ARM_LPAE
|
|
|
|
mrc p15, 0, r3, c0, c1, 4 @ read ID_MMFR0
|
|
|
|
and r3, r3, #0xf @ extract VMSA support
|
|
|
|
cmp r3, #5 @ long-descriptor translation table format?
|
|
|
|
THUMB( it lo ) @ force fixup-able long branch encoding
|
ARM: 7980/1: kernel: improve error message when LPAE config doesn't match CPU
Currently, when the kernel is configured with LPAE support, but the
CPU doesn't support it, the error message is fairly cryptic:
Error: unrecognized/unsupported processor variant (0x561f5811).
This messages is normally shown when there is an issue when comparing
the processor ID (CP15 0, c0, c0) with the values/masks described in
proc-v7.S. However, the same message is displayed when LPAE support is
enabled in the kernel configuration, but not available in the CPU,
after looking at ID_MMFR0 (CP15 0, c0, c1, 4). Having the same error
message is highly misleading.
This commit improves this by showing a different error message when
this situation occurs:
Error: Kernel with LPAE support, but CPU does not support LPAE.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2014-02-18 20:02:54 +04:00
|
|
|
blo __error_lpae @ only classic page table format
|
2012-01-09 15:24:47 +04:00
|
|
|
#endif
|
|
|
|
|
ARM: P2V: eliminate head.S use of PHYS_OFFSET for !XIP_KERNEL
head.S makes use of PHYS_OFFSET. When it becomes a variable, the
assembler won't understand this. Compute PHYS_OFFSET by the following
method. This code is linked at its virtual address, but run at before
the MMU is enabled, so at his physical address.
1: .long .
.long PAGE_OFFSET
adr r0, 1b @ r0 = physical ','
ldmia r0, {r1, r2} @ r1 = virtual '.', r2 = PAGE_OFFSET
sub r1, r0, r1 @ r1 = physical-virtual
add r2, r2, r1 @ r2 = PAGE_OFFSET + physical-virtual
@ := PHYS_OFFSET.
Switch XIP users of PHYS_OFFSET to use PLAT_PHYS_OFFSET - we can't
use this method for XIP kernels as the code doesn't execute in RAM.
Tested-by: Tony Lindgren <tony@atomide.com>
Reviewed-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2011-01-04 22:04:00 +03:00
|
|
|
#ifndef CONFIG_XIP_KERNEL
|
2020-09-14 11:25:46 +03:00
|
|
|
adr_l r8, _text @ __pa(_text)
|
|
|
|
sub r8, r8, #TEXT_OFFSET @ PHYS_OFFSET
|
ARM: P2V: eliminate head.S use of PHYS_OFFSET for !XIP_KERNEL
head.S makes use of PHYS_OFFSET. When it becomes a variable, the
assembler won't understand this. Compute PHYS_OFFSET by the following
method. This code is linked at its virtual address, but run at before
the MMU is enabled, so at his physical address.
1: .long .
.long PAGE_OFFSET
adr r0, 1b @ r0 = physical ','
ldmia r0, {r1, r2} @ r1 = virtual '.', r2 = PAGE_OFFSET
sub r1, r0, r1 @ r1 = physical-virtual
add r2, r2, r1 @ r2 = PAGE_OFFSET + physical-virtual
@ := PHYS_OFFSET.
Switch XIP users of PHYS_OFFSET to use PLAT_PHYS_OFFSET - we can't
use this method for XIP kernels as the code doesn't execute in RAM.
Tested-by: Tony Lindgren <tony@atomide.com>
Reviewed-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2011-01-04 22:04:00 +03:00
|
|
|
#else
|
2013-12-10 23:21:08 +04:00
|
|
|
ldr r8, =PLAT_PHYS_OFFSET @ always constant in this case
|
ARM: P2V: eliminate head.S use of PHYS_OFFSET for !XIP_KERNEL
head.S makes use of PHYS_OFFSET. When it becomes a variable, the
assembler won't understand this. Compute PHYS_OFFSET by the following
method. This code is linked at its virtual address, but run at before
the MMU is enabled, so at his physical address.
1: .long .
.long PAGE_OFFSET
adr r0, 1b @ r0 = physical ','
ldmia r0, {r1, r2} @ r1 = virtual '.', r2 = PAGE_OFFSET
sub r1, r0, r1 @ r1 = physical-virtual
add r2, r2, r1 @ r2 = PAGE_OFFSET + physical-virtual
@ := PHYS_OFFSET.
Switch XIP users of PHYS_OFFSET to use PLAT_PHYS_OFFSET - we can't
use this method for XIP kernels as the code doesn't execute in RAM.
Tested-by: Tony Lindgren <tony@atomide.com>
Reviewed-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2011-01-04 22:04:00 +03:00
|
|
|
#endif
|
|
|
|
|
2010-11-22 15:06:28 +03:00
|
|
|
/*
|
2011-04-29 00:27:20 +04:00
|
|
|
* r1 = machine no, r2 = atags or dtb,
|
ARM: P2V: eliminate head.S use of PHYS_OFFSET for !XIP_KERNEL
head.S makes use of PHYS_OFFSET. When it becomes a variable, the
assembler won't understand this. Compute PHYS_OFFSET by the following
method. This code is linked at its virtual address, but run at before
the MMU is enabled, so at his physical address.
1: .long .
.long PAGE_OFFSET
adr r0, 1b @ r0 = physical ','
ldmia r0, {r1, r2} @ r1 = virtual '.', r2 = PAGE_OFFSET
sub r1, r0, r1 @ r1 = physical-virtual
add r2, r2, r1 @ r2 = PAGE_OFFSET + physical-virtual
@ := PHYS_OFFSET.
Switch XIP users of PHYS_OFFSET to use PLAT_PHYS_OFFSET - we can't
use this method for XIP kernels as the code doesn't execute in RAM.
Tested-by: Tony Lindgren <tony@atomide.com>
Reviewed-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2011-01-04 22:04:00 +03:00
|
|
|
* r8 = phys_offset, r9 = cpuid, r10 = procinfo
|
2010-11-22 15:06:28 +03:00
|
|
|
*/
|
2007-06-01 01:02:22 +04:00
|
|
|
bl __vet_atags
|
2010-09-04 13:47:48 +04:00
|
|
|
#ifdef CONFIG_SMP_ON_UP
|
|
|
|
bl __fixup_smp
|
ARM: P2V: introduce phys_to_virt/virt_to_phys runtime patching
This idea came from Nicolas, Eric Miao produced an initial version,
which was then rewritten into this.
Patch the physical to virtual translations at runtime. As we modify
the code, this makes it incompatible with XIP kernels, but allows us
to achieve this with minimal loss of performance.
As many translations are of the form:
physical = virtual + (PHYS_OFFSET - PAGE_OFFSET)
virtual = physical - (PHYS_OFFSET - PAGE_OFFSET)
we generate an 'add' instruction for __virt_to_phys(), and a 'sub'
instruction for __phys_to_virt(). We calculate at run time (PHYS_OFFSET
- PAGE_OFFSET) by comparing the address prior to MMU initialization with
where it should be once the MMU has been initialized, and place this
constant into the above add/sub instructions.
Once we have (PHYS_OFFSET - PAGE_OFFSET), we can calculate the real
PHYS_OFFSET as PAGE_OFFSET is a build-time constant, and save this for
the C-mode PHYS_OFFSET variable definition to use.
At present, we are unable to support Realview with Sparsemem enabled
as this uses a complex mapping function, and MSM as this requires a
constant which will not fit in our math instruction.
Add a module version magic string for this feature to prevent
incompatible modules being loaded.
Tested-by: Tony Lindgren <tony@atomide.com>
Reviewed-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Tested-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2011-01-04 22:09:43 +03:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_ARM_PATCH_PHYS_VIRT
|
|
|
|
bl __fixup_pv_table
|
2010-09-04 13:47:48 +04:00
|
|
|
#endif
|
2005-04-17 02:20:36 +04:00
|
|
|
bl __create_page_tables
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The following calls CPU specific code in a position independent
|
|
|
|
* manner. See arch/arm/mm/proc-*.S for details. r10 = base of
|
2011-01-12 20:50:42 +03:00
|
|
|
* xxx_proc_info structure selected by __lookup_processor_type
|
2015-04-04 22:09:46 +03:00
|
|
|
* above.
|
|
|
|
*
|
|
|
|
* The processor init function will be called with:
|
|
|
|
* r1 - machine type
|
|
|
|
* r2 - boot data (atags/dt) pointer
|
|
|
|
* r4 - translation table base (low word)
|
|
|
|
* r5 - translation table base (high word, if LPAE)
|
|
|
|
* r8 - translation table base 1 (pfn if LPAE)
|
|
|
|
* r9 - cpuid
|
|
|
|
* r13 - virtual address for __enable_mmu -> __turn_mmu_on
|
|
|
|
*
|
|
|
|
* On return, the CPU will be ready for the MMU to be turned on,
|
|
|
|
* r0 will hold the CPU control register value, r1, r2, r4, and
|
|
|
|
* r9 will be preserved. r5 will also be preserved if LPAE.
|
2005-04-17 02:20:36 +04:00
|
|
|
*/
|
2010-10-04 19:22:34 +04:00
|
|
|
ldr r13, =__mmap_switched @ address to jump to after
|
2005-04-17 02:20:36 +04:00
|
|
|
@ mmu has been enabled
|
2015-04-21 16:17:25 +03:00
|
|
|
badr lr, 1f @ return (PIC) address
|
2015-04-04 22:09:46 +03:00
|
|
|
#ifdef CONFIG_ARM_LPAE
|
|
|
|
mov r5, #0 @ high TTBR0
|
|
|
|
mov r8, r4, lsr #12 @ TTBR1 is swapper_pg_dir pfn
|
|
|
|
#else
|
2011-05-26 14:22:44 +04:00
|
|
|
mov r8, r4 @ set TTBR1 to swapper_pg_dir
|
2015-04-04 22:09:46 +03:00
|
|
|
#endif
|
2015-03-18 09:29:32 +03:00
|
|
|
ldr r12, [r10, #PROCINFO_INITFUNC]
|
|
|
|
add r12, r12, r10
|
|
|
|
ret r12
|
2010-10-04 20:56:13 +04:00
|
|
|
1: b __enable_mmu
|
2008-08-28 14:22:32 +04:00
|
|
|
ENDPROC(stext)
|
2010-10-04 19:22:34 +04:00
|
|
|
.ltorg
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Setup the initial page tables. We only setup the barest
|
|
|
|
* amount which are required to get the kernel running, which
|
|
|
|
* generally means mapping in the kernel code.
|
|
|
|
*
|
ARM: P2V: eliminate head.S use of PHYS_OFFSET for !XIP_KERNEL
head.S makes use of PHYS_OFFSET. When it becomes a variable, the
assembler won't understand this. Compute PHYS_OFFSET by the following
method. This code is linked at its virtual address, but run at before
the MMU is enabled, so at his physical address.
1: .long .
.long PAGE_OFFSET
adr r0, 1b @ r0 = physical ','
ldmia r0, {r1, r2} @ r1 = virtual '.', r2 = PAGE_OFFSET
sub r1, r0, r1 @ r1 = physical-virtual
add r2, r2, r1 @ r2 = PAGE_OFFSET + physical-virtual
@ := PHYS_OFFSET.
Switch XIP users of PHYS_OFFSET to use PLAT_PHYS_OFFSET - we can't
use this method for XIP kernels as the code doesn't execute in RAM.
Tested-by: Tony Lindgren <tony@atomide.com>
Reviewed-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2011-01-04 22:04:00 +03:00
|
|
|
* r8 = phys_offset, r9 = cpuid, r10 = procinfo
|
2005-04-17 02:20:36 +04:00
|
|
|
*
|
|
|
|
* Returns:
|
2010-10-04 20:51:54 +04:00
|
|
|
* r0, r3, r5-r7 corrupted
|
2015-04-04 22:09:46 +03:00
|
|
|
* r4 = physical page table address
|
2005-04-17 02:20:36 +04:00
|
|
|
*/
|
|
|
|
__create_page_tables:
|
ARM: P2V: eliminate head.S use of PHYS_OFFSET for !XIP_KERNEL
head.S makes use of PHYS_OFFSET. When it becomes a variable, the
assembler won't understand this. Compute PHYS_OFFSET by the following
method. This code is linked at its virtual address, but run at before
the MMU is enabled, so at his physical address.
1: .long .
.long PAGE_OFFSET
adr r0, 1b @ r0 = physical ','
ldmia r0, {r1, r2} @ r1 = virtual '.', r2 = PAGE_OFFSET
sub r1, r0, r1 @ r1 = physical-virtual
add r2, r2, r1 @ r2 = PAGE_OFFSET + physical-virtual
@ := PHYS_OFFSET.
Switch XIP users of PHYS_OFFSET to use PLAT_PHYS_OFFSET - we can't
use this method for XIP kernels as the code doesn't execute in RAM.
Tested-by: Tony Lindgren <tony@atomide.com>
Reviewed-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2011-01-04 22:04:00 +03:00
|
|
|
pgtbl r4, r8 @ page table address
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/*
|
2011-08-23 17:07:23 +04:00
|
|
|
* Clear the swapper page table
|
2005-04-17 02:20:36 +04:00
|
|
|
*/
|
|
|
|
mov r0, r4
|
|
|
|
mov r3, #0
|
2011-08-23 17:07:23 +04:00
|
|
|
add r6, r0, #PG_DIR_SIZE
|
2005-04-17 02:20:36 +04:00
|
|
|
1: str r3, [r0], #4
|
|
|
|
str r3, [r0], #4
|
|
|
|
str r3, [r0], #4
|
|
|
|
str r3, [r0], #4
|
|
|
|
teq r0, r6
|
|
|
|
bne 1b
|
|
|
|
|
2011-11-22 21:30:29 +04:00
|
|
|
#ifdef CONFIG_ARM_LPAE
|
|
|
|
/*
|
|
|
|
* Build the PGD table (first level) to point to the PMD table. A PGD
|
|
|
|
* entry is 64-bit wide.
|
|
|
|
*/
|
|
|
|
mov r0, r4
|
|
|
|
add r3, r4, #0x1000 @ first PMD table address
|
|
|
|
orr r3, r3, #3 @ PGD block type
|
|
|
|
mov r6, #4 @ PTRS_PER_PGD
|
|
|
|
mov r7, #1 << (55 - 32) @ L_PGD_SWAPPER
|
2013-02-28 20:46:16 +04:00
|
|
|
1:
|
|
|
|
#ifdef CONFIG_CPU_ENDIAN_BE8
|
2011-11-22 21:30:29 +04:00
|
|
|
str r7, [r0], #4 @ set top PGD entry bits
|
2013-02-28 20:46:16 +04:00
|
|
|
str r3, [r0], #4 @ set bottom PGD entry bits
|
|
|
|
#else
|
|
|
|
str r3, [r0], #4 @ set bottom PGD entry bits
|
|
|
|
str r7, [r0], #4 @ set top PGD entry bits
|
|
|
|
#endif
|
2011-11-22 21:30:29 +04:00
|
|
|
add r3, r3, #0x1000 @ next PMD table
|
|
|
|
subs r6, r6, #1
|
|
|
|
bne 1b
|
|
|
|
|
|
|
|
add r4, r4, #0x1000 @ point to the PMD tables
|
2013-02-28 20:46:16 +04:00
|
|
|
#ifdef CONFIG_CPU_ENDIAN_BE8
|
|
|
|
add r4, r4, #4 @ we only write the bottom word
|
|
|
|
#endif
|
2011-11-22 21:30:29 +04:00
|
|
|
#endif
|
|
|
|
|
2006-06-29 21:24:21 +04:00
|
|
|
ldr r7, [r10, #PROCINFO_MM_MMUFLAGS] @ mm_mmuflags
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/*
|
2010-10-04 20:51:54 +04:00
|
|
|
* Create identity mapping to cater for __enable_mmu.
|
|
|
|
* This identity mapping will be removed by paging_init().
|
2005-04-17 02:20:36 +04:00
|
|
|
*/
|
2020-09-14 11:25:16 +03:00
|
|
|
adr_l r5, __turn_mmu_on @ _pa(__turn_mmu_on)
|
|
|
|
adr_l r6, __turn_mmu_on_end @ _pa(__turn_mmu_on_end)
|
2011-08-23 17:07:23 +04:00
|
|
|
mov r5, r5, lsr #SECTION_SHIFT
|
|
|
|
mov r6, r6, lsr #SECTION_SHIFT
|
2010-10-04 20:51:54 +04:00
|
|
|
|
2011-08-23 17:07:23 +04:00
|
|
|
1: orr r3, r7, r5, lsl #SECTION_SHIFT @ flags + kernel base
|
|
|
|
str r3, [r4, r5, lsl #PMD_ORDER] @ identity mapping
|
|
|
|
cmp r5, r6
|
|
|
|
addlo r5, r5, #1 @ next section
|
|
|
|
blo 1b
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/*
|
2012-07-04 07:58:12 +04:00
|
|
|
* Map our RAM from the start to the end of the kernel .bss section.
|
2005-04-17 02:20:36 +04:00
|
|
|
*/
|
2012-07-04 07:58:12 +04:00
|
|
|
add r0, r4, #PAGE_OFFSET >> (SECTION_SHIFT - PMD_ORDER)
|
|
|
|
ldr r6, =(_end - 1)
|
|
|
|
orr r3, r8, r7
|
2011-08-23 17:07:23 +04:00
|
|
|
add r6, r4, r6, lsr #(SECTION_SHIFT - PMD_ORDER)
|
2012-07-04 07:58:12 +04:00
|
|
|
1: str r3, [r0], #1 << PMD_ORDER
|
2011-08-23 17:07:23 +04:00
|
|
|
add r3, r3, #1 << SECTION_SHIFT
|
2012-07-04 07:58:12 +04:00
|
|
|
cmp r0, r6
|
2007-02-22 18:18:09 +03:00
|
|
|
bls 1b
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2007-02-21 17:32:28 +03:00
|
|
|
#ifdef CONFIG_XIP_KERNEL
|
|
|
|
/*
|
2012-07-04 07:58:12 +04:00
|
|
|
* Map the kernel image separately as it is not located in RAM.
|
2007-02-21 17:32:28 +03:00
|
|
|
*/
|
2012-07-04 07:58:12 +04:00
|
|
|
#define XIP_START XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR)
|
|
|
|
mov r3, pc
|
|
|
|
mov r3, r3, lsr #SECTION_SHIFT
|
|
|
|
orr r3, r7, r3, lsl #SECTION_SHIFT
|
|
|
|
add r0, r4, #(XIP_START & 0xff000000) >> (SECTION_SHIFT - PMD_ORDER)
|
|
|
|
str r3, [r0, #((XIP_START & 0x00f00000) >> SECTION_SHIFT) << PMD_ORDER]!
|
|
|
|
ldr r6, =(_edata_loc - 1)
|
|
|
|
add r0, r0, #1 << PMD_ORDER
|
2011-08-23 17:07:23 +04:00
|
|
|
add r6, r4, r6, lsr #(SECTION_SHIFT - PMD_ORDER)
|
2007-02-21 17:32:28 +03:00
|
|
|
1: cmp r0, r6
|
2012-07-04 07:58:12 +04:00
|
|
|
add r3, r3, #1 << SECTION_SHIFT
|
|
|
|
strls r3, [r0], #1 << PMD_ORDER
|
2007-02-21 17:32:28 +03:00
|
|
|
bls 1b
|
|
|
|
#endif
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/*
|
2012-07-04 07:58:12 +04:00
|
|
|
* Then map boot params address in r2 if specified.
|
2013-01-15 21:51:32 +04:00
|
|
|
* We map 2 sections in case the ATAGs/DTB crosses a section boundary.
|
2005-04-17 02:20:36 +04:00
|
|
|
*/
|
2011-08-23 17:07:23 +04:00
|
|
|
mov r0, r2, lsr #SECTION_SHIFT
|
2020-11-17 10:41:01 +03:00
|
|
|
cmp r2, #0
|
ARM: 9012/1: move device tree mapping out of linear region
On ARM, setting up the linear region is tricky, given the constraints
around placement and alignment of the memblocks, and how the kernel
itself as well as the DT are placed in physical memory.
Let's simplify matters a bit, by moving the device tree mapping to the
top of the address space, right between the end of the vmalloc region
and the start of the the fixmap region, and create a read-only mapping
for it that is independent of the size of the linear region, and how it
is organized.
Since this region was formerly used as a guard region, which will now be
populated fully on LPAE builds by this read-only mapping (which will
still be able to function as a guard region for stray writes), bump the
start of the [underutilized] fixmap region by 512 KB as well, to ensure
that there is always a proper guard region here. Doing so still leaves
ample room for the fixmap space, even with NR_CPUS set to its maximum
value of 32.
Tested-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
2020-10-11 12:21:37 +03:00
|
|
|
ldrne r3, =FDT_FIXED_BASE >> (SECTION_SHIFT - PMD_ORDER)
|
|
|
|
addne r3, r3, r4
|
2020-11-17 10:41:01 +03:00
|
|
|
orrne r6, r7, r0, lsl #SECTION_SHIFT
|
2013-01-15 21:51:32 +04:00
|
|
|
strne r6, [r3], #1 << PMD_ORDER
|
|
|
|
addne r6, r6, #1 << SECTION_SHIFT
|
2012-07-04 07:58:12 +04:00
|
|
|
strne r6, [r3]
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2013-04-03 15:24:45 +04:00
|
|
|
#if defined(CONFIG_ARM_LPAE) && defined(CONFIG_CPU_ENDIAN_BE8)
|
2013-02-28 20:46:16 +04:00
|
|
|
sub r4, r4, #4 @ Fixup page table pointer
|
|
|
|
@ for 64-bit descriptors
|
|
|
|
#endif
|
|
|
|
|
2005-07-01 14:56:55 +04:00
|
|
|
#ifdef CONFIG_DEBUG_LL
|
2012-02-23 00:58:03 +04:00
|
|
|
#if !defined(CONFIG_DEBUG_ICEDCC) && !defined(CONFIG_DEBUG_SEMIHOSTING)
|
2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* Map in IO space for serial debugging.
|
|
|
|
* This allows debug messages to be output
|
|
|
|
* via a serial console before paging_init.
|
|
|
|
*/
|
2011-09-01 06:55:46 +04:00
|
|
|
addruart r7, r3, r0
|
2010-07-07 07:19:48 +04:00
|
|
|
|
2011-08-23 17:07:23 +04:00
|
|
|
mov r3, r3, lsr #SECTION_SHIFT
|
|
|
|
mov r3, r3, lsl #PMD_ORDER
|
2010-07-07 07:19:48 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
add r0, r4, r3
|
2011-08-23 17:07:23 +04:00
|
|
|
mov r3, r7, lsr #SECTION_SHIFT
|
2010-07-07 07:19:48 +04:00
|
|
|
ldr r7, [r10, #PROCINFO_IO_MMUFLAGS] @ io_mmuflags
|
2011-08-23 17:07:23 +04:00
|
|
|
orr r3, r7, r3, lsl #SECTION_SHIFT
|
2011-11-22 21:30:29 +04:00
|
|
|
#ifdef CONFIG_ARM_LPAE
|
|
|
|
mov r7, #1 << (54 - 32) @ XN
|
2013-02-28 20:46:16 +04:00
|
|
|
#ifdef CONFIG_CPU_ENDIAN_BE8
|
|
|
|
str r7, [r0], #4
|
|
|
|
str r3, [r0], #4
|
2011-11-22 21:30:29 +04:00
|
|
|
#else
|
2012-03-18 23:29:42 +04:00
|
|
|
str r3, [r0], #4
|
2011-11-22 21:30:29 +04:00
|
|
|
str r7, [r0], #4
|
|
|
|
#endif
|
2013-02-28 20:46:16 +04:00
|
|
|
#else
|
|
|
|
orr r3, r3, #PMD_SECT_XN
|
|
|
|
str r3, [r0], #4
|
|
|
|
#endif
|
2010-07-07 07:19:48 +04:00
|
|
|
|
2012-02-23 00:58:03 +04:00
|
|
|
#else /* CONFIG_DEBUG_ICEDCC || CONFIG_DEBUG_SEMIHOSTING */
|
|
|
|
/* we don't need any serial debugging mappings */
|
2010-07-07 07:19:48 +04:00
|
|
|
ldr r7, [r10, #PROCINFO_IO_MMUFLAGS] @ io_mmuflags
|
2012-02-23 00:58:03 +04:00
|
|
|
#endif
|
2010-07-07 07:19:48 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
#if defined(CONFIG_ARCH_NETWINDER) || defined(CONFIG_ARCH_CATS)
|
|
|
|
/*
|
2005-11-25 18:43:22 +03:00
|
|
|
* If we're using the NetWinder or CATS, we also need to map
|
|
|
|
* in the 16550-type serial port for the debug messages
|
2005-04-17 02:20:36 +04:00
|
|
|
*/
|
2011-08-23 17:07:23 +04:00
|
|
|
add r0, r4, #0xff000000 >> (SECTION_SHIFT - PMD_ORDER)
|
2005-07-01 14:56:55 +04:00
|
|
|
orr r3, r7, #0x7c000000
|
|
|
|
str r3, [r0]
|
2005-04-17 02:20:36 +04:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_ARCH_RPC
|
|
|
|
/*
|
|
|
|
* Map in screen at 0x02000000 & SCREEN2_BASE
|
|
|
|
* Similar reasons here - for debug. This is
|
|
|
|
* only for Acorn RiscPC architectures.
|
|
|
|
*/
|
2011-08-23 17:07:23 +04:00
|
|
|
add r0, r4, #0x02000000 >> (SECTION_SHIFT - PMD_ORDER)
|
2005-07-01 14:56:55 +04:00
|
|
|
orr r3, r7, #0x02000000
|
2005-04-17 02:20:36 +04:00
|
|
|
str r3, [r0]
|
2011-08-23 17:07:23 +04:00
|
|
|
add r0, r4, #0xd8000000 >> (SECTION_SHIFT - PMD_ORDER)
|
2005-04-17 02:20:36 +04:00
|
|
|
str r3, [r0]
|
2005-07-01 14:56:55 +04:00
|
|
|
#endif
|
2011-11-22 21:30:29 +04:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_ARM_LPAE
|
|
|
|
sub r4, r4, #0x1000 @ point to the PGD table
|
2005-04-17 02:20:36 +04:00
|
|
|
#endif
|
2014-06-30 19:29:12 +04:00
|
|
|
ret lr
|
2008-08-28 14:22:32 +04:00
|
|
|
ENDPROC(__create_page_tables)
|
2005-04-17 02:20:36 +04:00
|
|
|
.ltorg
|
|
|
|
|
2010-10-04 20:56:13 +04:00
|
|
|
#if defined(CONFIG_SMP)
|
2013-07-31 14:37:17 +04:00
|
|
|
.text
|
2015-01-31 02:25:30 +03:00
|
|
|
.arm
|
2015-05-18 11:04:31 +03:00
|
|
|
ENTRY(secondary_startup_arm)
|
2015-04-21 16:17:25 +03:00
|
|
|
THUMB( badr r9, 1f ) @ Kernel is entered in ARM.
|
2015-01-31 02:25:30 +03:00
|
|
|
THUMB( bx r9 ) @ If this is a Thumb-2 kernel,
|
|
|
|
THUMB( .thumb ) @ switch to Thumb now.
|
|
|
|
THUMB(1: )
|
2010-10-04 20:56:13 +04:00
|
|
|
ENTRY(secondary_startup)
|
|
|
|
/*
|
|
|
|
* Common entry point for secondary CPUs.
|
|
|
|
*
|
|
|
|
* Ensure that we're in SVC mode, and IRQs are disabled. Lookup
|
|
|
|
* the processor type - there is no need to check the machine type
|
|
|
|
* as it has already been validated by the primary processor.
|
|
|
|
*/
|
2013-02-01 13:40:42 +04:00
|
|
|
|
|
|
|
ARM_BE8(setend be) @ ensure we are in BE8 mode
|
|
|
|
|
2012-02-09 20:47:17 +04:00
|
|
|
#ifdef CONFIG_ARM_VIRT_EXT
|
2013-01-04 21:44:14 +04:00
|
|
|
bl __hyp_stub_install_secondary
|
2012-02-09 20:47:17 +04:00
|
|
|
#endif
|
|
|
|
safe_svcmode_maskall r9
|
|
|
|
|
2010-10-04 20:56:13 +04:00
|
|
|
mrc p15, 0, r9, c0, c0 @ get processor id
|
|
|
|
bl __lookup_processor_type
|
|
|
|
movs r10, r5 @ invalid processor?
|
|
|
|
moveq r0, #'p' @ yes, error 'p'
|
2010-11-29 21:43:28 +03:00
|
|
|
THUMB( it eq ) @ force fixup-able long branch encoding
|
2010-10-04 20:56:13 +04:00
|
|
|
beq __error_p
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Use the page tables supplied from __cpu_up.
|
|
|
|
*/
|
2020-09-14 11:25:23 +03:00
|
|
|
adr_l r3, secondary_data
|
|
|
|
mov_l r12, __secondary_switched
|
2018-11-09 06:26:39 +03:00
|
|
|
ldrd r4, r5, [r3, #0] @ get secondary_data.pgdir
|
2015-08-06 17:07:04 +03:00
|
|
|
ARM_BE8(eor r4, r4, r5) @ Swap r5 and r4 in BE:
|
|
|
|
ARM_BE8(eor r5, r4, r5) @ it can be done in 3 steps
|
|
|
|
ARM_BE8(eor r4, r4, r5) @ without using a temp reg.
|
2015-04-04 22:09:46 +03:00
|
|
|
ldr r8, [r3, #8] @ get secondary_data.swapper_pg_dir
|
2015-04-21 16:17:25 +03:00
|
|
|
badr lr, __enable_mmu @ return address
|
2010-10-04 20:56:13 +04:00
|
|
|
mov r13, r12 @ __secondary_switched address
|
2015-03-18 09:29:32 +03:00
|
|
|
ldr r12, [r10, #PROCINFO_INITFUNC]
|
|
|
|
add r12, r12, r10 @ initialise processor
|
|
|
|
@ (return control reg)
|
|
|
|
ret r12
|
2010-10-04 20:56:13 +04:00
|
|
|
ENDPROC(secondary_startup)
|
2015-01-31 02:25:30 +03:00
|
|
|
ENDPROC(secondary_startup_arm)
|
2010-10-04 20:56:13 +04:00
|
|
|
|
|
|
|
ENTRY(__secondary_switched)
|
2020-09-14 11:25:23 +03:00
|
|
|
ldr_l r7, secondary_data + 12 @ get secondary_data.stack
|
|
|
|
mov sp, r7
|
2010-10-04 20:56:13 +04:00
|
|
|
mov fp, #0
|
|
|
|
b secondary_start_kernel
|
|
|
|
ENDPROC(__secondary_switched)
|
|
|
|
|
|
|
|
#endif /* defined(CONFIG_SMP) */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Setup common bits before finally enabling the MMU. Essentially
|
|
|
|
* this is just loading the page table pointer and domain access
|
2015-04-04 22:09:46 +03:00
|
|
|
* registers. All these registers need to be preserved by the
|
|
|
|
* processor setup function (or set in the case of r0)
|
2010-10-04 21:02:59 +04:00
|
|
|
*
|
|
|
|
* r0 = cp#15 control register
|
|
|
|
* r1 = machine ID
|
2011-04-29 00:27:20 +04:00
|
|
|
* r2 = atags or dtb pointer
|
2015-04-04 22:09:46 +03:00
|
|
|
* r4 = TTBR pointer (low word)
|
|
|
|
* r5 = TTBR pointer (high word if LPAE)
|
2010-10-04 21:02:59 +04:00
|
|
|
* r9 = processor ID
|
|
|
|
* r13 = *virtual* address to jump to upon completion
|
2010-10-04 20:56:13 +04:00
|
|
|
*/
|
|
|
|
__enable_mmu:
|
2011-11-07 21:05:53 +04:00
|
|
|
#if defined(CONFIG_ALIGNMENT_TRAP) && __LINUX_ARM_ARCH__ < 6
|
2010-10-04 20:56:13 +04:00
|
|
|
orr r0, r0, #CR_A
|
|
|
|
#else
|
|
|
|
bic r0, r0, #CR_A
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_CPU_DCACHE_DISABLE
|
|
|
|
bic r0, r0, #CR_C
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_CPU_BPREDICT_DISABLE
|
|
|
|
bic r0, r0, #CR_Z
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_CPU_ICACHE_DISABLE
|
|
|
|
bic r0, r0, #CR_I
|
|
|
|
#endif
|
2015-04-04 22:09:46 +03:00
|
|
|
#ifdef CONFIG_ARM_LPAE
|
|
|
|
mcrr p15, 0, r4, r5, c2 @ load TTBR0
|
|
|
|
#else
|
2015-08-21 11:23:26 +03:00
|
|
|
mov r5, #DACR_INIT
|
2010-10-04 20:56:13 +04:00
|
|
|
mcr p15, 0, r5, c3, c0, 0 @ load domain access register
|
|
|
|
mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
|
2011-11-22 21:30:29 +04:00
|
|
|
#endif
|
2010-10-04 20:56:13 +04:00
|
|
|
b __turn_mmu_on
|
|
|
|
ENDPROC(__enable_mmu)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Enable the MMU. This completely changes the structure of the visible
|
|
|
|
* memory space. You will not be able to trace execution through this.
|
|
|
|
* If you have an enquiry about this, *please* check the linux-arm-kernel
|
|
|
|
* mailing list archives BEFORE sending another post to the list.
|
|
|
|
*
|
|
|
|
* r0 = cp#15 control register
|
2010-10-04 21:02:59 +04:00
|
|
|
* r1 = machine ID
|
2011-04-29 00:27:20 +04:00
|
|
|
* r2 = atags or dtb pointer
|
2010-10-04 21:02:59 +04:00
|
|
|
* r9 = processor ID
|
2010-10-04 20:56:13 +04:00
|
|
|
* r13 = *virtual* address to jump to upon completion
|
|
|
|
*
|
|
|
|
* other registers depend on the function called upon completion
|
|
|
|
*/
|
|
|
|
.align 5
|
2011-11-23 16:26:25 +04:00
|
|
|
.pushsection .idmap.text, "ax"
|
|
|
|
ENTRY(__turn_mmu_on)
|
2010-10-04 20:56:13 +04:00
|
|
|
mov r0, r0
|
2011-11-22 21:30:28 +04:00
|
|
|
instr_sync
|
2010-10-04 20:56:13 +04:00
|
|
|
mcr p15, 0, r0, c1, c0, 0 @ write control reg
|
|
|
|
mrc p15, 0, r3, c0, c0, 0 @ read id reg
|
2011-11-22 21:30:28 +04:00
|
|
|
instr_sync
|
2010-10-04 20:56:13 +04:00
|
|
|
mov r3, r3
|
|
|
|
mov r3, r13
|
2014-06-30 19:29:12 +04:00
|
|
|
ret r3
|
2011-11-23 16:03:27 +04:00
|
|
|
__turn_mmu_on_end:
|
2010-10-04 20:56:13 +04:00
|
|
|
ENDPROC(__turn_mmu_on)
|
2011-11-23 16:26:25 +04:00
|
|
|
.popsection
|
2010-10-04 20:56:13 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2010-09-04 13:47:48 +04:00
|
|
|
#ifdef CONFIG_SMP_ON_UP
|
2014-04-16 18:38:26 +04:00
|
|
|
__HEAD
|
2010-09-04 13:47:48 +04:00
|
|
|
__fixup_smp:
|
2011-01-30 19:40:20 +03:00
|
|
|
and r3, r9, #0x000f0000 @ architecture version
|
|
|
|
teq r3, #0x000f0000 @ CPU ID supported?
|
2010-09-04 13:47:48 +04:00
|
|
|
bne __fixup_smp_on_up @ no, assume UP
|
|
|
|
|
2011-01-30 19:40:20 +03:00
|
|
|
bic r3, r9, #0x00ff0000
|
|
|
|
bic r3, r3, #0x0000000f @ mask 0xff00fff0
|
|
|
|
mov r4, #0x41000000
|
2010-11-22 15:06:28 +03:00
|
|
|
orr r4, r4, #0x0000b000
|
2011-01-30 19:40:20 +03:00
|
|
|
orr r4, r4, #0x00000020 @ val 0x4100b020
|
|
|
|
teq r3, r4 @ ARM 11MPCore?
|
2014-06-30 19:29:12 +04:00
|
|
|
reteq lr @ yes, assume SMP
|
2010-09-04 13:47:48 +04:00
|
|
|
|
|
|
|
mrc p15, 0, r0, c0, c0, 5 @ read MPIDR
|
2011-01-30 19:40:20 +03:00
|
|
|
and r0, r0, #0xc0000000 @ multiprocessing extensions and
|
|
|
|
teq r0, #0x80000000 @ not part of a uniprocessor system?
|
2013-09-28 00:56:31 +04:00
|
|
|
bne __fixup_smp_on_up @ no, assume UP
|
|
|
|
|
|
|
|
@ Core indicates it is SMP. Check for Aegis SOC where a single
|
|
|
|
@ Cortex-A9 CPU is present but SMP operations fault.
|
|
|
|
mov r4, #0x41000000
|
|
|
|
orr r4, r4, #0x0000c000
|
|
|
|
orr r4, r4, #0x00000090
|
|
|
|
teq r3, r4 @ Check for ARM Cortex-A9
|
2014-06-30 19:29:12 +04:00
|
|
|
retne lr @ Not ARM Cortex-A9,
|
2013-09-28 00:56:31 +04:00
|
|
|
|
|
|
|
@ If a future SoC *does* use 0x0 as the PERIPH_BASE, then the
|
|
|
|
@ below address check will need to be #ifdef'd or equivalent
|
|
|
|
@ for the Aegis platform.
|
|
|
|
mrc p15, 4, r0, c15, c0 @ get SCU base address
|
|
|
|
teq r0, #0x0 @ '0' on actual UP A9 hardware
|
|
|
|
beq __fixup_smp_on_up @ So its an A9 UP
|
|
|
|
ldr r0, [r0, #4] @ read SCU Config
|
2013-11-07 11:42:40 +04:00
|
|
|
ARM_BE8(rev r0, r0) @ byteswap if big endian
|
2013-09-28 00:56:31 +04:00
|
|
|
and r0, r0, #0x3 @ number of CPUs
|
|
|
|
teq r0, #0x0 @ is 1?
|
2014-06-30 19:29:12 +04:00
|
|
|
retne lr
|
2010-09-04 13:47:48 +04:00
|
|
|
|
|
|
|
__fixup_smp_on_up:
|
2020-09-14 11:25:29 +03:00
|
|
|
adr_l r4, __smpalt_begin
|
|
|
|
adr_l r5, __smpalt_end
|
2011-02-10 18:25:18 +03:00
|
|
|
b __do_fixup_smp_on_up
|
2010-09-04 13:47:48 +04:00
|
|
|
ENDPROC(__fixup_smp)
|
|
|
|
|
|
|
|
.pushsection .data
|
2017-07-26 14:49:31 +03:00
|
|
|
.align 2
|
2010-09-04 13:47:48 +04:00
|
|
|
.globl smp_on_up
|
|
|
|
smp_on_up:
|
|
|
|
ALT_SMP(.long 1)
|
|
|
|
ALT_UP(.long 0)
|
|
|
|
.popsection
|
2011-02-10 18:25:18 +03:00
|
|
|
#endif
|
2010-09-04 13:47:48 +04:00
|
|
|
|
2011-02-10 18:25:18 +03:00
|
|
|
.text
|
|
|
|
__do_fixup_smp_on_up:
|
|
|
|
cmp r4, r5
|
2014-06-30 19:29:12 +04:00
|
|
|
reths lr
|
2020-09-14 11:48:20 +03:00
|
|
|
ldmia r4, {r0, r6}
|
|
|
|
ARM( str r6, [r0, r4] )
|
|
|
|
THUMB( add r0, r0, r4 )
|
|
|
|
add r4, r4, #8
|
2011-02-10 18:25:18 +03:00
|
|
|
#ifdef __ARMEB__
|
|
|
|
THUMB( mov r6, r6, ror #16 ) @ Convert word order for big-endian.
|
2010-09-04 13:47:48 +04:00
|
|
|
#endif
|
2011-02-10 18:25:18 +03:00
|
|
|
THUMB( strh r6, [r0], #2 ) @ For Thumb-2, store as two halfwords
|
2020-09-14 11:48:20 +03:00
|
|
|
THUMB( mov r6, r6, lsr #16 ) @ to be robust against misaligned r0.
|
2011-02-10 18:25:18 +03:00
|
|
|
THUMB( strh r6, [r0] )
|
|
|
|
b __do_fixup_smp_on_up
|
|
|
|
ENDPROC(__do_fixup_smp_on_up)
|
|
|
|
|
|
|
|
ENTRY(fixup_smp)
|
|
|
|
stmfd sp!, {r4 - r6, lr}
|
|
|
|
mov r4, r0
|
|
|
|
add r5, r0, r1
|
|
|
|
bl __do_fixup_smp_on_up
|
|
|
|
ldmfd sp!, {r4 - r6, pc}
|
|
|
|
ENDPROC(fixup_smp)
|
2010-09-04 13:47:48 +04:00
|
|
|
|
2006-03-27 17:58:25 +04:00
|
|
|
#include "head-common.S"
|