Deleted Added
full compact
machdep.c (225888) machdep.c (230633)
1/*-
2 * Copyright (c) 2001 Jake Burkholder.
3 * Copyright (c) 1992 Terrence R. Lambert.
4 * Copyright (c) 1982, 1987, 1990 The Regents of the University of California.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * William Jolitz.

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

31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91
35 * from: FreeBSD: src/sys/i386/i386/machdep.c,v 1.477 2001/08/27
36 */
37
38#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2001 Jake Burkholder.
3 * Copyright (c) 1992 Terrence R. Lambert.
4 * Copyright (c) 1982, 1987, 1990 The Regents of the University of California.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * William Jolitz.

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

31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91
35 * from: FreeBSD: src/sys/i386/i386/machdep.c,v 1.477 2001/08/27
36 */
37
38#include <sys/cdefs.h>
39__FBSDID("$FreeBSD: head/sys/sparc64/sparc64/machdep.c 225888 2011-09-30 20:23:18Z marius $");
39__FBSDID("$FreeBSD: head/sys/sparc64/sparc64/machdep.c 230633 2012-01-27 23:21:54Z marius $");
40
41#include "opt_compat.h"
42#include "opt_ddb.h"
43#include "opt_kstack_pages.h"
44
45#include <sys/param.h>
46#include <sys/malloc.h>
47#include <sys/proc.h>

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

83#include <vm/vm_object.h>
84#include <vm/vm_pager.h>
85#include <vm/vm_param.h>
86
87#include <ddb/ddb.h>
88
89#include <machine/bus.h>
90#include <machine/cache.h>
40
41#include "opt_compat.h"
42#include "opt_ddb.h"
43#include "opt_kstack_pages.h"
44
45#include <sys/param.h>
46#include <sys/malloc.h>
47#include <sys/proc.h>

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

83#include <vm/vm_object.h>
84#include <vm/vm_pager.h>
85#include <vm/vm_param.h>
86
87#include <ddb/ddb.h>
88
89#include <machine/bus.h>
90#include <machine/cache.h>
91#include <machine/clock.h>
92#include <machine/cmt.h>
93#include <machine/cpu.h>
94#include <machine/fireplane.h>
95#include <machine/fp.h>
96#include <machine/fsr.h>
97#include <machine/intr_machdep.h>
98#include <machine/jbus.h>
99#include <machine/md_var.h>

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

