aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStuart Menefy <stuart.menefy@st.com>2007-11-30 03:52:53 -0500
committerPaul Mundt <lethal@linux-sh.org>2008-01-27 23:18:59 -0500
commitd02b08f6e8b184ffef349e395210a5e82ff4f4bc (patch)
tree1dbec9fe6d2315a95855ce5a91f92a2a1fbf5a22
parentcbaa118ecfd99fc5ed7adbd9c34a30e1c05e3c93 (diff)
sh: Clean up places that make 29-bit physical assumptions.
Signed-off-by: Stuart Menefy <stuart.menefy@st.com> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
-rw-r--r--arch/sh/boot/compressed/misc_32.c5
-rw-r--r--arch/sh/kernel/setup.c4
-rw-r--r--arch/sh/kernel/vmlinux_32.lds.S5
-rw-r--r--include/asm-sh/addrspace.h6
-rw-r--r--include/asm-sh/cpu-sh4/mmu_context.h8
-rw-r--r--include/asm-sh/io.h16
-rw-r--r--include/asm-sh/page.h50
-rw-r--r--include/asm-sh/pgtable.h8
-rw-r--r--include/asm-sh/pgtable_32.h2
-rw-r--r--include/asm-sh/scatterlist.h3
10 files changed, 71 insertions, 36 deletions
diff --git a/arch/sh/boot/compressed/misc_32.c b/arch/sh/boot/compressed/misc_32.c
index df65e305acf7..adcea31e663e 100644
--- a/arch/sh/boot/compressed/misc_32.c
+++ b/arch/sh/boot/compressed/misc_32.c
@@ -230,7 +230,10 @@ long* stack_start = &user_stack[STACK_SIZE];
230void decompress_kernel(void) 230void decompress_kernel(void)
231{ 231{
232 output_data = 0; 232 output_data = 0;
233 output_ptr = P2SEGADDR((unsigned long)&_text+PAGE_SIZE); 233 output_ptr = PHYSADDR((unsigned long)&_text+PAGE_SIZE);
234#ifdef CONFIG_29BIT
235 output_ptr |= P2SEG;
236#endif
234 free_mem_ptr = (unsigned long)&_end; 237 free_mem_ptr = (unsigned long)&_end;
235 free_mem_end_ptr = free_mem_ptr + HEAP_SIZE; 238 free_mem_end_ptr = free_mem_ptr + HEAP_SIZE;
236 239
diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
index 7eb7fdcce0f8..f48ce8e5d0a8 100644
--- a/arch/sh/kernel/setup.c
+++ b/arch/sh/kernel/setup.c
@@ -82,7 +82,7 @@ static int __init early_parse_mem(char *p)
82{ 82{
83 unsigned long size; 83 unsigned long size;
84 84
85 memory_start = (unsigned long)PAGE_OFFSET+__MEMORY_START; 85 memory_start = (unsigned long)__va(__MEMORY_START);
86 size = memparse(p, &p); 86 size = memparse(p, &p);
87 87
88 if (size > __MEMORY_SIZE) { 88 if (size > __MEMORY_SIZE) {
@@ -254,7 +254,7 @@ void __init setup_arch(char **cmdline_p)
254 data_resource.start = virt_to_phys(_etext); 254 data_resource.start = virt_to_phys(_etext);
255 data_resource.end = virt_to_phys(_edata)-1; 255 data_resource.end = virt_to_phys(_edata)-1;
256 256
257 memory_start = (unsigned long)PAGE_OFFSET+__MEMORY_START; 257 memory_start = (unsigned long)__va(__MEMORY_START);
258 if (!memory_end) 258 if (!memory_end)
259 memory_end = memory_start + __MEMORY_SIZE; 259 memory_end = memory_start + __MEMORY_SIZE;
260 260
diff --git a/arch/sh/kernel/vmlinux_32.lds.S b/arch/sh/kernel/vmlinux_32.lds.S
index 50c69c18dced..d549fac6d3e7 100644
--- a/arch/sh/kernel/vmlinux_32.lds.S
+++ b/arch/sh/kernel/vmlinux_32.lds.S
@@ -15,7 +15,12 @@ OUTPUT_ARCH(sh)
15ENTRY(_start) 15ENTRY(_start)
16SECTIONS 16SECTIONS
17{ 17{
18#ifdef CONFIG_32BIT
19 . = CONFIG_PAGE_OFFSET + CONFIG_ZERO_PAGE_OFFSET;
20#else
18 . = CONFIG_PAGE_OFFSET + CONFIG_MEMORY_START + CONFIG_ZERO_PAGE_OFFSET; 21 . = CONFIG_PAGE_OFFSET + CONFIG_MEMORY_START + CONFIG_ZERO_PAGE_OFFSET;
22#endif
23
19 _text = .; /* Text and read-only data */ 24 _text = .; /* Text and read-only data */
20 25
21 .empty_zero_page : { 26 .empty_zero_page : {
diff --git a/include/asm-sh/addrspace.h b/include/asm-sh/addrspace.h
index e7f2deb28e06..fa544fc38c23 100644
--- a/include/asm-sh/addrspace.h
+++ b/include/asm-sh/addrspace.h
@@ -31,6 +31,7 @@
31/* Returns the physical address of a PnSEG (n=1,2) address */ 31/* Returns the physical address of a PnSEG (n=1,2) address */
32#define PHYSADDR(a) (((unsigned long)(a)) & 0x1fffffff) 32#define PHYSADDR(a) (((unsigned long)(a)) & 0x1fffffff)
33 33
34#ifdef CONFIG_29BIT
34/* 35/*
35 * Map an address to a certain privileged segment 36 * Map an address to a certain privileged segment
36 */ 37 */
@@ -42,8 +43,11 @@
42 ((__typeof__(a))(((unsigned long)(a) & 0x1fffffff) | P3SEG)) 43 ((__typeof__(a))(((unsigned long)(a) & 0x1fffffff) | P3SEG))
43#define P4SEGADDR(a) \ 44#define P4SEGADDR(a) \
44 ((__typeof__(a))(((unsigned long)(a) & 0x1fffffff) | P4SEG)) 45 ((__typeof__(a))(((unsigned long)(a) & 0x1fffffff) | P4SEG))
45 46#endif /* 29BIT */
46#endif /* P1SEG */ 47#endif /* P1SEG */
47 48
49/* Check if an address can be reached in 29 bits */
50#define IS_29BIT(a) (((unsigned long)(a)) < 0x20000000)
51
48#endif /* __KERNEL__ */ 52#endif /* __KERNEL__ */
49#endif /* __ASM_SH_ADDRSPACE_H */ 53#endif /* __ASM_SH_ADDRSPACE_H */
diff --git a/include/asm-sh/cpu-sh4/mmu_context.h b/include/asm-sh/cpu-sh4/mmu_context.h
index fdd56e3e3a3b..9ea8eb27b18e 100644
--- a/include/asm-sh/cpu-sh4/mmu_context.h
+++ b/include/asm-sh/cpu-sh4/mmu_context.h
@@ -30,6 +30,12 @@
30#define MMUCR_ME (0) 30#define MMUCR_ME (0)
31#endif 31#endif
32 32
33#if defined(CONFIG_32BIT) && defined(CONFIG_CPU_SUBTYPE_ST40)
34#define MMUCR_SE (1 << 4)
35#else
36#define MMUCR_SE (0)
37#endif
38
33#ifdef CONFIG_SH_STORE_QUEUES 39#ifdef CONFIG_SH_STORE_QUEUES
34#define MMUCR_SQMD (1 << 9) 40#define MMUCR_SQMD (1 << 9)
35#else 41#else
@@ -37,7 +43,7 @@
37#endif 43#endif
38 44
39#define MMU_NTLB_ENTRIES 64 45#define MMU_NTLB_ENTRIES 64
40#define MMU_CONTROL_INIT (0x05|MMUCR_SQMD|MMUCR_ME) 46#define MMU_CONTROL_INIT (0x05|MMUCR_SQMD|MMUCR_ME|MMUCR_SE)
41 47
42#define MMU_ITLB_DATA_ARRAY 0xF3000000 48#define MMU_ITLB_DATA_ARRAY 0xF3000000
43#define MMU_UTLB_DATA_ARRAY 0xF7000000 49#define MMU_UTLB_DATA_ARRAY 0xF7000000
diff --git a/include/asm-sh/io.h b/include/asm-sh/io.h
index a4e5f5573eee..94900c089519 100644
--- a/include/asm-sh/io.h
+++ b/include/asm-sh/io.h
@@ -273,23 +273,9 @@ extern void onchip_unmap(unsigned long vaddr);
273#if !defined(CONFIG_MMU) 273#if !defined(CONFIG_MMU)
274#define virt_to_phys(address) ((unsigned long)(address)) 274#define virt_to_phys(address) ((unsigned long)(address))
275#define phys_to_virt(address) ((void *)(address)) 275#define phys_to_virt(address) ((void *)(address))
276#elif defined(CONFIG_SUPERH64) 276#else
277#define virt_to_phys(address) (__pa(address)) 277#define virt_to_phys(address) (__pa(address))
278#define phys_to_virt(address) (__va(address)) 278#define phys_to_virt(address) (__va(address))
279#else
280/*
281 * Change virtual addresses to physical addresses and vv.
282 * These are trivial on the 1:1 Linux/SuperH mapping
283 */
284static inline unsigned long virt_to_phys(volatile void *address)
285{
286 return PHYSADDR(address);
287}
288
289static inline void *phys_to_virt(unsigned long address)
290{
291 return (void *)P1SEGADDR(address);
292}
293#endif 279#endif
294 280
295/* 281/*
diff --git a/include/asm-sh/page.h b/include/asm-sh/page.h
index bff635a078c8..002e64a4f049 100644
--- a/include/asm-sh/page.h
+++ b/include/asm-sh/page.h
@@ -5,6 +5,8 @@
5 * Copyright (C) 1999 Niibe Yutaka 5 * Copyright (C) 1999 Niibe Yutaka
6 */ 6 */
7 7
8#include <linux/const.h>
9
8#ifdef __KERNEL__ 10#ifdef __KERNEL__
9 11
10/* PAGE_SHIFT determines the page size */ 12/* PAGE_SHIFT determines the page size */
@@ -18,15 +20,13 @@
18# error "Bogus kernel page size?" 20# error "Bogus kernel page size?"
19#endif 21#endif
20 22
21#ifdef __ASSEMBLY__ 23#define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
22#define PAGE_SIZE (1 << PAGE_SHIFT)
23#else
24#define PAGE_SIZE (1UL << PAGE_SHIFT)
25#endif
26
27#define PAGE_MASK (~(PAGE_SIZE-1)) 24#define PAGE_MASK (~(PAGE_SIZE-1))
28#define PTE_MASK PAGE_MASK 25#define PTE_MASK PAGE_MASK
29 26
27/* to align the pointer to the (next) page boundary */
28#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
29
30#if defined(CONFIG_HUGETLB_PAGE_SIZE_64K) 30#if defined(CONFIG_HUGETLB_PAGE_SIZE_64K)
31#define HPAGE_SHIFT 16 31#define HPAGE_SHIFT 16
32#elif defined(CONFIG_HUGETLB_PAGE_SIZE_256K) 32#elif defined(CONFIG_HUGETLB_PAGE_SIZE_256K)
@@ -104,20 +104,44 @@ typedef struct { unsigned long pgd; } pgd_t;
104 104
105#endif /* !__ASSEMBLY__ */ 105#endif /* !__ASSEMBLY__ */
106 106
107/* to align the pointer to the (next) page boundary */ 107/*
108#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK) 108 * __MEMORY_START and SIZE are the physical addresses and size of RAM.
109 109 */
110#define __MEMORY_START CONFIG_MEMORY_START 110#define __MEMORY_START CONFIG_MEMORY_START
111#define __MEMORY_SIZE CONFIG_MEMORY_SIZE 111#define __MEMORY_SIZE CONFIG_MEMORY_SIZE
112 112
113/*
114 * PAGE_OFFSET is the virtual address of the start of kernel address
115 * space.
116 */
113#define PAGE_OFFSET CONFIG_PAGE_OFFSET 117#define PAGE_OFFSET CONFIG_PAGE_OFFSET
114#define __pa(x) ((unsigned long)(x)-PAGE_OFFSET)
115#define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
116#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
117 118
119/*
120 * Virtual to physical RAM address translation.
121 *
122 * In 29 bit mode, the physical offset of RAM from address 0 is visible in
123 * the kernel virtual address space, and thus we don't have to take
124 * this into account when translating. However in 32 bit mode this offset
125 * is not visible (it is part of the PMB mapping) and so needs to be
126 * added or subtracted as required.
127 */
128#ifdef CONFIG_32BIT
129#define __pa(x) ((unsigned long)(x)-PAGE_OFFSET+__MEMORY_START)
130#define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET-__MEMORY_START))
131#else
132#define __pa(x) ((unsigned long)(x)-PAGE_OFFSET)
133#define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
134#endif
135
136#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
118#define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT) 137#define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
119 138
120/* PFN start number, because of __MEMORY_START */ 139/*
140 * PFN = physical frame number (ie PFN 0 == physical address 0)
141 * PFN_START is the PFN of the first page of RAM. By defining this we
142 * don't have struct page entries for the portion of address space
143 * between physical address 0 and the start of RAM.
144 */
121#define PFN_START (__MEMORY_START >> PAGE_SHIFT) 145#define PFN_START (__MEMORY_START >> PAGE_SHIFT)
122#define ARCH_PFN_OFFSET (PFN_START) 146#define ARCH_PFN_OFFSET (PFN_START)
123#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT) 147#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
diff --git a/include/asm-sh/pgtable.h b/include/asm-sh/pgtable.h
index b4d7561cd9e0..3df90f003e95 100644
--- a/include/asm-sh/pgtable.h
+++ b/include/asm-sh/pgtable.h
@@ -69,7 +69,13 @@ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
69#define USER_PTRS_PER_PGD (TASK_SIZE/PGDIR_SIZE) 69#define USER_PTRS_PER_PGD (TASK_SIZE/PGDIR_SIZE)
70#define FIRST_USER_ADDRESS 0 70#define FIRST_USER_ADDRESS 0
71 71
72#define PTE_PHYS_MASK (0x20000000 - PAGE_SIZE) 72#ifdef CONFIG_32BIT
73#define PHYS_ADDR_MASK 0xffffffff
74#else
75#define PHYS_ADDR_MASK 0x1fffffff
76#endif
77
78#define PTE_PHYS_MASK (PHYS_ADDR_MASK & PAGE_MASK)
73 79
74#ifdef CONFIG_SUPERH32 80#ifdef CONFIG_SUPERH32
75#define VMALLOC_START (P3SEG) 81#define VMALLOC_START (P3SEG)
diff --git a/include/asm-sh/pgtable_32.h b/include/asm-sh/pgtable_32.h
index 70303603e89d..7efc95404c64 100644
--- a/include/asm-sh/pgtable_32.h
+++ b/include/asm-sh/pgtable_32.h
@@ -98,7 +98,7 @@
98#define _PAGE_CLEAR_FLAGS (_PAGE_PROTNONE | _PAGE_ACCESSED | _PAGE_FILE) 98#define _PAGE_CLEAR_FLAGS (_PAGE_PROTNONE | _PAGE_ACCESSED | _PAGE_FILE)
99#endif 99#endif
100 100
101#define _PAGE_FLAGS_HARDWARE_MASK (0x1fffffff & ~(_PAGE_CLEAR_FLAGS)) 101#define _PAGE_FLAGS_HARDWARE_MASK (PHYS_ADDR_MASK & ~(_PAGE_CLEAR_FLAGS))
102 102
103/* Hardware flags, page size encoding */ 103/* Hardware flags, page size encoding */
104#if defined(CONFIG_X2TLB) 104#if defined(CONFIG_X2TLB)
diff --git a/include/asm-sh/scatterlist.h b/include/asm-sh/scatterlist.h
index a7d0d1856a99..35ef9c30f0de 100644
--- a/include/asm-sh/scatterlist.h
+++ b/include/asm-sh/scatterlist.h
@@ -1,6 +1,7 @@
1#ifndef __ASM_SH_SCATTERLIST_H 1#ifndef __ASM_SH_SCATTERLIST_H
2#define __ASM_SH_SCATTERLIST_H 2#define __ASM_SH_SCATTERLIST_H
3 3
4#include <asm/pgtable.h>
4#include <asm/types.h> 5#include <asm/types.h>
5 6
6struct scatterlist { 7struct scatterlist {
@@ -13,7 +14,7 @@ struct scatterlist {
13 unsigned int length; 14 unsigned int length;
14}; 15};
15 16
16#define ISA_DMA_THRESHOLD (0x1fffffff) 17#define ISA_DMA_THRESHOLD PHYS_ADDR_MASK
17 18
18/* These macros should be used after a pci_map_sg call has been done 19/* These macros should be used after a pci_map_sg call has been done
19 * to get bus addresses of each of the SG entries and their lengths. 20 * to get bus addresses of each of the SG entries and their lengths.