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_SPARC64V ||
455 cpu_impl >= CPU_IMPL_ULTRASPARCIII)
456 return (reg & TD_PA_CH_MASK);
457 return (reg & TD_PA_SF_MASK);
459 wrpr(pstate, pstate, 0);
464 itlb_va_to_pa_sun4u(vm_offset_t va)
469 pstate = rdpr(pstate);
470 wrpr(pstate, pstate & ~PSTATE_IE, 0);
471 for (i = 0; i < itlb_slot_max; i++) {
472 reg = ldxa(TLB_DAR_SLOT(i), ASI_ITLB_TAG_READ_REG);
473 if (TLB_TAR_VA(reg) != va)
475 reg = itlb_get_data_sun4u(i);
476 wrpr(pstate, pstate, 0);
478 if (cpu_impl == CPU_IMPL_SPARC64V ||
479 cpu_impl >= CPU_IMPL_ULTRASPARCIII)
480 return (reg & TD_PA_CH_MASK);
481 return (reg & TD_PA_SF_MASK);
483 wrpr(pstate, pstate, 0);
488 dtlb_enter_sun4u(u_int index, u_long data, vm_offset_t virt)
491 return (OF_call_method("SUNW,dtlb-load", mmu, 3, 0, index, data,
496 itlb_enter_sun4u(u_int index, u_long data, vm_offset_t virt)
499 if (cpu_impl == CPU_IMPL_ULTRASPARCIIIp && index == 0 &&
501 panic("%s: won't enter locked TLB entry at index 0 on USIII+",
503 return (OF_call_method("SUNW,itlb-load", mmu, 3, 0, index, data,
508 itlb_relocate_locked0_sun4u(void)
510 u_long data, pstate, tag;
513 if (cpu_impl != CPU_IMPL_ULTRASPARCIIIp)
516 pstate = rdpr(pstate);
517 wrpr(pstate, pstate & ~PSTATE_IE, 0);
519 data = itlb_get_data_sun4u(0);
520 if ((data & (TD_V | TD_L)) != (TD_V | TD_L)) {
521 wrpr(pstate, pstate, 0);
525 /* Flush the mapping of slot 0. */
526 tag = ldxa(TLB_DAR_SLOT(0), ASI_ITLB_TAG_READ_REG);
527 stxa(TLB_DEMAP_VA(TLB_TAR_VA(tag)) | TLB_DEMAP_PRIMARY |
528 TLB_DEMAP_PAGE, ASI_IMMU_DEMAP, 0);
529 flush(0); /* The USIII-family ignores the address. */
532 * Search a replacement slot != 0 and enter the data and tag
533 * that formerly were in slot 0.
535 for (i = 1; i < itlb_slot_max; i++) {
536 if ((itlb_get_data_sun4u(i) & TD_V) != 0)
539 stxa(AA_IMMU_TAR, ASI_IMMU, tag);
540 stxa(TLB_DAR_SLOT(i), ASI_ITLB_DATA_ACCESS_REG, data);
541 flush(0); /* The USIII-family ignores the address. */
544 wrpr(pstate, pstate, 0);
545 if (i == itlb_slot_max)
546 panic("%s: could not find a replacement slot", __func__);
550 mmu_mapin_sun4u(vm_offset_t va, vm_size_t len)
556 if (va + len > curkva)
559 pa = (vm_offset_t)-1;
560 len += va & PAGE_MASK_4M;
563 if (dtlb_va_to_pa_sun4u(va) == (vm_offset_t)-1 ||
564 itlb_va_to_pa_sun4u(va) == (vm_offset_t)-1) {
565 /* Allocate a physical page, claim the virtual area. */
566 if (pa == (vm_offset_t)-1) {
567 pa = alloc_phys(PAGE_SIZE_4M, PAGE_SIZE_4M);
568 if (pa == (vm_offset_t)-1)
569 panic("%s: out of memory", __func__);
570 mva = claim_virt(va, PAGE_SIZE_4M, 0);
572 panic("%s: can't claim virtual page "
573 "(wanted %#lx, got %#lx)",
576 * The mappings may have changed, be paranoid.
581 * Actually, we can only allocate two pages less at
582 * most (depending on the kernel TSB size).
584 if (dtlb_slot >= dtlb_slot_max)
585 panic("%s: out of dtlb_slots", __func__);
586 if (itlb_slot >= itlb_slot_max)
587 panic("%s: out of itlb_slots", __func__);
588 data = TD_V | TD_4M | TD_PA(pa) | TD_L | TD_CP |
590 dtlb_store[dtlb_slot].te_pa = pa;
591 dtlb_store[dtlb_slot].te_va = va;
592 index = dtlb_slot_max - dtlb_slot - 1;
593 if (dtlb_enter_sun4u(index, data, va) < 0)
594 panic("%s: can't enter dTLB slot %d data "
595 "%#lx va %#lx", __func__, index, data,
598 itlb_store[itlb_slot].te_pa = pa;
599 itlb_store[itlb_slot].te_va = va;
600 index = itlb_slot_max - itlb_slot - 1;
601 if (itlb_enter_sun4u(index, data, va) < 0)
602 panic("%s: can't enter iTLB slot %d data "
603 "%#lx va %#lxd", __func__, index, data,
606 pa = (vm_offset_t)-1;
608 len -= len > PAGE_SIZE_4M ? PAGE_SIZE_4M : len;
611 if (pa != (vm_offset_t)-1)
612 release_phys(pa, PAGE_SIZE_4M);
617 mmu_mapin_sun4v(vm_offset_t va, vm_size_t len)
621 if (va + len > curkva)
624 pa = (vm_offset_t)-1;
625 len += va & PAGE_MASK_4M;
628 if ((va >> 22) > SUN4V_TLB_SLOT_MAX)
629 panic("%s: trying to map more than 4GB", __func__);
630 if (tlb_store[va >> 22].te_pa == -1) {
631 /* Allocate a physical page, claim the virtual area */
632 if (pa == (vm_offset_t)-1) {
633 pa = alloc_phys(PAGE_SIZE_4M, PAGE_SIZE_4M);
634 if (pa == (vm_offset_t)-1)
635 panic("%s: out of memory", __func__);
636 mva = claim_virt(va, PAGE_SIZE_4M, 0);
638 panic("%s: can't claim virtual page "
639 "(wanted %#lx, got %#lx)",
643 tlb_store[va >> 22].te_pa = pa;
644 if (map_phys(-1, PAGE_SIZE_4M, va, pa) == -1)
645 printf("%s: can't map physical page\n",
647 pa = (vm_offset_t)-1;
649 len -= len > PAGE_SIZE_4M ? PAGE_SIZE_4M : len;
652 if (pa != (vm_offset_t)-1)
653 release_phys(pa, PAGE_SIZE_4M);
661 /* There is no need for continuous physical heap memory. */
662 heapva = (vm_offset_t)OF_claim((void *)HEAPVA, HEAPSZ, 32);
667 find_bsp_sun4u(phandle_t node, uint32_t bspid)
669 char type[sizeof("cpu")];
673 for (; node > 0; node = OF_peer(node)) {
674 child = OF_child(node);
676 child = find_bsp_sun4u(child, bspid);
680 if (OF_getprop(node, "device_type", type,
683 if (strcmp(type, "cpu") != 0)
685 if (OF_getprop(node, cpu_cpuid_prop_sun4u(), &cpuid,
696 cpu_cpuid_prop_sun4u(void)
700 case CPU_IMPL_SPARC64:
701 case CPU_IMPL_SPARC64V:
702 case CPU_IMPL_ULTRASPARCI:
703 case CPU_IMPL_ULTRASPARCII:
704 case CPU_IMPL_ULTRASPARCIIi:
705 case CPU_IMPL_ULTRASPARCIIe:
706 return ("upa-portid");
707 case CPU_IMPL_ULTRASPARCIII:
708 case CPU_IMPL_ULTRASPARCIIIp:
709 case CPU_IMPL_ULTRASPARCIIIi:
710 case CPU_IMPL_ULTRASPARCIIIip:
712 case CPU_IMPL_ULTRASPARCIV:
713 case CPU_IMPL_ULTRASPARCIVp:
721 cpu_get_mid_sun4u(void)
725 case CPU_IMPL_SPARC64:
726 case CPU_IMPL_SPARC64V:
727 case CPU_IMPL_ULTRASPARCI:
728 case CPU_IMPL_ULTRASPARCII:
729 case CPU_IMPL_ULTRASPARCIIi:
730 case CPU_IMPL_ULTRASPARCIIe:
731 return (UPA_CR_GET_MID(ldxa(0, ASI_UPA_CONFIG_REG)));
732 case CPU_IMPL_ULTRASPARCIII:
733 case CPU_IMPL_ULTRASPARCIIIp:
734 return (FIREPLANE_CR_GET_AID(ldxa(AA_FIREPLANE_CONFIG,
735 ASI_FIREPLANE_CONFIG_REG)));
736 case CPU_IMPL_ULTRASPARCIIIi:
737 case CPU_IMPL_ULTRASPARCIIIip:
738 return (JBUS_CR_GET_JID(ldxa(0, ASI_JBUS_CONFIG_REG)));
739 case CPU_IMPL_ULTRASPARCIV:
740 case CPU_IMPL_ULTRASPARCIVp:
741 return (INTR_ID_GET_ID(ldxa(AA_INTR_ID, ASI_INTR_ID)));
752 cpu_impl = VER_IMPL(rdpr(ver));
753 bsp = find_bsp_sun4u(OF_child(root), cpu_get_mid_sun4u());
755 panic("%s: no node for bootcpu?!?!", __func__);
757 if (OF_getprop(bsp, "#dtlb-entries", &dtlb_slot_max,
758 sizeof(dtlb_slot_max)) == -1 ||
759 OF_getprop(bsp, "#itlb-entries", &itlb_slot_max,
760 sizeof(itlb_slot_max)) == -1)
761 panic("%s: can't get TLB slot max.", __func__);
763 if (cpu_impl == CPU_IMPL_ULTRASPARCIIIp) {
765 printf("pre fixup:\n");
766 pmap_print_tlb_sun4u();
770 * Relocate the locked entry in it16 slot 0 (if existent)
771 * as part of working around Cheetah+ erratum 34.
773 itlb_relocate_locked0_sun4u();
776 printf("post fixup:\n");
777 pmap_print_tlb_sun4u();
781 dtlb_store = malloc(dtlb_slot_max * sizeof(*dtlb_store));
782 itlb_store = malloc(itlb_slot_max * sizeof(*itlb_store));
783 if (dtlb_store == NULL || itlb_store == NULL)
784 panic("%s: can't allocate TLB store", __func__);
791 tlb_store = malloc(SUN4V_TLB_SLOT_MAX * sizeof(*tlb_store));
792 memset(tlb_store, 0xFF, SUN4V_TLB_SLOT_MAX * sizeof(*tlb_store));
796 main(int (*openfirm)(void *))
803 * Tell the Open Firmware functions where they find the OFW gate.
807 archsw.arch_getdev = ofw_getdev;
808 archsw.arch_copyin = sparc64_copyin;
809 archsw.arch_copyout = ofw_copyout;
810 archsw.arch_readin = sparc64_readin;
811 archsw.arch_autoload = sparc64_autoload;
812 archsw.arch_maphint = sparc64_maphint;
814 if (init_heap() == (vm_offset_t)-1)
816 setheap((void *)heapva, (void *)(heapva + HEAPSZ));
819 * Probe for a console.
823 if ((root = OF_peer(0)) == -1)
824 panic("%s: can't get root phandle", __func__);
825 OF_getprop(root, "compatible", compatible, sizeof(compatible));
826 if (!strcmp(compatible, "sun4v")) {
827 printf("\nBooting with sun4v support.\n");
828 mmu_ops = &mmu_ops_sun4v;
831 printf("\nBooting with sun4u support.\n");
832 mmu_ops = &mmu_ops_sun4u;
838 * Initialize devices.
840 for (dp = devsw; *dp != 0; dp++) {
841 if ((*dp)->dv_init != 0)
846 * Set up the current device.
848 OF_getprop(chosen, "bootpath", bootpath, sizeof(bootpath));
851 * Sun compatible bootable CD-ROMs have a disk label placed
852 * before the cd9660 data, with the actual filesystem being
853 * in the first partition, while the other partitions contain
854 * pseudo disk labels with embedded boot blocks for different
855 * architectures, which may be followed by UFS filesystems.
856 * The firmware will set the boot path to the partition it
857 * boots from ('f' in the sun4u case), but we want the kernel
858 * to be loaded from the cd9660 fs ('a'), so the boot path
859 * needs to be altered.
861 if (bootpath[strlen(bootpath) - 2] == ':' &&
862 bootpath[strlen(bootpath) - 1] == 'f') {
863 bootpath[strlen(bootpath) - 1] = 'a';
864 printf("Boot path set to %s\n", bootpath);
867 env_setenv("currdev", EV_VOLATILE, bootpath,
868 ofw_setcurrdev, env_nounset);
869 env_setenv("loaddev", EV_VOLATILE, bootpath,
870 env_noset, env_nounset);
873 printf("%s, Revision %s\n", bootprog_name, bootprog_rev);
874 printf("(%s, %s)\n", bootprog_maker, bootprog_date);
875 printf("bootpath=\"%s\"\n", bootpath);
877 /* Give control to the machine independent loader code. */
882 COMMAND_SET(reboot, "reboot", "reboot the system", command_reboot);
885 command_reboot(int argc, char *argv[])
889 for (i = 0; devsw[i] != NULL; ++i)
890 if (devsw[i]->dv_cleanup != NULL)
891 (devsw[i]->dv_cleanup)();
893 printf("Rebooting...\n");
897 /* provide this for panic, as it's not in the startup code */
906 static const char *const page_sizes[] = {
907 " 8k", " 64k", "512k", " 4m"
911 pmap_print_tte_sun4u(tte_t tag, tte_t tte)
915 page_sizes[(tte >> TD_SIZE_SHIFT) & TD_SIZE_MASK],
916 tag & TD_G ? "G" : " ");
917 printf(tte & TD_W ? "W " : " ");
918 printf(tte & TD_P ? "\e[33mP\e[0m " : " ");
919 printf(tte & TD_E ? "E " : " ");
920 printf(tte & TD_CV ? "CV " : " ");
921 printf(tte & TD_CP ? "CP " : " ");
922 printf(tte & TD_L ? "\e[32mL\e[0m " : " ");
923 printf(tte & TD_IE ? "IE " : " ");
924 printf(tte & TD_NFO ? "NFO " : " ");
925 printf("pa=0x%lx va=0x%lx ctx=%ld\n",
926 TD_PA(tte), TLB_TAR_VA(tag), TLB_TAR_CTX(tag));
930 pmap_print_tlb_sun4u(void)
936 pstate = rdpr(pstate);
937 for (i = 0; i < itlb_slot_max; i++) {
938 wrpr(pstate, pstate & ~PSTATE_IE, 0);
939 tte = itlb_get_data_sun4u(i);
940 wrpr(pstate, pstate, 0);
943 tag = ldxa(TLB_DAR_SLOT(i), ASI_ITLB_TAG_READ_REG);
944 printf("iTLB-%2u: ", i);
945 pmap_print_tte_sun4u(tag, tte);
947 for (i = 0; i < dtlb_slot_max; i++) {
948 wrpr(pstate, pstate & ~PSTATE_IE, 0);
949 tte = dtlb_get_data_sun4u(i);
950 wrpr(pstate, pstate, 0);
953 tag = ldxa(TLB_DAR_SLOT(i), ASI_DTLB_TAG_READ_REG);
954 printf("dTLB-%2u: ", i);
955 pmap_print_tte_sun4u(tag, tte);