371 /*
372 * Set up Open Firmware entry points.
373 */
374 ofw_tba = rdpr(tba);
375 ofw_vec = (u_long)vec;
376
377 /*
378 * Parse metadata if present and fetch parameters. Must be before the
91#include <machine/cmt.h>
92#include <machine/cpu.h>
93#include <machine/fireplane.h>
94#include <machine/fp.h>
95#include <machine/fsr.h>
96#include <machine/intr_machdep.h>
97#include <machine/jbus.h>
98#include <machine/md_var.h>

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

370 /*
371 * Set up Open Firmware entry points.
372 */
373 ofw_tba = rdpr(tba);
374 ofw_vec = (u_long)vec;
375
376 /*
377 * Parse metadata if present and fetch parameters. Must be before the
379 * console is inited so cninit gets the right value of boothowto.
378 * console is inited so cninit() gets the right value of boothowto.
380 */
381 if (mdp != NULL) {
382 preload_metadata = mdp;
383 kmdp = preload_search_by_type("elf kernel");
384 if (kmdp != NULL) {
385 boothowto = MD_FETCH(kmdp, MODINFOMD_HOWTO, int);
386 kern_envp = MD_FETCH(kmdp, MODINFOMD_ENVP, char *);
387 end = MD_FETCH(kmdp, MODINFOMD_KERNEND, vm_offset_t);

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

416
417 /*
418 * Determine the OFW node and frequency of the BSP (and ensure the
419 * BSP is in the device tree in the first place).
420 */
421 root = OF_peer(0);
422 pc->pc_node = find_bsp(root, pc->pc_mid, cpu_impl);
423 if (pc->pc_node == 0)
379 */
380 if (mdp != NULL) {
381 preload_metadata = mdp;
382 kmdp = preload_search_by_type("elf kernel");
383 if (kmdp != NULL) {
384 boothowto = MD_FETCH(kmdp, MODINFOMD_HOWTO, int);
385 kern_envp = MD_FETCH(kmdp, MODINFOMD_ENVP, char *);
386 end = MD_FETCH(kmdp, MODINFOMD_KERNEND, vm_offset_t);

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

415
416 /*
417 * Determine the OFW node and frequency of the BSP (and ensure the
418 * BSP is in the device tree in the first place).
419 */
420 root = OF_peer(0);
421 pc->pc_node = find_bsp(root, pc->pc_mid, cpu_impl);
422 if (pc->pc_node == 0)
424 OF_exit();
423 OF_panic("%s: cannot find boot CPU node", __func__);
425 if (OF_getprop(pc->pc_node, "clock-frequency", &pc->pc_clock,
426 sizeof(pc->pc_clock)) <= 0)
424 if (OF_getprop(pc->pc_node, "clock-frequency", &pc->pc_clock,
425 sizeof(pc->pc_clock)) <= 0)
427 OF_exit();
426 OF_panic("%s: cannot determine boot CPU clock", __func__);
428
429 /*
427
428 /*
430 * Provide a DELAY() that works before PCPU_REG is set. We can't
431 * set PCPU_REG without also taking over the trap table or the
432 * firmware will overwrite it. Unfortunately, it's way to early
433 * to also take over the trap table at this point.
434 */
435 clock_boot = pc->pc_clock;
436 delay_func = delay_boot;
437
438 /*
439 * Initialize the console before printing anything.
440 * NB: the low-level console drivers require a working DELAY() at
441 * this point.
442 */
443 cninit();
444
445 /*
446 * Panic if there is no metadata. Most likely the kernel was booted
447 * directly, instead of through loader(8).
448 */
449 if (mdp == NULL || kmdp == NULL || end == 0 ||
429 * Panic if there is no metadata. Most likely the kernel was booted
430 * directly, instead of through loader(8).
431 */
432 if (mdp == NULL || kmdp == NULL || end == 0 ||
450 kernel_tlb_slots == 0 || kernel_tlbs == NULL) {
451 printf("sparc64_init: missing loader metadata.\n"
452 "This probably means you are not using loader(8).\n");
453 panic("sparc64_init");
454 }
433 kernel_tlb_slots == 0 || kernel_tlbs == NULL)
434 OF_panic("%s: missing loader metadata.\nThis probably means "
435 "you are not using loader(8).", __func__);
455
456 /*
457 * Work around the broken loader behavior of not demapping no
458 * longer used kernel TLB slots when unloading the kernel or
459 * modules.
460 */
461 for (va = KERNBASE + (kernel_tlb_slots - 1) * PAGE_SIZE_4M;
462 va >= roundup2(end, PAGE_SIZE_4M); va -= PAGE_SIZE_4M) {
463 if (bootverbose)
436
437 /*
438 * Work around the broken loader behavior of not demapping no
439 * longer used kernel TLB slots when unloading the kernel or
440 * modules.
441 */
442 for (va = KERNBASE + (kernel_tlb_slots - 1) * PAGE_SIZE_4M;
443 va >= roundup2(end, PAGE_SIZE_4M); va -= PAGE_SIZE_4M) {
444 if (bootverbose)
464 printf("demapping unused kernel TLB slot "
445 OF_printf("demapping unused kernel TLB slot "
465 "(va %#lx - %#lx)\n", va, va + PAGE_SIZE_4M - 1);
466 stxa(TLB_DEMAP_VA(va) | TLB_DEMAP_PRIMARY | TLB_DEMAP_PAGE,
467 ASI_DMMU_DEMAP, 0);
468 stxa(TLB_DEMAP_VA(va) | TLB_DEMAP_PRIMARY | TLB_DEMAP_PAGE,
469 ASI_IMMU_DEMAP, 0);
470 flush(KERNBASE);
471 kernel_tlb_slots--;
472 }
473
474 /*
475 * Determine the TLB slot maxima, which are expected to be
476 * equal across all CPUs.
477 * NB: for cheetah-class CPUs, these properties only refer
478 * to the t16s.
479 */
480 if (OF_getprop(pc->pc_node, "#dtlb-entries", &dtlb_slots,
481 sizeof(dtlb_slots)) == -1)
446 "(va %#lx - %#lx)\n", va, va + PAGE_SIZE_4M - 1);
447 stxa(TLB_DEMAP_VA(va) | TLB_DEMAP_PRIMARY | TLB_DEMAP_PAGE,
448 ASI_DMMU_DEMAP, 0);
449 stxa(TLB_DEMAP_VA(va) | TLB_DEMAP_PRIMARY | TLB_DEMAP_PAGE,
450 ASI_IMMU_DEMAP, 0);
451 flush(KERNBASE);
452 kernel_tlb_slots--;
453 }
454
455 /*
456 * Determine the TLB slot maxima, which are expected to be
457 * equal across all CPUs.
458 * NB: for cheetah-class CPUs, these properties only refer
459 * to the t16s.
460 */
461 if (OF_getprop(pc->pc_node, "#dtlb-entries", &dtlb_slots,
462 sizeof(dtlb_slots)) == -1)
482 panic("sparc64_init: cannot determine number of dTLB slots");
463 OF_panic("%s: cannot determine number of dTLB slots",
464 __func__);
483 if (OF_getprop(pc->pc_node, "#itlb-entries", &itlb_slots,
484 sizeof(itlb_slots)) == -1)
465 if (OF_getprop(pc->pc_node, "#itlb-entries", &itlb_slots,
466 sizeof(itlb_slots)) == -1)
485 panic("sparc64_init: cannot determine number of iTLB slots");
467 OF_panic("%s: cannot determine number of iTLB slots",
468 __func__);
486
487 /*
469
470 /*
488 * Initialize and enable the caches. Note that his may include
471 * Initialize and enable the caches. Note that this may include
489 * applying workarounds.
490 */
491 cache_init(pc);
492 cache_enable(cpu_impl);
493 uma_set_align(pc->pc_cache.dc_linesize - 1);
494
495 cpu_block_copy = bcopy;
496 cpu_block_zero = bzero;

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

568 * within the PROM so obtaining /virtual-memory/translations doesn't
569 * trigger a fatal reset error or worse things further down the road.
570 * XXX it should be possible to use this solely instead of writing
571 * %tba in cpu_setregs(). Doing so causes a hang however.
572 */
573 sun4u_set_traptable(tl0_base);
574
575 /*
472 * applying workarounds.
473 */
474 cache_init(pc);
475 cache_enable(cpu_impl);
476 uma_set_align(pc->pc_cache.dc_linesize - 1);
477
478 cpu_block_copy = bcopy;
479 cpu_block_zero = bzero;

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

551 * within the PROM so obtaining /virtual-memory/translations doesn't
552 * trigger a fatal reset error or worse things further down the road.
553 * XXX it should be possible to use this solely instead of writing
554 * %tba in cpu_setregs(). Doing so causes a hang however.
555 */
556 sun4u_set_traptable(tl0_base);
557
558 /*
576 * It's now safe to use the real DELAY().
559 * Initialize the console.
560 * NB: the low-level console drivers require a working DELAY() and
561 * some compiler optimizations may cause the curthread accesses of
562 * mutex(9) to be factored out even if the latter aren't actually
563 * called, both requiring PCPU_REG to be set.
577 */
564 */
578 delay_func = delay_tick;
565 cninit();
579
580 /*
581 * Initialize the dynamic per-CPU area for the BSP and the message
582 * buffer (after setting the trap table).
583 */
584 dpcpu_init(dpcpu0, 0);
585 msgbufinit(msgbufp, msgbufsize);
586

--- 541 unchanged lines hidden ---
566
567 /*
568 * Initialize the dynamic per-CPU area for the BSP and the message
569 * buffer (after setting the trap table).
570 */
571 dpcpu_init(dpcpu0, 0);
572 msgbufinit(msgbufp, msgbufsize);
573

--- 541 unchanged lines hidden ---