1178173Simp/*- 2178173Simp * Copyright (C) 2007 by Oleksandr Tymoshenko. All rights reserved. 3178173Simp * 4178173Simp * Redistribution and use in source and binary forms, with or without 5178173Simp * modification, are permitted provided that the following conditions 6178173Simp * are met: 7178173Simp * 1. Redistributions of source code must retain the above copyright 8178173Simp * notice, this list of conditions and the following disclaimer. 9178173Simp * 2. Redistributions in binary form must reproduce the above copyright 10178173Simp * notice, this list of conditions and the following disclaimer in the 11178173Simp * documentation and/or other materials provided with the distribution. 12178173Simp * 13178173Simp * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 14178173Simp * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 15178173Simp * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 16178173Simp * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT, 17178173Simp * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 18178173Simp * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19178173Simp * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20178173Simp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 21178173Simp * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 22178173Simp * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 23178173Simp * THE POSSIBILITY OF SUCH DAMAGE. 24178173Simp * 25178173Simp */ 26178173Simp 27178173Simp#include <sys/cdefs.h> 28178173Simp__FBSDID("$FreeBSD: releng/10.2/sys/mips/adm5120/adm5120_machdep.c 247297 2013-02-26 01:00:11Z attilio $"); 29178173Simp 30178173Simp#include "opt_ddb.h" 31178173Simp 32178173Simp#include <sys/param.h> 33178173Simp#include <sys/conf.h> 34178173Simp#include <sys/kernel.h> 35178173Simp#include <sys/systm.h> 36178173Simp#include <sys/imgact.h> 37178173Simp#include <sys/bio.h> 38178173Simp#include <sys/buf.h> 39178173Simp#include <sys/bus.h> 40178173Simp#include <sys/cpu.h> 41178173Simp#include <sys/cons.h> 42178173Simp#include <sys/exec.h> 43178173Simp#include <sys/ucontext.h> 44178173Simp#include <sys/proc.h> 45178173Simp#include <sys/kdb.h> 46178173Simp#include <sys/ptrace.h> 47178173Simp#include <sys/reboot.h> 48178173Simp#include <sys/signalvar.h> 49178173Simp#include <sys/sysent.h> 50178173Simp#include <sys/sysproto.h> 51178173Simp#include <sys/user.h> 52178173Simp 53178173Simp#include <vm/vm.h> 54178173Simp#include <vm/vm_object.h> 55178173Simp#include <vm/vm_page.h> 56178173Simp 57178173Simp#include <machine/cache.h> 58178173Simp#include <machine/clock.h> 59178173Simp#include <machine/cpu.h> 60178173Simp#include <machine/cpuinfo.h> 61178173Simp#include <machine/cpufunc.h> 62178173Simp#include <machine/cpuregs.h> 63178173Simp#include <machine/hwfunc.h> 64178173Simp#include <machine/intr_machdep.h> 65178173Simp#include <machine/locore.h> 66178173Simp#include <machine/md_var.h> 67178173Simp#include <machine/pte.h> 68178173Simp#include <machine/sigframe.h> 69178173Simp#include <machine/trap.h> 70178173Simp#include <machine/vmparam.h> 71178173Simp 72178173Simpextern int *edata; 73178173Simpextern int *end; 74178173Simp 75202037Simpvoid 76202037Simpplatform_cpu_init() 77202037Simp{ 78202037Simp /* Nothing special */ 79202037Simp} 80202037Simp 81178173Simpstatic void 82178173Simpmips_init(void) 83178173Simp{ 84178173Simp int i; 85178173Simp 86178173Simp printf("entry: mips_init()\n"); 87178173Simp 88178173Simp bootverbose = 1; 89178173Simp realmem = btoc(16 << 20); 90178173Simp 91178173Simp for (i = 0; i < 10; i++) { 92178173Simp phys_avail[i] = 0; 93178173Simp } 94178173Simp 95178173Simp /* phys_avail regions are in bytes */ 96202954Sgonzo phys_avail[0] = MIPS_KSEG0_TO_PHYS(kernel_kseg0_end); 97178173Simp phys_avail[1] = ctob(realmem); 98178173Simp 99216318Sgonzo dump_avail[0] = phys_avail[0]; 100216320Sgonzo dump_avail[1] = phys_avail[1]; 101216318Sgonzo 102178173Simp physmem = realmem; 103178173Simp 104178173Simp init_param1(); 105178173Simp init_param2(physmem); 106178173Simp mips_cpu_init(); 107178173Simp pmap_bootstrap(); 108178173Simp mips_proc0_init(); 109178173Simp mutex_init(); 110178173Simp kdb_init(); 111202849Simp#ifdef KDB 112202849Simp if (boothowto & RB_KDB) 113202849Simp kdb_enter(KDB_WHY_BOOTFLAGS, "Boot flags requested debugger"); 114178173Simp#endif 115178173Simp} 116178173Simp 117178173Simpvoid 118178173Simpplatform_reset(void) 119178173Simp{ 120178173Simp 121178173Simp __asm __volatile("li $25, 0xbfc00000"); 122178173Simp __asm __volatile("j $25"); 123178173Simp} 124178173Simp 125178173Simpvoid 126178173Simpplatform_start(__register_t a0 __unused, __register_t a1 __unused, 127178173Simp __register_t a2 __unused, __register_t a3 __unused) 128178173Simp{ 129178173Simp vm_offset_t kernend; 130178173Simp uint64_t platform_counter_freq = 175 * 1000 * 1000; 131178173Simp 132178173Simp /* clear the BSS and SBSS segments */ 133202954Sgonzo kernend = (vm_offset_t)&end; 134178173Simp memset(&edata, 0, kernend - (vm_offset_t)(&edata)); 135178173Simp 136202954Sgonzo mips_postboot_fixup(); 137202954Sgonzo 138202037Simp /* Initialize pcpu stuff */ 139202037Simp mips_pcpu0_init(); 140202037Simp 141178173Simp cninit(); 142178173Simp mips_init(); 143178173Simp mips_timer_init_params(platform_counter_freq, 0); 144178173Simp} 145