2 * Initial implementation:
3 * Copyright (c) 2001 Robert Drehmel
6 * As long as the above copyright statement and this notice remain
7 * unchanged, you can do what ever you want with this file.
10 * Copyright (c) 2008 Marius Strobl <marius@FreeBSD.org>
11 * All rights reserved.
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 #include <sys/cdefs.h>
36 __FBSDID("$FreeBSD$");
39 * FreeBSD/sparc64 kernel loader - machine dependent part
41 * - implements copyin and readin functions that map kernel
42 * pages on demand. The machine independent code does not
43 * know the size of the kernel early enough to pre-enter
44 * TTEs and install just one 4MB mapping seemed to limiting
49 #include <sys/param.h>
51 #include <sys/linker.h>
52 #include <sys/queue.h>
53 #include <sys/types.h>
56 #include <machine/asi.h>
57 #include <machine/cmt.h>
58 #include <machine/cpufunc.h>
59 #include <machine/elf.h>
60 #include <machine/fireplane.h>
61 #include <machine/jbus.h>
62 #include <machine/lsu.h>
63 #include <machine/metadata.h>
64 #include <machine/tte.h>
65 #include <machine/tlb.h>
66 #include <machine/upa.h>
67 #include <machine/ver.h>
68 #include <machine/vmparam.h>
70 #include "bootstrap.h"
75 #define CTASSERT(x) _CTASSERT(x, __LINE__)
76 #define _CTASSERT(x, y) __CTASSERT(x, y)
77 #define __CTASSERT(x, y) typedef char __assert ## y[(x) ? 1 : -1]
80 extern char bootprog_name[], bootprog_rev[], bootprog_date[], bootprog_maker[];
85 LOADSZ = 0x1000000 /* for kernel and modules */
88 /* At least Sun Fire V1280 require page sized allocations to be claimed. */
89 CTASSERT(HEAPSZ % PAGE_SIZE == 0);
91 static struct mmu_ops {
92 void (*tlb_init)(void);
93 int (*mmu_mapin)(vm_offset_t va, vm_size_t len);
96 typedef void kernel_entry_t(vm_offset_t mdp, u_long o1, u_long o2, u_long o3,
99 static inline u_long dtlb_get_data_sun4u(u_int);
100 static int dtlb_enter_sun4u(u_int, u_long data, vm_offset_t);
101 static vm_offset_t dtlb_va_to_pa_sun4u(vm_offset_t);
102 static inline u_long itlb_get_data_sun4u(u_int);
103 static int itlb_enter_sun4u(u_int, u_long data, vm_offset_t);
104 static vm_offset_t itlb_va_to_pa_sun4u(vm_offset_t);
105 static void itlb_relocate_locked0_sun4u(void);
106 extern vm_offset_t md_load(char *, vm_offset_t *);
107 static int sparc64_autoload(void);
108 static ssize_t sparc64_readin(const int, vm_offset_t, const size_t);
109 static ssize_t sparc64_copyin(const void *, vm_offset_t, size_t);
110 static void sparc64_maphint(vm_offset_t, size_t);
111 static vm_offset_t claim_virt(vm_offset_t, size_t, int);
112 static vm_offset_t alloc_phys(size_t, int);
113 static int map_phys(int, size_t, vm_offset_t, vm_offset_t);
114 static void release_phys(vm_offset_t, u_int);
115 static int __elfN(exec)(struct preloaded_file *);
116 static int mmu_mapin_sun4u(vm_offset_t, vm_size_t);
117 static int mmu_mapin_sun4v(vm_offset_t, vm_size_t);
118 static vm_offset_t init_heap(void);
119 static phandle_t find_bsp_sun4u(phandle_t, uint32_t);
120 const char *cpu_cpuid_prop_sun4u(void);
121 uint32_t cpu_get_mid_sun4u(void);
122 static void tlb_init_sun4u(void);
123 static void tlb_init_sun4v(void);
126 typedef u_int64_t tte_t;
128 static void pmap_print_tlb_sun4u(void);
129 static void pmap_print_tte_sun4u(tte_t, tte_t);
132 static struct mmu_ops mmu_ops_sun4u = { tlb_init_sun4u, mmu_mapin_sun4u };
133 static struct mmu_ops mmu_ops_sun4v = { tlb_init_sun4v, mmu_mapin_sun4v };
136 struct tlb_entry *dtlb_store;
137 struct tlb_entry *itlb_store;
141 static u_int dtlb_slot_max;
142 static u_int itlb_slot_max;
145 static struct tlb_entry *tlb_store;
146 static int is_sun4v = 0;
148 * no direct TLB access on sun4v
149 * we somewhat arbitrarily declare enough
150 * slots to cover a 4GB AS with 4MB pages
152 #define SUN4V_TLB_SLOT_MAX (1 << 10)
154 static vm_offset_t curkva = 0;
155 static vm_offset_t heapva;
157 static phandle_t root;
160 * Machine dependent structures that the machine independent
163 struct devsw *devsw[] = {
164 #ifdef LOADER_DISK_SUPPORT
167 #ifdef LOADER_NET_SUPPORT
172 struct arch_switch archsw;
174 static struct file_format sparc64_elf = {
178 struct file_format *file_formats[] = {
182 struct fs_ops *file_system[] = {
183 #ifdef LOADER_UFS_SUPPORT
186 #ifdef LOADER_CD9660_SUPPORT
189 #ifdef LOADER_ZIP_SUPPORT
192 #ifdef LOADER_GZIP_SUPPORT
195 #ifdef LOADER_BZIP2_SUPPORT
198 #ifdef LOADER_NFS_SUPPORT
201 #ifdef LOADER_TFTP_SUPPORT
206 struct netif_driver *netif_drivers[] = {
207 #ifdef LOADER_NET_SUPPORT
213 extern struct console ofwconsole;
214 struct console *consoles[] = {
221 watch_phys_set_mask(vm_offset_t pa, u_long mask)
225 stxa(AA_DMMU_PWPR, ASI_DMMU, pa & (((2UL << 38) - 1) << 3));
226 lsucr = ldxa(0, ASI_LSU_CTL_REG);
227 lsucr = ((lsucr | LSU_PW) & ~LSU_PM_MASK) |
228 (mask << LSU_PM_SHIFT);
229 stxa(0, ASI_LSU_CTL_REG, lsucr);
234 watch_phys_set(vm_offset_t pa, int sz)
238 off = (u_long)pa & 7;
239 /* Test for misaligned watch points. */
242 return (watch_phys_set_mask(pa, ((1 << sz) - 1) << off));
247 watch_virt_set_mask(vm_offset_t va, u_long mask)
251 stxa(AA_DMMU_VWPR, ASI_DMMU, va & (((2UL << 41) - 1) << 3));
252 lsucr = ldxa(0, ASI_LSU_CTL_REG);
253 lsucr = ((lsucr | LSU_VW) & ~LSU_VM_MASK) |
254 (mask << LSU_VM_SHIFT);
255 stxa(0, ASI_LSU_CTL_REG, lsucr);
260 watch_virt_set(vm_offset_t va, int sz)
264 off = (u_long)va & 7;
265 /* Test for misaligned watch points. */
268 return (watch_virt_set_mask(va, ((1 << sz) - 1) << off));
276 sparc64_autoload(void)
283 sparc64_readin(const int fd, vm_offset_t va, const size_t len)
286 mmu_ops->mmu_mapin(va, len);
287 return (read(fd, (void *)va, len));
291 sparc64_copyin(const void *src, vm_offset_t dest, size_t len)
294 mmu_ops->mmu_mapin(dest, len);
295 memcpy((void *)dest, src, len);
300 sparc64_maphint(vm_offset_t va, size_t len)
305 int i, free_excess = 0;
310 if (tlb_store[va >> 22].te_pa != -1)
313 /* round up to nearest 4MB page */
314 size = (len + PAGE_MASK_4M) & ~PAGE_MASK_4M;
316 pa = alloc_phys(PAGE_SIZE_256M, PAGE_SIZE_256M);
322 pa = alloc_phys(size, PAGE_SIZE_256M);
324 pa = alloc_phys(size, PAGE_SIZE_4M);
326 panic("%s: out of memory", __func__);
328 for (i = 0; i < size; i += PAGE_SIZE_4M) {
329 mva = claim_virt(va + i, PAGE_SIZE_4M, 0);
331 panic("%s: can't claim virtual page "
332 "(wanted %#lx, got %#lx)",
335 tlb_store[mva >> 22].te_pa = pa + i;
336 if (map_phys(-1, PAGE_SIZE_4M, mva, pa + i) != 0)
337 printf("%s: can't map physical page\n", __func__);
340 release_phys(pa, PAGE_SIZE_256M);
347 claim_virt(vm_offset_t virt, size_t size, int align)
351 if (OF_call_method("claim", mmu, 3, 1, virt, size, align, &mva) == -1)
352 return ((vm_offset_t)-1);
357 alloc_phys(size_t size, int align)
359 cell_t phys_hi, phys_low;
361 if (OF_call_method("claim", memory, 2, 2, size, align, &phys_low,
363 return ((vm_offset_t)-1);
364 return ((vm_offset_t)phys_hi << 32 | phys_low);
368 map_phys(int mode, size_t size, vm_offset_t virt, vm_offset_t phys)
371 return (OF_call_method("map", mmu, 5, 0, (uint32_t)phys,
372 (uint32_t)(phys >> 32), virt, size, mode));
376 release_phys(vm_offset_t phys, u_int size)
379 (void)OF_call_method("release", memory, 3, 0, (uint32_t)phys,
380 (uint32_t)(phys >> 32), size);
384 __elfN(exec)(struct preloaded_file *fp)
386 struct file_metadata *fmp;
392 if ((fmp = file_findmetadata(fp, MODINFOMD_ELFHDR)) == 0)
394 e = (Elf_Ehdr *)&fmp->md_data;
396 if ((error = md_load(fp->f_args, &mdp)) != 0)
399 printf("jumping to kernel entry at %#lx.\n", e->e_entry);
401 pmap_print_tlb_sun4u();
408 OF_release((void *)heapva, HEAPSZ);
410 ((kernel_entry_t *)entry)(mdp, 0, 0, 0, openfirmware);
412 panic("%s: exec returned", __func__);
416 dtlb_get_data_sun4u(u_int slot)
420 * We read ASI_DTLB_DATA_ACCESS_REG twice in order to work
421 * around errata of USIII and beyond.
423 (void)ldxa(TLB_DAR_SLOT(slot), ASI_DTLB_DATA_ACCESS_REG);
424 return (ldxa(TLB_DAR_SLOT(slot), ASI_DTLB_DATA_ACCESS_REG));
428 itlb_get_data_sun4u(u_int slot)
432 * We read ASI_ITLB_DATA_ACCESS_REG twice in order to work
433 * around errata of USIII and beyond.
435 (void)ldxa(TLB_DAR_SLOT(slot), ASI_ITLB_DATA_ACCESS_REG);
436 return (ldxa(TLB_DAR_SLOT(slot), ASI_ITLB_DATA_ACCESS_REG));
440 dtlb_va_to_pa_sun4u(vm_offset_t va)
445 pstate = rdpr(pstate);
446 wrpr(pstate, pstate & ~PSTATE_IE, 0);
447 for (i = 0; i < dtlb_slot_max; i++) {
448 reg = ldxa(TLB_DAR_SLOT(i), ASI_DTLB_TAG_READ_REG);
449 if (TLB_TAR_VA(reg) != va)
451 reg = dtlb_get_data_sun4u(i);
452 wrpr(pstate, pstate, 0);
454 if (cpu_impl >= CPU_IMPL_ULTRASPARCIII)
455 return (reg & TD_PA_CH_MASK);
456 return (reg & TD_PA_SF_MASK);
458 wrpr(pstate, pstate, 0);
463 itlb_va_to_pa_sun4u(vm_offset_t va)
468 pstate = rdpr(pstate);
469 wrpr(pstate, pstate & ~PSTATE_IE, 0);
470 for (i = 0; i < itlb_slot_max; i++) {
471 reg = ldxa(TLB_DAR_SLOT(i), ASI_ITLB_TAG_READ_REG);
472 if (TLB_TAR_VA(reg) != va)
474 reg = itlb_get_data_sun4u(i);
475 wrpr(pstate, pstate, 0);
477 if (cpu_impl >= CPU_IMPL_ULTRASPARCIII)
478 return (reg & TD_PA_CH_MASK);
479 return (reg & TD_PA_SF_MASK);
481 wrpr(pstate, pstate, 0);
486 dtlb_enter_sun4u(u_int index, u_long data, vm_offset_t virt)
489 return (OF_call_method("SUNW,dtlb-load", mmu, 3, 0, index, data,
494 itlb_enter_sun4u(u_int index, u_long data, vm_offset_t virt)
497 if (cpu_impl == CPU_IMPL_ULTRASPARCIIIp && index == 0 &&
499 panic("%s: won't enter locked TLB entry at index 0 on USIII+",
501 return (OF_call_method("SUNW,itlb-load", mmu, 3, 0, index, data,
506 itlb_relocate_locked0_sun4u(void)
508 u_long data, pstate, tag;
511 if (cpu_impl != CPU_IMPL_ULTRASPARCIIIp)
514 pstate = rdpr(pstate);
515 wrpr(pstate, pstate & ~PSTATE_IE, 0);
517 data = itlb_get_data_sun4u(0);
518 if ((data & (TD_V | TD_L)) != (TD_V | TD_L)) {
519 wrpr(pstate, pstate, 0);
523 /* Flush the mapping of slot 0. */
524 tag = ldxa(TLB_DAR_SLOT(0), ASI_ITLB_TAG_READ_REG);
525 stxa(TLB_DEMAP_VA(TLB_TAR_VA(tag)) | TLB_DEMAP_PRIMARY |
526 TLB_DEMAP_PAGE, ASI_IMMU_DEMAP, 0);
527 flush(0); /* The USIII-family ignores the address. */
530 * Search a replacement slot != 0 and enter the data and tag
531 * that formerly were in slot 0.
533 for (i = 1; i < itlb_slot_max; i++) {
534 if ((itlb_get_data_sun4u(i) & TD_V) != 0)
537 stxa(AA_IMMU_TAR, ASI_IMMU, tag);
538 stxa(TLB_DAR_SLOT(i), ASI_ITLB_DATA_ACCESS_REG, data);
539 flush(0); /* The USIII-family ignores the address. */
542 wrpr(pstate, pstate, 0);
543 if (i == itlb_slot_max)
544 panic("%s: could not find a replacement slot", __func__);
548 mmu_mapin_sun4u(vm_offset_t va, vm_size_t len)
554 if (va + len > curkva)
557 pa = (vm_offset_t)-1;
558 len += va & PAGE_MASK_4M;
561 if (dtlb_va_to_pa_sun4u(va) == (vm_offset_t)-1 ||
562 itlb_va_to_pa_sun4u(va) == (vm_offset_t)-1) {
563 /* Allocate a physical page, claim the virtual area. */
564 if (pa == (vm_offset_t)-1) {
565 pa = alloc_phys(PAGE_SIZE_4M, PAGE_SIZE_4M);
566 if (pa == (vm_offset_t)-1)
567 panic("%s: out of memory", __func__);
568 mva = claim_virt(va, PAGE_SIZE_4M, 0);
570 panic("%s: can't claim virtual page "
571 "(wanted %#lx, got %#lx)",
574 * The mappings may have changed, be paranoid.
579 * Actually, we can only allocate two pages less at
580 * most (depending on the kernel TSB size).
582 if (dtlb_slot >= dtlb_slot_max)
583 panic("%s: out of dtlb_slots", __func__);
584 if (itlb_slot >= itlb_slot_max)
585 panic("%s: out of itlb_slots", __func__);
586 data = TD_V | TD_4M | TD_PA(pa) | TD_L | TD_CP |
588 dtlb_store[dtlb_slot].te_pa = pa;
589 dtlb_store[dtlb_slot].te_va = va;
590 index = dtlb_slot_max - dtlb_slot - 1;
591 if (dtlb_enter_sun4u(index, data, va) < 0)
592 panic("%s: can't enter dTLB slot %d data "
593 "%#lx va %#lx", __func__, index, data,
596 itlb_store[itlb_slot].te_pa = pa;
597 itlb_store[itlb_slot].te_va = va;
598 index = itlb_slot_max - itlb_slot - 1;
599 if (itlb_enter_sun4u(index, data, va) < 0)
600 panic("%s: can't enter iTLB slot %d data "
601 "%#lx va %#lxd", __func__, index, data,
604 pa = (vm_offset_t)-1;
606 len -= len > PAGE_SIZE_4M ? PAGE_SIZE_4M : len;
609 if (pa != (vm_offset_t)-1)
610 release_phys(pa, PAGE_SIZE_4M);
615 mmu_mapin_sun4v(vm_offset_t va, vm_size_t len)
619 if (va + len > curkva)
622 pa = (vm_offset_t)-1;
623 len += va & PAGE_MASK_4M;
626 if ((va >> 22) > SUN4V_TLB_SLOT_MAX)
627 panic("%s: trying to map more than 4GB", __func__);
628 if (tlb_store[va >> 22].te_pa == -1) {
629 /* Allocate a physical page, claim the virtual area */
630 if (pa == (vm_offset_t)-1) {
631 pa = alloc_phys(PAGE_SIZE_4M, PAGE_SIZE_4M);
632 if (pa == (vm_offset_t)-1)
633 panic("%s: out of memory", __func__);
634 mva = claim_virt(va, PAGE_SIZE_4M, 0);
636 panic("%s: can't claim virtual page "
637 "(wanted %#lx, got %#lx)",
641 tlb_store[va >> 22].te_pa = pa;
642 if (map_phys(-1, PAGE_SIZE_4M, va, pa) == -1)
643 printf("%s: can't map physical page\n",
645 pa = (vm_offset_t)-1;
647 len -= len > PAGE_SIZE_4M ? PAGE_SIZE_4M : len;
650 if (pa != (vm_offset_t)-1)
651 release_phys(pa, PAGE_SIZE_4M);
659 /* There is no need for continuous physical heap memory. */
660 heapva = (vm_offset_t)OF_claim((void *)HEAPVA, HEAPSZ, 32);
665 find_bsp_sun4u(phandle_t node, uint32_t bspid)
667 char type[sizeof("cpu")];
671 for (; node > 0; node = OF_peer(node)) {
672 child = OF_child(node);
674 child = find_bsp_sun4u(child, bspid);
678 if (OF_getprop(node, "device_type", type,
681 if (strcmp(type, "cpu") != 0)
683 if (OF_getprop(node, cpu_cpuid_prop_sun4u(), &cpuid,
694 cpu_cpuid_prop_sun4u(void)
698 case CPU_IMPL_SPARC64:
699 case CPU_IMPL_ULTRASPARCI:
700 case CPU_IMPL_ULTRASPARCII:
701 case CPU_IMPL_ULTRASPARCIIi:
702 case CPU_IMPL_ULTRASPARCIIe:
703 return ("upa-portid");
704 case CPU_IMPL_ULTRASPARCIII:
705 case CPU_IMPL_ULTRASPARCIIIp:
706 case CPU_IMPL_ULTRASPARCIIIi:
707 case CPU_IMPL_ULTRASPARCIIIip:
709 case CPU_IMPL_ULTRASPARCIV:
710 case CPU_IMPL_ULTRASPARCIVp:
718 cpu_get_mid_sun4u(void)
722 case CPU_IMPL_SPARC64:
723 case CPU_IMPL_ULTRASPARCI:
724 case CPU_IMPL_ULTRASPARCII:
725 case CPU_IMPL_ULTRASPARCIIi:
726 case CPU_IMPL_ULTRASPARCIIe:
727 return (UPA_CR_GET_MID(ldxa(0, ASI_UPA_CONFIG_REG)));
728 case CPU_IMPL_ULTRASPARCIII:
729 case CPU_IMPL_ULTRASPARCIIIp:
730 return (FIREPLANE_CR_GET_AID(ldxa(AA_FIREPLANE_CONFIG,
731 ASI_FIREPLANE_CONFIG_REG)));
732 case CPU_IMPL_ULTRASPARCIIIi:
733 case CPU_IMPL_ULTRASPARCIIIip:
734 return (JBUS_CR_GET_JID(ldxa(0, ASI_JBUS_CONFIG_REG)));
735 case CPU_IMPL_ULTRASPARCIV:
736 case CPU_IMPL_ULTRASPARCIVp:
737 return (INTR_ID_GET_ID(ldxa(AA_INTR_ID, ASI_INTR_ID)));
748 cpu_impl = VER_IMPL(rdpr(ver));
749 bsp = find_bsp_sun4u(OF_child(root), cpu_get_mid_sun4u());
751 panic("%s: no node for bootcpu?!?!", __func__);
753 if (OF_getprop(bsp, "#dtlb-entries", &dtlb_slot_max,
754 sizeof(dtlb_slot_max)) == -1 ||
755 OF_getprop(bsp, "#itlb-entries", &itlb_slot_max,
756 sizeof(itlb_slot_max)) == -1)
757 panic("%s: can't get TLB slot max.", __func__);
759 if (cpu_impl == CPU_IMPL_ULTRASPARCIIIp) {
761 printf("pre fixup:\n");
762 pmap_print_tlb_sun4u();
766 * Relocate the locked entry in it16 slot 0 (if existent)
767 * as part of working around Cheetah+ erratum 34.
769 itlb_relocate_locked0_sun4u();
772 printf("post fixup:\n");
773 pmap_print_tlb_sun4u();
777 dtlb_store = malloc(dtlb_slot_max * sizeof(*dtlb_store));
778 itlb_store = malloc(itlb_slot_max * sizeof(*itlb_store));
779 if (dtlb_store == NULL || itlb_store == NULL)
780 panic("%s: can't allocate TLB store", __func__);
787 tlb_store = malloc(SUN4V_TLB_SLOT_MAX * sizeof(*tlb_store));
788 memset(tlb_store, 0xFF, SUN4V_TLB_SLOT_MAX * sizeof(*tlb_store));
792 main(int (*openfirm)(void *))
799 * Tell the Open Firmware functions where they find the OFW gate.
803 archsw.arch_getdev = ofw_getdev;
804 archsw.arch_copyin = sparc64_copyin;
805 archsw.arch_copyout = ofw_copyout;
806 archsw.arch_readin = sparc64_readin;
807 archsw.arch_autoload = sparc64_autoload;
808 archsw.arch_maphint = sparc64_maphint;
811 * Probe for a console.
815 if (init_heap() == (vm_offset_t)-1)
816 panic("%s: can't claim heap", __func__);
817 setheap((void *)heapva, (void *)(heapva + HEAPSZ));
819 if ((root = OF_peer(0)) == -1)
820 panic("%s: can't get root phandle", __func__);
821 OF_getprop(root, "compatible", compatible, sizeof(compatible));
822 if (!strcmp(compatible, "sun4v")) {
823 printf("\nBooting with sun4v support.\n");
824 mmu_ops = &mmu_ops_sun4v;
827 printf("\nBooting with sun4u support.\n");
828 mmu_ops = &mmu_ops_sun4u;
834 * Initialize devices.
836 for (dp = devsw; *dp != 0; dp++) {
837 if ((*dp)->dv_init != 0)
842 * Set up the current device.
844 OF_getprop(chosen, "bootpath", bootpath, sizeof(bootpath));
847 * Sun compatible bootable CD-ROMs have a disk label placed
848 * before the cd9660 data, with the actual filesystem being
849 * in the first partition, while the other partitions contain
850 * pseudo disk labels with embedded boot blocks for different
851 * architectures, which may be followed by UFS filesystems.
852 * The firmware will set the boot path to the partition it
853 * boots from ('f' in the sun4u case), but we want the kernel
854 * to be loaded from the cd9660 fs ('a'), so the boot path
855 * needs to be altered.
857 if (bootpath[strlen(bootpath) - 2] == ':' &&
858 bootpath[strlen(bootpath) - 1] == 'f') {
859 bootpath[strlen(bootpath) - 1] = 'a';
860 printf("Boot path set to %s\n", bootpath);
863 env_setenv("currdev", EV_VOLATILE, bootpath,
864 ofw_setcurrdev, env_nounset);
865 env_setenv("loaddev", EV_VOLATILE, bootpath,
866 env_noset, env_nounset);
869 printf("%s, Revision %s\n", bootprog_name, bootprog_rev);
870 printf("(%s, %s)\n", bootprog_maker, bootprog_date);
871 printf("bootpath=\"%s\"\n", bootpath);
873 /* Give control to the machine independent loader code. */
878 COMMAND_SET(reboot, "reboot", "reboot the system", command_reboot);
881 command_reboot(int argc, char *argv[])
885 for (i = 0; devsw[i] != NULL; ++i)
886 if (devsw[i]->dv_cleanup != NULL)
887 (devsw[i]->dv_cleanup)();
889 printf("Rebooting...\n");
893 /* provide this for panic, as it's not in the startup code */
902 static const char *const page_sizes[] = {
903 " 8k", " 64k", "512k", " 4m"
907 pmap_print_tte_sun4u(tte_t tag, tte_t tte)
911 page_sizes[(tte >> TD_SIZE_SHIFT) & TD_SIZE_MASK],
912 tag & TD_G ? "G" : " ");
913 printf(tte & TD_W ? "W " : " ");
914 printf(tte & TD_P ? "\e[33mP\e[0m " : " ");
915 printf(tte & TD_E ? "E " : " ");
916 printf(tte & TD_CV ? "CV " : " ");
917 printf(tte & TD_CP ? "CP " : " ");
918 printf(tte & TD_L ? "\e[32mL\e[0m " : " ");
919 printf(tte & TD_IE ? "IE " : " ");
920 printf(tte & TD_NFO ? "NFO " : " ");
921 printf("pa=0x%lx va=0x%lx ctx=%ld\n",
922 TD_PA(tte), TLB_TAR_VA(tag), TLB_TAR_CTX(tag));
926 pmap_print_tlb_sun4u(void)
932 pstate = rdpr(pstate);
933 for (i = 0; i < itlb_slot_max; i++) {
934 wrpr(pstate, pstate & ~PSTATE_IE, 0);
935 tte = itlb_get_data_sun4u(i);
936 wrpr(pstate, pstate, 0);
939 tag = ldxa(TLB_DAR_SLOT(i), ASI_ITLB_TAG_READ_REG);
940 printf("iTLB-%2u: ", i);
941 pmap_print_tte_sun4u(tag, tte);
943 for (i = 0; i < dtlb_slot_max; i++) {
944 wrpr(pstate, pstate & ~PSTATE_IE, 0);
945 tte = dtlb_get_data_sun4u(i);
946 wrpr(pstate, pstate, 0);
949 tag = ldxa(TLB_DAR_SLOT(i), ASI_DTLB_TAG_READ_REG);
950 printf("dTLB-%2u: ", i);
951 pmap_print_tte_sun4u(tag, tte);