Commit 37d07b72 authored by Nicolas Pitre's avatar Nicolas Pitre Committed by Russell King

[ARM] 3061/1: cleanup the XIP link address mess

Patch from Nicolas Pitre

Since vmlinux.lds.S is preprocessed, we can use the defines already
present in asm/memory.h (allowed by patch #3060) for the XIP kernel link
address instead of relying on a duplicated Makefile hardcoded value, and
also get rid of its dependency on awk to handle it at the same time.

While at it let's clean XIP stuff even further and make things clearer
in head.S with a nice code reduction.
Signed-off-by: default avatarNicolas Pitre <nico@cam.org>
Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
parent f09b9979
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
# Copyright (C) 1995-2001 by Russell King # Copyright (C) 1995-2001 by Russell King
LDFLAGS_vmlinux :=-p --no-undefined -X LDFLAGS_vmlinux :=-p --no-undefined -X
CPPFLAGS_vmlinux.lds = -DTEXTADDR=$(TEXTADDR) -DDATAADDR=$(DATAADDR) CPPFLAGS_vmlinux.lds = -DKERNEL_RAM_ADDR=$(TEXTADDR)
OBJCOPYFLAGS :=-O binary -R .note -R .comment -S OBJCOPYFLAGS :=-O binary -R .note -R .comment -S
GZFLAGS :=-9 GZFLAGS :=-9
#CFLAGS +=-pipe #CFLAGS +=-pipe
...@@ -108,27 +108,19 @@ export CFLAGS_3c589_cs.o ...@@ -108,27 +108,19 @@ export CFLAGS_3c589_cs.o
endif endif
TEXTADDR := $(textaddr-y) TEXTADDR := $(textaddr-y)
ifeq ($(CONFIG_XIP_KERNEL),y)
DATAADDR := $(TEXTADDR)
xipaddr-$(CONFIG_ARCH_CO285) := 0x5f000000
xipaddr-y ?= 0xbf000000
# Replace phys addr with virt addr while keeping offset from base.
TEXTADDR := $(shell echo $(CONFIG_XIP_PHYS_ADDR) $(xipaddr-y) | \
awk --non-decimal-data '/[:xdigit:]/ \
{ printf("0x%x\n", and($$1, 0x000fffff) + $$2) }' )
endif
ifeq ($(incdir-y),) ifeq ($(incdir-y),)
incdir-y := $(machine-y) incdir-y := $(machine-y)
endif endif
INCDIR := arch-$(incdir-y) INCDIR := arch-$(incdir-y)
ifneq ($(machine-y),) ifneq ($(machine-y),)
MACHINE := arch/arm/mach-$(machine-y)/ MACHINE := arch/arm/mach-$(machine-y)/
else else
MACHINE := MACHINE :=
endif endif
export TEXTADDR DATAADDR GZFLAGS export TEXTADDR GZFLAGS
# Do we have FASTFPE? # Do we have FASTFPE?
FASTFPE :=arch/arm/fastfpe FASTFPE :=arch/arm/fastfpe
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# Makefile for the linux kernel. # Makefile for the linux kernel.
# #
AFLAGS_head.o := -DTEXTADDR=$(TEXTADDR) -DDATAADDR=$(DATAADDR) AFLAGS_head.o := -DKERNEL_RAM_ADDR=$(TEXTADDR)
# Object file lists. # Object file lists.
......
...@@ -34,52 +34,28 @@ ...@@ -34,52 +34,28 @@
#define MACHINFO_PGOFFIO 12 #define MACHINFO_PGOFFIO 12
#define MACHINFO_NAME 16 #define MACHINFO_NAME 16
#ifndef CONFIG_XIP_KERNEL
/* /*
* We place the page tables 16K below TEXTADDR. Therefore, we must make sure * swapper_pg_dir is the virtual address of the initial page table.
* that TEXTADDR is correctly set. Currently, we expect the least significant * We place the page tables 16K below KERNEL_RAM_ADDR. Therefore, we must
* 16 bits to be 0x8000, but we could probably relax this restriction to * make sure that KERNEL_RAM_ADDR is correctly set. Currently, we expect
* TEXTADDR >= PAGE_OFFSET + 0x4000 * the least significant 16 bits to be 0x8000, but we could probably
* * relax this restriction to KERNEL_RAM_ADDR >= PAGE_OFFSET + 0x4000.
* Note that swapper_pg_dir is the virtual address of the page tables, and
* pgtbl gives us a position-independent reference to these tables. We can
* do this because stext == TEXTADDR
*/ */
#if (TEXTADDR & 0xffff) != 0x8000 #if (KERNEL_RAM_ADDR & 0xffff) != 0x8000
#error TEXTADDR must start at 0xXXXX8000 #error KERNEL_RAM_ADDR must start at 0xXXXX8000
#endif #endif
.globl swapper_pg_dir .globl swapper_pg_dir
.equ swapper_pg_dir, TEXTADDR - 0x4000 .equ swapper_pg_dir, KERNEL_RAM_ADDR - 0x4000
.macro pgtbl, rd, phys .macro pgtbl, rd
adr \rd, stext ldr \rd, =(__virt_to_phys(KERNEL_RAM_ADDR - 0x4000))
sub \rd, \rd, #0x4000
.endm .endm
#else
/*
* XIP Kernel:
*
* We place the page tables 16K below DATAADDR. Therefore, we must make sure
* that DATAADDR is correctly set. Currently, we expect the least significant
* 16 bits to be 0x8000, but we could probably relax this restriction to
* DATAADDR >= PAGE_OFFSET + 0x4000
*
* Note that pgtbl is meant to return the physical address of swapper_pg_dir.
* We can't make it relative to the kernel position in this case since
* the kernel can physically be anywhere.
*/
#if (DATAADDR & 0xffff) != 0x8000
#error DATAADDR must start at 0xXXXX8000
#endif
.globl swapper_pg_dir
.equ swapper_pg_dir, DATAADDR - 0x4000
.macro pgtbl, rd, phys #ifdef CONFIG_XIP_KERNEL
ldr \rd, =((DATAADDR - 0x4000) - PAGE_OFFSET) #define TEXTADDR XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR)
add \rd, \rd, \phys #else
.endm #define TEXTADDR KERNEL_RAM_ADDR
#endif #endif
/* /*
...@@ -280,7 +256,7 @@ __turn_mmu_on: ...@@ -280,7 +256,7 @@ __turn_mmu_on:
.type __create_page_tables, %function .type __create_page_tables, %function
__create_page_tables: __create_page_tables:
ldr r5, [r8, #MACHINFO_PHYSRAM] @ physram ldr r5, [r8, #MACHINFO_PHYSRAM] @ physram
pgtbl r4, r5 @ page table address pgtbl r4 @ page table address
/* /*
* Clear the 16K level 1 swapper page table * Clear the 16K level 1 swapper page table
......
...@@ -6,14 +6,23 @@ ...@@ -6,14 +6,23 @@
#include <asm-generic/vmlinux.lds.h> #include <asm-generic/vmlinux.lds.h>
#include <linux/config.h> #include <linux/config.h>
#include <asm/thread_info.h> #include <asm/thread_info.h>
#include <asm/memory.h>
OUTPUT_ARCH(arm) OUTPUT_ARCH(arm)
ENTRY(stext) ENTRY(stext)
#ifndef __ARMEB__ #ifndef __ARMEB__
jiffies = jiffies_64; jiffies = jiffies_64;
#else #else
jiffies = jiffies_64 + 4; jiffies = jiffies_64 + 4;
#endif #endif
#ifdef CONFIG_XIP_KERNEL
#define TEXTADDR XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR)
#else
#define TEXTADDR KERNEL_RAM_ADDR
#endif
SECTIONS SECTIONS
{ {
. = TEXTADDR; . = TEXTADDR;
...@@ -95,7 +104,7 @@ SECTIONS ...@@ -95,7 +104,7 @@ SECTIONS
#ifdef CONFIG_XIP_KERNEL #ifdef CONFIG_XIP_KERNEL
__data_loc = ALIGN(4); /* location in binary */ __data_loc = ALIGN(4); /* location in binary */
. = DATAADDR; . = KERNEL_RAM_ADDR;
#else #else
. = ALIGN(THREAD_SIZE); . = ALIGN(THREAD_SIZE);
__data_loc = .; __data_loc = .;
......
...@@ -68,6 +68,13 @@ ...@@ -68,6 +68,13 @@
#error Top of user space clashes with start of module space #error Top of user space clashes with start of module space
#endif #endif
/*
* The XIP kernel gets mapped at the bottom of the module vm area.
* Since we use sections to map it, this macro replaces the physical address
* with its virtual address while keeping offset from the base section.
*/
#define XIP_VIRT_ADDR(physaddr) (MODULE_START + ((physaddr) & 0x000fffff))
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment