Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a9f2fc62 authored by Max Filippov's avatar Max Filippov
Browse files

xtensa: cleanup MMU setup and kernel layout macros



Make kernel load address explicit, independent of the selected MMU
configuration and configurable from Kconfig. Do not restrict it to the
first 512MB of the physical address space.

Cleanup kernel memory layout macros:

- rename VECBASE_RESET_VADDR to VECBASE_VADDR, XC_VADDR to VECTOR_VADDR;
- drop VIRTUAL_MEMORY_ADDRESS and LOAD_MEMORY_ADDRESS;
- introduce PHYS_OFFSET and use it in __va and __pa definitions;
- synchronize MMU/noMMU vectors, drop unused NMI vector;
- replace hardcoded vectors offset of 0x3000 with Kconfig symbol.

Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
parent d39af902
Loading
Loading
Loading
Loading
+22 −27
Original line number Diff line number Diff line
@@ -3,15 +3,8 @@ MMUv3 initialization sequence.
The code in the initialize_mmu macro sets up MMUv3 memory mapping
identically to MMUv2 fixed memory mapping. Depending on
CONFIG_INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX symbol this code is
located in one of the following address ranges:

    0xF0000000..0xFFFFFFFF (will keep same address in MMU v2 layout;
    			 typically ROM)
    0x00000000..0x07FFFFFF (system RAM; this code is actually linked
    			 at 0xD0000000..0xD7FFFFFF [cached]
    			 or 0xD8000000..0xDFFFFFFF [uncached];
    			 in any case, initially runs elsewhere
    			 than linked, so have to be careful)
located in addresses it was linked for (symbol undefined), or not
(symbol defined), so it needs to be position-independent.

The code has the following assumptions:
  This code fragment is run only on an MMU v3.
@@ -28,24 +21,26 @@ TLB setup proceeds along the following steps.
    PA = physical address (two upper nibbles of it);
    pc = physical range that contains this code;

After step 2, we jump to virtual address in 0x40000000..0x5fffffff
that corresponds to next instruction to execute in this code.
After step 4, we jump to intended (linked) address of this code.
After step 2, we jump to virtual address in the range 0x40000000..0x5fffffff
or 0x00000000..0x1fffffff, depending on whether the kernel was loaded below
0x40000000 or above. That address corresponds to next instruction to execute
in this code. After step 4, we jump to intended (linked) address of this code.
The scheme below assumes that the kernel is loaded below 0x40000000.

        Step0  Step1  Step2  Step3          Step4  Step5
 ============  =====  ============  =====  ============  =====
   VA      PA     PA    VA      PA     PA    VA      PA     PA
 ------    --     --  ------    --     --  ------    --     --
 E0..FF -> E0  -> E0  E0..FF -> E0         F0..FF -> F0  -> F0
 C0..DF -> C0  -> C0  C0..DF -> C0         E0..EF -> F0  -> F0
 A0..BF -> A0  -> A0  A0..BF -> A0         D8..DF -> 00  -> 00
 80..9F -> 80  -> 80  80..9F -> 80         D0..D7 -> 00  -> 00
 60..7F -> 60  -> 60  60..7F -> 60
 40..5F -> 40         40..5F -> pc  -> pc  40..5F -> pc
 20..3F -> 20  -> 20  20..3F -> 20
 00..1F -> 00  -> 00  00..1F -> 00

The default location of IO peripherals is above 0xf0000000. This may change
        =====  =====  =====  =====          =====  =====
   VA      PA     PA     PA     PA     VA      PA     PA
 ------    --     --     --     --   ------    --     --
 E0..FF -> E0  -> E0  -> E0          F0..FF -> F0  -> F0
 C0..DF -> C0  -> C0  -> C0          E0..EF -> F0  -> F0
 A0..BF -> A0  -> A0  -> A0          D8..DF -> 00  -> 00
 80..9F -> 80  -> 80  -> 80          D0..D7 -> 00  -> 00
 60..7F -> 60  -> 60  -> 60
 40..5F -> 40         -> pc  -> pc   40..5F -> pc
 20..3F -> 20  -> 20  -> 20
 00..1F -> 00  -> 00  -> 00

The default location of IO peripherals is above 0xf0000000. This may be changed
using a "ranges" property in a device tree simple-bus node. See ePAPR 1.1, §6.5
for details on the syntax and semantic of simple-bus nodes. The following
limitations apply:
+20 −6
Original line number Diff line number Diff line
@@ -249,6 +249,25 @@ config KSEG_PADDR

	  If unsure, leave the default value here.

config KERNEL_LOAD_ADDRESS
	hex "Kernel load address"
	default 0x00003000
	help
	  This is the address where the kernel is loaded.
	  It is virtual address for MMUv2 configurations and physical address
	  for all other configurations.

	  If unsure, leave the default value here.

config VECTORS_OFFSET
	hex "Kernel vectors offset"
	default 0x00003000
	help
	  This is the offset of the kernel image from the relocatable vectors
	  base.

	  If unsure, leave the default value here.

choice
	prompt "KSEG layout"
	depends on MMU
@@ -487,12 +506,7 @@ config DEFAULT_MEM_START
	  used when no physical memory size is passed through DTB or through
	  boot parameter from bootloader.

	  In noMMU configuration the following parameters are derived from it:
	  - kernel load address;
	  - kernel entry point address;
	  - relocatable vectors base address;
	  - uBoot load address;
	  - TASK_SIZE.
	  It's also used for TASK_SIZE calculation in noMMU configuration.

	  If unsure, leave the default value here.

+1 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ SECTIONS
		*(.ResetVector.text)
	}

	.image KERNELOFFSET: AT (LOAD_MEMORY_ADDRESS)
	.image KERNELOFFSET: AT (CONFIG_KERNEL_LOAD_ADDRESS)
	{
		_image_start = .;
		*(image)
+6 −1
Original line number Diff line number Diff line
@@ -35,7 +35,12 @@ _ResetVector:

	.align 4
RomInitAddr:
	.word	LOAD_MEMORY_ADDRESS
#if defined(CONFIG_INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX) && \
	XCHAL_HAVE_PTP_MMU && XCHAL_HAVE_SPANNING_WAY
	.word	CONFIG_KERNEL_LOAD_ADDRESS
#else
	.word	KERNELOFFSET
#endif
RomBootParam:
	.word _bootparam
_bootparam:
+1 −9
Original line number Diff line number Diff line
@@ -4,15 +4,7 @@
# for more details.
#

ifdef CONFIG_MMU
ifdef CONFIG_INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX
UIMAGE_LOADADDR = 0x00003000
else
UIMAGE_LOADADDR = 0xd0003000
endif
else
UIMAGE_LOADADDR = $(shell printf "0x%x" $$(( ${CONFIG_DEFAULT_MEM_START} + 0x3000 )) )
endif
UIMAGE_LOADADDR = $(CONFIG_KERNEL_LOAD_ADDRESS)
UIMAGE_COMPRESSION = gzip

$(obj)/../uImage: vmlinux.bin.gz FORCE
Loading