diff options
author | Dave Jones <davej@redhat.com> | 2006-12-12 17:41:41 -0500 |
---|---|---|
committer | Dave Jones <davej@redhat.com> | 2006-12-12 17:41:41 -0500 |
commit | c4366889dda8110247be59ca41fddb82951a8c26 (patch) | |
tree | 705c1a996bed8fd48ce94ff33ec9fd00f9b94875 /arch/mips/kernel/setup.c | |
parent | db2fb9db5735cc532fd4fc55e94b9a3c3750378e (diff) | |
parent | e1036502e5263851259d147771226161e5ccc85a (diff) |
Merge ../linus
Conflicts:
drivers/cpufreq/cpufreq.c
Diffstat (limited to 'arch/mips/kernel/setup.c')
-rw-r--r-- | arch/mips/kernel/setup.c | 93 |
1 files changed, 59 insertions, 34 deletions
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c index fdbb508661c5..89440a0d8528 100644 --- a/arch/mips/kernel/setup.c +++ b/arch/mips/kernel/setup.c | |||
@@ -145,13 +145,12 @@ static int __init rd_start_early(char *p) | |||
145 | unsigned long start = memparse(p, &p); | 145 | unsigned long start = memparse(p, &p); |
146 | 146 | ||
147 | #ifdef CONFIG_64BIT | 147 | #ifdef CONFIG_64BIT |
148 | /* HACK: Guess if the sign extension was forgotten */ | 148 | /* Guess if the sign extension was forgotten by bootloader */ |
149 | if (start > 0x0000000080000000 && start < 0x00000000ffffffff) | 149 | if (start < XKPHYS) |
150 | start |= 0xffffffff00000000UL; | 150 | start = (int)start; |
151 | #endif | 151 | #endif |
152 | initrd_start = start; | 152 | initrd_start = start; |
153 | initrd_end += start; | 153 | initrd_end += start; |
154 | |||
155 | return 0; | 154 | return 0; |
156 | } | 155 | } |
157 | early_param("rd_start", rd_start_early); | 156 | early_param("rd_start", rd_start_early); |
@@ -159,41 +158,64 @@ early_param("rd_start", rd_start_early); | |||
159 | static int __init rd_size_early(char *p) | 158 | static int __init rd_size_early(char *p) |
160 | { | 159 | { |
161 | initrd_end += memparse(p, &p); | 160 | initrd_end += memparse(p, &p); |
162 | |||
163 | return 0; | 161 | return 0; |
164 | } | 162 | } |
165 | early_param("rd_size", rd_size_early); | 163 | early_param("rd_size", rd_size_early); |
166 | 164 | ||
165 | /* it returns the next free pfn after initrd */ | ||
167 | static unsigned long __init init_initrd(void) | 166 | static unsigned long __init init_initrd(void) |
168 | { | 167 | { |
169 | unsigned long tmp, end, size; | 168 | unsigned long end; |
170 | u32 *initrd_header; | 169 | u32 *initrd_header; |
171 | 170 | ||
172 | ROOT_DEV = Root_RAM0; | ||
173 | |||
174 | /* | 171 | /* |
175 | * Board specific code or command line parser should have | 172 | * Board specific code or command line parser should have |
176 | * already set up initrd_start and initrd_end. In these cases | 173 | * already set up initrd_start and initrd_end. In these cases |
177 | * perfom sanity checks and use them if all looks good. | 174 | * perfom sanity checks and use them if all looks good. |
178 | */ | 175 | */ |
179 | size = initrd_end - initrd_start; | 176 | if (initrd_start && initrd_end > initrd_start) |
180 | if (initrd_end == 0 || size == 0) { | 177 | goto sanitize; |
181 | initrd_start = 0; | 178 | |
182 | initrd_end = 0; | 179 | /* |
183 | } else | 180 | * See if initrd has been added to the kernel image by |
184 | return initrd_end; | 181 | * arch/mips/boot/addinitrd.c. In that case a header is |
185 | 182 | * prepended to initrd and is made up by 8 bytes. The fisrt | |
186 | end = (unsigned long)&_end; | 183 | * word is a magic number and the second one is the size of |
187 | tmp = PAGE_ALIGN(end) - sizeof(u32) * 2; | 184 | * initrd. Initrd start must be page aligned in any cases. |
188 | if (tmp < end) | 185 | */ |
189 | tmp += PAGE_SIZE; | 186 | initrd_header = __va(PAGE_ALIGN(__pa_symbol(&_end) + 8)) - 8; |
190 | 187 | if (initrd_header[0] != 0x494E5244) | |
191 | initrd_header = (u32 *)tmp; | 188 | goto disable; |
192 | if (initrd_header[0] == 0x494E5244) { | 189 | initrd_start = (unsigned long)(initrd_header + 2); |
193 | initrd_start = (unsigned long)&initrd_header[2]; | 190 | initrd_end = initrd_start + initrd_header[1]; |
194 | initrd_end = initrd_start + initrd_header[1]; | 191 | |
192 | sanitize: | ||
193 | if (initrd_start & ~PAGE_MASK) { | ||
194 | printk(KERN_ERR "initrd start must be page aligned\n"); | ||
195 | goto disable; | ||
195 | } | 196 | } |
196 | return initrd_end; | 197 | if (initrd_start < PAGE_OFFSET) { |
198 | printk(KERN_ERR "initrd start < PAGE_OFFSET\n"); | ||
199 | goto disable; | ||
200 | } | ||
201 | |||
202 | /* | ||
203 | * Sanitize initrd addresses. For example firmware | ||
204 | * can't guess if they need to pass them through | ||
205 | * 64-bits values if the kernel has been built in pure | ||
206 | * 32-bit. We need also to switch from KSEG0 to XKPHYS | ||
207 | * addresses now, so the code can now safely use __pa(). | ||
208 | */ | ||
209 | end = __pa(initrd_end); | ||
210 | initrd_end = (unsigned long)__va(end); | ||
211 | initrd_start = (unsigned long)__va(__pa(initrd_start)); | ||
212 | |||
213 | ROOT_DEV = Root_RAM0; | ||
214 | return PFN_UP(end); | ||
215 | disable: | ||
216 | initrd_start = 0; | ||
217 | initrd_end = 0; | ||
218 | return 0; | ||
197 | } | 219 | } |
198 | 220 | ||
199 | static void __init finalize_initrd(void) | 221 | static void __init finalize_initrd(void) |
@@ -204,12 +226,12 @@ static void __init finalize_initrd(void) | |||
204 | printk(KERN_INFO "Initrd not found or empty"); | 226 | printk(KERN_INFO "Initrd not found or empty"); |
205 | goto disable; | 227 | goto disable; |
206 | } | 228 | } |
207 | if (CPHYSADDR(initrd_end) > PFN_PHYS(max_low_pfn)) { | 229 | if (__pa(initrd_end) > PFN_PHYS(max_low_pfn)) { |
208 | printk("Initrd extends beyond end of memory"); | 230 | printk("Initrd extends beyond end of memory"); |
209 | goto disable; | 231 | goto disable; |
210 | } | 232 | } |
211 | 233 | ||
212 | reserve_bootmem(CPHYSADDR(initrd_start), size); | 234 | reserve_bootmem(__pa(initrd_start), size); |
213 | initrd_below_start_ok = 1; | 235 | initrd_below_start_ok = 1; |
214 | 236 | ||
215 | printk(KERN_INFO "Initial ramdisk at: 0x%lx (%lu bytes)\n", | 237 | printk(KERN_INFO "Initial ramdisk at: 0x%lx (%lu bytes)\n", |
@@ -223,7 +245,11 @@ disable: | |||
223 | 245 | ||
224 | #else /* !CONFIG_BLK_DEV_INITRD */ | 246 | #else /* !CONFIG_BLK_DEV_INITRD */ |
225 | 247 | ||
226 | #define init_initrd() 0 | 248 | static unsigned long __init init_initrd(void) |
249 | { | ||
250 | return 0; | ||
251 | } | ||
252 | |||
227 | #define finalize_initrd() do {} while (0) | 253 | #define finalize_initrd() do {} while (0) |
228 | 254 | ||
229 | #endif | 255 | #endif |
@@ -255,8 +281,7 @@ static void __init bootmem_init(void) | |||
255 | * not selected. Once that done we can determine the low bound | 281 | * not selected. Once that done we can determine the low bound |
256 | * of usable memory. | 282 | * of usable memory. |
257 | */ | 283 | */ |
258 | reserved_end = init_initrd(); | 284 | reserved_end = max(init_initrd(), PFN_UP(__pa_symbol(&_end))); |
259 | reserved_end = PFN_UP(CPHYSADDR(max(reserved_end, (unsigned long)&_end))); | ||
260 | 285 | ||
261 | /* | 286 | /* |
262 | * Find the highest page frame number we have available. | 287 | * Find the highest page frame number we have available. |
@@ -428,10 +453,10 @@ static void __init resource_init(void) | |||
428 | if (UNCAC_BASE != IO_BASE) | 453 | if (UNCAC_BASE != IO_BASE) |
429 | return; | 454 | return; |
430 | 455 | ||
431 | code_resource.start = virt_to_phys(&_text); | 456 | code_resource.start = __pa_symbol(&_text); |
432 | code_resource.end = virt_to_phys(&_etext) - 1; | 457 | code_resource.end = __pa_symbol(&_etext) - 1; |
433 | data_resource.start = virt_to_phys(&_etext); | 458 | data_resource.start = __pa_symbol(&_etext); |
434 | data_resource.end = virt_to_phys(&_edata) - 1; | 459 | data_resource.end = __pa_symbol(&_edata) - 1; |
435 | 460 | ||
436 | /* | 461 | /* |
437 | * Request address space for all standard RAM. | 462 | * Request address space for all standard RAM. |