转载自。在此基础上,做一些修改。
1)TEXT_OFFSET 内核在RAM中的起始位置相对于RAM起始地址偏移。值为0x00008000
- ./arch/arm/Makefile
- 111 textofs-y := 0x00008000
- 112 textofs-$(CONFIG_ARCH_CLPS711X) := 0x00028000
- 113 # We don't want the htc bootloader to corrupt kernel during resume
- 114 textofs-$(CONFIG_PM_H1940) := 0x00108000
- 115 # SA1111 DMA bug: we don't want the kernel to live in precious DMA-able memory
- 116 ifeq ($(CONFIG_ARCH_SA1100),y)
- 117 textofs-$(CONFIG_SA1111) := 0x00208000
- 118 endif
- 212 # The byte offset of the kernel image in RAM from the start of RAM.
- 213 TEXT_OFFSET := $(textofs-y)
2)PAGE_OFFSE 内核镜像起始虚拟地址。值为0xC0000000
- arch/arm/Kconfig
- 1165 config PAGE_OFFSET ----这个就是CONFIG_PAGE_OFFSET宏,默认值为0xC0000000
- 1166 hex
- 1167 default 0x40000000 if VMSPLIT_1G
- 1168 default 0x80000000 if VMSPLIT_2G
- 1169 default 0xC0000000
- ./arch/arm/include/asm/memory.h
- 34 #define PAGE_OFFSET UL(CONFIG_PAGE_OFFSET)
3)PHYS_OFFSET RAM启始物理地址,对应于DDR的物理地址。需要在mach-xxxx/include/mach/memory.h文件中定义这个宏。
对于2410来说值为0x30000000,RAM接在片选6上
arch/arm/mach-s3c2410/include/mach/memory.h
#define PHYS_OFFSET UL(0x30000000)
4)KERNEL_RAM_VADDR 内核在RAM中的虚拟地址。值为0xC0008000
5)KERNEL_RAM_PADDR 内核在RAM中的物理地址。值为0x30008000
arch/arm/kernel/head.S
29 #define KERNEL_RAM_VADDR (PAGE_OFFSET + TEXT_OFFSET)
30 #define KERNEL_RAM_PADDR (PHYS_OFFSET + TEXT_OFFSET)
6)swapper_pg_dir 初始页表虚拟地址,值为0xC0004000,
一般分配KERNEL_RAM_VADDR地址下16K作为页表,因此,我们必须确保正确设置KERNEL_RAM_VADDR。
arch/arm/kernel/head.S
44 .globl swapper_pg_dir
45 .equ swapper_pg_dir, KERNEL_RAM_VADDR - 0x4000
7)VMALLOC_START 0xc4800000
8)VMALLOC_END 0xe0000000
9)MODULES_VADDR 0xbf000000
10)MODULES_END 0xc0000000
arch/arm/include/asm/memory.h
- 47 #ifndef CONFIG_THUMB2_KERNEL
48 #define MODULES_VADDR (PAGE_OFFSET - 16*1024*1024)
49 #else
50 /* smaller range for Thumb-2 symbols relocation (2^24)*/
51 #define MODULES_VADDR (PAGE_OFFSET - 8*1024*1024)
52 #endif
53
54 #if TASK_SIZE > MODULES_VADDR
55 #error Top of user space clashes with start of module space
56 #endif
57
58 /*
59 * The highmem pkmap virtual space shares the end of the module area.
60 */
61 #ifdef CONFIG_HIGHMEM
62 #define MODULES_END (PAGE_OFFSET - PMD_SIZE)
63 #else
64 #define MODULES_END (PAGE_OFFSET)
65 #endif
11)PKMAP_BASE
arch/arm/include/asm/highmem.h:
6:#define PKMAP_BASE (PAGE_OFFSET - PMD_SIZE)
12)TASK_SIZE
./arch/arm/include/asm/memory.h
34 #define PAGE_OFFSET UL(CONFIG_PAGE_OFFSET)
35 #define TASK_SIZE (UL(CONFIG_PAGE_OFFSET) - UL(0x01000000))
36 #define TASK_UNMAPPED_BASE (UL(CONFIG_PAGE_OFFSET) / 3)
13)一些不同地址之间转换的宏
./arch/arm/include/asm/memory.h
135 /*
136 * Physical vs virtual RAM address space conversion. These are
137 * private definitions which should NOT be used outside memory.h
138 * files. Use virt_to_phys/phys_to_virt/__pa/__va instead.
139 */
140 #ifndef __virt_to_phys
141 #define __virt_to_phys(x) ((x) - PAGE_OFFSET + PHYS_OFFSET)//物理地址和虚拟地址
142 #define __phys_to_virt(x) ((x) - PHYS_OFFSET + PAGE_OFFSET)//之间转换的宏
143 #endif
144
145 /*
146 * Convert a physical address to a Page Frame Number and back
147 */
148 #define __phys_to_pfn(paddr) ((paddr) >> PAGE_SHIFT) //物理地址和页帧号之间
149 #define __pfn_to_phys(pfn) ((pfn) << PAGE_SHIFT) //转换的宏
150
151 /*
152 * Convert a page to/from a physical address
153 */
154 #define page_to_phys(page) (__pfn_to_phys(page_to_pfn(page)))//页地址和物理地址
155 #define phys_to_page(phys) (pfn_to_page(__phys_to_pfn(phys)))//之间的转换宏依赖于内存模型。
201 /*
202 * Drivers should NOT use these either.
203 */
204 #define __pa(x) __virt_to_phys((unsigned long)(x))
205 #define __va(x) ((void *)__phys_to_virt((unsigned long)(x)))
206 #define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
207
208 /*
209 * Virtual <-> DMA view memory address translations
210 * Again, these are *only* valid on the kernel direct mapped RAM
211 * memory. Use of these is *deprecated* (and that doesn't mean
212 * use the __ prefixed forms instead.) See dma-mapping.h.
213 */
214 #ifndef __virt_to_bus
215 #define __virt_to_bus __virt_to_phys
216 #define __bus_to_virt __phys_to_virt
217 #define __pfn_to_bus(x) __pfn_to_phys(x)
218 #define __bus_to_pfn(x) __phys_to_pfn(x)
219 #endif
阅读(1461) | 评论(0) | 转发(0) |