board_bwct.c revision 171673
197403Sobrien/*- 297403Sobrien * Copyright (c) 1994-1998 Mark Brinicombe. 3169691Skan * Copyright (c) 1994 Brini. 4132720Skan * All rights reserved. 597403Sobrien * 697403Sobrien * This code is derived from software written for Brini by Mark Brinicombe 797403Sobrien * 897403Sobrien * Redistribution and use in source and binary forms, with or without 997403Sobrien * modification, are permitted provided that the following conditions 1097403Sobrien * are met: 1197403Sobrien * 1. Redistributions of source code must retain the above copyright 1297403Sobrien * notice, this list of conditions and the following disclaimer. 1397403Sobrien * 2. Redistributions in binary form must reproduce the above copyright 1497403Sobrien * notice, this list of conditions and the following disclaimer in the 1597403Sobrien * documentation and/or other materials provided with the distribution. 1697403Sobrien * 3. All advertising materials mentioning features or use of this software 1797403Sobrien * must display the following acknowledgement: 1897403Sobrien * This product includes software developed by Brini. 19169691Skan * 4. The name of the company nor the name of the author may be used to 2097403Sobrien * endorse or promote products derived from this software without specific 2197403Sobrien * prior written permission. 2297403Sobrien * 2397403Sobrien * THIS SOFTWARE IS PROVIDED BY BRINI ``AS IS'' AND ANY EXPRESS OR IMPLIED 2497403Sobrien * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 2597403Sobrien * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 2697403Sobrien * IN NO EVENT SHALL BRINI OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 2797403Sobrien * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 2897403Sobrien * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 2997403Sobrien * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3097403Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3197403Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3297403Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3397403Sobrien * SUCH DAMAGE. 3497403Sobrien * 3597403Sobrien * RiscBSD kernel project 36169691Skan * 37169691Skan * machdep.c 38132720Skan * 39132720Skan * Machine dependant functions for kernel setup 4097403Sobrien * 4197403Sobrien * This file needs a lot of work. 4297403Sobrien * 43169691Skan * Created : 17/09/94 4497403Sobrien */ 45132720Skan 46132720Skan#include "opt_msgbuf.h" 47132720Skan#include "opt_ddb.h" 48132720Skan#include "opt_at91.h" 49132720Skan 50132720Skan#include <sys/cdefs.h> 51132720Skan__FBSDID("$FreeBSD: head/sys/arm/at91/kb920x_machdep.c 171673 2007-07-31 17:43:18Z imp $"); 52132720Skan 53132720Skan#define _ARM32_BUS_DMA_PRIVATE 54132720Skan#include <sys/param.h> 55132720Skan#include <sys/systm.h> 56132720Skan#include <sys/sysproto.h> 57132720Skan#include <sys/signalvar.h> 58117397Skan#include <sys/imgact.h> 59117397Skan#include <sys/kernel.h> 6097403Sobrien#include <sys/ktr.h> 6197403Sobrien#include <sys/linker.h> 62117397Skan#include <sys/lock.h> 6397403Sobrien#include <sys/malloc.h> 64132720Skan#include <sys/mutex.h> 65132720Skan#include <sys/pcpu.h> 66132720Skan#include <sys/proc.h> 67132720Skan#include <sys/ptrace.h> 68132720Skan#include <sys/cons.h> 69132720Skan#include <sys/bio.h> 70132720Skan#include <sys/bus.h> 71132720Skan#include <sys/buf.h> 72132720Skan#include <sys/exec.h> 73132720Skan#include <sys/kdb.h> 74132720Skan#include <sys/msgbuf.h> 75117397Skan#include <machine/reg.h> 76132720Skan#include <machine/cpu.h> 77117397Skan 78132720Skan#include <vm/vm.h> 79117397Skan#include <vm/pmap.h> 80132720Skan#include <vm/vm_object.h> 81117397Skan#include <vm/vm_page.h> 82132720Skan#include <vm/vm_pager.h> 83117397Skan#include <vm/vm_map.h> 84132720Skan#include <vm/vnode_pager.h> 85117397Skan#include <machine/pmap.h> 86132720Skan#include <machine/vmparam.h> 87117397Skan#include <machine/pcb.h> 88132720Skan#include <machine/undefined.h> 89117397Skan#include <machine/machdep.h> 90132720Skan#include <machine/metadata.h> 91117397Skan#include <machine/armreg.h> 92132720Skan#include <machine/bus.h> 93117397Skan#include <sys/reboot.h> 94132720Skan 95117397Skan#include <arm/at91/at91rm92reg.h> 96132720Skan#include <arm/at91/at91_piovar.h> 97117397Skan#include <arm/at91/at91_pio_rm9200.h> 9897403Sobrien 99117397Skan#define KERNEL_PT_SYS 0 /* Page table for mapping proc0 zero page */ 100169691Skan#define KERNEL_PT_KERN 1 101117397Skan#define KERNEL_PT_KERN_NUM 22 102169691Skan#define KERNEL_PT_AFKERNEL KERNEL_PT_KERN + KERNEL_PT_KERN_NUM /* L2 table for mapping after kernel */ 103117397Skan#define KERNEL_PT_AFKERNEL_NUM 5 104169691Skan 105117397Skan/* this should be evenly divisable by PAGE_SIZE / L2_TABLE_SIZE_REAL (or 4) */ 106169691Skan#define NUM_KERNEL_PTS (KERNEL_PT_AFKERNEL + KERNEL_PT_AFKERNEL_NUM) 107117397Skan 108169691Skan/* Define various stack sizes in pages */ 109117397Skan#define IRQ_STACK_SIZE 1 110169691Skan#define ABT_STACK_SIZE 1 111117397Skan#define UND_STACK_SIZE 1 112169691Skan 113117397Skanextern u_int data_abort_handler_address; 114169691Skanextern u_int prefetch_abort_handler_address; 115117397Skanextern u_int undefined_handler_address; 116169691Skan 117117397Skanstruct pv_addr kernel_pt_table[NUM_KERNEL_PTS]; 118169691Skan 119117397Skanextern void *_end; 120169691Skan 121132720Skanextern int *end; 12297403Sobrien 123117397Skanstruct pcpu __pcpu; 124117397Skanstruct pcpu *pcpup = &__pcpu; 125132720Skan 126117397Skan/* Physical and virtual addresses for some global pages */ 127132720Skan 128117397Skanvm_paddr_t phys_avail[10]; 12997403Sobrienvm_paddr_t dump_avail[4]; 130117397Skanvm_offset_t physical_pages; 131117397Skan 13297403Sobrienstruct pv_addr systempage; 13397403Sobrienstruct pv_addr msgbufpv; 134117397Skanstruct pv_addr irqstack; 13597403Sobrienstruct pv_addr undstack; 136117397Skanstruct pv_addr abtstack; 137117397Skanstruct pv_addr kernelstack; 138132720Skan 13997403Sobrienstatic struct trapframe proc0_tf; 140117397Skan 14197403Sobrien/* Static device mappings. */ 142117397Skanstatic const struct pmap_devmap kb920x_devmap[] = { 143132720Skan /* 14497403Sobrien * Map the on-board devices VA == PA so that we can access them 145117397Skan * with the MMU on or off. 146132720Skan */ 147132720Skan { 148132720Skan /* 149132720Skan * This at least maps the interrupt controller, the UART 150132720Skan * and the timer. Other devices should use newbus to 151132720Skan * map their memory anyway. 152132720Skan */ 153132720Skan 0xdff00000, 154132720Skan 0xfff00000, 155132720Skan 0x100000, 15697403Sobrien VM_PROT_READ|VM_PROT_WRITE, 157117397Skan PTE_NOCACHE, 158132720Skan }, 159132720Skan /* 160132720Skan * We can't just map the OHCI registers VA == PA, because 16197403Sobrien * AT91RM92_OHCI_BASE belongs to the userland address space. 16297403Sobrien * We could just choose a different virtual address, but a better 163117397Skan * solution would probably be to just use pmap_mapdev() to allocate 16497403Sobrien * KVA, as we don't need the OHCI controller before the vm 165117397Skan * initialization is done. However, the AT91 resource allocation 16697403Sobrien * system doesn't know how to use pmap_mapdev() yet. 167132720Skan */ 168132720Skan#if 1 16997403Sobrien { 17097403Sobrien /* 171117397Skan * Add the ohci controller, and anything else that might be 172117397Skan * on this chip select for a VA/PA mapping. 173117397Skan */ 174117397Skan AT91RM92_OHCI_BASE, 175117397Skan AT91RM92_OHCI_PA_BASE, 176132720Skan AT91RM92_OHCI_SIZE, 177132720Skan VM_PROT_READ|VM_PROT_WRITE, 178117397Skan PTE_NOCACHE, 17997403Sobrien }, 18097403Sobrien#endif 181117397Skan { 182117397Skan 0, 183117397Skan 0, 184117397Skan 0, 185117397Skan 0, 186117397Skan 0, 187169691Skan } 188117397Skan}; 18997403Sobrien 190117397Skan#define SDRAM_START 0xa0000000 191132720Skan 192132720Skan#ifdef DDB 193117397Skanextern vm_offset_t ksym_start, ksym_end; 194117397Skan#endif 195117397Skan 196117397Skanstatic long 197117397Skanramsize(void) 19897403Sobrien{ 199117397Skan uint32_t *SDRAMC = (uint32_t *)(AT91RM92_BASE + AT91RM92_SDRAMC_BASE); 200132720Skan uint32_t cr, mr; 201117397Skan int banks, rows, cols, bw; 202132720Skan 203117397Skan cr = SDRAMC[AT91RM92_SDRAMC_CR / 4]; 204117397Skan mr = SDRAMC[AT91RM92_SDRAMC_MR / 4]; 205117397Skan bw = (mr & AT91RM92_SDRAMC_MR_DBW_16) ? 1 : 2; 206117397Skan banks = (cr & AT91RM92_SDRAMC_CR_NB_4) ? 2 : 1; 207117397Skan rows = ((cr & AT91RM92_SDRAMC_CR_NR_MASK) >> 2) + 11; 208117397Skan cols = (cr & AT91RM92_SDRAMC_CR_NC_MASK) + 8; 20997403Sobrien return (1 << (cols + rows + banks + bw)); 21097403Sobrien} 21197403Sobrien 212169691Skanstatic long 21397403Sobrienboard_init(void) 214132720Skan{ 215 /* 216 * Since the USART supprots RS-485 multidrop mode, it allows the 217 * TX pins to float. However, for RS-232 operations, we don't want 218 * these pins to float. Instead, they should be pulled up to avoid 219 * mismatches. Linux does something similar when it configures the 220 * TX lines. This implies that we also allow the RX lines to float 221 * rather than be in the state they are left in by the boot loader. 222 * Since they are input pins, I think that this is the right thing 223 * to do. 224 */ 225 226 /* PIOA's A periph: Turn USART 0 and 2's TX/RX pins */ 227 at91_pio_use_periph_a(AT91RM92_PIOA_BASE, 228 AT91C_PA18_RXD0 | AT91C_PA22_RXD2, 0); 229 at91_pio_use_periph_a(AT91RM92_PIOA_BASE, 230 AT91C_PA17_TXD0 | AT91C_PA23_TXD2, 1); 231 /* PIOA's B periph: Turn USART 3's TX/RX pins */ 232 at91_pio_use_periph_b(AT91RM92_PIOA_BASE, AT91C_PA6_RXD3, 0); 233 at91_pio_use_periph_b(AT91RM92_PIOA_BASE, AT91C_PA5_TXD3, 1); 234#ifdef AT91_TSC 235 /* We're using TC0's A1 and A2 input */ 236 at91_pio_use_periph_b(AT91RM92_PIOA_BASE, 237 AT91C_PA19_TIOA1 | AT91C_PA21_TIOA2, 0); 238#endif 239 /* PIOB's A periph: Turn USART 1's TX/RX pins */ 240 at91_pio_use_periph_a(AT91RM92_PIOB_BASE, AT91C_PB21_RXD1, 0); 241 at91_pio_use_periph_a(AT91RM92_PIOB_BASE, AT91C_PB20_TXD1, 1); 242 243 /* Pin assignment */ 244#ifdef AT91_TSC 245 /* Assert PA24 low -- talk to rubidium */ 246 at91_pio_use_gpio(AT91RM92_PIOA_BASE, AT91C_PIO_PA24); 247 at91_pio_gpio_output(AT91RM92_PIOA_BASE, AT91C_PIO_PA24, 0); 248 at91_pio_gpio_clear(AT91RM92_PIOA_BASE, AT91C_PIO_PA24); 249 at91_pio_use_gpio(AT91RM92_PIOB_BASE, 250 AT91C_PIO_PB16 | AT91C_PIO_PB17 | AT91C_PIO_PB18 | AT91C_PIO_PB19); 251#endif 252 253 return (ramsize()); 254} 255 256void * 257initarm(void *arg, void *arg2) 258{ 259 struct pv_addr kernel_l1pt; 260 int loop; 261 u_int l1pagetable; 262 vm_offset_t freemempos; 263 vm_offset_t afterkern; 264 int i; 265 uint32_t fake_preload[35]; 266 uint32_t memsize; 267 vm_offset_t lastaddr; 268#ifdef DDB 269 vm_offset_t zstart = 0, zend = 0; 270#endif 271 272 i = 0; 273 274 set_cpufuncs(); 275 276 fake_preload[i++] = MODINFO_NAME; 277 fake_preload[i++] = strlen("elf kernel") + 1; 278 strcpy((char*)&fake_preload[i++], "elf kernel"); 279 i += 2; 280 fake_preload[i++] = MODINFO_TYPE; 281 fake_preload[i++] = strlen("elf kernel") + 1; 282 strcpy((char*)&fake_preload[i++], "elf kernel"); 283 i += 2; 284 fake_preload[i++] = MODINFO_ADDR; 285 fake_preload[i++] = sizeof(vm_offset_t); 286 fake_preload[i++] = KERNBASE; 287 fake_preload[i++] = MODINFO_SIZE; 288 fake_preload[i++] = sizeof(uint32_t); 289 fake_preload[i++] = (uint32_t)&end - KERNBASE; 290#ifdef DDB 291 if (*(uint32_t *)KERNVIRTADDR == MAGIC_TRAMP_NUMBER) { 292 fake_preload[i++] = MODINFO_METADATA|MODINFOMD_SSYM; 293 fake_preload[i++] = sizeof(vm_offset_t); 294 fake_preload[i++] = *(uint32_t *)(KERNVIRTADDR + 4); 295 fake_preload[i++] = MODINFO_METADATA|MODINFOMD_ESYM; 296 fake_preload[i++] = sizeof(vm_offset_t); 297 fake_preload[i++] = *(uint32_t *)(KERNVIRTADDR + 8); 298 lastaddr = *(uint32_t *)(KERNVIRTADDR + 8); 299 zend = lastaddr; 300 zstart = *(uint32_t *)(KERNVIRTADDR + 4); 301 ksym_start = zstart; 302 ksym_end = zend; 303 } else 304#endif 305 lastaddr = (vm_offset_t)&end; 306 307 fake_preload[i++] = 0; 308 fake_preload[i] = 0; 309 preload_metadata = (void *)fake_preload; 310 311 312 pcpu_init(pcpup, 0, sizeof(struct pcpu)); 313 PCPU_SET(curthread, &thread0); 314 315#define KERNEL_TEXT_BASE (KERNBASE) 316 freemempos = (lastaddr + PAGE_MASK) & ~PAGE_MASK; 317 /* Define a macro to simplify memory allocation */ 318#define valloc_pages(var, np) \ 319 alloc_pages((var).pv_va, (np)); \ 320 (var).pv_pa = (var).pv_va + (KERNPHYSADDR - KERNVIRTADDR); 321 322#define alloc_pages(var, np) \ 323 (var) = freemempos; \ 324 freemempos += (np * PAGE_SIZE); \ 325 memset((char *)(var), 0, ((np) * PAGE_SIZE)); 326 327 while (((freemempos - L1_TABLE_SIZE) & (L1_TABLE_SIZE - 1)) != 0) 328 freemempos += PAGE_SIZE; 329 valloc_pages(kernel_l1pt, L1_TABLE_SIZE / PAGE_SIZE); 330 for (loop = 0; loop < NUM_KERNEL_PTS; ++loop) { 331 if (!(loop % (PAGE_SIZE / L2_TABLE_SIZE_REAL))) { 332 valloc_pages(kernel_pt_table[loop], 333 L2_TABLE_SIZE / PAGE_SIZE); 334 } else { 335 kernel_pt_table[loop].pv_va = freemempos - 336 (loop % (PAGE_SIZE / L2_TABLE_SIZE_REAL)) * 337 L2_TABLE_SIZE_REAL; 338 kernel_pt_table[loop].pv_pa = 339 kernel_pt_table[loop].pv_va - KERNVIRTADDR + 340 KERNPHYSADDR; 341 } 342 i++; 343 } 344 /* 345 * Allocate a page for the system page mapped to V0x00000000 346 * This page will just contain the system vectors and can be 347 * shared by all processes. 348 */ 349 valloc_pages(systempage, 1); 350 351 /* Allocate stacks for all modes */ 352 valloc_pages(irqstack, IRQ_STACK_SIZE); 353 valloc_pages(abtstack, ABT_STACK_SIZE); 354 valloc_pages(undstack, UND_STACK_SIZE); 355 valloc_pages(kernelstack, KSTACK_PAGES); 356 valloc_pages(msgbufpv, round_page(MSGBUF_SIZE) / PAGE_SIZE); 357 /* 358 * Now we start construction of the L1 page table 359 * We start by mapping the L2 page tables into the L1. 360 * This means that we can replace L1 mappings later on if necessary 361 */ 362 l1pagetable = kernel_l1pt.pv_va; 363 364 /* Map the L2 pages tables in the L1 page table */ 365 pmap_link_l2pt(l1pagetable, ARM_VECTORS_HIGH, 366 &kernel_pt_table[KERNEL_PT_SYS]); 367 for (i = 0; i < KERNEL_PT_KERN_NUM; i++) 368 pmap_link_l2pt(l1pagetable, KERNBASE + i * 0x100000, 369 &kernel_pt_table[KERNEL_PT_KERN + i]); 370 pmap_map_chunk(l1pagetable, KERNBASE, KERNPHYSADDR, 371 (((uint32_t)(lastaddr) - KERNBASE) + PAGE_SIZE) & ~(PAGE_SIZE - 1), 372 VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE); 373 afterkern = round_page((lastaddr + L1_S_SIZE) & ~(L1_S_SIZE 374 - 1)); 375 for (i = 0; i < KERNEL_PT_AFKERNEL_NUM; i++) { 376 pmap_link_l2pt(l1pagetable, afterkern + i * 0x00100000, 377 &kernel_pt_table[KERNEL_PT_AFKERNEL + i]); 378 } 379 380 /* Map the vector page. */ 381 pmap_map_entry(l1pagetable, ARM_VECTORS_HIGH, systempage.pv_pa, 382 VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE); 383 /* Map the stack pages */ 384 pmap_map_chunk(l1pagetable, irqstack.pv_va, irqstack.pv_pa, 385 IRQ_STACK_SIZE * PAGE_SIZE, VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE); 386 pmap_map_chunk(l1pagetable, abtstack.pv_va, abtstack.pv_pa, 387 ABT_STACK_SIZE * PAGE_SIZE, VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE); 388 pmap_map_chunk(l1pagetable, undstack.pv_va, undstack.pv_pa, 389 UND_STACK_SIZE * PAGE_SIZE, VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE); 390 pmap_map_chunk(l1pagetable, kernelstack.pv_va, kernelstack.pv_pa, 391 KSTACK_PAGES * PAGE_SIZE, VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE); 392 393 pmap_map_chunk(l1pagetable, kernel_l1pt.pv_va, kernel_l1pt.pv_pa, 394 L1_TABLE_SIZE, VM_PROT_READ|VM_PROT_WRITE, PTE_PAGETABLE); 395 pmap_map_chunk(l1pagetable, msgbufpv.pv_va, msgbufpv.pv_pa, 396 MSGBUF_SIZE, VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE); 397 398 399 for (loop = 0; loop < NUM_KERNEL_PTS; ++loop) { 400 pmap_map_chunk(l1pagetable, kernel_pt_table[loop].pv_va, 401 kernel_pt_table[loop].pv_pa, L2_TABLE_SIZE, 402 VM_PROT_READ|VM_PROT_WRITE, PTE_PAGETABLE); 403 } 404 405 pmap_devmap_bootstrap(l1pagetable, kb920x_devmap); 406 cpu_domains((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2)) | DOMAIN_CLIENT); 407 setttb(kernel_l1pt.pv_pa); 408 cpu_tlb_flushID(); 409 cpu_domains(DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2)); 410 cninit(); 411 memsize = board_init(); 412 physmem = memsize / PAGE_SIZE; 413 414 /* 415 * Pages were allocated during the secondary bootstrap for the 416 * stacks for different CPU modes. 417 * We must now set the r13 registers in the different CPU modes to 418 * point to these stacks. 419 * Since the ARM stacks use STMFD etc. we must set r13 to the top end 420 * of the stack memory. 421 */ 422 423 cpu_control(CPU_CONTROL_MMU_ENABLE, CPU_CONTROL_MMU_ENABLE); 424 set_stackptr(PSR_IRQ32_MODE, 425 irqstack.pv_va + IRQ_STACK_SIZE * PAGE_SIZE); 426 set_stackptr(PSR_ABT32_MODE, 427 abtstack.pv_va + ABT_STACK_SIZE * PAGE_SIZE); 428 set_stackptr(PSR_UND32_MODE, 429 undstack.pv_va + UND_STACK_SIZE * PAGE_SIZE); 430 431 432 433 /* 434 * We must now clean the cache again.... 435 * Cleaning may be done by reading new data to displace any 436 * dirty data in the cache. This will have happened in setttb() 437 * but since we are boot strapping the addresses used for the read 438 * may have just been remapped and thus the cache could be out 439 * of sync. A re-clean after the switch will cure this. 440 * After booting there are no gross reloations of the kernel thus 441 * this problem will not occur after initarm(). 442 */ 443 cpu_idcache_wbinv_all(); 444 445 /* Set stack for exception handlers */ 446 447 data_abort_handler_address = (u_int)data_abort_handler; 448 prefetch_abort_handler_address = (u_int)prefetch_abort_handler; 449 undefined_handler_address = (u_int)undefinedinstruction_bounce; 450 undefined_init(); 451 452 proc_linkup(&proc0, &thread0); 453 thread0.td_kstack = kernelstack.pv_va; 454 thread0.td_pcb = (struct pcb *) 455 (thread0.td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1; 456 thread0.td_pcb->pcb_flags = 0; 457 thread0.td_frame = &proc0_tf; 458 pcpup->pc_curpcb = thread0.td_pcb; 459 460 arm_vector_init(ARM_VECTORS_HIGH, ARM_VEC_ALL); 461 462 pmap_curmaxkvaddr = afterkern + 0x100000 * (KERNEL_PT_KERN_NUM - 1); 463 /* 464 * ARM_USE_SMALL_ALLOC uses dump_avail, so it must be filled before 465 * calling pmap_bootstrap. 466 */ 467 dump_avail[0] = KERNPHYSADDR; 468 dump_avail[1] = KERNPHYSADDR + memsize; 469 dump_avail[2] = 0; 470 dump_avail[3] = 0; 471 472 pmap_bootstrap(freemempos, 473 KERNVIRTADDR + 3 * memsize, 474 &kernel_l1pt); 475 msgbufp = (void*)msgbufpv.pv_va; 476 msgbufinit(msgbufp, MSGBUF_SIZE); 477 mutex_init(); 478 479 i = 0; 480 481 phys_avail[0] = virtual_avail - KERNVIRTADDR + KERNPHYSADDR; 482 phys_avail[1] = KERNPHYSADDR + memsize; 483 phys_avail[2] = 0; 484 phys_avail[3] = 0; 485 /* Do basic tuning, hz etc */ 486 init_param1(); 487 init_param2(physmem); 488 kdb_init(); 489 return ((void *)(kernelstack.pv_va + USPACE_SVC_STACK_TOP - 490 sizeof(struct pcb))); 491} 492