Deleted Added
full compact
machdep.c (217688) machdep.c (222400)
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 217688 2011-01-21 10:26:26Z pluknet $");
82__FBSDID("$FreeBSD: head/sys/powerpc/booke/machdep.c 222400 2011-05-28 04:10:44Z marcel $");
83
84#include "opt_compat.h"
85#include "opt_ddb.h"
86#include "opt_kstack_pages.h"
87#include "opt_platform.h"
88
89#include <sys/cdefs.h>
90#include <sys/types.h>

--- 94 unchanged lines hidden (view full) ---

185
186int hw_direct_map = 0;
187
188static void cpu_e500_startup(void *);
189SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_e500_startup, NULL);
190
191void print_kernel_section_addr(void);
192void print_kenv(void);
83
84#include "opt_compat.h"
85#include "opt_ddb.h"
86#include "opt_kstack_pages.h"
87#include "opt_platform.h"
88
89#include <sys/cdefs.h>
90#include <sys/types.h>

--- 94 unchanged lines hidden (view full) ---

185
186int hw_direct_map = 0;
187
188static void cpu_e500_startup(void *);
189SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_e500_startup, NULL);
190
191void print_kernel_section_addr(void);
192void print_kenv(void);
193u_int e500_init(u_int32_t, u_int32_t, void *);
193u_int booke_init(uint32_t, uint32_t);
194
195static void
196cpu_e500_startup(void *dummy)
197{
198 int indx, size;
199
200 /* Initialise the decrementer-based clock. */
201 decr_init();

--- 69 unchanged lines hidden (view full) ---

271 debugf(" _edata = 0x%08x\n", (uint32_t)_edata);
272 debugf(" __sbss_start = 0x%08x\n", (uint32_t)__sbss_start);
273 debugf(" __sbss_end = 0x%08x\n", (uint32_t)__sbss_end);
274 debugf(" __sbss_start = 0x%08x\n", (uint32_t)__bss_start);
275 debugf(" _end = 0x%08x\n", (uint32_t)_end);
276}
277
278u_int
194
195static void
196cpu_e500_startup(void *dummy)
197{
198 int indx, size;
199
200 /* Initialise the decrementer-based clock. */
201 decr_init();

--- 69 unchanged lines hidden (view full) ---

271 debugf(" _edata = 0x%08x\n", (uint32_t)_edata);
272 debugf(" __sbss_start = 0x%08x\n", (uint32_t)__sbss_start);
273 debugf(" __sbss_end = 0x%08x\n", (uint32_t)__sbss_end);
274 debugf(" __sbss_start = 0x%08x\n", (uint32_t)__bss_start);
275 debugf(" _end = 0x%08x\n", (uint32_t)_end);
276}
277
278u_int
279e500_init(u_int32_t startkernel, u_int32_t endkernel, void *mdp)
279booke_init(uint32_t arg1, uint32_t arg2)
280{
281 struct pcpu *pc;
280{
281 struct pcpu *pc;
282 void *kmdp;
282 void *kmdp, *mdp;
283 vm_offset_t dtbp, end;
284 uint32_t csr;
285
286 kmdp = NULL;
287
283 vm_offset_t dtbp, end;
284 uint32_t csr;
285
286 kmdp = NULL;
287
288 end = endkernel;
288 end = (uintptr_t)_end;
289 dtbp = (vm_offset_t)NULL;
290
291 /*
289 dtbp = (vm_offset_t)NULL;
290
291 /*
292 * Handle the various ways we can get loaded and started:
293 * - FreeBSD's loader passes the pointer to the metadata
294 * in arg1, with arg2 undefined. arg1 has a value that's
295 * relative to the kernel's link address (i.e. larger
296 * than 0xc0000000).
297 * - Juniper's loader passes the metadata pointer in arg2
298 * and sets arg1 to zero. This is to signal that the
299 * loader maps the kernel and starts it at its link
300 * address (unlike the FreeBSD loader).
301 * - U-Boot passes the standard argc and argv parameters
302 * in arg1 and arg2 (resp). arg1 is between 1 and some
303 * relatively small number, such as 64K. arg2 is the
304 * physical address of the argv vector.
305 */
306 if (arg1 > (uintptr_t)kernel_text) /* FreeBSD loader */
307 mdp = (void *)arg1;
308 else if (arg1 == 0) /* Juniper loader */
309 mdp = (void *)arg2;
310 else /* U-Boot */
311 mdp = NULL;
312
313 /*
292 * Parse metadata and fetch parameters.
293 */
294 if (mdp != NULL) {
295 preload_metadata = mdp;
296 kmdp = preload_search_by_type("elf kernel");
297 if (kmdp != NULL) {
298 boothowto = MD_FETCH(kmdp, MODINFOMD_HOWTO, int);
299 kern_envp = MD_FETCH(kmdp, MODINFOMD_ENVP, char *);

--- 4 unchanged lines hidden (view full) ---

304 MODINFO_METADATA | MODINFOMD_BOOTINFO);
305
306#ifdef DDB
307 ksym_start = MD_FETCH(kmdp, MODINFOMD_SSYM, uintptr_t);
308 ksym_end = MD_FETCH(kmdp, MODINFOMD_ESYM, uintptr_t);
309#endif
310 }
311 } else {
314 * Parse metadata and fetch parameters.
315 */
316 if (mdp != NULL) {
317 preload_metadata = mdp;
318 kmdp = preload_search_by_type("elf kernel");
319 if (kmdp != NULL) {
320 boothowto = MD_FETCH(kmdp, MODINFOMD_HOWTO, int);
321 kern_envp = MD_FETCH(kmdp, MODINFOMD_ENVP, char *);

--- 4 unchanged lines hidden (view full) ---

326 MODINFO_METADATA | MODINFOMD_BOOTINFO);
327
328#ifdef DDB
329 ksym_start = MD_FETCH(kmdp, MODINFOMD_SSYM, uintptr_t);
330 ksym_end = MD_FETCH(kmdp, MODINFOMD_ESYM, uintptr_t);
331#endif
332 }
333 } else {
312 /*
313 * We should scream but how? Cannot even output anything...
314 */
315
316 /*
317 * FIXME add return value and handle in the locore so we can
318 * return to the loader maybe? (this seems not very easy to
319 * restore everything as the TLB have all been reprogrammed
320 * in the locore etc...)
321 */
322 while (1);
334 bzero(__sbss_start, __sbss_end - __sbss_start);
335 bzero(__bss_start, _end - __bss_start);
323 }
324
325#if defined(FDT_DTB_STATIC)
326 /*
327 * In case the device tree blob was not retrieved (from metadata) try
328 * to use the statically embedded one.
329 */
330 if (dtbp == (vm_offset_t)NULL)

--- 32 unchanged lines hidden (view full) ---

363
364 /* Initialize system mutexes. */
365 mutex_init();
366
367 /* Initialize the console before printing anything. */
368 cninit();
369
370 /* Print out some debug info... */
336 }
337
338#if defined(FDT_DTB_STATIC)
339 /*
340 * In case the device tree blob was not retrieved (from metadata) try
341 * to use the statically embedded one.
342 */
343 if (dtbp == (vm_offset_t)NULL)

