machdep.c revision 182198
1176771Sraj/*- 2176771Sraj * Copyright (C) 2006 Semihalf, Marian Balakowicz <m8@semihalf.com> 3176771Sraj * All rights reserved. 4176771Sraj * 5176771Sraj * Redistribution and use in source and binary forms, with or without 6176771Sraj * modification, are permitted provided that the following conditions 7176771Sraj * are met: 8176771Sraj * 1. Redistributions of source code must retain the above copyright 9176771Sraj * notice, this list of conditions and the following disclaimer. 10176771Sraj * 2. Redistributions in binary form must reproduce the above copyright 11176771Sraj * notice, this list of conditions and the following disclaimer in the 12176771Sraj * documentation and/or other materials provided with the distribution. 13176771Sraj * 3. The name of the author may not be used to endorse or promote products 14176771Sraj * derived from this software without specific prior written permission. 15176771Sraj * 16176771Sraj * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17176771Sraj * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18176771Sraj * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN 19176771Sraj * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20176771Sraj * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 21176771Sraj * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22176771Sraj * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 23176771Sraj * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 24176771Sraj * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25176771Sraj * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26176771Sraj */ 27176771Sraj/*- 28176771Sraj * Copyright (C) 2001 Benno Rice 29176771Sraj * All rights reserved. 30176771Sraj * 31176771Sraj * Redistribution and use in source and binary forms, with or without 32176771Sraj * modification, are permitted provided that the following conditions 33176771Sraj * are met: 34176771Sraj * 1. Redistributions of source code must retain the above copyright 35176771Sraj * notice, this list of conditions and the following disclaimer. 36176771Sraj * 2. Redistributions in binary form must reproduce the above copyright 37176771Sraj * notice, this list of conditions and the following disclaimer in the 38176771Sraj * documentation and/or other materials provided with the distribution. 39176771Sraj * 40176771Sraj * THIS SOFTWARE IS PROVIDED BY Benno Rice ``AS IS'' AND ANY EXPRESS OR 41176771Sraj * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 42176771Sraj * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 43176771Sraj * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 44176771Sraj * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 45176771Sraj * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 46176771Sraj * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 47176771Sraj * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 48176771Sraj * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 49176771Sraj * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 50176771Sraj * $NetBSD: machdep.c,v 1.74.2.1 2000/11/01 16:13:48 tv Exp $ 51176771Sraj */ 52176771Sraj/*- 53176771Sraj * Copyright (C) 1995, 1996 Wolfgang Solfrank. 54176771Sraj * Copyright (C) 1995, 1996 TooLs GmbH. 55176771Sraj * All rights reserved. 56176771Sraj * 57176771Sraj * Redistribution and use in source and binary forms, with or without 58176771Sraj * modification, are permitted provided that the following conditions 59176771Sraj * are met: 60176771Sraj * 1. Redistributions of source code must retain the above copyright 61176771Sraj * notice, this list of conditions and the following disclaimer. 62176771Sraj * 2. Redistributions in binary form must reproduce the above copyright 63176771Sraj * notice, this list of conditions and the following disclaimer in the 64176771Sraj * documentation and/or other materials provided with the distribution. 65176771Sraj * 3. All advertising materials mentioning features or use of this software 66176771Sraj * must display the following acknowledgement: 67176771Sraj * This product includes software developed by TooLs GmbH. 68176771Sraj * 4. The name of TooLs GmbH may not be used to endorse or promote products 69176771Sraj * derived from this software without specific prior written permission. 70176771Sraj * 71176771Sraj * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR 72176771Sraj * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 73176771Sraj * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 74176771Sraj * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 75176771Sraj * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 76176771Sraj * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 77176771Sraj * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 78176771Sraj * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 79176771Sraj * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 80176771Sraj * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 81176771Sraj */ 82176771Sraj 83176771Sraj#include <sys/cdefs.h> 84176771Sraj__FBSDID("$FreeBSD: head/sys/powerpc/booke/machdep.c 182198 2008-08-26 17:07:37Z raj $"); 85176771Sraj 86176771Sraj#include "opt_compat.h" 87176771Sraj#include "opt_kstack_pages.h" 88176771Sraj 89176771Sraj#include <sys/cdefs.h> 90176771Sraj#include <sys/types.h> 91176771Sraj 92176771Sraj#include <sys/param.h> 93176771Sraj#include <sys/proc.h> 94176771Sraj#include <sys/systm.h> 95176771Sraj#include <sys/time.h> 96176771Sraj#include <sys/bio.h> 97176771Sraj#include <sys/buf.h> 98176771Sraj#include <sys/bus.h> 99176771Sraj#include <sys/cons.h> 100176771Sraj#include <sys/cpu.h> 101176771Sraj#include <sys/kdb.h> 102176771Sraj#include <sys/kernel.h> 103176771Sraj#include <sys/lock.h> 104176771Sraj#include <sys/mutex.h> 105176771Sraj#include <sys/sysctl.h> 106176771Sraj#include <sys/exec.h> 107176771Sraj#include <sys/ktr.h> 108176771Sraj#include <sys/sysproto.h> 109176771Sraj#include <sys/signalvar.h> 110176771Sraj#include <sys/sysent.h> 111176771Sraj#include <sys/imgact.h> 112176771Sraj#include <sys/msgbuf.h> 113176771Sraj#include <sys/ptrace.h> 114176771Sraj 115176771Sraj#include <vm/vm.h> 116176771Sraj#include <vm/pmap.h> 117176771Sraj#include <vm/vm_page.h> 118176771Sraj#include <vm/vm_object.h> 119176771Sraj#include <vm/vm_pager.h> 120176771Sraj 121176771Sraj#include <machine/cpu.h> 122176771Sraj#include <machine/kdb.h> 123176771Sraj#include <machine/reg.h> 124176771Sraj#include <machine/vmparam.h> 125176771Sraj#include <machine/spr.h> 126176771Sraj#include <machine/hid.h> 127176771Sraj#include <machine/psl.h> 128176771Sraj#include <machine/trap.h> 129176771Sraj#include <machine/md_var.h> 130176771Sraj#include <machine/mmuvar.h> 131176771Sraj#include <machine/pmap.h> 132176771Sraj#include <machine/sigframe.h> 133176771Sraj#include <machine/metadata.h> 134176771Sraj#include <machine/bootinfo.h> 135176771Sraj#include <machine/powerpc.h> 136176771Sraj 137176771Sraj#include <sys/linker.h> 138176771Sraj#include <sys/reboot.h> 139176771Sraj 140176771Sraj#ifdef DEBUG 141176771Sraj#define debugf(fmt, args...) printf(fmt, ##args) 142176771Sraj#else 143176771Sraj#define debugf(fmt, args...) 144176771Sraj#endif 145176771Sraj 146176771Srajextern unsigned char kernel_text[]; 147176771Srajextern unsigned char _etext[]; 148176771Srajextern unsigned char _edata[]; 149176771Srajextern unsigned char __bss_start[]; 150176771Srajextern unsigned char __sbss_start[]; 151176771Srajextern unsigned char __sbss_end[]; 152176771Srajextern unsigned char _end[]; 153176771Sraj 154176771Srajextern struct mem_region availmem_regions[]; 155176771Srajextern int availmem_regions_sz; 156176771Sraj 157176928Smarcelextern void dcache_enable(void); 158176928Smarcelextern void dcache_inval(void); 159176928Smarcelextern void icache_enable(void); 160176928Smarcelextern void icache_inval(void); 161176928Smarcel 162176771Srajstruct kva_md_info kmi; 163176771Srajstruct pcpu __pcpu[MAXCPU]; 164176771Srajstruct trapframe frame0; 165176771Srajint cold = 1; 166176771Srajlong realmem = 0; 167176771Srajlong Maxmem = 0; 168176771Sraj 169176771Srajstruct bootinfo *bootinfo; 170176771Sraj 171176771Srajchar machine[] = "powerpc"; 172176771SrajSYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD, machine, 0, ""); 173176771Sraj 174176771Srajstatic int cacheline_size = CACHELINESIZE; 175176771SrajSYSCTL_INT(_machdep, CPU_CACHELINE, cacheline_size, 176176771Sraj CTLFLAG_RD, &cacheline_size, 0, ""); 177176771Sraj 178176771Srajstatic void cpu_e500_startup(void *); 179177253SrwatsonSYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_e500_startup, NULL); 180176771Sraj 181176771Srajvoid print_kernel_section_addr(void); 182176771Srajvoid dump_bootinfo(void); 183176771Srajvoid dump_kenv(void); 184182198Sraju_int e500_init(u_int32_t, u_int32_t, void *); 185176771Sraj 186176771Srajstatic void 187176771Srajcpu_e500_startup(void *dummy) 188176771Sraj{ 189182198Sraj int indx, size; 190176771Sraj 191176771Sraj /* Initialise the decrementer-based clock. */ 192176771Sraj decr_init(); 193176771Sraj 194176771Sraj /* Good {morning,afternoon,evening,night}. */ 195176771Sraj cpu_setup(PCPU_GET(cpuid)); 196176771Sraj 197176771Sraj printf("real memory = %ld (%ld MB)\n", ptoa(physmem), 198182198Sraj ptoa(physmem) / 1048576); 199176771Sraj realmem = physmem; 200176771Sraj 201176771Sraj /* Display any holes after the first chunk of extended memory. */ 202176771Sraj if (bootverbose) { 203176771Sraj printf("Physical memory chunk(s):\n"); 204176771Sraj for (indx = 0; phys_avail[indx + 1] != 0; indx += 2) { 205182198Sraj size = phys_avail[indx + 1] - phys_avail[indx]; 206176771Sraj printf("0x%08x - 0x%08x, %d bytes (%d pages)\n", 207182198Sraj phys_avail[indx], phys_avail[indx + 1] - 1, size, 208182198Sraj size / PAGE_SIZE); 209176771Sraj } 210176771Sraj } 211176771Sraj 212176771Sraj vm_ksubmap_init(&kmi); 213176771Sraj 214176771Sraj printf("avail memory = %ld (%ld MB)\n", ptoa(cnt.v_free_count), 215176771Sraj ptoa(cnt.v_free_count) / 1048576); 216176771Sraj 217176771Sraj /* Set up buffers, so they can be used to read disk labels. */ 218176771Sraj bufinit(); 219176771Sraj vm_pager_bufferinit(); 220176771Sraj} 221176771Sraj 222176771Srajstatic char * 223176771Srajkenv_next(char *cp) 224176771Sraj{ 225176771Sraj 226176771Sraj if (cp != NULL) { 227176771Sraj while (*cp != 0) 228176771Sraj cp++; 229176771Sraj cp++; 230176771Sraj if (*cp == 0) 231176771Sraj cp = NULL; 232176771Sraj } 233176771Sraj return (cp); 234176771Sraj} 235176771Sraj 236176771Srajvoid 237176771Srajdump_kenv(void) 238176771Sraj{ 239176771Sraj int len; 240176771Sraj char *cp; 241176771Sraj 242176771Sraj debugf("loader passed (static) kenv:\n"); 243176771Sraj if (kern_envp == NULL) { 244176771Sraj debugf(" no env, null ptr\n"); 245176771Sraj return; 246176771Sraj } 247176771Sraj debugf(" kern_envp = 0x%08x\n", (u_int32_t)kern_envp); 248176771Sraj 249176771Sraj len = 0; 250176771Sraj for (cp = kern_envp; cp != NULL; cp = kenv_next(cp)) 251176771Sraj debugf(" %x %s\n", (u_int32_t)cp, cp); 252176771Sraj} 253176771Sraj 254176771Srajvoid 255176771Srajdump_bootinfo(void) 256176771Sraj{ 257176771Sraj struct bi_mem_region *mr; 258176771Sraj struct bi_eth_addr *eth; 259176771Sraj int i, j; 260176771Sraj 261176771Sraj debugf("bootinfo:\n"); 262176771Sraj if (bootinfo == NULL) { 263176771Sraj debugf(" no bootinfo, null ptr\n"); 264176771Sraj return; 265176771Sraj } 266176771Sraj 267176771Sraj debugf(" version = 0x%08x\n", bootinfo->bi_version); 268176771Sraj debugf(" ccsrbar = 0x%08x\n", bootinfo->bi_bar_base); 269176771Sraj debugf(" cpu_clk = 0x%08x\n", bootinfo->bi_cpu_clk); 270176771Sraj debugf(" bus_clk = 0x%08x\n", bootinfo->bi_bus_clk); 271176771Sraj 272176771Sraj debugf(" mem regions:\n"); 273176771Sraj mr = (struct bi_mem_region *)bootinfo->bi_data; 274176771Sraj for (i = 0; i < bootinfo->bi_mem_reg_no; i++, mr++) 275176771Sraj debugf(" #%d, base = 0x%08x, size = 0x%08x\n", i, 276176771Sraj mr->mem_base, mr->mem_size); 277176771Sraj 278176771Sraj debugf(" eth addresses:\n"); 279176771Sraj eth = (struct bi_eth_addr *)mr; 280176771Sraj for (i = 0; i < bootinfo->bi_eth_addr_no; i++, eth++) { 281176771Sraj debugf(" #%d, addr = ", i); 282176771Sraj for (j = 0; j < 6; j++) 283176771Sraj debugf("%02x ", eth->mac_addr[j]); 284176771Sraj debugf("\n"); 285176771Sraj } 286176771Sraj} 287176771Sraj 288176771Srajvoid 289176771Srajprint_kernel_section_addr(void) 290176771Sraj{ 291176771Sraj 292176771Sraj debugf("kernel image addresses:\n"); 293176771Sraj debugf(" kernel_text = 0x%08x\n", (u_int32_t)kernel_text); 294176771Sraj debugf(" _etext (sdata) = 0x%08x\n", (u_int32_t)_etext); 295176771Sraj debugf(" _edata = 0x%08x\n", (u_int32_t)_edata); 296176771Sraj debugf(" __sbss_start = 0x%08x\n", (u_int32_t)__sbss_start); 297176771Sraj debugf(" __sbss_end = 0x%08x\n", (u_int32_t)__sbss_end); 298176771Sraj debugf(" __sbss_start = 0x%08x\n", (u_int32_t)__bss_start); 299176771Sraj debugf(" _end = 0x%08x\n", (u_int32_t)_end); 300176771Sraj} 301176771Sraj 302177110Srajstruct bi_mem_region * 303177110Srajbootinfo_mr(void) 304177110Sraj{ 305177110Sraj 306177110Sraj return((struct bi_mem_region *)bootinfo->bi_data); 307177110Sraj} 308177110Sraj 309177110Srajstruct bi_eth_addr * 310177110Srajbootinfo_eth(void) 311177110Sraj{ 312177110Sraj struct bi_mem_region *mr; 313177110Sraj struct bi_eth_addr *eth; 314177110Sraj int i; 315177110Sraj 316177110Sraj /* Advance to the eth section */ 317177110Sraj mr = bootinfo_mr(); 318177110Sraj for (i = 0; i < bootinfo->bi_mem_reg_no; i++, mr++) 319177110Sraj ; 320177110Sraj 321177110Sraj eth = (struct bi_eth_addr *)mr; 322177110Sraj return (eth); 323177110Sraj} 324177110Sraj 325182198Sraju_int 326176771Sraje500_init(u_int32_t startkernel, u_int32_t endkernel, void *mdp) 327176771Sraj{ 328176771Sraj struct pcpu *pc; 329176771Sraj void *kmdp; 330176771Sraj vm_offset_t end; 331176771Sraj struct bi_mem_region *mr; 332176928Smarcel uint32_t csr; 333176771Sraj int i; 334176771Sraj 335176771Sraj kmdp = NULL; 336176771Sraj 337176771Sraj end = endkernel; 338176771Sraj 339176771Sraj /* 340176771Sraj * Parse metadata and fetch parameters. This must be done as the first 341176771Sraj * step as we need bootinfo data to at least init the console 342176771Sraj */ 343176771Sraj if (mdp != NULL) { 344176771Sraj preload_metadata = mdp; 345176771Sraj kmdp = preload_search_by_type("elf kernel"); 346176771Sraj if (kmdp != NULL) { 347176771Sraj bootinfo = (struct bootinfo *)preload_search_info(kmdp, 348176771Sraj MODINFO_METADATA|MODINFOMD_BOOTINFO); 349176771Sraj 350176771Sraj boothowto = MD_FETCH(kmdp, MODINFOMD_HOWTO, int); 351176771Sraj kern_envp = MD_FETCH(kmdp, MODINFOMD_ENVP, char *); 352176771Sraj end = MD_FETCH(kmdp, MODINFOMD_KERNEND, vm_offset_t); 353176771Sraj } 354176771Sraj } else { 355176771Sraj /* 356176771Sraj * We should scream but how? - without CCSR bar (in bootinfo) 357176771Sraj * cannot even output anything... 358176771Sraj */ 359176771Sraj 360176771Sraj /* 361176771Sraj * FIXME add return value and handle in the locore so we can 362176771Sraj * return to the loader maybe? (this seems not very easy to 363176771Sraj * restore everything as the TLB have all been reprogrammed 364176771Sraj * in the locore etc...) 365176771Sraj */ 366176771Sraj while(1); 367176771Sraj } 368176771Sraj 369176771Sraj /* Initialize memory regions table */ 370177110Sraj mr = bootinfo_mr(); 371176771Sraj for (i = 0; i < bootinfo->bi_mem_reg_no; i++, mr++) { 372176771Sraj if (i == MEM_REGIONS) 373176771Sraj break; 374176771Sraj availmem_regions[i].mr_start = mr->mem_base; 375176771Sraj availmem_regions[i].mr_size = mr->mem_size; 376176771Sraj } 377176771Sraj availmem_regions_sz = i; 378176771Sraj 379176771Sraj /* Initialize TLB1 handling */ 380176771Sraj tlb1_init(bootinfo->bi_bar_base); 381176771Sraj 382176771Sraj /* 383176771Sraj * Time Base and Decrementer are updated every 8 CCB bus clocks. 384176771Sraj * HID0[SEL_TBCLK] = 0 385176771Sraj */ 386176771Sraj decr_config(bootinfo->bi_bus_clk/8); 387176771Sraj 388176771Sraj /* Init params/tunables that can be overridden by the loader. */ 389176771Sraj init_param1(); 390176771Sraj 391176771Sraj /* Start initializing proc0 and thread0. */ 392176771Sraj proc_linkup(&proc0, &thread0); 393176771Sraj thread0.td_frame = &frame0; 394176771Sraj 395176771Sraj /* Set up per-cpu data and store the pointer in SPR general 0. */ 396176771Sraj pc = &__pcpu[0]; 397176771Sraj pcpu_init(pc, 0, sizeof(struct pcpu)); 398176771Sraj pc->pc_curthread = &thread0; 399176771Sraj pc->pc_cpuid = 0; 400176771Sraj __asm __volatile("mtsprg 0, %0" :: "r"(pc)); 401176771Sraj 402176771Sraj /* Initialize system mutexes. */ 403176771Sraj mutex_init(); 404176771Sraj 405176771Sraj /* Initialize the console before printing anything. */ 406176771Sraj cninit(); 407176771Sraj 408176771Sraj /* Print out some debug info... */ 409176771Sraj debugf("e500_init: console initialized\n"); 410176771Sraj debugf(" arg1 startkernel = 0x%08x\n", startkernel); 411176771Sraj debugf(" arg2 endkernel = 0x%08x\n", endkernel); 412176771Sraj debugf(" arg3 midp = 0x%08x\n", (u_int32_t)mdp); 413176771Sraj debugf(" end = 0x%08x\n", (u_int32_t)end); 414176771Sraj debugf(" boothowto = 0x%08x\n", boothowto); 415176771Sraj debugf(" kernel ccsrbar = 0x%08x\n", CCSRBAR_VA); 416176771Sraj debugf(" MSR = 0x%08x\n", mfmsr()); 417176771Sraj dump_bootinfo(); 418176771Sraj print_kernel_section_addr(); 419176771Sraj dump_kenv(); 420176771Sraj //tlb1_print_entries(); 421176771Sraj //tlb1_print_tlbentries(); 422176771Sraj 423176771Sraj kdb_init(); 424176771Sraj 425176771Sraj#ifdef KDB 426176771Sraj if (boothowto & RB_KDB) 427176771Sraj kdb_enter(KDB_WHY_BOOTFLAGS, "Boot flags requested debugger"); 428176771Sraj#endif 429176771Sraj kobj_machdep_init(); 430176771Sraj 431176771Sraj /* Initialise virtual memory. */ 432176771Sraj pmap_mmu_install(MMU_TYPE_BOOKE, 0); 433176771Sraj pmap_bootstrap(startkernel, end); 434176771Sraj debugf("MSR = 0x%08x\n", mfmsr()); 435176771Sraj //tlb1_print_entries(); 436176771Sraj //tlb1_print_tlbentries(); 437176771Sraj 438176771Sraj /* Initialize params/tunables that are derived from memsize. */ 439176771Sraj init_param2(physmem); 440176771Sraj 441176771Sraj /* Finish setting up thread0. */ 442176771Sraj thread0.td_pcb = (struct pcb *) 443182198Sraj ((thread0.td_kstack + thread0.td_kstack_pages * PAGE_SIZE - 444182198Sraj sizeof(struct pcb)) & ~15); 445176771Sraj bzero((void *)thread0.td_pcb, sizeof(struct pcb)); 446176771Sraj pc->pc_curpcb = thread0.td_pcb; 447176771Sraj 448176771Sraj /* Initialise the message buffer. */ 449176771Sraj msgbufinit(msgbufp, MSGBUF_SIZE); 450176771Sraj 451176771Sraj /* Enable Machine Check interrupt. */ 452176771Sraj mtmsr(mfmsr() | PSL_ME); 453176771Sraj isync(); 454176771Sraj 455176928Smarcel /* Enable D-cache if applicable */ 456176928Smarcel csr = mfspr(SPR_L1CSR0); 457176928Smarcel if ((csr & L1CSR0_DCE) == 0) { 458176928Smarcel dcache_inval(); 459176928Smarcel dcache_enable(); 460176928Smarcel } 461176928Smarcel csr = mfspr(SPR_L1CSR0); 462176928Smarcel if ((boothowto & RB_VERBOSE) != 0 || (csr & L1CSR0_DCE) == 0) 463176928Smarcel printf("L1 D-cache %sabled\n", 464176928Smarcel (csr & L1CSR0_DCE) ? "en" : "dis"); 465176928Smarcel 466176928Smarcel /* Enable L1 I-cache if applicable. */ 467176928Smarcel csr = mfspr(SPR_L1CSR1); 468176928Smarcel if ((csr & L1CSR1_ICE) == 0) { 469176928Smarcel icache_inval(); 470176928Smarcel icache_enable(); 471176928Smarcel } 472176928Smarcel csr = mfspr(SPR_L1CSR1); 473176928Smarcel if ((boothowto & RB_VERBOSE) != 0 || (csr & L1CSR1_ICE) == 0) 474176928Smarcel printf("L1 I-cache %sabled\n", 475176928Smarcel (csr & L1CSR1_ICE) ? "en" : "dis"); 476176928Smarcel 477182198Sraj debugf("e500_init: SP = 0x%08x\n", ((uintptr_t)thread0.td_pcb - 16) & ~15); 478176771Sraj debugf("e500_init: e\n"); 479182198Sraj 480182198Sraj return (((uintptr_t)thread0.td_pcb - 16) & ~15); 481176771Sraj} 482176771Sraj 483176771Sraj/* Initialise a struct pcpu. */ 484176771Srajvoid 485176771Srajcpu_pcpu_init(struct pcpu *pcpu, int cpuid, size_t sz) 486176771Sraj{ 487176771Sraj 488176771Sraj} 489176771Sraj 490176771Sraj/* Set set up registers on exec. */ 491176771Srajvoid 492176771Srajexec_setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings) 493176771Sraj{ 494176771Sraj struct trapframe *tf; 495176771Sraj struct ps_strings arginfo; 496176771Sraj 497176771Sraj tf = trapframe(td); 498176771Sraj bzero(tf, sizeof *tf); 499176771Sraj tf->fixreg[1] = -roundup(-stack + 8, 16); 500176771Sraj 501176771Sraj /* 502176771Sraj * XXX Machine-independent code has already copied arguments and 503176771Sraj * XXX environment to userland. Get them back here. 504176771Sraj */ 505176771Sraj (void)copyin((char *)PS_STRINGS, &arginfo, sizeof(arginfo)); 506176771Sraj 507176771Sraj /* 508176771Sraj * Set up arguments for _start(): 509176771Sraj * _start(argc, argv, envp, obj, cleanup, ps_strings); 510176771Sraj * 511176771Sraj * Notes: 512176771Sraj * - obj and cleanup are the auxilliary and termination 513176771Sraj * vectors. They are fixed up by ld.elf_so. 514176771Sraj * - ps_strings is a NetBSD extention, and will be 515176771Sraj * ignored by executables which are strictly 516176771Sraj * compliant with the SVR4 ABI. 517176771Sraj * 518176771Sraj * XXX We have to set both regs and retval here due to different 519176771Sraj * XXX calling convention in trap.c and init_main.c. 520176771Sraj */ 521176771Sraj /* 522176771Sraj * XXX PG: these get overwritten in the syscall return code. 523176771Sraj * execve() should return EJUSTRETURN, like it does on NetBSD. 524176771Sraj * Emulate by setting the syscall return value cells. The 525176771Sraj * registers still have to be set for init's fork trampoline. 526176771Sraj */ 527176771Sraj td->td_retval[0] = arginfo.ps_nargvstr; 528176771Sraj td->td_retval[1] = (register_t)arginfo.ps_argvstr; 529176771Sraj tf->fixreg[3] = arginfo.ps_nargvstr; 530176771Sraj tf->fixreg[4] = (register_t)arginfo.ps_argvstr; 531176771Sraj tf->fixreg[5] = (register_t)arginfo.ps_envstr; 532176771Sraj tf->fixreg[6] = 0; /* auxillary vector */ 533176771Sraj tf->fixreg[7] = 0; /* termination vector */ 534176771Sraj tf->fixreg[8] = (register_t)PS_STRINGS; /* NetBSD extension */ 535176771Sraj 536176771Sraj tf->srr0 = entry; 537176771Sraj tf->srr1 = PSL_USERSET; 538176771Sraj td->td_pcb->pcb_flags = 0; 539176771Sraj} 540176771Sraj 541176771Srajint 542176771Srajfill_regs(struct thread *td, struct reg *regs) 543176771Sraj{ 544176771Sraj struct trapframe *tf; 545176771Sraj 546176771Sraj tf = td->td_frame; 547176771Sraj memcpy(regs, tf, sizeof(struct reg)); 548176771Sraj 549176771Sraj return (0); 550176771Sraj} 551176771Sraj 552176771Srajint 553176771Srajfill_fpregs(struct thread *td, struct fpreg *fpregs) 554176771Sraj{ 555176771Sraj 556176771Sraj return (0); 557176771Sraj} 558176771Sraj 559176771Sraj/* Get current clock frequency for the given cpu id. */ 560176771Srajint 561176771Srajcpu_est_clockrate(int cpu_id, uint64_t *rate) 562176771Sraj{ 563176771Sraj 564176771Sraj return (ENXIO); 565176771Sraj} 566176771Sraj 567176771Sraj/* 568176771Sraj * Construct a PCB from a trapframe. This is called from kdb_trap() where 569176771Sraj * we want to start a backtrace from the function that caused us to enter 570176771Sraj * the debugger. We have the context in the trapframe, but base the trace 571176771Sraj * on the PCB. The PCB doesn't have to be perfect, as long as it contains 572176771Sraj * enough for a backtrace. 573176771Sraj */ 574176771Srajvoid 575176771Srajmakectx(struct trapframe *tf, struct pcb *pcb) 576176771Sraj{ 577176771Sraj 578176771Sraj pcb->pcb_lr = tf->srr0; 579176771Sraj pcb->pcb_sp = tf->fixreg[1]; 580176771Sraj} 581176771Sraj 582176771Sraj/* 583176771Sraj * get_mcontext/sendsig helper routine that doesn't touch the 584176771Sraj * proc lock. 585176771Sraj */ 586176771Srajstatic int 587176771Srajgrab_mcontext(struct thread *td, mcontext_t *mcp, int flags) 588176771Sraj{ 589176771Sraj struct pcb *pcb; 590176771Sraj 591176771Sraj pcb = td->td_pcb; 592176771Sraj memset(mcp, 0, sizeof(mcontext_t)); 593176771Sraj 594176771Sraj mcp->mc_vers = _MC_VERSION; 595176771Sraj mcp->mc_flags = 0; 596176771Sraj memcpy(&mcp->mc_frame, td->td_frame, sizeof(struct trapframe)); 597176771Sraj if (flags & GET_MC_CLEAR_RET) { 598176771Sraj mcp->mc_gpr[3] = 0; 599176771Sraj mcp->mc_gpr[4] = 0; 600176771Sraj } 601176771Sraj 602176771Sraj /* XXX Altivec context ? */ 603176771Sraj 604176771Sraj mcp->mc_len = sizeof(*mcp); 605176771Sraj return (0); 606176771Sraj} 607176771Sraj 608176771Srajint 609176771Srajget_mcontext(struct thread *td, mcontext_t *mcp, int flags) 610176771Sraj{ 611176771Sraj int error; 612176771Sraj 613176771Sraj error = grab_mcontext(td, mcp, flags); 614176771Sraj if (error == 0) { 615176771Sraj PROC_LOCK(curthread->td_proc); 616176771Sraj mcp->mc_onstack = sigonstack(td->td_frame->fixreg[1]); 617176771Sraj PROC_UNLOCK(curthread->td_proc); 618176771Sraj } 619176771Sraj 620176771Sraj return (error); 621176771Sraj} 622176771Sraj 623176771Srajint 624176771Srajset_mcontext(struct thread *td, const mcontext_t *mcp) 625176771Sraj{ 626176771Sraj struct pcb *pcb; 627176771Sraj struct trapframe *tf; 628176771Sraj 629176771Sraj pcb = td->td_pcb; 630176771Sraj tf = td->td_frame; 631176771Sraj 632176771Sraj if (mcp->mc_vers != _MC_VERSION || mcp->mc_len != sizeof(*mcp)) 633176771Sraj return (EINVAL); 634176771Sraj 635176771Sraj memcpy(tf, mcp->mc_frame, sizeof(mcp->mc_frame)); 636176771Sraj 637176771Sraj /* XXX Altivec context? */ 638176771Sraj 639176771Sraj return (0); 640176771Sraj} 641176771Sraj 642176771Srajint 643176771Srajsigreturn(struct thread *td, struct sigreturn_args *uap) 644176771Sraj{ 645176771Sraj struct proc *p; 646176771Sraj ucontext_t uc; 647176771Sraj int error; 648176771Sraj 649176771Sraj CTR2(KTR_SIG, "sigreturn: td=%p ucp=%p", td, uap->sigcntxp); 650176771Sraj 651176771Sraj if (copyin(uap->sigcntxp, &uc, sizeof(uc)) != 0) { 652176771Sraj CTR1(KTR_SIG, "sigreturn: efault td=%p", td); 653176771Sraj return (EFAULT); 654176771Sraj } 655176771Sraj 656176771Sraj error = set_mcontext(td, &uc.uc_mcontext); 657176771Sraj if (error != 0) 658176771Sraj return (error); 659176771Sraj 660176771Sraj p = td->td_proc; 661176771Sraj PROC_LOCK(p); 662176771Sraj td->td_sigmask = uc.uc_sigmask; 663176771Sraj SIG_CANTMASK(td->td_sigmask); 664176771Sraj signotify(td); 665176771Sraj PROC_UNLOCK(p); 666176771Sraj 667176771Sraj CTR3(KTR_SIG, "sigreturn: return td=%p pc=%#x sp=%#x", 668176771Sraj td, uc.uc_mcontext.mc_srr0, uc.uc_mcontext.mc_gpr[1]); 669176771Sraj 670176771Sraj return (EJUSTRETURN); 671176771Sraj} 672176771Sraj 673176771Sraj#ifdef COMPAT_FREEBSD4 674176771Srajint 675176771Srajfreebsd4_sigreturn(struct thread *td, struct freebsd4_sigreturn_args *uap) 676176771Sraj{ 677176771Sraj 678176771Sraj return sigreturn(td, (struct sigreturn_args *)uap); 679176771Sraj} 680176771Sraj#endif 681176771Sraj 682176771Sraj/* 683176771Sraj * cpu_idle 684176771Sraj * 685176771Sraj * Set Wait state enable. 686176771Sraj */ 687176771Srajvoid 688178471Sjeffcpu_idle (int busy) 689176771Sraj{ 690176771Sraj register_t msr; 691176771Sraj 692176771Sraj msr = mfmsr(); 693176771Sraj#ifdef INVARIANTS 694176771Sraj if ((msr & PSL_EE) != PSL_EE) { 695176771Sraj struct thread *td = curthread; 696176771Sraj printf("td msr %x\n", td->td_md.md_saved_msr); 697176771Sraj panic("ints disabled in idleproc!"); 698176771Sraj } 699176771Sraj#endif 700176771Sraj#if 0 701176771Sraj /* 702176771Sraj * Freescale E500 core RM section 6.4.1 703176771Sraj */ 704176771Sraj msr = msr | PSL_WE; 705176771Sraj 706176771Sraj __asm__(" msync;" 707176771Sraj " mtmsr %0;" 708176771Sraj " isync;" 709176771Sraj "loop: b loop" : 710176771Sraj /* no output */ : 711176771Sraj "r" (msr)); 712176771Sraj#endif 713176771Sraj} 714176771Sraj 715178471Sjeffint 716178471Sjeffcpu_idle_wakeup(int cpu) 717178471Sjeff{ 718178471Sjeff 719178471Sjeff return (0); 720178471Sjeff} 721178471Sjeff 722176771Srajvoid 723176771Srajspinlock_enter(void) 724176771Sraj{ 725176771Sraj struct thread *td; 726176771Sraj 727176771Sraj td = curthread; 728176771Sraj if (td->td_md.md_spinlock_count == 0) 729176771Sraj td->td_md.md_saved_msr = intr_disable(); 730176771Sraj td->td_md.md_spinlock_count++; 731176771Sraj critical_enter(); 732176771Sraj} 733176771Sraj 734176771Srajvoid 735176771Srajspinlock_exit(void) 736176771Sraj{ 737176771Sraj struct thread *td; 738176771Sraj 739176771Sraj td = curthread; 740176771Sraj critical_exit(); 741176771Sraj td->td_md.md_spinlock_count--; 742176771Sraj if (td->td_md.md_spinlock_count == 0) 743176771Sraj intr_restore(td->td_md.md_saved_msr); 744176771Sraj} 745176771Sraj 746176771Sraj/* Shutdown the CPU as much as possible. */ 747176771Srajvoid 748176771Srajcpu_halt(void) 749176771Sraj{ 750176771Sraj 751176771Sraj mtmsr(mfmsr() & ~(PSL_CE | PSL_EE | PSL_ME | PSL_DE)); 752176771Sraj while (1); 753176771Sraj} 754176771Sraj 755176771Srajint 756176771Srajset_regs(struct thread *td, struct reg *regs) 757176771Sraj{ 758176771Sraj struct trapframe *tf; 759176771Sraj 760176771Sraj tf = td->td_frame; 761176771Sraj memcpy(tf, regs, sizeof(struct reg)); 762176771Sraj return (0); 763176771Sraj} 764176771Sraj 765176771Srajint 766176771Srajfill_dbregs(struct thread *td, struct dbreg *dbregs) 767176771Sraj{ 768176771Sraj 769176771Sraj /* No debug registers on PowerPC */ 770176771Sraj return (ENOSYS); 771176771Sraj} 772176771Sraj 773176771Srajint 774176771Srajset_dbregs(struct thread *td, struct dbreg *dbregs) 775176771Sraj{ 776176771Sraj 777176771Sraj /* No debug registers on PowerPC */ 778176771Sraj return (ENOSYS); 779176771Sraj} 780176771Sraj 781176771Srajint 782176771Srajset_fpregs(struct thread *td, struct fpreg *fpregs) 783176771Sraj{ 784176771Sraj 785176771Sraj return (0); 786176771Sraj} 787176771Sraj 788176771Srajint 789176771Srajptrace_set_pc(struct thread *td, unsigned long addr) 790176771Sraj{ 791176771Sraj struct trapframe *tf; 792176771Sraj 793176771Sraj tf = td->td_frame; 794176771Sraj tf->srr0 = (register_t)addr; 795176771Sraj 796176771Sraj return (0); 797176771Sraj} 798176771Sraj 799176771Srajint 800176771Srajptrace_single_step(struct thread *td) 801176771Sraj{ 802176771Sraj struct trapframe *tf; 803176771Sraj u_int reg; 804176771Sraj 805176771Sraj reg = mfspr(SPR_DBCR0); 806176771Sraj reg |= DBCR0_IC | DBCR0_IDM; 807176771Sraj mtspr(SPR_DBCR0, reg); 808176771Sraj 809176771Sraj tf = td->td_frame; 810176771Sraj tf->srr1 |= PSL_DE; 811176771Sraj return (0); 812176771Sraj} 813176771Sraj 814176771Srajint 815176771Srajptrace_clear_single_step(struct thread *td) 816176771Sraj{ 817176771Sraj struct trapframe *tf; 818176771Sraj 819176771Sraj tf = td->td_frame; 820176771Sraj tf->srr1 &= ~PSL_DE; 821176771Sraj return (0); 822176771Sraj} 823176771Sraj 824176771Srajvoid 825176771Srajkdb_cpu_clear_singlestep(void) 826176771Sraj{ 827176771Sraj register_t r; 828176771Sraj 829176771Sraj r = mfspr(SPR_DBCR0); 830176771Sraj mtspr(SPR_DBCR0, r & ~DBCR0_IC); 831176771Sraj kdb_frame->srr1 &= ~PSL_DE; 832176771Sraj} 833176771Sraj 834176771Srajvoid 835176771Srajkdb_cpu_set_singlestep(void) 836176771Sraj{ 837176771Sraj register_t r; 838176771Sraj 839176771Sraj r = mfspr(SPR_DBCR0); 840176771Sraj mtspr(SPR_DBCR0, r | DBCR0_IC | DBCR0_IDM); 841176771Sraj kdb_frame->srr1 |= PSL_DE; 842176771Sraj} 843176771Sraj 844176771Srajvoid 845176771Srajsendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) 846176771Sraj{ 847176771Sraj struct trapframe *tf; 848176771Sraj struct sigframe *sfp; 849176771Sraj struct sigacts *psp; 850176771Sraj struct sigframe sf; 851176771Sraj struct thread *td; 852176771Sraj struct proc *p; 853176771Sraj int oonstack, rndfsize; 854176771Sraj int sig, code; 855176771Sraj 856176771Sraj td = curthread; 857176771Sraj p = td->td_proc; 858176771Sraj PROC_LOCK_ASSERT(p, MA_OWNED); 859176771Sraj sig = ksi->ksi_signo; 860176771Sraj code = ksi->ksi_code; 861176771Sraj psp = p->p_sigacts; 862176771Sraj mtx_assert(&psp->ps_mtx, MA_OWNED); 863176771Sraj tf = td->td_frame; 864176771Sraj oonstack = sigonstack(tf->fixreg[1]); 865176771Sraj 866176771Sraj rndfsize = ((sizeof(sf) + 15) / 16) * 16; 867176771Sraj 868176771Sraj CTR4(KTR_SIG, "sendsig: td=%p (%s) catcher=%p sig=%d", td, p->p_comm, 869176771Sraj catcher, sig); 870176771Sraj 871176771Sraj /* 872176771Sraj * Save user context 873176771Sraj */ 874176771Sraj memset(&sf, 0, sizeof(sf)); 875176771Sraj grab_mcontext(td, &sf.sf_uc.uc_mcontext, 0); 876176771Sraj sf.sf_uc.uc_sigmask = *mask; 877176771Sraj sf.sf_uc.uc_stack = td->td_sigstk; 878176771Sraj sf.sf_uc.uc_stack.ss_flags = (td->td_pflags & TDP_ALTSTACK) 879176771Sraj ? ((oonstack) ? SS_ONSTACK : 0) : SS_DISABLE; 880176771Sraj 881176771Sraj sf.sf_uc.uc_mcontext.mc_onstack = (oonstack) ? 1 : 0; 882176771Sraj 883176771Sraj /* 884176771Sraj * Allocate and validate space for the signal handler context. 885176771Sraj */ 886176771Sraj if ((td->td_pflags & TDP_ALTSTACK) != 0 && !oonstack && 887176771Sraj SIGISMEMBER(psp->ps_sigonstack, sig)) { 888176771Sraj sfp = (struct sigframe *)((caddr_t)td->td_sigstk.ss_sp + 889176771Sraj td->td_sigstk.ss_size - rndfsize); 890176771Sraj } else { 891176771Sraj sfp = (struct sigframe *)(tf->fixreg[1] - rndfsize); 892176771Sraj } 893176771Sraj 894176771Sraj /* 895176771Sraj * Translate the signal if appropriate (Linux emu ?) 896176771Sraj */ 897176771Sraj if (p->p_sysent->sv_sigtbl && sig <= p->p_sysent->sv_sigsize) 898176771Sraj sig = p->p_sysent->sv_sigtbl[_SIG_IDX(sig)]; 899176771Sraj 900176771Sraj /* 901176771Sraj * Save the floating-point state, if necessary, then copy it. 902176771Sraj */ 903176771Sraj /* XXX */ 904176771Sraj 905176771Sraj /* 906176771Sraj * Set up the registers to return to sigcode. 907176771Sraj * 908176771Sraj * r1/sp - sigframe ptr 909176771Sraj * lr - sig function, dispatched to by blrl in trampoline 910176771Sraj * r3 - sig number 911176771Sraj * r4 - SIGINFO ? &siginfo : exception code 912176771Sraj * r5 - user context 913176771Sraj * srr0 - trampoline function addr 914176771Sraj */ 915176771Sraj tf->lr = (register_t)catcher; 916176771Sraj tf->fixreg[1] = (register_t)sfp; 917176771Sraj tf->fixreg[FIRSTARG] = sig; 918176771Sraj tf->fixreg[FIRSTARG+2] = (register_t)&sfp->sf_uc; 919176771Sraj if (SIGISMEMBER(psp->ps_siginfo, sig)) { 920176771Sraj /* 921176771Sraj * Signal handler installed with SA_SIGINFO. 922176771Sraj */ 923176771Sraj tf->fixreg[FIRSTARG+1] = (register_t)&sfp->sf_si; 924176771Sraj 925176771Sraj /* 926176771Sraj * Fill siginfo structure. 927176771Sraj */ 928176771Sraj sf.sf_si = ksi->ksi_info; 929176771Sraj sf.sf_si.si_signo = sig; 930176771Sraj sf.sf_si.si_addr = (void *) ((tf->exc == EXC_DSI) ? 931176771Sraj tf->cpu.booke.dear : tf->srr0); 932176771Sraj } else { 933176771Sraj /* Old FreeBSD-style arguments. */ 934176771Sraj tf->fixreg[FIRSTARG+1] = code; 935176771Sraj tf->fixreg[FIRSTARG+3] = (tf->exc == EXC_DSI) ? 936176771Sraj tf->cpu.booke.dear : tf->srr0; 937176771Sraj } 938176771Sraj mtx_unlock(&psp->ps_mtx); 939176771Sraj PROC_UNLOCK(p); 940176771Sraj 941176771Sraj tf->srr0 = (register_t)(PS_STRINGS - *(p->p_sysent->sv_szsigcode)); 942176771Sraj 943176771Sraj /* 944176771Sraj * copy the frame out to userland. 945176771Sraj */ 946176771Sraj if (copyout((caddr_t)&sf, (caddr_t)sfp, sizeof(sf)) != 0) { 947176771Sraj /* 948176771Sraj * Process has trashed its stack. Kill it. 949176771Sraj */ 950176771Sraj CTR2(KTR_SIG, "sendsig: sigexit td=%p sfp=%p", td, sfp); 951176771Sraj PROC_LOCK(p); 952176771Sraj sigexit(td, SIGILL); 953176771Sraj } 954176771Sraj 955176771Sraj CTR3(KTR_SIG, "sendsig: return td=%p pc=%#x sp=%#x", td, 956176771Sraj tf->srr0, tf->fixreg[1]); 957176771Sraj 958176771Sraj PROC_LOCK(p); 959176771Sraj mtx_lock(&psp->ps_mtx); 960176771Sraj} 961176771Sraj 962176771Srajvoid 963176771Srajbzero(void *buf, size_t len) 964176771Sraj{ 965176771Sraj caddr_t p; 966176771Sraj 967176771Sraj p = buf; 968176771Sraj 969176771Sraj while (((vm_offset_t) p & (sizeof(u_long) - 1)) && len) { 970176771Sraj *p++ = 0; 971176771Sraj len--; 972176771Sraj } 973176771Sraj 974176771Sraj while (len >= sizeof(u_long) * 8) { 975176771Sraj *(u_long*) p = 0; 976176771Sraj *((u_long*) p + 1) = 0; 977176771Sraj *((u_long*) p + 2) = 0; 978176771Sraj *((u_long*) p + 3) = 0; 979176771Sraj len -= sizeof(u_long) * 8; 980176771Sraj *((u_long*) p + 4) = 0; 981176771Sraj *((u_long*) p + 5) = 0; 982176771Sraj *((u_long*) p + 6) = 0; 983176771Sraj *((u_long*) p + 7) = 0; 984176771Sraj p += sizeof(u_long) * 8; 985176771Sraj } 986176771Sraj 987176771Sraj while (len >= sizeof(u_long)) { 988176771Sraj *(u_long*) p = 0; 989176771Sraj len -= sizeof(u_long); 990176771Sraj p += sizeof(u_long); 991176771Sraj } 992176771Sraj 993176771Sraj while (len) { 994176771Sraj *p++ = 0; 995176771Sraj len--; 996176771Sraj } 997176771Sraj} 998176771Sraj 999176771Sraj/* 1000176771Sraj * XXX what is the better/proper place for this routine? 1001176771Sraj */ 1002176771Srajint 1003176771Srajmem_valid(vm_offset_t addr, int len) 1004176771Sraj{ 1005176771Sraj 1006176771Sraj return (1); 1007176771Sraj} 1008