machdep.c (209613) | machdep.c (209908) |
---|---|
1/*- 2 * Copyright (C) 2006 Semihalf, Marian Balakowicz <m8@semihalf.com> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 65 unchanged lines hidden (view full) --- 74 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 75 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 76 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 77 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 78 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 79 */ 80 81#include <sys/cdefs.h> | 1/*- 2 * Copyright (C) 2006 Semihalf, Marian Balakowicz <m8@semihalf.com> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 65 unchanged lines hidden (view full) --- 74 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 75 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 76 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 77 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 78 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 79 */ 80 81#include <sys/cdefs.h> |
82__FBSDID("$FreeBSD: head/sys/powerpc/booke/machdep.c 209613 2010-06-30 18:03:42Z jhb $"); | 82__FBSDID("$FreeBSD: head/sys/powerpc/booke/machdep.c 209908 2010-07-11 21:08:29Z raj $"); |
83 84#include "opt_compat.h" 85#include "opt_ddb.h" 86#include "opt_kstack_pages.h" 87#include "opt_msgbuf.h" 88 89#include <sys/cdefs.h> 90#include <sys/types.h> --- 34 unchanged lines hidden (view full) --- 125#include <machine/spr.h> 126#include <machine/hid.h> 127#include <machine/psl.h> 128#include <machine/trap.h> 129#include <machine/md_var.h> 130#include <machine/mmuvar.h> 131#include <machine/sigframe.h> 132#include <machine/metadata.h> | 83 84#include "opt_compat.h" 85#include "opt_ddb.h" 86#include "opt_kstack_pages.h" 87#include "opt_msgbuf.h" 88 89#include <sys/cdefs.h> 90#include <sys/types.h> --- 34 unchanged lines hidden (view full) --- 125#include <machine/spr.h> 126#include <machine/hid.h> 127#include <machine/psl.h> 128#include <machine/trap.h> 129#include <machine/md_var.h> 130#include <machine/mmuvar.h> 131#include <machine/sigframe.h> 132#include <machine/metadata.h> |
133#include <machine/bootinfo.h> | |
134#include <machine/platform.h> 135 136#include <sys/linker.h> 137#include <sys/reboot.h> 138 | 133#include <machine/platform.h> 134 135#include <sys/linker.h> 136#include <sys/reboot.h> 137 |
139#include <powerpc/mpc85xx/ocpbus.h> | 138#include <dev/fdt/fdt_common.h> 139#include <dev/ofw/openfirm.h> 140 |
140#include <powerpc/mpc85xx/mpc85xx.h> 141 142#ifdef DDB 143extern vm_offset_t ksym_start, ksym_end; 144#endif 145 146#ifdef DEBUG 147#define debugf(fmt, args...) printf(fmt, ##args) --- 16 unchanged lines hidden (view full) --- 164 165struct kva_md_info kmi; 166struct pcpu __pcpu[MAXCPU]; 167struct trapframe frame0; 168int cold = 1; 169long realmem = 0; 170long Maxmem = 0; 171 | 141#include <powerpc/mpc85xx/mpc85xx.h> 142 143#ifdef DDB 144extern vm_offset_t ksym_start, ksym_end; 145#endif 146 147#ifdef DEBUG 148#define debugf(fmt, args...) printf(fmt, ##args) --- 16 unchanged lines hidden (view full) --- 165 166struct kva_md_info kmi; 167struct pcpu __pcpu[MAXCPU]; 168struct trapframe frame0; 169int cold = 1; 170long realmem = 0; 171long Maxmem = 0; 172 |
172struct bootinfo *bootinfo; 173 | |
174char machine[] = "powerpc"; 175SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD, machine, 0, ""); 176 177int cacheline_size = 32; 178 179SYSCTL_INT(_machdep, CPU_CACHELINE, cacheline_size, 180 CTLFLAG_RD, &cacheline_size, 0, ""); 181 182int hw_direct_map = 0; 183 184static void cpu_e500_startup(void *); 185SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_e500_startup, NULL); 186 187void print_kernel_section_addr(void); | 173char machine[] = "powerpc"; 174SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD, machine, 0, ""); 175 176int cacheline_size = 32; 177 178SYSCTL_INT(_machdep, CPU_CACHELINE, cacheline_size, 179 CTLFLAG_RD, &cacheline_size, 0, ""); 180 181int hw_direct_map = 0; 182 183static void cpu_e500_startup(void *); 184SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_e500_startup, NULL); 185 186void print_kernel_section_addr(void); |
188void print_bootinfo(void); | |
189void print_kenv(void); 190u_int e500_init(u_int32_t, u_int32_t, void *); 191 192static void 193cpu_e500_startup(void *dummy) 194{ 195 int indx, size; 196 --- 57 unchanged lines hidden (view full) --- 254 debugf(" kern_envp = 0x%08x\n", (u_int32_t)kern_envp); 255 256 len = 0; 257 for (cp = kern_envp; cp != NULL; cp = kenv_next(cp)) 258 debugf(" %x %s\n", (u_int32_t)cp, cp); 259} 260 261void | 187void print_kenv(void); 188u_int e500_init(u_int32_t, u_int32_t, void *); 189 190static void 191cpu_e500_startup(void *dummy) 192{ 193 int indx, size; 194 --- 57 unchanged lines hidden (view full) --- 252 debugf(" kern_envp = 0x%08x\n", (u_int32_t)kern_envp); 253 254 len = 0; 255 for (cp = kern_envp; cp != NULL; cp = kenv_next(cp)) 256 debugf(" %x %s\n", (u_int32_t)cp, cp); 257} 258 259void |
262print_bootinfo(void) 263{ 264 struct bi_mem_region *mr; 265 struct bi_eth_addr *eth; 266 int i, j; 267 268 debugf("bootinfo:\n"); 269 if (bootinfo == NULL) { 270 debugf(" no bootinfo, null ptr\n"); 271 return; 272 } 273 274 debugf(" version = 0x%08x\n", bootinfo->bi_version); 275 debugf(" ccsrbar = 0x%08x\n", bootinfo->bi_bar_base); 276 debugf(" cpu_clk = 0x%08x\n", bootinfo->bi_cpu_clk); 277 debugf(" bus_clk = 0x%08x\n", bootinfo->bi_bus_clk); 278 279 debugf(" mem regions:\n"); 280 mr = (struct bi_mem_region *)bootinfo->bi_data; 281 for (i = 0; i < bootinfo->bi_mem_reg_no; i++, mr++) 282 debugf(" #%d, base = 0x%08x, size = 0x%08x\n", i, 283 mr->mem_base, mr->mem_size); 284 285 debugf(" eth addresses:\n"); 286 eth = (struct bi_eth_addr *)mr; 287 for (i = 0; i < bootinfo->bi_eth_addr_no; i++, eth++) { 288 debugf(" #%d, addr = ", i); 289 for (j = 0; j < 6; j++) 290 debugf("%02x ", eth->mac_addr[j]); 291 debugf("\n"); 292 } 293} 294 295void | |
296print_kernel_section_addr(void) 297{ 298 299 debugf("kernel image addresses:\n"); 300 debugf(" kernel_text = 0x%08x\n", (uint32_t)kernel_text); 301 debugf(" _etext (sdata) = 0x%08x\n", (uint32_t)_etext); 302 debugf(" _edata = 0x%08x\n", (uint32_t)_edata); 303 debugf(" __sbss_start = 0x%08x\n", (uint32_t)__sbss_start); 304 debugf(" __sbss_end = 0x%08x\n", (uint32_t)__sbss_end); 305 debugf(" __sbss_start = 0x%08x\n", (uint32_t)__bss_start); 306 debugf(" _end = 0x%08x\n", (uint32_t)_end); 307} 308 | 260print_kernel_section_addr(void) 261{ 262 263 debugf("kernel image addresses:\n"); 264 debugf(" kernel_text = 0x%08x\n", (uint32_t)kernel_text); 265 debugf(" _etext (sdata) = 0x%08x\n", (uint32_t)_etext); 266 debugf(" _edata = 0x%08x\n", (uint32_t)_edata); 267 debugf(" __sbss_start = 0x%08x\n", (uint32_t)__sbss_start); 268 debugf(" __sbss_end = 0x%08x\n", (uint32_t)__sbss_end); 269 debugf(" __sbss_start = 0x%08x\n", (uint32_t)__bss_start); 270 debugf(" _end = 0x%08x\n", (uint32_t)_end); 271} 272 |
309struct bi_mem_region * 310bootinfo_mr(void) 311{ 312 313 return ((struct bi_mem_region *)bootinfo->bi_data); 314} 315 316struct bi_eth_addr * 317bootinfo_eth(void) 318{ 319 struct bi_mem_region *mr; 320 struct bi_eth_addr *eth; 321 int i; 322 323 /* Advance to the eth section */ 324 mr = bootinfo_mr(); 325 for (i = 0; i < bootinfo->bi_mem_reg_no; i++, mr++) 326 ; 327 328 eth = (struct bi_eth_addr *)mr; 329 return (eth); 330} 331 | |
332u_int 333e500_init(u_int32_t startkernel, u_int32_t endkernel, void *mdp) 334{ 335 struct pcpu *pc; 336 void *kmdp; | 273u_int 274e500_init(u_int32_t startkernel, u_int32_t endkernel, void *mdp) 275{ 276 struct pcpu *pc; 277 void *kmdp; |
337 vm_offset_t end; | 278 vm_offset_t dtbp, end; |
338 uint32_t csr; 339 340 kmdp = NULL; 341 342 end = endkernel; | 279 uint32_t csr; 280 281 kmdp = NULL; 282 283 end = endkernel; |
284 dtbp = (vm_offset_t)NULL; |
|
343 344 /* | 285 286 /* |
345 * Parse metadata and fetch parameters. This must be done as the first 346 * step as we need bootinfo data to at least init the console | 287 * Parse metadata and fetch parameters. |
347 */ 348 if (mdp != NULL) { 349 preload_metadata = mdp; 350 kmdp = preload_search_by_type("elf kernel"); 351 if (kmdp != NULL) { | 288 */ 289 if (mdp != NULL) { 290 preload_metadata = mdp; 291 kmdp = preload_search_by_type("elf kernel"); 292 if (kmdp != NULL) { |
352 bootinfo = (struct bootinfo *)preload_search_info(kmdp, 353 MODINFO_METADATA | MODINFOMD_BOOTINFO); 354 | |
355 boothowto = MD_FETCH(kmdp, MODINFOMD_HOWTO, int); 356 kern_envp = MD_FETCH(kmdp, MODINFOMD_ENVP, char *); | 293 boothowto = MD_FETCH(kmdp, MODINFOMD_HOWTO, int); 294 kern_envp = MD_FETCH(kmdp, MODINFOMD_ENVP, char *); |
295 dtbp = MD_FETCH(kmdp, MODINFOMD_DTBP, vm_offset_t); |
|
357 end = MD_FETCH(kmdp, MODINFOMD_KERNEND, vm_offset_t); 358#ifdef DDB 359 ksym_start = MD_FETCH(kmdp, MODINFOMD_SSYM, uintptr_t); 360 ksym_end = MD_FETCH(kmdp, MODINFOMD_ESYM, uintptr_t); 361#endif 362 } 363 } else { 364 /* | 296 end = MD_FETCH(kmdp, MODINFOMD_KERNEND, vm_offset_t); 297#ifdef DDB 298 ksym_start = MD_FETCH(kmdp, MODINFOMD_SSYM, uintptr_t); 299 ksym_end = MD_FETCH(kmdp, MODINFOMD_ESYM, uintptr_t); 300#endif 301 } 302 } else { 303 /* |
365 * We should scream but how? - without CCSR bar (in bootinfo) 366 * cannot even output anything... | 304 * We should scream but how? Cannot even output anything... |
367 */ 368 369 /* 370 * FIXME add return value and handle in the locore so we can 371 * return to the loader maybe? (this seems not very easy to 372 * restore everything as the TLB have all been reprogrammed 373 * in the locore etc...) 374 */ | 305 */ 306 307 /* 308 * FIXME add return value and handle in the locore so we can 309 * return to the loader maybe? (this seems not very easy to 310 * restore everything as the TLB have all been reprogrammed 311 * in the locore etc...) 312 */ |
375 while(1); | 313 while (1); |
376 } 377 | 314 } 315 |
316 if (OF_install(OFW_FDT, 0) == FALSE) 317 while (1); 318 319 if (OF_init((void *)dtbp) != 0) 320 while (1); 321 322 if (fdt_immr_addr() != 0) 323 while (1); 324 325 OF_interpret("perform-fixup", 0); 326 |
|
378 /* Initialize TLB1 handling */ | 327 /* Initialize TLB1 handling */ |
379 tlb1_init(bootinfo->bi_bar_base); | 328 tlb1_init(fdt_immr_pa); |
380 381 /* Reset Time Base */ 382 mttb(0); 383 384 /* Init params/tunables that can be overridden by the loader. */ 385 init_param1(); 386 387 /* Start initializing proc0 and thread0. */ --- 24 unchanged lines hidden (view full) --- 412 debugf(" HID0 = 0x%08x\n", mfspr(SPR_HID0)); 413 debugf(" HID1 = 0x%08x\n", mfspr(SPR_HID1)); 414 debugf(" BUCSR = 0x%08x\n", mfspr(SPR_BUCSR)); 415 416 __asm __volatile("msync; isync"); 417 csr = ccsr_read4(OCP85XX_L2CTL); 418 debugf(" L2CTL = 0x%08x\n", csr); 419 | 329 330 /* Reset Time Base */ 331 mttb(0); 332 333 /* Init params/tunables that can be overridden by the loader. */ 334 init_param1(); 335 336 /* Start initializing proc0 and thread0. */ --- 24 unchanged lines hidden (view full) --- 361 debugf(" HID0 = 0x%08x\n", mfspr(SPR_HID0)); 362 debugf(" HID1 = 0x%08x\n", mfspr(SPR_HID1)); 363 debugf(" BUCSR = 0x%08x\n", mfspr(SPR_BUCSR)); 364 365 __asm __volatile("msync; isync"); 366 csr = ccsr_read4(OCP85XX_L2CTL); 367 debugf(" L2CTL = 0x%08x\n", csr); 368 |
420 print_bootinfo(); | 369 debugf(" dtbp = 0x%08x\n", (uint32_t)dtbp); 370 |
421 print_kernel_section_addr(); 422 print_kenv(); 423 //tlb1_print_entries(); 424 //tlb1_print_tlbentries(); 425 426 kdb_init(); 427 428#ifdef KDB --- 585 unchanged lines hidden --- | 371 print_kernel_section_addr(); 372 print_kenv(); 373 //tlb1_print_entries(); 374 //tlb1_print_tlbentries(); 375 376 kdb_init(); 377 378#ifdef KDB --- 585 unchanged lines hidden --- |