--- 32 unchanged lines hidden (view full) ---

376
377 /* Initialize system mutexes. */
378 mutex_init();
379
380 /* Initialize the console before printing anything. */
381 cninit();
382
383 /* Print out some debug info... */
371 debugf("e500_init: console initialized\n");
372 debugf(" arg1 startkernel = 0x%08x\n", startkernel);
373 debugf(" arg2 endkernel = 0x%08x\n", endkernel);
384 debugf("%s: console initialized\n", __func__);
374 debugf(" arg3 mdp = 0x%08x\n", (u_int32_t)mdp);
375 debugf(" end = 0x%08x\n", (u_int32_t)end);
376 debugf(" boothowto = 0x%08x\n", boothowto);
377 debugf(" kernel ccsrbar = 0x%08x\n", CCSRBAR_VA);
378 debugf(" MSR = 0x%08x\n", mfmsr());
379 debugf(" HID0 = 0x%08x\n", mfspr(SPR_HID0));
380 debugf(" HID1 = 0x%08x\n", mfspr(SPR_HID1));
381 debugf(" BUCSR = 0x%08x\n", mfspr(SPR_BUCSR));

--- 16 unchanged lines hidden (view full) ---

398 kdb_enter(KDB_WHY_BOOTFLAGS, "Boot flags requested debugger");
399#endif
400
401 /* Initialise platform module */
402 platform_probe_and_attach();
403
404 /* Initialise virtual memory. */
405 pmap_mmu_install(MMU_TYPE_BOOKE, 0);
385 debugf(" arg3 mdp = 0x%08x\n", (u_int32_t)mdp);
386 debugf(" end = 0x%08x\n", (u_int32_t)end);
387 debugf(" boothowto = 0x%08x\n", boothowto);
388 debugf(" kernel ccsrbar = 0x%08x\n", CCSRBAR_VA);
389 debugf(" MSR = 0x%08x\n", mfmsr());
390 debugf(" HID0 = 0x%08x\n", mfspr(SPR_HID0));
391 debugf(" HID1 = 0x%08x\n", mfspr(SPR_HID1));
392 debugf(" BUCSR = 0x%08x\n", mfspr(SPR_BUCSR));

