Index: ofw/common/main.c =================================================================== RCS file: /mnt/futile/usr/data/bsd/cvs/fbsd/src/sys/boot/ofw/common/main.c,v retrieving revision 1.8 diff -u -p -r1.8 main.c --- ofw/common/main.c 2 Nov 2006 00:26:45 -0000 1.8 +++ ofw/common/main.c 17 Nov 2006 12:26:10 -0000 @@ -41,7 +41,6 @@ extern char bootprog_rev[]; extern char bootprog_date[]; extern char bootprog_maker[]; -phandle_t chosen; u_int32_t acells; static char bootargs[128]; @@ -64,24 +63,22 @@ init_heap(void) uint64_t memsize(void) { - ihandle_t meminstance; - phandle_t memory; + phandle_t memoryp; struct ofw_reg reg[4]; struct ofw_reg2 reg2[8]; int i; u_int64_t sz, memsz; - OF_getprop(chosen, "memory", &meminstance, sizeof(meminstance)); - memory = OF_instance_to_package(meminstance); + memoryp = OF_instance_to_package(memory); if (acells == 1) { - sz = OF_getprop(memory, "reg", ®, sizeof(reg)); + sz = OF_getprop(memoryp, "reg", ®, sizeof(reg)); sz /= sizeof(struct ofw_reg); for (i = 0, memsz = 0; i < sz; i++) memsz += reg[i].size; } else if (acells == 2) { - sz = OF_getprop(memory, "reg", ®2, sizeof(reg2)); + sz = OF_getprop(memoryp, "reg", ®2, sizeof(reg2)); sz /= sizeof(struct ofw_reg2); for (i = 0, memsz = 0; i < sz; i++) @@ -107,7 +104,6 @@ main(int (*openfirm)(void *)) OF_init(openfirm); root = OF_finddevice("/"); - chosen = OF_finddevice("/chosen"); acells = 1; OF_getprop(root, "#address-cells", &acells, sizeof(acells)); Index: ofw/libofw/Makefile =================================================================== RCS file: /mnt/futile/usr/data/bsd/cvs/fbsd/src/sys/boot/ofw/libofw/Makefile,v retrieving revision 1.10 diff -u -p -r1.10 Makefile --- ofw/libofw/Makefile 9 Oct 2006 04:43:06 -0000 1.10 +++ ofw/libofw/Makefile 10 Oct 2006 13:12:22 -0000 @@ -5,7 +5,7 @@ INTERNALLIB= SRCS= devicename.c elf_freebsd.c ofw_console.c ofw_copy.c ofw_disk.c \ ofw_memory.c ofw_module.c ofw_net.c ofw_reboot.c \ - ofw_time.c openfirm.c openfirm_mmu.c + ofw_time.c openfirm.c CFLAGS+= -I${.CURDIR}/../../../../lib/libstand/ Index: ofw/libofw/ofw_console.c =================================================================== RCS file: /mnt/futile/usr/data/bsd/cvs/fbsd/src/sys/boot/ofw/libofw/ofw_console.c,v retrieving revision 1.11 diff -u -p -r1.11 ofw_console.c --- ofw/libofw/ofw_console.c 20 Oct 2005 10:39:09 -0000 1.11 +++ ofw/libofw/ofw_console.c 9 Oct 2006 22:51:13 -0000 @@ -34,8 +34,6 @@ __FBSDID("$FreeBSD: src/sys/boot/ofw/lib #include "bootstrap.h" #include "openfirm.h" -int console; - static void ofw_cons_probe(struct console *cp); static int ofw_cons_init(int); void ofw_cons_putchar(int); @@ -59,10 +57,7 @@ struct console ofwconsole = { static void ofw_cons_probe(struct console *cp) { - phandle_t chosen; - if ((chosen = OF_finddevice("/chosen")) == -1) - OF_exit(); OF_getprop(chosen, "stdin", &stdin, sizeof(stdin)); OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)); cp->c_flags |= C_PRESENTIN|C_PRESENTOUT; Index: ofw/libofw/ofw_net.c =================================================================== RCS file: /mnt/futile/usr/data/bsd/cvs/fbsd/src/sys/boot/ofw/libofw/ofw_net.c,v retrieving revision 1.10 diff -u -p -r1.10 ofw_net.c --- ofw/libofw/ofw_net.c 2 Mar 2005 20:12:27 -0000 1.10 +++ ofw/libofw/ofw_net.c 9 Oct 2006 22:51:49 -0000 @@ -179,12 +179,11 @@ extern char *strchr(); static void ofwn_init(struct iodesc *desc, void *machdep_hint) { - phandle_t chosen, netdev; + phandle_t netdev; char path[64]; char *ch; int pathlen; - chosen = OF_finddevice("/chosen"); pathlen = OF_getprop(chosen, "bootpath", path, 64); if ((ch = index(path, ':')) != NULL) *ch = '\0'; Index: ofw/libofw/openfirm.c =================================================================== RCS file: /mnt/futile/usr/data/bsd/cvs/fbsd/src/sys/boot/ofw/libofw/openfirm.c,v retrieving revision 1.13 diff -u -p -r1.13 openfirm.c --- ofw/libofw/openfirm.c 9 Oct 2006 04:43:07 -0000 1.13 +++ ofw/libofw/openfirm.c 10 Oct 2006 12:57:53 -0000 @@ -66,6 +66,7 @@ __FBSDID("$FreeBSD: src/sys/boot/ofw/lib int (*openfirmware)(void *); +phandle_t chosen; ihandle_t mmu; ihandle_t memory; @@ -74,31 +75,17 @@ ihandle_t memory; void OF_init(int (*openfirm)(void *)) { - phandle_t chosen; openfirmware = openfirm; - chosen = OF_finddevice("/chosen"); + if ((chosen = OF_finddevice("/chosen")) == -1) + OF_exit(); OF_getprop(chosen, "memory", &memory, sizeof(memory)); if (memory == 0) - panic("failed to get memory ihandle"); + OF_exit(); OF_getprop(chosen, "mmu", &mmu, sizeof(mmu)); if (mmu == 0) - panic("failed to get mmu ihandle"); -} - -phandle_t -OF_chosennode(void) -{ - static phandle_t chosen; - - if (chosen) - return (chosen); - - if ((chosen = OF_finddevice("/chosen")) == -1) - OF_exit(); - - return (chosen); + OF_exit(); } /* @@ -508,7 +495,8 @@ OF_call_method(char *method, ihandle_t i 0, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; - int *ip, n; + cell_t *cp; + int n; if (nargs > 6) return -1; @@ -517,16 +505,16 @@ OF_call_method(char *method, ihandle_t i args.method = (cell_t)method; args.instance = (u_int)instance; va_start(ap, nreturns); - for (ip = (int *)(args.args_n_results + (n = nargs)); --n >= 0;) - *--ip = va_arg(ap, int); + for (cp = (cell_t *)(args.args_n_results + (n = nargs)); --n >= 0;) + *--cp = va_arg(ap, cell_t); if (openfirmware(&args) == -1) return -1; if (args.args_n_results[nargs]) return (int)args.args_n_results[nargs]; - for (ip = (int *)(args.args_n_results + nargs + (n = args.nreturns)); + for (cp = (cell_t *)(args.args_n_results + nargs + (n = args.nreturns)); --n > 0;) - *va_arg(ap, int *) = *--ip; + *va_arg(ap, cell_t *) = *--cp; va_end(ap); return 0; } @@ -716,83 +704,6 @@ OF_claim(void *virt, u_int size, u_int a return (void *)args.baseaddr; } -/* Allocate an area of physical memory */ -vm_offset_t -OF_claim_virt(vm_offset_t virt, size_t size, int align) -{ - static struct { - cell_t name; - cell_t nargs; - cell_t nret; - cell_t method; - cell_t ihandle; - cell_t align; - cell_t size; - cell_t virt; - cell_t status; - cell_t ret; - } args = { - (cell_t)"call-method", - 5, - 2, - (cell_t)"claim", - 0, - 0, - 0, - 0, - 0, /* ret */ - 0, - }; - - args.ihandle = mmu; - args.align = align; - args.size = size; - args.virt = virt; - - if (openfirmware(&args) == -1) - return (vm_offset_t)-1; - - return (vm_offset_t)args.ret; -} - -/* Allocate an area of physical memory */ -void * -OF_alloc_phys(size_t size, int align) -{ - static struct { - cell_t name; - cell_t nargs; - cell_t nret; - cell_t method; - cell_t ihandle; - cell_t align; - cell_t size; - cell_t status; - cell_t phys_hi; - cell_t phys_low; - } args = { - (cell_t)"call-method", - 4, - 3, - (cell_t)"claim", - 0, - 0, - 0, - 0, /* ret */ - 0, - 0, - }; - - args.ihandle = memory; - args.size = size; - args.align = align; - - if (openfirmware(&args) == -1) - return (void *)-1; - - return (void *)(args.phys_hi << 32 | args.phys_low); -} - /* Release an area of memory. */ void OF_release(void *virt, u_int size) @@ -816,37 +727,6 @@ OF_release(void *virt, u_int size) openfirmware(&args); } -/* Release an area of physical memory. */ -void -OF_release_phys(vm_offset_t phys, u_int size) -{ - static struct { - cell_t name; - cell_t nargs; - cell_t nret; - cell_t method; - cell_t ihandle; - cell_t size; - cell_t phys_hi; - cell_t phys_lo; - } args = { - (cell_t)"call-method", - 5, - 0, - (cell_t)"release", - 0, - 0, - 0, - 0 - }; - - args.ihandle = memory; - args.phys_hi = (u_int32_t)(phys >> 32); - args.phys_lo = (u_int32_t)phys; - args.size = size; - openfirmware(&args); -} - /* * Control transfer functions. */ Index: ofw/libofw/openfirm_mmu.c =================================================================== RCS file: ofw/libofw/openfirm_mmu.c diff -N ofw/libofw/openfirm_mmu.c --- ofw/libofw/openfirm_mmu.c 9 Oct 2006 07:00:59 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,143 +0,0 @@ -/* - * Copyright (c) 2006 Kip Macy - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - - -#include -__FBSDID("$FreeBSD: src/sys/boot/ofw/libofw/openfirm_mmu.c,v 1.1 2006/10/09 07:00:59 kmacy Exp $"); - -#include -#include - -#include "openfirm.h" - -static ihandle_t -OF_mmu_ihandle(void) -{ - static ihandle_t immu; - - if (immu != (ihandle_t)0) - return (immu); - - if (OF_getproplen(OF_chosennode(), "mmu") != sizeof (ihandle_t)) - return (immu = (ihandle_t)-1); - - (void) OF_getprop(OF_chosennode(), "mmu", (caddr_t)(&immu), sizeof immu); - return (immu); -} - - -int -OF_translate_virt(vm_offset_t va, int *valid, vm_paddr_t *physaddr, int *mode) -{ - int rv; - static struct { - cell_t name; - cell_t nargs; - cell_t nreturns; - cell_t method; - cell_t immu; - cell_t va; - cell_t result; - cell_t valid; - cell_t mode; - cell_t phys_hi; - cell_t phys_lo; - } args = { - (cell_t)"call-method", - 3, - 5, - (cell_t)"translate", - }; - - args.immu = (cell_t) OF_mmu_ihandle(); - args.result = 0; - args.valid = 0; - args.mode = 0; - rv = openfirmware(&args); - if (rv == -1) - return (-1); - if (args.result != 0) - return (-1); - - *valid = args.valid; - *mode = args.mode; - *physaddr = (vm_paddr_t)(args.phys_hi << 32 | args.phys_lo); - - return (0); -} - -vm_paddr_t -OF_vtophys(vm_offset_t va) -{ - int mode, valid, error; - vm_paddr_t physaddr; - - error = OF_translate_virt(va, &valid, &physaddr, &mode); - - if (error == 0 && valid == -1) - return physaddr; - - return (0); -} - -int -OF_map_phys(int mode, size_t size, vm_offset_t va, uint64_t pa) -{ - int rv; - - static struct { - cell_t name; - cell_t nargs; - cell_t nreturns; - cell_t method; - cell_t immu; - cell_t mode; - cell_t size; - cell_t va; - cell_t pa_hi; - cell_t pa_lo; - cell_t result; - } args = { - (cell_t)"call-method", - 7, - 1, - (cell_t)"map", - }; - args.immu = (cell_t)OF_mmu_ihandle(); - args.mode = (cell_t)mode; - args.size = (cell_t)size; - args.va = (cell_t)va; - args.pa_hi = (cell_t)(pa >> 32); - args.pa_lo = (cell_t)((uint32_t)pa); - - rv = openfirmware(&args); - if (rv == -1) - return (-1); - if (args.result != 0) - return (-1); - - return (0); -} Index: sparc64/loader/main.c =================================================================== RCS file: /mnt/futile/usr/data/bsd/cvs/fbsd/src/sys/boot/sparc64/loader/main.c,v retrieving revision 1.29 diff -u -p -r1.29 main.c --- sparc64/loader/main.c 2 Nov 2006 00:26:45 -0000 1.29 +++ sparc64/loader/main.c 2 Nov 2006 00:28:22 -0000 @@ -40,23 +40,19 @@ __FBSDID("$FreeBSD: src/sys/boot/sparc64 #include "libofw.h" #include "dev_net.h" +extern char bootprog_name[], bootprog_rev[], bootprog_date[], bootprog_maker[]; + enum { HEAPVA = 0x800000, HEAPSZ = 0x1000000, LOADSZ = 0x1000000 /* for kernel and modules */ }; -struct memory_slice { - vm_offset_t pstart; - vm_offset_t size; -}; - struct mmu_ops { void (*tlb_init)(void); int (*mmu_mapin)(vm_offset_t va, vm_size_t len); } *mmu_ops; - typedef void kernel_entry_t(vm_offset_t mdp, u_long o1, u_long o2, u_long o3, void *openfirmware); @@ -75,41 +71,27 @@ static void tlb_init_sun4v(void); struct mmu_ops mmu_ops_sun4u = { tlb_init_sun4u, mmu_mapin_sun4u }; struct mmu_ops mmu_ops_sun4v = { tlb_init_sun4v, mmu_mapin_sun4v }; -extern char bootprog_name[], bootprog_rev[], bootprog_date[], bootprog_maker[]; - /* sun4u */ struct tlb_entry *dtlb_store; struct tlb_entry *itlb_store; int dtlb_slot; int itlb_slot; -int dtlb_slot_max; -int itlb_slot_max; +static int dtlb_slot_max; +static int itlb_slot_max; /* sun4v */ -struct tlb_entry *tlb_store; -/* +static struct tlb_entry *tlb_store; +/* * no direct TLB access on sun4v - * we somewhat arbitrarily declare enough + * we somewhat arbitrarily declare enough * slots to cover a 4GB AS with 4MB pages */ #define SUN4V_TLB_SLOT_MAX (1 << 10) +static vm_offset_t curkva = 0; +static vm_offset_t heapva; -extern char bootprog_name[], bootprog_rev[], bootprog_date[], bootprog_maker[]; - -struct tlb_entry *dtlb_store; -struct tlb_entry *itlb_store; - -int dtlb_slot; -int itlb_slot; -int dtlb_slot_max; -int itlb_slot_max; - -vm_offset_t curkva = 0; -vm_offset_t heapva; -phandle_t pmemh; /* OFW memory handle */ - -struct memory_slice memslices[18]; +static phandle_t root; /* * Machine dependent structures that the machine independent @@ -230,23 +212,26 @@ watch_virt_set(vm_offset_t va, int sz) static int sparc64_autoload(void) { + printf("nothing to autoload yet.\n"); - return 0; + return (0); } static ssize_t sparc64_readin(const int fd, vm_offset_t va, const size_t len) { + mmu_ops->mmu_mapin(va, len); - return read(fd, (void *)va, len); + return (read(fd, (void *)va, len)); } static ssize_t sparc64_copyin(const void *src, vm_offset_t dest, size_t len) { + mmu_ops->mmu_mapin(dest, len); memcpy((void *)dest, src, len); - return len; + return (len); } /* @@ -262,12 +247,12 @@ __elfN(exec)(struct preloaded_file *fp) int error; if ((fmp = file_findmetadata(fp, MODINFOMD_ELFHDR)) == 0) { - return EFTYPE; + return (EFTYPE); } e = (Elf_Ehdr *)&fmp->md_data; if ((error = md_load(fp->f_args, &mdp)) != 0) - return error; + return (error); printf("jumping to kernel entry at %#lx.\n", e->e_entry); #if 0 @@ -277,7 +262,7 @@ __elfN(exec)(struct preloaded_file *fp) entry = e->e_entry; - OF_release(heapva, HEAPSZ); + OF_release((void *)heapva, HEAPSZ); ((kernel_entry_t *)entry)(mdp, 0, 0, 0, openfirmware); @@ -287,6 +272,7 @@ __elfN(exec)(struct preloaded_file *fp) static int mmu_mapin_sun4u(vm_offset_t va, vm_size_t len) { + cell_t phys_hi, phys_low; vm_offset_t pa, mva; u_long data; @@ -301,17 +287,16 @@ mmu_mapin_sun4u(vm_offset_t va, vm_size_ itlb_va_to_pa(va) == (vm_offset_t)-1) { /* Allocate a physical page, claim the virtual area */ if (pa == (vm_offset_t)-1) { - pa = (vm_offset_t)OF_alloc_phys(PAGE_SIZE_4M, - PAGE_SIZE_4M); - if (pa == (vm_offset_t)-1) + if (OF_call_method("claim", memory, 2, 2, + PAGE_SIZE_4M, PAGE_SIZE_4M, &phys_low, + &phys_hi) == -1) panic("out of memory"); - mva = (vm_offset_t)OF_claim_virt(va, - PAGE_SIZE_4M, 0); - if (mva != va) { + pa = (vm_offset_t)phys_hi << 32 | phys_low; + if (OF_call_method("claim", mmu, 3, 1, va, + PAGE_SIZE_4M, 0, &mva) == -1) panic("can't claim virtual page " "(wanted %#lx, got %#lx)", va, mva); - } /* The mappings may have changed, be paranoid. */ continue; } @@ -320,9 +305,9 @@ mmu_mapin_sun4u(vm_offset_t va, vm_size_ * most (depending on the kernel TSB size). */ if (dtlb_slot >= dtlb_slot_max) - panic("mmu_mapin: out of dtlb_slots"); + panic("out of dtlb_slots"); if (itlb_slot >= itlb_slot_max) - panic("mmu_mapin: out of itlb_slots"); + panic("out of itlb_slots"); data = TD_V | TD_4M | TD_PA(pa) | TD_L | TD_CP | TD_CV | TD_P | TD_W; dtlb_store[dtlb_slot].te_pa = pa; @@ -339,18 +324,17 @@ mmu_mapin_sun4u(vm_offset_t va, vm_size_ va += PAGE_SIZE_4M; } if (pa != (vm_offset_t)-1) - OF_release_phys(pa, PAGE_SIZE_4M); + OF_call_method("relase", memory, 3, 0, (uint32_t)pa, + (uint32_t)(pa >> 32), PAGE_SIZE_4M); - return 0; + return (0); } static int mmu_mapin_sun4v(vm_offset_t va, vm_size_t len) { - + cell_t phys_hi, phys_low; vm_offset_t pa, mva; - u_long data; - int ret; if (va + len > curkva) curkva = va + len; @@ -364,86 +348,81 @@ mmu_mapin_sun4v(vm_offset_t va, vm_size_ if (tlb_store[va >> 22].te_pa == -1) { /* Allocate a physical page, claim the virtual area */ if (pa == (vm_offset_t)-1) { - pa = (vm_offset_t)OF_alloc_phys(PAGE_SIZE_4M, - PAGE_SIZE_4M); - if (pa == (vm_offset_t)-1) + if (OF_call_method("claim", memory, 2, 2, + PAGE_SIZE_4M, PAGE_SIZE_4M, &phys_low, + &phys_hi) == -1) panic("out of memory"); - mva = (vm_offset_t)OF_claim_virt(va, - PAGE_SIZE_4M, 0); - if (mva != va) { + pa = (vm_offset_t)phys_hi << 32 || phys_low; + if (OF_call_method("claim", mmu, 3, 1, va, + PAGE_SIZE_4M, 0, &mva) == -1) panic("can't claim virtual page " "(wanted %#lx, got %#lx)", va, mva); - } } tlb_store[va >> 22].te_pa = pa; - if ((ret = OF_map_phys(-1, PAGE_SIZE_4M, va, pa)) != 0) - printf("OF_map_phys failed: %d\n", ret); + if (OF_call_method("map", mmu, 5, 0, (uint32_t)pa, + (uint32_t)(pa >> 32), va, PAGE_SIZE_4M, -1) == -1) + printf("can't map physical page\n"); pa = (vm_offset_t)-1; } len -= len > PAGE_SIZE_4M ? PAGE_SIZE_4M : len; va += PAGE_SIZE_4M; } if (pa != (vm_offset_t)-1) - OF_release_phys(pa, PAGE_SIZE_4M); - return 0; + OF_call_method("relase", memory, 3, 0, (uint32_t)pa, + (uint32_t)(pa >> 32), PAGE_SIZE_4M); + return (0); } static vm_offset_t init_heap(void) { - if ((pmemh = OF_finddevice("/memory")) == (phandle_t)-1) - OF_exit(); - if (OF_getprop(pmemh, "available", memslices, sizeof(memslices)) <= 0) - OF_exit(); /* There is no need for continuous physical heap memory. */ heapva = (vm_offset_t)OF_claim((void *)HEAPVA, HEAPSZ, 32); - return heapva; + return (heapva); } static void tlb_init_sun4u(void) { phandle_t child; - phandle_t root; char buf[128]; u_int bootcpu; u_int cpu; bootcpu = UPA_CR_GET_MID(ldxa(0, ASI_UPA_CONFIG_REG)); - if ((root = OF_peer(0)) == -1) - panic("main: OF_peer"); for (child = OF_child(root); child != 0; child = OF_peer(child)) { if (child == -1) - panic("main: OF_child"); + panic("can't get child phandle"); if (OF_getprop(child, "device_type", buf, sizeof(buf)) > 0 && strcmp(buf, "cpu") == 0) { if (OF_getprop(child, "upa-portid", &cpu, sizeof(cpu)) == -1 && OF_getprop(child, "portid", &cpu, sizeof(cpu)) == -1) - panic("main: OF_getprop"); + panic("can't get portid"); if (cpu == bootcpu) break; } } if (cpu != bootcpu) - panic("init_tlb: no node for bootcpu?!?!"); + panic("no node for bootcpu?!?!"); if (OF_getprop(child, "#dtlb-entries", &dtlb_slot_max, sizeof(dtlb_slot_max)) == -1 || OF_getprop(child, "#itlb-entries", &itlb_slot_max, sizeof(itlb_slot_max)) == -1) - panic("init_tlb: OF_getprop"); + panic("can't get TLB slot max."); dtlb_store = malloc(dtlb_slot_max * sizeof(*dtlb_store)); itlb_store = malloc(itlb_slot_max * sizeof(*itlb_store)); if (dtlb_store == NULL || itlb_store == NULL) - panic("init_tlb: malloc"); + panic("can't allocate TLB store"); } static void tlb_init_sun4v(void) { + tlb_store = malloc(SUN4V_TLB_SLOT_MAX * sizeof(*tlb_store)); memset(tlb_store, 0xFF, SUN4V_TLB_SLOT_MAX * sizeof(*tlb_store)); } @@ -454,8 +433,6 @@ main(int (*openfirm)(void *)) char bootpath[64]; char compatible[32]; struct devsw **dp; - phandle_t rooth; - phandle_t chosenh; /* * Tell the Open Firmware functions where they find the ofw gate. @@ -470,13 +447,15 @@ main(int (*openfirm)(void *)) init_heap(); setheap((void *)heapva, (void *)(heapva + HEAPSZ)); + /* * Probe for a console. */ cons_probe(); - rooth = OF_peer(0); - OF_getprop(rooth, "compatible", compatible, sizeof(compatible)); + if ((root = OF_peer(0)) == -1) + panic("can't get root phandle"); + OF_getprop(root, "compatible", compatible, sizeof(compatible)); if (!strcmp(compatible, "sun4v")) { printf("\nBooting with sun4v support.\n"); mmu_ops = &mmu_ops_sun4v; @@ -498,8 +477,7 @@ main(int (*openfirm)(void *)) /* * Set up the current device. */ - chosenh = OF_finddevice("/chosen"); - OF_getprop(chosenh, "bootpath", bootpath, sizeof(bootpath)); + OF_getprop(chosen, "bootpath", bootpath, sizeof(bootpath)); /* * Sun compatible bootable CD-ROMs have a disk label placed @@ -530,7 +508,7 @@ main(int (*openfirm)(void *)) /* Give control to the machine independent loader code. */ interact(); - return 1; + return (1); } COMMAND_SET(reboot, "reboot", "reboot the system", command_reboot); @@ -552,6 +530,7 @@ command_reboot(int argc, char *argv[]) void exit(int code) { + OF_exit(); } @@ -565,6 +544,7 @@ const char *page_sizes[] = { static void pmap_print_tte(tte_t tag, tte_t tte) { + printf("%s %s ", page_sizes[(tte & TD_SIZE_MASK) >> TD_SIZE_SHIFT], tag & TD_G ? "G" : " "); Index: sparc64/loader/metadata.c =================================================================== RCS file: /mnt/futile/usr/data/bsd/cvs/fbsd/src/sys/boot/sparc64/loader/metadata.c,v retrieving revision 1.15 diff -u -p -r1.15 metadata.c --- sparc64/loader/metadata.c 22 Sep 2005 15:06:58 -0000 1.15 +++ sparc64/loader/metadata.c 10 Oct 2006 00:49:10 -0000 @@ -155,13 +155,11 @@ md_bootserial(void) return(-1); output = OF_finddevice(buf); if (input == -1 || output == -1 || OF_getproplen(input, "keyboard") >= 0) { - if ((node = OF_finddevice("/chosen")) == -1) - return(-1); - if (OF_getprop(node, "stdin", &inst, sizeof(inst)) == -1) + if (OF_getprop(chosen, "stdin", &inst, sizeof(inst)) == -1) return(-1); if ((input = OF_instance_to_package(inst)) == -1) return(-1); - if (OF_getprop(node, "stdout", &inst, sizeof(inst)) == -1) + if (OF_getprop(chosen, "stdout", &inst, sizeof(inst)) == -1) return(-1); if ((output = OF_instance_to_package(inst)) == -1) return(-1);