--- 16 unchanged lines hidden (view full) ---

409 kdb_enter(KDB_WHY_BOOTFLAGS, "Boot flags requested debugger");
410#endif
411
412 /* Initialise platform module */
413 platform_probe_and_attach();
414
415 /* Initialise virtual memory. */
416 pmap_mmu_install(MMU_TYPE_BOOKE, 0);
406 pmap_bootstrap(startkernel, end);
417 pmap_bootstrap((uintptr_t)kernel_text, end);
407 debugf("MSR = 0x%08x\n", mfmsr());
408 //tlb1_print_entries();
409 //tlb1_print_tlbentries();
410
411 /* Initialize params/tunables that are derived from memsize. */
412 init_param2(physmem);
413
414 /* Finish setting up thread0. */

--- 29 unchanged lines hidden (view full) ---

444 icache_enable();
445 }
446
447 csr = mfspr(SPR_L1CSR1);
448 if ((boothowto & RB_VERBOSE) != 0 || (csr & L1CSR1_ICE) == 0)
449 printf("L1 I-cache %sabled\n",
450 (csr & L1CSR1_ICE) ? "en" : "dis");
451
418 debugf("MSR = 0x%08x\n", mfmsr());
419 //tlb1_print_entries();
420 //tlb1_print_tlbentries();
421
422 /* Initialize params/tunables that are derived from memsize. */
423 init_param2(physmem);
424
425 /* Finish setting up thread0. */

--- 29 unchanged lines hidden (view full) ---

455 icache_enable();
456 }
457
458 csr = mfspr(SPR_L1CSR1);
459 if ((boothowto & RB_VERBOSE) != 0 || (csr & L1CSR1_ICE) == 0)
460 printf("L1 I-cache %sabled\n",
461 (csr & L1CSR1_ICE) ? "en" : "dis");
462
452 debugf("e500_init: SP = 0x%08x\n", ((uintptr_t)thread0.td_pcb - 16) & ~15);
453 debugf("e500_init: e\n");
463 debugf("%s: SP = 0x%08x\n", __func__,
464 ((uintptr_t)thread0.td_pcb - 16) & ~15);
454
455 return (((uintptr_t)thread0.td_pcb - 16) & ~15);
456}
457
458#define RES_GRANULE 32
459extern uint32_t tlb0_miss_locks[];
460
461/* Initialise a struct pcpu. */

--- 156 unchanged lines hidden ---
465
466 return (((uintptr_t)thread0.td_pcb - 16) & ~15);
467}
468
469#define RES_GRANULE 32
470extern uint32_t tlb0_miss_locks[];
471
472/* Initialise a struct pcpu. */

--- 156 unchanged lines hidden ---